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 | |
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
-rw-r--r-- | mail/e-mail-shell-content.c | 10 | ||||
-rw-r--r-- | mail/e-mail-shell-sidebar.c | 47 | ||||
-rw-r--r-- | mail/e-mail-shell-view-private.c | 6 | ||||
-rw-r--r-- | mail/em-folder-tree-model.c | 59 | ||||
-rw-r--r-- | mail/em-folder-tree-model.h | 2 | ||||
-rw-r--r-- | mail/em-folder-tree.c | 86 | ||||
-rw-r--r-- | mail/em-folder-utils.c | 37 | ||||
-rw-r--r-- | mail/em-folder-utils.h | 36 | ||||
-rw-r--r-- | shell/e-shell-sidebar.c | 83 | ||||
-rw-r--r-- | shell/e-shell-sidebar.h | 3 | ||||
-rw-r--r-- | shell/e-shell-view.h | 3 |
11 files changed, 252 insertions, 120 deletions
diff --git a/mail/e-mail-shell-content.c b/mail/e-mail-shell-content.c index ece2e2ee3a..5019d234bc 100644 --- a/mail/e-mail-shell-content.c +++ b/mail/e-mail-shell-content.c @@ -97,6 +97,9 @@ mail_shell_content_message_list_scrolled_cb (EMailShellContent *mail_shell_conte /* Save the scrollbar position for the current folder. */ + if (message_list->folder == NULL) + return; + key = "evolution:list_scroll_position"; position = message_list_get_scrollbar_position (message_list); value = g_strdup_printf ("%f", position); @@ -225,7 +228,12 @@ mail_shell_content_message_selected_cb (EMailShellContent *mail_shell_content, CamelFolder *folder; folder = message_list->folder; - g_return_if_fail (folder != NULL); + + /* This also gets triggered when selecting a store name on + * the sidebar such as "On This Computer", in which case + * 'folder' will be NULL. */ + if (folder == NULL) + return; if (camel_object_meta_set (folder, key, selected_uid)) camel_object_state_write (folder); diff --git a/mail/e-mail-shell-sidebar.c b/mail/e-mail-shell-sidebar.c index 242216d602..c448be9782 100644 --- a/mail/e-mail-shell-sidebar.c +++ b/mail/e-mail-shell-sidebar.c @@ -25,6 +25,7 @@ #include <camel/camel.h> #include "em-utils.h" +#include "em-folder-utils.h" #include "e-mail-shell-module.h" @@ -44,6 +45,42 @@ enum { static gpointer parent_class; static void +mail_shell_sidebar_selection_changed_cb (EShellSidebar *shell_sidebar, + GtkTreeSelection *selection) +{ + EShellView *shell_view; + EShellViewClass *shell_view_class; + GtkTreeModel *model; + GtkTreeIter iter; + const gchar *icon_name; + gchar *display_name = NULL; + gboolean is_folder = FALSE; + guint flags = 0; + + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); + + if (gtk_tree_selection_get_selected (selection, &model, &iter)) + gtk_tree_model_get ( + model, &iter, + COL_STRING_DISPLAY_NAME, &display_name, + COL_BOOL_IS_FOLDER, &is_folder, + COL_UINT_FLAGS, &flags, -1); + + if (is_folder) + icon_name = em_folder_utils_get_icon_name (flags); + else { + icon_name = shell_view_class->icon_name; + display_name = g_strdup (shell_view_class->label); + } + + e_shell_sidebar_set_icon_name (shell_sidebar, icon_name); + e_shell_sidebar_set_primary_text (shell_sidebar, display_name); + + g_free (display_name); +} + +static void mail_shell_sidebar_get_property (GObject *object, guint property_id, GValue *value, @@ -94,6 +131,8 @@ mail_shell_sidebar_constructed (GObject *object) EShellSidebar *shell_sidebar; EShellModule *shell_module; EShellView *shell_view; + GtkTreeSelection *selection; + GtkTreeView *tree_view; GtkWidget *container; GtkWidget *widget; @@ -127,6 +166,14 @@ mail_shell_sidebar_constructed (GObject *object) gtk_container_add (GTK_CONTAINER (container), widget); priv->folder_tree = g_object_ref (widget); gtk_widget_show (widget); + + tree_view = GTK_TREE_VIEW (priv->folder_tree); + selection = gtk_tree_view_get_selection (tree_view); + + g_signal_connect_swapped ( + selection, "changed", + G_CALLBACK (mail_shell_sidebar_selection_changed_cb), + shell_sidebar); } static guint32 diff --git a/mail/e-mail-shell-view-private.c b/mail/e-mail-shell-view-private.c index 82a97352d9..160e1b8828 100644 --- a/mail/e-mail-shell-view-private.c +++ b/mail/e-mail-shell-view-private.c @@ -271,6 +271,8 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view) guint32 num_unread; guint32 num_visible; + /* FIXME The sidebar should handle icon name and primary text. */ + g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view)); shell_view = E_SHELL_VIEW (mail_shell_view); @@ -290,11 +292,12 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view) gchar *label; action = e_shell_view_get_action (shell_view); + g_object_get (action, "label", &label, NULL); - e_shell_sidebar_set_primary_text (shell_sidebar, label); e_shell_sidebar_set_secondary_text (shell_sidebar, NULL); e_shell_view_set_title (shell_view, label); g_free (label); + return; } @@ -390,7 +393,6 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view) display_name = folder_name; title = g_strdup_printf ("%s (%s)", display_name, buffer->str); - e_shell_sidebar_set_primary_text (shell_sidebar, display_name); e_shell_sidebar_set_secondary_text (shell_sidebar, buffer->str); e_shell_view_set_title (shell_view, title); g_free (title); diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index 39c46fdbb0..5ddd8876e6 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -51,6 +51,7 @@ #include "mail-folder-cache.h" #include "em-utils.h" +#include "em-folder-utils.h" #include <camel/camel-folder.h> #include <camel/camel-vee-store.h> @@ -71,11 +72,13 @@ struct _EMFolderTreeModelPrivate { static GType col_types[] = { G_TYPE_STRING, /* display name */ G_TYPE_POINTER, /* store object */ - G_TYPE_STRING, /* path */ + G_TYPE_STRING, /* full name */ + G_TYPE_STRING, /* icon name */ G_TYPE_STRING, /* uri */ G_TYPE_UINT, /* unread count */ G_TYPE_UINT, /* flags */ G_TYPE_BOOLEAN, /* is a store node */ + G_TYPE_BOOLEAN, /* is a folder node */ G_TYPE_BOOLEAN, /* has not-yet-loaded subfolders */ }; @@ -555,6 +558,7 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *ite { EShellModule *shell_module; GtkTreeRowReference *uri_row, *path_row; + GtkTreeStore *tree_store; unsigned int unread; GtkTreePath *path; GtkTreeIter sub; @@ -562,12 +566,14 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *ite CamelFolder *folder; gboolean emitted = FALSE; const char *name; + const gchar *icon_name; guint32 flags; /* make sure we don't already know about it? */ if (g_hash_table_lookup (si->full_hash, fi->full_name)) return; + tree_store = GTK_TREE_STORE (model); shell_module = model->priv->shell_module; if (!fully_loaded) @@ -642,31 +648,40 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *ite } } - gtk_tree_store_set ((GtkTreeStore *) model, iter, - COL_STRING_DISPLAY_NAME, name, - COL_POINTER_CAMEL_STORE, si->store, - COL_STRING_FULL_NAME, fi->full_name, - COL_STRING_URI, fi->uri, - COL_UINT_FLAGS, flags, - COL_BOOL_IS_STORE, FALSE, - COL_BOOL_LOAD_SUBDIRS, load, - -1); + /* Choose an icon name for the folder. */ + icon_name = em_folder_utils_get_icon_name (flags); + + gtk_tree_store_set ( + tree_store, iter, + COL_STRING_DISPLAY_NAME, name, + COL_POINTER_CAMEL_STORE, si->store, + COL_STRING_FULL_NAME, fi->full_name, + COL_STRING_ICON_NAME, icon_name, + COL_STRING_URI, fi->uri, + COL_UINT_FLAGS, flags, + COL_BOOL_IS_STORE, FALSE, + COL_BOOL_IS_FOLDER, TRUE, + COL_BOOL_LOAD_SUBDIRS, load, + -1); if (unread != ~0) - gtk_tree_store_set ((GtkTreeStore *) model, iter, COL_UINT_UNREAD, unread, -1); + gtk_tree_store_set (tree_store, iter, COL_UINT_UNREAD, unread, -1); if (load) { /* create a placeholder node for our subfolders... */ - gtk_tree_store_append ((GtkTreeStore *) model, &sub, iter); - gtk_tree_store_set ((GtkTreeStore *) model, &sub, - COL_STRING_DISPLAY_NAME, _("Loading..."), - COL_POINTER_CAMEL_STORE, NULL, - COL_STRING_FULL_NAME, NULL, - COL_BOOL_LOAD_SUBDIRS, FALSE, - COL_BOOL_IS_STORE, FALSE, - COL_STRING_URI, NULL, - COL_UINT_UNREAD, 0, - -1); + gtk_tree_store_append (tree_store, &sub, iter); + gtk_tree_store_set ( + tree_store, &sub, + COL_STRING_DISPLAY_NAME, _("Loading..."), + COL_POINTER_CAMEL_STORE, NULL, + COL_STRING_FULL_NAME, NULL, + COL_STRING_ICON_NAME, NULL, + COL_BOOL_LOAD_SUBDIRS, FALSE, + COL_BOOL_IS_STORE, FALSE, + COL_BOOL_IS_FOLDER, FALSE, + COL_STRING_URI, NULL, + COL_UINT_UNREAD, 0, + -1); path = gtk_tree_model_get_path ((GtkTreeModel *) model, iter); g_signal_emit (model, signals[LOADING_ROW], 0, path, iter); @@ -678,7 +693,7 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *ite fi = fi->child; do { - gtk_tree_store_append ((GtkTreeStore *) model, &sub, iter); + gtk_tree_store_append (tree_store, &sub, iter); if (!emitted) { path = gtk_tree_model_get_path ((GtkTreeModel *) model, iter); diff --git a/mail/em-folder-tree-model.h b/mail/em-folder-tree-model.h index 0ab0f24d6d..8236f3c303 100644 --- a/mail/em-folder-tree-model.h +++ b/mail/em-folder-tree-model.h @@ -60,11 +60,13 @@ enum { COL_STRING_DISPLAY_NAME, /* string that appears in the tree */ COL_POINTER_CAMEL_STORE, /* CamelStore object */ COL_STRING_FULL_NAME, /* if node is a folder, the full path name of the folder, no leading / */ + COL_STRING_ICON_NAME, /* icon name for the folder */ COL_STRING_URI, /* the uri to get the store or folder object */ COL_UINT_UNREAD, /* unread count */ COL_UINT_FLAGS, /* FolderInfo.flags */ COL_BOOL_IS_STORE, /* toplevel store node? */ + COL_BOOL_IS_FOLDER, /* folder (not a store) */ COL_BOOL_LOAD_SUBDIRS, /* %TRUE only if the store/folder * has subfolders which have not yet * been added to the tree */ diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 97a6884566..ecfe5d29ad 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -363,87 +363,6 @@ subdirs_contain_unread (GtkTreeModel *model, GtkTreeIter *root) return FALSE; } - -enum { - FOLDER_ICON_NORMAL, - FOLDER_ICON_INBOX, - FOLDER_ICON_OUTBOX, - FOLDER_ICON_TRASH, - FOLDER_ICON_JUNK, - FOLDER_ICON_SHARED_TO_ME, - FOLDER_ICON_SHARED_BY_ME, - FOLDER_ICON_SENT, - FOLDER_ICON_VIRTUAL, - FOLDER_ICON_LAST -}; - -static GdkPixbuf *folder_icons[FOLDER_ICON_LAST]; - -static void -render_pixbuf (GtkTreeViewColumn *column, GtkCellRenderer *renderer, - GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) -{ - static gboolean initialised = FALSE; - GdkPixbuf *pixbuf = NULL; - gboolean is_store; - guint32 flags; - EMEventTargetCustomIcon *target; - const char *folder_name; - - if (!initialised) { - folder_icons[FOLDER_ICON_NORMAL] = e_icon_factory_get_icon ("folder", E_ICON_SIZE_MENU); - folder_icons[FOLDER_ICON_INBOX] = e_icon_factory_get_icon ("mail-inbox", E_ICON_SIZE_MENU); - folder_icons[FOLDER_ICON_OUTBOX] = e_icon_factory_get_icon ("mail-outbox", E_ICON_SIZE_MENU); - folder_icons[FOLDER_ICON_TRASH] = e_icon_factory_get_icon ("user-trash", E_ICON_SIZE_MENU); - folder_icons[FOLDER_ICON_JUNK] = e_icon_factory_get_icon ("mail-mark-junk", E_ICON_SIZE_MENU); - folder_icons[FOLDER_ICON_SHARED_TO_ME] = e_icon_factory_get_icon ("stock_shared-to-me", E_ICON_SIZE_MENU); - folder_icons[FOLDER_ICON_SHARED_BY_ME] = e_icon_factory_get_icon ("stock_shared-by-me", E_ICON_SIZE_MENU); - folder_icons[FOLDER_ICON_SENT] = e_icon_factory_get_icon ("mail-sent", E_ICON_SIZE_MENU); - folder_icons[FOLDER_ICON_VIRTUAL] = e_icon_factory_get_icon ("folder-saved-search", E_ICON_SIZE_MENU); - - initialised = TRUE; - } - - gtk_tree_model_get (model, iter, COL_BOOL_IS_STORE, &is_store, COL_UINT_FLAGS, &flags, -1); - - if (!is_store) { - switch((flags & CAMEL_FOLDER_TYPE_MASK)) { - case CAMEL_FOLDER_TYPE_INBOX: - pixbuf = folder_icons[FOLDER_ICON_INBOX]; - break; - case CAMEL_FOLDER_TYPE_OUTBOX: - pixbuf = folder_icons[FOLDER_ICON_OUTBOX]; - break; - case CAMEL_FOLDER_TYPE_TRASH: - pixbuf = folder_icons[FOLDER_ICON_TRASH]; - break; - case CAMEL_FOLDER_TYPE_JUNK: - pixbuf = folder_icons[FOLDER_ICON_JUNK]; - break; - case CAMEL_FOLDER_TYPE_SENT: - pixbuf = folder_icons[FOLDER_ICON_SENT]; - break; - default: - if (flags & CAMEL_FOLDER_SHARED_TO_ME) - pixbuf = folder_icons[FOLDER_ICON_SHARED_TO_ME]; - else if (flags & CAMEL_FOLDER_SHARED_BY_ME) - pixbuf = folder_icons[FOLDER_ICON_SHARED_BY_ME]; - else if (flags & CAMEL_FOLDER_VIRTUAL) - pixbuf = folder_icons[FOLDER_ICON_VIRTUAL]; - else { - pixbuf = folder_icons[FOLDER_ICON_NORMAL]; - g_object_set (renderer, "pixbuf", pixbuf, "visible", !is_store, NULL); - gtk_tree_model_get (model, iter, COL_STRING_FULL_NAME, &folder_name, -1); - target = em_event_target_new_custom_icon (em_event_peek(), renderer, folder_name, EM_EVENT_CUSTOM_ICON); - e_event_emit ((EEvent *)em_event_peek (), "folder.customicon", (EEventTarget *) target); - return; - } - } - } - - g_object_set (renderer, "pixbuf", pixbuf, "visible", !is_store, NULL); -} - static void render_display_name (GtkTreeViewColumn *column, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) @@ -539,7 +458,10 @@ folder_tree_new (EMFolderTree *emft, EMFolderTreeModel *model) renderer = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, renderer, FALSE); - gtk_tree_view_column_set_cell_data_func (column, renderer, render_pixbuf, NULL, NULL); + gtk_tree_view_column_add_attribute ( + column, renderer, "icon-name", COL_STRING_ICON_NAME); + gtk_tree_view_column_add_attribute ( + column, renderer, "visible", COL_BOOL_IS_FOLDER); renderer = gtk_cell_renderer_text_new (); if (!gconf_client_get_bool (gconf, "/apps/evolution/mail/display/no_folder_dots", NULL)) diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c index aa9e6aa402..cb1c333bfb 100644 --- a/mail/em-folder-utils.c +++ b/mail/em-folder-utils.c @@ -40,8 +40,6 @@ #include <glib/gi18n.h> #include <camel/camel-session.h> -#include <camel/camel-store.h> -#include <camel/camel-folder.h> #include <camel/camel-vee-store.h> #include <camel/camel-vtrash-folder.h> #include <camel/camel-stream-mem.h> @@ -696,3 +694,38 @@ em_folder_utils_create_folder (CamelFolderInfo *folderinfo, EMFolderTree *emft) g_signal_connect (dialog, "response", G_CALLBACK (emfu_popup_new_folder_response), emft); gtk_widget_show (dialog); } + +const gchar * +em_folder_utils_get_icon_name (guint32 flags) +{ + const gchar *icon_name; + + switch (flags & CAMEL_FOLDER_TYPE_MASK) { + case CAMEL_FOLDER_TYPE_INBOX: + icon_name = "mail-inbox"; + break; + case CAMEL_FOLDER_TYPE_OUTBOX: + icon_name = "mail-outbox"; + break; + case CAMEL_FOLDER_TYPE_TRASH: + icon_name = "user-trash"; + break; + case CAMEL_FOLDER_TYPE_JUNK: + icon_name = "mail-mark-junk"; + break; + case CAMEL_FOLDER_TYPE_SENT: + icon_name = "mail-sent"; + break; + default: + if (flags & CAMEL_FOLDER_SHARED_TO_ME) + icon_name = "stock_shared-to-me"; + else if (flags & CAMEL_FOLDER_SHARED_BY_ME) + icon_name = "stock_shared-by-me"; + else if (flags & CAMEL_FOLDER_VIRTUAL) + icon_name = "folder-saved-search"; + else + icon_name = "folder"; + } + + return icon_name; +} diff --git a/mail/em-folder-utils.h b/mail/em-folder-utils.h index 19bedd46a3..e3161bdcc0 100644 --- a/mail/em-folder-utils.h +++ b/mail/em-folder-utils.h @@ -21,18 +21,36 @@ * */ -#ifndef _EM_FOLDER_UTILS_H -#define _EM_FOLDER_UTILS_H +#ifndef EM_FOLDER_UTILS_H +#define EM_FOLDER_UTILS_H -int em_folder_utils_copy_folders(CamelStore *fromstore, const char *frombase, CamelStore *tostore, const char *tobase, int delete); +#include <glib.h> +#include <camel/camel-folder.h> +#include <camel/camel-store.h> +#include <mail/em-folder-tree.h> -/* FIXME: These api's are really busted, there is no consistency and most rely on the wrong data */ +G_BEGIN_DECLS -void em_folder_utils_copy_folder (struct _CamelFolderInfo *folderinfo, int delete); +gint em_folder_utils_copy_folders (CamelStore *fromstore, + const gchar *frombase, + CamelStore *tostore, + const gchar *tobase, + int delete); -void em_folder_utils_delete_folder (struct _CamelFolder *folder); -void em_folder_utils_rename_folder (struct _CamelFolder *folder); +/* FIXME These API's are really busted. There is no consistency and + * most rely on the wrong data. */ -void em_folder_utils_create_folder (struct _CamelFolderInfo *folderinfo, EMFolderTree * emft); +void em_folder_utils_copy_folder (CamelFolderInfo *folderinfo, + int delete); -#endif +void em_folder_utils_delete_folder (CamelFolder *folder); +void em_folder_utils_rename_folder (CamelFolder *folder); + +void em_folder_utils_create_folder (CamelFolderInfo *folderinfo, + EMFolderTree * emft); + +const gchar * em_folder_utils_get_icon_name (guint32 flags); + +G_END_DECLS + +#endif /* EM_FOLDER_UTILS_H */ 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 * diff --git a/shell/e-shell-sidebar.h b/shell/e-shell-sidebar.h index 1cf141b2a8..27966e5429 100644 --- a/shell/e-shell-sidebar.h +++ b/shell/e-shell-sidebar.h @@ -80,6 +80,9 @@ GtkWidget * e_shell_sidebar_new (struct _EShellView *shell_view); guint32 e_shell_sidebar_check_state (EShellSidebar *shell_sidebar); struct _EShellView * e_shell_sidebar_get_shell_view (EShellSidebar *shell_sidebar); +const gchar * e_shell_sidebar_get_icon_name (EShellSidebar *shell_sidebar); +void e_shell_sidebar_set_icon_name (EShellSidebar *shell_sidebar, + const gchar *icon_name); const gchar * e_shell_sidebar_get_primary_text(EShellSidebar *shell_sidebar); void e_shell_sidebar_set_primary_text(EShellSidebar *shell_sidebar, const gchar *primary_text); diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h index 78987d9db6..1392acfa0a 100644 --- a/shell/e-shell-view.h +++ b/shell/e-shell-view.h @@ -132,7 +132,8 @@ struct _EShellViewClass { /* Base name of the UI definition file. */ const gchar *ui_definition; - /* GtkUIManager ID for use with EPluginUI. */ + /* GtkUIManager identifier for use with EPluginUI. + * Usually "org.gnome.evolution.$(VIEW_NAME)". */ const gchar *ui_manager_id; /* Widget path to the search options popup menu. */ |