From 9284b3b9a8936ac973589bef2c3d791dae10efcf Mon Sep 17 00:00:00 2001 From: hiro Date: Mon, 20 Jun 2005 08:16:57 +0000 Subject: added 'Add to address book' to the context menu of textview. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@352 ee746299-78ed-0310-b773-934348b2243d --- src/addressadd.c | 8 +++++++- src/mainwindow.c | 4 ++-- src/summaryview.c | 4 ++-- src/textview.c | 38 +++++++++++++++++++++++++++++++++++++- 4 files changed, 48 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/addressadd.c b/src/addressadd.c index 0f17eb30..a9997d2f 100644 --- a/src/addressadd.c +++ b/src/addressadd.c @@ -50,6 +50,7 @@ #include "addritem.h" #include "addrbook.h" #include "addrindex.h" +#include "editaddress.h" #include "manage_window.h" typedef struct { @@ -392,7 +393,12 @@ gboolean addressadd_selection( AddressIndex *addrIndex, const gchar *name, const if( addressadd_dlg.fiSelected ) { FolderInfo *fi = addressadd_dlg.fiSelected; person = addrbook_add_contact( fi->book, fi->folder, name, address, remarks ); - if( person ) retVal = TRUE; + if( person ) { + if( addressbook_edit_person( fi->book, NULL, person, FALSE ) == NULL ) + addrbook_remove_person( fi->book, person ); + else + retVal = TRUE; + } } } diff --git a/src/mainwindow.c b/src/mainwindow.c index 02612536..3af7d2dc 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -720,7 +720,7 @@ static GtkItemFactoryEntry mainwin_entries[] = {N_("/_Tools"), NULL, NULL, 0, ""}, {N_("/_Tools/_Address book"), "A", addressbook_open_cb, 0, NULL}, - {N_("/_Tools/Add sender to address boo_k"), + {N_("/_Tools/Add sender to address boo_k..."), NULL, add_address_cb, 0, NULL}, {N_("/_Tools/---"), NULL, NULL, 0, ""}, {N_("/_Tools/_Filter all messages in folder"), @@ -1825,7 +1825,7 @@ void main_window_set_menu_sensitive(MainWindow *mainwin) {"/Message/Set as not junk mail" , M_TARGET_EXIST|M_ALLOW_DELETE|M_ENABLE_JUNK}, {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT}, - {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST}, + {"/Tools/Add sender to address book...", M_SINGLE_TARGET_EXIST}, {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC}, {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC}, {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED}, diff --git a/src/summaryview.c b/src/summaryview.c index 34889990..3c19c6c9 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -392,7 +392,7 @@ static GtkItemFactoryEntry summary_popup_entries[] = {N_("/---"), NULL, NULL, 0, ""}, {N_("/Re-_edit"), NULL, summary_reedit, 0, NULL}, {N_("/---"), NULL, NULL, 0, ""}, - {N_("/Add sender to address boo_k"), + {N_("/Add sender to address boo_k..."), NULL, summary_add_address_cb, 0, NULL}, {N_("/---"), NULL, NULL, 0, ""}, {N_("/_View"), NULL, NULL, 0, ""}, @@ -1016,7 +1016,7 @@ static void summary_set_menu_sensitive(SummaryView *summaryview) menu_set_sensitive(ifactory, "/Forward as attachment", TRUE); menu_set_sensitive(ifactory, "/Redirect", sens); - menu_set_sensitive(ifactory, "/Add sender to address book", sens); + menu_set_sensitive(ifactory, "/Add sender to address book...", sens); menu_set_sensitive(ifactory, "/View", sens); menu_set_sensitive(ifactory, "/View/Open in new window", sens); diff --git a/src/textview.c b/src/textview.c index d547e06d..f974fde6 100644 --- a/src/textview.c +++ b/src/textview.c @@ -191,6 +191,9 @@ static gboolean textview_visibility_notify (GtkWidget *widget, static void textview_populate_popup (GtkWidget *widget, GtkMenu *menu, TextView *textview); +static void textview_popup_menu_activate_add_address_cb + (GtkMenuItem *menuitem, + gpointer data); static void textview_popup_menu_activate_copy_cb(GtkMenuItem *menuitem, gpointer data); static void textview_popup_menu_activate_image_cb @@ -1852,6 +1855,7 @@ static void textview_populate_popup(GtkWidget *widget, GtkMenu *menu, gboolean on_link; RemoteURI *uri; GdkPixbuf *pixbuf; + const gchar *copy_link_label; buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)); @@ -1890,13 +1894,45 @@ static void textview_populate_popup(GtkWidget *widget, GtkMenu *menu, gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator); gtk_widget_show(separator); - menuitem = gtk_menu_item_new_with_mnemonic(_("Copy this _link")); + if (!g_ascii_strncasecmp(uri->uri, "mailto:", 7)) { + menuitem = gtk_menu_item_new_with_mnemonic + (_("Add to address _book...")); + g_signal_connect + (menuitem, "activate", + G_CALLBACK(textview_popup_menu_activate_add_address_cb), uri); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + gtk_widget_show(menuitem); + + copy_link_label = _("Copy this add_ress"); + } else + copy_link_label = _("Copy this _link"); + + menuitem = gtk_menu_item_new_with_mnemonic(copy_link_label); g_signal_connect(menuitem, "activate", G_CALLBACK(textview_popup_menu_activate_copy_cb), uri); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); gtk_widget_show(menuitem); } +static void textview_popup_menu_activate_add_address_cb(GtkMenuItem *menuitem, + gpointer data) +{ + RemoteURI *uri = (RemoteURI *)data; + const gchar *addr; + + g_return_if_fail(uri != NULL); + + if (!uri->uri) + return; + + if (!g_ascii_strncasecmp(uri->uri, "mailto:", 7)) + addr = uri->uri + 7; + else + addr = uri->uri; + + addressbook_add_contact(addr, addr, NULL); +} + static void textview_popup_menu_activate_copy_cb(GtkMenuItem *menuitem, gpointer data) { -- cgit v1.2.3