#include "imap.h"
#include "socket.h"
#include "printing.h"
+#ifdef G_OS_WIN32
+#include "w32lib.h"
+#endif
#define AC_LABEL_WIDTH 240
gpointer data);
static void save_as_cb (GtkAction *action,
gpointer data);
-#if GTK_CHECK_VERSION(2,10,0)
+#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
static void page_setup_cb (GtkAction *action,
gpointer data);
#endif
static void prefs_filtering_open_cb (GtkAction *action,
gpointer data);
-#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
+#ifdef USE_GNUTLS
static void ssl_manager_open_cb (GtkAction *action,
gpointer data);
#endif
static void legend_open_cb (GtkAction *action,
gpointer data);
+#ifdef G_OS_WIN32
+static void set_default_client_cb (GtkAction *action,
+ gpointer data);
+#endif
+
static void scan_tree_func (Folder *folder,
FolderItem *item,
gpointer data);
{"File/SaveAs", NULL, N_("_Save as..."), "<control>S", NULL, G_CALLBACK(save_as_cb) },
-#if GTK_CHECK_VERSION(2,10,0)
+#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
{"File/PageSetup", NULL, N_("Page setup..."), NULL, NULL, G_CALLBACK(page_setup_cb) },
#endif
{"File/Print", NULL, N_("_Print..."), "<control>P", NULL, G_CALLBACK(print_cb) },
/* {"Tools/---", NULL, "---", NULL, NULL, NULL }, */
{"Tools/Execute", NULL, N_("E_xecute"), "X", NULL, G_CALLBACK(execute_summary_cb) },
-#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
+#ifdef USE_GNUTLS
/* {"Tools/---", NULL, "---", NULL, NULL, NULL }, */
{"Tools/SSLCertificates", NULL, N_("SSL cer_tificates"), NULL, NULL, G_CALLBACK(ssl_manager_open_cb) },
#endif
{"Help/Manual", NULL, N_("_Manual"), NULL, NULL, G_CALLBACK(manual_open_cb) },
{"Help/FAQ", NULL, N_("_Online User-contributed FAQ"), NULL, NULL, G_CALLBACK(manual_faq_open_cb) },
{"Help/IconLegend", NULL, N_("Icon _Legend"), NULL, NULL, G_CALLBACK(legend_open_cb) },
+#ifdef G_OS_WIN32
+ {"Help/SetDefault", NULL, N_("Set as default client"), NULL, NULL, G_CALLBACK(set_default_client_cb) },
+#endif
{"Help/---", NULL, "---" },
{"Help/About", NULL, N_("_About"), NULL, NULL, G_CALLBACK(about_cb) },
};
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "EmptyTrashes", "File/EmptyTrashes", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Separator4", "File/---", GTK_UI_MANAGER_SEPARATOR)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "SaveAs", "File/SaveAs", GTK_UI_MANAGER_MENUITEM)
-#if GTK_CHECK_VERSION(2,10,0)
+#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "PageSetup", "File/PageSetup", GTK_UI_MANAGER_MENUITEM)
#endif
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Print", "File/Print", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator5", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Execute", "Tools/Execute", GTK_UI_MANAGER_MENUITEM)
-#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
+#ifdef USE_GNUTLS
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator6", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "SSLCertificates", "Tools/SSLCertificates", GTK_UI_MANAGER_MENUITEM)
#endif
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "Manual", "Help/Manual", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "FAQ", "Help/FAQ", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "IconLegend", "Help/IconLegend", GTK_UI_MANAGER_MENUITEM)
+#ifdef G_OS_WIN32
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "Separator1", "Help/---", GTK_UI_MANAGER_SEPARATOR)
+ MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "SetDefault", "Help/SetDefault", GTK_UI_MANAGER_MENUITEM)
+#endif
+ MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "Separator2", "Help/---", GTK_UI_MANAGER_SEPARATOR)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "About", "Help/About", GTK_UI_MANAGER_MENUITEM)
#endif
/* create views */
mainwin->folderview = folderview = folderview_create();
- mainwin->summaryview = summaryview = summary_create();
+ mainwin->summaryview = summaryview = summary_create(mainwin);
mainwin->messageview = messageview = messageview_create(mainwin);
/* init log instances data before creating log views */
ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
-/* FIXME menu_connect_identical_items(); */
-
#ifndef GENERIC_UMPC
gtk_window_iconify(GTK_WINDOW(mainwin->window));
#endif
folderview_init(folderview);
summary_init(summaryview);
messageview_init(messageview);
-#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
+#ifdef USE_GNUTLS
sslcertwindow_register_hook();
#endif
mainwin->lock_count = 0;
/* clear items. get item pointers. */
for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
+ g_signal_handlers_disconnect_matched
+ (gtk_ui_manager_get_accel_group(mainwin->ui_manager),
+ G_SIGNAL_MATCH_DATA|G_SIGNAL_MATCH_FUNC,
+ 0, 0, NULL, mainwin_accel_changed_cb, cur->data);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(cur->data), NULL);
}
mainwindow_colorlabel_menu_create(mainwin, TRUE);
static void mailing_list_compose (GtkWidget *w, gpointer *data)
{
const gchar *mailto;
+ PrefsAccount *account = NULL;
+ FolderItem *folder_item = NULL;
mailto = gtk_label_get_text(GTK_LABEL (gtk_bin_get_child(GTK_BIN((w)))));
+ if (mainwindow_get_mainwindow()) {
+ folder_item = mainwindow_get_mainwindow()->summaryview->folder_item;
+ if (folder_item && folder_item->prefs && folder_item->prefs->enable_default_account)
+ account = account_find_from_id(folder_item->prefs->default_account);
+ if (folder_item && !account)
+ account = account_find_from_item(folder_item);
+ }
if (mailto)
- compose_new(NULL, mailto+7, NULL);
+ compose_new_with_folderitem(account, folder_item, mailto+7);
}
static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
summary_print(mainwin->summaryview);
}
-#if GTK_CHECK_VERSION(2,10,0)
+#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
static void page_setup_cb(GtkAction *action, gpointer data)
{
MainWindow *mainwin = (MainWindow *)data;
MainWindow *mainwin;
gboolean have_connectivity;
-#ifdef HAVE_NETWORKMANAGER
+#ifdef HAVE_NETWORKMANAGER_SUPPORT
have_connectivity = networkmanager_is_online(NULL);
#else
have_connectivity = TRUE;
if(have_connectivity)
mainwindow_check_synchronise(mainwin, TRUE);
prefs_common.work_offline = TRUE;
- imap_disconnect_all();
+ if(have_connectivity)
+ imap_disconnect_all();
hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
} else {
/*go online */
GSList * list = summary_get_selected_msg_list(mainwin->summaryview);
tag_apply_open(list);
}
-#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
+#ifdef USE_GNUTLS
static void ssl_manager_open_cb(GtkAction *action, gpointer data)
{
MainWindow *mainwin = (MainWindow *)data;
legend_show();
}
+#ifdef G_OS_WIN32
+static void set_default_client_cb(GtkAction *action, gpointer data)
+{
+ char exename[MAX_PATH];
+ gchar *binary_icon = NULL;
+ gchar *binary_compose = NULL;
+ gchar *binary_run = NULL;
+ int r = 0;
+ if ( !GetModuleFileNameA (0, exename, sizeof (exename)) ) {
+ alertpanel_error(_("Can not register as default client: impossible to get executable path."));
+ return;
+ }
+ binary_icon = g_strconcat(exename, ",0", NULL);
+ binary_compose = g_strconcat(exename, " --compose %1", NULL);
+ binary_run = g_strconcat(exename, NULL);
+
+ /* Try to set the Mail Start menu item to Claws. It may fail if we're not root; we don't care */
+ r = write_w32_registry_string("HKLM", "Software\\Clients\\Mail",
+ "", "Claws Mail");
+
+ r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail",
+ "", "Claws Mail");
+ if (!r)
+ r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail",
+ "DLLPath", "");
+ if (!r)
+ r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto",
+ "", "URL:MailTo-Protocol");
+ if (!r)
+ r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto",
+ "URL Protocol", "");
+ if (!r)
+ r = write_w32_registry_dword ("HKCU", "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto",
+ "EditFlags", 2);
+ if (!r)
+ r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto\\DefaultIcon",
+ "", binary_icon);
+ if (!r)
+ r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto\\shell\\open\\command",
+ "", binary_compose);
+ if (!r)
+ r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail\\shell\\open\\command",
+ "", binary_run);
+
+ if (!r)
+ r = write_w32_registry_string("HKCU", "Software\\Classes\\mailto",
+ "", "URL:MailTo-Protocol");
+ if (!r)
+ r = write_w32_registry_string("HKCU", "Software\\Classes\\mailto",
+ "URL Protocol", "");
+ if (!r)
+ r = write_w32_registry_dword ("HKCU", "Software\\Classes\\mailto",
+ "EditFlags", 2);
+ if (!r)
+ r = write_w32_registry_string("HKCU", "Software\\Classes\\mailto\\DefaultIcon",
+ "", binary_icon);
+ if (!r)
+ r = write_w32_registry_string("HKCU", "Software\\Classes\\mailto\\shell\\open\\command",
+ "", binary_compose);
+
+ if (!r) {
+ SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Software\\Clients\\Mail");
+ alertpanel_notice(_("Claws Mail has been registered as default client."));
+ } else {
+ alertpanel_error(_("Can not register as default client: impossible to write to the registry."));
+ }
+ g_free(binary_icon);
+ g_free(binary_compose);
+ g_free(binary_run);
+}
+#endif
+
static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
{
MainWindow *mainwin = (MainWindow *)data;