2007-04-17 [wwp] 2.9.0cvs2
authorTristan Chabredier <wwp@claws-mail.org>
Tue, 17 Apr 2007 08:47:10 +0000 (08:47 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Tue, 17 Apr 2007 08:47:10 +0000 (08:47 +0000)
* src/compose.c
Prepend "Add to address book" to the context menu of compose window's sender and
recipient fields.

ChangeLog
PATCHSETS
configure.ac
src/compose.c

index 6da44f7c769b3a1949f6780a0d27e5df4b882ab2..ac6f66b15eda41b27bcee72802ddf0c9ed5c1b54 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-04-17 [wwp]       2.9.0cvs2
+
+       * src/compose.c
+               Prepend "Add to address book" to the context menu of compose window's sender and
+               recipient fields.
+
 2007-04-16 [paul]      2.9.0cvs1
 
        * src/gtk/authors.h
index dd3192fa7c04751884f658777b009e2bb006698a..f89e02740395005194d7bf7bef2ed9dde10339bb 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.12 -r 1.1.2.13 po/ca.po;  cvs diff -u -r 1.9.2.11 -r 1.9.2.12 po/cs.po;  cvs diff -u -r 1.58.2.30 -r 1.58.2.31 po/de.po;  cvs diff -u -r 1.5.2.4 -r 1.5.2.5 po/hu.po;  cvs diff -u -r 1.10.2.12 -r 1.10.2.13 po/pl.po;  cvs diff -u -r 1.50.2.24 -r 1.50.2.25 po/pt_BR.po;  cvs diff -u -r 1.17.2.26 -r 1.17.2.27 po/sr.po;  cvs diff -u -r 1.5.2.22 -r 1.5.2.23 po/zh_CN.po;  ) > 2.8.1cvs101.patchset
 ( cvs diff -u -r 1.42.2.30 -r 1.42.2.31 po/fr.po;  ) > 2.8.1cvs102.patchset
 ( cvs diff -u -r 1.1.2.35 -r 1.1.2.36 src/gtk/authors.h;  ) > 2.9.0cvs1.patchset
+( cvs diff -u -r 1.382.2.369 -r 1.382.2.370 src/compose.c;  ) > 2.9.0cvs2.patchset
index ac5dd2e539e2368fc0e80e6491b8ed0d450a73cd..90cad19f15e7d74250a0af5c01a2a433cf051932 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=1
+EXTRA_VERSION=2
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 695d67988ea5c974c2edf1389d4af45749d336d7..5972f7500416e822f3c25940b6a9fae3e9e2734e 100644 (file)
@@ -5657,6 +5657,48 @@ static void compose_convert_header(Compose *compose, gchar *dest, gint len, gcha
        g_free(tmpstr);
 }
 
+static void compose_add_to_addressbook_cb(GtkMenuItem *menuitem, gpointer user_data)
+{
+       gchar *address;
+
+       g_return_if_fail(user_data != NULL);
+
+       address = g_strdup(gtk_entry_get_text(GTK_ENTRY(user_data)));
+       g_strstrip(address);
+       if (*address != '\0') {
+               gchar *name = procheader_get_fromname(address);
+               extract_address(address);
+               addressbook_add_contact(name, address, NULL);
+       }
+       g_free(address);
+}
+
+static void compose_entry_popup_extend(GtkEntry *entry, GtkMenu *menu, gpointer user_data)
+{
+       GtkWidget *menuitem;
+       gchar *address;
+
+       g_return_if_fail(menu != NULL);
+       g_return_if_fail(GTK_IS_MENU_SHELL(menu));
+
+       menuitem = gtk_separator_menu_item_new();
+       gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), menuitem);
+       gtk_widget_show(menuitem);
+
+       menuitem = gtk_menu_item_new_with_mnemonic(_("Add to address _book"));
+       gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), menuitem);
+
+       address = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
+       g_strstrip(address);
+       if (*address == '\0') {
+               gtk_widget_set_sensitive(GTK_WIDGET(menuitem), FALSE);
+       }
+
+       g_signal_connect(G_OBJECT(menuitem), "activate",
+                        G_CALLBACK(compose_add_to_addressbook_cb), entry);
+       gtk_widget_show(menuitem);
+}
+
 static void compose_create_header_entry(Compose *compose) 
 {
        gchar *headers[] = {"To:", "Cc:", "Bcc:", "Newsgroups:", "Reply-To:", "Followup-To:", NULL};
@@ -5684,9 +5726,12 @@ static void compose_create_header_entry(Compose *compose)
        g_signal_connect(G_OBJECT(GTK_COMBO(combo)->entry), "grab_focus",
                         G_CALLBACK(compose_grab_focus_cb), compose);
        gtk_widget_show(combo);
-       gtk_table_attach(GTK_TABLE(compose->header_table), combo, 0, 1, compose->header_nextrow, compose->header_nextrow+1, GTK_SHRINK, GTK_FILL, 0, 0);
+       gtk_table_attach(GTK_TABLE(compose->header_table), combo, 0, 1,
+                       compose->header_nextrow, compose->header_nextrow+1,
+                       GTK_SHRINK, GTK_FILL, 0, 0);
        if (compose->header_last) {     
-               const gchar *last_header_entry = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(compose->header_last->combo)->entry));
+               const gchar *last_header_entry = gtk_entry_get_text(
+                               GTK_ENTRY(GTK_COMBO(compose->header_last->combo)->entry));
                string = headers;
                while (*string != NULL) {
                        if (!strcmp(*string, last_header_entry))
@@ -5717,7 +5762,9 @@ static void compose_create_header_entry(Compose *compose)
        gtk_widget_show(entry);
        gtk_tooltips_set_tip(compose->tooltips, entry,
                _("Use <tab> to autocomplete from addressbook"), NULL);
-       gtk_table_attach(GTK_TABLE(compose->header_table), entry, 1, 2, compose->header_nextrow, compose->header_nextrow+1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+       gtk_table_attach(GTK_TABLE(compose->header_table), entry, 1, 2,
+                       compose->header_nextrow, compose->header_nextrow+1,
+                       GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
 
         g_signal_connect(G_OBJECT(entry), "key-press-event", 
                         G_CALLBACK(compose_headerentry_key_press_event_cb), 
@@ -5738,6 +5785,9 @@ static void compose_create_header_entry(Compose *compose)
        g_signal_connect(G_OBJECT(entry), "drag-drop",
                         G_CALLBACK(compose_drag_drop),
                         compose);
+       g_signal_connect(G_OBJECT(entry), "populate-popup",
+                        G_CALLBACK(compose_entry_popup_extend),
+                        NULL);
        
        address_completion_register_entry(GTK_ENTRY(entry), TRUE);
 
@@ -6622,6 +6672,9 @@ static GtkWidget *compose_account_option_menu_create(Compose *compose)
        g_signal_connect(G_OBJECT(optmenu), "changed",
                        G_CALLBACK(account_activated),
                        compose);
+       g_signal_connect(G_OBJECT(from_name), "populate-popup",
+                        G_CALLBACK(compose_entry_popup_extend),
+                        NULL);
 
        gtk_box_pack_start(GTK_BOX(hbox), optmenubox, FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), from_name, TRUE, TRUE, 0);