Switch core from strerror to g_strerror
[claws.git] / src / mimeview.c
index 17223b8ec5e3cf2b7faf5e0d909416fca312feab..4ee68bb3bd75ee0a827dc144ca8061fdadd7299f 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2013 Hiroyuki Yamamoto and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2015 Hiroyuki Yamamoto and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * 
+ *
  */
 
 #ifdef HAVE_CONFIG_H
@@ -458,9 +458,6 @@ MimeView *mimeview_create(MainWindow *mainwin)
        mimeview->icon_mainbox  = icon_mainbox;
        mimeview->icon_count    = 0;
        mimeview->mainwin       = mainwin;
-#if !(GTK_CHECK_VERSION(2,12,0))
-       mimeview->tooltips      = tips;
-#endif
        mimeview->mime_toggle   = mime_toggle;
        mimeview->siginfoview   = siginfoview;
        mimeview->scrollbutton  = scrollbutton;
@@ -1462,7 +1459,8 @@ static void mimeview_selected(GtkTreeSelection *selection, MimeView *mimeview)
                }
        }
 
-       if (mimeview->siginfo && privacy_auto_check_signatures(mimeview->siginfo)) {
+       if (mimeview->siginfo && privacy_auto_check_signatures(mimeview->siginfo)
+       &&  privacy_mimeinfo_get_sig_status(mimeview->siginfo) == SIGNATURE_UNCHECKED) {
                mimeview_check_signature(mimeview);
        }
 }
@@ -1696,21 +1694,23 @@ static void mimeview_drag_data_get(GtkWidget        *widget,
                FILE *fp;
 
                fp = g_fopen(partinfo->data.filename, "rb");
-               fseek(fp, partinfo->offset, SEEK_SET);
-               headers = procheader_get_header_array_asis(fp);
-               if (headers) {
-                       gint i;
-                       for (i = 0; i < headers->len; i++) {
-                               Header *header = g_ptr_array_index(headers, i);
-                               if (procheader_headername_equal(header->name, "Subject")) {
-                                       unfold_line(header->body);
-                                       name = g_strconcat(header->body, ".txt", NULL);
-                                       subst_for_filename(name);
+               if (fp != NULL && fseek(fp, partinfo->offset, SEEK_SET) == 0) {
+                       headers = procheader_get_header_array_asis(fp);
+                       if (headers) {
+                               gint i;
+                               for (i = 0; i < headers->len; i++) {
+                                       Header *header = g_ptr_array_index(headers, i);
+                                       if (procheader_headername_equal(header->name, "Subject")) {
+                                               unfold_line(header->body);
+                                               name = g_strconcat(header->body, ".txt", NULL);
+                                               subst_for_filename(name);
+                                       }
                                }
+                               procheader_header_array_destroy(headers);
                        }
-                       procheader_header_array_destroy(headers);
                }
-               fclose(fp);
+               if (fp != NULL)
+                       fclose(fp);
                if (name)
                        filename = g_path_get_basename(name);
                g_free(name);
@@ -1761,7 +1761,7 @@ check_new_file:
        if ((err = procmime_get_part(filename, partinfo)) < 0)
                alertpanel_error
                        (_("Couldn't save the part of multipart message: %s"), 
-                               strerror(-err));
+                               g_strerror(-err));
 
        tmp = g_filename_to_uri(filename, NULL, NULL);
        uriname = g_strconcat(tmp, "\r\n", NULL);
@@ -1850,7 +1850,7 @@ static gboolean mimeview_write_part(const gchar *filename,
        if ((err = procmime_get_part(filename, partinfo)) < 0) {
                alertpanel_error
                        (_("Couldn't save the part of multipart message: %s"), 
-                               strerror(-err));
+                               g_strerror(-err));
                return FALSE;
        }
 
@@ -2042,7 +2042,7 @@ void mimeview_launch(MimeView *mimeview, MimeInfo *partinfo)
        if ((err = procmime_get_part(filename, partinfo)) < 0)
                alertpanel_error
                        (_("Couldn't save the part of multipart message: %s"), 
-                               strerror(-err));
+                               g_strerror(-err));
        else
                mimeview_view_file(filename, partinfo, NULL, mimeview);
 
@@ -2078,7 +2078,7 @@ static void mimeview_open_part_with(MimeView *mimeview, MimeInfo *partinfo, gboo
        if ((err = procmime_get_part(filename, partinfo)) < 0) {
                alertpanel_error
                        (_("Couldn't save the part of multipart message: %s"), 
-                               strerror(-err));
+                               g_strerror(-err));
                g_free(filename);
                return;
        }
@@ -2190,7 +2190,7 @@ static void mimeview_send_to(MimeView *mimeview, MimeInfo *partinfo)
        } else
                alertpanel_error
                        (_("Couldn't save the part of multipart message: %s"), 
-                               strerror(-err));
+                               g_strerror(-err));
        g_free(filename);
 }
 
@@ -2411,9 +2411,6 @@ static void icon_list_append_icon (MimeView *mimeview, MimeInfo *mimeinfo)
 #ifdef GENERIC_UMPC
        GtkRequisition r;
 #endif
-#if !(GTK_CHECK_VERSION(2,12,0))
-       GtkTooltips *tips = mimeview->tooltips;
-#endif
        
        if (!prefs_common.show_inline_attachments && mimeinfo->id)
                return;
@@ -2659,22 +2656,17 @@ static void icon_list_toggle_by_mime_info (MimeView     *mimeview,
        
        children = gtk_container_get_children(GTK_CONTAINER(mimeview->icon_vbox));
        for (child = children; child != NULL; child = g_list_next(child)) {
+               gboolean *highlight = NULL;
+               GtkWidget *icon = gtk_bin_get_child(GTK_BIN(child->data));
+
                if (!GTK_IS_EVENT_BOX(child->data))
                        continue;
-               if(g_object_get_data(G_OBJECT(child->data),
-                                     "partinfo") == (gpointer)mimeinfo) {
-                       gboolean *highlight = NULL;
-                       GtkWidget *icon = gtk_bin_get_child(GTK_BIN(child->data));
-                       highlight = g_object_get_data(G_OBJECT(icon), "highlight");
-                       *highlight = TRUE;
-                       gtk_widget_queue_draw(icon);
-               } else {
-                       gint *highlight = NULL;
-                       GtkWidget *icon = gtk_bin_get_child(GTK_BIN(child->data));
-                       highlight = g_object_get_data(G_OBJECT(icon), "highlight");
-                       *highlight = FALSE;
-                       gtk_widget_queue_draw(icon);
-               }                        
+
+               highlight = g_object_get_data(G_OBJECT(icon), "highlight");
+               *highlight = (g_object_get_data(G_OBJECT(child->data),
+                                     "partinfo") == (gpointer)mimeinfo);
+
+               gtk_widget_queue_draw(icon);
        }
        g_list_free(children);
 }
@@ -2726,7 +2718,8 @@ static gint mime_toggle_button_cb(GtkWidget *button, GdkEventButton *event,
        return TRUE;
 }
 
-void mimeview_update (MimeView *mimeview) {
+void mimeview_update (MimeView *mimeview)
+{
        if (mimeview && mimeview->mimeinfo) {
                icon_list_clear(mimeview);
                icon_list_create(mimeview, mimeview->mimeinfo);