/*
Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team
+ Copyright (C) 1999-2018 the Claws Mail team and 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
#include "defs.h"
+#ifdef G_OS_WIN32
+#define UNICODE
+#define _UNICODE
+#endif
+
#include <glib.h>
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#include "folderview.h"
#include "folder_item_prefs.h"
#include "foldersel.h"
+#include "quicksearch.h"
#include "summaryview.h"
#include "summary_search.h"
#include "messageview.h"
gpointer data);
static void filtering_debug_window_show_cb (GtkAction *action,
gpointer data);
+#ifdef G_OS_WIN32
+static void debug_log_show_cb(GtkAction *action, gpointer data);
+#endif
static void inc_cancel_cb (GtkAction *action,
gpointer data);
/* {"Tools/---", NULL, "---", NULL, NULL, NULL }, */
{"Tools/FilteringLog", NULL, N_("Filtering Lo_g"), NULL, NULL, G_CALLBACK(filtering_debug_window_show_cb) },
{"Tools/NetworkLog", NULL, N_("Network _Log"), "<shift><control>L", NULL, G_CALLBACK(log_window_show_cb) },
+#ifdef G_OS_WIN32
+ {"Tools/DebugLog", NULL, N_("Debug _Log"), NULL, NULL, G_CALLBACK(debug_log_show_cb) },
+#endif
/* {"Tools/---", NULL, "---", NULL, NULL, NULL }, */
{"Tools/ForgetSessionPasswords", NULL, N_("_Forget all session passwords"), NULL, NULL, G_CALLBACK(forget_session_passwords_cb) },
#ifndef PASSWORD_CRYPTO_OLD
};
static gboolean offline_ask_sync = TRUE;
-static guint lastkey;
static gboolean is_obscured = FALSE;
-static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
- GObject *arg1,
- guint value,
- GdkModifierType mod,
- gpointer user_data)
-{
- MainWindow *mainwin = (MainWindow *)user_data;
-
- if (mainwin->summaryview &&
- mainwin->summaryview->quicksearch &&
- quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
- (mod == 0 || mod == GDK_SHIFT_MASK)) {
- quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
- return TRUE;
- }
- return FALSE;
-}
-
#define N_COLOR_LABELS colorlabel_get_color_count()
static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
gpointer data)
{
MainWindow *mainwin = (MainWindow*) data;
-
+
if (!mainwin || !event)
return FALSE;
if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
{
- lastkey = event->keyval;
- return FALSE;
+ GtkWidget *entry =
+ quicksearch_get_entry(mainwin->summaryview->quicksearch);
+ gboolean handled;
+ g_signal_emit_by_name(entry, "key-press-event", event, &handled);
+ if (handled) {
+ return TRUE;
+ }
}
switch (event->keyval) {
FolderView *folderview;
SummaryView *summaryview;
MessageView *messageview;
-#if !GTK_CHECK_VERSION(3, 0, 0)
GdkColormap *colormap;
gboolean success[4];
-#endif
GdkColor color[4];
GtkWidget *ac_menu;
gint i;
/* main window */
window = GTK_WIDGET(gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow"));
- gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION_FRIENDLY);
+ gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
#ifdef GENERIC_UMPC
prefs_common.layout_mode = SMALL_LAYOUT;
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator7", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "FilteringLog", "Tools/FilteringLog", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "NetworkLog", "Tools/NetworkLog", GTK_UI_MANAGER_MENUITEM)
+#ifdef G_OS_WIN32
+ MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "DebugLog", "Tools/DebugLog", GTK_UI_MANAGER_MENUITEM)
+#endif
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator8", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "ForgetSessionPasswords", "Tools/ForgetSessionPasswords", GTK_UI_MANAGER_MENUITEM)
#ifndef PASSWORD_CRYPTO_OLD
gtk_widget_hide(menubar);
gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(mainwin->ui_manager));
+ /* Create a menu container for the different popup menus we
+ * will be adding from other UI elements. */
+ MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/", "Menus", "Menus", GTK_UI_MANAGER_MENUBAR)
+
gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
if (prefs_common.toolbar_detachable) {
online_pixmap = stock_pixmap_widget(STOCK_PIXMAP_ONLINE);
offline_pixmap = stock_pixmap_widget(STOCK_PIXMAP_OFFLINE);
online_switch = gtk_button_new ();
- gtkut_widget_set_can_focus(online_switch, FALSE);
+ gtk_widget_set_can_focus(online_switch, FALSE);
CLAWS_SET_TIP(online_switch,
_("You are online. Click the icon to go offline"));
offline_switch = gtk_button_new ();
ac_button = gtk_button_new();
CLAWS_SET_TIP(ac_button, _("Select account"));
- gtkut_widget_set_can_focus(ac_button, FALSE);
+ gtk_widget_set_can_focus(ac_button, FALSE);
gtk_widget_set_size_request(ac_button, -1, 0);
gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
g_signal_connect(G_OBJECT(ac_button), "button_press_event",
g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
#endif
/* create views */
- mainwin->folderview = folderview = folderview_create();
+ mainwin->folderview = folderview = folderview_create(mainwin);
mainwin->summaryview = summaryview = summary_create(mainwin);
mainwin->messageview = messageview = messageview_create(mainwin);
summaryview->color_dim.red = summaryview->color_dim.green =
summaryview->color_dim.blue = COLOR_DIM;
- gtkut_convert_int_to_gdk_color(prefs_common.color_new,
+ gtkut_convert_int_to_gdk_color(prefs_common.color[COL_NEW],
&folderview->color_new);
- gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
+ gtkut_convert_int_to_gdk_color(prefs_common.color[COL_TGT_FOLDER],
&folderview->color_op);
- summaryview->color_important.red = 0;
- summaryview->color_important.green = 0;
- summaryview->color_important.blue = (guint16)65535;
-
color[0] = summaryview->color_marked;
color[1] = summaryview->color_dim;
color[2] = folderview->color_new;
color[3] = folderview->color_op;
-#if !GTK_CHECK_VERSION(3, 0, 0)
colormap = gdk_drawable_get_colormap(gtk_widget_get_window(window));
gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
for (i = 0; i < 4; i++) {
if (success[i] == FALSE)
g_warning("MainWindow: color allocation %d failed", i);
}
-#endif
debug_print("done.\n");
#define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
gtk_window_add_accel_group \
(GTK_WINDOW(win), \
- gtk_ui_manager_get_accel_group(gtkut_ui_manager())); \
- g_signal_connect(G_OBJECT(gtk_ui_manager_get_accel_group(gtkut_ui_manager())), \
- "accel_activate", \
- G_CALLBACK(main_window_accel_activate), mainwin);
+ gtk_ui_manager_get_accel_group(gtkut_ui_manager()));
ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
: _("none"));
if (cur_account)
- buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION_FRIENDLY);
+ buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
else
- buf = g_strdup(PROG_VERSION_FRIENDLY);
+ buf = g_strdup(PROG_VERSION);
gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
g_free(buf);
if (for_quit)
val = alertpanel(_("Empty trash"),
_("Delete all messages in trash folders?"),
- GTK_STOCK_NO, "+" GTK_STOCK_YES, _("Don't quit"));
+ GTK_STOCK_NO, GTK_STOCK_YES, _("Don't quit"),
+ ALERTFOCUS_SECOND);
else
val = alertpanel(_("Empty trash"),
_("Delete all messages in trash folders?"),
- GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL);
+ GTK_STOCK_NO, GTK_STOCK_YES, NULL,
+ ALERTFOCUS_SECOND);
if (val == G_ALERTALTERNATE) {
debug_print("will empty trash\n");
} else if (val == G_ALERTDEFAULT) {
Folder *folder;
path = input_dialog(_("Add mailbox"),
- _("Input the location of mailbox.\n"
- "If an existing mailbox is specified, it will be\n"
+ _("Input the location of the mailbox.\n"
+ "The location can be either the full path or relative to the \n"
+ "home directory.\n"
+ "If the location of an existing mailbox is specified, it will be\n"
"scanned automatically."),
"Mail");
if (!path) return;
&& mainwin->summaryview->folder_item->stype != F_DRAFT)
UPDATE_STATE(M_NOT_DRAFT);
+ if (mainwin->summaryview->folder_item &&
+ mainwin->summaryview->folder_item->stype == F_DRAFT)
+ UPDATE_STATE(M_DRAFT);
+
if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
UPDATE_STATE(M_ACTIONS_EXIST);
UPDATE_STATE(M_MASTER_PASSPHRASE);
}
#endif
+
#undef UPDATE_STATE
return state;
cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/Message/CheckSignature",
mimepart_selected && mainwin->messageview->mimeview->signed_part);
+ sensitive = TRUE;
+ if (mimepart_selected) {
+ MimeInfo *partinfo = messageview_get_selected_mime_part(mainwin->messageview);
+
+ if (partinfo && (partinfo->type == MIMETYPE_MESSAGE ||
+ partinfo->type == MIMETYPE_IMAGE ||
+ partinfo->type == MIMETYPE_MULTIPART)) {
+ sensitive = FALSE;
+ }
+ }
+ cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Part/AsText", sensitive);
+
main_window_menu_callback_unblock(mainwin);
}
}
/* Mailing list post */
- if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
+ if (!g_strcmp0 (msginfo->extradata->list_post, "NO")) {
g_free(msginfo->extradata->list_post);
msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
}
/* free toolbar stuff */
toolbar_clear_list(TOOLBAR_MAIN);
- TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
- TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
+ toolbar_destroy(mainwin->toolbar);
summaryview_destroy(mainwin->summaryview);
mainwin->folderview->mainwin = NULL;
if (prefs_common.confirm_on_exit) {
if (alertpanel(_("Exit"), _("Exit Claws Mail?"),
- GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
+ GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL, ALERTFOCUS_FIRST)
!= G_ALERTALTERNATE)
return;
manage_window_focus_in(mainwin->window, NULL, NULL);
msginfo_list = summary_get_selection(mainwin->summaryview);
cm_return_if_fail(msginfo_list != NULL);
- compose_reply_from_messageview(msgview, msginfo_list, action);
+
+ if (!summary_has_opened_message(mainwin->summaryview)) {
+ compose_reply_from_messageview(NULL, msginfo_list, action);
+ } else if (summary_is_opened_message_selected(mainwin->summaryview)) {
+ compose_reply_from_messageview(msgview, msginfo_list, action);
+ } else {
+ compose_reply_from_messageview(msgview, NULL, action);
+ }
+
g_slist_free(msginfo_list);
}
online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
offline_ask_sync = TRUE;
+ inc_reset_offline_override_timers();
+
switching = FALSE;
}
if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
_("Do you want to synchronise your folders now?"),
- GTK_STOCK_CANCEL, g_strconcat("+", _("_Synchronise"), NULL), NULL) != G_ALERTALTERNATE)
+ GTK_STOCK_CANCEL, _("_Synchronise"), NULL, ALERTFOCUS_SECOND) != G_ALERTALTERNATE)
return;
if (offline_ask_sync)
log_window_show(mainwin->filtering_debugwin);
}
+#ifdef G_OS_WIN32
+static void debug_log_show_cb(GtkAction *action, gpointer data)
+{
+ GError *error = NULL;
+ gchar *logpath8 = win32_debug_log_path();
+ gunichar2 *logpath16;
+
+ debug_print("opening '%s'\n", logpath8);
+
+ logpath16 = g_utf8_to_utf16(logpath8, -1, NULL, NULL, &error);
+
+ if (error != NULL) {
+ g_warning("couldn't convert debug log path '%s' to UTF-16: %s",
+ logpath8, error->message);
+ g_error_free(error);
+ g_free(logpath16);
+ return;
+ }
+
+ HINSTANCE ret = ShellExecute(NULL, NULL, (LPCWSTR)logpath16,
+ NULL, NULL, SW_SHOW);
+
+ g_free(logpath8);
+ g_free(logpath16);
+ debug_print("ShellExecute result: %"G_GSIZE_FORMAT"\n", (gsize)ret);
+}
+#endif
+
static void inc_cancel_cb(GtkAction *action, gpointer data)
{
inc_cancel_all();
static void sort_summary_cb(GtkAction *action, GtkRadioAction *current, gpointer data)
{
MainWindow *mainwin = (MainWindow *)data;
- FolderItem *item = mainwin->summaryview->folder_item;
gint value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current));
if (mainwin->menu_lock_count) return;
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current)) && item) {
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current))) {
summary_sort(mainwin->summaryview, (FolderSortKey)value,
- item->sort_type);
- item->sort_key = value;
+ mainwin->summaryview->sort_type);
}
}
static void sort_summary_type_cb(GtkAction *gaction, GtkRadioAction *current, gpointer data)
{
MainWindow *mainwin = (MainWindow *)data;
- FolderItem *item = mainwin->summaryview->folder_item;
gint value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current));
if (mainwin->menu_lock_count) return;
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current)) && item)
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current)))
summary_sort(mainwin->summaryview,
- item->sort_key, (FolderSortType)value);
+ mainwin->summaryview->sort_key, (FolderSortType)value);
}
static void attract_by_subject_cb(GtkAction *action, gpointer data)
if (!cur_account) {
new_account_cb(NULL, mainwin);
} else {
- account_open(cur_account);
+ account_open(cur_account, FALSE);
}
}