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-file-monitor.c File Reference
#include "config.h"
#include <glib.h>
#include <gio/gio.h>
#include "ev-file-monitor.h"
+ Include dependency graph for ev-file-monitor.c:

Go to the source code of this file.

Data Structures

struct  _EvFileMonitorPrivate
 

Macros

#define EV_FILE_MONITOR_GET_PRIVATE(object)   (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_FILE_MONITOR, EvFileMonitorPrivate))
 

Enumerations

enum  { CHANGED, N_SIGNALS }
 

Functions

static void ev_file_monitor_timeout_start (EvFileMonitor *ev_monitor)
 
static void ev_file_monitor_timeout_stop (EvFileMonitor *ev_monitor)
 
static void ev_file_monitor_changed_cb (GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent event_type, EvFileMonitor *ev_monitor)
 
static void ev_file_monitor_init (EvFileMonitor *ev_monitor)
 
static void ev_file_monitor_finalize (GObject *object)
 
static void ev_file_monitor_class_init (EvFileMonitorClass *klass)
 
static gboolean timeout_cb (EvFileMonitor *ev_monitor)
 
EvFileMonitorev_file_monitor_new (const gchar *uri)
 

Variables

static guint signals [N_SIGNALS]
 

Macro Definition Documentation

#define EV_FILE_MONITOR_GET_PRIVATE (   object)    (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_FILE_MONITOR, EvFileMonitorPrivate))

Definition at line 47 of file ev-file-monitor.c.

Enumeration Type Documentation

anonymous enum
Enumerator
CHANGED 
N_SIGNALS 

Definition at line 28 of file ev-file-monitor.c.

28  {
29  CHANGED,
30  N_SIGNALS
31 };

Function Documentation

static void ev_file_monitor_changed_cb ( GFileMonitor *  monitor,
GFile *  file,
GFile *  other_file,
GFileMonitorEvent  event_type,
EvFileMonitor ev_monitor 
)
static

Definition at line 126 of file ev-file-monitor.c.

131 {
132  switch (event_type) {
133  case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
134  ev_file_monitor_timeout_stop (ev_monitor);
135  g_signal_emit (ev_monitor, signals[CHANGED], 0);
136 
137  break;
138  case G_FILE_MONITOR_EVENT_CHANGED:
139  ev_file_monitor_timeout_start (ev_monitor);
140  break;
141  default:
142  break;
143  }
144 }

+ Here is the caller graph for this function:

static void ev_file_monitor_class_init ( EvFileMonitorClass klass)
static

Definition at line 79 of file ev-file-monitor.c.

80 {
81  GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
82 
83  g_type_class_add_private (g_object_class, sizeof (EvFileMonitorPrivate));
84 
85  g_object_class->finalize = ev_file_monitor_finalize;
86 
87  /* Signals */
88  signals[CHANGED] =
89  g_signal_new ("changed",
91  G_SIGNAL_RUN_LAST,
92  G_STRUCT_OFFSET (EvFileMonitorClass, changed),
93  NULL, NULL,
94  g_cclosure_marshal_VOID__VOID,
95  G_TYPE_NONE, 0);
96 }
static void ev_file_monitor_finalize ( GObject *  object)
static

Definition at line 61 of file ev-file-monitor.c.

62 {
63  EvFileMonitor *ev_monitor = EV_FILE_MONITOR (object);
64 
65  ev_file_monitor_timeout_stop (ev_monitor);
66 
67  if (ev_monitor->priv->monitor) {
68  g_signal_handlers_disconnect_by_func (ev_monitor->priv->monitor,
70  ev_monitor);
71  g_object_unref (ev_monitor->priv->monitor);
72  ev_monitor->priv->monitor = NULL;
73  }
74 
75  G_OBJECT_CLASS (ev_file_monitor_parent_class)->finalize (object);
76 }

+ Here is the caller graph for this function:

static void ev_file_monitor_init ( EvFileMonitor ev_monitor)
static

Definition at line 55 of file ev-file-monitor.c.

56 {
57  ev_monitor->priv = EV_FILE_MONITOR_GET_PRIVATE (ev_monitor);
58 }
EvFileMonitor* ev_file_monitor_new ( const gchar *  uri)

Definition at line 147 of file ev-file-monitor.c.

148 {
149  EvFileMonitor *ev_monitor;
150  GFile *file;
151  GError *error = NULL;
152 
153  ev_monitor = EV_FILE_MONITOR (g_object_new (EV_TYPE_FILE_MONITOR, NULL));
154 
155  file = g_file_new_for_uri (uri);
156  ev_monitor->priv->monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, &error);
157  if (ev_monitor->priv->monitor) {
158  g_signal_connect (ev_monitor->priv->monitor, "changed",
159  G_CALLBACK (ev_file_monitor_changed_cb), ev_monitor);
160  } else if (error) {
161  g_warning ("%s", error->message);
162  g_error_free (error);
163  }
164 
165  g_object_unref (file);
166 
167  return ev_monitor;
168 }

+ Here is the caller graph for this function:

static void ev_file_monitor_timeout_start ( EvFileMonitor ev_monitor)
static

Definition at line 108 of file ev-file-monitor.c.

109 {
110  ev_file_monitor_timeout_stop (ev_monitor);
111 
112  ev_monitor->priv->timeout_id =
113  g_timeout_add_seconds (5, (GSourceFunc)timeout_cb, ev_monitor);
114 }

+ Here is the caller graph for this function:

static void ev_file_monitor_timeout_stop ( EvFileMonitor ev_monitor)
static

Definition at line 117 of file ev-file-monitor.c.

118 {
119  if (ev_monitor->priv->timeout_id > 0) {
120  g_source_remove (ev_monitor->priv->timeout_id);
121  ev_monitor->priv->timeout_id = 0;
122  }
123 }

+ Here is the caller graph for this function:

static gboolean timeout_cb ( EvFileMonitor ev_monitor)
static

Definition at line 99 of file ev-file-monitor.c.

100 {
101  g_signal_emit (ev_monitor, signals[CHANGED], 0);
102 
103  ev_monitor->priv->timeout_id = 0;
104  return FALSE;
105 }

+ Here is the caller graph for this function:

Variable Documentation

guint signals[N_SIGNALS]
static

Definition at line 52 of file ev-file-monitor.c.