/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
- *
- * 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "defs.h"
#include "procmsg.h"
#include "import.h"
#include "export.h"
+#include "edittags.h"
#include "prefs_common.h"
#include "prefs_actions.h"
#include "prefs_filtering.h"
#include "foldersort.h"
#include "icon_legend.h"
#include "colorlabel.h"
+#include "tags.h"
#include "textview.h"
#include "imap.h"
#include "socket.h"
static GdkCursor *watch_cursor = NULL;
static GdkCursor *hand_cursor = NULL;
+static gint iconified_count = 0;
+
static void main_window_menu_callback_block (MainWindow *mainwin);
static void main_window_menu_callback_unblock (MainWindow *mainwin);
static void log_window_show_cb (MainWindow *mainwin,
guint action,
GtkWidget *widget);
+static void filtering_debug_window_show_cb (MainWindow *mainwin,
+ guint action,
+ GtkWidget *widget);
static void inc_cancel_cb (MainWindow *mainwin,
guint action,
static void prefs_actions_open_cb (MainWindow *mainwin,
guint action,
GtkWidget *widget);
+static void prefs_tags_open_cb (MainWindow *mainwin,
+ guint action,
+ GtkWidget *widget);
static void prefs_account_open_cb (MainWindow *mainwin,
guint action,
GtkWidget *widget);
static gboolean mainwindow_visibility_event_cb (GtkWidget *widget,
GdkEventVisibility *state,
gpointer data);
+static gboolean mainwindow_state_event_cb (GtkWidget *widget,
+ GdkEventWindowState *state,
+ gpointer data);
static void main_window_reply_cb (MainWindow *mainwin,
guint action,
GtkWidget *widget);
{N_("/_View/Layout/_Three columns"), NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
{N_("/_View/Layout/_Wide message"), NULL, set_layout_cb, WIDE_LAYOUT, "/View/Layout/Standard"},
{N_("/_View/Layout/W_ide message list"),NULL, set_layout_cb, WIDE_MSGLIST_LAYOUT, "/View/Layout/Standard"},
+ {N_("/_View/Layout/S_mall screen"), NULL, set_layout_cb, SMALL_LAYOUT, "/View/Layout/Standard"},
{N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
{N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
{N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
{N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
+ {N_("/_View/_Sort/by Thread date"), NULL, sort_summary_cb, SORT_BY_THREAD_DATE, "/View/Sort/by number"},
{N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
{N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
{N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
- {N_("/_View/_Sort/by _color label"),
- NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
+ {N_("/_View/_Sort/by _color label"), NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
+ {N_("/_View/_Sort/by tag"), NULL, sort_summary_cb, SORT_BY_TAGS, "/View/Sort/by number"},
{N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
{N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
{N_("/_View/_Sort/by a_ttachment"),
{N_("/_Message/_Mark/Lock"), NULL, lock_msgs_cb, 0, NULL},
{N_("/_Message/_Mark/Unlock"), NULL, unlock_msgs_cb, 0, NULL},
{N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
+ {N_("/_Message/T_ags"), NULL, NULL, 0, NULL},
{N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
NULL, ssl_manager_open_cb, 0, NULL},
#endif
{N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
+ {N_("/_Tools/Filtering Log"), NULL, filtering_debug_window_show_cb, 0, NULL},
+ {N_("/_Tools/Network _Log"), "<shift><control>L", log_window_show_cb, 0, NULL},
{N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
{N_("/_Configuration/C_hange current account"),
NULL, prefs_filtering_open_cb, 0, NULL},
{N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
{N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
+ {N_("/_Configuration/Tag_s..."), NULL, prefs_tags_open_cb, 0, NULL},
+ {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
{N_("/_Help"), NULL, NULL, 0, "<Branch>"},
} else
g_warning("invalid number of color elements (%d)\n", n);
+ g_slist_free(sel);
/* reset "dont_toggle" state */
g_object_set_data(G_OBJECT(menu), "dont_toggle",
GINT_TO_POINTER(0));
summary_set_colorlabel(mainwin->summaryview, color, NULL);
}
+static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
+ gpointer data)
+{
+ MainWindow *mainwin;
+ GtkMenuShell *menu;
+ GList *cur;
+ GSList *sel;
+ GHashTable *menu_table = g_hash_table_new_full(
+ g_direct_hash,
+ g_direct_equal,
+ NULL, NULL);
+
+ mainwin = (MainWindow *)data;
+ g_return_if_fail(mainwin != NULL);
+
+ sel = summary_get_selection(mainwin->summaryview);
+ if (!sel) return;
+
+ menu = GTK_MENU_SHELL(mainwin->tags_menu);
+ g_return_if_fail(menu != NULL);
+
+ /* NOTE: don't return prematurely because we set the "dont_toggle"
+ * state for check menu items */
+ g_object_set_data(G_OBJECT(menu), "dont_toggle",
+ GINT_TO_POINTER(1));
+
+ /* clear items. get item pointers. */
+ for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
+ if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
+ gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
+ "tag_id"));
+ gtk_check_menu_item_set_active
+ (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
+
+ g_hash_table_insert(menu_table, GINT_TO_POINTER(id), GTK_CHECK_MENU_ITEM(cur->data));
+ }
+ }
+
+ /* iterate all messages and set the state of the appropriate
+ * items */
+ for (; sel != NULL; sel = sel->next) {
+ MsgInfo *msginfo;
+ GSList *tags = NULL;
+ gint id;
+ GtkCheckMenuItem *item;
+ msginfo = (MsgInfo *)sel->data;
+ if (msginfo) {
+ tags = msginfo->tags;
+ if (!tags)
+ continue;
+
+ for (; tags; tags = tags->next) {
+ id = GPOINTER_TO_INT(tags->data);
+ item = g_hash_table_lookup(menu_table, GINT_TO_POINTER(tags->data));
+ if (item && !item->active)
+ gtk_check_menu_item_set_active
+ (item, TRUE);
+ }
+ }
+ }
+
+ g_slist_free(sel);
+ g_hash_table_destroy(menu_table);
+ /* reset "dont_toggle" state */
+ g_object_set_data(G_OBJECT(menu), "dont_toggle",
+ GINT_TO_POINTER(0));
+}
+
+static void mainwindow_tags_menu_item_activate_cb(GtkWidget *widget,
+ gpointer data)
+{
+ gint id = GPOINTER_TO_INT(data);
+ gboolean set = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
+ MainWindow *mainwin;
+
+ mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
+ g_return_if_fail(mainwin != NULL);
+
+ /* "dont_toggle" state set? */
+ if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
+ "dont_toggle"))
+ return;
+
+ if (!set)
+ id = -id;
+ summary_set_tag(mainwin->summaryview, id, NULL);
+}
+
static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
{
GtkWidget *label_menuitem;
g_object_set_data(G_OBJECT(item), "mainwin",
mainwin);
gtk_widget_show(item);
- gtk_widget_add_accelerator(item, "activate",
+ if (i < 9)
+ gtk_widget_add_accelerator(item, "activate",
mainwin->menu_factory->accel_group,
GDK_1+i, GDK_CONTROL_MASK,
GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
}
-
gtk_widget_show(menu);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
mainwin->colorlabel_menu = menu;
}
+static void mainwindow_tags_menu_item_new_tag_activate_cb(GtkWidget *widget,
+ gpointer data)
+{
+ MainWindow *mainwin;
+ gint id;
+ mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
+ g_return_if_fail(mainwin != NULL);
+
+ /* "dont_toggle" state set? */
+ if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
+ "dont_toggle"))
+ return;
+
+ id = prefs_tags_create_new(mainwin);
+ if (id != -1) {
+ summary_set_tag(mainwin->summaryview, id, NULL);
+ main_window_reflect_tags_changes(mainwindow_get_mainwindow());
+ }
+}
+
+static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
+{
+ GtkWidget *label_menuitem;
+ GtkWidget *menu;
+ GtkWidget *item;
+ GSList *cur = tags_get_list();
+ GSList *orig = cur;
+ gboolean existing_tags = FALSE;
+
+ label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
+ "/Message/Tags");
+ g_signal_connect(G_OBJECT(label_menuitem), "activate",
+ G_CALLBACK(mainwindow_tags_menu_item_activate_item_cb),
+ mainwin);
+
+ gtk_widget_show(label_menuitem);
+
+ menu = gtk_menu_new();
+
+ /* create tags menu items */
+ for (; cur; cur = cur->next) {
+ gint id = GPOINTER_TO_INT(cur->data);
+ const gchar *tag = tags_get_tag(id);
+
+ item = gtk_check_menu_item_new_with_label(tag);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+ g_signal_connect(G_OBJECT(item), "activate",
+ G_CALLBACK(mainwindow_tags_menu_item_activate_cb),
+ GINT_TO_POINTER(id));
+ g_object_set_data(G_OBJECT(item), "mainwin",
+ mainwin);
+ g_object_set_data(G_OBJECT(item), "tag_id",
+ GINT_TO_POINTER(id));
+ gtk_widget_show(item);
+ existing_tags = TRUE;
+ }
+ if (existing_tags) {
+ /* separator */
+ item = gtk_menu_item_new();
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+ gtk_widget_show(item);
+ }
+ item = gtk_menu_item_new_with_label(_("New tag..."));
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+ g_signal_connect(G_OBJECT(item), "activate",
+ G_CALLBACK(mainwindow_tags_menu_item_new_tag_activate_cb),
+ NULL);
+ g_object_set_data(G_OBJECT(item), "mainwin",
+ mainwin);
+ gtk_widget_show(item);
+ g_slist_free(orig);
+ gtk_widget_show(menu);
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
+ mainwin->tags_menu = menu;
+}
+
static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
MainWindow *mainwindow)
{
menubar = menubar_create(window, mainwin_entries,
n_menu_entries, "<Main>", mainwin);
gtk_widget_show(menubar);
+
+#ifndef MAEMO
gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
+#endif
+
ifactory = gtk_item_factory_from_widget(menubar);
/* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
}
/* link window to mainwin->window to avoid gdk warnings */
mainwin->window = window;
+ mainwin_list = g_list_append(mainwin_list, mainwin);
- /* create toolbar */
+#ifdef MAEMO
+ mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
+ window,
+ (gpointer)mainwin);
+#else
mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
handlebox,
(gpointer)mainwin);
+#endif
toolbar_set_learn_button
(mainwin->toolbar,
LEARN_SPAM);
statusbar = statusbar_create();
gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
+#ifndef MAEMO
progressbar = gtk_progress_bar_new();
gtk_widget_set_size_request(progressbar, 120, 1);
gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
-
+#endif
online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
online_switch = gtk_button_new ();
gtk_widget_hide(offline_switch);
gtk_widget_hide(warning_btn);
+
/* create views */
mainwin->folderview = folderview = folderview_create();
mainwin->summaryview = summaryview = summary_create();
mainwin->messageview = messageview = messageview_create(mainwin);
- mainwin->logwin = log_window_create();
+ /* init log instances data before creating log views */
+ set_log_title(LOG_PROTOCOL, _("Network log"));
+ set_log_prefs(LOG_PROTOCOL,
+ &prefs_common.logwin_width,
+ &prefs_common.logwin_height);
+ set_log_title(LOG_DEBUG_FILTERING, _("Filtering/processing debug log"));
+ set_log_prefs(LOG_DEBUG_FILTERING,
+ &prefs_common.filtering_debugwin_width,
+ &prefs_common.filtering_debugwin_height);
+
+ /* setup log windows */
+ mainwin->logwin = log_window_create(LOG_PROTOCOL);
log_window_init(mainwin->logwin);
- log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
+
+ mainwin->filtering_debugwin = log_window_create(LOG_DEBUG_FILTERING);
+ log_window_set_clipping(mainwin->logwin,
+ prefs_common.cliplog,
prefs_common.loglength);
+ log_window_init(mainwin->filtering_debugwin);
+ log_window_set_clipping(mainwin->filtering_debugwin,
+ prefs_common.filtering_debug_cliplog,
+ prefs_common.filtering_debug_loglength);
+ if (prefs_common.enable_filtering_debug)
+ log_message(LOG_DEBUG_FILTERING, _("filtering log enabled\n"));
+ else
+ log_message(LOG_DEBUG_FILTERING, _("filtering log disabled\n"));
+
folderview->mainwin = mainwin;
folderview->summaryview = summaryview;
mainwin->vbox_body = vbox_body;
mainwin->hbox_stat = hbox_stat;
mainwin->statusbar = statusbar;
+#ifndef MAEMO
mainwin->progressbar = progressbar;
+#endif
mainwin->statuslabel = statuslabel;
mainwin->online_switch = online_switch;
mainwin->online_pixmap = online_pixmap;
menu items in different menus */
menu_connect_identical_items();
+#ifndef MAEMO
gtk_window_iconify(GTK_WINDOW(mainwin->window));
+#endif
+ g_signal_connect(G_OBJECT(window), "window_state_event",
+ G_CALLBACK(mainwindow_state_event_cb), mainwin);
g_signal_connect(G_OBJECT(window), "visibility_notify_event",
G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
- if (prefs_common.layout_mode == VERTICAL_LAYOUT)
+ if (prefs_common.layout_mode == VERTICAL_LAYOUT ||
+ prefs_common.layout_mode == SMALL_LAYOUT) {
summary_relayout(mainwin->summaryview);
-
+ }
+ summary_update_unread(mainwin->summaryview, NULL);
+
gtk_widget_show(mainwin->window);
/* initialize views */
if (!hand_cursor)
hand_cursor = gdk_cursor_new(GDK_HAND2);
- mainwin_list = g_list_append(mainwin_list, mainwin);
-
/* init work_offline */
if (prefs_common.work_offline)
online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
mainwindow_colorlabel_menu_create(mainwin, FALSE);
+ mainwindow_tags_menu_create(mainwin, FALSE);
return mainwin;
}
}
+void main_window_reflect_tags_changes(MainWindow *mainwin)
+{
+ GtkMenuShell *menu;
+ GList *cur;
+
+ /* re-create tags submenu */
+ menu = GTK_MENU_SHELL(mainwin->tags_menu);
+ g_return_if_fail(menu != NULL);
+
+ /* clear items. get item pointers. */
+ for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
+ gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
+ }
+ mainwindow_tags_menu_create(mainwin, TRUE);
+ summary_reflect_tags_changes(mainwin->summaryview);
+
+}
+
void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
{
if (prefs_tag == 0 || pixmap_theme_changed) {
static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
GList *account_list)
{
- GList *cur_ac, *cur_item;
+ GList *cur_ac;
GtkWidget *menuitem;
PrefsAccount *ac_prefs;
GtkWidget *menu = NULL;
- if (mainwin->toolbar->getall_btn == NULL
- || mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
+ if (mainwin->toolbar->getall_btn == NULL) /* button doesn't exist */
return;
- menu = mainwin->toolbar->getall_combo->menu;
-
- /* destroy all previous menu item */
- cur_item = GTK_MENU_SHELL(menu)->children;
- while (cur_item != NULL) {
- GList *next = cur_item->next;
- gtk_widget_destroy(GTK_WIDGET(cur_item->data));
- cur_item = next;
- }
+ menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn));
+ if (menu)
+ gtk_widget_destroy(menu);
+ menu = gtk_menu_new();
for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
ac_prefs = (PrefsAccount *)cur_ac->data;
G_CALLBACK(account_receive_menu_cb),
ac_prefs);
}
+ gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn), menu);
}
static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
GList *account_list)
{
- GList *cur_ac, *cur_item;
+#ifndef MAEMO
+ GList *cur_ac;
GtkWidget *menuitem;
PrefsAccount *ac_prefs;
GtkWidget *menu = NULL;
- if (mainwin->toolbar->compose_mail_btn == NULL
- || mainwin->toolbar->compose_combo == NULL) /* button doesn't exist */
+ if (mainwin->toolbar->compose_mail_btn == NULL) /* button doesn't exist */
return;
- menu = mainwin->toolbar->compose_combo->menu;
+ menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn));
+ if (menu)
+ gtk_widget_destroy(menu);
+ menu = gtk_menu_new();
+
+ for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
+ ac_prefs = (PrefsAccount *)cur_ac->data;
- /* destroy all previous menu item */
- cur_item = GTK_MENU_SHELL(menu)->children;
- while (cur_item != NULL) {
- GList *next = cur_item->next;
- gtk_widget_destroy(GTK_WIDGET(cur_item->data));
- cur_item = next;
+ menuitem = gtk_menu_item_new_with_label
+ (ac_prefs->account_name
+ ? ac_prefs->account_name : _("Untitled"));
+ gtk_widget_show(menuitem);
+ gtk_menu_append(GTK_MENU(menu), menuitem);
+ g_signal_connect(G_OBJECT(menuitem), "activate",
+ G_CALLBACK(account_compose_menu_cb),
+ ac_prefs);
}
+ gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn), menu);
+ menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_news_btn));
+ if (menu)
+ gtk_widget_destroy(menu);
+ menu = gtk_menu_new();
for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
ac_prefs = (PrefsAccount *)cur_ac->data;
G_CALLBACK(account_compose_menu_cb),
ac_prefs);
}
+ gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_news_btn), menu);
+#endif
}
void main_window_set_account_menu(GList *account_list)
gtk_widget_unref(message_wid);
}
-static void mainwin_reset_paned(GtkPaned *paned)
+void mainwindow_reset_paned(GtkPaned *paned)
{
gint min, max, mid;
+
+ if (gtk_paned_get_child1(GTK_PANED(paned)))
+ gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
+ if (gtk_paned_get_child2(GTK_PANED(paned)))
+ gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
+
+GTK_EVENTS_FLUSH();
g_object_get (G_OBJECT(paned),
"min-position",
&min, NULL);
"max-position",
&max, NULL);
mid = (min+max)/2;
-
gtk_paned_set_position(GTK_PANED(paned), mid);
}
+static void mainwin_paned_show_first(GtkPaned *paned)
+{
+ gint max;
+ g_object_get (G_OBJECT(paned),
+ "max-position",
+ &max, NULL);
+
+ if (gtk_paned_get_child1(GTK_PANED(paned)))
+ gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
+ if (gtk_paned_get_child2(GTK_PANED(paned)))
+ gtk_widget_hide(gtk_paned_get_child2(GTK_PANED(paned)));
+ gtk_paned_set_position(GTK_PANED(paned), max);
+}
+
+static void mainwin_paned_show_last(GtkPaned *paned)
+{
+ gint min;
+ g_object_get (G_OBJECT(paned),
+ "min-position",
+ &min, NULL);
+
+ if (gtk_paned_get_child1(GTK_PANED(paned)))
+ gtk_widget_hide(gtk_paned_get_child1(GTK_PANED(paned)));
+ if (gtk_paned_get_child2(GTK_PANED(paned)))
+ gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
+ gtk_paned_set_position(GTK_PANED(paned), min);
+}
+
void main_window_toggle_message_view(MainWindow *mainwin)
{
SummaryView *summaryview = mainwin->summaryview;
switch (prefs_common.layout_mode) {
case NORMAL_LAYOUT:
case VERTICAL_LAYOUT:
+ case SMALL_LAYOUT:
ppaned = mainwin->vpaned;
container = mainwin->hpaned;
if (ppaned->parent != NULL) {
path = input_dialog(_("Add mailbox"),
_("Input the location of mailbox.\n"
- "If the existing mailbox is specified, it will be\n"
+ "If an existing mailbox is specified, it will be\n"
"scanned automatically."),
"Mail");
if (!path) return;
SummarySelection selection;
FolderItem *item = mainwin->summaryview->folder_item;
GList *account_list = account_get_list();
+ GSList *tmp;
selection = summary_get_selection_type(mainwin->summaryview);
if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
state |= M_ACTIONS_EXIST;
+ tmp = tags_get_list();
+ if (tmp && g_slist_length(tmp))
+ state |= M_TAGS_EXIST;
+ g_slist_free(tmp);
+
if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
state |= M_HAVE_QUEUED_MAILS;
if (inc_is_active())
state |= M_INC_ACTIVE;
+ if (imap_cancel_all_enabled())
+ state |= M_INC_ACTIVE;
if (mainwin->summaryview->deleted > 0 ||
mainwin->summaryview->moved > 0 ||
{"/File/Synchronise folders", M_WANT_SYNC},
{"/File/Exit" , M_UNLOCKED},
- {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
- {"/Edit/Delete thread" , M_SINGLE_TARGET_EXIST},
+ {"/Edit/Select thread" , M_TARGET_EXIST},
+ {"/Edit/Delete thread" , M_TARGET_EXIST},
{"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
{"/View/Set displayed columns/in Folder list..."
{"/Message/Mark/Lock" , M_TARGET_EXIST},
{"/Message/Mark/Unlock" , M_TARGET_EXIST},
{"/Message/Color label" , M_TARGET_EXIST},
+ {"/Message/Tags" , M_TARGET_EXIST},
{"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
{"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
{"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
{"/Configuration", M_UNLOCKED},
+ {"/Configuration/Preferences for current account...", M_UNLOCKED},
+ {"/Configuration/Create new account...", M_UNLOCKED},
+ {"/Configuration/Edit accounts...", M_UNLOCKED},
{NULL, 0}
};
menu_path = "/View/Sort/by Size"; break;
case SORT_BY_DATE:
menu_path = "/View/Sort/by Date"; break;
+ case SORT_BY_THREAD_DATE:
+ menu_path = "/View/Sort/by Thread date"; break;
case SORT_BY_FROM:
menu_path = "/View/Sort/by From"; break;
case SORT_BY_TO:
menu_path = "/View/Sort/by score"; break;
case SORT_BY_LOCKED:
menu_path = "/View/Sort/by locked"; break;
+ case SORT_BY_TAGS:
+ menu_path = "/View/Sort/by tag"; break;
case SORT_BY_NONE:
default:
menu_path = "/View/Sort/Don't sort"; break;
const gchar *buf;
gint i = 0;
buf = *buffer;
-
+ gboolean with_plus = TRUE;
+
if (buf == 0x00) {
*url_decoded = '\0';
*buffer = NULL;
/* First non space and non comment must be a < */
if (*buf =='<' ) {
buf++;
+ if (!strncmp(buf, "mailto:", strlen("mailto:")))
+ with_plus = FALSE;
for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
buf++;
}
if (i == maxlen) {
return;
}
- decode_uri (url_decoded, (const gchar *)tmp);
+ decode_uri_with_plus (url_decoded, (const gchar *)tmp, with_plus);
/* Prepare the work for the next url in the list */
/* after the closing bracket >, ignore space, comments and tabs */
main_window_show(mainwin);
gtkut_window_popup(mainwin->window);
+ if (prefs_common.layout_mode == SMALL_LAYOUT) {
+ if (mainwin->in_folder) {
+ mainwindow_enter_folder(mainwin);
+ } else {
+ mainwindow_exit_folder(mainwin);
+ }
+ }
}
void main_window_show(MainWindow *mainwin)
GtkWidget *vbox_body = mainwin->vbox_body;
GtkItemFactory *ifactory = mainwin->menu_factory;
GtkWidget *menuitem;
-
+ gboolean first_set = (mainwin->hpaned == NULL);
debug_print("Setting widgets... ");
- gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
+ if (layout_mode == SMALL_LAYOUT && first_set) {
+ gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
prefs_common.folderview_width,
prefs_common.folderview_height);
- gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
+ gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
+ 0,0);
+ gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
+ 0,0);
+ } else {
+ gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
+ prefs_common.folderview_width,
+ prefs_common.folderview_height);
+ gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
prefs_common.summaryview_width,
prefs_common.summaryview_height);
- gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
+ gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
prefs_common.msgview_width,
prefs_common.msgview_height);
+ }
mainwin->messageview->statusbar = mainwin->statusbar;
mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
gtk_widget_destroy(mainwin->hpaned);
}
- menu_set_sensitive(ifactory, "/View/Show or hide/Message view", (layout_mode != WIDE_MSGLIST_LAYOUT));
+ menu_set_sensitive(ifactory, "/View/Show or hide/Message view",
+ (layout_mode != WIDE_MSGLIST_LAYOUT && layout_mode != SMALL_LAYOUT));
switch (layout_mode) {
case VERTICAL_LAYOUT:
case NORMAL_LAYOUT:
+ case SMALL_LAYOUT:
hpaned = gtk_hpaned_new();
if (layout_mode == VERTICAL_LAYOUT)
vpaned = gtk_hpaned_new();
gtk_paned_add2(GTK_PANED(vpaned),
GTK_WIDGET_PTR(mainwin->messageview));
gtk_widget_show(vpaned);
+ if (layout_mode == SMALL_LAYOUT && first_set) {
+ mainwin_paned_show_first(GTK_PANED(hpaned));
+ }
gtk_widget_queue_resize(vpaned);
break;
case WIDE_LAYOUT:
mainwin->hpaned = hpaned;
mainwin->vpaned = vpaned;
+ if (layout_mode == SMALL_LAYOUT) {
+ if (mainwin->messageview->visible)
+ main_window_toggle_message_view(mainwin);
+ }
+
+ if (layout_mode == SMALL_LAYOUT && first_set) {
+ gtk_widget_realize(mainwin->window);
+ gtk_widget_realize(mainwin->folderview->ctree);
+ gtk_widget_realize(mainwin->summaryview->hbox);
+ gtk_widget_realize(mainwin->summaryview->hbox_l);
+ gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
+ prefs_common.folderview_width,
+ prefs_common.folderview_height);
+ gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
+ 0,0);
+ gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
+ 0,0);
+ gtk_widget_set_size_request(GTK_WIDGET(mainwin->window),
+ prefs_common.mainwin_width,
+ prefs_common.mainwin_height);
+ gtk_paned_set_position(GTK_PANED(mainwin->hpaned), 800);
+ }
/* remove headerview if not in prefs */
headerview_set_visibility(mainwin->messageview->headerview,
prefs_common.display_header_pane);
case WIDE_MSGLIST_LAYOUT:
SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message list", TRUE);
break;
+ case SMALL_LAYOUT:
+ SET_CHECK_MENU_ACTIVE("/View/Layout/Small screen", TRUE);
+ break;
}
#undef SET_CHECK_MENU_ACTIVE
gpointer data)
{
MainWindow *mainwin = (MainWindow *)data;
-
main_window_get_size(mainwin);
}
GtkWidget *widget)
{
LayoutType layout_mode = action;
-
+ LayoutType old_layout_mode = prefs_common.layout_mode;
if (mainwin->menu_lock_count) {
return;
}
return;
}
- if (!mainwin->messageview->visible)
+ if (!mainwin->messageview->visible && layout_mode != SMALL_LAYOUT)
+ main_window_toggle_message_view(mainwin);
+ else if (mainwin->messageview->visible && layout_mode == SMALL_LAYOUT)
main_window_toggle_message_view(mainwin);
main_window_separation_change(mainwin, layout_mode);
-
- mainwin_reset_paned(GTK_PANED(mainwin->vpaned));
+ mainwindow_reset_paned(GTK_PANED(mainwin->vpaned));
+ if (old_layout_mode == SMALL_LAYOUT && layout_mode != SMALL_LAYOUT) {
+ mainwindow_reset_paned(GTK_PANED(mainwin->hpaned));
+ }
+ if (old_layout_mode != SMALL_LAYOUT && layout_mode == SMALL_LAYOUT) {
+ mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
+ mainwindow_exit_folder(mainwin);
+ }
summary_relayout(mainwin->summaryview);
+ summary_update_unread(mainwin->summaryview, NULL);
}
void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
_("Do you want to synchronise your folders now?"),
GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
return;
-
- folder_synchronise(NULL);
+
+ if (offline_ask_sync)
+ folder_synchronise(NULL);
}
static void online_switch_clicked (GtkButton *btn, gpointer data)
log_window_show(mainwin->logwin);
}
+static void filtering_debug_window_show_cb(MainWindow *mainwin, guint action,
+ GtkWidget *widget)
+{
+ log_window_show(mainwin->filtering_debugwin);
+}
+
static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
{
inc_cancel_all();
+ imap_cancel_all();
}
static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
{
prefs_actions_open(mainwin);
}
+
+static void prefs_tags_open_cb(MainWindow *mainwin, guint action,
+ GtkWidget *widget)
+{
+ prefs_tags_open(mainwin);
+}
#ifdef USE_OPENSSL
static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
GtkWidget *widget)
return FALSE;
}
+static gboolean mainwindow_state_event_cb(GtkWidget *widget, GdkEventWindowState *state,
+ gpointer data)
+{
+ if (!claws_is_starting()
+ && state->changed_mask&GDK_WINDOW_STATE_ICONIFIED
+ && state->new_window_state&GDK_WINDOW_STATE_ICONIFIED) {
+
+ if (iconified_count > 0)
+ hooks_invoke(MAIN_WINDOW_GOT_ICONIFIED, NULL);
+ iconified_count++;
+ }
+ if (state->new_window_state == 0)
+ gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
+ return FALSE;
+}
+
gboolean mainwindow_is_obscured(void)
{
return is_obscured;
folderview_select_next_unread(mainwin->folderview, TRUE);
}
break;
+#ifdef MAEMO
+ case GDK_F6:
+ if (maemo_mainwindow_is_fullscreen(widget)) {
+ gtk_window_unfullscreen(GTK_WINDOW(widget));
+ } else {
+ gtk_window_fullscreen(GTK_WINDOW(widget));
+ }
+ break;
+#endif
default:
break;
}
summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
}
-void mainwindow_jump_to(const gchar *target)
+void mainwindow_jump_to(const gchar *target, gboolean popup)
{
gchar *tmp = NULL;
gchar *p = NULL;
if ((item = folder_find_item_from_identifier(tmp))) {
printf("selecting folder '%s'\n", tmp);
folderview_select(mainwin->folderview, item);
- main_window_popup(mainwin);
+ if (popup)
+ main_window_popup(mainwin);
g_free(tmp);
return;
}
printf("selecting message %d\n", atoi(msg));
summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
summary_display_msg_selected(mainwin->summaryview, FALSE);
- main_window_popup(mainwin);
+ if (popup)
+ main_window_popup(mainwin);
g_free(tmp);
return;
} else if (item && msg[0] == '<' && msg[strlen(msg)-1] == '>') {
printf("selecting message %s\n", msg);
summary_select_by_msgnum(mainwin->summaryview, msginfo->msgnum);
summary_display_msg_selected(mainwin->summaryview, FALSE);
- main_window_popup(mainwin);
+ if (popup)
+ main_window_popup(mainwin);
g_free(tmp);
procmsg_msginfo_free(msginfo);
return;
g_free(tmp);
}
+
+void mainwindow_exit_folder(MainWindow *mainwin) {
+ if (prefs_common.layout_mode == SMALL_LAYOUT) {
+ folderview_close_opened(mainwin->folderview);
+ mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
+ }
+ mainwin->in_folder = FALSE;
+}
+
+void mainwindow_enter_folder(MainWindow *mainwin) {
+ if (prefs_common.layout_mode == SMALL_LAYOUT) {
+ mainwin_paned_show_last(GTK_PANED(mainwin->hpaned));
+ }
+ mainwin->in_folder = TRUE;
+}
+
+#ifdef MAEMO
+gboolean maemo_mainwindow_is_fullscreen(GtkWidget *widget)
+{
+ gint w, h;
+ gtk_window_get_size(GTK_WINDOW(widget), &w, &h);
+ return (w == 800);
+}
+
+void maemo_window_full_screen_if_needed (GtkWindow *window)
+{
+ if (maemo_mainwindow_is_fullscreen(mainwindow_get_mainwindow()->window)) {
+ gtk_window_fullscreen(GTK_WINDOW(window));
+ }
+}
+
+void maemo_connect_key_press_to_mainwindow (GtkWindow *window)
+{
+ g_signal_connect(G_OBJECT(window), "key_press_event",
+ G_CALLBACK(mainwindow_key_pressed), mainwindow_get_mainwindow());
+}
+#endif