aboutsummaryrefslogtreecommitdiffstats
path: root/mail/folder-browser-ui.c
diff options
context:
space:
mode:
author4 <NotZed@Ximian.com>2001-10-24 10:56:06 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-10-24 10:56:06 +0800
commite4fa983be5e2c6a6496ba02f5391800ecee4575d (patch)
tree648176650d5c3f1e2b8dac2f225bc2ca89fe6069 /mail/folder-browser-ui.c
parentd6088ab1f0e058c35cab4ef247231ca07d456de4 (diff)
downloadgsoc2013-evolution-e4fa983be5e2c6a6496ba02f5391800ecee4575d.tar
gsoc2013-evolution-e4fa983be5e2c6a6496ba02f5391800ecee4575d.tar.gz
gsoc2013-evolution-e4fa983be5e2c6a6496ba02f5391800ecee4575d.tar.bz2
gsoc2013-evolution-e4fa983be5e2c6a6496ba02f5391800ecee4575d.tar.lz
gsoc2013-evolution-e4fa983be5e2c6a6496ba02f5391800ecee4575d.tar.xz
gsoc2013-evolution-e4fa983be5e2c6a6496ba02f5391800ecee4575d.tar.zst
gsoc2013-evolution-e4fa983be5e2c6a6496ba02f5391800ecee4575d.zip
all this crap just to make the print icon desensitive at the right time.
fix for #10346 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. svn path=/trunk/; revision=13972
Diffstat (limited to 'mail/folder-browser-ui.c')
-rw-r--r--mail/folder-browser-ui.c90
1 files changed, 47 insertions, 43 deletions
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);
}