Commit 81123eac authored by Stephan Arts's avatar Stephan Arts

Monitor for file-changes

parent 8f0c954a
......@@ -41,6 +41,15 @@ static guint rstto_thumbnail_size[] =
THUMBNAIL_SIZE_VERY_LARGE_SIZE
};
enum
{
RSTTO_FILE_SIGNAL_CHANGED = 0,
RSTTO_FILE_SIGNAL_COUNT
};
static gint
rstto_file_signals[RSTTO_FILE_SIGNAL_COUNT];
static void
rstto_file_init (GObject *);
static void
......@@ -142,6 +151,17 @@ rstto_file_class_init (GObjectClass *object_class)
object_class->set_property = rstto_file_set_property;
object_class->get_property = rstto_file_get_property;
rstto_file_signals[RSTTO_FILE_SIGNAL_CHANGED] = g_signal_new("changed",
G_TYPE_FROM_CLASS(object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
0,
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0,
NULL);
}
/**
......@@ -503,3 +523,13 @@ rstto_file_get_thumbnail (
return r_file->priv->thumbnails[size];
}
void
rstto_file_changed ( RsttoFile *r_file )
{
g_signal_emit (
G_OBJECT (r_file),
rstto_file_signals[RSTTO_FILE_SIGNAL_CHANGED],
0,
NULL);
}
......@@ -106,6 +106,9 @@ rstto_file_set_orientation (
gboolean
rstto_file_has_exif ( RsttoFile * );
void
rstto_file_changed ( RsttoFile * );
G_END_DECLS
......
......@@ -671,6 +671,10 @@ rstto_image_list_set_directory (
rstto_image_list_remove_all (image_list);
rstto_image_list_monitor_dir (
image_list,
dir );
/* Allow all images to be removed by providing NULL to dir */
if ( NULL != dir )
{
......@@ -773,10 +777,6 @@ cb_rstto_read_file ( gpointer user_data )
g_object_unref (loader->files[i]);
}
rstto_image_list_monitor_dir (
loader->image_list,
loader->dir );
/* This is a hack, use a closure */
if (loader->image_list->priv->directory_loader != 0)
{
......@@ -845,6 +845,7 @@ cb_file_monitor_changed (
{
RsttoImageList *image_list = RSTTO_IMAGE_LIST (user_data);
RsttoFile *r_file = rstto_file_new (file);
GSList *iter = NULL;
switch ( event_type )
{
......@@ -892,6 +893,9 @@ cb_file_monitor_changed (
monitor);
}
break;
case G_FILE_MONITOR_EVENT_CHANGED:
rstto_file_changed (r_file);
break;
default:
break;
}
......@@ -966,7 +970,6 @@ rstto_image_list_iter_class_init(RsttoImageListIterClass *iter_class)
G_TYPE_NONE,
0,
NULL);
}
static void
......
......@@ -198,6 +198,11 @@ rstto_image_viewer_get_property (
GValue *value,
GParamSpec *pspec);
static void
cb_rstto_image_viewer_file_changed (
RsttoFile *r_file,
RsttoImageViewer *viewer );
static void
rstto_image_viewer_set_motion_state (RsttoImageViewer *viewer, RsttoImageViewerMotionState state);
......@@ -429,6 +434,13 @@ rstto_image_viewer_class_init(RsttoImageViewerClass *viewer_class)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_new ("status-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_new ("files-dnd",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
......@@ -1594,6 +1606,15 @@ rstto_image_viewer_set_file (
}
g_object_ref (file);
g_signal_connect (
file,
"changed",
G_CALLBACK (cb_rstto_image_viewer_file_changed),
viewer);
g_signal_handlers_disconnect_by_func (
viewer->priv->file,
cb_rstto_image_viewer_file_changed,
viewer );
g_object_unref (viewer->priv->file);
viewer->priv->file = file;
......@@ -1614,6 +1635,11 @@ rstto_image_viewer_set_file (
}
else
{
g_signal_connect (
file,
"changed",
G_CALLBACK (cb_rstto_image_viewer_file_changed),
viewer);
g_object_ref (file);
viewer->priv->file = file;
rstto_image_viewer_load_image (viewer, viewer->priv->file, scale);
......@@ -1646,6 +1672,10 @@ rstto_image_viewer_set_file (
}
if (viewer->priv->file)
{
g_signal_handlers_disconnect_by_func (
viewer->priv->file,
cb_rstto_image_viewer_file_changed,
viewer );
g_object_unref (viewer->priv->file);
viewer->priv->file = NULL;
......@@ -2902,3 +2932,16 @@ rstto_image_viewer_is_busy (
}
return FALSE;
}
static void
cb_rstto_image_viewer_file_changed (
RsttoFile *r_file,
RsttoImageViewer *viewer )
{
rstto_image_viewer_load_image (
viewer,
r_file,
viewer->priv->scale);
g_signal_emit_by_name(viewer, "status-changed");
}
......@@ -1088,6 +1088,7 @@ rstto_main_window_init (RsttoMainWindow *window)
g_signal_connect(G_OBJECT(window->priv->thumbnailbar), "button-press-event", G_CALLBACK(cb_rstto_main_window_navigationtoolbar_button_press_event), window);
g_signal_connect(G_OBJECT(window->priv->image_viewer), "size-ready", G_CALLBACK(cb_rstto_main_window_update_statusbar), window);
g_signal_connect(G_OBJECT(window->priv->image_viewer), "scale-changed", G_CALLBACK(cb_rstto_main_window_update_statusbar), window);
g_signal_connect(G_OBJECT(window->priv->image_viewer), "status-changed", G_CALLBACK(cb_rstto_main_window_update_statusbar), window);
g_signal_connect(G_OBJECT(window->priv->image_viewer), "files-dnd", G_CALLBACK(cb_rstto_main_window_dnd_files), window);
g_signal_connect (
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment