[Xfce4-commits] [apps/xfce4-dict] 25/43: Replace gtk_combo_box_* by gtk_combo_box_text*

noreply at xfce.org noreply at xfce.org
Tue Nov 1 00:31:38 CET 2016


This is an automated email from the git hooks/post-receive script.

andre pushed a commit to branch master
in repository apps/xfce4-dict.

commit 2d26c5c9d41046c8b0beea108827c9c4eeec1642
Author: Andre Miranda <andre42m at gmail.com>
Date:   Sun Aug 21 16:38:14 2016 -0300

    Replace gtk_combo_box_* by gtk_combo_box_text*
---
 lib/common.c |  2 +-
 lib/dictd.c  |  4 ++--
 lib/gui.c    |  4 ++--
 lib/prefs.c  | 30 +++++++++++-------------------
 lib/spell.c  | 13 +++++++------
 5 files changed, 23 insertions(+), 30 deletions(-)

diff --git a/lib/common.c b/lib/common.c
index 03a5a2b..f16b81f 100644
--- a/lib/common.c
+++ b/lib/common.c
@@ -241,7 +241,7 @@ void dict_search_word(DictData *dd, const gchar *word)
 	}
 	/* remove leading and trailing spaces */
 	g_strstrip(dd->searched_word);
-	gtk_combo_box_prepend_text(GTK_COMBO_BOX(dd->main_combo), dd->searched_word);
+	gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(dd->main_combo), dd->searched_word);
 
 	dict_gui_clear_text_buffer(dd);
 
diff --git a/lib/dictd.c b/lib/dictd.c
index bcaa8b3..38ca631 100644
--- a/lib/dictd.c
+++ b/lib/dictd.c
@@ -847,7 +847,7 @@ void dict_dictd_get_list(GtkWidget *button, DictData *dd)
 	i = gtk_tree_model_iter_n_children(gtk_combo_box_get_model(GTK_COMBO_BOX(dict_combo)), NULL);
 	for (i -= 1; i > 2; i--)  /* first three entries (*, ! and ----) should always exist */
 	{
-		gtk_combo_box_remove_text(GTK_COMBO_BOX(dict_combo), i);
+		gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(dict_combo), i);
 	}
 
 	/* parse output */
@@ -859,7 +859,7 @@ void dict_dictd_get_list(GtkWidget *button, DictData *dd)
 	i = 0;
 	while (i < max_lines && lines[i][0] != '.')
 	{
-		gtk_combo_box_append_text(GTK_COMBO_BOX(dict_combo), lines[i]);
+		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(dict_combo), lines[i]);
 		i++;
 	}
 
diff --git a/lib/gui.c b/lib/gui.c
index 237e0a3..7bb1513 100644
--- a/lib/gui.c
+++ b/lib/gui.c
@@ -558,7 +558,7 @@ static void combo_changed_cb(GtkComboBox *combo, DictData *dd)
 
 	if (gtk_combo_box_get_active_iter(combo, &iter))
 	{
-		gchar *text = gtk_combo_box_get_active_text(combo);
+		gchar *text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo));
 		dict_search_word(dd, text);
 		g_free(text);
 	}
@@ -842,7 +842,7 @@ void dict_gui_create_main_window(DictData *dd)
 	gtk_widget_show(label_box);
 	gtk_box_pack_start(GTK_BOX(entry_box), label_box, TRUE, TRUE, 5);
 
-	dd->main_combo = gtk_combo_box_entry_new_text();
+	dd->main_combo = gtk_combo_box_text_new_with_entry();
 	gtk_widget_show(dd->main_combo);
 	gtk_box_pack_start(GTK_BOX(label_box), dd->main_combo, TRUE, TRUE, 0);
 	g_signal_connect(dd->main_combo, "changed", G_CALLBACK(combo_changed_cb), dd);
diff --git a/lib/prefs.c b/lib/prefs.c
index d7f0815..0a40614 100644
--- a/lib/prefs.c
+++ b/lib/prefs.c
@@ -92,8 +92,8 @@ void dict_prefs_dialog_response(GtkWidget *dlg, gint response, DictData *dd)
 
 	/* check some values before actually saving the settings in case we need to return to
 	 * the dialog */
-	dictionary = gtk_combo_box_get_active_text(
-		GTK_COMBO_BOX(g_object_get_data(G_OBJECT(dlg), "dict_combo")));
+	dictionary = gtk_combo_box_text_get_active_text(
+		GTK_COMBO_BOX_TEXT(g_object_get_data(G_OBJECT(dlg), "dict_combo")));
 	if (! NZV(dictionary) || dictionary[0] == '-')
 	{
 		dict_show_msgbox(dd, GTK_MESSAGE_ERROR, _("You have chosen an invalid dictionary."));
@@ -122,8 +122,8 @@ void dict_prefs_dialog_response(GtkWidget *dlg, gint response, DictData *dd)
 	gtk_widget_set_sensitive(dd->radio_button_web, NZV(dd->web_url));
 
 	/* MODE SPELL */
-	dictionary = gtk_combo_box_get_active_text(
-			GTK_COMBO_BOX(g_object_get_data(G_OBJECT(dlg), "spell_combo")));
+	dictionary = gtk_combo_box_text_get_active_text(
+			GTK_COMBO_BOX_TEXT(g_object_get_data(G_OBJECT(dlg), "spell_combo")));
 	if (NZV(dictionary))
 	{
 		g_free(dd->spell_dictionary);
@@ -476,11 +476,11 @@ GtkWidget *dict_prefs_dialog_show(GtkWidget *parent, DictData *dd)
 		/* dictionary */
 		label3 = gtk_label_new_with_mnemonic(_("Dictionary:"));
 
-		dict_combo = gtk_combo_box_new_text();
-		gtk_combo_box_append_text(GTK_COMBO_BOX(dict_combo), _("* (use all)"));
-		gtk_combo_box_append_text(GTK_COMBO_BOX(dict_combo),
+		dict_combo = gtk_combo_box_text_new();
+		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(dict_combo), _("* (use all)"));
+		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(dict_combo),
 											_("! (use all, stop after first match)"));
-		gtk_combo_box_append_text(GTK_COMBO_BOX(dict_combo), "----------------");
+		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(dict_combo), "----------------");
 		if (dd->dictionary != NULL)
 		{
 			if (dd->dictionary[0] == '*')
@@ -489,7 +489,7 @@ GtkWidget *dict_prefs_dialog_show(GtkWidget *parent, DictData *dd)
 				gtk_combo_box_set_active(GTK_COMBO_BOX(dict_combo), 1);
 			else
 			{
-				gtk_combo_box_append_text(GTK_COMBO_BOX(dict_combo), dd->dictionary);
+				gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(dict_combo), dd->dictionary);
 				gtk_combo_box_set_active(GTK_COMBO_BOX(dict_combo), 3);
 			}
 		}
@@ -599,9 +599,7 @@ GtkWidget *dict_prefs_dialog_show(GtkWidget *parent, DictData *dd)
 	 */
 #define PAGE_SPELL /* only for navigation in Geany's symbol list ;-) */
 	{
-		GtkWidget *grid, *label_help, *spell_entry, *spell_combo, *button_refresh, *image, *icon;
-		GtkListStore *store;
-		GtkCellRenderer *renderer;
+		GtkWidget *grid, *label_help, *spell_entry, *spell_combo, *button_refresh, *icon;
 
 		notebook_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
 		gtk_widget_show(notebook_vbox);
@@ -637,14 +635,9 @@ GtkWidget *dict_prefs_dialog_show(GtkWidget *parent, DictData *dd)
 		label2 = gtk_label_new_with_mnemonic(_("Dictionary:"));
 		gtk_widget_show(label2);
 
-		store = gtk_list_store_new(1, G_TYPE_STRING);
-		spell_combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
+		spell_combo = gtk_combo_box_text_new ();
 		g_object_set_data(G_OBJECT(spell_combo), "spell_entry", spell_entry);
 
-		renderer = gtk_cell_renderer_text_new();
-		gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(spell_combo), renderer, TRUE);
-		gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(spell_combo), renderer, "text", 0);
-
 		dict_spell_get_dictionaries(dd, spell_combo);
 		g_signal_connect(spell_combo, "changed", G_CALLBACK(spell_combo_changed_cb), dd);
 		gtk_widget_show(spell_combo);
@@ -658,7 +651,6 @@ GtkWidget *dict_prefs_dialog_show(GtkWidget *parent, DictData *dd)
 		g_object_set_data(G_OBJECT(spell_entry), "spell_combo", spell_combo);
 		g_object_set_data(G_OBJECT(dialog), "spell_combo", spell_combo);
 		g_object_set_data(G_OBJECT(dialog), "spell_entry", spell_entry);
-		g_object_unref(store);
 
 		spell_entry_focus_cb(GTK_ENTRY(spell_entry), NULL, icon); /* initially set the icon */
 
diff --git a/lib/spell.c b/lib/spell.c
index 00c4bc8..ebadc2f 100644
--- a/lib/spell.c
+++ b/lib/spell.c
@@ -339,12 +339,12 @@ static gchar **get_aspell_dicts(const gchar *str)
 
 void dict_spell_get_dictionaries(DictData *dd, GtkWidget *spell_combo)
 {
-	GtkTreeModel *model;
+	GtkComboBoxText *combo;
 	const gchar *entry_cmd = gtk_entry_get_text(
 		GTK_ENTRY(g_object_get_data(G_OBJECT(spell_combo), "spell_entry")));
 
-	model = gtk_combo_box_get_model(GTK_COMBO_BOX(spell_combo));
-	gtk_list_store_clear(GTK_LIST_STORE(model));
+	combo = GTK_COMBO_BOX_TEXT (spell_combo);
+	gtk_combo_box_text_remove_all (combo);
 
 	if (*entry_cmd != '\0')
 	{
@@ -371,6 +371,7 @@ void dict_spell_get_dictionaries(DictData *dd, GtkWidget *spell_combo)
 		{
 			gchar **list;
 			guint i, len;
+			guint item_count = 0;
 
 			list = (use_enchant) ? get_enchant_dicts(tmp) : get_aspell_dicts(tmp);
 			len = g_strv_length(list);
@@ -378,10 +379,10 @@ void dict_spell_get_dictionaries(DictData *dd, GtkWidget *spell_combo)
 			{
 				if (NZV(list[i]))
 				{
-					gtk_list_store_append(GTK_LIST_STORE(model), &iter);
-					gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, list[i], -1);
+					gtk_combo_box_text_append_text (combo, list[i]);
 					if (strcmp(dd->spell_dictionary, list[i]) == 0)
-						gtk_combo_box_set_active_iter(GTK_COMBO_BOX(spell_combo), &iter);
+						gtk_combo_box_set_active(GTK_COMBO_BOX(combo), item_count);
+					item_count++;
 				}
 			}
 			g_strfreev(list);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list