From e29900ebe2fadd133dda97ce21be84dd6e8f0bdb Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 30 Jul 2010 06:16:49 +0000 Subject: added new global option 'Change current account on folder open'. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2649 ee746299-78ed-0310-b773-934348b2243d --- src/folderview.c | 14 ++++++++++++++ src/mainwindow.c | 16 +++++++++++----- src/mainwindow.h | 4 +++- src/prefs_common_dialog.c | 21 +++++++++++++++++++-- 4 files changed, 47 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/folderview.c b/src/folderview.c index a56c5ca6..467b5727 100644 --- a/src/folderview.c +++ b/src/folderview.c @@ -2105,6 +2105,20 @@ static void folderview_selection_changed(GtkTreeSelection *selection, gtk_tree_path_free(path); folderview->selection_locked = FALSE; + + if (prefs_common.change_account_on_folder_sel) { + PrefsAccount *account; + + account = account_find_from_item_property(item); + if (!account && item->folder) + account = item->folder->account; + if (!account) + account = account_get_default(); + if (account && account != cur_account) { + cur_account = account; + main_window_change_cur_account(); + } + } } static void folderview_row_expanded(GtkTreeView *treeview, GtkTreeIter *iter, diff --git a/src/mainwindow.c b/src/mainwindow.c index b00fb148..c1329202 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -1408,6 +1408,16 @@ static void main_window_show_cur_account(MainWindow *mainwin) g_free(ac_name); } +void main_window_change_cur_account(void) +{ + MainWindow *mainwin; + + mainwin = main_window_get(); + main_window_show_cur_account(mainwin); + main_window_set_menu_sensitive(mainwin); + main_window_set_toolbar_sensitive(mainwin); +} + MainWindow *main_window_get(void) { if (mainwin_list) @@ -3957,12 +3967,8 @@ static void new_account_cb(MainWindow *mainwin, guint action, static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data) { - MainWindow *mainwin = main_window_get(); - cur_account = (PrefsAccount *)data; - main_window_show_cur_account(mainwin); - main_window_set_menu_sensitive(mainwin); - main_window_set_toolbar_sensitive(mainwin); + main_window_change_cur_account(); } static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data) diff --git a/src/mainwindow.h b/src/mainwindow.h index 79a371d9..54686543 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2008 Hiroyuki Yamamoto + * Copyright (C) 1999-2010 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -147,6 +147,8 @@ void main_window_reflect_prefs_all (void); void main_window_set_summary_column (void); void main_window_set_account_menu (GList *account_list); +void main_window_change_cur_account (void); + MainWindow *main_window_get (void); GtkWidget *main_window_get_folder_window (MainWindow *mainwin); diff --git a/src/prefs_common_dialog.c b/src/prefs_common_dialog.c index e17ac789..5d2bae2e 100644 --- a/src/prefs_common_dialog.c +++ b/src/prefs_common_dialog.c @@ -200,9 +200,10 @@ static struct Interface { GtkWidget *checkbtn_always_show_msg; GtkWidget *checkbtn_openunread; GtkWidget *checkbtn_remember_lastsel; - GtkWidget *checkbtn_mark_as_read_on_newwin; + /* GtkWidget *checkbtn_mark_as_read_on_newwin; */ GtkWidget *checkbtn_openinbox; GtkWidget *checkbtn_openinbox_startup; + GtkWidget *checkbtn_change_account_on_folder_sel; GtkWidget *checkbtn_immedexec; #ifndef G_OS_WIN32 GtkWidget *checkbtn_comply_gnome_hig; @@ -505,13 +506,18 @@ static PrefsUIData ui_data[] = { prefs_set_data_from_toggle, prefs_set_toggle}, {"remember_last_selected", &interface.checkbtn_remember_lastsel, prefs_set_data_from_toggle, prefs_set_toggle}, +#if 0 {"mark_as_read_on_new_window", &interface.checkbtn_mark_as_read_on_newwin, prefs_set_data_from_toggle, prefs_set_toggle}, +#endif {"open_inbox_on_inc", &interface.checkbtn_openinbox, prefs_set_data_from_toggle, prefs_set_toggle}, {"open_inbox_on_startup", &interface.checkbtn_openinbox_startup, prefs_set_data_from_toggle, prefs_set_toggle}, + {"change_account_on_folder_selection", + &interface.checkbtn_change_account_on_folder_sel, + prefs_set_data_from_toggle, prefs_set_toggle}, {"immediate_execution", &interface.checkbtn_immedexec, prefs_set_data_from_toggle, prefs_set_toggle}, @@ -2330,9 +2336,10 @@ static void prefs_details_create(void) GtkWidget *checkbtn_always_show_msg; GtkWidget *checkbtn_openunread; GtkWidget *checkbtn_remember_lastsel; - GtkWidget *checkbtn_mark_as_read_on_newwin; + /* GtkWidget *checkbtn_mark_as_read_on_newwin; */ GtkWidget *checkbtn_openinbox; GtkWidget *checkbtn_openinbox_startup; + GtkWidget *checkbtn_change_account_on_folder_sel; GtkWidget *checkbtn_immedexec; GtkWidget *hbox1; GtkWidget *hbox_spc; @@ -2383,9 +2390,11 @@ static void prefs_details_create(void) (vbox2, checkbtn_remember_lastsel, _("Remember last selected message")); +#if 0 PACK_CHECK_BUTTON (vbox2, checkbtn_mark_as_read_on_newwin, _("Only mark message as read when opened in new window")); +#endif PACK_CHECK_BUTTON (vbox2, checkbtn_openinbox, @@ -2393,6 +2402,10 @@ static void prefs_details_create(void) PACK_CHECK_BUTTON (vbox2, checkbtn_openinbox_startup, _("Open inbox on startup")); + PACK_CHECK_BUTTON + (vbox2, checkbtn_change_account_on_folder_sel, + _("Change current account on folder open")); + vbox3 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox3); gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0); @@ -2464,10 +2477,14 @@ static void prefs_details_create(void) interface.checkbtn_always_show_msg = checkbtn_always_show_msg; interface.checkbtn_openunread = checkbtn_openunread; interface.checkbtn_remember_lastsel = checkbtn_remember_lastsel; +#if 0 interface.checkbtn_mark_as_read_on_newwin = checkbtn_mark_as_read_on_newwin; +#endif interface.checkbtn_openinbox = checkbtn_openinbox; interface.checkbtn_openinbox_startup = checkbtn_openinbox_startup; + interface.checkbtn_change_account_on_folder_sel = + checkbtn_change_account_on_folder_sel; interface.checkbtn_immedexec = checkbtn_immedexec; #ifndef G_OS_WIN32 -- cgit v1.2.3