diff options
author | jacob berkman <jacob@ximian.com> | 2001-06-26 05:12:10 +0800 |
---|---|---|
committer | Jacob Berkman <jberkman@src.gnome.org> | 2001-06-26 05:12:10 +0800 |
commit | 57db15334b2ea42d619024a48bda764af46d0e2a (patch) | |
tree | bcedce63814055decf0206e29deb9fec968148b6 | |
parent | 4d5ccfcb23509552645597c073fd0fa311701ded (diff) | |
download | gsoc2013-evolution-57db15334b2ea42d619024a48bda764af46d0e2a.tar.gz gsoc2013-evolution-57db15334b2ea42d619024a48bda764af46d0e2a.tar.zst gsoc2013-evolution-57db15334b2ea42d619024a48bda764af46d0e2a.zip |
sync folders after we've gotten mail
2001-06-25 jacob berkman <jacob@ximian.com>
* mail-send-recv.c (free_send_data): sync folders after we've
gotten mail
* folder-browser-factory.c (control_activate): set the ui
component on the folder browser
(control_activate): update the view preview item
(control_deactivate): don't sync the folder here
(control_deactivate): unset the ui component of the folder browser
* mail-callbacks.c (toggle_flags): stuff from jleach to add an
importance keybinding
(mark_as_important): ditto
(toggle_as_important): again
* mail-config.c (mail_config_get_show_preview):
(mail_config_set_show_preview): basically a copy of
get_thread_list() but for the preview pane
* folder-browser.c (folder_browser_destroy): unref the our ui
component
(folder_browser_set_ui_component): new function for setting the ui
component
(save_cursor_pos):
(set_cursor_pos): try to show the selected row when the preview
pane is shown
(folder_browser_set_message_preview): implement
(folder_browser_toggle_preview): toggle the preview (duh)
(on_key_press): add keybindings for marking as important (!), and
hiding the preview pane (q)
(etree_key): clean up a little bit, and make enter either show the
preview pane or open the message
(fb_resize_cb): only save the paned size if the preview is alread
shown
(folder_browser_gui_init): pass ourselves to fb_resize_cb
(on_message_selected): only add the timeout if the preview is
shown
svn path=/trunk/; revision=10491
-rw-r--r-- | mail/ChangeLog | 39 | ||||
-rw-r--r-- | mail/folder-browser-factory.c | 14 | ||||
-rw-r--r-- | mail/folder-browser.c | 152 | ||||
-rw-r--r-- | mail/folder-browser.h | 10 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 49 | ||||
-rw-r--r-- | mail/mail-callbacks.h | 3 | ||||
-rw-r--r-- | mail/mail-config.c | 48 | ||||
-rw-r--r-- | mail/mail-config.h | 3 | ||||
-rw-r--r-- | mail/mail-send-recv.c | 16 |
9 files changed, 314 insertions, 20 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 05ef8d82cf..485db80a67 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,42 @@ +2001-06-25 jacob berkman <jacob@ximian.com> + + * mail-send-recv.c (free_send_data): sync folders after we've + gotten mail + + * folder-browser-factory.c (control_activate): set the ui + component on the folder browser + (control_activate): update the view preview item + (control_deactivate): don't sync the folder here + (control_deactivate): unset the ui component of the folder browser + + * mail-callbacks.c (toggle_flags): stuff from jleach to add an + importance keybinding + (mark_as_important): ditto + (toggle_as_important): again + + * mail-config.c (mail_config_get_show_preview): + (mail_config_set_show_preview): basically a copy of + get_thread_list() but for the preview pane + + * folder-browser.c (folder_browser_destroy): unref the our ui + component + (folder_browser_set_ui_component): new function for setting the ui + component + (save_cursor_pos): + (set_cursor_pos): try to show the selected row when the preview + pane is shown + (folder_browser_set_message_preview): implement + (folder_browser_toggle_preview): toggle the preview (duh) + (on_key_press): add keybindings for marking as important (!), and + hiding the preview pane (q) + (etree_key): clean up a little bit, and make enter either show the + preview pane or open the message + (fb_resize_cb): only save the paned size if the preview is alread + shown + (folder_browser_gui_init): pass ourselves to fb_resize_cb + (on_message_selected): only add the timeout if the preview is + shown + 2001-06-25 Jeffrey Stedfast <fejj@ximian.com> * folder-browser.c (folder_browser_destroy): Unref the invisible diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c index 5f959cdc50..70e149a6bd 100644 --- a/mail/folder-browser-factory.c +++ b/mail/folder-browser-factory.c @@ -76,6 +76,7 @@ BonoboUIVerb verbs [] = { BONOBO_UI_UNSAFE_VERB ("MessageMarkAllAsRead", mark_all_as_seen), BONOBO_UI_UNSAFE_VERB ("MessageMarkAsRead", mark_as_seen), BONOBO_UI_UNSAFE_VERB ("MessageMarkAsUnRead", mark_as_unseen), + BONOBO_UI_UNSAFE_VERB ("MessageMarkAsImportant", mark_as_important), BONOBO_UI_UNSAFE_VERB ("MessageMove", move_msg), BONOBO_UI_UNSAFE_VERB ("MessageOpen", open_message), BONOBO_UI_UNSAFE_VERB ("MessageReplyAll", reply_to_all), @@ -245,6 +246,7 @@ control_activate (BonoboControl *control, g_return_if_fail (container != CORBA_OBJECT_NIL); folder_browser = bonobo_control_get_widget (control); + folder_browser_set_ui_component (FOLDER_BROWSER (folder_browser), uic); bonobo_ui_component_add_verb_list_with_data ( uic, verbs, folder_browser); @@ -254,6 +256,12 @@ control_activate (BonoboControl *control, bonobo_ui_util_set_ui ( uic, EVOLUTION_DATADIR, "evolution-mail.xml", "evolution-mail"); + + state = mail_config_get_show_preview (FOLDER_BROWSER (folder_browser)->uri); + bonobo_ui_component_set_prop (uic, "/commands/ViewPreview", "state", state ? "1" : "0", NULL); + bonobo_ui_component_add_listener (uic, "ViewPreview", folder_browser_toggle_preview, folder_browser); + /* FIXME: this kind of bypasses bonobo but seems the only way when we change components */ + folder_browser_toggle_preview (uic, "", Bonobo_UIComponent_STATE_CHANGED, state ? "1" : "0", folder_browser); state = mail_config_get_thread_list (FOLDER_BROWSER (folder_browser)->uri); bonobo_ui_component_set_prop (uic, "/commands/ViewThreaded", "state", state ? "1" : "0", NULL); @@ -307,9 +315,15 @@ control_deactivate (BonoboControl *control, bonobo_ui_component_rm (uic, "/", NULL); bonobo_ui_component_unset_container (uic); + /* turn this back on to get the old (broken) behaviour of + * synching when leaving a folder + */ +#if 0 if (fb->folder) mail_sync_folder (fb->folder, NULL, NULL); +#endif + folder_browser_set_ui_component (fb, NULL); folder_browser_discard_view_menus (fb); } diff --git a/mail/folder-browser.c b/mail/folder-browser.c index b50fae4a5d..80b7247bcc 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -77,7 +77,6 @@ static GdkAtom clipboard_atom = GDK_NONE; static GByteArray *clipboard_selection = NULL; static GtkWidget *invisible = NULL; -static void fb_resize_cb (GtkWidget *w, GtkAllocation *a); static void update_unread_count (CamelObject *, gpointer, gpointer); static GtkObjectClass *folder_browser_parent_class; @@ -112,6 +111,9 @@ folder_browser_destroy (GtkObject *object) if (folder_browser->shell != CORBA_OBJECT_NIL) CORBA_Object_release (folder_browser->shell, &ev); + + if (folder_browser->uicomp) + bonobo_object_unref (BONOBO_OBJECT (folder_browser->uicomp)); g_free (folder_browser->uri); @@ -579,6 +581,19 @@ folder_browser_set_uri (FolderBrowser *folder_browser, const char *uri) return TRUE; } +void +folder_browser_set_ui_component (FolderBrowser *fb, BonoboUIComponent *uicomp) +{ + g_return_if_fail (IS_FOLDER_BROWSER (fb)); + + if (fb->uicomp) + bonobo_object_unref (BONOBO_OBJECT (fb->uicomp)); + + if (uicomp) + bonobo_object_ref (BONOBO_OBJECT (uicomp)); + + fb->uicomp = uicomp; +} extern CamelFolder *drafts_folder, *sent_folder, *outbox_folder; @@ -656,13 +671,64 @@ folder_browser_is_outbox (FolderBrowser *fb) return fb->folder == outbox_folder; } +static int +save_cursor_pos (FolderBrowser *fb) +{ + ETreePath node; + GtkAdjustment *adj; + int row, y, height; + + node = e_tree_get_cursor (fb->message_list->tree); + if (!node) + return -1; + + row = e_tree_row_of_node (fb->message_list->tree, node); + + e_tree_get_cell_geometry (fb->message_list->tree, row, 0, + NULL, &y, NULL, &height); + + adj = e_scroll_frame_get_vadjustment (E_SCROLL_FRAME (fb->message_list)); + y += adj->value - ((mail_config_get_paned_size () - height) / 2); + + return y; +} + +static void +set_cursor_pos (FolderBrowser *fb, int y) +{ + GtkAdjustment *adj; + + if (y == -1) + return; + + adj = e_scroll_frame_get_vadjustment (E_SCROLL_FRAME (fb->message_list)); + gtk_adjustment_set_value (adj, (gfloat)y); +} + +static gboolean do_message_selected(FolderBrowser *fb); + void folder_browser_set_message_preview (FolderBrowser *folder_browser, gboolean show_message_preview) { if (folder_browser->preview_shown == show_message_preview) return; - - g_warning ("FIXME: implement me"); + + folder_browser->preview_shown = show_message_preview; + + 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 ()); + 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); + gtk_widget_hide (GTK_WIDGET (folder_browser->mail_display)); + mail_display_set_message(folder_browser->mail_display, NULL); + } } enum { @@ -756,6 +822,22 @@ folder_browser_search_query_changed (ESearchBar *esb, FolderBrowser *fb) } void +folder_browser_toggle_preview (BonoboUIComponent *component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + FolderBrowser *fb = user_data; + + if (type != Bonobo_UIComponent_STATE_CHANGED) + return; + + mail_config_set_show_preview (fb->uri, atoi (state)); + folder_browser_set_message_preview (fb, atoi (state)); +} + +void folder_browser_toggle_threads (BonoboUIComponent *component, const char *path, Bonobo_UIComponent_EventType type, @@ -1284,6 +1366,16 @@ on_key_press (GtkWidget *widget, GdkEventKey *key, gpointer data) on_right_click (fb->message_list->tree, row, path, 2, (GdkEvent *)key, fb); return TRUE; + case '!': + toggle_as_important (NULL, fb, NULL); + return TRUE; + case 'q': + case 'Q': + if (fb->preview_shown && fb->uicomp) + bonobo_ui_component_set_prop (fb->uicomp, + "/commands/ViewPreview", + "state", "0", NULL); + return TRUE; } return FALSE; @@ -1297,25 +1389,39 @@ etree_key (ETree *tree, int row, ETreePath path, int col, GdkEvent *ev, FolderBr if ((ev->key.state & GDK_CONTROL_MASK) != 0) return FALSE; - if (ev->key.keyval != GDK_space && ev->key.keyval != GDK_BackSpace) - return on_key_press ((GtkWidget *)tree, (GdkEventKey *)ev, fb); vadj = e_scroll_frame_get_vadjustment (fb->mail_display->scroll); page_size = vadj->page_size - vadj->step_increment; - if (ev->key.keyval == GDK_BackSpace) { - if (vadj->value > vadj->lower + page_size) - vadj->value -= page_size; - else - vadj->value = vadj->lower; - } else { + switch (ev->key.keyval) { + case GDK_space: if (vadj->value < vadj->upper - vadj->page_size - page_size) vadj->value += page_size; else vadj->value = vadj->upper - vadj->page_size; + gtk_adjustment_value_changed (vadj); + break; + case GDK_BackSpace: + if (vadj->value > vadj->lower + page_size) + vadj->value -= page_size; + else + vadj->value = vadj->lower; + gtk_adjustment_value_changed (vadj); + break; + case GDK_Return: + case GDK_KP_Enter: + case GDK_ISO_Enter: + if (fb->preview_shown) + open_msg (NULL, fb); + else if (fb->uicmp) + bonobo_ui_component_set_prop (fb->uicomp, + "/commands/ViewPreview", + "state", "1", NULL); + break; + default: + return on_key_press ((GtkWidget *)tree, (GdkEventKey *)ev, fb); } - gtk_adjustment_value_changed (vadj); return TRUE; } @@ -1332,6 +1438,13 @@ on_double_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *even } static void +fb_resize_cb (GtkWidget *w, GtkAllocation *a, FolderBrowser *fb) +{ + if (fb->preview_shown) + mail_config_set_paned_size (a->height); +} + +static void folder_browser_gui_init (FolderBrowser *fb) { /* The panned container */ @@ -1381,7 +1494,7 @@ folder_browser_gui_init (FolderBrowser *fb) gtk_widget_show (GTK_WIDGET (fb->message_list)); gtk_signal_connect (GTK_OBJECT (fb->message_list), "size_allocate", - GTK_SIGNAL_FUNC (fb_resize_cb), NULL); + GTK_SIGNAL_FUNC (fb_resize_cb), fb); e_paned_add2 (E_PANED (fb->vpaned), GTK_WIDGET (fb->mail_display)); e_paned_set_position (E_PANED (fb->vpaned), mail_config_get_paned_size ()); @@ -1488,7 +1601,9 @@ on_message_selected (MessageList *ml, const char *uid, FolderBrowser *fb) g_free(fb->new_uid); fb->new_uid = g_strdup(uid); - fb->loading_id = gtk_timeout_add(100, (GtkFunction)do_message_selected, fb); + + if (fb->preview_shown) + fb->loading_id = gtk_timeout_add(100, (GtkFunction)do_message_selected, fb); } static void @@ -1515,7 +1630,9 @@ my_folder_browser_init (GtkObject *object) */ fb->message_list = (MessageList *)message_list_new (); fb->mail_display = (MailDisplay *)mail_display_new (); - + + fb->preview_shown = TRUE; + e_scroll_frame_set_policy(E_SCROLL_FRAME(fb->message_list), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); @@ -1601,8 +1718,3 @@ folder_browser_new (const GNOME_Evolution_Shell shell) E_MAKE_TYPE (folder_browser, "FolderBrowser", FolderBrowser, folder_browser_class_init, folder_browser_init, PARENT_TYPE); - -static void fb_resize_cb (GtkWidget *w, GtkAllocation *a) -{ - mail_config_set_paned_size (a->height); -} diff --git a/mail/folder-browser.h b/mail/folder-browser.h index 4372d8cc22..943bcf2fc8 100644 --- a/mail/folder-browser.h +++ b/mail/folder-browser.h @@ -30,6 +30,7 @@ struct _FolderBrowser { BonoboPropertyBag *properties; GNOME_Evolution_Shell shell; + BonoboUIComponent *uicomp; /* * The current URI being displayed by the FolderBrowser @@ -84,6 +85,9 @@ struct fb_ondemand_closure { GtkType folder_browser_get_type (void); GtkWidget *folder_browser_new (const GNOME_Evolution_Shell shell); +void folder_browser_set_ui_component (FolderBrowser *fb, + BonoboUIComponent *uicomp); + gboolean folder_browser_set_uri (FolderBrowser *folder_browser, const char *uri); @@ -113,6 +117,12 @@ void hide_none(GtkWidget *w, FolderBrowser *fb); void hide_subject(GtkWidget *w, FolderBrowser *fb); void hide_sender(GtkWidget *w, FolderBrowser *fb); +void folder_browser_toggle_preview (BonoboUIComponent *component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data); + void folder_browser_toggle_threads (BonoboUIComponent *component, const char *path, Bonobo_UIComponent_EventType type, diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index 730df51c5e..e5e359e219 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -1024,6 +1024,42 @@ flag_messages(FolderBrowser *fb, guint32 mask, guint32 set) return i; } +static int +toggle_flags (FolderBrowser *fb, guint32 mask) +{ + MessageList *ml = fb->message_list; + GPtrArray *uids; + int i; + + if (ml->folder == NULL) + return 0; + + /* could just use specific callback but i'm lazy */ + uids = g_ptr_array_new (); + message_list_foreach (ml, enumerate_msg, uids); + camel_folder_freeze (ml->folder); + for (i = 0; i < uids->len; i++) { + gint flags; + + flags = camel_folder_get_message_flags (ml->folder, uids->pdata[i]); + + if (flags & mask) + camel_folder_set_message_flags (ml->folder, uids->pdata[i], mask, 0); + else { + if ((mask & CAMEL_MESSAGE_FLAGGED) && (flags & CAMEL_MESSAGE_DELETED)) + camel_folder_set_message_flags (ml->folder, uids->pdata[i], CAMEL_MESSAGE_DELETED, 0); + camel_folder_set_message_flags (ml->folder, uids->pdata[i], mask, mask); + } + + g_free (uids->pdata[i]); + } + camel_folder_thaw (ml->folder); + + g_ptr_array_free (uids, TRUE); + + return i; +} + void mark_as_seen (BonoboUIComponent *uih, void *user_data, const char *path) { @@ -1043,6 +1079,19 @@ mark_all_as_seen (BonoboUIComponent *uih, void *user_data, const char *path) flag_messages (FOLDER_BROWSER (user_data), CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN); } +void +mark_as_important (BonoboUIComponent *uih, void *user_data, const char *path) +{ + flag_messages (FOLDER_BROWSER (user_data), CAMEL_MESSAGE_DELETED, 0); + flag_messages (FOLDER_BROWSER (user_data), CAMEL_MESSAGE_FLAGGED, CAMEL_MESSAGE_FLAGGED); +} + +void +toggle_as_important (BonoboUIComponent *uih, void *user_data, const char *path) +{ + toggle_flags (FOLDER_BROWSER (user_data), CAMEL_MESSAGE_FLAGGED); +} + static void do_edit_messages(CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, void *data) { diff --git a/mail/mail-callbacks.h b/mail/mail-callbacks.h index 836401e520..cb7ee409e4 100644 --- a/mail/mail-callbacks.h +++ b/mail/mail-callbacks.h @@ -85,6 +85,9 @@ void invert_selection (BonoboUIComponent *uih, void *user_data, const char void mark_as_seen (BonoboUIComponent *uih, void *user_data, const char *path); void mark_all_as_seen (BonoboUIComponent *uih, void *user_data, const char *path); void mark_as_unseen (BonoboUIComponent *uih, void *user_data, const char *path); +void mark_as_important (BonoboUIComponent *uih, void *user_data, const char *path); +void toggle_as_important (BonoboUIComponent *uih, void *user_data, const char *path); + void edit_message (BonoboUIComponent *uih, void *user_data, const char *path); void open_message (BonoboUIComponent *uih, void *user_data, const char *path); void expunge_folder (BonoboUIComponent *uih, void *user_data, const char *path); diff --git a/mail/mail-config.c b/mail/mail-config.c index dadf4e3123..1bf052fa5b 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -51,6 +51,7 @@ #include "Mail.h" typedef struct { + gboolean show_preview; gboolean thread_list; gboolean hide_deleted; gint paned_size; @@ -72,6 +73,7 @@ typedef struct { char *default_charset; GHashTable *threaded_hash; + GHashTable *preview_hash; } MailConfig; static const char GCONFPATH[] = "/apps/Evolution/Mail"; @@ -793,6 +795,52 @@ mail_config_is_configured (void) } gboolean +mail_config_get_show_preview (const char *uri) +{ + if (uri) { + gboolean value = FALSE; + + if (!config->preview_hash) + config->preview_hash = g_hash_table_new (g_str_hash, g_str_equal); + else + value = GPOINTER_TO_INT (g_hash_table_lookup (config->preview_hash, uri)); + + if (!value) { + /* just in case we got a NULL because it just wasn't in the hash table yet */ + gboolean def; + char *str; + + str = g_strdup_printf ("=%s/config/Mail=/Preview/%s", evolution_dir, uri); + value = gnome_config_get_bool_with_default (str, &def); + g_free (str); + + if (!def) { + g_hash_table_insert (config->preview_hash, g_strdup (uri), + GINT_TO_POINTER (value)); + return value; + } + } else + return value; + } + + /* return the default value */ + + return config->show_preview; +} + +void +mail_config_set_show_preview (const char *uri, gboolean value) +{ + if (uri) { + if (!config->preview_hash) + config->preview_hash = g_hash_table_new (g_str_hash, g_str_equal); + + g_hash_table_insert (config->preview_hash, g_strdup (uri), GINT_TO_POINTER (value)); + } else + config->show_preview = value; +} + +gboolean mail_config_get_thread_list (const char *uri) { if (uri) { diff --git a/mail/mail-config.h b/mail/mail-config.h index a068e9f4ac..bd030f6f28 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -107,6 +107,9 @@ gboolean mail_config_is_configured (void); gboolean mail_config_get_thread_list (const char *uri); void mail_config_set_thread_list (const char *uri, gboolean value); +gboolean mail_config_get_show_preview (const char *uri); +void mail_config_set_show_preview (const char *uri, gboolean value); + gboolean mail_config_get_hide_deleted (void); void mail_config_set_hide_deleted (gboolean value); diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c index f59f322a3d..ac1d58ab19 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -50,6 +50,10 @@ #include "mail-ops.h" #include "mail-send-recv.h" +#include "folder-browser-factory.h" +#include "folder-browser.h" +#include "e-util/e-list.h" + #define d(x) /* ms between status updates to the gui */ @@ -164,6 +168,8 @@ static void free_send_data(void) { struct _send_data *data = send_data; + EList *list; + EIterator *it; g_assert(g_hash_table_size(data->active) == 0); @@ -179,6 +185,16 @@ free_send_data(void) } g_free(data); send_data = NULL; + + list = folder_browser_factory_get_control_list (); + for (it = e_list_get_iterator (list); e_iterator_is_valid (it); e_iterator_next (it)) { + BonoboControl *control = e_iterator_get (it); + if (control) { + FolderBrowser *fb = bonobo_control_get_widget (control); + if (fb && fb->folder) + mail_sync_folder (fb->folder, NULL, NULL); + } + } } |