aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-06-07 08:53:28 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-06-07 08:53:28 +0000
commitbf8f09d3ba0cb9722a4aac217b3b2f49fc9b6683 (patch)
tree2a0d70f0ea0257facf4fe0f09571843df0762147 /src
parentcd889b96814cd7c88f254ac91b92d807915e8d5d (diff)
made the old behavior of address completion configurable.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2565 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r--src/addr_compl.c20
-rw-r--r--src/prefs_common_dialog.c134
2 files changed, 137 insertions, 17 deletions
diff --git a/src/addr_compl.c b/src/addr_compl.c
index 9735f273..7aaa97d7 100644
--- a/src/addr_compl.c
+++ b/src/addr_compl.c
@@ -36,6 +36,7 @@
#include "utils.h"
#include "addressbook.h"
#include "main.h"
+#include "prefs_common.h"
/* How it works:
*
@@ -740,7 +741,6 @@ static void address_completion_mainwindow_set_focus(GtkWindow *window,
}
static GtkWidget *completion_window;
-static gboolean start_completion_on_tab = FALSE;
/* watch for tabs in one of the address entries. if no tab then clear the
* completion cache */
@@ -750,7 +750,7 @@ static gboolean address_completion_entry_key_pressed(GtkEntry *entry,
{
g_print("entry_key_pressed: %s\n", gtk_entry_get_text(entry));
- if (start_completion_on_tab && ev->keyval == GDK_Tab) {
+ if (!prefs_common.fullauto_completion_mode && ev->keyval == GDK_Tab) {
if (address_completion_complete_address_in_entry(entry, TRUE)) {
address_completion_create_completion_window(entry, TRUE);
/* route a void character to the default handler */
@@ -788,7 +788,7 @@ static void address_completion_entry_changed(GtkEditable *editable,
GtkEntry *entry = GTK_ENTRY(editable);
g_print("changed: %s\n", gtk_entry_get_text(entry));
- if (start_completion_on_tab)
+ if (!prefs_common.fullauto_completion_mode)
return;
g_signal_handlers_block_by_func
@@ -1016,7 +1016,6 @@ static gboolean completion_window_key_press(GtkWidget *widget,
GdkEventKey *event,
GtkWidget **window)
{
- GdkEventKey tmp_event;
GtkWidget *entry;
gchar *prefix;
gint cursor_pos;
@@ -1060,7 +1059,8 @@ static gboolean completion_window_key_press(GtkWidget *widget,
/* look for presses that accept the selection */
if (event->keyval == GDK_Return ||
- (start_completion_on_tab && event->keyval == GDK_space)) {
+ (!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)) {
completion_window_apply_selection_address_only
@@ -1087,7 +1087,8 @@ static gboolean completion_window_key_press(GtkWidget *widget,
}
/* other key, let's restore the prefix (orignal text) */
- if (start_completion_on_tab || event->keyval == GDK_Escape) {
+ if (!prefs_common.fullauto_completion_mode ||
+ event->keyval == GDK_Escape) {
prefix = get_complete_address(0);
g_free(get_address_from_edit(GTK_ENTRY(entry), &cursor_pos));
replace_address_in_edit(GTK_ENTRY(entry), prefix, cursor_pos);
@@ -1095,16 +1096,17 @@ static gboolean completion_window_key_press(GtkWidget *widget,
}
/* make sure anything we typed comes in the edit box */
- if ((start_completion_on_tab && event->length > 0 &&
+ if ((!prefs_common.fullauto_completion_mode && event->length > 0 &&
event->keyval != GDK_Escape) ||
- (!start_completion_on_tab && event->keyval != GDK_Escape)) {
+ (prefs_common.fullauto_completion_mode &&
+ event->keyval != GDK_Escape)) {
GtkWidget *pwin = entry;
while ((pwin = gtk_widget_get_parent(pwin)) != NULL) {
if (GTK_WIDGET_TOPLEVEL(pwin)) {
gtk_window_propagate_key_event
(GTK_WINDOW(pwin), event);
- if (!start_completion_on_tab)
+ if (prefs_common.fullauto_completion_mode)
return TRUE;
}
}
diff --git a/src/prefs_common_dialog.c b/src/prefs_common_dialog.c
index 3c4c32e5..31659d47 100644
--- a/src/prefs_common_dialog.c
+++ b/src/prefs_common_dialog.c
@@ -218,7 +218,7 @@ static struct Other {
GtkWidget *checkbtn_close_recv_dialog;
GtkWidget *checkbtn_addaddrbyclick;
- GtkWidget *checkbtn_enable_addr_compl;
+ GtkWidget *radiobtn_addr_compl;
GtkWidget *checkbtn_confonexit;
GtkWidget *checkbtn_cleanonexit;
@@ -281,6 +281,9 @@ static void prefs_common_recv_dialog_set_optmenu (PrefParam *pparam);
static void prefs_common_uri_set_data_from_entry (PrefParam *pparam);
static void prefs_common_uri_set_entry (PrefParam *pparam);
+static void prefs_common_addr_compl_set_data_from_radiobtn (PrefParam *pparam);
+static void prefs_common_addr_compl_set_radiobtn (PrefParam *pparam);
+
static PrefsUIData ui_data[] = {
/* Receive */
{"autochk_newmail", &receive.checkbtn_autochk,
@@ -534,8 +537,9 @@ static PrefsUIData ui_data[] = {
{"add_address_by_click", &other.checkbtn_addaddrbyclick,
prefs_set_data_from_toggle, prefs_set_toggle},
- {"enable_address_completion", &other.checkbtn_enable_addr_compl,
- 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},
{"confirm_on_exit", &other.checkbtn_confonexit,
prefs_set_data_from_toggle, prefs_set_toggle},
@@ -2490,7 +2494,11 @@ static GtkWidget *prefs_other_create(void)
GtkWidget *frame_addr;
GtkWidget *vbox_addr;
GtkWidget *checkbtn_addaddrbyclick;
- GtkWidget *checkbtn_enable_addr_compl;
+ GtkWidget *vbox_spc;
+ GtkWidget *hbox_spc;
+ GtkWidget *radiobtn_addr_compl;
+ GtkWidget *radiobtn_compl_tab;
+ GtkWidget *radiobtn_no_compl;
GtkWidget *frame_exit;
GtkWidget *vbox_exit;
@@ -2545,9 +2553,49 @@ static GtkWidget *prefs_other_create(void)
PACK_CHECK_BUTTON
(vbox_addr, checkbtn_addaddrbyclick,
_("Add address to destination when double-clicked"));
- PACK_CHECK_BUTTON
- (vbox_addr, checkbtn_enable_addr_compl,
- _("Enable address auto-completion"));
+
+ PACK_VSPACER (vbox_addr, vbox_spc, VSPACING_NARROW_2);
+
+ hbox1 = gtk_hbox_new (FALSE, 8);
+ gtk_widget_show (hbox1);
+ gtk_box_pack_start (GTK_BOX (vbox_addr), hbox1, FALSE, FALSE, 0);
+
+ label = gtk_label_new (_("Address auto-completion:"));
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
+
+ hbox1 = gtk_hbox_new (FALSE, 8);
+ gtk_widget_show (hbox1);
+ gtk_box_pack_start (GTK_BOX (vbox_addr), hbox1, FALSE, FALSE, 0);
+
+ hbox_spc = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (hbox_spc);
+ gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
+ gtk_widget_set_size_request (hbox_spc, 12, -1);
+
+ radiobtn_addr_compl = gtk_radio_button_new_with_label
+ (NULL, _("Automatic"));
+ gtk_widget_show (radiobtn_addr_compl);
+ gtk_box_pack_start (GTK_BOX (hbox1), radiobtn_addr_compl,
+ FALSE, FALSE, 0);
+ g_object_set_data (G_OBJECT (radiobtn_addr_compl), MENU_VAL_ID,
+ GINT_TO_POINTER (0));
+
+ radiobtn_compl_tab = gtk_radio_button_new_with_label_from_widget
+ (GTK_RADIO_BUTTON (radiobtn_addr_compl), _("Start with Tab"));
+ gtk_widget_show (radiobtn_compl_tab);
+ gtk_box_pack_start (GTK_BOX (hbox1), radiobtn_compl_tab,
+ FALSE, FALSE, 0);
+ g_object_set_data (G_OBJECT (radiobtn_compl_tab), MENU_VAL_ID,
+ GINT_TO_POINTER (1));
+
+ radiobtn_no_compl = gtk_radio_button_new_with_label_from_widget
+ (GTK_RADIO_BUTTON (radiobtn_addr_compl), _("Disable"));
+ gtk_widget_show (radiobtn_no_compl);
+ gtk_box_pack_start (GTK_BOX (hbox1), radiobtn_no_compl,
+ FALSE, FALSE, 0);
+ g_object_set_data (G_OBJECT (radiobtn_no_compl), MENU_VAL_ID,
+ GINT_TO_POINTER (2));
PACK_FRAME (vbox1, frame_exit, _("On exit"));
@@ -2577,7 +2625,7 @@ static GtkWidget *prefs_other_create(void)
other.checkbtn_close_recv_dialog = checkbtn_close_recv_dialog;
other.checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
- other.checkbtn_enable_addr_compl = checkbtn_enable_addr_compl;
+ other.radiobtn_addr_compl = radiobtn_addr_compl;
other.checkbtn_confonexit = checkbtn_confonexit;
other.checkbtn_cleanonexit = checkbtn_cleanonexit;
@@ -4174,6 +4222,76 @@ static void prefs_common_uri_set_entry(PrefParam *pparam)
}
}
+static void prefs_common_addr_compl_set_data_from_radiobtn(PrefParam *pparam)
+{
+ PrefsUIData *ui_data;
+ GtkRadioButton *radiobtn;
+ GSList *group;
+
+ ui_data = (PrefsUIData *)pparam->ui_data;
+ g_return_if_fail(ui_data != NULL);
+ g_return_if_fail(*ui_data->widget != NULL);
+
+ radiobtn = GTK_RADIO_BUTTON(*ui_data->widget);
+ group = gtk_radio_button_get_group(radiobtn);
+ while (group != NULL) {
+ GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data);
+ gint mode;
+
+ if (gtk_toggle_button_get_active(btn)) {
+ mode = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn),
+ MENU_VAL_ID));
+ if (mode == 2) {
+ prefs_common.enable_address_completion = FALSE;
+ prefs_common.fullauto_completion_mode = FALSE;
+ } else {
+ prefs_common.enable_address_completion = TRUE;
+ if (mode == 0)
+ prefs_common.fullauto_completion_mode = TRUE;
+ else
+ prefs_common.fullauto_completion_mode = FALSE;
+ }
+ break;
+ }
+ group = group->next;
+ }
+}
+
+static void prefs_common_addr_compl_set_radiobtn(PrefParam *pparam)
+{
+ PrefsUIData *ui_data;
+ GtkRadioButton *radiobtn;
+ GSList *group;
+ gint mode;
+
+ if (prefs_common.enable_address_completion) {
+ if (prefs_common.fullauto_completion_mode)
+ mode = 0;
+ else
+ mode = 1;
+ } else
+ mode = 2;
+
+ ui_data = (PrefsUIData *)pparam->ui_data;
+ g_return_if_fail(ui_data != NULL);
+ g_return_if_fail(*ui_data->widget != NULL);
+
+ radiobtn = GTK_RADIO_BUTTON(*ui_data->widget);
+ group = gtk_radio_button_get_group(radiobtn);
+ while (group != NULL) {
+ GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data);
+ gint data;
+
+ data = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn),
+ MENU_VAL_ID));
+ if (data == mode) {
+ gtk_toggle_button_set_active(btn, TRUE);
+ break;
+ }
+ group = group->next;
+ }
+}
+
static void prefs_common_dispitem_clicked(void)
{
prefs_summary_column_open(FOLDER_ITEM_IS_SENT_FOLDER