/*
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 "folderview.h"
#include "folder_item_prefs.h"
#include "foldersel.h"
+#include "quicksearch.h"
#include "summaryview.h"
#include "summary_search.h"
#include "messageview.h"
};
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;
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",
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) {
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);
}
/* 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)
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);
}
}