[Kazehakase-devel 2212] inline-completionの有効/無効の切替え

Back to archive index

Kouhei Sutou kou****@cozmi*****
2005年 6月 14日 (火) 00:58:33 JST


須藤です.

URLエントリボックスでinline-completionを使うかどうかをカスタ
マイズできるようにするパッチです.

poはこんな感じでどうでしょうか.
  msgid "Use _inline-completion in URL entry box"
  msgstr "URLエントリボックスでの自動補完機能時にその場に補完候補を表示する(_I)"

-------------- next part --------------
Index: src/actions/kz-history-action.c
===================================================================
RCS file: /cvsroot/kazehakase/kazehakase/src/actions/kz-history-action.c,v
retrieving revision 1.18
diff -u -p -r1.18 kz-history-action.c
--- src/actions/kz-history-action.c	15 Mar 2005 12:29:46 -0000	1.18
+++ src/actions/kz-history-action.c	13 Jun 2005 15:53:49 -0000
@@ -606,10 +606,15 @@ kz_history_set_completion (KzHistoryActi
 {
 	GtkCellRenderer *cell;
 	GtkTreeModel *model;
-
+	gboolean use_inline_completion = FALSE;
+	
 	action->completion = gtk_entry_completion_new ();
 	model = GTK_TREE_MODEL(action->list_store);
 
+	KZ_CONF_GET("Global", "use_inline_completion",
+		    use_inline_completion, BOOL);
+	kz_history_set_inline_completion(action, use_inline_completion);
+	
 	gtk_entry_completion_set_model (action->completion, model);
 	gtk_entry_completion_set_match_func (action->completion, completion_func, action, NULL);
 	g_signal_connect (action->completion, "match_selected",
@@ -642,3 +647,13 @@ kz_history_unset_completion (KzHistoryAc
 	gtk_entry_set_completion (entry, NULL);
 }
 
+void
+kz_history_set_inline_completion (KzHistoryAction *action, gboolean use)
+{
+	g_return_if_fail(action->completion);
+	
+	g_object_set(action->completion,
+		     "text_column", use ? COLUMN_URI : -1,
+		     NULL);
+	gtk_entry_completion_set_inline_completion(action->completion, use);
+}
Index: src/actions/kz-history-action.h
===================================================================
RCS file: /cvsroot/kazehakase/kazehakase/src/actions/kz-history-action.h,v
retrieving revision 1.9
diff -u -p -r1.9 kz-history-action.h
--- src/actions/kz-history-action.h	4 Feb 2005 09:57:42 -0000	1.9
+++ src/actions/kz-history-action.h	13 Jun 2005 15:53:49 -0000
@@ -76,6 +76,8 @@ void         kz_history_set_completion  
 						 GtkEntry *entry);
 void         kz_history_unset_completion        (KzHistoryAction *action,
 						 GtkEntry *entry);
+void         kz_history_set_inline_completion   (KzHistoryAction *action,
+						 gboolean use);
 
 /* protected */
 GtkComboBox    *kz_history_action_get_combo_widget (KzHistoryAction *action,
Index: src/actions/kz-location-entry-action.c
===================================================================
RCS file: /cvsroot/kazehakase/kazehakase/src/actions/kz-location-entry-action.c,v
retrieving revision 1.42
diff -u -p -r1.42 kz-location-entry-action.c
--- src/actions/kz-location-entry-action.c	12 Jun 2005 23:32:06 -0000	1.42
+++ src/actions/kz-location-entry-action.c	13 Jun 2005 15:53:50 -0000
@@ -563,6 +563,22 @@ cb_profile_global_changed (KzProfile *pr
 	                               kz_history_unset_completion (KZ_HISTORY_ACTION(action), entry);
                         }
 		}
+	case 'i':
+		if (strcmp(key, "use_inline_completion") == 0)
+		{
+			GtkAction *action;
+	                
+			action = g_object_get_data(G_OBJECT(entry),
+        			        	   KZ_LOCATION_ENTRY_ACTION_KEY);
+			if (action && KZ_IS_HISTORY_ACTION(action))
+                        {
+		                gboolean inline_completion = FALSE;
+        		        KZ_CONF_GET("Global", "use_inline_completion",
+					    inline_completion, BOOL);
+				kz_history_set_inline_completion(KZ_HISTORY_ACTION(action),
+								 inline_completion);
+			}
+		}
 	default:
 		break;
 	}
Index: src/prefs_ui/prefs_entry.c
===================================================================
RCS file: /cvsroot/kazehakase/kazehakase/src/prefs_ui/prefs_entry.c,v
retrieving revision 1.5
diff -u -p -r1.5 prefs_entry.c
--- src/prefs_ui/prefs_entry.c	13 Feb 2005 13:20:36 -0000	1.5
+++ src/prefs_ui/prefs_entry.c	13 Jun 2005 15:53:50 -0000
@@ -47,6 +47,7 @@ typedef struct _KzPrefsEntry
 	GtkWidget     *main_vbox;
 	GtkWidget     *open_in_new_tab;
 	GtkWidget     *auto_completion;
+	GtkWidget     *inline_completion;
 	gboolean       changed;
 } KzPrefsEntry;
 
@@ -66,6 +67,18 @@ cb_changed (GtkWidget *widget, KzPrefsEn
 	prefsui->changed = TRUE;
 }
 
+static void
+cb_inline_changed (GtkWidget *widget, KzPrefsEntry *prefsui)
+{
+	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
+	{
+		gtk_toggle_button_set_active
+			(GTK_TOGGLE_BUTTON(prefsui->auto_completion), TRUE);
+	}
+	
+	cb_changed(widget, prefsui);
+}
+
 
 static GtkWidget *
 prefs_entry_create (void)
@@ -75,6 +88,7 @@ prefs_entry_create (void)
 	GtkWidget *label;
 	GtkWidget *check;
 	gboolean newtab = FALSE, autocompletion = FALSE;
+	gboolean inline_completion = FALSE;
 
 	main_vbox = gtk_vbox_new(FALSE, 0);
 	prefsui->main_vbox = main_vbox;
@@ -113,6 +127,17 @@ prefs_entry_create (void)
 			 G_CALLBACK(cb_changed), prefsui);
 	gtk_widget_show(check);
 
+	/* inline-completion */
+	check = gtk_check_button_new_with_mnemonic(_("Use _inline-completion in URL entry box"));
+	prefsui->inline_completion = check;
+	gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 2);
+	KZ_CONF_GET("Global", "use_inline_completion", inline_completion, BOOL);
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
+				     inline_completion);
+	g_signal_connect(check, "toggled",
+			 G_CALLBACK(cb_inline_changed), prefsui);
+	gtk_widget_show(check);
+
 	prefsui->changed = FALSE;
 
 	return main_vbox;
@@ -131,7 +156,7 @@ prefs_entry_response (GtkWidget *widget,
 	case GTK_RESPONSE_ACCEPT:
 	case GTK_RESPONSE_APPLY:
 	{
-		gboolean newtab, autocompletion;
+		gboolean newtab, autocompletion, inline_completion;
 
 		if (!prefsui->changed)
 			break;
@@ -148,6 +173,13 @@ prefs_entry_response (GtkWidget *widget,
 		/* Should change the section name? */
 		KZ_CONF_SET("Global", "use_auto_completion", autocompletion, BOOL);
 
+		/* inline-completion */
+		inline_completion = gtk_toggle_button_get_active
+			(GTK_TOGGLE_BUTTON(prefsui->inline_completion));
+		/* Should change the section name? */
+		KZ_CONF_SET("Global", "use_inline_completion",
+			    inline_completion, BOOL);
+
                 prefsui->changed = FALSE;
 
 		break;


Kazehakase-devel メーリングリストの案内
Back to archive index