2007-11-07 [colin] 3.0.2cvs124
[claws.git] / src / mimeview.c
index 4f8c3476b0cbb99185eb2e061bfb378d5a077680..35aa0ccc29d6fad0996a8707ac341ffa9686cf05 100644 (file)
@@ -41,6 +41,8 @@
 #include <gtk/gtkcontainer.h>
 #include <gtk/gtkbutton.h>
 #include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 
 #ifndef HAVE_APACHE_FNMATCH
 /* kludge: apache's fnmatch clashes with <regex.h>, don't include
@@ -788,7 +790,7 @@ void mimeview_clear(MimeView *mimeview)
 }
 
 static void check_signature_cb(GtkWidget *widget, gpointer user_data);
-void mimeview_check_signature(MimeView *mimeview);
+static void mimeview_check_signature(MimeView *mimeview);
 static void display_full_info_cb(GtkWidget *widget, gpointer user_data);
 
 static void update_signature_noticeview(MimeView *mimeview, MimeInfo *mimeinfo, 
@@ -1059,7 +1061,7 @@ static void check_signature_cb(GtkWidget *widget, gpointer user_data)
 #endif
        noticeview_set_text(mimeview->siginfoview, _("Checking signature..."));
        GTK_EVENTS_FLUSH();
-#if (defined USE_PTHREAD && defined __GLIBC__ && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)))
+#if (defined USE_PTHREAD && ((defined __GLIBC__ && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3))) || !defined __GLIBC__))
        /* let's do it non-blocking */
        mimeview_check_sig_in_thread(mimeview);
        if (!mimeview->check_data) /* let's check syncronously */
@@ -1073,7 +1075,7 @@ static void check_signature_cb(GtkWidget *widget, gpointer user_data)
        }
 }
 
-void mimeview_check_signature(MimeView *mimeview)
+static void mimeview_check_signature(MimeView *mimeview)
 {
        check_signature_cb(NULL, mimeview);     
 }
@@ -1859,16 +1861,14 @@ static void mimeview_open_part_with(MimeView *mimeview, MimeInfo *partinfo, gboo
                                 _("Enter the command line to open file:\n"
                                   "('%s' will be replaced with file name)"),
                                 mime_command ? mime_command : prefs_common.mime_open_cmd,
-                                prefs_common.mime_open_cmd_history,
-                                TRUE, &remember);
+                                prefs_common.mime_open_cmd_history, &remember);
                else
                        cmd = input_dialog_combo
                                (_("Open with"),
                                 _("Enter the command line to open file:\n"
                                   "('%s' will be replaced with file name)"),
                                 mime_command ? mime_command : prefs_common.mime_open_cmd,
-                                prefs_common.mime_open_cmd_history,
-                                TRUE);
+                                prefs_common.mime_open_cmd_history);
                if (cmd && remember) {
                        mailcap_update_default(content_type, cmd);
                }
@@ -1883,7 +1883,9 @@ static void mimeview_open_part_with(MimeView *mimeview, MimeInfo *partinfo, gboo
                prefs_common.mime_open_cmd_history =
                        add_history(prefs_common.mime_open_cmd_history, cmd);
        }
+#ifdef MAEMO
 out:
+#endif
        g_free(content_type);
        g_free(filename);
 }
@@ -1897,14 +1899,21 @@ static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo,
                mimeview_open_part_with(mimeview, partinfo, TRUE);
        else {
                if ((p = strchr(cmd, '%')) && *(p + 1) == 's' &&
-                   !strchr(p + 2, '%'))
+                   !strchr(p + 2, '%')) {
                        g_snprintf(buf, sizeof(buf), cmd, filename);
-               else {
+                       if (!prefs_common.save_parts_readwrite)
+                               g_chmod(filename, S_IRUSR);
+                       else
+                               g_chmod(filename, S_IRUSR|S_IWUSR);
+               } else {
                        g_warning("MIME viewer command line is invalid: '%s'", cmd);
                        mimeview_open_part_with(mimeview, partinfo, FALSE);
                }
-               if (execute_command_line(buf, TRUE) != 0)
+               if (execute_command_line(buf, TRUE) != 0) {
+                       if (!prefs_common.save_parts_readwrite)
+                               g_chmod(filename, S_IRUSR|S_IWUSR);
                        mimeview_open_part_with(mimeview, partinfo, FALSE);
+               }
        }
 }
 
@@ -2253,6 +2262,7 @@ static void icon_list_clear (MimeView *mimeview)
        mimeview->icon_count = 0;
        adj  = gtk_layout_get_vadjustment(GTK_LAYOUT(mimeview->icon_scroll));
        gtk_adjustment_set_value(adj, adj->lower);
+       gtk_adjustment_changed(adj);
 }
 
 /*!