diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2009-01-25 11:28:18 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2009-01-25 11:28:18 +0800 |
commit | 32ffc3ca1ca80b2d843fbe28da7deab35fabcbf1 (patch) | |
tree | 36f52060c250aacf445013b1bf15541892098f3f /shell/e-shell-sidebar.c | |
parent | cbb3a71adc5551f4c600cfc6f53fc112f3022a78 (diff) | |
download | gsoc2013-evolution-32ffc3ca1ca80b2d843fbe28da7deab35fabcbf1.tar.gz gsoc2013-evolution-32ffc3ca1ca80b2d843fbe28da7deab35fabcbf1.tar.zst gsoc2013-evolution-32ffc3ca1ca80b2d843fbe28da7deab35fabcbf1.zip |
Make the sidebar icon follow the folder icon.
Fix more runtime warnings.
svn path=/branches/kill-bonobo/; revision=37130
Diffstat (limited to 'shell/e-shell-sidebar.c')
-rw-r--r-- | shell/e-shell-sidebar.c | 83 |
1 files changed, 82 insertions, 1 deletions
diff --git a/shell/e-shell-sidebar.c b/shell/e-shell-sidebar.c index 7e5a1f7695..fecb41426a 100644 --- a/shell/e-shell-sidebar.c +++ b/shell/e-shell-sidebar.c @@ -32,6 +32,7 @@ struct _EShellSidebarPrivate { gpointer shell_view; /* weak pointer */ GtkWidget *event_box; + GtkWidget *image; GtkWidget *primary_label; GtkWidget *secondary_label; gchar *primary_text; @@ -40,6 +41,7 @@ struct _EShellSidebarPrivate { enum { PROP_0, + PROP_ICON_NAME, PROP_PRIMARY_TEXT, PROP_SECONDARY_TEXT, PROP_SHELL_VIEW @@ -67,6 +69,12 @@ shell_sidebar_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_ICON_NAME: + e_shell_sidebar_set_icon_name ( + E_SHELL_SIDEBAR (object), + g_value_get_string (value)); + return; + case PROP_PRIMARY_TEXT: e_shell_sidebar_set_primary_text ( E_SHELL_SIDEBAR (object), @@ -96,6 +104,12 @@ shell_sidebar_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_ICON_NAME: + g_value_set_string ( + value, e_shell_sidebar_get_icon_name ( + E_SHELL_SIDEBAR (object))); + return; + case PROP_PRIMARY_TEXT: g_value_set_string ( value, e_shell_sidebar_get_primary_text ( @@ -131,6 +145,11 @@ shell_sidebar_dispose (GObject *object) priv->shell_view = NULL; } + if (priv->image != NULL) { + g_object_unref (priv->image); + priv->image = NULL; + } + if (priv->event_box != NULL) { g_object_unref (priv->event_box); priv->event_box = NULL; @@ -174,6 +193,7 @@ shell_sidebar_constructed (GObject *object) GtkWidget *container; GtkWidget *widget; gchar *label; + gchar *icon_name; shell_sidebar = E_SHELL_SIDEBAR (object); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); @@ -192,8 +212,9 @@ shell_sidebar_constructed (GObject *object) container = widget; - widget = gtk_action_create_icon (action, GTK_ICON_SIZE_MENU); + widget = gtk_image_new (); gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + shell_sidebar->priv->image = g_object_ref (widget); gtk_widget_show (widget); widget = gtk_label_new (NULL); @@ -210,6 +231,10 @@ shell_sidebar_constructed (GObject *object) shell_sidebar->priv->secondary_label = g_object_ref (widget); gtk_widget_show (widget); + g_object_get (action, "icon-name", &icon_name, NULL); + e_shell_sidebar_set_icon_name (shell_sidebar, icon_name); + g_free (icon_name); + g_object_get (action, "label", &label, NULL); e_shell_sidebar_set_primary_text (shell_sidebar, label); g_free (label); @@ -333,6 +358,21 @@ shell_sidebar_class_init (EShellSidebarClass *class) container_class->forall = shell_sidebar_forall; /** + * EShellSidebar:icon-name + * + * The named icon is displayed at the top of the sidebar. + */ + g_object_class_install_property ( + object_class, + PROP_ICON_NAME, + g_param_spec_string ( + "icon-name", + NULL, + NULL, + NULL, + G_PARAM_READWRITE)); + + /** * EShellSidebar:primary-text * * The primary text is displayed in bold at the top of the sidebar. @@ -489,6 +529,47 @@ e_shell_sidebar_get_shell_view (EShellSidebar *shell_sidebar) } /** + * e_shell_sidebar_get_icon_name: + * @shell_sidebar: an #EShellSidebar + * + * Returns the icon name displayed at the top of the sidebar. + * + * Returns: the icon name for @shell_sidebar + **/ +const gchar * +e_shell_sidebar_get_icon_name (EShellSidebar *shell_sidebar) +{ + GtkImage *image; + const gchar *icon_name; + + g_return_val_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar), NULL); + + image = GTK_IMAGE (shell_sidebar->priv->image); + gtk_image_get_icon_name (image, &icon_name, NULL); + + return icon_name; +} + +/** + * e_shell_sidebar_set_icon_name: + * + * Sets the icon name displayed at the top of the sidebar. + **/ +void +e_shell_sidebar_set_icon_name (EShellSidebar *shell_sidebar, + const gchar *icon_name) +{ + GtkImage *image; + + g_return_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar)); + + image = GTK_IMAGE (shell_sidebar->priv->image); + gtk_image_set_from_icon_name (image, icon_name, GTK_ICON_SIZE_MENU); + + g_object_notify (G_OBJECT (shell_sidebar), "icon-name"); +} + +/** * e_shell_sidebar_get_primary_text: * @shell_sidebar: an #EShellSidebar * |