eel r2119 - in trunk: . eel



Author: ssp
Date: Mon Jun  2 01:02:48 2008
New Revision: 2119
URL: http://svn.gnome.org/viewvc/eel?rev=2119&view=rev

Log:
Sun Jun  1 21:02:00 2008  SÃren Sandmann  <sandmann redhat com>

	* eel/eel-background.c: Don't store the image_uri - instead rely
	on getting it from GnomeBG.



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	Mon Jun  2 01:02:48 2008
@@ -49,8 +49,6 @@
 static void       eel_background_init                      (gpointer       object,
 							    gpointer       klass);
 static void       eel_background_finalize                  (GObject       *object);
-static void       eel_background_reload_image              (EelBackground *background);
-static void       eel_background_ensure_image_nonswapped   (EelBackground *background);
 static GdkPixmap *eel_background_get_pixmap_and_color      (EelBackground *background,
 							    GdkWindow     *window,
 							    GdkColor      *color,
@@ -76,7 +74,6 @@
 struct EelBackgroundDetails {
 	char *color;
 	
-	char *image_uri;
 	time_t image_mtime;
 	GnomeBG *bg;
 
@@ -187,7 +184,6 @@
 	background = EEL_BACKGROUND (object);
 
 	g_free (background->details->color);
-	g_free (background->details->image_uri);
 	eel_background_remove_current_image (background);
 
 	if (background->details->background_pixmap != NULL) {
@@ -263,17 +259,6 @@
 }
 
 static void
-eel_background_ensure_image_nonswapped (EelBackground *background)
-{
-	if (!background->details->is_desktop) {
-		return;
-	}
-	if (background->details->image_uri != NULL && background->details->bg == NULL) {
-		eel_background_reload_image (background);
-	}	
-}
-
-static void
 eel_background_unrealize (EelBackground *background)
 {
 	if (background->details->background_pixmap != NULL) {
@@ -319,10 +304,6 @@
 	
 	drawable_get_adjusted_size (background, window, &entire_width, &entire_height);
 	
-	/* Try to parse the color spec.  If we fail, default to the style's color */
-	
-        eel_background_ensure_image_nonswapped (background);
-
 	/* Set the default color */
 	
 	/* Get the widget to which the window belongs and its style as well */
@@ -507,9 +488,13 @@
 char *
 eel_background_get_image_uri (EelBackground *background)
 {
+	const char *filename;
+	
 	g_return_val_if_fail (EEL_IS_BACKGROUND (background), NULL);
 
-	return g_strdup (background->details->image_uri);
+	filename = gnome_bg_get_filename (background->details->bg);
+	
+	return g_filename_to_uri (filename, NULL, NULL);
 }
 
 /* Use style->base as the default color instead of bg */
@@ -532,78 +517,39 @@
 	}
 }
 
-static void
-eel_background_reload_image (EelBackground *background)
-{
-	char *filename;
-
-	filename = NULL;
-	
-	if (background->details->image_uri != NULL) {
-		filename = g_filename_from_uri (background->details->image_uri,
-						NULL, NULL);
-	}
-
-	gnome_bg_set_filename (background->details->bg, filename);
-
-	g_free (filename);
-}
-
 static gboolean
 eel_background_set_image_uri_helper (EelBackground *background,
 				     const char *image_uri,
-				     gboolean emit_setting_change,
-				     gboolean emit_appearance_change)
+				     gboolean emit_signal)
 {
-        time_t mtime;
-	GFile *f;
-	GFileInfo *info;
-
-	g_assert (EEL_IS_BACKGROUND (background));
+	char *filename;
 
-	mtime = background->details->image_mtime;
 	if (image_uri != NULL) {
-		mtime = 0;
-		f = g_file_new_for_uri (image_uri);
-		info = g_file_query_info (f, G_FILE_ATTRIBUTE_TIME_MODIFIED, 0, NULL, NULL);
-		g_object_unref (f);
-		if (info != NULL) {
-			mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
-			g_object_unref (info);
-		}
+		filename = g_filename_from_uri (image_uri, NULL, NULL);
 	}
-	if (eel_strcmp (background->details->image_uri, image_uri) == 0 &&
-	    mtime == background->details->image_mtime) {
-		return FALSE;
+	else {
+		filename = NULL;
 	}
-
-	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
-	 * image loads - in eel_background_load_image_callback. This way the
-	 * current image can be used if an update is needed before the load completes.
-	 */
 	
-	eel_background_reload_image (background);
-	
-	if (emit_setting_change) {
+	gnome_bg_set_filename (background->details->bg, filename);
+
+	if (emit_signal) {
 		g_signal_emit (GTK_OBJECT (background), signals[SETTINGS_CHANGED], 0, GDK_ACTION_COPY);
 	}
 
 	set_image_properties (background);
 	
+	g_free (filename);
+	
 	return TRUE;
 }
 
 void
 eel_background_set_image_uri (EelBackground *background, const char *image_uri)
 {
-	eel_background_set_image_uri_helper (background, image_uri, TRUE, TRUE);
+	
+	
+	eel_background_set_image_uri_helper (background, image_uri, TRUE);
 }
 
 /* Use this fn to set both the image and color and avoid flash. The color isn't
@@ -614,12 +560,7 @@
 eel_background_set_image_uri_and_color (EelBackground *background, GdkDragAction action,
 					const char *image_uri, const char *color)
 {
-	if (eel_strcmp (background->details->color, color) == 0 &&
-	    eel_strcmp (background->details->image_uri, image_uri) == 0) {
-		return;
-	}
-
-	eel_background_set_image_uri_helper (background, image_uri, FALSE, FALSE);
+	eel_background_set_image_uri_helper (background, image_uri, FALSE);
 	eel_background_set_color (background, color);
 
 	/* We always emit, even if the color didn't change, because the image change
@@ -654,7 +595,7 @@
 	g_assert (EEL_IS_BACKGROUND (background));
 
 	return background->details->color != NULL
-		|| background->details->image_uri != NULL;
+		|| gnome_bg_get_filename (background->details->bg) != NULL;
 }
 
 /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]