eel r2092 - in trunk: . eel
- From: cneumair svn gnome org
- To: svn-commits-list gnome org
- Subject: eel r2092 - in trunk: . eel
- Date: Fri, 14 Mar 2008 16:41:09 +0000 (GMT)
Author: cneumair
Date: Fri Mar 14 16:41:09 2008
New Revision: 2092
URL: http://svn.gnome.org/viewvc/eel?rev=2092&view=rev
Log:
2008-03-11 Christian Neumair <cneumair gnome org>
* eel/eel-background.c: (background_image_file_changed),
(eel_background_update_file_monitor),
(eel_background_set_image_uri_helper): Update EelBackground if the
image file changes. Fixes #106613.
Modified:
trunk/ChangeLog
trunk/eel/eel-background.c
Modified: trunk/eel/eel-background.c
==============================================================================
--- trunk/eel/eel-background.c (original)
+++ trunk/eel/eel-background.c Fri Mar 14 16:41:09 2008
@@ -55,6 +55,8 @@
GdkWindow *window,
GdkColor *color,
gboolean *changes_with_size);
+static void eel_background_update_file_monitor (EelBackground *background,
+ const char *image_uri);
static void set_image_properties (EelBackground *background);
EEL_CLASS_BOILERPLATE (EelBackground, eel_background, GTK_TYPE_OBJECT)
@@ -78,6 +80,7 @@
char *image_uri;
time_t image_mtime;
+ GFileMonitor *image_file_monitor;
GnomeBG *bg;
EelBackgroundImagePlacement image_placement;
@@ -187,6 +190,8 @@
background = EEL_BACKGROUND (object);
+ eel_background_update_file_monitor (background, NULL);
+
g_free (background->details->color);
g_free (background->details->image_uri);
eel_background_remove_current_image (background);
@@ -529,6 +534,45 @@
gnome_bg_set_uri (background->details->bg, background->details->image_uri);
}
+static void
+background_image_file_changed (GFileMonitor *file_monitor,
+ GFile *child,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ gpointer user_data)
+{
+ EelBackground *background;
+
+ background = EEL_BACKGROUND (user_data);
+
+ eel_background_set_image_uri (background, background->details->image_uri);
+}
+
+static void
+eel_background_update_file_monitor (EelBackground *background,
+ const char *image_uri)
+{
+ GFile *f;
+
+ if (eel_strcmp (background->details->image_uri, image_uri) == 0) {
+ return;
+ }
+
+ if (background->details->image_file_monitor != NULL) {
+ g_object_unref (background->details->image_file_monitor);
+ background->details->image_file_monitor = NULL;
+ }
+
+ if (image_uri != NULL) {
+ f = g_file_new_for_uri (image_uri);
+
+ background->details->image_file_monitor = g_file_monitor_file (f, 0, NULL, NULL);
+ g_signal_connect (background->details->image_file_monitor, "changed",
+ G_CALLBACK (background_image_file_changed), background);
+ g_object_unref (f);
+ }
+}
+
static gboolean
eel_background_set_image_uri_helper (EelBackground *background,
const char *image_uri,
@@ -557,8 +601,13 @@
return FALSE;
}
- g_free (background->details->image_uri);
- background->details->image_uri = g_strdup (image_uri);
+ eel_background_update_file_monitor (background, image_uri);
+
+ if (image_uri != background->details->image_uri) {
+ g_free (background->details->image_uri);
+ background->details->image_uri = g_strdup (image_uri);
+ }
+
background->details->image_mtime = mtime;
/* We do not get rid of the current image here. This gets done after the new
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]