2005-02-09 [colin] 1.0.1cvs1.1
[claws.git] / src / mimeview.c
index 42fc4e29495bf7ba10371d76a3e9e2753914d02c..187ff460a647f6e81e55b5c548166a79af5ed3b3 100644 (file)
@@ -429,7 +429,7 @@ static GtkCTreeNode *mimeview_append_part(MimeView *mimeview,
        gchar *str[N_MIMEVIEW_COLS];
 
        if (partinfo->type != MIMETYPE_UNKNOWN && partinfo->subtype) {
-               g_snprintf(content_type, 64, "%s/%s", procmime_get_type_str(partinfo->type), partinfo->subtype);
+               g_snprintf(content_type, 64, "%s/%s", procmime_get_media_type_str(partinfo->type), partinfo->subtype);
        } else {
                g_snprintf(content_type, 64, "UNKNOWN");
        }
@@ -532,7 +532,7 @@ static MimeViewer *get_viewer_for_mimeinfo(MimeView *mimeview, MimeInfo *partinf
        MimeViewer *viewer = NULL;
 
        if ((partinfo->type == MIMETYPE_APPLICATION) &&
-            (!g_strcasecmp(partinfo->subtype, "octet-stream"))) {
+            (!g_ascii_strcasecmp(partinfo->subtype, "octet-stream"))) {
                const gchar *filename;
 
                filename = procmime_mimeinfo_get_parameter(partinfo, "filename");
@@ -552,7 +552,7 @@ static MimeViewer *get_viewer_for_mimeinfo(MimeView *mimeview, MimeInfo *partinf
        return viewer;
 }
 
-static gboolean mimeview_show_part(MimeView *mimeview, MimeInfo *partinfo)
+gboolean mimeview_show_part(MimeView *mimeview, MimeInfo *partinfo)
 {
        MimeViewer *viewer;
        
@@ -584,12 +584,12 @@ static void mimeview_change_view_type(MimeView *mimeview, MimeViewType type)
 
        switch (type) {
        case MIMEVIEW_TEXT:
-               gtk_notebook_set_page(GTK_NOTEBOOK(mimeview->mime_notebook),
+               gtk_notebook_set_current_page(GTK_NOTEBOOK(mimeview->mime_notebook),
                        gtk_notebook_page_num(GTK_NOTEBOOK(mimeview->mime_notebook), 
                        GTK_WIDGET_PTR(textview)));
                break;
        case MIMEVIEW_VIEWER:
-               gtk_notebook_set_page(GTK_NOTEBOOK(mimeview->mime_notebook),
+               gtk_notebook_set_current_page(GTK_NOTEBOOK(mimeview->mime_notebook),
                        gtk_notebook_page_num(GTK_NOTEBOOK(mimeview->mime_notebook), 
                        GTK_WIDGET(mimeview->mimeviewer->get_widget(mimeview->mimeviewer))));
                break;
@@ -669,7 +669,7 @@ static void update_signature_noticeview(MimeView *mimeview, MimeInfo *mimeinfo)
        noticeview_set_button_text(mimeview->siginfoview, button_text);
        noticeview_set_button_press_callback(
                mimeview->siginfoview,
-               GTK_SIGNAL_FUNC(func),
+               G_CALLBACK(func),
                (gpointer) mimeview);
        noticeview_set_icon(mimeview->siginfoview, icon);
 }
@@ -823,7 +823,7 @@ static gboolean part_button_pressed(MimeView *mimeview, GdkEventButton *event,
                                           "/Display as text", TRUE);
                if (partinfo &&
                    partinfo->type == MIMETYPE_APPLICATION &&
-                   !g_strcasecmp(partinfo->subtype, "octet-stream"))
+                   !g_ascii_strcasecmp(partinfo->subtype, "octet-stream"))
                        menu_set_sensitive(mimeview->popupfactory,
                                           "/Open", FALSE);
                else
@@ -967,7 +967,7 @@ static void mimeview_drag_data_get(GtkWidget            *widget,
                alertpanel_error
                        (_("Can't save the part of multipart message."));
 
-       uriname = g_strconcat("file:/", filename, NULL);
+       uriname = g_strconcat("file://", filename, NULL);
        gtk_selection_data_set(selection_data, selection_data->target, 8,
                               uriname, strlen(uriname));
 
@@ -1012,7 +1012,7 @@ static gboolean mimeview_write_part(const gchar *filename,
 {
        gchar *dir;
        
-       dir= g_dirname(filename);
+       dir= g_path_get_dirname(filename);
        if (!is_dir_exist(dir))
                make_dir_hier(dir);
        g_free(dir);
@@ -1023,8 +1023,8 @@ static gboolean mimeview_write_part(const gchar *filename,
                
                res = g_strdup_printf(_("Overwrite existing file '%s'?"),
                                      filename);
-               aval = alertpanel(_("Overwrite"), res, _("OK")
-                                 _("Cancel"), NULL);
+               aval = alertpanel(_("Overwrite"), res, GTK_STOCK_OK
+                                 GTK_STOCK_CANCEL, NULL);
                g_free(res);                                      
                if (G_ALERTDEFAULT != aval) return FALSE;
        }
@@ -1074,6 +1074,15 @@ static void mimeview_save_all(MimeView *mimeview)
        if (dirname[strlen(dirname)-1] == G_DIR_SEPARATOR)
                dirname[strlen(dirname)-1] = '\0';
 
+       /* Skip the first part, that is sometimes DISPOSITIONTYPE_UNKNOWN */
+       if (partinfo && partinfo->type == MIMETYPE_MESSAGE)
+               partinfo = procmime_mimeinfo_next(partinfo);
+       if (partinfo && partinfo->type == MIMETYPE_MULTIPART) {
+               partinfo = procmime_mimeinfo_next(partinfo);
+               if (partinfo && partinfo->type == MIMETYPE_TEXT)
+                       partinfo = procmime_mimeinfo_next(partinfo);
+       }
+               
        while (partinfo != NULL) {
                if (partinfo->type != MIMETYPE_MESSAGE &&
                    partinfo->type != MIMETYPE_MULTIPART &&
@@ -1138,7 +1147,7 @@ static void mimeview_save_as(MimeView *mimeview)
 
        mimeview_write_part(filename, partinfo);
 
-       filedir = g_dirname(filename);
+       filedir = g_path_get_dirname(filename);
        if (filedir && strcmp(filedir, ".")) {
                if (prefs_common.attach_save_dir)
                        g_free(prefs_common.attach_save_dir);
@@ -1264,7 +1273,7 @@ static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo,
                cmd = cmdline;
                def_cmd = NULL;
        } else if (MIMETYPE_APPLICATION == partinfo->type &&
-                  !g_strcasecmp(partinfo->subtype, "octet-stream")) {
+                  !g_ascii_strcasecmp(partinfo->subtype, "octet-stream")) {
                return;
        } else if (MIMETYPE_IMAGE == partinfo->type) {
                cmd = prefs_common.mime_image_viewer;
@@ -1506,9 +1515,9 @@ static void icon_list_append_icon (MimeView *mimeview, MimeInfo *mimeinfo)
        switch (mimeinfo->type) {
                
        case MIMETYPE_TEXT:
-               if (mimeinfo->subtype && !g_strcasecmp(mimeinfo->subtype, "html"))
+               if (mimeinfo->subtype && !g_ascii_strcasecmp(mimeinfo->subtype, "html"))
                        stockp = STOCK_PIXMAP_MIME_TEXT_HTML;
-               else if  (mimeinfo->subtype && !g_strcasecmp(mimeinfo->subtype, "enriched"))
+               else if  (mimeinfo->subtype && !g_ascii_strcasecmp(mimeinfo->subtype, "enriched"))
                        stockp = STOCK_PIXMAP_MIME_TEXT_ENRICHED;
                else
                        stockp = STOCK_PIXMAP_MIME_TEXT_PLAIN;