patch for handling theme changes in g-c-c shell



Hi!,

playing a bit with themes, I realized that the g-c-c shell doesn't
handle it nicely:

1) background color doesn't get updated (It seems I broke it, sorry)
2) same for icons (I think it has been this way forever)

The attached patch fixes both issues, plus a memleak :), is it OK to
commit?

	Regards

? patch-gcc
? capplets/about-me/gnome-about-me
? m4/intltool.m4
Index: control-center/ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-control-center/control-center/ChangeLog,v
retrieving revision 1.157
diff -u -r1.157 ChangeLog
--- control-center/ChangeLog	24 Oct 2005 11:31:26 -0000	1.157
+++ control-center/ChangeLog	25 Oct 2005 22:05:41 -0000
@@ -1,3 +1,10 @@
+2005-10-25  Carlos Garnacho Parro  <carlosg gnome org>
+
+	* control-center-categories.[ch] (control_center_reload_icons): added
+	to reload icons if gtk theme changes
+	* gnomecc-canvas.c: switch correctly both shell background and icons
+	in case of theme change. Plugged a memleak on finalize
+
 2005-10-24  Carlos Garnacho Parro  <carlosg gnome org>
 
 	* gnomecc-canvas.c: calculate item widths instead of forcing them to
Index: control-center/control-center-categories.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/control-center/control-center-categories.c,v
retrieving revision 1.10
diff -u -r1.10 control-center-categories.c
--- control-center/control-center-categories.c	15 Oct 2005 21:42:13 -0000	1.10
+++ control-center/control-center-categories.c	25 Oct 2005 22:05:41 -0000
@@ -124,7 +124,8 @@
 	retval->title         = g_strdup (gmenu_tree_entry_get_name (menu_entry));
 	retval->comment       = g_strdup (gmenu_tree_entry_get_comment (menu_entry));
 	retval->desktop_entry = g_strdup (gmenu_tree_entry_get_desktop_file_path (menu_entry));
-	retval->icon_pixbuf   = load_icon (gmenu_tree_entry_get_icon (menu_entry));
+	retval->icon          = g_strdup (gmenu_tree_entry_get_icon (menu_entry));
+	retval->icon_pixbuf   = load_icon (retval->icon);
 
 	return retval;
 }
@@ -331,4 +332,25 @@
 	information->categories = NULL;
 
 	g_free (information);
+}
+
+void
+control_center_reload_icons (ControlCenterInformation *information)
+{
+	int i, j;
+	int n_cat, n_entries;
+	ControlCenterEntry *entry;
+
+	n_cat = information->n_categories;
+
+	for (i = 0; i < n_cat; i++) {
+		n_entries = information->categories[i]->n_entries;
+
+		for (j = 0; j < n_entries; j++) {
+			entry = information->categories[i]->entries[j];
+
+			gdk_pixbuf_unref (entry->icon_pixbuf);
+			entry->icon_pixbuf = load_icon (entry->icon);
+		}
+	}
 }
Index: control-center/control-center-categories.h
===================================================================
RCS file: /cvs/gnome/gnome-control-center/control-center/control-center-categories.h,v
retrieving revision 1.3
diff -u -r1.3 control-center-categories.h
--- control-center/control-center-categories.h	16 Nov 2004 08:56:50 -0000	1.3
+++ control-center/control-center-categories.h	25 Oct 2005 22:05:41 -0000
@@ -44,6 +44,7 @@
 	char *comment;
 	char *desktop_entry;
 
+	char *icon;
 	GdkPixbuf *icon_pixbuf;
 
 	gpointer user_data;
@@ -67,6 +68,7 @@
 
 ControlCenterInformation *control_center_get_information  (void);
 void                      control_center_information_free (ControlCenterInformation *information);
+void                      control_center_reload_icons     (ControlCenterInformation *information);
 
 G_END_DECLS
 
Index: control-center/gnomecc-canvas.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/control-center/gnomecc-canvas.c,v
retrieving revision 1.3
diff -u -r1.3 gnomecc-canvas.c
--- control-center/gnomecc-canvas.c	24 Oct 2005 11:31:27 -0000	1.3
+++ control-center/gnomecc-canvas.c	25 Oct 2005 22:05:43 -0000
@@ -171,11 +171,9 @@
 gnomecc_canvas_init (GnomeccCanvas *canvas)
 {
 	GnomeccCanvasPrivate *priv;
-	GtkWidget *widget;
 	
 	g_return_if_fail (GNOMECC_IS_CANVAS (canvas));
 
-	widget = GTK_WIDGET (canvas);
 	priv = GNOMECC_CANVAS_GET_PRIVATE (canvas);
 
 	priv->max_width = 300;
@@ -190,10 +188,7 @@
 
 	priv->accessible_children = g_hash_table_new (g_int_hash, g_int_equal);
 
-	gtk_widget_modify_bg (GTK_WIDGET (canvas), GTK_STATE_NORMAL,
-			      &widget->style->base[GTK_STATE_NORMAL]);
-
-	gtk_widget_show_all (widget);
+	gtk_widget_show_all (GTK_WIDGET (canvas));
 }
 
 static gboolean
@@ -695,12 +690,11 @@
 					gnome_canvas_pixbuf_get_type (),
 					"pixbuf", pixbuf,
 					NULL);
-				g_object_unref (pixbuf);
+
 				ei->highlight_pixbuf = gnome_canvas_item_new (ei->group,
 					gnome_canvas_pixbuf_get_type (),
 					"pixbuf", highlight_pixbuf,
 					NULL);
-				g_object_unref (highlight_pixbuf);
 			} else {
 				ei->pixbuf = NULL;
 				ei->highlight_pixbuf = NULL;
@@ -764,6 +758,12 @@
 static void
 gnomecc_canvas_finalize (GObject *object)
 {
+	GnomeccCanvasPrivate *priv;
+
+	priv = GNOMECC_CANVAS_GET_PRIVATE (object);
+
+	g_hash_table_destroy (priv->accessible_children);
+
 	if (G_OBJECT_CLASS (gnomecc_canvas_parent_class)->finalize)
 		(* G_OBJECT_CLASS (gnomecc_canvas_parent_class)->finalize) (object);
 }
@@ -958,6 +958,9 @@
 
 	priv = GNOMECC_CANVAS_GET_PRIVATE (canvas);
 
+	widget->style->bg[GTK_STATE_NORMAL] = widget->style->base[GTK_STATE_NORMAL];
+	control_center_reload_icons (priv->info);
+
 	for (i = 0; i < priv->info->n_categories; i++) {
 		CategoryInfo *catinfo = priv->info->categories[i]->user_data;
 
@@ -980,6 +983,15 @@
 		for (j = 0; j < priv->info->categories[i]->n_entries; j++) {
 			ControlCenterEntry *entry = priv->info->categories[i]->entries[j];
 			EntryInfo *entryinfo = entry->user_data;
+
+			g_object_set (entryinfo->pixbuf,
+				      "pixbuf", entry->icon_pixbuf,
+				      NULL);
+
+			g_object_set (entryinfo->highlight_pixbuf,
+				      "pixbuf", create_spotlight_pixbuf (entry->icon_pixbuf),
+				      NULL);
+
 			if (font_changed && entryinfo->text)
 				g_object_set (entryinfo->text,
 					      "font", NULL,


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