From e522a301b4ecfabbf40fb42ed7e082c293a7f2db Mon Sep 17 00:00:00 2001 From: Srinivasa Ragavan Date: Mon, 15 Dec 2008 06:44:07 +0000 Subject: Add the unread vfolder hack. 2008-12-15 Srinivasa Ragavan * em-account-editor.c: (emae_option_checkspin): * em-folder-tree.c: (emft_popup_uvfolder), (emft_popup): Add the unread vfolder hack. svn path=/trunk/; revision=36884 --- mail/ChangeLog | 6 ++++++ mail/em-account-editor.c | 2 +- mail/em-folder-tree.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index 890fa12189..bf1deafc5a 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,9 @@ +2008-12-15 Srinivasa Ragavan + + * em-account-editor.c: (emae_option_checkspin): + * em-folder-tree.c: (emft_popup_uvfolder), (emft_popup): Add the + unread vfolder hack. + 2008-12-15 Lucian Langa ** Fixes bug #564519 diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c index caa8aa50f5..9d82b61620 100644 --- a/mail/em-account-editor.c +++ b/mail/em-account-editor.c @@ -2001,7 +2001,7 @@ emae_option_checkspin(EMAccountEditorService *service, CamelURL *url, const char spin = gtk_spin_button_new((GtkAdjustment *)gtk_adjustment_new(def, min, max, 1, 1, 1), 1, 0); if (post) - label = gtk_label_new(post); + label = gtk_label_new_with_mnemonic(post); gtk_box_pack_start((GtkBox *)hbox, check, FALSE, TRUE, 0); gtk_box_pack_start((GtkBox *)hbox, spin, FALSE, TRUE, 0); if (label) diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 1eed0fd671..b66c80b31b 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -2094,6 +2094,23 @@ emft_popup_properties (EPopup *ep, EPopupItem *pitem, void *data) g_free (uri); } +static void +emft_popup_uvfolder (EPopup *ep, EPopupItem *pitem, void *data) +{ + EMFolderTree *emft = data; + CamelFolder *folder; + char *meta = camel_object_meta_get(folder, "vfolder:unread"); + + if ((folder = em_folder_tree_get_selected_folder (emft)) != NULL) { + if (!meta || strcmp(meta, "false") == 0) + camel_object_meta_set(folder, "vfolder:unread", "true"); + else + camel_object_meta_set(folder, "vfolder:unread", "false"); + } + camel_object_state_write (folder); + g_free (meta); +} + static EPopupItem emft_popup_items[] = { #if 0 { E_POPUP_ITEM, "00.emc.00", N_("_View"), emft_popup_view, NULL, NULL, EM_POPUP_FOLDER_SELECT }, @@ -2211,6 +2228,25 @@ emft_popup (EMFolderTree *emft, GdkEvent *event) if ((folder_type_flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_TRASH) menus = g_slist_prepend (menus, &trash_popup_item); + if (!isstore && strstr(uri, "vfolder")) { + /* This is a vfolder, so lets add hacked up menu item. */ + static EPopupItem *item = NULL; + char *meta = camel_object_meta_get (selfolder, "vfolder:unread"); + + if (!item) + item = g_malloc0(sizeof(*item)); + if (meta && (strcmp (meta, "true") == 0)) + item->type = E_POPUP_TOGGLE | E_POPUP_ACTIVE; + else + item->type = E_POPUP_TOGGLE & ~E_POPUP_ACTIVE; + item->path = "99.emc.99"; + item->label = _("_Unread Search Folder"); + item->activate = emft_popup_uvfolder; + item->visible = EM_POPUP_FOLDER_SELECT; + item->user_data = NULL; + menus = g_slist_prepend (menus, item); + g_free (meta); + } e_popup_add_items ((EPopup *)emp, menus, NULL, emft_popup_free, emft); -- cgit