aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-sidebar.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2008-08-07 22:29:49 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-08-07 22:29:49 +0800
commitc714d8efd156f22661de6d2055e82522de17b382 (patch)
tree930cb413b6fe34f44a648173f05866e9e2205491 /shell/e-sidebar.c
parent92bc398f6b596236019c34029f85fac5c6449e20 (diff)
downloadgsoc2013-evolution-c714d8efd156f22661de6d2055e82522de17b382.tar
gsoc2013-evolution-c714d8efd156f22661de6d2055e82522de17b382.tar.gz
gsoc2013-evolution-c714d8efd156f22661de6d2055e82522de17b382.tar.bz2
gsoc2013-evolution-c714d8efd156f22661de6d2055e82522de17b382.tar.lz
gsoc2013-evolution-c714d8efd156f22661de6d2055e82522de17b382.tar.xz
gsoc2013-evolution-c714d8efd156f22661de6d2055e82522de17b382.tar.zst
gsoc2013-evolution-c714d8efd156f22661de6d2055e82522de17b382.zip
** Fixes bug #467115
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. svn path=/trunk/; revision=35924
Diffstat (limited to 'shell/e-sidebar.c')
-rw-r--r--shell/e-sidebar.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/shell/e-sidebar.c b/shell/e-sidebar.c
index d3404b5813..bd822b25da 100644
--- a/shell/e-sidebar.c
+++ b/shell/e-sidebar.c
@@ -36,7 +36,7 @@ typedef struct {
GtkWidget *label;
GtkWidget *icon;
GtkWidget *hbox;
- GdkPixbuf *default_icon;
+ gchar *default_icon_name;
int id;
} Button;
@@ -79,17 +79,20 @@ button_new (GtkWidget *button_widget,
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 @@ button_free (Button *button)
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 @@ void
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 @@ e_sidebar_add_button (ESidebar *sidebar,
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_add_button (ESidebar *sidebar,
/**
* 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 @@ e_sidebar_change_button_icon (ESidebar *sidebar, GdkPixbuf *icon, int button_id
if (!button->icon)
break;
- if (icon) {
- if (!button->default_icon)
- button->default_icon = gdk_pixbuf_copy (gtk_image_get_pixbuf (GTK_IMAGE (button->icon)));
+ if (icon_name == NULL)
+ icon_name = button->default_icon_name;
- 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;
- }
+ gtk_image_set_from_icon_name (
+ GTK_IMAGE (button->icon),
+ icon_name, GTK_ICON_SIZE_BUTTON);
break;
}