talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 84076b9bbd3642bfb493d4add15c5a02a324d9c6
parent 8ccad05c59bf973eb25a9aea903a61aff42908b9
Author: Colin Leroy <colin@colino.net>
Date:   Tue,  4 Nov 2008 21:13:42 +0000

2008-11-04 [colin]	3.6.1cvs15

	* src/procmime.c
		w32: Fix getting content-type
	* src/mimeview.c
	* src/prefs_common.c
	* src/prefs_common.h
	* src/prefs_ext_prog.c
	* src/textview.c
		w32: better integration (use the
		standard file associations instead
		of our platform-unadapted open
		dialog)
	* src/mainwindow.c
	* src/common/utils.c
	* src/common/w32_reg.c
	* src/common/w32lib.h
		w32: better integration (allow
		setting Claws as default MUA)

Diffstat:
MChangeLog | 20++++++++++++++++++++
MPATCHSETS | 1+
Mconfigure.ac | 2+-
Msrc/common/utils.c | 4++++
Msrc/common/w32_reg.c | 72+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
Msrc/common/w32lib.h | 2++
Msrc/mainwindow.c | 80+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/mimeview.c | 37+++++++++++++++++++++++++++++++++++--
Msrc/prefs_common.c | 10++++++----
Msrc/prefs_common.h | 2++
Msrc/prefs_ext_prog.c | 23+++++++++++++++++------
Msrc/procmime.c | 21+++++++++++++++------
Msrc/textview.c | 2++
13 files changed, 248 insertions(+), 28 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,23 @@ +2008-11-04 [colin] 3.6.1cvs15 + + * src/procmime.c + w32: Fix getting content-type + * src/mimeview.c + * src/prefs_common.c + * src/prefs_common.h + * src/prefs_ext_prog.c + * src/textview.c + w32: better integration (use the + standard file associations instead + of our platform-unadapted open + dialog) + * src/mainwindow.c + * src/common/utils.c + * src/common/w32_reg.c + * src/common/w32lib.h + w32: better integration (allow + setting Claws as default MUA) + 2008-11-01 [colin] 3.6.1cvs14 * src/codeconv.c diff --git a/PATCHSETS b/PATCHSETS @@ -3596,3 +3596,4 @@ ( cvs diff -u -r 1.25.2.27 -r 1.25.2.28 tools/Makefile.am; diff -u /dev/null tools/kdeservicemenu/claws-mail-attach-files.desktop.kde4template; cvs diff -u -r 1.2.2.8 -r 1.2.2.9 tools/kdeservicemenu/install.sh; ) > 3.6.1cvs12.patchset ( cvs diff -u -r 1.83.2.145 -r 1.83.2.146 src/mimeview.c; cvs diff -u -r 1.20.2.26 -r 1.20.2.27 src/mimeview.h; cvs diff -u -r 1.96.2.208 -r 1.96.2.209 src/textview.c; cvs diff -u -r 1.12.2.24 -r 1.12.2.25 src/textview.h; ) > 3.6.1cvs13.patchset ( cvs diff -u -r 1.65.2.62 -r 1.65.2.63 src/codeconv.c; ) > 3.6.1cvs14.patchset +( cvs diff -u -r 1.274.2.285 -r 1.274.2.286 src/mainwindow.c; cvs diff -u -r 1.83.2.146 -r 1.83.2.147 src/mimeview.c; cvs diff -u -r 1.204.2.181 -r 1.204.2.182 src/prefs_common.c; cvs diff -u -r 1.103.2.116 -r 1.103.2.117 src/prefs_common.h; cvs diff -u -r 1.3.2.23 -r 1.3.2.24 src/prefs_ext_prog.c; cvs diff -u -r 1.49.2.118 -r 1.49.2.119 src/procmime.c; cvs diff -u -r 1.96.2.209 -r 1.96.2.210 src/textview.c; cvs diff -u -r 1.36.2.153 -r 1.36.2.154 src/common/utils.c; cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/common/w32_reg.c; cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/common/w32lib.h; ) > 3.6.1cvs15.patchset diff --git a/configure.ac b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=6 MICRO_VERSION=1 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=14 +EXTRA_VERSION=15 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/common/utils.c b/src/common/utils.c @@ -3331,6 +3331,7 @@ static void encode_uri(gchar *encoded_uri, gint bufsize, const gchar *uri) gint open_uri(const gchar *uri, const gchar *cmdline) { #ifndef MAEMO +#ifndef G_OS_WIN32 gchar buf[BUFFSIZE]; gchar *p; gchar encoded_uri[BUFFSIZE]; @@ -3353,6 +3354,9 @@ gint open_uri(const gchar *uri, const gchar *cmdline) execute_command_line(buf, TRUE); #else + ShellExecute(NULL, "open", uri, NULL, NULL, SW_SHOW); +#endif +#else extern osso_context_t *get_osso_context(void); osso_rpc_run_with_defaults(get_osso_context(), "osso_browser", OSSO_BROWSER_OPEN_NEW_WINDOW_REQ, NULL, diff --git a/src/common/w32_reg.c b/src/common/w32_reg.c @@ -19,17 +19,12 @@ */ #include <windows.h> +#include "utils.h" #include "w32lib.h" -char *read_w32_registry_string( char *parent, char *section, char *key ) +static HKEY get_root_key_from_str(char *parent) { - HKEY hKey, rootKey; - char *str; - int ret; - - char buf[ MAX_PATH ]; - DWORD bufsiz = sizeof( buf ); - + HKEY rootKey = NULL; if (!parent || !strlen(parent)) rootKey = HKEY_CURRENT_USER ; else if (!strcmp(parent, "HKCR") || !strcmp(parent,"HKEY_CLASSES_ROOT")) @@ -42,7 +37,66 @@ char *read_w32_registry_string( char *parent, char *section, char *key ) rootKey = HKEY_USERS ; else if (!strcmp(parent, "HKCC") || !strcmp(parent,"HKEY_CURRENT_CONFIG")) rootKey = HKEY_CURRENT_CONFIG ; - else + return rootKey; + +} + +int write_w32_registry_string( char *parent, char *section, char *value, char *data ) +{ + HKEY hKey, rootKey; + int ret; + + rootKey = get_root_key_from_str(parent); + ret = RegCreateKeyEx(rootKey, section, 0, NULL, + REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL); + if (ret != ERROR_SUCCESS) { + debug_print("can't write key %s\\%s: %d\n", parent, section, ret); + return -1; + } + ret = RegSetValueEx(hKey, value, 0, REG_SZ, (LPVOID)data, strlen(data)); + if (ret != ERROR_SUCCESS) { + RegCloseKey(hKey); + debug_print("can't write key %s\\%s: %d\n", parent, section, ret); + return -1; + } + RegCloseKey(hKey); + return 0; +} + +int write_w32_registry_dword( char *parent, char *section, char *value, int data ) +{ + HKEY hKey, rootKey; + int ret; + + rootKey = get_root_key_from_str(parent); + ret = RegCreateKeyEx(rootKey, section, 0, NULL, + REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL); + if (ret != ERROR_SUCCESS) { + debug_print("can't write key %s\\%s: %d\n", parent, section, ret); + return -1; + } + ret = RegSetValueEx(hKey, value, 0, REG_DWORD, (LPBYTE)&data, sizeof(data)); + if (ret != ERROR_SUCCESS) { + RegCloseKey(hKey); + debug_print("can't write key %s\\%s: %d\n", parent, section, ret); + return -1; + } + RegCloseKey(hKey); + return 0; +} + +char *read_w32_registry_string( char *parent, char *section, char *key ) +{ + HKEY hKey, rootKey; + char *str; + int ret; + + char buf[ MAX_PATH ]; + DWORD bufsiz = sizeof( buf ); + + rootKey = get_root_key_from_str(parent); + + if (!rootKey) return NULL; str = NULL; diff --git a/src/common/w32lib.h b/src/common/w32lib.h @@ -209,6 +209,8 @@ int pclose( FILE *stream ); int w32_is_administrator (void); /*** misc ***/ +int write_w32_registry_string( char *parent, char *section, char *value, char *data ); +int write_w32_registry_dword( char *parent, char *section, char *value, int data ); char *read_w32_registry_string( char *parent, char *section, char *key ); char *get_content_type_from_registry_with_ext( char *ext ); diff --git a/src/mainwindow.c b/src/mainwindow.c @@ -373,6 +373,11 @@ static void manual_faq_open_cb (GtkAction *action, 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); @@ -723,6 +728,9 @@ static GtkActionEntry mainwin_entries[] = {"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) }, }; @@ -1926,6 +1934,8 @@ MainWindow *main_window_create() 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) 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) + 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) @@ -4906,6 +4916,76 @@ static void legend_open_cb(GtkAction *action, gpointer 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); + + r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail", + "", "Claws Mail"); + if (!r) + 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) { + 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; diff --git a/src/mimeview.c b/src/mimeview.c @@ -119,10 +119,12 @@ static void mimeview_save_as (MimeView *mimeview); static void mimeview_save_all (MimeView *mimeview); static void mimeview_launch (MimeView *mimeview, MimeInfo *partinfo); +#ifndef G_OS_WIN32 static void mimeview_open_with (MimeView *mimeview); static void mimeview_open_part_with (MimeView *mimeview, MimeInfo *partinfo, gboolean automatic); +#endif static void mimeview_select_next_part (MimeView *mimeview); static void mimeview_select_prev_part (MimeView *mimeview); static void mimeview_view_file (const gchar *filename, @@ -161,10 +163,12 @@ static void mimeview_launch_cb(GtkAction *action, gpointer data) mimeview_launch(mimeview, mimeview_get_part_to_use(mimeview)); } +#ifndef G_OS_WIN32 static void mimeview_open_with_cb(GtkAction *action, gpointer data) { mimeview_open_with((MimeView *)data); } +#endif static void mimeview_display_as_text_cb(GtkAction *action, gpointer data) { @@ -189,7 +193,7 @@ static void mimeview_select_next_part_cb(GtkAction *action, gpointer data) static GtkActionEntry mimeview_menu_actions[] = { { "MimeView", NULL, "MimeView" }, { "MimeView/Open", NULL, N_("_Open (l)"), NULL, "Open MIME part", G_CALLBACK(mimeview_launch_cb) }, -#ifndef MAEMO +#if (!defined MAEMO && !defined G_OS_WIN32) { "MimeView/OpenWith", NULL, N_("Open _with (o)..."), NULL, "Open MIME part with...", G_CALLBACK(mimeview_open_with_cb) }, #endif { "MimeView/DisplayAsText", NULL, N_("_Display as text (t)"), NULL, "Display as text", G_CALLBACK(mimeview_display_as_text_cb) }, @@ -359,7 +363,7 @@ MimeView *mimeview_create(MainWindow *mainwin) MENUITEM_ADDUI_MANAGER(mimeview->ui_manager, "/Menus/MimeView/", "Open", "MimeView/Open", GTK_UI_MANAGER_MENUITEM); -#ifndef MAEMO +#if (!defined MAEMO && !defined G_OS_WIN32) MENUITEM_ADDUI_MANAGER(mimeview->ui_manager, "/Menus/MimeView/", "OpenWith", "MimeView/OpenWith", GTK_UI_MANAGER_MENUITEM); @@ -1312,11 +1316,13 @@ static gboolean part_button_pressed(MimeView *mimeview, GdkEventButton *event, cm_menu_set_sensitive_full(mimeview->ui_manager, "Menus/MimeView/DisplayAsText", FALSE); else cm_menu_set_sensitive_full(mimeview->ui_manager, "Menus/MimeView/DisplayAsText", TRUE); +#ifndef G_OS_WIN32 if (partinfo && partinfo->type == MIMETYPE_APPLICATION && !g_ascii_strcasecmp(partinfo->subtype, "octet-stream")) cm_menu_set_sensitive_full(mimeview->ui_manager, "Menus/MimeView/Open", FALSE); else +#endif cm_menu_set_sensitive_full(mimeview->ui_manager, "Menus/MimeView/Open", TRUE); g_object_set_data(G_OBJECT(mimeview->popupmenu), @@ -1445,11 +1451,13 @@ static gint mimeview_key_pressed(GtkWidget *widget, GdkEventKey *event, KEY_PRESS_EVENT_STOP(); mimeview_launch(mimeview, NULL); return TRUE; +#ifndef G_OS_WIN32 case GDK_o: BREAK_ON_MODIFIER_KEY(); KEY_PRESS_EVENT_STOP(); mimeview_open_with(mimeview); return TRUE; +#endif case GDK_c: BREAK_ON_MODIFIER_KEY(); KEY_PRESS_EVENT_STOP(); @@ -1846,6 +1854,7 @@ static void mimeview_launch(MimeView *mimeview, MimeInfo *partinfo) g_free(filename); } +#ifndef G_OS_WIN32 static void mimeview_open_with(MimeView *mimeview) { MimeInfo *partinfo; @@ -1976,10 +1985,12 @@ out: g_free(content_type); g_free(filename); } +#endif static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo, const gchar *cmd, MimeView *mimeview) { +#ifndef G_OS_WIN32 gchar *p; gchar buf[BUFFSIZE]; if (cmd == NULL) @@ -2002,6 +2013,24 @@ static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo, mimeview_open_part_with(mimeview, partinfo, FALSE); } } +#else + SHFILEINFO file_info; + if ((SHGetFileInfo(filename, 0, &file_info, sizeof(SHFILEINFO), SHGFI_EXETYPE)) != 0) { + AlertValue val = alertpanel_full(_("Execute untrusted binary?"), + _("This attachment is an executable file. Executing " + "untrusted binaries is dangerous and could probably " + "lead to compromission of your computer.\n\n" + "Do you want to run this file?"), GTK_STOCK_CANCEL, + _("Run binary"), + NULL, FALSE, NULL, ALERT_WARNING, G_ALERTDEFAULT); + if (val == G_ALERTALTERNATE) { + debug_print("executing binary\n"); + ShellExecute(NULL, "open", filename, NULL, NULL, SW_SHOW); + } + } else + ShellExecute(NULL, "open", filename, NULL, NULL, SW_SHOW); + +#endif } void mimeview_register_viewer_factory(MimeViewerFactory *factory) @@ -2127,10 +2156,12 @@ static gint icon_key_pressed(GtkWidget *button, GdkEventKey *event, BREAK_ON_MODIFIER_KEY(); mimeview_launch(mimeview, NULL); return TRUE; +#ifndef G_OS_WIN32 case GDK_o: BREAK_ON_MODIFIER_KEY(); mimeview_open_with(mimeview); return TRUE; +#endif case GDK_c: BREAK_ON_MODIFIER_KEY(); mimeview_check_signature(mimeview); @@ -2509,8 +2540,10 @@ void mimeview_handle_cmd(MimeView *mimeview, const gchar *cmd, GdkEventButton *e mimeview_save_as(mimeview); else if (!strcmp(cmd, "sc://display_as_text")) mimeview_display_as_text(mimeview); +#ifndef G_OS_WIN32 else if (!strcmp(cmd, "sc://open_with")) mimeview_open_with(mimeview); +#endif else if (!strcmp(cmd, "sc://open")) mimeview_launch(mimeview, NULL); else if (!strcmp(cmd, "sc://select_attachment") && data != NULL) { diff --git a/src/prefs_common.c b/src/prefs_common.c @@ -121,10 +121,6 @@ static PrefParam param_os_specific[] = { &prefs_common.pixmap_theme_path, P_STRING, NULL, NULL, NULL}, /* Other */ - {"uri_open_command", NULL, - &prefs_common.uri_cmd, P_STRING, NULL, NULL, NULL}, - {"print_command", "notepad /p %s", - &prefs_common.print_cmd, P_STRING, NULL, NULL, NULL}, {"ext_editor_command", "notepad %s", &prefs_common.ext_editor_cmd, P_STRING, NULL, NULL, NULL}, @@ -813,10 +809,12 @@ static PrefParam param[] = { P_INT, NULL, NULL, NULL}, /* Other */ +#ifndef G_OS_WIN32 {"uri_open_command", DEFAULT_BROWSER_CMD, &SPECIFIC_PREFS.uri_cmd, P_STRING, NULL, NULL, NULL}, {"print_command", "lpr %s", &SPECIFIC_PREFS.print_cmd, P_STRING, NULL, NULL, NULL}, +#endif {"ext_editor_command", DEFAULT_EDITOR_CMD, &SPECIFIC_PREFS.ext_editor_cmd, P_STRING, NULL, NULL, NULL}, {"cmds_use_system_default", "FALSE", @@ -1518,6 +1516,9 @@ const gchar *prefs_common_translated_header_name(const gchar *header_name) const gchar *prefs_common_get_uri_cmd(void) { +#ifdef G_OS_WIN32 + return NULL; +#else gchar *tmp = NULL; if (!prefs_common.cmds_use_system_default) @@ -1529,6 +1530,7 @@ const gchar *prefs_common_get_uri_cmd(void) g_free(tmp); return "xdg-open %s"; +#endif } const gchar *prefs_common_get_ext_editor_cmd(void) diff --git a/src/prefs_common.h b/src/prefs_common.h @@ -370,8 +370,10 @@ struct _PrefsCommon gint apply_per_account_filtering_rules; /* Other */ +#ifndef G_OS_WIN32 gchar *uri_cmd; gchar *print_cmd; +#endif gchar *ext_editor_cmd; gboolean cmds_use_system_default; diff --git a/src/prefs_ext_prog.c b/src/prefs_ext_prog.c @@ -48,14 +48,14 @@ typedef struct _ExtProgPage GtkWidget *window; /* do not modify */ GtkWidget *cmds_use_system_default_checkbtn; - +#ifndef G_OS_WIN32 GtkWidget *uri_label; GtkWidget *uri_combo; GtkWidget *uri_entry; GtkWidget *printcmd_label; GtkWidget *printcmd_entry; - +#endif GtkWidget *exteditor_label; GtkWidget *exteditor_combo; GtkWidget *exteditor_entry; @@ -74,16 +74,18 @@ static void prefs_ext_prog_create_widget(PrefsPage *_page, GtkWindow *window, GtkWidget *hint_label; GtkWidget *table2; GtkWidget *cmds_use_system_default_checkbtn; +#ifndef G_OS_WIN32 GtkWidget *uri_label; GtkWidget *uri_combo; GtkWidget *uri_entry; + GtkWidget *printcmd_label; + GtkWidget *printcmd_entry; +#endif GtkWidget *exteditor_label; GtkWidget *exteditor_combo; GtkWidget *exteditor_entry; GtkWidget *astextviewer_label; GtkWidget *astextviewer_entry; - GtkWidget *printcmd_label; - GtkWidget *printcmd_entry; CLAWS_TIP_DECL(); int i = 0; gchar *tmp; @@ -144,6 +146,7 @@ static void prefs_ext_prog_create_widget(PrefsPage *_page, GtkWindow *window, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 2); +#ifndef G_OS_WIN32 uri_label = gtk_label_new (_("Web browser")); gtk_widget_show(uri_label); #ifdef MAEMO @@ -177,7 +180,7 @@ static void prefs_ext_prog_create_widget(PrefsPage *_page, GtkWindow *window, uri_entry = gtk_bin_get_child(GTK_BIN((uri_combo))); gtk_entry_set_text(GTK_ENTRY(uri_entry), prefs_common.uri_cmd ? prefs_common.uri_cmd : ""); - +#endif exteditor_label = gtk_label_new (_("Text editor")); gtk_widget_show(exteditor_label); @@ -229,6 +232,7 @@ static void prefs_ext_prog_create_widget(PrefsPage *_page, GtkWindow *window, gtk_entry_set_text(GTK_ENTRY(astextviewer_entry), prefs_common.mime_textviewer ? prefs_common.mime_textviewer : ""); +#ifndef G_OS_WIN32 printcmd_label = gtk_label_new (_("Print command")); #if !defined(USE_GNOMEPRINT) && !GTK_CHECK_VERSION(2,10,0) gtk_widget_show(printcmd_label); @@ -248,9 +252,12 @@ static void prefs_ext_prog_create_widget(PrefsPage *_page, GtkWindow *window, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_entry_set_text(GTK_ENTRY(printcmd_entry), prefs_common.print_cmd ? prefs_common.print_cmd : ""); +#endif +#ifndef G_OS_WIN32 SET_TOGGLE_SENSITIVITY_REVERSE (cmds_use_system_default_checkbtn, uri_label); SET_TOGGLE_SENSITIVITY_REVERSE (cmds_use_system_default_checkbtn, uri_combo); +#endif #if 0 /* we should do that, but it detaches the editor and breaks compose.c's external composition. */ SET_TOGGLE_SENSITIVITY_REVERSE (cmds_use_system_default_checkbtn, exteditor_label); @@ -258,10 +265,12 @@ static void prefs_ext_prog_create_widget(PrefsPage *_page, GtkWindow *window, #endif prefs_ext_prog->window = GTK_WIDGET(window); +#ifndef G_OS_WIN32 prefs_ext_prog->uri_entry = uri_entry; + prefs_ext_prog->printcmd_entry = printcmd_entry; +#endif prefs_ext_prog->exteditor_entry = exteditor_entry; prefs_ext_prog->astextviewer_entry = astextviewer_entry; - prefs_ext_prog->printcmd_entry = printcmd_entry; prefs_ext_prog->cmds_use_system_default_checkbtn = cmds_use_system_default_checkbtn; prefs_ext_prog->page.widget = table; } @@ -270,10 +279,12 @@ static void prefs_ext_prog_save(PrefsPage *_page) { ExtProgPage *ext_prog = (ExtProgPage *) _page; +#ifndef G_OS_WIN32 prefs_common.uri_cmd = gtk_editable_get_chars (GTK_EDITABLE(ext_prog->uri_entry), 0, -1); prefs_common.print_cmd = gtk_editable_get_chars (GTK_EDITABLE(ext_prog->printcmd_entry), 0, -1); +#endif prefs_common.ext_editor_cmd = gtk_editable_get_chars (GTK_EDITABLE(ext_prog->exteditor_entry), 0, -1); prefs_common.mime_textviewer = gtk_editable_get_chars diff --git a/src/procmime.c b/src/procmime.c @@ -978,33 +978,42 @@ static GList *mime_type_list = NULL; gchar *procmime_get_mime_type(const gchar *filename) { - static GHashTable *mime_type_table = NULL; - MimeType *mime_type; const gchar *p; gchar *ext = NULL; gchar *base; +#ifndef G_OS_WIN32 + static GHashTable *mime_type_table = NULL; + MimeType *mime_type; if (!mime_type_table) { mime_type_table = procmime_get_mime_type_table(); if (!mime_type_table) return NULL; } +#endif base = g_path_get_basename(filename); if ((p = strrchr(base, '.')) != NULL) ext = g_utf8_strdown(p + 1, -1); g_free(base); +#ifndef G_OS_WIN32 mime_type = g_hash_table_lookup(mime_type_table, ext); - g_free(ext); + if (mime_type) { gchar *str; - str = g_strconcat(mime_type->type, "/", mime_type->sub_type, NULL); + debug_print("got type %s for %s\n", str, ext); + g_free(ext); return str; - } - + } return NULL; +#else + gchar *str = get_content_type_from_registry_with_ext(ext); + + g_free(ext); + return str; +#endif } static guint procmime_str_hash(gconstpointer gptr) diff --git a/src/textview.c b/src/textview.c @@ -924,10 +924,12 @@ void textview_show_mime_part(TextView *textview, MimeInfo *partinfo) TEXTVIEW_INSERT(_(" (Shortcut key: 'l')\n")); TEXTVIEW_INSERT(_(" (alternately double-click, or click the middle ")); TEXTVIEW_INSERT(_("mouse button)\n")); +#ifndef G_OS_WIN32 TEXTVIEW_INSERT(_(" - Or use ")); TEXTVIEW_INSERT_LINK(_("'Open with...'"), "sc://open_with", NULL); TEXTVIEW_INSERT(_(" (Shortcut key: 'o')")); #endif +#endif TEXTVIEW_INSERT("\n"); textview_show_icon(textview, GTK_STOCK_DIALOG_INFO);