Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ev-media.c
Go to the documentation of this file.
1 /* this file is part of evince, a gnome document viewer
2  *
3  * Copyright (C) 2015 Igalia S.L.
4  *
5  * Evince is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * Evince is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 #include <config.h>
21 
22 #include "ev-media.h"
23 
25  guint page;
26  gchar *uri;
27  gboolean show_controls;
28 };
29 
30 G_DEFINE_TYPE (EvMedia, ev_media, G_TYPE_OBJECT)
31 
32 static void
33 ev_media_finalize (GObject *object)
34 {
35  EvMedia *media = EV_MEDIA (object);
36 
37  g_clear_pointer (&media->priv->uri, g_free);
38 
39  G_OBJECT_CLASS (ev_media_parent_class)->finalize (object);
40 }
41 
42 static void
44 {
45  GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
46 
47  g_object_class->finalize = ev_media_finalize;
48 
49  g_type_class_add_private (g_object_class, sizeof (EvMediaPrivate));
50 }
51 
52 static void
54 {
55  media->priv = G_TYPE_INSTANCE_GET_PRIVATE (media, EV_TYPE_MEDIA, EvMediaPrivate);
56 }
57 
58 EvMedia *
60  const gchar *uri)
61 {
62  EvMedia *media;
63 
64  g_return_val_if_fail (EV_IS_PAGE (page), NULL);
65  g_return_val_if_fail (uri != NULL, NULL);
66 
67  media = EV_MEDIA (g_object_new (EV_TYPE_MEDIA, NULL));
68  media->priv->page = page->index;
69  media->priv->uri = g_strdup (uri);
70 
71  return media;
72 }
73 
74 const gchar *
76 {
77  g_return_val_if_fail (EV_IS_MEDIA (media), NULL);
78 
79  return media->priv->uri;
80 }
81 
82 guint
84 {
85  g_return_val_if_fail (EV_IS_MEDIA (media), 0);
86 
87  return media->priv->page;
88 }
89 
90 gboolean
92 {
93  g_return_val_if_fail (EV_IS_MEDIA (media), FALSE);
94 
95  return media->priv->show_controls;
96 }
97 
98 void
100  gboolean show_controls)
101 {
102  g_return_if_fail (EV_IS_MEDIA (media));
103 
104  media->priv->show_controls = show_controls;
105 }