2006-02-06 [colin] 2.0.0cvs20
authorColin Leroy <colin@colino.net>
Mon, 6 Feb 2006 17:56:35 +0000 (17:56 +0000)
committerColin Leroy <colin@colino.net>
Mon, 6 Feb 2006 17:56:35 +0000 (17:56 +0000)
* src/addressbook.c
Use internal mime-type instead of text/plain for d'n'd
* src/compose.c
Allow attaching files from mimeview's icon list via d'n'd
* src/folderview.c
* src/folderview.h
Use internal mime-type instead of text/plain for d'n'd
Don't try to selected opened folder if none is
Factorize d'n'd from other apps code
* src/headerview.c
* src/textview.c
* src/gtk/gtkutils.c
* src/gtk/gtkutils.h
Factorize Face/X-Face stuff
* src/mimeview.c
Fix d'n'd to other apps
* src/prefs_message.c
Let the XFace pref be usable without libcompface as it also
applies to Face
* src/summaryview.c
Fix d'n'd to other apps
Factorize d'n'd from other apps code

14 files changed:
ChangeLog
PATCHSETS
configure.ac
src/addressbook.c
src/compose.c
src/folderview.c
src/folderview.h
src/gtk/gtkutils.c
src/gtk/gtkutils.h
src/headerview.c
src/mimeview.c
src/prefs_message.c
src/summaryview.c
src/textview.c

index 8e4b379..8b306e6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2006-02-06 [colin]     2.0.0cvs20
+
+       * src/addressbook.c
+               Use internal mime-type instead of text/plain for d'n'd
+       * src/compose.c
+               Allow attaching files from mimeview's icon list via d'n'd
+       * src/folderview.c
+       * src/folderview.h
+               Use internal mime-type instead of text/plain for d'n'd
+               Don't try to selected opened folder if none is
+               Factorize d'n'd from other apps code
+       * src/headerview.c
+       * src/textview.c
+       * src/gtk/gtkutils.c
+       * src/gtk/gtkutils.h
+               Factorize Face/X-Face stuff
+       * src/mimeview.c
+               Fix d'n'd to other apps
+       * src/prefs_message.c
+               Let the XFace pref be usable without libcompface as it also
+               applies to Face
+       * src/summaryview.c
+               Fix d'n'd to other apps
+               Factorize d'n'd from other apps code
+
 2006-02-06 [wwp]       2.0.0cvs19
 
        * po/it.po
index 277db4d..2ab8084 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.179.2.90 -r 1.179.2.91 src/imap.c;  cvs diff -u -r 1.1.4.26 -r 1.1.4.27 src/etpan/imap-thread.c;  ) > 2.0.0cvs17.patchset
 ( cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/gtk/icon_legend.c;  ) > 2.0.0cvs18.patchset
 ( cvs diff -u -r 1.34.2.16 -r 1.34.2.17 po/it.po;  ) > 2.0.0cvs19.patchset
+( cvs diff -u -r 1.60.2.47 -r 1.60.2.48 src/addressbook.c;  cvs diff -u -r 1.382.2.234 -r 1.382.2.235 src/compose.c;  cvs diff -u -r 1.207.2.87 -r 1.207.2.88 src/folderview.c;  cvs diff -u -r 1.20.2.10 -r 1.20.2.11 src/folderview.h;  cvs diff -u -r 1.8.2.14 -r 1.8.2.15 src/headerview.c;  cvs diff -u -r 1.96.2.93 -r 1.96.2.94 src/textview.c;  cvs diff -u -r 1.83.2.63 -r 1.83.2.64 src/mimeview.c;  cvs diff -u -r 1.1.2.10 -r 1.1.2.11 src/prefs_message.c;  cvs diff -u -r 1.395.2.163 -r 1.395.2.164 src/summaryview.c;  cvs diff -u -r 1.5.2.19 -r 1.5.2.20 src/gtk/gtkutils.c;  cvs diff -u -r 1.4.2.16 -r 1.4.2.17 src/gtk/gtkutils.h;  ) > 2.0.0cvs20.patchset
index 8551ad9..0d2addf 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=19
+EXTRA_VERSION=20
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index c18707e..5924fea 100644 (file)
@@ -393,7 +393,7 @@ static void addressbook_list_menu_setup( void );
 
 static GtkTargetEntry addressbook_drag_types[] =
 {
-       {"text/plain", GTK_TARGET_SAME_APP, TARGET_DUMMY}
+       {"sylpheed-claws/internal", GTK_TARGET_SAME_APP, TARGET_DUMMY}
 };
 
 static GtkTargetList *addressbook_target_list = NULL;
index ee5ce14..ff82178 100644 (file)
@@ -7929,7 +7929,8 @@ static void compose_attach_drag_received_cb (GtkWidget            *widget,
 
        if (gdk_atom_name(data->type) && 
            !strcmp(gdk_atom_name(data->type), "text/uri-list")
-           && gtk_drag_get_source_widget(context) == NULL) {
+           && gtk_drag_get_source_widget(context) != 
+               mainwindow_get_mainwindow()->summaryview->ctree) {
                list = uri_list_extract_filenames((const gchar *)data->data);
                for (tmp = list; tmp != NULL; tmp = tmp->next)
                        compose_attach_append
index 6eaf6bd..4297f2e 100644 (file)
@@ -292,7 +292,7 @@ static GtkItemFactoryEntry folder_view_trash_popup_entries[] = {
 
 GtkTargetEntry folderview_drag_types[] =
 {
-       {"text/plain", GTK_TARGET_SAME_APP, TARGET_DUMMY},
+       {"sylpheed-claws/internal", GTK_TARGET_SAME_APP, TARGET_DUMMY},
        {"text/uri-list", 0, TARGET_MAIL_URI_LIST}
 };
 
@@ -2491,7 +2491,8 @@ static gboolean folderview_drag_motion_cb(GtkWidget      *widget,
                                        (context->actions == GDK_ACTION_COPY ?
                                        GDK_ACTION_COPY : GDK_ACTION_MOVE) , time);
        } else {
-               gtk_ctree_select(GTK_CTREE(widget), folderview->opened);
+               if (folderview->opened)
+                       gtk_ctree_select(GTK_CTREE(widget), folderview->opened);
                gdk_drag_status(context, 0, time);
        }
 
@@ -2512,6 +2513,45 @@ static void free_info (gpointer stuff, gpointer data)
        g_free(stuff);
 }
 
+void folderview_finish_dnd(const gchar *data, GdkDragContext *drag_context,
+                          guint time, FolderItem *item)
+{
+       GList *list, *tmp;
+       GSList *msglist = NULL;
+       list = uri_list_extract_filenames(data);
+       if (!(item && item->folder && folder_item_parent(item) != NULL
+                   && FOLDER_CLASS(item->folder)->add_msg != NULL))
+       {
+               gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
+               return;
+       }       
+       if (!list) {
+               gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
+               return;
+       }
+       for (tmp = list; tmp != NULL; tmp = tmp->next) {
+               MsgFileInfo *info = NULL;
+
+               if (file_is_email((gchar *)tmp->data)) {
+                       info = g_new0(MsgFileInfo, 1);
+                       info->msginfo = NULL;
+                       info->file = (gchar *)tmp->data;
+                       msglist = g_slist_prepend(msglist, info);
+               }
+       }
+       if (msglist) {
+               msglist = g_slist_reverse(msglist);
+               folder_item_add_msgs(item, msglist, FALSE);
+               g_slist_foreach(msglist, free_info, NULL);
+               g_slist_free(msglist);
+               gtk_drag_finish(drag_context, TRUE, FALSE, time);
+       } else {
+               gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
+       }
+       list_free_strings(list);
+       g_list_free(list);
+}
+
 static void folderview_drag_received_cb(GtkWidget        *widget,
                                        GdkDragContext   *drag_context,
                                        gint              x,
@@ -2593,8 +2633,6 @@ static void folderview_drag_received_cb(GtkWidget        *widget,
                }
                folderview->nodes_to_recollapse = NULL;
        } else if (info == TARGET_MAIL_URI_LIST) {
-               GList *list, *tmp;
-               GSList *msglist = NULL;
                if (gtk_clist_get_selection_info
                        (GTK_CLIST(widget), x - 24, y - 24, &row, &column) == 0)
                        return;
@@ -2609,32 +2647,7 @@ static void folderview_drag_received_cb(GtkWidget        *widget,
                        gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
                        return;
                }
-               list = uri_list_extract_filenames((const gchar *)data->data);
-               if (!list) {
-                       gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
-                       return;
-               }
-               for (tmp = list; tmp != NULL; tmp = tmp->next) {
-                       MsgFileInfo *info = NULL;
-                       
-                       if (file_is_email((gchar *)tmp->data)) {
-                               info = g_new0(MsgFileInfo, 1);
-                               info->msginfo = NULL;
-                               info->file = (gchar *)tmp->data;
-                               msglist = g_slist_prepend(msglist, info);
-                       }
-               }
-               if (msglist) {
-                       msglist = g_slist_reverse(msglist);
-                       folder_item_add_msgs(item, msglist, FALSE);
-                       g_slist_foreach(msglist, free_info, NULL);
-                       g_slist_free(msglist);
-                       gtk_drag_finish(drag_context, TRUE, FALSE, time);
-               } else {
-                       gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
-               }
-               list_free_strings(list);
-               g_list_free(list);
+               folderview_finish_dnd(data->data, drag_context, time, item);
        }
 }
 
index a23068b..dd97afd 100644 (file)
@@ -132,5 +132,9 @@ void folderview_unregister_popup    (FolderViewPopup        *fpopup);
 void folderview_update_search_icon     (FolderItem             *item,  
                                         gboolean                matches);
 void folderview_set_column_order       (FolderView             *folderview);
+void folderview_finish_dnd             (const gchar            *data, 
+                                        GdkDragContext         *drag_context,
+                                        guint                   time, 
+                                        FolderItem             *item);
 
 #endif /* __FOLDERVIEW_H__ */
index 3deec74..cbd81c7 100644 (file)
 #  include <compface.h>
 #endif
 
+#if HAVE_LIBCOMPFACE
+#define XPM_XFACE_HEIGHT       (HEIGHT + 3)  /* 3 = 1 header + 2 colors */
+#endif
+
 #if (HAVE_WCTYPE_H && HAVE_WCHAR_H)
 #  include <wchar.h>
 #  include <wctype.h>
@@ -55,6 +59,7 @@
 #include "prefs_account.h"
 #include "prefs_common.h"
 #include "manage_window.h"
+#include "base64.h"
 
 gboolean gtkut_get_font_size(GtkWidget *widget,
                             gint *width, gint *height)
@@ -983,3 +988,77 @@ gboolean get_tag_range(GtkTextIter *iter,
 
        return TRUE;
 }
+
+#if HAVE_LIBCOMPFACE
+GtkWidget *xface_get_from_header(const gchar *o_xface, GdkColor *background,
+                                GdkWindow *window)
+{
+       static gchar *xpm_xface[XPM_XFACE_HEIGHT];
+       static gboolean xpm_xface_init = TRUE;
+       GdkPixmap *pixmap;
+       GdkBitmap *mask;
+       gchar xface[2048];
+       strncpy(xface, o_xface, sizeof(xface));
+
+       if (uncompface(xface) < 0) {
+               g_warning("uncompface failed\n");
+               return NULL;
+       }
+
+       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
+               (window, &mask, 
+                background, xpm_xface);
+       return gtk_image_new_from_pixmap(pixmap, mask);
+}
+#endif
+
+GtkWidget *face_get_from_header(const gchar *o_face)
+{
+       gchar face[2048];
+       gchar face_png[2048];
+       gint pngsize;
+       GdkPixbuf *pixbuf;
+       GError *error = NULL;
+       GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
+       GtkWidget *image;
+       
+       strncpy2(face, o_face, sizeof(face));
+
+       unfold_line(face); /* strip all whitespace and linebreaks */
+       remove_space(face);
+
+       pngsize = base64_decode(face_png, face, strlen(face));
+
+       if (!gdk_pixbuf_loader_write (loader, face_png, pngsize, &error) ||
+           !gdk_pixbuf_loader_close (loader, &error)) {
+               g_warning("loading face failed\n");
+               g_object_unref(loader);
+               return NULL;
+       }
+
+       pixbuf = g_object_ref(gdk_pixbuf_loader_get_pixbuf(loader));
+
+       g_object_unref(loader);
+
+       if ((gdk_pixbuf_get_width(pixbuf) != 48) || (gdk_pixbuf_get_height(pixbuf) != 48)) {
+               g_object_unref(pixbuf);
+               g_warning("wrong_size");
+               return NULL;
+       }
+
+       image = gtk_image_new_from_pixbuf(pixbuf);
+       g_object_unref(pixbuf);
+       return image;
+}
index fddd7fb..fe10d2d 100644 (file)
@@ -186,9 +186,13 @@ 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);
+GtkWidget *xface_get_from_header(const gchar *o_xface, GdkColor *background,
+                                GdkWindow *window);
 #endif
 gboolean get_tag_range(GtkTextIter *iter,
                                       GtkTextTag *tag,
                                       GtkTextIter *start_iter,
                                       GtkTextIter *end_iter);
+
+GtkWidget *face_get_from_header(const gchar *o_face);
 #endif /* __GTKUTILS_H__ */
index c1c1cea..f9dbdca 100644 (file)
@@ -228,10 +228,8 @@ void headerview_show(HeaderView *headerview, MsgInfo *msginfo)
 #if HAVE_LIBCOMPFACE
 static void headerview_show_xface(HeaderView *headerview, MsgInfo *msginfo)
 {
-       gchar xface[2048];
-       GdkPixmap *pixmap;
-       GdkBitmap *mask;
        GtkWidget *hbox = headerview->hbox;
+       GtkWidget *image;
 
        if (!msginfo->xface || strlen(msginfo->xface) < 5) {
                if (headerview->image &&
@@ -243,44 +241,28 @@ static void headerview_show_xface(HeaderView *headerview, MsgInfo *msginfo)
        }
        if (!GTK_WIDGET_VISIBLE(headerview->hbox)) return;
 
-       strncpy(xface, msginfo->xface, sizeof(xface));
-
-       if (uncompface(xface) < 0) {
-               g_warning("uncompface failed\n");
-               if (headerview->image)
-                       gtk_widget_hide(headerview->image);
-               return;
+       if (headerview->image) {
+               gtk_widget_destroy(headerview->image);
+               headerview->image = NULL;
        }
+       
 
-       create_xpm_from_xface(xpm_xface, xface);
-
-       pixmap = gdk_pixmap_create_from_xpm_d
-               (hbox->window, &mask, &hbox->style->white, xpm_xface);
-
-       if (!headerview->image) {
-               GtkWidget *image;
+       image = xface_get_from_header(msginfo->xface, &hbox->style->white,
+                               hbox->window);
 
-               image = gtk_image_new_from_pixmap(pixmap, mask);
+       if (image) {
                gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
                gtk_widget_show(image);
-               headerview->image = image;
-       } else {
-               gtk_image_set_from_pixmap(GTK_IMAGE(headerview->image), pixmap, mask);
-               gtk_widget_show(headerview->image);
        }
 
-       g_object_unref(pixmap);
+       headerview->image = image;
 }
 #endif
 
 static gint headerview_show_face (HeaderView *headerview, MsgInfo *msginfo)
 {
-       gchar face[2048];
-       gchar face_png[2048];
-       gint pngsize;
        GtkWidget *hbox = headerview->hbox;
-       GdkPixbuf *pixbuf;
-       GError *error = NULL;
+       GtkWidget *image;
 
        if (!msginfo->face) {
                if (headerview->image &&
@@ -292,47 +274,24 @@ static gint headerview_show_face (HeaderView *headerview, MsgInfo *msginfo)
        }
        if (!GTK_WIDGET_VISIBLE(headerview->hbox)) return -1;
 
-       strncpy2(face, msginfo->face, sizeof(face));
-
-       unfold_line(face); /* strip all whitespace and linebreaks */
-       remove_space(face);
-
-       pngsize = base64_decode(face_png, face, strlen(face));
-
-       GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
-       if (!gdk_pixbuf_loader_write (loader, face_png, pngsize, &error) ||
-           !gdk_pixbuf_loader_close (loader, &error)) {
-               g_warning("loading face failed\n");
-               g_object_unref(loader);
-               if (headerview->image)
-                       gtk_widget_hide(headerview->image);
-               return;
-       }
-
-       pixbuf = g_object_ref(gdk_pixbuf_loader_get_pixbuf(loader));
-
-       g_object_unref(loader);
-
-       if ((gdk_pixbuf_get_width(pixbuf) != 48) || (gdk_pixbuf_get_height(pixbuf) != 48)) {
-               g_object_unref(pixbuf);
-               return -1;
+       if (headerview->image) {
+               gtk_widget_destroy(headerview->image);
+               headerview->image = NULL;
        }
+       
 
-       if (!headerview->image) {
-               GtkWidget *image;
+       image = face_get_from_header(msginfo->face);
 
-               image = gtk_image_new_from_pixbuf(pixbuf);
+       if (image) {
                gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
                gtk_widget_show(image);
-               headerview->image = image;
-       } else {
-               gtk_image_set_from_pixbuf(GTK_IMAGE(headerview->image), pixbuf);
-               gtk_widget_show(headerview->image);
        }
 
-       g_object_unref(pixbuf);
-
-       return 0;
+       headerview->image = image;
+       if (image == NULL)
+               return -1;
+       else 
+               return 0;
 }
 
 void headerview_clear(HeaderView *headerview)
index 321e8f2..97509ad 100644 (file)
@@ -1318,7 +1318,7 @@ static void mimeview_drag_data_get(GtkWidget          *widget,
        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));
index 51a0dea..0c51c58 100644 (file)
@@ -48,9 +48,8 @@ typedef struct _MessagePage
 
        GtkWidget *chkbtn_disphdrpane;
        GtkWidget *chkbtn_disphdr;
-#if HAVE_LIBCOMPFACE
        GtkWidget *chkbtn_dispxface;
-#endif
+
        GtkWidget *chkbtn_html;
        GtkWidget *spinbtn_linespc;
 
@@ -61,7 +60,6 @@ typedef struct _MessagePage
        GtkWidget *chkbtn_attach_desc;
 } MessagePage;
 
-#if HAVE_LIBCOMPFACE
 static void disphdr_pane_toggled(GtkToggleButton *toggle_btn, GtkWidget *widget)
 {
        gboolean is_active;
@@ -70,7 +68,6 @@ static void disphdr_pane_toggled(GtkToggleButton *toggle_btn, GtkWidget *widget)
 
        gtk_widget_set_sensitive(widget, !is_active);
 }
-#endif
 
 void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window, 
                                  gpointer data)
@@ -82,9 +79,8 @@ void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
        GtkWidget *hbox1;
        GtkWidget *chkbtn_disphdrpane;
        GtkWidget *chkbtn_disphdr;
-#if HAVE_LIBCOMPFACE
        GtkWidget *chkbtn_dispxface;
-#endif
+
        GtkWidget *button_edit_disphdr;
        GtkWidget *chkbtn_html;
        GtkWidget *hbox_linespc;
@@ -116,14 +112,17 @@ void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
 
 #if HAVE_LIBCOMPFACE
        PACK_CHECK_BUTTON(vbox2, chkbtn_dispxface,
-                         _("Display X-Face in message view"));
+                         _("Display (X-)Face in message view"));
+#else
+       PACK_CHECK_BUTTON(vbox2, chkbtn_dispxface,
+                         _("Display 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);
-#endif
 
        hbox1 = gtk_hbox_new (FALSE, 8);
        gtk_widget_show (hbox1);
@@ -216,10 +215,10 @@ void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
 
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_disphdrpane),
                prefs_common.display_header_pane);
-#if HAVE_LIBCOMPFACE
+
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_dispxface),
                prefs_common.display_xface);
-#endif
+
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_disphdr),
                prefs_common.display_header);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_html),
@@ -237,9 +236,7 @@ void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
                
        prefs_message->window = GTK_WIDGET(window);
        prefs_message->chkbtn_disphdrpane = chkbtn_disphdrpane;
-#if HAVE_LIBCOMPFACE
        prefs_message->chkbtn_dispxface = chkbtn_dispxface;
-#endif
        prefs_message->chkbtn_disphdr = chkbtn_disphdr;
        prefs_message->chkbtn_html = chkbtn_html;
        prefs_message->spinbtn_linespc = spinbtn_linespc;
@@ -257,10 +254,8 @@ void prefs_message_save(PrefsPage *_page)
 
        prefs_common.display_header_pane = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->chkbtn_disphdrpane));
-#if HAVE_LIBCOMPFACE
        prefs_common.display_xface = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->chkbtn_dispxface));
-#endif
        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 6ab8f82..6916a83 100644 (file)
@@ -344,6 +344,12 @@ static void summary_drag_data_received(GtkWidget        *widget,
                                        guint             info,
                                        guint             time,
                                        SummaryView       *summaryview);
+static gboolean summary_drag_motion_cb(GtkWidget      *widget,
+                                         GdkDragContext *context,
+                                         gint            x,
+                                         gint            y,
+                                         guint           time,
+                                         SummaryView    *summaryview);
 
 /* custom compare functions for sorting */
 
@@ -403,7 +409,7 @@ static gboolean summary_update_msg  (gpointer source, gpointer data);
 GtkTargetEntry summary_drag_types[2] =
 {
        {"text/uri-list", 0, TARGET_MAIL_URI_LIST},
-       {"text/plain", GTK_TARGET_SAME_APP, TARGET_DUMMY}
+       {"sylpheed-claws/internal", GTK_TARGET_SAME_APP, TARGET_DUMMY}
 };
 
 static GtkItemFactoryEntry summary_popup_entries[] =
@@ -4629,6 +4635,10 @@ static GtkWidget *summary_ctree_create(SummaryView *summaryview)
                         G_CALLBACK(summary_drag_data_received),
                         summaryview);
 
+       g_signal_connect(G_OBJECT(ctree), "drag_motion",
+                        G_CALLBACK(summary_drag_motion_cb),
+                        summaryview);
+
        return ctree;
 }
 
@@ -5192,13 +5202,13 @@ static void summary_drag_data_get(GtkWidget        *widget,
                                        tmp2 = dest;
                                }
                        } 
-                       tmp1 = g_strconcat("file://", tmp2, NULL);
+                       tmp1 = g_strconcat("file://", tmp2, "\r\n", NULL);
                        g_free(tmp2);
 
                        if (!mail_list) {
                                mail_list = tmp1;
                        } else {
-                               tmp2 = g_strconcat(mail_list, "\n", tmp1, NULL);
+                               tmp2 = g_strconcat(mail_list, tmp1, NULL);
                                g_free(mail_list);
                                g_free(tmp1);
                                mail_list = tmp2;
@@ -5220,9 +5230,26 @@ static void summary_drag_data_get(GtkWidget        *widget,
        }
 }
 
-static void free_info (gpointer stuff, gpointer data)
+static gboolean summary_drag_motion_cb(GtkWidget      *widget,
+                                         GdkDragContext *context,
+                                         gint            x,
+                                         gint            y,
+                                         guint           time,
+                                         SummaryView    *summaryview)
 {
-       g_free(stuff);
+       FolderItem *item = summaryview->folder_item;
+       if (!(item && item->folder && folder_item_parent(item) != NULL
+                   && FOLDER_CLASS(item->folder)->add_msg != NULL)) {
+               gdk_drag_status(context, 0, time);
+               return FALSE;
+       } else if (gtk_drag_get_source_widget(context) ==
+               mainwindow_get_mainwindow()->folderview->ctree) {
+               gdk_drag_status(context, 0, time);
+               return FALSE;
+       } else {
+               gdk_drag_status(context, GDK_ACTION_COPY, time);
+               return TRUE;
+       }
 }
 
 static void summary_drag_data_received(GtkWidget        *widget,
@@ -5235,39 +5262,13 @@ static void summary_drag_data_received(GtkWidget        *widget,
                                        SummaryView       *summaryview)
 {
        if (info == TARGET_MAIL_URI_LIST) {
-               GList *list, *tmp;
-               GSList *msglist = NULL;
                FolderItem *item = summaryview->folder_item;
                if (!item) {
                        gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
                        return;
-               }
-               list = uri_list_extract_filenames((const gchar *)data->data);
-               if (!list) {
-                       gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
-                       return;
-               }
-               for (tmp = list; tmp != NULL; tmp = tmp->next) {
-                       MsgFileInfo *info = NULL;
-                       
-                       if (file_is_email((gchar *)tmp->data)) {
-                               info = g_new0(MsgFileInfo, 1);
-                               info->msginfo = NULL;
-                               info->file = (gchar *)tmp->data;
-                               msglist = g_slist_prepend(msglist, info);
-                       }
-               }
-               if (msglist) {
-                       msglist = g_slist_reverse(msglist);
-                       folder_item_add_msgs(item, msglist, FALSE);
-                       g_slist_foreach(msglist, free_info, NULL);
-                       g_slist_free(msglist);
-                       gtk_drag_finish(drag_context, TRUE, FALSE, time);
                } else {
-                       gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
+                       folderview_finish_dnd(data->data, drag_context, time, item);
                }
-               list_free_strings(list);
-               g_list_free(list);
        }
 }
 
index a362def..65b015c 100644 (file)
@@ -241,6 +241,10 @@ static GtkItemFactoryEntry textview_file_popup_entries[] =
 
 static void scrolled_cb (GtkAdjustment *adj, TextView *textview)
 {
+#ifndef WIDTH
+#  define WIDTH 48
+#  define HEIGHT 48
+#endif
        if (textview->image) {
                gint x, y, x1;
                x1 = textview->text->allocation.width - WIDTH - 5;
@@ -759,7 +763,6 @@ void textview_show_mime_part(TextView *textview, MimeInfo *partinfo)
        TEXT_INSERT(_("    (alternately double-click, or click the middle "));
        TEXT_INSERT(_("mouse button),\n"));
        TEXT_INSERT(_("    or 'Open with...' (Shortcut key: 'o')\n"));
-
 }
 
 #undef TEXT_INSERT
@@ -1300,51 +1303,23 @@ static GPtrArray *textview_scan_header(TextView *textview, FILE *fp)
 
 static void textview_show_face(TextView *textview)
 {
-       gchar face[2048];
-       gchar face_png[2048];
-       gint pngsize;
-       GdkPixbuf *pixbuf;
-       GError *error = NULL;
        GtkTextView *text = GTK_TEXT_VIEW(textview->text);
        MsgInfo *msginfo = textview->messageview->msginfo;
        int x = 0;
        
-       if (prefs_common.display_header_pane)
+       if (prefs_common.display_header_pane
+       ||  !prefs_common.display_xface)
                goto bail;
-
+       
        if (!msginfo->face) {
                goto bail;
        }
 
-       strncpy2(face, msginfo->face, sizeof(face));
-
-       unfold_line(face); /* strip all whitespace and linebreaks */
-       remove_space(face);
-
-       pngsize = base64_decode(face_png, face, strlen(face));
-
-       GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
-       if (!gdk_pixbuf_loader_write (loader, face_png, pngsize, &error) ||
-           !gdk_pixbuf_loader_close (loader, &error)) {
-               g_warning("loading face failed\n");
-               g_object_unref(loader);
-               goto bail;
-       }
-
-       pixbuf = g_object_ref(gdk_pixbuf_loader_get_pixbuf(loader));
-
-       g_object_unref(loader);
-
-       if ((gdk_pixbuf_get_width(pixbuf) != 48) || (gdk_pixbuf_get_height(pixbuf) != 48)) {
-               g_object_unref(pixbuf);
-               g_warning("wrong_size");
-               goto bail;
-       }
-
        if (textview->image) 
                gtk_widget_destroy(textview->image);
        
-       textview->image = gtk_image_new_from_pixbuf(pixbuf);
+       textview->image = face_get_from_header(msginfo->face);
+
        gtk_widget_show(textview->image);
        
        x = textview->text->allocation.width - WIDTH -5;
@@ -1352,8 +1327,6 @@ static void textview_show_face(TextView *textview)
        gtk_text_view_add_child_in_window(text, textview->image, 
                GTK_TEXT_WINDOW_TEXT, x, 5);
 
-       g_object_unref(pixbuf);
-       
        gtk_widget_show_all(textview->text);
        
 
@@ -1367,14 +1340,10 @@ bail:
 #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);
        int x = 0;
+
        if (prefs_common.display_header_pane
        ||  !prefs_common.display_xface)
                goto bail;
@@ -1389,33 +1358,13 @@ static void textview_show_xface(TextView *textview)
                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);
-       
        if (textview->image) 
                gtk_widget_destroy(textview->image);
        
-       textview->image = gtk_image_new_from_pixmap(pixmap, mask);
+       textview->image = xface_get_from_header(msginfo->xface,
+                               &textview->text->style->white,
+                               textview->text->window);
+
        gtk_widget_show(textview->image);
        
        x = textview->text->allocation.width - WIDTH -5;