From 1d2c08d736595d00fe3976b8774566783fa40c20 Mon Sep 17 00:00:00 2001 From: hiro Date: Mon, 20 Dec 2010 05:11:34 +0000 Subject: added new option: 'Set only mail address when composing from address book'. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2759 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 10 ++++++++++ libsylph/prefs_common.c | 2 ++ libsylph/prefs_common.h | 2 ++ src/addr_compl.c | 3 ++- src/addressbook.c | 11 ++++++++++- src/compose.c | 19 ++++++++++++++++--- src/compose.h | 5 +++++ src/importldif.c | 2 +- src/prefs_common_dialog.c | 11 ++++++++++- 9 files changed, 58 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1274e363..98e3d474 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-12-20 + + * libsylph/prefs_common.[ch] + src/compose.[ch] + src/addressbook.c + src/addr_compl.c + src/prefs_common_dialog.c: added new option: "Set only mail address + when composing from address book". + * src/importldif.c: fixed uninitialized variable. + 2010-12-17 * src/compose.c diff --git a/libsylph/prefs_common.c b/libsylph/prefs_common.c index 2cf13174..ee6040c6 100644 --- a/libsylph/prefs_common.c +++ b/libsylph/prefs_common.c @@ -443,6 +443,8 @@ static PrefParam param[] = { &prefs_common.enable_address_completion, P_BOOL}, {"fullauto_completion_mode", "TRUE", &prefs_common.fullauto_completion_mode, P_BOOL}, + {"always_add_address_only", "FALSE", + &prefs_common.always_add_address_only, P_BOOL}, {"confirm_on_exit", "FALSE", &prefs_common.confirm_on_exit, P_BOOL}, {"clean_trash_on_exit", "FALSE", &prefs_common.clean_on_exit, P_BOOL}, diff --git a/libsylph/prefs_common.h b/libsylph/prefs_common.h index 1630adce..aac6c48d 100644 --- a/libsylph/prefs_common.h +++ b/libsylph/prefs_common.h @@ -320,6 +320,8 @@ struct _PrefsCommon gboolean change_account_on_folder_sel; /* Interface */ gboolean always_mark_read_on_show_msg; /* Interface */ + + gboolean always_add_address_only; /* Compose */ }; extern PrefsCommon prefs_common; diff --git a/src/addr_compl.c b/src/addr_compl.c index a27e8c2f..8a1fbeca 100644 --- a/src/addr_compl.c +++ b/src/addr_compl.c @@ -1054,7 +1054,8 @@ static gboolean completion_window_key_press(GtkWidget *widget, (!prefs_common.fullauto_completion_mode && event->keyval == GDK_space)) { /* insert address only if shift or control is pressed */ - if (event->state & (GDK_SHIFT_MASK|GDK_CONTROL_MASK)) { + if (event->state & (GDK_SHIFT_MASK|GDK_CONTROL_MASK) || + prefs_common.always_add_address_only) { completion_window_apply_selection_address_only (GTK_CLIST(clist), GTK_ENTRY(entry)); } diff --git a/src/addressbook.c b/src/addressbook.c index f1606594..94f97426 100644 --- a/src/addressbook.c +++ b/src/addressbook.c @@ -1217,7 +1217,8 @@ gchar *addressbook_format_address(AddressObject *obj) } } if( address ) { - if( name && name[0] != '\0' ) { + if( !prefs_common.always_add_address_only && + name && name[0] != '\0' ) { if( name[0] != '"' && strpbrk( name, ",.[]<>" ) != NULL ) buf = g_strdup_printf( "\"%s\" <%s>", name, address ); else @@ -1234,13 +1235,18 @@ gchar *addressbook_format_address(AddressObject *obj) static void addressbook_to_clicked(GtkButton *button, gpointer data) { GList *node = _addressListSelection_; + gboolean new_compose = FALSE; if (!addrbook.target_compose) { + new_compose = TRUE; addrbook.target_compose = compose_new(NULL, NULL, NULL, NULL); if (!addrbook.target_compose) return; } + if (new_compose) + compose_block_modified(addrbook.target_compose); + while( node ) { AddressObject *obj = node->data; Compose *compose = addrbook.target_compose; @@ -1264,6 +1270,9 @@ static void addressbook_to_clicked(GtkButton *button, gpointer data) } } } + + if (new_compose) + compose_unblock_modified(addrbook.target_compose); } static void addressbook_menuitem_set_sensitive(void) diff --git a/src/compose.c b/src/compose.c index 9b39e87f..3cd7ab74 100644 --- a/src/compose.c +++ b/src/compose.c @@ -3425,6 +3425,16 @@ void compose_unlock(Compose *compose) compose->lock_count--; } +void compose_block_modified(Compose *compose) +{ + compose->block_modified = TRUE; +} + +void compose_unblock_modified(Compose *compose) +{ + compose->block_modified = FALSE; +} + static gint compose_send(Compose *compose) { gchar tmp[MAXPATHLEN + 1]; @@ -5569,6 +5579,8 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode) compose->window_maximized = prefs_common.compose_maximized; + compose->block_modified = FALSE; + compose_set_toolbar_button_visibility(compose); compose_select_account(compose, account, TRUE); @@ -7648,7 +7660,7 @@ static void compose_attach_toggled(GtkWidget *widget, Compose *compose) static void compose_buffer_changed_cb(GtkTextBuffer *textbuf, Compose *compose) { - if (compose->modified == FALSE) { + if (compose->modified == FALSE && compose->block_modified == FALSE) { compose->modified = TRUE; compose_set_title(compose); } @@ -7656,8 +7668,9 @@ static void compose_buffer_changed_cb(GtkTextBuffer *textbuf, Compose *compose) static void compose_changed_cb(GtkEditable *editable, Compose *compose) { - if (compose->modified == FALSE || - editable == GTK_EDITABLE(compose->subject_entry)) { + if (compose->block_modified == FALSE && + (compose->modified == FALSE || + editable == GTK_EDITABLE(compose->subject_entry))) { compose->modified = TRUE; compose_set_title(compose); } diff --git a/src/compose.h b/src/compose.h index d73c94b9..5dcf61c2 100644 --- a/src/compose.h +++ b/src/compose.h @@ -196,6 +196,8 @@ struct _Compose guint lock_count; gboolean window_maximized; + + gboolean block_modified; }; struct _AttachInfo @@ -238,6 +240,9 @@ gchar *compose_entry_get_text (Compose *compose, void compose_lock (Compose *compose); void compose_unlock (Compose *compose); +void compose_block_modified (Compose *compose); +void compose_unblock_modified (Compose *compose); + void compose_reflect_prefs_all (void); #endif /* __COMPOSE_H__ */ diff --git a/src/importldif.c b/src/importldif.c index db595738..329b253e 100644 --- a/src/importldif.c +++ b/src/importldif.c @@ -824,7 +824,7 @@ AddressBookFile *addressbook_imp_ldif_file( AddressIndex *addrIndex, const gchar *book_name ) { gchar *fsfile; GList *node, *list; - gboolean ret; + gboolean ret = FALSE; g_return_val_if_fail(addrIndex != NULL, NULL); g_return_val_if_fail(file != NULL, NULL); diff --git a/src/prefs_common_dialog.c b/src/prefs_common_dialog.c index ae60d73a..e7e76e8e 100644 --- a/src/prefs_common_dialog.c +++ b/src/prefs_common_dialog.c @@ -220,6 +220,7 @@ static struct Other { GtkWidget *checkbtn_close_recv_dialog; GtkWidget *checkbtn_addaddrbyclick; + GtkWidget *checkbtn_add_address_only; GtkWidget *radiobtn_addr_compl; GtkWidget *checkbtn_confonexit; @@ -546,6 +547,8 @@ static PrefsUIData ui_data[] = { {"add_address_by_click", &other.checkbtn_addaddrbyclick, prefs_set_data_from_toggle, prefs_set_toggle}, + {"always_add_address_only", &other.checkbtn_add_address_only, + prefs_set_data_from_toggle, prefs_set_toggle}, {"enable_address_completion", &other.radiobtn_addr_compl, prefs_common_addr_compl_set_data_from_radiobtn, prefs_common_addr_compl_set_radiobtn}, @@ -2525,6 +2528,7 @@ static GtkWidget *prefs_other_create(void) GtkWidget *frame_addr; GtkWidget *vbox_addr; GtkWidget *checkbtn_addaddrbyclick; + GtkWidget *checkbtn_add_address_only; GtkWidget *vbox_spc; GtkWidget *hbox_spc; GtkWidget *radiobtn_addr_compl; @@ -2585,6 +2589,10 @@ static GtkWidget *prefs_other_create(void) (vbox_addr, checkbtn_addaddrbyclick, _("Add address to destination when double-clicked")); + PACK_CHECK_BUTTON + (vbox_addr, checkbtn_add_address_only, + _("Set only mail address when composing from address book")); + PACK_VSPACER (vbox_addr, vbox_spc, VSPACING_NARROW_2); hbox1 = gtk_hbox_new (FALSE, 8); @@ -2656,7 +2664,8 @@ static GtkWidget *prefs_other_create(void) other.checkbtn_close_recv_dialog = checkbtn_close_recv_dialog; other.checkbtn_addaddrbyclick = checkbtn_addaddrbyclick; - other.radiobtn_addr_compl = radiobtn_addr_compl; + other.checkbtn_add_address_only = checkbtn_add_address_only; + other.radiobtn_addr_compl = radiobtn_addr_compl; other.checkbtn_confonexit = checkbtn_confonexit; other.checkbtn_cleanonexit = checkbtn_cleanonexit; -- cgit v1.2.3