2005-08-22 [paul] 1.9.13cvs46
authorPaul Mangan <paul@claws-mail.org>
Mon, 22 Aug 2005 10:36:39 +0000 (10:36 +0000)
committerPaul Mangan <paul@claws-mail.org>
Mon, 22 Aug 2005 10:36:39 +0000 (10:36 +0000)
* src/mimeview.c
* src/prefs_common.c
* src/common/defs.h
define reused defaults in defs.h
* src/textview.c
add 'Open image' to image popup menu

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/common/defs.h
src/mimeview.c
src/prefs_common.c
src/textview.c

index ef03845d45431e1bb6844b3280cd91aa399876e2..537dd6315cf665a2ef98b4c0e6e7d71838fb69dc 100644 (file)
@@ -1,3 +1,12 @@
+2005-08-22 [paul]      1.9.13cvs46
+
+       * src/mimeview.c
+       * src/prefs_common.c
+       * src/common/defs.h
+               define reused defaults in defs.h
+       * src/textview.c
+               add 'Open image' to image popup menu
+
 2005-08-21 [colin]     1.9.13cvs45
 
        * src/summaryview.c
index 23ad886881164a9879e76be4ebbbf7a49dc2fc8e..1bb3bf3df0f82f81e14d3a683838c354a3d0bba4 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.149.2.31 -r 1.149.2.32 src/inc.c;  cvs diff -u -r 1.204.2.53 -r 1.204.2.54 src/prefs_common.c;  cvs diff -u -r 1.103.2.26 -r 1.103.2.27 src/prefs_common.h;  ) > 1.9.13cvs43.patchset
 ( cvs diff -u -r 1.213.2.52 -r 1.213.2.53 src/folder.c;  ) > 1.9.13cvs44.patchset
 ( cvs diff -u -r 1.395.2.115 -r 1.395.2.116 src/summaryview.c;  ) > 1.9.13cvs45.patchset
+( cvs diff -u -r 1.83.2.36 -r 1.83.2.37 src/mimeview.c;  cvs diff -u -r 1.204.2.54 -r 1.204.2.55 src/prefs_common.c;  cvs diff -u -r 1.96.2.70 -r 1.96.2.71 src/textview.c;  cvs diff -u -r 1.9.2.13 -r 1.9.2.14 src/common/defs.h;  ) > 1.9.13cvs46.patchset
index a23591573c2a16e307f49fafa0a5ab6dff386be1..114d59b62f64aebecceeaa77628ee21c561eec60 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=13
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=45
+EXTRA_VERSION=46
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index b126775b7209b34ccc8ddf27a38450506ceb033e..7aeb719bb8cd4084fbc6b3bf892f16ef2beaff0d 100644 (file)
@@ -93,6 +93,9 @@
 /* #define DEFAULT_INC_PROGRAM "imget" */
 #define DEFAULT_SENDMAIL_CMD   "/usr/sbin/sendmail -t -i"
 #define DEFAULT_BROWSER_CMD    "mozilla-firefox -remote 'openURL(%s,new-window)'"
+#define DEFAULT_MIME_CMD       "metamail -d -b -x -c %s '%s'"
+#define DEFAULT_IMAGE_VIEWER_CMD "display '%s'"
+#define DEFAULT_AUDIO_PLAYER_CMD "play '%s'"
 
 #ifdef _PATH_MAILDIR
 #  define DEFAULT_SPOOL_PATH   _PATH_MAILDIR
index dd0d8f4fb99398490fa6ce49ac51a15815ce6cbe..2dd927c50ad7974c1fc24d744cd5ffcdaa230d7d 100644 (file)
@@ -1277,10 +1277,10 @@ static void mimeview_open_with(MimeView *mimeview)
 static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo,
                               const gchar *cmdline)
 {
-       static gchar *default_image_cmdline = "display '%s'";
-       static gchar *default_audio_cmdline = "play '%s'";
+       static gchar *default_image_cmdline = DEFAULT_IMAGE_VIEWER_CMD;
+       static gchar *default_audio_cmdline = DEFAULT_AUDIO_PLAYER_CMD;
        static gchar *default_html_cmdline = DEFAULT_BROWSER_CMD;
-       static gchar *mime_cmdline = "metamail -d -b -x -c %s '%s'";
+       static gchar *mime_cmdline = DEFAULT_MIME_CMD;
        gchar buf[1024];
        gchar m_buf[1024];
        const gchar *cmd;
index eba8c4611a2cbc4f6273396f0cb9ae8f890d4295..bb2e1acb0651807b6ecfd380a34a2f85f088b707 100644 (file)
@@ -480,9 +480,9 @@ static PrefParam param[] = {
         &prefs_common.attach_save_dir, P_STRING, NULL, NULL, NULL},
 
        /* MIME viewer */
-       {"mime_image_viewer", "display '%s'",
+       {"mime_image_viewer", DEFAULT_IMAGE_VIEWER_CMD,
         &prefs_common.mime_image_viewer, P_STRING, NULL, NULL, NULL},
-       {"mime_audio_player", "play '%s'",
+       {"mime_audio_player", DEFAULT_AUDIO_PLAYER_CMD,
         &prefs_common.mime_audio_player, P_STRING, NULL, NULL, NULL},
        {"mime_open_command", "gedit '%s'",
         &prefs_common.mime_open_cmd, P_STRING, NULL, NULL, NULL},
index 024457748e34df601f8e69d6e4f93cf75a2b178c..4a1876b542de2c2e79b8fe9caeb25573e01a79c2 100644 (file)
@@ -208,6 +208,9 @@ static void copy_mail_to_uri_cb                     (TextView       *textview,
 static void save_file_cb                       (TextView       *textview,
                                                 guint           action,
                                                 void           *data);
+static void open_image_cb                      (TextView       *textview,
+                                                guint           action,
+                                                void           *data);
 
 static GtkItemFactoryEntry textview_link_popup_entries[] = 
 {
@@ -224,7 +227,8 @@ static GtkItemFactoryEntry textview_mail_popup_entries[] =
 
 static GtkItemFactoryEntry textview_file_popup_entries[] = 
 {
-       {N_("/_Save this image..."),            NULL, save_file_cb, 0, NULL},
+       {N_("/_Open image"),            NULL, open_image_cb, 0, NULL},
+       {N_("/_Save image..."),         NULL, save_file_cb, 0, NULL},
 };
 
 
@@ -1942,6 +1946,57 @@ static void open_uri_cb (TextView *textview, guint action, void *data)
                          NULL);
 }
 
+static void open_image_cb (TextView *textview, guint action, void *data)
+{
+       RemoteURI *uri = g_object_get_data(G_OBJECT(textview->file_popup_menu),
+                                          "menu_button");
+
+       static gchar *default_cmdline = DEFAULT_IMAGE_VIEWER_CMD;
+       gchar buf[1024];
+       const gchar *cmd;
+       const gchar *def_cmd;
+       const gchar *p;
+       gchar *filename = NULL;
+
+       if (uri == NULL)
+               return;
+
+       if (uri->filename == NULL)
+               return;
+       
+       filename = g_strdup(uri->filename);
+       
+       if (!g_utf8_validate(filename, -1, NULL)) {
+               gchar *tmp = conv_filename_to_utf8(filename);
+               g_free(filename);
+               filename = tmp;
+       }
+
+       subst_for_filename(filename);
+
+       cmd = prefs_common.mime_image_viewer;
+       def_cmd = default_cmdline;
+       
+       if (cmd && (p = strchr(cmd, '%')) && *(p + 1) == 's' &&
+           !strchr(p + 2, '%'))
+               g_snprintf(buf, sizeof(buf), cmd, filename);
+       else {
+               if (cmd)
+                       g_warning("Image viewer command line is invalid: '%s'", cmd);
+               if (def_cmd)
+                       g_snprintf(buf, sizeof(buf), def_cmd, filename);
+               else
+                       return;
+       }
+
+       execute_command_line(buf, TRUE);
+
+       g_free(filename);
+
+       g_object_set_data(G_OBJECT(textview->file_popup_menu), "menu_button",
+                         NULL);
+}
+
 static void save_file_cb (TextView *textview, guint action, void *data)
 {
        RemoteURI *uri = g_object_get_data(G_OBJECT(textview->file_popup_menu),