eel r2112 - in trunk: . eel test



Author: ssp
Date: Sat May 31 02:15:40 2008
New Revision: 2112
URL: http://svn.gnome.org/viewvc/eel?rev=2112&view=rev

Log:
Fri May 30 22:13:51 2008  SÃren Sandmann  <sandmann redhat com>

	* eel/eel-background.[ch]: Rename eel_background_set/get_image_uri()
	to set/get_image_filename() to reflect the fact that only local
	files works.



Modified:
   trunk/ChangeLog
   trunk/eel/eel-background.c
   trunk/eel/eel-background.h
   trunk/test/test-eel-background.c
   trunk/test/test.c

Modified: trunk/eel/eel-background.c
==============================================================================
--- trunk/eel/eel-background.c	(original)
+++ trunk/eel/eel-background.c	Sat May 31 02:15:40 2008
@@ -56,7 +56,7 @@
 							    GdkColor      *color,
 							    gboolean      *changes_with_size);
 static void        eel_background_update_file_monitor      (EelBackground *background,
-							    const char    *image_uri);
+							    const char    *image_filename);
 static void set_image_properties (EelBackground *background);
 
 EEL_CLASS_BOILERPLATE (EelBackground, eel_background, GTK_TYPE_OBJECT)
@@ -78,7 +78,7 @@
 struct EelBackgroundDetails {
 	char *color;
 	
-	char *image_uri;
+	char *image_filename;
 	time_t image_mtime;
 	GFileMonitor *image_file_monitor;
 	GnomeBG *bg;
@@ -170,7 +170,7 @@
 }
 
 /* The safe way to clear an image from a background is:
- * 		eel_background_set_image_uri (NULL);
+ * 		eel_background_set_image_filename (NULL);
  * This fn is a private utility - it does NOT clear
  * the details->bg_uri setting.
  */
@@ -193,7 +193,7 @@
 	eel_background_update_file_monitor (background, NULL);
 
 	g_free (background->details->color);
-	g_free (background->details->image_uri);
+	g_free (background->details->image_filename);
 	eel_background_remove_current_image (background);
 
 	if (background->details->background_pixmap != NULL) {
@@ -239,7 +239,7 @@
 	if (!background->details->is_desktop) {
 		return;
 	}
-	if (background->details->image_uri != NULL && background->details->bg == NULL) {
+	if (background->details->image_filename != NULL && background->details->bg == NULL) {
 		eel_background_reload_image (background);
 	}	
 }
@@ -501,11 +501,11 @@
 }
 
 char *
-eel_background_get_image_uri (EelBackground *background)
+eel_background_get_image_filename (EelBackground *background)
 {
 	g_return_val_if_fail (EEL_IS_BACKGROUND (background), NULL);
 
-	return g_strdup (background->details->image_uri);
+	return g_strdup (background->details->image_filename);
 }
 
 /* Use style->base as the default color instead of bg */
@@ -531,7 +531,7 @@
 static void
 eel_background_reload_image (EelBackground *background)
 {
-	gnome_bg_set_uri (background->details->bg, background->details->image_uri);
+	gnome_bg_set_uri (background->details->bg, background->details->image_filename);
 }
 
 static void
@@ -545,16 +545,16 @@
 
 	background = EEL_BACKGROUND (user_data);
 
-	eel_background_set_image_uri (background, background->details->image_uri);
+	eel_background_set_image_filename (background, background->details->image_filename);
 }
 
 static void
 eel_background_update_file_monitor (EelBackground *background,
-				    const char *image_uri)
+				    const char *image_filename)
 {
 	GFile *f;
 
-	if (eel_strcmp (background->details->image_uri, image_uri) == 0) {
+	if (eel_strcmp (background->details->image_filename, image_filename) == 0) {
 		return;
 	}
 
@@ -563,8 +563,8 @@
 		background->details->image_file_monitor = NULL;
 	}
 
-	if (image_uri != NULL) {
-		f = g_file_new_for_uri (image_uri);
+	if (image_filename != NULL) {
+		f = g_file_new_for_uri (image_filename);
 
 		background->details->image_file_monitor = g_file_monitor_file (f, 0, NULL, NULL);
 		g_signal_connect (background->details->image_file_monitor, "changed",
@@ -574,10 +574,9 @@
 }
 
 static gboolean
-eel_background_set_image_uri_helper (EelBackground *background,
-				     const char *image_uri,
-				     gboolean emit_setting_change,
-				     gboolean emit_appearance_change)
+eel_background_set_image_filename_helper (EelBackground *background,
+					  const char *image_filename,
+					  gboolean emit_changed)
 {
         time_t mtime;
 	GFile *f;
@@ -586,9 +585,9 @@
 	g_assert (EEL_IS_BACKGROUND (background));
 
 	mtime = background->details->image_mtime;
-	if (image_uri != NULL) {
+	if (image_filename != NULL) {
 		mtime = 0;
-		f = g_file_new_for_uri (image_uri);
+		f = g_file_new_for_uri (image_filename);
 		info = g_file_query_info (f, G_FILE_ATTRIBUTE_TIME_MODIFIED, 0, NULL, NULL);
 		g_object_unref (f);
 		if (info != NULL) {
@@ -596,16 +595,16 @@
 			g_object_unref (info);
 		}
 	}
-	if (eel_strcmp (background->details->image_uri, image_uri) == 0 &&
+	if (eel_strcmp (background->details->image_filename, image_filename) == 0 &&
 	    mtime == background->details->image_mtime) {
 		return FALSE;
 	}
 
-	eel_background_update_file_monitor (background, image_uri);
+	eel_background_update_file_monitor (background, image_filename);
 
-	if (image_uri != background->details->image_uri) {
-		g_free (background->details->image_uri);
-		background->details->image_uri = g_strdup (image_uri);
+	if (image_filename != background->details->image_filename) {
+		g_free (background->details->image_filename);
+		background->details->image_filename = g_strdup (image_filename);
 	}
 
         background->details->image_mtime = mtime;
@@ -617,7 +616,7 @@
 	
 	eel_background_reload_image (background);
 	
-	if (emit_setting_change) {
+	if (emit_changed) {
 		g_signal_emit (GTK_OBJECT (background), signals[SETTINGS_CHANGED], 0, GDK_ACTION_COPY);
 	}
 
@@ -627,9 +626,9 @@
 }
 
 void
-eel_background_set_image_uri (EelBackground *background, const char *image_uri)
+eel_background_set_image_filename (EelBackground *background, const char *image_filename)
 {
-	eel_background_set_image_uri_helper (background, image_uri, TRUE, TRUE);
+	eel_background_set_image_filename_helper (background, image_filename, TRUE);
 }
 
 /* Use this fn to set both the image and color and avoid flash. The color isn't
@@ -637,15 +636,15 @@
  * before then, it will use the old color and image.
  */
 static void
-eel_background_set_image_uri_and_color (EelBackground *background, GdkDragAction action,
-					const char *image_uri, const char *color)
+eel_background_set_image_filename_and_color (EelBackground *background, GdkDragAction action,
+					     const char *image_filename, const char *color)
 {
 	if (eel_strcmp (background->details->color, color) == 0 &&
-	    eel_strcmp (background->details->image_uri, image_uri) == 0) {
+	    eel_strcmp (background->details->image_filename, image_filename) == 0) {
 		return;
 	}
 
-	eel_background_set_image_uri_helper (background, image_uri, FALSE, FALSE);
+	eel_background_set_image_filename_helper (background, image_filename, FALSE);
 	eel_background_set_color (background, color);
 
 	/* We always emit, even if the color didn't change, because the image change
@@ -658,15 +657,15 @@
 void
 eel_background_receive_dropped_background_image (EelBackground *background,
 						 GdkDragAction action,
-						 const char *image_uri)
+						 const char *image_filename)
 {
 	/* Currently, we only support tiled images. So we set the placement.
-	 * We rely on eel_background_set_image_uri_and_color to emit
+	 * We rely on eel_background_set_image_filename_and_color to emit
 	 * the SETTINGS_CHANGED & APPEARANCE_CHANGE signals.
 	 */
 	eel_background_set_image_placement (background, EEL_BACKGROUND_TILED);
 	
-	eel_background_set_image_uri_and_color (background, action, image_uri, NULL);
+	eel_background_set_image_filename_and_color (background, action, image_filename, NULL);
 }
 
 /**
@@ -680,7 +679,7 @@
 	g_assert (EEL_IS_BACKGROUND (background));
 
 	return background->details->color != NULL
-		|| background->details->image_uri != NULL;
+		|| background->details->image_filename != NULL;
 }
 
 /**
@@ -984,7 +983,7 @@
 	
 	g_free (color_spec);
 
-	eel_background_set_image_uri_and_color (background, action, NULL, new_gradient_spec);
+	eel_background_set_image_filename_and_color (background, action, NULL, new_gradient_spec);
 
 	g_free (new_gradient_spec);
 }

Modified: trunk/eel/eel-background.h
==============================================================================
--- trunk/eel/eel-background.h	(original)
+++ trunk/eel/eel-background.h	Sat May 31 02:15:40 2008
@@ -76,8 +76,8 @@
 									     gboolean                     use_base);
 void                        eel_background_set_color                        (EelBackground               *background,
 									     const char                  *color_or_gradient);
-void                        eel_background_set_image_uri                    (EelBackground               *background,
-									     const char                  *image_uri);
+void                        eel_background_set_image_filename               (EelBackground               *background,
+									     const char                  *image_filename);
 
 void                        eel_background_reset                            (EelBackground               *background);
 void                        eel_background_set_image_placement              (EelBackground               *background,
@@ -91,7 +91,7 @@
 
 /* Calls to interrogate the current state of a background. */
 char *                      eel_background_get_color                        (EelBackground               *background);
-char *                      eel_background_get_image_uri                    (EelBackground               *background);
+char *                      eel_background_get_image_filename               (EelBackground               *background);
 EelBackgroundImagePlacement eel_background_get_image_placement              (EelBackground               *background);
 gboolean                    eel_background_is_dark                          (EelBackground               *background);
 gboolean                    eel_background_is_set                           (EelBackground               *background);
@@ -111,7 +111,7 @@
 /* Handles a special-case image name that means "reset to default background" too. */
 void                        eel_background_receive_dropped_background_image (EelBackground               *background,
 									     GdkDragAction                action,
-									     const char                  *image_uri);
+									     const char                  *image_filename);
 
 /* Gets or creates a background so that it's attached to a widget. */
 EelBackground *             eel_get_widget_background                       (GtkWidget                   *widget);

Modified: trunk/test/test-eel-background.c
==============================================================================
--- trunk/test/test-eel-background.c	(original)
+++ trunk/test/test-eel-background.c	Sat May 31 02:15:40 2008
@@ -13,7 +13,7 @@
 {
 	GtkWidget *window;
 	EelBackground *background;
-	char *image_uri;
+	char *image_filename;
 #if 0
 	char *titles[] = { "test 1", "test 2", "test 3"};
 #endif
@@ -33,12 +33,12 @@
 	eel_background_set_color (background,
 				  "red-blue:h");
 
-	image_uri = g_filename_to_uri (PATTERNS_DIR "/50s.png", NULL, NULL);
+	image_filename = g_filename_to_uri (PATTERNS_DIR "/50s.png", NULL, NULL);
 
 #if 1
-	eel_background_set_image_uri (background, image_uri);
+	eel_background_set_image_filename (background, image_filename);
 #endif
-	g_free (image_uri);
+	g_free (image_filename);
 
 
 	gtk_widget_show_all (window);

Modified: trunk/test/test.c
==============================================================================
--- trunk/test/test.c	(original)
+++ trunk/test/test.c	Sat May 31 02:15:40 2008
@@ -67,7 +67,7 @@
 				      const char *image_name)
 {
 	EelBackground *background;
-	char *path, *uri;
+	char *path;
 
 	g_return_if_fail (GTK_IS_WIDGET (widget));
 	g_return_if_fail (image_name != NULL);
@@ -75,12 +75,10 @@
 	background = eel_get_widget_background (widget);
 	
 	path = g_strconcat ("EEL_DATADIR", image_name, NULL);
-	uri = g_filename_to_uri (path, NULL, NULL);
-	g_free (path);
 
-	eel_background_set_image_uri (background, uri);
+	eel_background_set_image_filename (background, path);
 
-	g_free (uri);
+	g_free (path);
 }
 
 void



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