[evolution] Bug #633779 - GtkComboBoxText issues



commit b09b3e9ccacea345fee998ff20ef01ae043eaeac
Author: Milan Crha <mcrha redhat com>
Date:   Thu Nov 18 13:35:36 2010 +0100

    Bug #633779 - GtkComboBoxText issues

 addressbook/gui/contact-editor/contact-editor.ui  |    8 +++---
 addressbook/gui/contact-editor/e-contact-editor.c |   28 +++++++++++++++++--
 calendar/gui/dialogs/event-page.c                 |   21 ++++++++++++---
 calendar/gui/dialogs/event-page.ui                |    2 +-
 e-util/gtk-compat.h                               |    1 +
 filter/filter.ui                                  |    2 +-
 mail/em-filter-editor.c                           |   16 +++++-----
 mail/mail-config.ui                               |    6 ++--
 modules/mail/em-mailer-prefs.c                    |   30 ++++++++++++--------
 smime/gui/e-cert-selector.c                       |   13 +++++---
 smime/gui/smime-ui.ui                             |    2 +-
 widgets/misc/e-dateedit.c                         |   11 -------
 12 files changed, 87 insertions(+), 53 deletions(-)
---
diff --git a/addressbook/gui/contact-editor/contact-editor.ui b/addressbook/gui/contact-editor/contact-editor.ui
index 1c0dcca..88c90c1 100644
--- a/addressbook/gui/contact-editor/contact-editor.ui
+++ b/addressbook/gui/contact-editor/contact-editor.ui
@@ -376,7 +376,7 @@
                                       </packing>
                                     </child>
                                     <child>
-                                      <object class="GtkComboBoxText" id="combobox-email-1">
+                                      <object class="GtkComboBox" id="combobox-email-1">
                                         <property name="visible">True</property>
                                         <property name="model">model2</property>
                                         <child>
@@ -392,7 +392,7 @@
                                       </packing>
                                     </child>
                                     <child>
-                                      <object class="GtkComboBoxText" id="combobox-email-3">
+                                      <object class="GtkComboBox" id="combobox-email-3">
                                         <property name="visible">True</property>
                                         <property name="model">model3</property>
                                         <child>
@@ -410,7 +410,7 @@
                                       </packing>
                                     </child>
                                     <child>
-                                      <object class="GtkComboBoxText" id="combobox-email-2">
+                                      <object class="GtkComboBox" id="combobox-email-2">
                                         <property name="visible">True</property>
                                         <property name="model">model4</property>
                                         <child>
@@ -428,7 +428,7 @@
                                       </packing>
                                     </child>
                                     <child>
-                                      <object class="GtkComboBoxText" id="combobox-email-4">
+                                      <object class="GtkComboBox" id="combobox-email-4">
                                         <property name="visible">True</property>
                                         <property name="model">model5</property>
                                         <child>
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index e67305b..e179457 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -722,6 +722,8 @@ init_email_record_location (EContactEditor *editor, gint record)
 	GtkWidget *email_entry;
 	gchar     *widget_name;
 	gint       i;
+	GtkTreeIter iter;
+	GtkListStore *store;
 
 	widget_name = g_strdup_printf ("entry-email-%d", record);
 	email_entry = e_builder_get_widget (editor->builder, widget_name);
@@ -731,10 +733,14 @@ init_email_record_location (EContactEditor *editor, gint record)
 	location_combo_box = GTK_COMBO_BOX (e_builder_get_widget (editor->builder, widget_name));
 	g_free (widget_name);
 
-	gtk_list_store_clear (GTK_LIST_STORE (gtk_combo_box_get_model (location_combo_box)));
+	store = GTK_LIST_STORE (gtk_combo_box_get_model (location_combo_box));
+	gtk_list_store_clear (store);
 
 	for (i = 0; i < G_N_ELEMENTS (common_location); i++) {
-		gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (location_combo_box), _(common_location[i].pretty_name));
+		gtk_list_store_append (store, &iter);
+		gtk_list_store_set (store, &iter,
+			0, _(common_location[i].pretty_name),
+			-1);
 	}
 
 	g_signal_connect_swapped (location_combo_box, "changed", G_CALLBACK (gtk_widget_grab_focus), email_entry);
@@ -2371,13 +2377,29 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id)
 		const gchar *text = gtk_entry_get_text (GTK_ENTRY (widget));
 		e_contact_set (contact, field_id, (gchar *) text);
 	}
-	else if (GTK_IS_COMBO_BOX (widget)) {
+	else if (GTK_IS_COMBO_BOX_TEXT (widget)) {
 		gchar *text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (widget));
 
 		e_contact_set (contact, field_id, text);
 
 		g_free (text);
 	}
+	else if (GTK_IS_COMBO_BOX (widget)) {
+		GtkTreeIter iter;
+		gchar *text = NULL;
+
+		if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) {
+			GtkListStore *store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (widget)));
+
+			gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
+				0, &text,
+				-1);
+		}
+
+		e_contact_set (contact, field_id, text);
+
+		g_free (text);
+	}
 	else if (GTK_IS_TEXT_VIEW (widget)) {
 		GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
 		GtkTextIter    start, end;
diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c
index 32c2c18..06ba147 100644
--- a/calendar/gui/dialogs/event-page.c
+++ b/calendar/gui/dialogs/event-page.c
@@ -2859,6 +2859,8 @@ init_widgets (EventPage *epage)
 	GtkTreeSelection *selection;
 	gboolean active;
 	ECal *client;
+	GtkTreeIter iter;
+	GtkListStore *store;
 
 	editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage));
 	client = comp_editor_get_client (editor);
@@ -3025,17 +3027,28 @@ init_widgets (EventPage *epage)
 		break;
 	}
 
+	store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (priv->alarm_time_combo)));
 	if (combo_label) {
-		gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (priv->alarm_time_combo), combo_label);
+		gtk_list_store_append (store, &iter);
+		gtk_list_store_set (store, &iter,
+			0, combo_label,
+			-1);
 		g_free (combo_label);
 		priv->alarm_map = alarm_map_with_user_time;
 	} else {
 		priv->alarm_map = alarm_map_without_user_time;
 	}
 
-	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (priv->alarm_time_combo), _("Customize"));
-	/* Translators: "None" for "No alarm set" */
-	gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (priv->alarm_time_combo), C_("cal-alarms", "None"));
+	gtk_list_store_append (store, &iter);
+	gtk_list_store_set (store, &iter,
+		0, _("Customize"),
+		-1);
+
+	gtk_list_store_insert (store, &iter, 0);
+	gtk_list_store_set (store, &iter,
+		/* Translators: "None" for "No alarm set" */
+		0, C_("cal-alarms", "None"),
+		-1);
 
 	g_signal_connect_swapped (
 		priv->alarm_time_combo, "changed",
diff --git a/calendar/gui/dialogs/event-page.ui b/calendar/gui/dialogs/event-page.ui
index fe3ece2..1791904 100644
--- a/calendar/gui/dialogs/event-page.ui
+++ b/calendar/gui/dialogs/event-page.ui
@@ -1059,7 +1059,7 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkComboBoxText" id="alarm-time-combobox">
+                      <object class="GtkComboBox" id="alarm-time-combobox">
                         <property name="visible">True</property>
                         <property name="add_tearoffs">False</property>
                         <property name="focus_on_click">True</property>
diff --git a/e-util/gtk-compat.h b/e-util/gtk-compat.h
index ab4a872..bbee371 100644
--- a/e-util/gtk-compat.h
+++ b/e-util/gtk-compat.h
@@ -11,6 +11,7 @@
 #define gtk_combo_box_text_prepend_text		gtk_combo_box_prepend_text
 #define gtk_combo_box_text_get_active_text	gtk_combo_box_get_active_text
 #define GTK_COMBO_BOX_TEXT			GTK_COMBO_BOX
+#define GTK_IS_COMBO_BOX_TEXT			GTK_IS_COMBO_BOX
 #define GtkComboBoxText				GtkComboBox
 
 /* The below can be used only once in sources */
diff --git a/filter/filter.ui b/filter/filter.ui
index a7e981c..b2e11f6 100644
--- a/filter/filter.ui
+++ b/filter/filter.ui
@@ -107,7 +107,7 @@
       </packing>
     </child>
     <child>
-      <object class="GtkComboBoxText" id="filter_source_combobox">
+      <object class="GtkComboBox" id="filter_source_combobox">
         <property name="visible">True</property>
         <property name="model">model1</property>
         <child>
diff --git a/mail/em-filter-editor.c b/mail/em-filter-editor.c
index ca351e8..ca41486 100644
--- a/mail/em-filter-editor.c
+++ b/mail/em-filter-editor.c
@@ -35,9 +35,6 @@
 #include "em-filter-editor.h"
 #include "em-filter-rule.h"
 
-/* backward-compatibility cruft */
-#include "e-util/gtk-compat.h"
-
 static gpointer parent_class;
 
 static EFilterRule *
@@ -170,16 +167,19 @@ em_filter_editor_construct (EMFilterEditor *fe,
 	GtkWidget *combobox;
 	gint i;
 	GtkTreeViewColumn *column;
-	GtkTreeModel *model;
+	GtkTreeIter iter;
+	GtkListStore *store;
 	GSList *sources = NULL;
 
 	combobox = e_builder_get_widget (builder, "filter_source_combobox");
-	model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
-	gtk_list_store_clear (GTK_LIST_STORE (model));
+	store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (combobox)));
+	gtk_list_store_clear (store);
 
 	for (i = 0; source_names[i].source; i++) {
-		gtk_combo_box_text_append_text (
-			GTK_COMBO_BOX_TEXT (combobox), source_names[i].name);
+		gtk_list_store_append (store, &iter);
+		gtk_list_store_set (store, &iter,
+			0, source_names[i].name,
+			-1);
 		sources = g_slist_append (sources, g_strdup (source_names[i].source));
 	}
 
diff --git a/mail/mail-config.ui b/mail/mail-config.ui
index 171205c..7252206 100644
--- a/mail/mail-config.ui
+++ b/mail/mail-config.ui
@@ -2704,7 +2704,7 @@ For example: "Work" or "Personal"</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkComboBoxText" id="comboboxEmptyTrashDays">
+                          <object class="GtkComboBox" id="comboboxEmptyTrashDays">
                             <property name="visible">True</property>
                             <property name="model">model1</property>
                             <child>
@@ -3342,7 +3342,7 @@ For example: "Work" or "Personal"</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkComboBoxText" id="default_junk_plugin">
+                          <object class="GtkComboBox" id="default_junk_plugin">
                             <property name="visible">True</property>
                           </object>
                           <packing>
@@ -3427,7 +3427,7 @@ For example: "Work" or "Personal"</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkComboBoxText" id="junk_empty_combobox">
+                          <object class="GtkComboBox" id="junk_empty_combobox">
                             <property name="visible">True</property>
                             <property name="model">model2</property>
                             <child>
diff --git a/modules/mail/em-mailer-prefs.c b/modules/mail/em-mailer-prefs.c
index 2c4a2eb..b03ac60 100644
--- a/modules/mail/em-mailer-prefs.c
+++ b/modules/mail/em-mailer-prefs.c
@@ -544,21 +544,24 @@ emmp_empty_trash_init (EMMailerPrefs *prefs,
                        GtkComboBox *combo_box)
 {
 	gint days, hist = 0, ii;
-	GtkTreeModel *model;
+	GtkListStore *store;
+	GtkTreeIter iter;
 
 	days = gconf_client_get_int (
 		prefs->gconf,
 		"/apps/evolution/mail/trash/empty_on_exit_days", NULL);
 
-	model = gtk_combo_box_get_model (combo_box);
-	gtk_list_store_clear (GTK_LIST_STORE (model));
+	store = GTK_LIST_STORE (gtk_combo_box_get_model (combo_box));
+	gtk_list_store_clear (store);
 
 	for (ii = 0; ii < G_N_ELEMENTS (empty_trash_frequency); ii++) {
 		if (days >= empty_trash_frequency[ii].days)
 			hist = ii;
-		gtk_combo_box_text_append_text (
-			GTK_COMBO_BOX_TEXT (combo_box),
-			gettext (empty_trash_frequency[ii].label));
+
+		gtk_list_store_append (store, &iter);
+		gtk_list_store_set (store, &iter,
+			0,  gettext (empty_trash_frequency[ii].label),
+			-1);
 	}
 
 	g_signal_connect (
@@ -589,21 +592,24 @@ emmp_empty_junk_init (EMMailerPrefs *prefs,
                       GtkComboBox *combo_box)
 {
 	gint days, hist = 0, ii;
-	GtkTreeModel *model;
+	GtkListStore *store;
+	GtkTreeIter iter;
 
 	days = gconf_client_get_int (
 		prefs->gconf,
 		"/apps/evolution/mail/junk/empty_on_exit_days", NULL);
 
-	model = gtk_combo_box_get_model (combo_box);
-	gtk_list_store_clear (GTK_LIST_STORE (model));
+	store = GTK_LIST_STORE (gtk_combo_box_get_model (combo_box));
+	gtk_list_store_clear (store);
 
 	for (ii = 0; ii < G_N_ELEMENTS (empty_trash_frequency); ii++) {
 		if (days >= empty_trash_frequency[ii].days)
 			hist = ii;
-		gtk_combo_box_text_append_text (
-			GTK_COMBO_BOX_TEXT (combo_box),
-			gettext (empty_trash_frequency[ii].label));
+
+		gtk_list_store_append (store, &iter);
+		gtk_list_store_set (store, &iter,
+			0, gettext (empty_trash_frequency[ii].label),
+			-1);
 	}
 
 	g_signal_connect (
diff --git a/smime/gui/e-cert-selector.c b/smime/gui/e-cert-selector.c
index 5bbf3af..f20baa5 100644
--- a/smime/gui/e-cert-selector.c
+++ b/smime/gui/e-cert-selector.c
@@ -37,9 +37,6 @@
 #include "e-util/e-util.h"
 #include "e-util/e-util-private.h"
 
-/* backward-compatibility cruft */
-#include "e-util/gtk-compat.h"
-
 struct _ECertSelectorPrivate {
 	CERTCertList *certlist;
 
@@ -153,6 +150,8 @@ e_cert_selector_new (gint type, const gchar *currentid)
 	GtkBuilder *builder;
 	GtkWidget *content_area;
 	GtkWidget *w;
+	GtkListStore *store;
+	GtkTreeIter iter;
 	gint n=0, active=0;
 
 	ecs = g_object_new (e_cert_selector_get_type (), NULL);
@@ -179,7 +178,8 @@ e_cert_selector_new (gint type, const gchar *currentid)
 		break;
 	}
 
-	gtk_list_store_clear (GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (p->combobox))));
+	store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (p->combobox)));
+	gtk_list_store_clear (store);
 
 	certlist = CERT_FindUserCertsByUsage (CERT_GetDefaultCertDB (), usage, FALSE, TRUE, NULL);
 	ecs->priv->certlist = certlist;
@@ -187,7 +187,10 @@ e_cert_selector_new (gint type, const gchar *currentid)
 		node = CERT_LIST_HEAD (certlist);
 		while (!CERT_LIST_END (node, certlist)) {
 			if (node->cert->nickname || node->cert->emailAddr) {
-				gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (p->combobox), node->cert->nickname?node->cert->nickname:node->cert->emailAddr);
+				gtk_list_store_append (store, &iter);
+				gtk_list_store_set (store, &iter,
+					0, node->cert->nickname?node->cert->nickname:node->cert->emailAddr,
+					-1);
 
 				if (currentid != NULL
 				    && ((node->cert->nickname != NULL && strcmp (node->cert->nickname, currentid) == 0)
diff --git a/smime/gui/smime-ui.ui b/smime/gui/smime-ui.ui
index 0f876ea..3d3dd28 100644
--- a/smime/gui/smime-ui.ui
+++ b/smime/gui/smime-ui.ui
@@ -1332,7 +1332,7 @@
           </packing>
         </child>
         <child>
-          <object class="GtkComboBoxText" id="cert_combobox">
+          <object class="GtkComboBox" id="cert_combobox">
             <property name="visible">True</property>
             <property name="model">model1</property>
             <child>
diff --git a/widgets/misc/e-dateedit.c b/widgets/misc/e-dateedit.c
index a1a385c..d0b9b7e 100644
--- a/widgets/misc/e-dateedit.c
+++ b/widgets/misc/e-dateedit.c
@@ -578,17 +578,6 @@ create_children			(EDateEdit	*dedit)
 		"has-entry", TRUE,
 		"entry-text-column", 0,
 		NULL);
-
-	{
-	GtkCellRenderer *cell;
-
-	gtk_cell_layout_clear (GTK_CELL_LAYOUT (priv->time_combo));
-
-	cell = gtk_cell_renderer_text_new ();
-	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->time_combo), cell, TRUE);
-	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->time_combo), cell, "text", 0, NULL);
-	}
-
 #else
 	priv->time_combo = gtk_combo_box_entry_new_with_model (
 		GTK_TREE_MODEL (time_store), 0);



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