2006-04-06 [mones] 2.1.0cvs7
[claws.git] / src / mimeview.c
index 641a7cb64d6259c80ae900d6e95afe7a9662280f..e9a194ba42e598b012ddd6274dc24859298d86c5 100644 (file)
@@ -63,6 +63,7 @@
 #include "procheader.h"
 #include "stock_pixmap.h"
 #include "gtk/gtkvscrollbutton.h"
+#include "gtk/logwindow.h"
 
 
 typedef enum
@@ -602,6 +603,7 @@ gboolean mimeview_show_part(MimeView *mimeview, MimeInfo *partinfo)
                mimeview->mimeviewer = viewer;
                mimeview_change_view_type(mimeview, MIMEVIEW_VIEWER);
        }
+       viewer->mimeview = mimeview;
        viewer->show_mimepart(viewer, mimeview->file, partinfo);
 
        return TRUE;
@@ -1052,26 +1054,6 @@ static void mimeview_selected(GtkCTree *ctree, GtkCTreeNode *node, gint column,
                        mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
                        textview_clear(mimeview->textview);
                        textview_show_mime_part(mimeview->textview, partinfo);
-                       
-#if 0 /* this sucks. I'll do better. */
-                       val = alertpanel_full(_("Unknown part type"), 
-                                             _("The type of this part is unknown. What would you like "
-                                               "to do with it?"),
-                                             GTK_STOCK_SAVE, GTK_STOCK_OPEN, _("Display as text"),
-                                             FALSE, NULL, ALERT_WARNING, G_ALERTALTERNATE);
-                       switch (val) {
-                               case G_ALERTDEFAULT:
-                                       mimeview_save_as(mimeview);
-                                       break;
-                               case G_ALERTALTERNATE:
-                                       mimeview_open_with(mimeview);
-                                       break;
-                               case G_ALERTOTHER:
-                                       mimeview_display_as_text(mimeview);
-                                       break;
-                               default:
-                       }
-#endif
                        break;
                }
        }
@@ -1308,18 +1290,18 @@ static void mimeview_drag_data_get(GtkWidget        *widget,
                filename = g_path_get_basename("Unnamed part");
                
 
-
-       tmp = filename;
+       tmp = g_filename_from_utf8(filename, -1, NULL, NULL, NULL);
        
        filename = g_strconcat(get_mime_tmp_dir(), G_DIR_SEPARATOR_S,
-                              filename, NULL);
+                              tmp, NULL);
 
        g_free(tmp);
 
        if (procmime_get_part(filename, partinfo) < 0)
                alertpanel_error
                        (_("Can't save the part of multipart message."));
-       uriname = g_strconcat("file://", filename, NULL);
+       uriname = g_strconcat("file://", filename, "\r\n", NULL);
+
        gtk_selection_data_set(selection_data, selection_data->target, 8,
                               uriname, strlen(uriname));
 
@@ -1427,14 +1409,14 @@ static void mimeview_save_all(MimeView *mimeview)
 
        dirname = filesel_select_file_save_folder(_("Select destination folder"), startdir);
        if (!dirname) {
-               if (startdir) g_free(startdir);
+               g_free(startdir);
                return;
        }
 
        if (!is_dir_exist (dirname)) {
                alertpanel_error(_("'%s' is not a directory."),
                                 dirname);
-               if (startdir) g_free(startdir);
+               g_free(startdir);
                return;
        }
 
@@ -1463,12 +1445,9 @@ static void mimeview_save_all(MimeView *mimeview)
                partinfo = procmime_mimeinfo_next(partinfo);
        }
 
-       if (prefs_common.attach_save_dir)
-               g_free(prefs_common.attach_save_dir);
-
+       g_free(prefs_common.attach_save_dir);
+       g_free(startdir);
        prefs_common.attach_save_dir = g_strdup(dirname);
-
-       if (startdir) g_free(startdir);
 }
 
 /**
@@ -1527,8 +1506,7 @@ static void mimeview_save_as(MimeView *mimeview)
 
        filedir = g_path_get_dirname(filename);
        if (filedir && strcmp(filedir, ".")) {
-               if (prefs_common.attach_save_dir)
-                       g_free(prefs_common.attach_save_dir);
+               g_free(prefs_common.attach_save_dir);
                prefs_common.attach_save_dir = g_strdup(filedir);
        }
 
@@ -2185,3 +2163,32 @@ void mimeview_update (MimeView *mimeview) {
                icon_list_create(mimeview, mimeview->mimeinfo);
        }
 }
+
+void mimeview_handle_cmd(MimeView *mimeview, const gchar *cmd)
+{
+       MessageView *msgview = NULL;
+       MainWindow *mainwin = NULL;
+       
+       if (!cmd)
+               return;
+       
+       msgview = mimeview->messageview;
+       if (!msgview)
+               return;
+               
+       mainwin = msgview->mainwin;
+       if (!mainwin)
+               return;
+               
+       else if (!strcmp(cmd, "sc://view_log"))
+               log_window_show(mainwin->logwin);
+       else if (!strcmp(cmd, "sc://save_as"))
+               mimeview_save_as(mimeview);
+       else if (!strcmp(cmd, "sc://display_as_text"))
+               mimeview_display_as_text(mimeview);
+       else if (!strcmp(cmd, "sc://open_with"))
+               mimeview_open_with(mimeview);
+       else if (!strcmp(cmd, "sc://open"))
+               mimeview_launch(mimeview);
+}
+