evolution r35924 - trunk/shell



Author: mbarnes
Date: Thu Aug  7 14:29:49 2008
New Revision: 35924
URL: http://svn.gnome.org/viewvc/evolution?rev=35924&view=rev

Log:
2008-08-07  Matthew Barnes  <mbarnes redhat com>

	** Fixes bug #467115

	* shell/e-component-registry.h:
	Replace button and menu icon pixbufs with an icon name string.

	* shell/e-component-registry.c (query_components):
	No need to create pixbufs, just save the icon name.

	* shell/e-sidebar.c:
	Remember a default icon name rather than a default pixbuf.

	* shell/e-sidebar.c (e_sidebar_add_button),
        (e_sidebar_change_button_icon):
	* shell/e-shell-window.c (e_shell_window_change_component_button_icon):
	Take an icon name instead of a pixbuf.

	* shell/e-shell-window.c (switch_view):
	Call gtk_window_set_icon_name() instead of gtk_window_set_icon().

	* shell/e-shell-window.c (setup_widgets):
	Change XML from pixtype="pixbuf" to pixbuf="filename" and derive
	an appropriate filename from the icon name.



Modified:
   trunk/shell/ChangeLog
   trunk/shell/e-component-registry.c
   trunk/shell/e-component-registry.h
   trunk/shell/e-shell-view.c
   trunk/shell/e-shell-window.c
   trunk/shell/e-shell-window.h
   trunk/shell/e-sidebar.c
   trunk/shell/e-sidebar.h

Modified: trunk/shell/e-component-registry.c
==============================================================================
--- trunk/shell/e-component-registry.c	(original)
+++ trunk/shell/e-component-registry.c	Thu Aug  7 14:29:49 2008
@@ -54,9 +54,8 @@
 	  	    const char *button_tooltips,
 		    const char *menu_label,
 		    const char *menu_accelerator,
-		    int sort_order,
-		    GdkPixbuf *button_icon,
-		    GdkPixbuf *menu_icon)
+                    const char *icon_name,
+		    int sort_order)
 {
 	EComponentInfo *info = g_new0 (EComponentInfo, 1);
 
@@ -67,16 +66,9 @@
 	info->button_tooltips = g_strdup (button_tooltips);
 	info->menu_label = g_strdup (menu_label);
 	info->menu_accelerator = g_strdup (menu_accelerator);
+        info->icon_name = g_strdup (icon_name);
 	info->sort_order = sort_order;
 
-	info->button_icon = button_icon;
-	if (info->button_icon)
-		g_object_ref (info->button_icon);
-
-	info->menu_icon = menu_icon;
-	if (info->menu_icon)
-		g_object_ref (info->menu_icon);
-
 	return info;
 }
 
@@ -90,12 +82,6 @@
 	g_free (info->menu_label);
 	g_free (info->menu_accelerator);
 
-	if (info->button_icon)
-		g_object_unref (info->button_icon);
-
-	if (info->menu_icon)
-		g_object_unref (info->menu_icon);
-
 	if (info->iface != NULL)
 		bonobo_object_release_unref (info->iface, NULL);
 
@@ -183,7 +169,6 @@
 		const char *icon_name;
 		const char *sort_order_string;
 		const char *tooltips;
-		GdkPixbuf *icon = NULL, *menuicon = NULL;
 		EComponentInfo *info;
 		int sort_order;
 		GNOME_Evolution_Component iface;
@@ -211,10 +196,6 @@
 		alias = bonobo_server_info_prop_lookup (& info_list->_buffer[i], "evolution:component_alias", NULL);
 
 		icon_name = bonobo_server_info_prop_lookup (& info_list->_buffer[i], "evolution:button_icon", NULL);
-		if (icon_name) {
-			icon = e_icon_factory_get_icon (icon_name, E_ICON_SIZE_LARGE_TOOLBAR);
-			menuicon = e_icon_factory_get_icon (icon_name, E_ICON_SIZE_MENU);
-		}
 
 		sort_order_string = bonobo_server_info_prop_lookup (& info_list->_buffer[i],
 								    "evolution:button_sort_order", NULL);
@@ -224,15 +205,11 @@
 			sort_order = atoi (sort_order_string);
 
 		info = component_info_new (id, iface, alias, label, tooltips, menu_label,
-					   menu_accelerator, sort_order, icon, menuicon);
+					   menu_accelerator, icon_name, sort_order);
 		set_schemas (info, & info_list->_buffer [i]);
 
 		registry->priv->infos = g_slist_prepend (registry->priv->infos, info);
 
-		if (icon != NULL)
-			g_object_unref (icon);
-		if (menuicon != NULL)
-			g_object_unref (menuicon);
 		bonobo_object_release_unref(iface, NULL);
 	}
 	g_slist_free(languages);

Modified: trunk/shell/e-component-registry.h
==============================================================================
--- trunk/shell/e-component-registry.h	(original)
+++ trunk/shell/e-component-registry.h	Thu Aug  7 14:29:49 2008
@@ -73,10 +73,9 @@
 
 	char *button_label;
 	char *button_tooltips;
-	GdkPixbuf *button_icon;
 	char *menu_label;
 	char *menu_accelerator;
-	GdkPixbuf *menu_icon;
+	char *icon_name;
 
 	int sort_order;
 

Modified: trunk/shell/e-shell-view.c
==============================================================================
--- trunk/shell/e-shell-view.c	(original)
+++ trunk/shell/e-shell-view.c	Thu Aug  7 14:29:49 2008
@@ -61,7 +61,7 @@
 
 struct change_icon_struct {
 	const char *component_name;
-	GdkPixbuf *icon;
+	const char *icon_name;
 };
 
 static gboolean
@@ -72,7 +72,7 @@
 	g_return_val_if_fail (window != NULL, FALSE);
 	g_return_val_if_fail (cis != NULL, FALSE);
 
-	e_shell_window_change_component_button_icon (window, cis->component_name, cis->icon);
+	e_shell_window_change_component_button_icon (window, cis->component_name, cis->icon_name);
 
 	return TRUE;
 }
@@ -85,15 +85,9 @@
 
 	struct change_icon_struct cis;
 	cis.component_name = id;
-	cis.icon = NULL;
-
-	if (iconName)
-		cis.icon = e_icon_factory_get_icon (iconName, E_ICON_SIZE_BUTTON);
+	cis.icon_name = iconName;
 
 	e_shell_foreach_shell_window (shell, change_button_icon_func, &cis);
-
-	if (cis.icon)
-		g_object_unref (cis.icon);
 }
 
 static void

Modified: trunk/shell/e-shell-window.c
==============================================================================
--- trunk/shell/e-shell-window.c	(original)
+++ trunk/shell/e-shell-window.c	Thu Aug  7 14:29:49 2008
@@ -331,8 +331,8 @@
 	} else
 		gtk_window_set_title (GTK_WINDOW (window), component_view->title);
 
-	if (info->button_icon)
-		gtk_window_set_icon (GTK_WINDOW (window), info->button_icon);
+	if (info->icon_name)
+		gtk_window_set_icon_name (GTK_WINDOW (window), info->icon_name);
 
 	gconf_client_set_string (gconf_client, "/apps/evolution/shell/view_defaults/component_id",
 				 (component_view->component_alias != NULL
@@ -756,12 +756,14 @@
 		char *tmp, *tmp2;
 		EComponentInfo *info = p->data;
 		ComponentView *view = component_view_new (info->id, info->alias, button_id);
+		GtkIconInfo *icon_info;
+		gint width;
 
 		window->priv->component_views = g_slist_prepend (window->priv->component_views, view);
 
 		if (!info->button_label || !info->menu_label)
 			continue;
-		e_sidebar_add_button (E_SIDEBAR (priv->sidebar), info->button_label, info->button_tooltips, info->button_icon, button_id);
+		e_sidebar_add_button (E_SIDEBAR (priv->sidebar), info->button_label, info->button_tooltips, info->icon_name, button_id);
 
 		g_string_printf(xml, "SwitchComponent-%s", info->alias);
 		bonobo_ui_component_add_verb (e_shell_window_peek_bonobo_ui_component (window),
@@ -783,11 +785,14 @@
 		g_free (tmp2);
 		g_free (tmp);
 
-		tmp = bonobo_ui_util_pixbuf_to_xml (info->menu_icon),
-		g_string_append_printf(xml, "\" pixtype=\"pixbuf\" pixname=\"%s\"/>"
+		gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, NULL);
+		icon_info = gtk_icon_theme_lookup_icon (
+			gtk_icon_theme_get_default (),
+			info->icon_name, width, 0);
+		g_string_append_printf(xml, "\" pixtype=\"filename\" pixname=\"%s\"/>"
 				       "</placeholder></submenu></submenu>\n",
-				       tmp);
-		g_free(tmp);
+				       gtk_icon_info_get_filename (icon_info));
+		gtk_icon_info_free (icon_info);
 		bonobo_ui_component_set_translate (e_shell_window_peek_bonobo_ui_component (window),
 						   "/menu",
 						   xml->str,
@@ -1246,7 +1251,7 @@
  * @param icon Icon buffer.
  **/
 void
-e_shell_window_change_component_button_icon (EShellWindow *window, const char *component_id, GdkPixbuf *icon)
+e_shell_window_change_component_button_icon (EShellWindow *window, const char *component_id, const char *icon_name)
 {
 	EShellWindowPrivate *priv;
 	GSList *p;
@@ -1265,7 +1270,7 @@
 		if (strcmp (this_view->component_id, component_id) == 0
 		    || (this_view->component_alias != NULL
 			&& strcmp (this_view->component_alias, component_id) == 0)) {
-			e_sidebar_change_button_icon (E_SIDEBAR (priv->sidebar), icon, this_view->button_id);
+			e_sidebar_change_button_icon (E_SIDEBAR (priv->sidebar), icon_name, this_view->button_id);
 			break;
 		}
 	}

Modified: trunk/shell/e-shell-window.h
==============================================================================
--- trunk/shell/e-shell-window.h	(original)
+++ trunk/shell/e-shell-window.h	Thu Aug  7 14:29:49 2008
@@ -73,6 +73,6 @@
 void  e_shell_window_save_defaults  (EShellWindow *window);
 void  e_shell_window_show_settings  (EShellWindow *window);
 
-void e_shell_window_change_component_button_icon (EShellWindow *window, const char *component_id, GdkPixbuf *icon);
+void e_shell_window_change_component_button_icon (EShellWindow *window, const char *component_id, const char *icon_name);
 
 #endif /* _E_SHELL_WINDOW_H_ */

Modified: trunk/shell/e-sidebar.c
==============================================================================
--- trunk/shell/e-sidebar.c	(original)
+++ trunk/shell/e-sidebar.c	Thu Aug  7 14:29:49 2008
@@ -36,7 +36,7 @@
 	GtkWidget *label;
 	GtkWidget *icon;
 	GtkWidget *hbox;
-	GdkPixbuf *default_icon;
+	gchar *default_icon_name;
 	int id;
 } Button;
 
@@ -79,17 +79,20 @@
 	    int        id)
 {
 	Button *button = g_new (Button, 1);
+	const gchar *icon_name;
 
 	button->button_widget = button_widget;
 	button->label = label;
-	button->icon = icon;
+        button->icon = icon;
 	button->hbox = hbox;
 	button->id = id;
-	button->default_icon = NULL;
+
+	gtk_image_get_icon_name (GTK_IMAGE (icon), &icon_name, NULL);
+	button->default_icon_name = g_strdup (icon_name);
 
 	g_object_ref (button_widget);
 	g_object_ref (label);
-	g_object_ref (icon);
+        g_object_ref (icon);
 	g_object_ref (hbox);
 
 	return button;
@@ -102,8 +105,7 @@
 	g_object_unref (button->label);
 	g_object_unref (button->icon);
 	g_object_unref (button->hbox);
-	if (button->default_icon)
-		g_object_unref (button->default_icon);
+	g_free (button->default_icon_name);
 	g_free (button);
 }
 
@@ -545,7 +547,7 @@
 e_sidebar_add_button (ESidebar *sidebar,
 		      const char *label,
 		      const char *tooltips,
-		      GdkPixbuf *icon,
+		      const char *icon_name,
 		      int id)
 {
 	GtkWidget *button_widget;
@@ -564,7 +566,8 @@
 	gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
 	gtk_widget_show (hbox);
 
-	icon_widget = gtk_image_new_from_pixbuf (icon);
+	icon_widget = gtk_image_new_from_icon_name (
+		icon_name, GTK_ICON_SIZE_BUTTON);
 	gtk_widget_show (icon_widget);
 
 	label_widget = gtk_label_new (label);
@@ -603,16 +606,15 @@
 
 /**
  * e_sidebar_change_button_icon
+ * @sidebar: an #ESidebar
+ * @icon_name: button icon name, or %NULL
+ * @button_id: component's button ID, for which change the icon.
+ *
  * This will change icon in icon_widget of the button of known component.
  * You cannot change icon as in a stack, only one default icon will be stored.
- * @param sidebar ESidebar instance.
- * @param icon Pointer to buffer with icon. Can by NULL, in this case the icon will be
- *             put back to default one for the component.
- * @param button_id Component's button ID, for which change the icon.
  **/
-
 void
-e_sidebar_change_button_icon (ESidebar *sidebar, GdkPixbuf  *icon, int button_id)
+e_sidebar_change_button_icon (ESidebar *sidebar, const gchar *icon_name, int button_id)
 {
 	GSList *p;
 
@@ -625,16 +627,12 @@
 			if (!button->icon)
 				break;
 
-			if (icon) {
-				if (!button->default_icon)
-					button->default_icon = gdk_pixbuf_copy (gtk_image_get_pixbuf (GTK_IMAGE (button->icon)));
-
-				gtk_image_set_from_pixbuf (GTK_IMAGE (button->icon), icon);
-			} else if (button->default_icon) {
-				gtk_image_set_from_pixbuf (GTK_IMAGE (button->icon), button->default_icon);
-				g_object_unref (button->default_icon);
-				button->default_icon = NULL;
-			}
+			if (icon_name == NULL)
+				icon_name = button->default_icon_name;
+
+			gtk_image_set_from_icon_name (
+				GTK_IMAGE (button->icon),
+				icon_name, GTK_ICON_SIZE_BUTTON);
 
 			break;
 		}

Modified: trunk/shell/e-sidebar.h
==============================================================================
--- trunk/shell/e-sidebar.h	(original)
+++ trunk/shell/e-sidebar.h	Thu Aug  7 14:29:49 2008
@@ -67,14 +67,14 @@
 void  e_sidebar_add_button  (ESidebar   *sidebar,
 			     const char *label,
 			     const char *tooltips,
-			     GdkPixbuf  *icon,
+			     const char *icon_name,
 			     int         id);
 
 void  e_sidebar_select_button  (ESidebar *sidebar,
 				int       id);
 
 void e_sidebar_change_button_icon (ESidebar *sidebar,
-				   GdkPixbuf  *icon,
+				   const char *icon_name,
 				   int button_id);
 
 ESidebarMode e_sidebar_get_mode (ESidebar *sidebar);



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