2005-10-20 [colin] 1.9.15cvs84
authorColin Leroy <colin@colino.net>
Thu, 20 Oct 2005 17:49:21 +0000 (17:49 +0000)
committerColin Leroy <colin@colino.net>
Thu, 20 Oct 2005 17:49:21 +0000 (17:49 +0000)
* configure.ac
* src/folderview.c
* src/headerview.c
* src/main.c
* src/prefs_common.c
* src/prefs_common.h
* src/prefs_message.c
* src/textview.c
* src/textview.h
* src/common/defs.h
* src/common/utils.c
* src/common/utils.h
* src/gtk/gtkutils.c
* src/gtk/gtkutils.h
Migrate config to .sylpheed-claws (Automatically)
Add a way to get the Xface in the TextView

16 files changed:
ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/common/defs.h
src/common/utils.c
src/common/utils.h
src/folderview.c
src/gtk/gtkutils.c
src/gtk/gtkutils.h
src/headerview.c
src/main.c
src/prefs_common.c
src/prefs_common.h
src/prefs_message.c
src/textview.c
src/textview.h

index b8246e870a67601493ee74559685e89818780716..6e6ffe44e248255156e609137bfb5e36712b1ed1 100644 (file)
@@ -1,3 +1,22 @@
+2005-10-20 [colin]     1.9.15cvs84
+
+       * configure.ac
+       * src/folderview.c
+       * src/headerview.c
+       * src/main.c
+       * src/prefs_common.c
+       * src/prefs_common.h
+       * src/prefs_message.c
+       * src/textview.c
+       * src/textview.h
+       * src/common/defs.h
+       * src/common/utils.c
+       * src/common/utils.h
+       * src/gtk/gtkutils.c
+       * src/gtk/gtkutils.h
+               Migrate config to .sylpheed-claws (Automatically)
+               Add a way to get the Xface in the TextView
+
 2005-10-20 [colin]     1.9.15cvs83
 
        * src/gtk/Makefile.am
index 3ce4601588ba97544ff4640700d261adc3813a67..44d4794665a63a9141abe9299235d47ece7bc62e 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.179.2.80 -r 1.179.2.81 src/imap.c;  cvs diff -u -r 1.1.4.23 -r 1.1.4.24 src/etpan/imap-thread.c;  ) > 1.9.15cvs81.patchset
 ( cvs diff -u -r 1.83.2.48 -r 1.83.2.49 src/mimeview.c;  ) > 1.9.15cvs82.patchset
 ( cvs diff -u -r 1.20.2.5 -r 1.20.2.6 src/gtk/Makefile.am;  cvs diff -u -r 1.4.2.18 -r 1.4.2.19 src/gtk/about.c;  diff -u /dev/null src/gtk/authors.h;  ) > 1.9.15cvs83.patchset
+( cvs diff -u -r 1.654.2.963 -r 1.654.2.964 configure.ac;  cvs diff -u -r 1.207.2.76 -r 1.207.2.77 src/folderview.c;  cvs diff -u -r 1.8.2.10 -r 1.8.2.11 src/headerview.c;  cvs diff -u -r 1.115.2.61 -r 1.115.2.62 src/main.c;  cvs diff -u -r 1.204.2.66 -r 1.204.2.67 src/prefs_common.c;  cvs diff -u -r 1.103.2.34 -r 1.103.2.35 src/prefs_common.h;  cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/prefs_message.c;  cvs diff -u -r 1.96.2.79 -r 1.96.2.80 src/textview.c;  cvs diff -u -r 1.12.2.8 -r 1.12.2.9 src/textview.h;  cvs diff -u -r 1.9.2.18 -r 1.9.2.19 src/common/defs.h;  cvs diff -u -r 1.36.2.46 -r 1.36.2.47 src/common/utils.c;  cvs diff -u -r 1.20.2.25 -r 1.20.2.26 src/common/utils.h;  cvs diff -u -r 1.5.2.15 -r 1.5.2.16 src/gtk/gtkutils.c;  cvs diff -u -r 1.4.2.13 -r 1.4.2.14 src/gtk/gtkutils.h;  ) > 1.9.15cvs84.patchset
index ed7957431f753f58494b2b0d1f78bc058e202194..2ae286450318874e83d7ab1b2bfe9e14dac5259e 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=15
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=83
+EXTRA_VERSION=84
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
@@ -343,10 +343,10 @@ AC_ARG_WITH(passcrypt-key, [  --with-passcrypt-key=KEY     Key used to encode pa
 AC_SUBST(PASSCRYPT_KEY, $with_passcrypt_key)
 
 dnl RC dir (will be default at a certain point in time)
-AC_ARG_WITH(config-dir,    [  --with-config-dir=RCDIR      Local configuration dir (default: .sylpheed-gtk2)],
-             ac_cv_with_config_dir="$withval", ac_cv_with_config_dir=".sylpheed-gtk2")
+AC_ARG_WITH(config-dir,    [  --with-config-dir=RCDIR      Local configuration dir (default: .sylpheed-claws)],
+             ac_cv_with_config_dir="$withval", ac_cv_with_config_dir=".sylpheed-claws")
 if test x"$ac_cv_with_config_dir" = x""; then
-       ac_cv_with_config_dir=".sylpheed-gtk2"
+       ac_cv_with_config_dir=".sylpheed-claws"
 fi 
 AC_DEFINE_UNQUOTED(CFG_RC_DIR, "$ac_cv_with_config_dir", Configuration directory)
 
index 77eee1f65b3bd12198e93215d0c1a58ecbe0e687..9d2e92e65b824883c85ae339755270aad2f18625 100644 (file)
@@ -44,6 +44,8 @@
 #define DRAFT_DIR              "draft"
 #define TRASH_DIR              "trash"
 #define RC_DIR                 CFG_RC_DIR
+#define OLD_GTK2_RC_DIR                ".sylpheed-gtk2"
+#define OLD_GTK1_RC_DIR                ".sylpheed"
 #define NEWS_CACHE_DIR         "newscache"
 #define IMAP_CACHE_DIR         "imapcache"
 #define MBOX_CACHE_DIR         "mboxcache"
index baf5873eb552c126453dd8cbb6ccf611ee1e2c1a..ec086a1cc145c070fd2d9da30dc508714a89239d 100644 (file)
@@ -4437,3 +4437,34 @@ gchar *mailcap_get_command_for_type(const gchar *type)
        result = mailcap_get_command_in_file("/etc/mailcap", type);
        return result;
 }
+
+gint copy_dir(const gchar *src, const gchar *dst)
+{
+       GDir *dir;
+       const gchar *name;
+       
+       if ((dir = g_dir_open(src, 0, NULL)) == NULL) {
+               g_warning("failed to open directory: %s\n", src);
+               return -1;
+       }
+
+       if (make_dir(dst) < 0)
+               return -1;
+       
+       while ((name = g_dir_read_name(dir)) != NULL) {
+               gchar *old_file, *new_file;
+               old_file = g_strconcat(src, G_DIR_SEPARATOR_S, name, NULL);
+               new_file = g_strconcat(dst, G_DIR_SEPARATOR_S, name, NULL);
+               debug_print("copying: %s -> %s\n", old_file, new_file);
+               if (g_file_test(old_file, G_FILE_TEST_IS_REGULAR)) {
+                       gint r = copy_file(old_file, new_file, TRUE);
+                       if (r < 0)
+                               return r;
+               } else if (g_file_test(old_file, G_FILE_TEST_IS_DIR)) {
+                       gint r = copy_dir(old_file, new_file);
+                       if (r < 0)
+                               return r;
+               }
+       }
+       return 0;
+}
index ebca23fbb3bc846a7b7daf5e71bf53812971073b..85247dc37776701606c105b0bdbdbf93773e2f20 100644 (file)
@@ -442,6 +442,8 @@ gint copy_file                      (const gchar    *src,
 gint move_file                 (const gchar    *src,
                                 const gchar    *dest,
                                 gboolean        overwrite);
+gint copy_dir                  (const gchar    *src,
+                                const gchar    *dest);
 gint copy_file_part_to_fp      (FILE           *fp,
                                 off_t           offset,
                                 size_t          length,
index db508ac478ecf0519adc991ebe3d8eceef5854eb..702980efc6b9042efa35af1d89ed869a7881399c 100644 (file)
@@ -947,29 +947,6 @@ static void folderview_scan_tree_func(Folder *folder, FolderItem *item,
        }
 }
 
-static GtkWidget *label_window_create(const gchar *str)
-{
-       GtkWidget *window;
-       GtkWidget *label;
-
-       window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-       gtk_widget_set_size_request(window, 380, 60);
-       gtk_container_set_border_width(GTK_CONTAINER(window), 8);
-       gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
-       gtk_window_set_title(GTK_WINDOW(window), str);
-       gtk_window_set_modal(GTK_WINDOW(window), TRUE);
-       gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
-       manage_window_set_transient(GTK_WINDOW(window));
-
-       label = gtk_label_new(str);
-       gtk_container_add(GTK_CONTAINER(window), label);
-       gtk_widget_show(label);
-
-       gtk_widget_show_now(window);
-
-       return window;
-}
-
 void folderview_rescan_tree(Folder *folder, gboolean rebuild)
 {
        GtkWidget *window;
index 9709fb6a2e64eb898e679feee1a35593d2003224..92e3dc7dfd4b23ecfeae1fcdbfd6e3a7fe8f453c 100644 (file)
 #include <stdarg.h>
 #include <sys/stat.h>
 
+#if HAVE_LIBCOMPFACE
+#  include <compface.h>
+#endif
+
 #if (HAVE_WCTYPE_H && HAVE_WCHAR_H)
 #  include <wchar.h>
 #  include <wctype.h>
@@ -50,6 +54,7 @@
 #include "menu.h"
 #include "prefs_account.h"
 #include "prefs_common.h"
+#include "manage_window.h"
 
 gboolean gtkut_get_font_size(GtkWidget *widget,
                             gint *width, gint *height)
@@ -692,6 +697,29 @@ void gtkut_widget_set_composer_icon(GtkWidget *widget)
        gdk_window_set_icon(widget->window, NULL, xpm, bmp);    
 }
 
+GtkWidget *label_window_create(const gchar *str)
+{
+       GtkWidget *window;
+       GtkWidget *label;
+
+       window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+       gtk_widget_set_size_request(window, 380, 60);
+       gtk_container_set_border_width(GTK_CONTAINER(window), 8);
+       gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
+       gtk_window_set_title(GTK_WINDOW(window), str);
+       gtk_window_set_modal(GTK_WINDOW(window), TRUE);
+       gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
+       manage_window_set_transient(GTK_WINDOW(window));
+
+       label = gtk_label_new(str);
+       gtk_container_add(GTK_CONTAINER(window), label);
+       gtk_widget_show(label);
+
+       gtk_widget_show_now(window);
+
+       return window;
+}
+
 GtkWidget *gtkut_account_menu_new(GList                        *ac_list,
                                  GCallback              callback,
                                  gpointer               data)
@@ -858,3 +886,75 @@ GtkWidget *gtkut_get_browse_directory_btn(const gchar *button_label)
 #endif
        return button;
 }
+
+#if HAVE_LIBCOMPFACE
+gint create_xpm_from_xface(gchar *xpm[], const gchar *xface)
+{
+       static gchar *bit_pattern[] = {
+               "....",
+               "...#",
+               "..#.",
+               "..##",
+               ".#..",
+               ".#.#",
+               ".##.",
+               ".###",
+               "#...",
+               "#..#",
+               "#.#.",
+               "#.##",
+               "##..",
+               "##.#",
+               "###.",
+               "####"
+       };
+
+       static gchar *xface_header = "48 48 2 1";
+       static gchar *xface_black  = "# c #000000";
+       static gchar *xface_white  = ". c #ffffff";
+
+       gint i, line = 0;
+       const guchar *p;
+       gchar buf[WIDTH * 4 + 1];  /* 4 = strlen("0x0000") */
+
+       p = xface;
+
+       strcpy(xpm[line++], xface_header);
+       strcpy(xpm[line++], xface_black);
+       strcpy(xpm[line++], xface_white);
+
+       for (i = 0; i < HEIGHT; i++) {
+               gint col;
+
+               buf[0] = '\0';
+     
+               for (col = 0; col < 3; col++) {
+                       gint figure;
+
+                       p += 2;  /* skip '0x' */
+
+                       for (figure = 0; figure < 4; figure++) {
+                               gint n = 0;
+
+                               if ('0' <= *p && *p <= '9') {
+                                       n = *p - '0';
+                               } else if ('a' <= *p && *p <= 'f') {
+                                       n = *p - 'a' + 10;
+                               } else if ('A' <= *p && *p <= 'F') {
+                                       n = *p - 'A' + 10;
+                               }
+
+                               strcat(buf, bit_pattern[n]);
+                               p++;  /* skip ',' */
+                       }
+
+                       p++;  /* skip '\n' */
+               }
+
+               strcpy(xpm[line++], buf);
+               p++;
+       }
+
+       return 0;
+}
+#endif
index ef306fb616a878f1f9c66a54594cacef9d45626a..ca979ded5415b1817ad56a8b6d15b19669bd7c32 100644 (file)
@@ -160,7 +160,7 @@ gboolean gtkut_text_buffer_find_backward(GtkTextBuffer              *buffer,
                                         GtkTextIter            *match_pos);
 
 gchar *gtkut_text_view_get_selection   (GtkTextView    *textview);
-
+GtkWidget *label_window_create(const gchar *str);
 void gtkut_window_popup                        (GtkWidget      *window);
 
 void gtkut_widget_get_uposition                (GtkWidget      *widget,
@@ -184,5 +184,7 @@ GtkWidget *gtkut_get_focused_child  (GtkContainer   *parent);
 
 GtkWidget *gtkut_get_browse_file_btn(const gchar *label);
 GtkWidget *gtkut_get_browse_directory_btn(const gchar *label);
-
+#if HAVE_LIBCOMPFACE
+gint create_xpm_from_xface(gchar *xpm[], const gchar *xface);
+#endif
 #endif /* __GTKUTILS_H__ */
index 770ce90a5d0cff01cfc1977731b98d9f59f7037d..a8998665ed4546dc441ea9c3964760742dc491f5 100644 (file)
@@ -62,8 +62,6 @@ static gchar *xpm_xface[XPM_XFACE_HEIGHT];
 
 static void headerview_show_xface      (HeaderView     *headerview,
                                         MsgInfo        *msginfo);
-static gint create_xpm_from_xface      (gchar          *xpm[],
-                                        const gchar    *xface);
 #endif
 
 HeaderView *headerview_create(void)
@@ -295,75 +293,3 @@ void headerview_destroy(HeaderView *headerview)
 {
        g_free(headerview);
 }
-
-#if HAVE_LIBCOMPFACE
-static gint create_xpm_from_xface(gchar *xpm[], const gchar *xface)
-{
-       static gchar *bit_pattern[] = {
-               "....",
-               "...#",
-               "..#.",
-               "..##",
-               ".#..",
-               ".#.#",
-               ".##.",
-               ".###",
-               "#...",
-               "#..#",
-               "#.#.",
-               "#.##",
-               "##..",
-               "##.#",
-               "###.",
-               "####"
-       };
-
-       static gchar *xface_header = "48 48 2 1";
-       static gchar *xface_black  = "# c #000000";
-       static gchar *xface_white  = ". c #ffffff";
-
-       gint i, line = 0;
-       const guchar *p;
-       gchar buf[WIDTH * 4 + 1];  /* 4 = strlen("0x0000") */
-
-       p = xface;
-
-       strcpy(xpm[line++], xface_header);
-       strcpy(xpm[line++], xface_black);
-       strcpy(xpm[line++], xface_white);
-
-       for (i = 0; i < HEIGHT; i++) {
-               gint col;
-
-               buf[0] = '\0';
-     
-               for (col = 0; col < 3; col++) {
-                       gint figure;
-
-                       p += 2;  /* skip '0x' */
-
-                       for (figure = 0; figure < 4; figure++) {
-                               gint n = 0;
-
-                               if ('0' <= *p && *p <= '9') {
-                                       n = *p - '0';
-                               } else if ('a' <= *p && *p <= 'f') {
-                                       n = *p - 'a' + 10;
-                               } else if ('A' <= *p && *p <= 'F') {
-                                       n = *p - 'A' + 10;
-                               }
-
-                               strcat(buf, bit_pattern[n]);
-                               p++;  /* skip ',' */
-                       }
-
-                       p++;  /* skip '\n' */
-               }
-
-               strcpy(xpm[line++], buf);
-               p++;
-       }
-
-       return 0;
-}
-#endif
index 4986c27dfcf4e777a47f1ede1d711e0b175c76f6..2584f3aaebb0f2cb972a659ceba62c34ffe4de1f 100644 (file)
@@ -246,6 +246,29 @@ gboolean defer_check(void *data)
        return FALSE;
 }
 
+static gboolean migrate_old_config(const gchar *old_cfg_dir, const gchar *new_cfg_dir)
+{
+       gchar *message = g_strdup_printf(_("Configuration for Sylpheed-Claws %s found.\n"
+                        "Do you want to migrate this configuration?"),
+                        !strcmp(old_cfg_dir, OLD_GTK1_RC_DIR)?
+                               _("1.0.5 or previous"):_("1.9.15 or previous"));
+       gint r = 0;
+       GtkWidget *window = NULL;
+       if (alertpanel(_("Migration of configuration"),
+                      message,
+                      GTK_STOCK_YES, GTK_STOCK_NO, NULL) != G_ALERTDEFAULT)
+               return FALSE;
+       
+       window = label_window_create(_("Copying configuration..."));
+       GTK_EVENTS_FLUSH();
+       r = copy_dir(old_cfg_dir, new_cfg_dir);
+       gtk_widget_destroy(window);
+       if (r != 0) {
+               alertpanel_error(_("Migration failed!"));
+       }
+       return (r == 0);
+}
+
 int main(int argc, char *argv[])
 {
        gchar *userrc;
@@ -316,6 +339,18 @@ int main(int argc, char *argv[])
                             G_DIR_SEPARATOR_S, "gtkrc-2.0", NULL);
        gtk_rc_parse(userrc);
        g_free(userrc);
+
+       CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
+       if (!is_dir_exist(RC_DIR)) {
+               gboolean r = FALSE;
+               if (is_dir_exist(OLD_GTK2_RC_DIR))
+                       r = migrate_old_config(OLD_GTK2_RC_DIR, RC_DIR);
+               else if (is_dir_exist(OLD_GTK1_RC_DIR))
+                       r = migrate_old_config(OLD_GTK1_RC_DIR, RC_DIR);
+               if (r == FALSE && !is_dir_exist(RC_DIR) && make_dir(RC_DIR) < 0)
+                       exit(1);
+       }
+
        userrc = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "gtkrc-2.0", NULL);
        gtk_rc_parse(userrc);
        g_free(userrc);
@@ -328,10 +363,6 @@ int main(int argc, char *argv[])
                                       "gtk-can-change-accels",
                                       (glong)TRUE, "XProperty");
 
-       CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
-
-       MAKE_DIR_IF_NOT_EXIST(RC_DIR);
-
        CHDIR_RETURN_VAL_IF_FAIL(get_rc_dir(), 1);
 
        MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir());
index 9625d26b77258563e5c0be41eea4766d7ce023c9..345ff7a8e06d7704b46daf69229a09f58498fc97 100644 (file)
@@ -442,6 +442,8 @@ static PrefParam param[] = {
         P_BOOL, NULL, NULL, NULL},
        {"display_header", "TRUE", &prefs_common.display_header, P_BOOL,
         NULL, NULL, NULL},
+       {"display_xface", "TRUE", &prefs_common.display_xface,
+        P_BOOL, NULL, NULL, NULL},
        {"render_html", "TRUE", &prefs_common.render_html, P_BOOL,
         NULL, NULL, NULL},
        {"line_space", "2", &prefs_common.line_space, P_INT,
index 17505adee32a087a0405a1cfb7a1c3260383ea9b..37d1bd83edf79773674f5b0ab320ecba1dc3a869 100644 (file)
@@ -239,6 +239,7 @@ struct _PrefsCommon
        gboolean conv_mb_alnum;
        gboolean display_header_pane;
        gboolean display_header;
+       gboolean display_xface;
        gint line_space;
        gboolean render_html;
        gboolean textview_cursor_visible;
index fa26e1fd2a680ef999b14bbc2b33e2f6c42b6245..824ecf23c5fca57e2ca72246e70aa39802161f63 100644 (file)
@@ -49,6 +49,7 @@ typedef struct _MessagePage
        GtkWidget *chkbtn_mbalnum;
        GtkWidget *chkbtn_disphdrpane;
        GtkWidget *chkbtn_disphdr;
+       GtkWidget *chkbtn_dispxface;
        GtkWidget *chkbtn_html;
        GtkWidget *spinbtn_linespc;
 
@@ -59,6 +60,16 @@ typedef struct _MessagePage
        GtkWidget *chkbtn_attach_desc;
 } MessagePage;
 
+static void disphdr_pane_toggled(GtkToggleButton *toggle_btn, GtkWidget *widget)
+{
+       gboolean is_active;
+
+       is_active = gtk_toggle_button_get_active(toggle_btn);
+
+       gtk_widget_set_sensitive(widget, !is_active);
+}
+
+
 void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window, 
                                  gpointer data)
 {
@@ -71,6 +82,7 @@ void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
        GtkWidget *chkbtn_mbalnum;
        GtkWidget *chkbtn_disphdrpane;
        GtkWidget *chkbtn_disphdr;
+       GtkWidget *chkbtn_dispxface;
        GtkWidget *button_edit_disphdr;
        GtkWidget *chkbtn_html;
        GtkWidget *hbox_linespc;
@@ -107,6 +119,16 @@ void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
        PACK_CHECK_BUTTON(vbox2, chkbtn_disphdrpane,
                          _("Display header pane above message view"));
 
+#if HAVE_LIBCOMPFACE
+       PACK_CHECK_BUTTON(vbox2, chkbtn_dispxface,
+                         _("Display X-Face in message view"));
+#endif
+       gtk_widget_set_sensitive(chkbtn_dispxface, 
+               !prefs_common.display_header_pane);
+       
+       g_signal_connect(G_OBJECT(chkbtn_disphdrpane), "toggled",
+                        G_CALLBACK(disphdr_pane_toggled), chkbtn_dispxface);
+
        hbox1 = gtk_hbox_new (FALSE, 8);
        gtk_widget_show (hbox1);
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
@@ -206,6 +228,8 @@ void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
                prefs_common.conv_mb_alnum);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_disphdrpane),
                prefs_common.display_header_pane);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_dispxface),
+               prefs_common.display_xface);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_disphdr),
                prefs_common.display_header);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_html),
@@ -224,6 +248,7 @@ void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
        prefs_message->window = GTK_WIDGET(window);
        prefs_message->chkbtn_mbalnum = chkbtn_mbalnum;
        prefs_message->chkbtn_disphdrpane = chkbtn_disphdrpane;
+       prefs_message->chkbtn_dispxface = chkbtn_dispxface;
        prefs_message->chkbtn_disphdr = chkbtn_disphdr;
        prefs_message->chkbtn_html = chkbtn_html;
        prefs_message->spinbtn_linespc = spinbtn_linespc;
@@ -243,6 +268,8 @@ void prefs_message_save(PrefsPage *_page)
                GTK_TOGGLE_BUTTON(page->chkbtn_mbalnum));
        prefs_common.display_header_pane = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->chkbtn_disphdrpane));
+       prefs_common.display_xface = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->chkbtn_dispxface));
        prefs_common.display_header = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->chkbtn_disphdr));
        prefs_common.render_html = gtk_toggle_button_get_active(
index 5f2d6a7bc5241648b9cb2d556ef5ab1570c4fbe0..cce2489b75ba5bd32b46d342256ad67639cc3ae5 100644 (file)
 #include <ctype.h>
 #include <string.h>
 #include <stdlib.h>
+#if HAVE_LIBCOMPFACE
+#  include <compface.h>
+#endif
+
+#if HAVE_LIBCOMPFACE
+#define XPM_XFACE_HEIGHT       (HEIGHT + 3)  /* 3 = 1 header + 2 colors */
+#endif
 
 #include "main.h"
 #include "summaryview.h"
@@ -231,6 +238,19 @@ static GtkItemFactoryEntry textview_file_popup_entries[] =
        {N_("/_Save image..."),         NULL, save_file_cb, 0, NULL},
 };
 
+static void scrolled_cb (GtkAdjustment *adj, TextView *textview)
+{
+#if HAVE_LIBCOMPFACE
+       if (textview->image) {
+               gint x, y;
+               gtk_text_view_buffer_to_window_coords(
+                       GTK_TEXT_VIEW(textview->text),
+                       GTK_TEXT_WINDOW_RIGHT, 5, 5, &x, &y);
+               gtk_text_view_move_child(GTK_TEXT_VIEW(textview->text), 
+                       textview->image, 5, y);
+       }
+#endif
+}
 
 TextView *textview_create(void)
 {
@@ -242,6 +262,7 @@ TextView *textview_create(void)
        GtkClipboard *clipboard;
        GtkItemFactory *link_popupfactory, *mail_popupfactory, *file_popupfactory;
        GtkWidget *link_popupmenu, *mail_popupmenu, *file_popupmenu;
+       GtkAdjustment *adj;
        gint n_entries;
 
        debug_print("Creating text view...\n");
@@ -284,6 +305,10 @@ TextView *textview_create(void)
                         G_CALLBACK(textview_leave_notify), textview);
        g_signal_connect(G_OBJECT(text), "visibility-notify-event",
                         G_CALLBACK(textview_visibility_notify), textview);
+       adj = gtk_scrolled_window_get_vadjustment(
+               GTK_SCROLLED_WINDOW(scrolledwin));
+       g_signal_connect(G_OBJECT(adj), "value-changed",
+                        G_CALLBACK(scrolled_cb), textview);
 
        gtk_widget_show(scrolledwin);
 
@@ -1257,6 +1282,75 @@ static GPtrArray *textview_scan_header(TextView *textview, FILE *fp)
        return sorted_headers;
 }
 
+#if HAVE_LIBCOMPFACE
+static void textview_show_xface(TextView *textview)
+{
+       gchar xface[2048];
+       MsgInfo *msginfo = textview->messageview->msginfo;
+       static gchar *xpm_xface[XPM_XFACE_HEIGHT];
+       static gboolean xpm_xface_init = TRUE;
+       GdkPixmap *pixmap;
+       GdkBitmap *mask;
+       GtkTextView *text = GTK_TEXT_VIEW(textview->text);
+       
+       gtk_text_view_set_border_window_size(text, GTK_TEXT_WINDOW_RIGHT, 0);
+
+       if (prefs_common.display_header_pane
+       ||  !prefs_common.display_xface)
+               goto bail;
+       
+       if (!msginfo)
+               goto bail;
+
+       if (!msginfo->xface || strlen(msginfo->xface) < 5) {
+               goto bail;
+       }
+
+       strncpy(xface, msginfo->xface, sizeof(xface));
+
+       if (uncompface(xface) < 0) {
+               g_warning("uncompface failed\n");
+               goto bail;
+       }
+
+       if (xpm_xface_init) {
+               gint i;
+
+               for (i = 0; i < XPM_XFACE_HEIGHT; i++) {
+                       xpm_xface[i] = g_malloc(WIDTH + 1);
+                       *xpm_xface[i] = '\0';
+               }
+               xpm_xface_init = FALSE;
+       }
+
+       create_xpm_from_xface(xpm_xface, xface);
+
+       pixmap = gdk_pixmap_create_from_xpm_d
+               (textview->text->window, &mask, 
+                &textview->text->style->white, xpm_xface);
+       
+       gtk_text_view_set_border_window_size(text, GTK_TEXT_WINDOW_RIGHT, 
+               WIDTH+10);
+
+       if (textview->image) 
+               gtk_widget_destroy(textview->image);
+       
+       textview->image = gtk_image_new_from_pixmap(pixmap, mask);
+       gtk_widget_show(textview->image);
+       gtk_text_view_add_child_in_window(text, textview->image, 
+               GTK_TEXT_WINDOW_RIGHT, 5, 5);
+
+       gtk_widget_show_all(textview->text);
+       
+       return;
+bail:
+       if (textview->image) 
+               gtk_widget_destroy(textview->image);
+       textview->image = NULL;
+       
+}
+#endif
+
 static void textview_show_header(TextView *textview, GPtrArray *headers)
 {
        GtkTextView *text = GTK_TEXT_VIEW(textview->text);
@@ -1302,6 +1396,9 @@ static void textview_show_header(TextView *textview, GPtrArray *headers)
                gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "\n", 1,
                                                         "header", NULL);
        }
+#if HAVE_LIBCOMPFACE
+       textview_show_xface(textview);
+#endif
 }
 
 gboolean textview_search_string(TextView *textview, const gchar *str,
index 16441ab1a732fe47803e4f8ef372d9f4af7659ee..bd1193618a9e5fda95ea38fd149c406c186e32ab 100644 (file)
@@ -61,6 +61,7 @@ struct _TextView
        RemoteURI *uri_hover;
        GtkTextIter uri_hover_start_iter;
        GtkTextIter uri_hover_end_iter;
+       GtkWidget *image;
 };
 
 TextView *textview_create              (void);