aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Williams <peterw@ximian.com>2002-08-29 02:14:38 +0800
committerPeter Williams <peterw@src.gnome.org>2002-08-29 02:14:38 +0800
commit46cea1ca0b850344f45ff1647a179a88f2299555 (patch)
treebcae0e8190c3f9b782295c6b437fd7120305b2d6
parentc56f0963c4f1d11983d4ca8c3c4269bf6d8048cc (diff)
downloadgsoc2013-evolution-46cea1ca0b850344f45ff1647a179a88f2299555.tar
gsoc2013-evolution-46cea1ca0b850344f45ff1647a179a88f2299555.tar.gz
gsoc2013-evolution-46cea1ca0b850344f45ff1647a179a88f2299555.tar.bz2
gsoc2013-evolution-46cea1ca0b850344f45ff1647a179a88f2299555.tar.lz
gsoc2013-evolution-46cea1ca0b850344f45ff1647a179a88f2299555.tar.xz
gsoc2013-evolution-46cea1ca0b850344f45ff1647a179a88f2299555.tar.zst
gsoc2013-evolution-46cea1ca0b850344f45ff1647a179a88f2299555.zip
Add some new flags for sensitizing nodes based on the flags of the
2002-08-28 Peter Williams <peterw@ximian.com> * folder-browser-ui.c (default_ui_nodes): Add some new flags for sensitizing nodes based on the flags of the currently selected messages. (folder_browser_ui_add_message): Reset the sensitivity cache when we re-add UI items. (folder_browser_ui_add_list): Same. (folder_browser_ui_add_global): Same. (fbui_sensitise_item): Only cache the sensitivity in the hash table if we actually change it. (folder_browser_ui_scan_selection): New function, getting the bulk of the contents of folder_browser_ui_set_selection_state. Now with code to iterate over the currently selected messages and check their flags so we can sensitize based on them. (folder_browser_ui_set_selection_state): Now just set the selection state if necessary and pass off to _scan_selection. Don't skip of we're trying to go from SELSTATE_SINGLE to SELSTATE_SINGLE, eg, as the flags of the selected messages may have changed. * folder-browser-ui.h: Prototype folder_browser_ui_scan_selection. * folder-browser.c (main_folder_changed): Call folder_browser_ui_scan_selection as the flags on a selected message may have just changed. svn path=/trunk/; revision=17893
-rw-r--r--mail/ChangeLog26
-rw-r--r--mail/folder-browser-ui.c123
-rw-r--r--mail/folder-browser-ui.h1
-rw-r--r--mail/folder-browser.c1
4 files changed, 134 insertions, 17 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index d60bc5b932..e734feb71b 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,31 @@
2002-08-28 Peter Williams <peterw@ximian.com>
+ * folder-browser-ui.c (default_ui_nodes): Add some new flags for
+ sensitizing nodes based on the flags of the currently selected
+ messages.
+ (folder_browser_ui_add_message): Reset the sensitivity cache when
+ we re-add UI items.
+ (folder_browser_ui_add_list): Same.
+ (folder_browser_ui_add_global): Same.
+ (fbui_sensitise_item): Only cache the sensitivity in the hash
+ table if we actually change it.
+ (folder_browser_ui_scan_selection): New function, getting the bulk
+ of the contents of folder_browser_ui_set_selection_state. Now
+ with code to iterate over the currently selected messages and
+ check their flags so we can sensitize based on them.
+ (folder_browser_ui_set_selection_state): Now just set the
+ selection state if necessary and pass off to _scan_selection. Don't
+ skip of we're trying to go from SELSTATE_SINGLE to SELSTATE_SINGLE,
+ eg, as the flags of the selected messages may have changed.
+
+ * folder-browser-ui.h: Prototype folder_browser_ui_scan_selection.
+
+ * folder-browser.c (main_folder_changed): Call
+ folder_browser_ui_scan_selection as the flags on a selected
+ message may have just changed.
+
+2002-08-28 Peter Williams <peterw@ximian.com>
+
* mail-format.c (component_supports): Also check that the component
has PersistStream.
(mail_lookup_handler): Get a list of all components and go with the
diff --git a/mail/folder-browser-ui.c b/mail/folder-browser-ui.c
index 0135872d2d..1cddc16969 100644
--- a/mail/folder-browser-ui.c
+++ b/mail/folder-browser-ui.c
@@ -15,6 +15,7 @@
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-util.h> /* gnome_util_prepend_user_home */
+#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-ui-component.h>
#include <bonobo/bonobo-ui-util.h>
@@ -189,11 +190,22 @@ enum {
IS_THREADED = (1 << 7),
NOT_THREADED = (1<<8),
ANY_THREADED = (IS_THREADED|NOT_THREADED),
+
+ HAS_UNDELETED = (1 << 9),
+ HAS_DELETED = (1 << 10),
+ HAS_UNREAD = (1 << 11),
+ HAS_READ = (1 << 12),
+ HAS_UNIMPORTANT = (1 << 13),
+ HAS_IMPORTANT = (1 << 14)
};
-#define IS_1MESSAGE (IS_ANY_FOLDER | SELECTION_SINGLE | ANY_THREADED)
-#define IS_0MESSAGE (IS_ANY_FOLDER | SELECTION_ANYTHING | SELECTION_NONE | ANY_THREADED)
-#define IS_NMESSAGE (IS_ANY_FOLDER | SELECTION_ANYTHING | ANY_THREADED)
+#define HAS_FLAGS (HAS_UNDELETED | HAS_DELETED | \
+ HAS_UNREAD | HAS_READ | \
+ HAS_UNIMPORTANT | HAS_IMPORTANT)
+
+#define IS_1MESSAGE (IS_ANY_FOLDER | SELECTION_SINGLE | ANY_THREADED | HAS_FLAGS)
+#define IS_0MESSAGE (IS_ANY_FOLDER | SELECTION_ANYTHING | SELECTION_NONE | ANY_THREADED | HAS_FLAGS)
+#define IS_NMESSAGE (IS_ANY_FOLDER | SELECTION_ANYTHING | ANY_THREADED | HAS_FLAGS)
struct _UINode {
const char *name;
@@ -237,12 +249,12 @@ struct _UINode default_ui_nodes[] = {
{ "MessageApplyFilters", IS_NMESSAGE },
{ "MessageCopy", IS_NMESSAGE },
{ "MessageMove", IS_NMESSAGE },
- { "MessageDelete", IS_NMESSAGE },
- { "MessageUndelete", IS_NMESSAGE },
- { "MessageMarkAsRead", IS_NMESSAGE },
- { "MessageMarkAsUnRead", IS_NMESSAGE },
- { "MessageMarkAsImportant", IS_NMESSAGE },
- { "MessageMarkAsUnimportant", IS_NMESSAGE },
+ { "MessageDelete", IS_NMESSAGE & ~HAS_UNDELETED },
+ { "MessageUndelete", IS_NMESSAGE & ~HAS_DELETED },
+ { "MessageMarkAsRead", IS_NMESSAGE & ~HAS_UNREAD },
+ { "MessageMarkAsUnRead", IS_NMESSAGE & ~HAS_READ },
+ { "MessageMarkAsImportant", IS_NMESSAGE & ~HAS_UNIMPORTANT },
+ { "MessageMarkAsUnimportant", IS_NMESSAGE & ~HAS_IMPORTANT },
{ "MessageFollowUpFlag", IS_NMESSAGE },
{ "MessageOpen", IS_NMESSAGE },
{ "MessageSaveAs", IS_NMESSAGE },
@@ -475,6 +487,11 @@ folder_browser_ui_add_message (FolderBrowser *fb)
BonoboUIComponent *uic = fb->uicomp;
FolderBrowserSelectionState prev_state;
+ if (fb->sensitise_state) {
+ g_hash_table_destroy(fb->sensitise_state);
+ fb->sensitise_state = NULL;
+ }
+
ui_add (fb, "message", message_verbs, message_pixcache);
/* Display Style */
@@ -509,6 +526,11 @@ folder_browser_ui_add_list (FolderBrowser *fb)
BonoboUIComponent *uic = fb->uicomp;
int state;
+ if (fb->sensitise_state) {
+ g_hash_table_destroy(fb->sensitise_state);
+ fb->sensitise_state = NULL;
+ }
+
ui_add (fb, "list", list_verbs, list_pixcache);
/* Hide Deleted */
@@ -553,6 +575,11 @@ folder_browser_ui_add_global (FolderBrowser *fb)
{
int state;
BonoboUIComponent *uic = fb->uicomp;
+
+ if (fb->sensitise_state) {
+ g_hash_table_destroy(fb->sensitise_state);
+ fb->sensitise_state = NULL;
+ }
ui_add (fb, "global", global_verbs, global_pixcache);
@@ -598,12 +625,11 @@ fbui_sensitise_item (FolderBrowser *fb, const char *item, int state)
return;
}
- g_hash_table_insert (fb->sensitise_state, (char *)item, (void *)state);
-
if (fb->uicomp) {
name = alloca (strlen (item) + strlen ("/commands/") + 1);
sprintf (name, "/commands/%s", item);
bonobo_ui_component_set_prop (fb->uicomp, name, "sensitive", state ? "1" : "0", NULL);
+ g_hash_table_insert (fb->sensitise_state, (char *) item, (gpointer) state);
}
}
@@ -620,14 +646,61 @@ fbui_sensitize_items (FolderBrowser *fb, guint32 enable_mask)
}
void
-folder_browser_ui_set_selection_state (FolderBrowser *fb, FolderBrowserSelectionState state)
+folder_browser_ui_scan_selection (FolderBrowser *fb)
{
gboolean outgoing = FALSE;
guint32 enable_mask = 0;
- if (state == fb->selection_state)
- return;
-
+ if (fb->selection_state == FB_SELSTATE_SINGLE ||
+ fb->selection_state == FB_SELSTATE_MULTIPLE) {
+ GPtrArray *uids;
+ CamelMessageInfo *info;
+ guint32 temp_mask = 0;
+ int i;
+
+ uids = g_ptr_array_new ();
+ message_list_foreach (fb->message_list, enumerate_msg, uids);
+
+ for (i = 0; i < uids->len; i++) {
+
+ info = camel_folder_get_message_info (fb->folder, uids->pdata[i]);
+ if (info == NULL)
+ continue;
+
+ if (info->flags & CAMEL_MESSAGE_DELETED)
+ temp_mask |= HAS_DELETED;
+ else
+ temp_mask |= HAS_UNDELETED;
+
+ if (info->flags & CAMEL_MESSAGE_SEEN)
+ temp_mask |= HAS_READ;
+ else
+ temp_mask |= HAS_UNREAD;
+
+ if (info->flags & CAMEL_MESSAGE_FLAGGED)
+ temp_mask |= HAS_IMPORTANT;
+ else
+ temp_mask |= HAS_UNIMPORTANT;
+
+
+ camel_folder_free_message_info (fb->folder, info);
+ g_free (uids->pdata[i]);
+ }
+
+ g_ptr_array_free (uids, TRUE);
+
+ /* yeah, the naming is a bit backwards, but we need to support
+ * the case when, say, both a deleted and an undeleted message
+ * are selected. Both the Delete and Undelete menu items should
+ * be sensitized, but the only good way to set the flags is as
+ * above. Anyway, the naming is a bit of a lie but it works out
+ * so that it's sensible both above and in the definition of
+ * the UI items, so deal with it.
+ */
+
+ enable_mask |= (~temp_mask & HAS_FLAGS);
+ }
+
if (folder_browser_is_drafts (fb)) {
enable_mask |= IS_DRAFTS_FOLDER;
outgoing = TRUE;
@@ -651,7 +724,7 @@ folder_browser_ui_set_selection_state (FolderBrowser *fb, FolderBrowserSelection
if (outgoing == FALSE)
enable_mask |= IS_INCOMING_FOLDER;
- switch (state) {
+ switch (fb->selection_state) {
case FB_SELSTATE_SINGLE:
enable_mask |= SELECTION_SINGLE;
break;
@@ -663,10 +736,26 @@ folder_browser_ui_set_selection_state (FolderBrowser *fb, FolderBrowserSelection
enable_mask |= SELECTION_NONE;
break;
}
-
+
fbui_sensitize_items (fb, enable_mask);
+}
+
+void
+folder_browser_ui_set_selection_state (FolderBrowser *fb, FolderBrowserSelectionState state)
+{
+ /* the state may be the same but with
+ * different messages selected, necessitating
+ * a recheck of the flags of the selected
+ * messages.
+ */
+
+ if (state == fb->selection_state &&
+ state != FB_SELSTATE_SINGLE &&
+ state != FB_SELSTATE_MULTIPLE)
+ return;
fb->selection_state = state;
+ folder_browser_ui_scan_selection (fb);
}
void
diff --git a/mail/folder-browser-ui.h b/mail/folder-browser-ui.h
index 0d305cb277..5c2bc1fa28 100644
--- a/mail/folder-browser-ui.h
+++ b/mail/folder-browser-ui.h
@@ -21,6 +21,7 @@ void folder_browser_ui_rm_list (FolderBrowser *fb);
void folder_browser_ui_rm_all (FolderBrowser *fb);
/* these affect the sensitivity of UI elements */
+void folder_browser_ui_scan_selection (FolderBrowser *fb);
void folder_browser_ui_set_selection_state (FolderBrowser *fb, FolderBrowserSelectionState state);
void folder_browser_ui_message_loaded (FolderBrowser *fb);
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index 1ef7039d7c..6c9b13d68c 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -823,6 +823,7 @@ static void main_folder_changed(CamelObject *o, void *event_data, void *data)
/* so some corba unref doesnt blow us away while we're busy */
gtk_object_ref((GtkObject *)fb);
update_status_bar(fb);
+ folder_browser_ui_scan_selection (fb);
gtk_object_unref((GtkObject *)fb);
}