2006-06-24 [paul] 2.3.1cvs17
authorPaul Mangan <paul@claws-mail.org>
Sat, 24 Jun 2006 10:45:26 +0000 (10:45 +0000)
committerPaul Mangan <paul@claws-mail.org>
Sat, 24 Jun 2006 10:45:26 +0000 (10:45 +0000)
* src/compose.c
* src/prefs_common.c
* src/prefs_common.h
* src/prefs_compose_writing.c
enable setting of default action when
dnd'ing files in the compose window.
(Collaborative effort with wwp)

ChangeLog
PATCHSETS
configure.ac
src/compose.c
src/prefs_common.c
src/prefs_common.h
src/prefs_compose_writing.c

index fc3fbbb..f9eac28 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-06-24 [paul]      2.3.1cvs17
+
+       * src/compose.c
+       * src/prefs_common.c
+       * src/prefs_common.h
+       * src/prefs_compose_writing.c
+               enable setting of default action when
+               dnd'ing files in the compose window.
+               (Collaborative effort with wwp)
+
 2006-06-23 [wwp]       2.3.1cvs16
 
        * src/compose.c
index 7bde631..30abb14 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.654.2.1660 -r 1.654.2.1661 configure.ac;  ) > 2.3.1cvs14.patchset
 ( cvs diff -u -r 1.16.2.21 -r 1.16.2.22 src/prefs_customheader.c;  ) > 2.3.1cvs15.patchset
 ( cvs diff -u -r 1.382.2.283 -r 1.382.2.284 src/compose.c;  ) > 2.3.1cvs16.patchset
+( cvs diff -u -r 1.382.2.284 -r 1.382.2.285 src/compose.c;  cvs diff -u -r 1.204.2.89 -r 1.204.2.90 src/prefs_common.c;  cvs diff -u -r 1.103.2.52 -r 1.103.2.53 src/prefs_common.h;  cvs diff -u -r 1.1.2.8 -r 1.1.2.9 src/prefs_compose_writing.c;  ) > 2.3.1cvs17.patchset
index 7b12108..70b7783 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=3
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=16
+EXTRA_VERSION=17
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 0786780..b91b952 100644 (file)
@@ -8506,10 +8506,36 @@ static void compose_insert_drag_received_cb (GtkWidget          *widget,
 {
        Compose *compose = (Compose *)user_data;
        GList *list, *tmp;
-       AlertValue val = alertpanel(_("Insert or attach?"),
-                                _("Do you want to insert the contents of this file in the email body, "
-                                  "or rather attach it to the email?"),
-                                 GTK_STOCK_CANCEL, _("+_Insert"), _("_Attach"));
+       AlertValue val = G_ALERTDEFAULT;
+
+       switch (prefs_common.compose_dnd_mode) {
+               case COMPOSE_DND_ASK:
+                       val = alertpanel_full(_("Insert or attach?"),
+                                _("Do you want to insert the contents of the file(s) "
+                                  "into the message body, or attach it to the email?"),
+                                 GTK_STOCK_CANCEL, _("+_Insert"), _("_Attach"),
+                                 TRUE, NULL, ALERT_QUESTION, G_ALERTALTERNATE);
+                       break;
+               case COMPOSE_DND_INSERT:
+                       val = G_ALERTALTERNATE;
+                       break;
+               case COMPOSE_DND_ATTACH:
+                       val = G_ALERTOTHER;
+                       break;
+               default:
+                       /* unexpected case */
+                       g_warning("error: unexpected compose_dnd_mode option value in compose_insert_drag_received_cb()");
+       }
+
+       if (val & G_ALERTDISABLE) {
+               val &= ~G_ALERTDISABLE;
+               /* remember what action to perform by default, only if we don't click Cancel */
+               if (val == G_ALERTALTERNATE)
+                       prefs_common.compose_dnd_mode = COMPOSE_DND_INSERT;
+               else
+                       if (val == G_ALERTOTHER)
+                               prefs_common.compose_dnd_mode = COMPOSE_DND_ATTACH;
+       }
        
        if (val == G_ALERTDEFAULT) {
                gtk_drag_finish(drag_context, FALSE, FALSE, time);
index 13ddcaf..ce929c3 100644 (file)
@@ -230,6 +230,8 @@ static PrefParam param[] = {
 #endif
        {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL,
         NULL, NULL, NULL},
+       {"compose_dnd_insert_or_attach", "TRUE", &prefs_common.compose_dnd_mode, P_ENUM,
+        NULL, NULL, NULL},
 
        /* Account autoselection */
        {"reply_account_autoselect", "TRUE",
index d7cda7b..fbffd9e 100644 (file)
@@ -42,6 +42,12 @@ typedef enum {
        RECV_DIALOG_NEVER
 } RecvDialogMode;
 
+typedef enum {
+       COMPOSE_DND_ASK,
+       COMPOSE_DND_INSERT,
+       COMPOSE_DND_ATTACH
+} ComposeDndInsertOrAttach;
+
 typedef enum {
        CTE_AUTO,
        CTE_BASE64,
@@ -115,6 +121,7 @@ struct _PrefsCommon
        gboolean autosave;
        gint autosave_length;
        gboolean compose_no_markup;
+       ComposeDndInsertOrAttach compose_dnd_mode;
 
        /* Quote */
        gboolean reply_with_quote;
index dd48d1f..3307f23 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "gtk/gtkutils.h"
 #include "gtk/prefswindow.h"
+#include "gtk/menu.h"
 
 #include "manage_window.h"
 
@@ -56,6 +57,7 @@ typedef struct _WritingPage
        GtkWidget *hbox_autosave;
        GtkWidget *checkbtn_autosave;
        GtkWidget *spinbtn_autosave_length;
+       GtkWidget *optmenu_dnd_insert_or_attach;
 } WritingPage;
 
 void prefs_compose_writing_create_widget(PrefsPage *_page, GtkWindow *window, 
@@ -90,6 +92,12 @@ void prefs_compose_writing_create_widget(PrefsPage *_page, GtkWindow *window,
        GtkWidget *spinbtn_autosave_length;
        GtkWidget *label_autosave_length;
        
+       GtkWidget *hbox_dnd_insert_or_attach;
+       GtkWidget *label_dnd_insert_or_attach;
+       GtkWidget *optmenu_dnd_insert_or_attach;
+       GtkWidget *menu;
+       GtkWidget *menuitem;
+
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
@@ -170,6 +178,29 @@ void prefs_compose_writing_create_widget(PrefsPage *_page, GtkWindow *window,
        PACK_CHECK_BUTTON (vbox1, checkbtn_default_reply_list,
                           _("Reply button invokes mailing list reply"));
 
+       /* dnd insert or attach */
+       label_dnd_insert_or_attach = gtk_label_new (_("When dropping files into the Compose window"));
+       gtk_misc_set_alignment(GTK_MISC(label_dnd_insert_or_attach), 0, 0.5);
+       gtk_widget_show (label_dnd_insert_or_attach);
+
+       optmenu_dnd_insert_or_attach = gtk_option_menu_new ();
+       gtk_widget_show (optmenu_dnd_insert_or_attach);
+
+       menu = gtk_menu_new ();
+       MENUITEM_ADD (menu, menuitem, _("Ask whether to insert or attach"), COMPOSE_DND_ASK);
+       MENUITEM_ADD (menu, menuitem, _("Always insert"), COMPOSE_DND_INSERT);
+       MENUITEM_ADD (menu, menuitem, _("Always attach"), COMPOSE_DND_ATTACH);
+
+       gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_dnd_insert_or_attach), menu);
+
+       hbox_dnd_insert_or_attach = gtk_hbox_new(FALSE, 20);
+       gtk_widget_show(hbox_dnd_insert_or_attach);
+       gtk_box_pack_start(GTK_BOX(vbox1), hbox_dnd_insert_or_attach, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox_dnd_insert_or_attach),
+                       label_dnd_insert_or_attach, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox_dnd_insert_or_attach),
+                       optmenu_dnd_insert_or_attach, FALSE, FALSE, 0);
+       
        SET_TOGGLE_SENSITIVITY (checkbtn_autosave, spinbtn_autosave_length);
        SET_TOGGLE_SENSITIVITY (checkbtn_autosave, label_autosave_length);
 
@@ -190,6 +221,8 @@ void prefs_compose_writing_create_widget(PrefsPage *_page, GtkWindow *window,
                checkbtn_redirect_keep_from;
        prefs_writing->checkbtn_default_reply_list = checkbtn_default_reply_list;
 
+       prefs_writing->optmenu_dnd_insert_or_attach = optmenu_dnd_insert_or_attach;
+
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_autoextedit),
                prefs_common.auto_exteditor);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_forward_as_attachment),
@@ -210,12 +243,17 @@ void prefs_compose_writing_create_widget(PrefsPage *_page, GtkWindow *window,
                prefs_common.reedit_account_autosel);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_default_reply_list),
                prefs_common.default_reply_list);
+       gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu_dnd_insert_or_attach),
+               prefs_common.compose_dnd_mode);
 
        prefs_writing->page.widget = vbox1;
 }
 
 void prefs_compose_writing_save(PrefsPage *_page)
 {
+       GtkWidget *menu;
+       GtkWidget *menuitem;
+
        WritingPage *page = (WritingPage *) _page;
        prefs_common.auto_exteditor = 
                gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_autoextedit));
@@ -239,6 +277,10 @@ void prefs_compose_writing_save(PrefsPage *_page)
        prefs_common.default_reply_list =
                gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_reply_list));
        
+       menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_dnd_insert_or_attach));
+       menuitem = gtk_menu_get_active(GTK_MENU(menu));
+       prefs_common.compose_dnd_mode = GPOINTER_TO_INT
+               (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
 }
 
 static void prefs_compose_writing_destroy_widget(PrefsPage *_page)