aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/ChangeLog37
-rw-r--r--mail/folder-browser-factory.c8
-rw-r--r--mail/folder-browser-ui.c90
-rw-r--r--mail/folder-browser-ui.h3
-rw-r--r--mail/folder-browser.c15
-rw-r--r--mail/folder-browser.h1
-rw-r--r--mail/message-browser.c2
7 files changed, 108 insertions, 48 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 8f96dbab03..01a7b6b0a4 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,40 @@
+2001-10-24 <NotZed@Ximian.com>
+
+ * message-browser.c (message_browser_message_loaded): Call
+ ui_message_loaded when we are.
+
+ * folder-browser-factory.c (control_activate): Freeze/thaw around
+ all updates.
+ (control_deactivate): Freeze/thaw around all updates.
+
+ * folder-browser.c (folder_browser_init): Setup a hashtable to
+ keep track of *our* sensitise state, so we can optimise pushes to
+ bonobo.
+ (folder_browser_finalise): Free hash here.
+ (folder_browser_set_message_preview): Call a ui_message_loaded,
+ even though it isn't, so it updates sensitivities right.
+ (done_message_selected): Call ui_message_loaded when it really is,
+ rather than the very fucked up idea of reversing the loaded_uid
+ check.
+
+ * folder-browser-ui.c (folder_browser_ui_set_selection_state):
+ Dont enable the message-enabled options if the message display is
+ hidden, e.g. print, view headers, etc.
+ (folder_browser_ui_rm_all): Forget sensitise state.
+ (fbui_sensitise_item): Sensitise items via a current-state table,
+ so we dont have to do bonobo calls every time.
+ (folder_browser_setup_property_menu): Call sensitise_item.
+ (folder_browser_ui_add_message):
+ (folder_browser_ui_add_global): Leave current set_prop "sensitive"
+ for the stop button, so it doesn't get lost by the stuff in
+ mail-mt.c
+ (fbui_real_sensitize_items): Removed.
+ (fbui_sensitize_timeout): Cleaned up, use sensitise_item to do
+ work.
+ (folder_browser_ui_message_loaded): Setup sensitive based on
+ preview_shown too.
+ (folder_browser_ui_set_selection_state): And here too.
+
2001-10-23 Jeffrey Stedfast <fejj@ximian.com>
* mail-account-gui.c (service_check_supported): Don't allow an
diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c
index 86a51a0d59..c398e8b748 100644
--- a/mail/folder-browser-factory.c
+++ b/mail/folder-browser-factory.c
@@ -87,10 +87,14 @@ control_activate (BonoboControl *control,
folder_browser = bonobo_control_get_widget (control);
folder_browser_set_ui_component (FOLDER_BROWSER (folder_browser), uic);
+ bonobo_ui_component_freeze (uic, NULL);
+
folder_browser_ui_add_global (fb);
folder_browser_ui_add_list (fb);
folder_browser_ui_add_message (fb);
+ bonobo_ui_component_thaw (uic, NULL);
+
folder_browser_set_shell_view(fb, fb_get_svi (control));
if (fb->folder)
@@ -102,8 +106,12 @@ control_deactivate (BonoboControl *control,
BonoboUIComponent *uic,
FolderBrowser *fb)
{
+ bonobo_ui_component_freeze (uic, NULL);
+
folder_browser_ui_rm_list (fb);
folder_browser_ui_rm_all (fb);
+
+ bonobo_ui_component_thaw (uic, NULL);
if (fb->folder)
mail_sync_folder (fb->folder, NULL, NULL);
diff --git a/mail/folder-browser-ui.c b/mail/folder-browser-ui.c
index 12fd394cfe..1110470e28 100644
--- a/mail/folder-browser-ui.c
+++ b/mail/folder-browser-ui.c
@@ -30,6 +30,7 @@
#include "evolution-shell-component-utils.h" /* Pixmap stuff */
+
/*
* Add with 'folder_browser'
*/
@@ -279,12 +280,7 @@ folder_browser_setup_property_menu (FolderBrowser *fb,
if (url)
camel_url_free(url);
- if (strncmp(fb->uri, "vfolder:", 8) == 0 || strncmp(fb->uri, "file:", 5) == 0)
- name = "1";
- else
- name = "0";
- bonobo_ui_component_set_prop (uic, "/commands/ChangeFolderProperties", "sensitive", name, NULL);
-
+ fbui_sensitise_item(fb, "ChangeFolderProperties", (strncmp(fb->uri, "vfolder:", 8) == 0 || strncmp(fb->uri, "file:", 5) == 0));
}
/* Must be in the same order as MailConfigDisplayStyle */
@@ -319,7 +315,7 @@ folder_browser_ui_add_message (FolderBrowser *fb)
/* Resend Message */
if (fb->folder && !folder_browser_is_sent (fb))
- bonobo_ui_component_set_prop (uic, "/commands/MessageResend", "sensitive", "0", NULL);
+ fbui_sensitise_item(fb, "MessageResent", FALSE);
/* sensitivity of message-specific commands */
prev_state = fb->selection_state;
@@ -350,7 +346,7 @@ folder_browser_ui_add_list (FolderBrowser *fb)
/* Hide Deleted */
if (fb->folder && (fb->folder->folder_flags & CAMEL_FOLDER_IS_TRASH)) {
- bonobo_ui_component_set_prop (uic, "/commands/HideDeleted", "sensitive", "0", NULL);
+ fbui_sensitise_item(fb, "HideDeleted", FALSE);
state = FALSE;
} else {
state = mail_config_get_hide_deleted ();
@@ -400,7 +396,7 @@ folder_browser_ui_add_global (FolderBrowser *fb)
folder_browser_toggle_preview (uic, "", Bonobo_UIComponent_STATE_CHANGED, state ? "1" : "0", fb);
/* Stop button */
-
+ /* TODO: Go through cache, but we can't becaus eof mail-mt.c:set_stop at the moment */
bonobo_ui_component_set_prop(uic, "/commands/MailStop", "sensitive", "0", NULL);
}
@@ -418,31 +414,40 @@ folder_browser_ui_rm_all (FolderBrowser *fb)
bonobo_ui_component_rm (uic, "/", NULL);
bonobo_ui_component_unset_container (uic);
-}
-struct sensitize_data {
- const char **items;
- gboolean enable;
-};
+ if (fb->sensitise_state) {
+ g_hash_table_destroy(fb->sensitise_state);
+ fb->sensitise_state = NULL;
+ }
+}
-static void
-fbui_real_sensitize_items (BonoboUIComponent *uic, const char **items, gboolean enable)
+void
+fbui_sensitise_item(FolderBrowser *fb, const char *item, int state)
{
- int i;
- char name_buf[256]; /* this should really be large enough */
- char *value;
+ char *name;
+ int val;
+ char *key;
- if (enable)
- value = "1";
- else
- value = "0";
+ /* If this whole caching idea doesn't work, remove it here */
+ if (fb->sensitise_state == NULL)
+ fb->sensitise_state = g_hash_table_new(g_str_hash, g_str_equal);
- for (i = 0; items[i]; i++) {
- sprintf (name_buf, "/commands/%s", items[i]);
- bonobo_ui_component_set_prop (uic, name_buf, "sensitive", value, NULL);
+ if (g_hash_table_lookup_extended(fb->sensitise_state, item, (void **)&key, (void **)&val)) {
+ if (val == state)
+ return;
}
+
+ g_hash_table_insert(fb->sensitise_state, (char *)item, (void *)state);
+ 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);
}
+struct sensitize_data {
+ const char **items;
+ gboolean enable;
+};
+
static gboolean
fbui_sensitize_timeout (gpointer data)
{
@@ -450,23 +455,22 @@ fbui_sensitize_timeout (gpointer data)
BonoboUIComponent *uic = fb->uicomp;
GSList *iter;
struct sensitize_data *sd;
+ int i;
- if (uic)
+ if (uic) {
bonobo_ui_component_freeze (uic, NULL);
- for (iter = fb->sensitize_changes; iter; iter = iter->next) {
- sd = (struct sensitize_data *) iter->data;
- /* if UIC == NULL, we could just return TRUE, but we don't
- * know when UIC is going to come back... when it does,
- * the UI stuff will be reset, so no problem.
- */
+ for (iter = fb->sensitize_changes; iter; iter = iter->next) {
+ sd = (struct sensitize_data *) iter->data;
+ for (i=0;sd->items[i];i++)
+ fbui_sensitise_item(fb, sd->items[i], sd->enable);
+ g_free(sd);
+ }
- if (uic)
- fbui_real_sensitize_items (uic, sd->items, sd->enable);
- g_free (sd);
- }
- if (uic)
bonobo_ui_component_thaw (uic, NULL);
+ } else {
+ g_slist_foreach(fb->sensitize_changes, (GFunc)g_free, NULL);
+ }
g_slist_free (fb->sensitize_changes);
fb->sensitize_changes = NULL;
@@ -563,6 +567,9 @@ folder_browser_ui_set_selection_state (FolderBrowser *fb, FolderBrowserSelection
NULL
};
+
+ fbui_sensitize_items (fb, message_pane_enables, state != FB_SELSTATE_NONE && fb->loaded_uid && fb->preview_shown);
+
/* assumes that all the appropriate XML's have been loaded */
if (state == fb->selection_state)
@@ -591,9 +598,6 @@ folder_browser_ui_set_selection_state (FolderBrowser *fb, FolderBrowserSelection
return;
}
- if (fb->loaded_uid == NULL)
- fbui_sensitize_items (fb, message_pane_enables, FALSE);
-
fb->selection_state = state;
}
@@ -602,6 +606,6 @@ folder_browser_ui_message_loaded (FolderBrowser *fb)
{
BonoboUIComponent *uic = fb->uicomp;
- if (fb->loaded_uid == NULL && uic)
- fbui_sensitize_items (fb, message_pane_enables, TRUE);
+ if (uic)
+ fbui_sensitize_items (fb, message_pane_enables, fb->loaded_uid && fb->preview_shown);
}
diff --git a/mail/folder-browser-ui.h b/mail/folder-browser-ui.h
index 8bd0d13c1c..788ebb7b8d 100644
--- a/mail/folder-browser-ui.h
+++ b/mail/folder-browser-ui.h
@@ -24,4 +24,7 @@ void folder_browser_ui_rm_all (FolderBrowser *fb);
void folder_browser_ui_set_selection_state (FolderBrowser *fb, FolderBrowserSelectionState state);
void folder_browser_ui_message_loaded (FolderBrowser *fb);
+/* Set the sensitivity of a single item */
+void fbui_sensitise_item(FolderBrowser *fb, const char *item, int state);
+
#endif /* _FOLDER_BROWSER_UI_H */
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index 6f75607ee0..89b6f43524 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -169,6 +169,11 @@ folder_browser_finalise (GtkObject *object)
if (folder_browser->clipboard_selection)
g_byte_array_free (folder_browser->clipboard_selection, TRUE);
+
+ if (folder_browser->sensitise_state) {
+ g_hash_table_destroy(folder_browser->sensitise_state);
+ folder_browser->sensitise_state = NULL;
+ }
folder_browser_parent_class->finalize (object);
}
@@ -1019,16 +1024,15 @@ folder_browser_set_message_preview (FolderBrowser *folder_browser, gboolean show
if (show_message_preview) {
int y;
y = save_cursor_pos (folder_browser);
- e_paned_set_position (E_PANED (folder_browser->vpaned),
- mail_config_get_paned_size ());
+ e_paned_set_position (E_PANED (folder_browser->vpaned), mail_config_get_paned_size ());
gtk_widget_show (GTK_WIDGET (folder_browser->mail_display));
do_message_selected (folder_browser);
set_cursor_pos (folder_browser, y);
} else {
- e_paned_set_position (E_PANED (folder_browser->vpaned),
- 10000);
+ e_paned_set_position (E_PANED (folder_browser->vpaned), 10000);
gtk_widget_hide (GTK_WIDGET (folder_browser->mail_display));
mail_display_set_message(folder_browser->mail_display, NULL);
+ folder_browser_ui_message_loaded(folder_browser);
}
}
@@ -1856,7 +1860,6 @@ done_message_selected (CamelFolder *folder, char *uid, CamelMimeMessage *msg, vo
return;
mail_display_set_message (fb->mail_display, (CamelMedium *)msg);
- folder_browser_ui_message_loaded (fb);
/* FIXME: should this signal be emitted here?? */
gtk_signal_emit (GTK_OBJECT (fb), folder_browser_signals [MESSAGE_LOADED], uid);
@@ -1874,6 +1877,8 @@ done_message_selected (CamelFolder *folder, char *uid, CamelMimeMessage *msg, vo
g_free (fb->loaded_uid);
fb->loaded_uid = fb->loading_uid;
fb->loading_uid = NULL;
+
+ folder_browser_ui_message_loaded (fb);
/* if we are still on the same message, do the 'idle read' thing */
if (fb->seen_id)
diff --git a/mail/folder-browser.h b/mail/folder-browser.h
index f290587498..d5a494ce54 100644
--- a/mail/folder-browser.h
+++ b/mail/folder-browser.h
@@ -74,6 +74,7 @@ struct _FolderBrowser {
FolderBrowserSelectionState selection_state;
GSList *sensitize_changes;
+ GHashTable *sensitise_state; /* the last sent sensitise state, to avoid much bonobo overhead */
int sensitize_timeout_id;
/* View collection and the menu handler object */
diff --git a/mail/message-browser.c b/mail/message-browser.c
index 6d7ef49398..71a0a4464d 100644
--- a/mail/message-browser.c
+++ b/mail/message-browser.c
@@ -109,6 +109,8 @@ message_browser_message_loaded (FolderBrowser *fb, const char *uid, MessageBrows
CamelMimeMessage *message;
char *subject = NULL;
char *title;
+
+ folder_browser_ui_message_loaded(fb);
message = fb->mail_display->current_message;