Use GLib's implementation of Base64 instead of our own.
[claws.git] / src / prefs_customheader.c
index 2afef7700d058d8299608c4197ab4ae1a2a7e2b7..a82e0ecc24292804ffa475bc3cec7176bedd598c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2012 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
@@ -19,6 +19,7 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
+#include "claws-features.h"
 #endif
 
 #include "defs.h"
@@ -45,7 +46,6 @@
 #include "utils.h"
 #include "gtkutils.h"
 #include "alertpanel.h"
-#include "base64.h"
 #include "filesel.h"
 #include "combobox.h"
 
@@ -233,7 +233,7 @@ static void prefs_custom_header_create(void)
                          0, 0, 0);
        gtk_widget_set_size_request (val_entry, 200, -1);
 
-       val_btn = gtk_button_new_with_label (_("From file..."));
+       val_btn = gtkut_get_browse_file_btn(_("Bro_wse"));
        gtk_widget_show (val_btn);
        gtk_table_attach (GTK_TABLE (table1), val_btn, 2, 3, 1, 2,
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
@@ -500,10 +500,6 @@ static void prefs_custom_header_list_view_set_row(PrefsAccount *ac)
        CustomHeader *ch;
        const gchar *entry_text;
        gchar *ch_str;
-       GtkListStore *store;
-
-       store = GTK_LIST_STORE(gtk_tree_view_get_model
-                               (GTK_TREE_VIEW(customhdr.list_view)));
 
        entry_text = gtk_entry_get_text(GTK_ENTRY(customhdr.hdr_entry));
        if (entry_text[0] == '\0') {
@@ -574,7 +570,7 @@ static void prefs_custom_header_val_from_file_cb(void)
                if (filename && is_file_exist(filename)) {
                        FILE *fp = NULL;
                        gint len;
-                       gchar inbuf[B64_LINE_SIZE], outbuf[B64_BUFFSIZE];
+                       gchar inbuf[B64_LINE_SIZE], *outbuf;
                        gchar *tmp = NULL;
                        gint w, h;
                        GdkPixbufFormat *format = gdk_pixbuf_get_file_info(
@@ -652,16 +648,18 @@ static void prefs_custom_header_val_from_file_cb(void)
                        while ((len = fread(inbuf, sizeof(gchar),
                                            B64_LINE_SIZE, fp))
                               == B64_LINE_SIZE) {
-                               base64_encode(outbuf, inbuf, B64_LINE_SIZE);
+                               outbuf = g_base64_encode(inbuf, B64_LINE_SIZE);
 
                                tmp = contents;
                                contents = g_strconcat(tmp?tmp:"",outbuf, NULL);
+                               g_free(outbuf);
                                g_free(tmp);
                        }
                        if (len > 0 && feof(fp)) {
                                tmp = contents;
-                               base64_encode(outbuf, inbuf, len);
+                               outbuf = g_base64_encode(inbuf, len);
                                contents = g_strconcat(tmp?tmp:"",outbuf, NULL);
+                               g_free(outbuf);
                                g_free(tmp);
                        }
                        fclose(fp);
@@ -778,7 +776,7 @@ static gboolean prefs_custom_header_key_pressed(GtkWidget *widget,
                                                GdkEventKey *event,
                                                gpointer data)
 {
-       if (event && event->keyval == GDK_Escape)
+       if (event && event->keyval == GDK_KEY_Escape)
                prefs_custom_header_cancel();
        return FALSE;
 }
@@ -917,29 +915,15 @@ static gboolean prefs_custom_header_selected(GtkTreeSelection *selector,
                pixbuf = gtk_image_get_pixbuf(preview);
                gtk_image_set_from_pixbuf (GTK_IMAGE(customhdr.preview), pixbuf);
                gtk_widget_show(customhdr.preview);
-#if GLIB_CHECK_VERSION(2,10,0)
                g_object_ref_sink (G_OBJECT(preview));
-#else
-               gtk_object_ref (G_OBJECT(preview));
-               gtk_object_sink (G_OBJECT(preview));
-#endif
        } 
 #if HAVE_LIBCOMPFACE
 else if (!strcmp2("X-Face", ch->name)) {
-               GdkColor color;
-               color.pixel = 0;
-               preview = GTK_IMAGE(xface_get_from_header(ch->value, 
-                                         &color, 
-                                         mainwindow_get_mainwindow()->window->window));        
+               preview = GTK_IMAGE(xface_get_from_header(ch->value));  
                pixbuf = gtk_image_get_pixbuf(preview);
                gtk_image_set_from_pixbuf (GTK_IMAGE(customhdr.preview), pixbuf);
                gtk_widget_show(customhdr.preview);
-#if GLIB_CHECK_VERSION(2,10,0)
                g_object_ref_sink (G_OBJECT(preview));
-#else
-               gtk_object_ref (G_OBJECT(preview));
-               gtk_object_sink (G_OBJECT(preview));
-#endif
        } 
 #endif
 else {