[Xfce4-commits] <ristretto:ristretto-0.3> Add per-file monitoring if a selection of files is opened
Stephan Arts
noreply at xfce.org
Sat Mar 10 21:46:03 CET 2012
Updating branch refs/heads/ristretto-0.3
to 08509337e10bd43d1d826e7de0163a9fae8b3615 (commit)
from bda4a17aa3194a31d76d2bfdfa30f6d80bd6ee51 (commit)
commit 08509337e10bd43d1d826e7de0163a9fae8b3615
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Mar 10 21:23:58 2012 +0100
Add per-file monitoring if a selection of files is opened
src/image_list.c | 41 +++++++++++++++++++++++++++++++++--------
1 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/src/image_list.c b/src/image_list.c
index 5881651..31fcb85 100644
--- a/src/image_list.c
+++ b/src/image_list.c
@@ -122,10 +122,11 @@ struct _RsttoImageListIterPriv
struct _RsttoImageListPriv
{
- GFileMonitor *monitor;
+ GFileMonitor *dir_monitor;
RsttoSettings *settings;
GtkFileFilter *filter;
+ GList *image_monitors;
GList *images;
gint n_images;
@@ -275,6 +276,7 @@ rstto_image_list_add_file (
GtkFileFilterInfo filter_info;
GList *image_iter = g_list_find (image_list->priv->images, file);
GSList *iter = image_list->priv->iterators;
+ GFileMonitor *monitor = NULL;
g_return_val_if_fail ( NULL != file , FALSE);
g_return_val_if_fail ( RSTTO_IS_FILE (file) , FALSE);
@@ -295,6 +297,23 @@ rstto_image_list_add_file (
image_list->priv->n_images++;
+ if (image_list->priv->dir_monitor == NULL)
+ {
+ monitor = g_file_monitor_file (
+ rstto_file_get_file (file),
+ G_FILE_MONITOR_NONE,
+ NULL,
+ NULL);
+ g_signal_connect (
+ G_OBJECT(monitor),
+ "changed",
+ G_CALLBACK (cb_file_monitor_changed),
+ image_list);
+ image_list->priv->image_monitors = g_list_prepend (
+ image_list->priv->image_monitors,
+ monitor);
+ }
+
g_signal_emit (G_OBJECT (image_list), rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_NEW_IMAGE], 0, file, NULL);
/** TODO: update all iterators */
while (iter)
@@ -355,8 +374,9 @@ rstto_image_list_remove_file (RsttoImageList *image_list, RsttoFile *file)
{
GSList *iter = NULL;
RsttoFile *afile = NULL;
+ gint index = g_list_index (image_list->priv->images, file);
- if (g_list_find(image_list->priv->images, file))
+ if (index != -1)
{
iter = image_list->priv->iterators;
@@ -474,10 +494,10 @@ rstto_image_list_monitor_dir (
{
GFileMonitor *monitor = NULL;
- if ( NULL != image_list->priv->monitor )
+ if ( NULL != image_list->priv->dir_monitor )
{
- g_object_unref (image_list->priv->monitor);
- image_list->priv->monitor = NULL;
+ g_object_unref (image_list->priv->dir_monitor);
+ image_list->priv->dir_monitor = NULL;
}
/* Allow a monitor to be removed by providing NULL to dir */
@@ -496,7 +516,14 @@ rstto_image_list_monitor_dir (
image_list);
}
- image_list->priv->monitor = monitor;
+ if (image_list->priv->image_monitors)
+ {
+ g_list_foreach (image_list->priv->image_monitors, (GFunc)g_object_unref, NULL);
+ g_list_free (image_list->priv->image_monitors);
+ image_list->priv->image_monitors = NULL;
+ }
+
+ image_list->priv->dir_monitor = monitor;
}
static void
@@ -510,8 +537,6 @@ cb_file_monitor_changed (
RsttoImageList *image_list = RSTTO_IMAGE_LIST (user_data);
RsttoFile *r_file = rstto_file_new (file);
- g_return_if_fail ( monitor == image_list->priv->monitor);
-
switch ( event_type )
{
case G_FILE_MONITOR_EVENT_DELETED:
More information about the Xfce4-commits
mailing list