#include "stock_pixmap.h"
#include "folder.h"
#include "inc.h"
+#include "log.h"
#include "compose.h"
#include "procmsg.h"
#include "import.h"
#include "icon_legend.h"
#include "colorlabel.h"
#include "textview.h"
+#include "imap.h"
+#include "socket.h"
#define AC_LABEL_WIDTH 240
static GList *mainwin_list = NULL;
static GdkCursor *watch_cursor = NULL;
+static GdkCursor *hand_cursor = NULL;
static void main_window_menu_callback_block (MainWindow *mainwin);
static void main_window_menu_callback_unblock (MainWindow *mainwin);
guint action,
GtkWidget *widget);
+static void hide_quotes_cb(MainWindow *mainwin,
+ guint action,
+ GtkWidget *widget);
+
static void move_to_cb (MainWindow *mainwin,
guint action,
GtkWidget *widget);
static void next_labeled_cb (MainWindow *mainwin,
guint action,
GtkWidget *widget);
+static void last_read_cb (MainWindow *mainwin,
+ guint action,
+ GtkWidget *widget);
+static void parent_cb (MainWindow *mainwin,
+ guint action,
+ GtkWidget *widget);
static void goto_folder_cb (MainWindow *mainwin,
guint action,
GtkWidget *widget);
+static void goto_unread_folder_cb(MainWindow *mainwin,
+ guint action,
+ GtkWidget *widget);
static void copy_cb (MainWindow *mainwin,
guint action,
gpointer data);
static void account_receive_menu_cb (GtkMenuItem *menuitem,
gpointer data);
+static void account_compose_menu_cb (GtkMenuItem *menuitem,
+ gpointer data);
static void prefs_open_cb (GtkMenuItem *menuitem,
gpointer data);
GtkWidget *widget);
gboolean mainwindow_progressindicator_hook (gpointer source,
gpointer userdata);
+
+static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
+ MsgInfo *msginfo);
+
+static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
+
+static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
+
+static void mailing_list_compose(GtkWidget *w, gpointer *data);
+
+static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
#define SEPARATE_ACTION 500
static void mainwindow_quicksearch (MainWindow *mainwin,
guint action,
{N_("/_View/_Go to/Next la_beled message"),
NULL, next_labeled_cb, 0, NULL},
{N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
+ {N_("/_View/_Go to/Last read message"),
+ NULL, last_read_cb, 0, NULL},
+ {N_("/_View/_Go to/Parent message"),
+ "<control>Up", parent_cb, 0, NULL},
+ {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
+ {N_("/_View/_Go to/Next unread _folder"), "<shift>G", goto_unread_folder_cb, 0, NULL},
+ {N_("/_View/_Go to/_Other folder..."), "G", goto_folder_cb, 0, NULL},
{N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
#define ENC_SEPARATOR \
{N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
{N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
- {N_("/_View/Show all headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
+ {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
+ {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
+ {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
+ {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
{N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
{N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
{N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
{N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
+
+ {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
+
{N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
{N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
mainwin->colorlabel_menu = menu;
}
+static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
+ MainWindow *mainwindow)
+{
+ if (evt && evt->button == 1) {
+ log_window_show_error(mainwindow->logwin);
+ gtk_widget_hide(mainwindow->warning_btn);
+ }
+ return FALSE;
+}
+
+static gboolean warning_visi_notify(GtkWidget *widget,
+ GdkEventVisibility *event,
+ MainWindow *mainwindow)
+{
+ gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
+ return FALSE;
+}
+
+static gboolean warning_leave_notify(GtkWidget *widget,
+ GdkEventCrossing *event,
+ MainWindow *mainwindow)
+{
+ gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
+ return FALSE;
+}
+
+static gboolean warning_enter_notify(GtkWidget *widget,
+ GdkEventCrossing *event,
+ MainWindow *mainwindow)
+{
+ gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
+ return FALSE;
+}
+
+void mainwindow_show_error(void)
+{
+ MainWindow *mainwin = mainwindow_get_mainwindow();
+ gtk_widget_show(mainwin->warning_btn);
+}
+
+void mainwindow_clear_error(MainWindow *mainwin)
+{
+ gtk_widget_hide(mainwin->warning_btn);
+}
MainWindow *main_window_create(SeparateType type)
{
GtkWidget *offline_pixmap;
GtkWidget *online_switch;
GtkWidget *offline_switch;
- GtkTooltips *offline_tip;
- GtkTooltips *online_tip;
- GtkTooltips *sel_ac_tip;
+ GtkTooltips *tips;
+ GtkWidget *warning_icon;
+ GtkWidget *warning_btn;
FolderView *folderview;
SummaryView *summaryview;
gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
ifactory = gtk_item_factory_from_widget(menubar);
+/* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
+ main_create_mailing_list_menu (mainwin, NULL); */
+
menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
if (prefs_common.toolbar_detachable) {
hbox_stat = gtk_hbox_new(FALSE, 2);
gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
+ tips = gtk_tooltips_new();
+
+ warning_icon = gtk_image_new_from_stock
+ (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
+ warning_btn = gtk_event_box_new();
+ gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
+
+ mainwin->warning_btn = warning_btn;
+
+ g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
+ G_CALLBACK(warning_icon_pressed),
+ (gpointer) mainwin);
+ g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
+ G_CALLBACK(warning_visi_notify), mainwin);
+ g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
+ G_CALLBACK(warning_visi_notify), mainwin);
+ g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
+ G_CALLBACK(warning_leave_notify), mainwin);
+ g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
+ G_CALLBACK(warning_enter_notify), mainwin);
+
+ gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
+
+ gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
+ _("Some error(s) happened. Click here to view log."), NULL);
+ gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
+
statusbar = statusbar_create();
gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
- online_tip = gtk_tooltips_new();
online_switch = gtk_button_new ();
- gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
+ gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
_("You are online. Click the icon to go offline"), NULL);
- offline_tip = gtk_tooltips_new();
offline_switch = gtk_button_new ();
- gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
+ gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
_("You are offline. Click the icon to go online"),
NULL);
gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
statuslabel = gtk_label_new("");
gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
- sel_ac_tip = gtk_tooltips_new();
ac_button = gtk_button_new();
- gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
+ gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
ac_button, _("Select account"), NULL);
GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
gtk_widget_set_size_request(ac_button, -1, 0);
gtk_widget_show_all(hbox_stat);
gtk_widget_hide(offline_switch);
+ gtk_widget_hide(warning_btn);
/* create views */
mainwin->folderview = folderview = folderview_create();
mainwin->summaryview = summaryview = summary_create();
/* create actions menu */
main_window_update_actions_menu(mainwin);
+ main_create_mailing_list_menu (mainwin, NULL);
+
/* attach accel groups to main window */
#define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
gtk_window_add_accel_group \
if (!watch_cursor)
watch_cursor = gdk_cursor_new(GDK_WATCH);
+ if (!hand_cursor)
+ hand_cursor = gdk_cursor_new(GDK_HAND2);
mainwin_list = g_list_append(mainwin_list, mainwin);
return FALSE;
}
+void main_window_reflect_prefs_all_now(void)
+{
+ reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
+}
+
void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
{
GtkMenuShell *menu;
}
}
+static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
+ GList *account_list)
+{
+ GList *cur_ac, *cur_item;
+ GtkWidget *menuitem;
+ PrefsAccount *ac_prefs;
+ GtkWidget *menu = NULL;
+
+ if (mainwin->toolbar->compose_mail_btn == NULL
+ || mainwin->toolbar->compose_combo == NULL) /* button doesn't exist */
+ return;
+
+ menu = mainwin->toolbar->compose_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;
+ }
+
+ for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
+ ac_prefs = (PrefsAccount *)cur_ac->data;
+
+ 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);
+ }
+}
+
void main_window_set_account_menu(GList *account_list)
{
GList *cur;
main_window_set_account_selector_menu(mainwin, account_list);
main_window_set_account_receive_menu(mainwin, account_list);
main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
+ main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
}
}
for (cur = mainwin_list; cur != NULL; cur = cur->next) {
mainwin = (MainWindow *)cur->data;
main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
+ main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
}
}
g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
- (cur == 0 && total == 0) ? 0 :
- (gfloat)cur / (gfloat)total);
+ (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
}
void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
if ((selection == SUMMARY_NONE && item->hide_read_msgs)
|| selection != SUMMARY_NONE)
- state |= M_HIDE_READ_MSG;
+ state |= M_HIDE_READ_MSG;
}
if (mainwin->summaryview->threaded)
state |= M_THREADED;
state |= M_NEWS;
else
state |= M_NOT_NEWS;
+ if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
+ state |= M_ACTIONS_EXIST;
+
+ if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
+ state |= M_HAVE_QUEUED_MAILS;
+
if (selection == SUMMARY_SELECTED_SINGLE &&
(item &&
(folder_has_parent_of_type(item, F_DRAFT) ||
{"/View/Go to/Previous unread message" , M_MSG_EXIST},
{"/View/Go to/Previous new message" , M_MSG_EXIST},
{"/View/Go to/Previous marked message" , M_MSG_EXIST},
- {"/View/Go to/Next marked message" , M_MSG_EXIST},
{"/View/Go to/Previous labeled message", M_MSG_EXIST},
{"/View/Go to/Next labeled message", M_MSG_EXIST},
+ {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
+ {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
{"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
{"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
+ {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
{"/View/Message source" , M_SINGLE_TARGET_EXIST},
{"/Message/Receive/Get from current account"
, M_HAVE_ACCOUNT|M_UNLOCKED},
{"/Message/Receive/Cancel receiving"
, M_INC_ACTIVE},
-
+ {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
{"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
- {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
- {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
- {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
+ {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
+ {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
+ {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
{"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
{"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
- {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
+ {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
{"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
{"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
{"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
{"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
{"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
{"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
- {"/Tools/Actions" , M_TARGET_EXIST},
+ {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
{"/Tools/Execute" , M_DELAY_EXEC},
{"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
SET_CHECK_MENU_ACTIVE("/View/Show all headers",
mainwin->messageview->mimeview->textview->show_all_headers);
SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
+ SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
+ SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
+ SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
+ if (prefs_common.hide_quotes == 1)
+ SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
+ if (prefs_common.hide_quotes == 2)
+ SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
+ if (prefs_common.hide_quotes == 3)
+ SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
#undef SET_CHECK_MENU_ACTIVE
main_window_menu_callback_unblock(mainwin);
}
+void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
+{
+ GtkItemFactory *ifactory;
+ gint is_menu = 0;
+ ifactory = gtk_item_factory_from_widget(mainwin->menubar);
+
+ if (msginfo)
+ is_menu = mailing_list_create_submenu (ifactory, msginfo);
+ if (is_menu)
+ gtk_widget_set_sensitive (gtk_item_factory_get_item
+ (ifactory,"/Message/Mailing-List"), TRUE);
+ else
+ gtk_widget_set_sensitive (gtk_item_factory_get_item
+ (ifactory,"/Message/Mailing-List"), FALSE);
+}
+
+static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
+{
+ gint menu_nb = 0;
+ GtkWidget *menuitem;
+
+ if (!msginfo || !msginfo->extradata) {
+ menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
+ menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
+ menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
+ menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
+ menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
+ menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
+ return 0;
+ }
+
+ /* Mailing list post */
+ if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
+ g_free(msginfo->extradata->list_post);
+ msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
+ }
+ menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
+
+ menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
+
+ /* Mailing list help */
+ menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
+
+ menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
+
+ /* Mailing list subscribe */
+ menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
+
+ menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
+
+ /* Mailing list unsubscribe */
+ menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
+
+ menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
+
+ /* Mailing list view archive */
+ menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
+
+ menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
+
+ /* Mailing list contact owner */
+ menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
+
+ menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
+
+ return menu_nb;
+}
+
+static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
+{
+ GtkWidget *item, *menu;
+ const gchar *url_pt ;
+ gchar url_decoded[BUFFSIZE];
+ GList *amenu, *alist;
+ gint menu_nb = 0;
+
+ menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
+
+ /* First delete old submenu */
+ /* FIXME: we can optimize this, and only change/add/delete necessary items */
+ for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
+ alist = amenu->next;
+ item = GTK_WIDGET (amenu->data);
+ gtk_widget_destroy (item);
+ amenu = alist;
+ }
+ if (list_header) {
+ for (url_pt = list_header; url_pt && *url_pt;) {
+ get_url_part (&url_pt, url_decoded, BUFFSIZE);
+ item = NULL;
+ if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
+ item = gtk_menu_item_new_with_label ((url_decoded));
+ gtk_signal_connect (GTK_OBJECT(item), "activate",
+ GTK_SIGNAL_FUNC(mailing_list_compose), NULL);
+ }
+ else if (!g_strncasecmp (url_decoded, "http:", 5) ||
+ !g_strncasecmp (url_decoded, "https:",6)) {
+
+ item = gtk_menu_item_new_with_label ((url_decoded));
+ gtk_signal_connect (GTK_OBJECT(item), "activate",
+ GTK_SIGNAL_FUNC(mailing_list_open_uri), NULL);
+ }
+ if (item) {
+ gtk_menu_append (GTK_MENU(menu), item);
+ gtk_widget_show (item);
+ menu_nb++;
+ }
+ }
+ }
+ if (menu_nb)
+ gtk_widget_set_sensitive (menuitem, TRUE);
+ else
+ gtk_widget_set_sensitive (menuitem, FALSE);
+
+
+ return menu_nb;
+}
+
+static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
+{
+ gchar tmp[BUFFSIZE];
+ const gchar *buf;
+ gint i = 0;
+ buf = *buffer;
+
+ if (buf == 0x00) {
+ *url_decoded = '\0';
+ *buffer = NULL;
+ return;
+ }
+ /* Ignore spaces, comments and tabs () */
+ for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
+ if (*buf == '(')
+ for (;*buf != ')' && *buf != 0x00; buf++);
+
+ /* First non space and non comment must be a < */
+ if (*buf =='<' ) {
+ buf++;
+ for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
+ buf++;
+ }
+ else {
+ *buffer = NULL;
+ *url_decoded = '\0';
+ return;
+ }
+
+ tmp[i] = 0x00;
+ *url_decoded = '\0';
+ *buffer = NULL;
+
+ if (i == maxlen) {
+ return;
+ }
+ decode_uri (url_decoded, (const gchar *)tmp);
+
+ /* Prepare the work for the next url in the list */
+ /* after the closing bracket >, ignore space, comments and tabs */
+ for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
+ if (*buf == '(')
+ for (;*buf != ')' && *buf != 0x00; buf++);
+
+ if (!buf || !*buf) {
+ *buffer = NULL;
+ return;
+ }
+
+ /* now first non space, non comment must be a comma */
+ if (*buf != ',')
+ for (;*buf != 0x00; buf++);
+ else
+ buf++;
+ *buffer = buf;
+}
+
+static void mailing_list_compose (GtkWidget *w, gpointer *data)
+{
+ gchar *mailto;
+
+ gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
+ compose_new(NULL, mailto+7, NULL);
+}
+
+ static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
+{
+
+ gchar *mailto;
+
+ gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
+ open_uri (mailto, prefs_common.uri_cmd);
+}
+
void main_window_popup(MainWindow *mainwin)
{
gtkut_window_popup(mainwin->window);
mainwin->messageview->handlebox,
prefs_common.toolbar_style);
+ /* remove headerview if not in prefs */
+ headerview_set_visibility(mainwin->messageview->headerview,
+ prefs_common.display_header_pane);
+
break;
case SEPARATE_BOTH:
messageview_add_toolbar(mainwin->messageview, messagewin);
mainwin->messageview->handlebox,
prefs_common.toolbar_style);
+ /* remove headerview if not in prefs */
+ headerview_set_visibility(mainwin->messageview->headerview,
+ prefs_common.display_header_pane);
+
break;
}
static void import_mbox_cb(MainWindow *mainwin, guint action,
GtkWidget *widget)
{
- import_mbox(mainwin->summaryview->folder_item);
+ /* only notify if import has failed */
+ if (import_mbox(mainwin->summaryview->folder_item) == -1) {
+ alertpanel_error(_("Mbox import has failed."));
+ }
}
static void export_mbox_cb(MainWindow *mainwin, guint action,
GtkWidget *widget)
{
- export_mbox(mainwin->summaryview->folder_item);
+ /* only notify if export has failed */
+ if (export_mbox(mainwin->summaryview->folder_item) == -1) {
+ alertpanel_error(_("Export to mbox has failed."));
+ }
}
static void export_list_mbox_cb(MainWindow *mainwin, guint action,
GtkWidget *widget)
{
- summaryview_export_mbox_list(mainwin->summaryview);
+ /* only notify if export has failed */
+ if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
+ alertpanel_error(_("Export to mbox has failed."));
+ }
}
static void empty_trash_cb(MainWindow *mainwin, guint action,
g_return_if_fail(menuitem != NULL);
if (btn == GTK_BUTTON(mainwin->online_switch)) {
- /* go offline */
- mainwindow_check_synchronise(mainwin, TRUE);
gtk_widget_hide (mainwin->online_switch);
gtk_widget_show (mainwin->offline_switch);
menuitem->active = TRUE;
+ inc_autocheck_timer_remove();
+
+ /* go offline */
+ if (prefs_common.work_offline)
+ return;
+ mainwindow_check_synchronise(mainwin, TRUE);
prefs_common.work_offline = TRUE;
- inc_autocheck_timer_remove();
+ imap_disconnect_all();
} else {
/*go online */
+ if (!prefs_common.work_offline)
+ return;
gtk_widget_hide (mainwin->offline_switch);
gtk_widget_show (mainwin->online_switch);
menuitem->active = FALSE;
prefs_common.work_offline = FALSE;
inc_autocheck_timer_set();
+ refresh_resolvers();
}
}
GTK_CHECK_MENU_ITEM(widget)->active);
}
+#define SET_CHECK_MENU_ACTIVE(path, active) \
+{ \
+ menuitem = gtk_item_factory_get_widget(ifactory, path); \
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
+}
+
+static void hide_quotes_cb(MainWindow *mainwin, guint action,
+ GtkWidget *widget)
+{
+ GtkWidget *menuitem;
+ GtkItemFactory *ifactory = mainwin->menu_factory;
+
+ if (mainwin->menu_lock_count) return;
+
+ prefs_common.hide_quotes =
+ GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
+
+ mainwin->menu_lock_count++;
+ SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
+ SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
+ SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);
+ mainwin->menu_lock_count--;
+
+ summary_redisplay_msg(mainwin->summaryview);
+}
+
+#undef SET_CHECK_MENU_ACTIVE
static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
{
summary_mark(mainwin->summaryview);
summary_select_next_labeled(mainwin->summaryview);
}
+static void last_read_cb(MainWindow *mainwin, guint action,
+ GtkWidget *widget)
+{
+ summary_select_last_read(mainwin->summaryview);
+}
+
+static void parent_cb(MainWindow *mainwin, guint action,
+ GtkWidget *widget)
+{
+ summary_select_parent(mainwin->summaryview);
+}
+
static void goto_folder_cb(MainWindow *mainwin, guint action,
GtkWidget *widget)
{
folderview_select(mainwin->folderview, to_folder);
}
+static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
+ GtkWidget *widget)
+{
+ folderview_select_next_unread(mainwin->folderview, FALSE);
+}
+
static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
{
messageview_copy_clipboard(mainwin->messageview);
{
MessageView *msgview = mainwin->messageview;
- if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
- summary_select_all(mainwin->summaryview);
- else if (messageview_is_visible(msgview) &&
+ if (messageview_is_visible(msgview) &&
(GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
messageview_select_all(mainwin->messageview);
+ else
+ summary_select_all(mainwin->summaryview);
}
static void select_thread_cb(MainWindow *mainwin, guint action,
{
prefs_filtering_open(&pre_global_processing,
_("Processing rules to apply before folder rules"),
- NULL, NULL);
+ MANUAL_ANCHOR_PROCESSING,
+ NULL, NULL, FALSE);
}
static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
{
prefs_filtering_open(&post_global_processing,
_("Processing rules to apply after folder rules"),
- NULL, NULL);
+ MANUAL_ANCHOR_PROCESSING,
+ NULL, NULL, FALSE);
}
static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
{
prefs_filtering_open(&filtering_rules,
_("Filtering configuration"),
- NULL, NULL);
+ MANUAL_ANCHOR_FILTERING,
+ NULL, NULL, TRUE);
}
static void prefs_template_open_cb(MainWindow *mainwin, guint action,
inc_account_mail(mainwin, account);
}
+static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
+{
+ MainWindow *mainwin = (MainWindow *)mainwin_list->data;
+ PrefsAccount *account = (PrefsAccount *)data;
+ FolderItem *item = mainwin->summaryview->folder_item;
+
+ compose_new_with_folderitem(account, item);
+}
+
static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
{
prefs_gtk_open();
static void manual_open_cb(MainWindow *mainwin, guint action,
GtkWidget *widget)
{
- manual_open((ManualType)action);
+ manual_open((ManualType)action, NULL);
}
static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
SummaryView *summary;
g_return_val_if_fail(data, FALSE);
+ if (!g_list_find(mainwin_list, data))
+ return TRUE;
summary = ((MainWindow *)data)->summaryview;
g_return_val_if_fail(summary, FALSE);
return FALSE;
case GDK_space:
if (mainwin->folderview && mainwin->summaryview
- && !mainwin->summaryview->displayed) {
- summary_lock(mainwin->summaryview);
- folderview_select_next_unread(mainwin->folderview);
- summary_unlock(mainwin->summaryview);
+ && ((!mainwin->summaryview->displayed
+ && !mainwin->summaryview->selected)
+ || (mainwin->summaryview->folder_item
+ && mainwin->summaryview->folder_item->total_msgs == 0))) {
+ g_signal_stop_emission_by_name(G_OBJECT(widget),
+ "key_press_event");
+ folderview_select_next_unread(mainwin->folderview, TRUE);
}
break;
default:
{
summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
}
+
+void mainwindow_jump_to(const gchar *target)
+{
+ gchar *tmp = NULL;
+ gchar *p = NULL;
+ FolderItem *item = NULL;
+ gchar *msg = NULL;
+ MainWindow *mainwin = mainwindow_get_mainwindow();
+
+ if (!target)
+ return;
+
+ if (!mainwin) {
+ printf(_("not initialized\n"));
+ return;
+ }
+
+ tmp = g_strdup(target);
+
+ if ((p = strstr(tmp, "\r")) != NULL)
+ *p = '\0';
+ if ((p = strstr(tmp, "\n")) != NULL)
+ *p = '\0';
+
+ if ((item = folder_find_item_from_identifier(tmp))) {
+ printf(_("selecting folder '%s'\n"), tmp);
+ folderview_select(mainwin->folderview, item);
+ main_window_popup(mainwin);
+ g_free(tmp);
+ return;
+ }
+
+ msg = strrchr(tmp, G_DIR_SEPARATOR);
+ if (msg) {
+ *msg++ = '\0';
+ if ((item = folder_find_item_from_identifier(tmp))) {
+ printf(_("selecting folder '%s'\n"), tmp);
+ folderview_select(mainwin->folderview, item);
+ }
+ if (item && msg && atoi(msg)) {
+ 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);
+ g_free(tmp);
+ return;
+ }
+ }
+
+ printf("'%s' not found\n", tmp);
+
+ g_free(tmp);
+}