[gnumeric] GUI: Inhibit typing an underline style in the format dialog.



commit 182f8db04712ca358f11453f132dbc64c0532e34
Author: Morten Welinder <terra gnome org>
Date:   Sun Mar 18 13:06:48 2012 -0400

    GUI: Inhibit typing an underline style in the format dialog.
    
    Also use Gtk's combo, not goffice's.

 NEWS                             |    1 +
 src/dialogs/ChangeLog            |    6 ++++++
 src/dialogs/dialog-cell-format.c |   28 +++++++++++++++++++---------
 3 files changed, 26 insertions(+), 9 deletions(-)
---
diff --git a/NEWS b/NEWS
index 318b3e9..01a03f5 100644
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,7 @@ Morten:
 	* Improve test suite.
 	* Lower per-cell memory usage.
 	* Fix INTERPOLATION crash.  [#672154]
+	* Inhibit typing underline style in format dialog.
 
 --------------------------------------------------------------------------
 Gnumeric 1.11.2
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index a4740fe..10210d1 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,9 @@
+2012-03-18  Morten Welinder  <terra gnome org>
+
+	* dialog-cell-format.c (fmt_dialog_init_font_page): Convert from
+	GoComboText to GtkComboBoxText.  Make underline combo's entry not
+	take focus and not editable.
+
 2012-03-16  Morten Welinder  <terra gnome org>
 
 	* dialog-quit.c (url_renderer_func): Use g_uri_unescape_string,
diff --git a/src/dialogs/dialog-cell-format.c b/src/dialogs/dialog-cell-format.c
index 114a92c..328d673 100644
--- a/src/dialogs/dialog-cell-format.c
+++ b/src/dialogs/dialog-cell-format.c
@@ -784,15 +784,17 @@ cb_font_script_toggle (GtkToggleButton *button, FormatState *state)
 }
 
 static gboolean
-cb_font_underline_changed (G_GNUC_UNUSED GtkWidget *ct,
-			   char *new_text, FormatState *state)
+cb_font_underline_changed (GtkComboBoxText *combo,
+			   FormatState *state)
 {
 	GnmUnderline res = UNDERLINE_NONE;
 	int i;
+	char *new_text = gtk_combo_box_text_get_active_text (combo);
 
-	/* ignore the clear while assigning a new value */
-	if (!state->enable_edit || new_text == NULL || *new_text == '\0')
+	if (!state->enable_edit) {
+		g_free (new_text);
 		return FALSE;
+	}
 
 	for (i = G_N_ELEMENTS (underline_types); i-- > 0; )
 		if (go_utf8_collate_casefold (new_text, g_dpgettext2 (NULL, "underline", underline_types[i].Cname)) == 0) {
@@ -801,6 +803,7 @@ cb_font_underline_changed (G_GNUC_UNUSED GtkWidget *ct,
 		}
 
 	font_selector_set_underline (state->font.selector, res);
+	g_free (new_text);
 	return TRUE;
 }
 
@@ -811,7 +814,8 @@ fmt_dialog_init_font_page (FormatState *state)
 	GtkWidget *tmp = font_selector_new ();
 	FontSelector *font_widget = FONT_SELECTOR (tmp);
 	GtkWidget *container = go_gtk_builder_get_widget (state->gui, "font-grid");
-	GtkWidget *uline = go_combo_text_new_default ();
+	GtkWidget *uline = gtk_combo_box_text_new_with_entry ();
+	GtkEntry *uline_entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (uline)));
 	char const *uline_str;
 	GtkWidget *strike = go_gtk_builder_get_widget (state->gui, "strikethrough_button");
 	gboolean   strikethrough = FALSE;
@@ -847,17 +851,23 @@ fmt_dialog_init_font_page (FormatState *state)
 					  gnm_style_get_font_size (state->style));
 
 	for (i = 0; i < (int)G_N_ELEMENTS (underline_types); i++)
-		go_combo_text_add_item	(GO_COMBO_TEXT (uline), g_dpgettext2 (NULL, "underline", underline_types[i].Cname));
+		gtk_combo_box_text_append_text
+			(GTK_COMBO_BOX_TEXT (uline),
+			 g_dpgettext2 (NULL, "underline",
+				       underline_types[i].Cname));
 	if (0 == (state->conflicts & (1 << MSTYLE_FONT_UNDERLINE))) {
 		GnmUnderline ut = gnm_style_get_font_uline (state->style);
 		uline_str = g_dpgettext2 (NULL, "underline", underline_types[ut].Cname);
 		font_selector_set_underline (state->font.selector, ut);
 	} else
 		uline_str = "";
-	go_combo_text_set_text	(GO_COMBO_TEXT (uline), uline_str,
-				 GO_COMBO_TEXT_FROM_TOP);
+	gtk_entry_set_text (uline_entry, uline_str);
+	g_object_set (uline_entry,
+		      "editable", FALSE,
+		      "can-focus", FALSE,
+		      NULL);
 	g_signal_connect (G_OBJECT (uline),
-			  "entry_changed",
+			  "changed",
 			  G_CALLBACK (cb_font_underline_changed), state);
 	gtk_widget_show_all (uline);
 	gtk_grid_attach (GTK_GRID (container), uline, 3, 2, 1, 1);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]