[gtk+/gtk-2-24] Don't add a second cell renderer
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] Don't add a second cell renderer
- Date: Mon, 18 Oct 2010 12:21:10 +0000 (UTC)
commit b94372f199ff2eab34c349aa6410b5a90a4e7eb3
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Oct 18 08:19:59 2010 -0400
Don't add a second cell renderer
When has-entry is TRUE, GtkComboBox already adds a cell renderer
for the text column, so avoid adding a second one in GtkComboBoxText.
https://bugzilla.gnome.org/show_bug.cgi?id=632381
(cherry picked from commit b613cc64786a95ea069d3d308906133165062315)
gtk/gtkcomboboxtext.c | 48 ++++++++++++++++++++++++++++++++++++------------
1 files changed, 36 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkcomboboxtext.c b/gtk/gtkcomboboxtext.c
index e19da43..ea508b6 100644
--- a/gtk/gtkcomboboxtext.c
+++ b/gtk/gtkcomboboxtext.c
@@ -45,30 +45,50 @@
G_DEFINE_TYPE (GtkComboBoxText, gtk_combo_box_text, GTK_TYPE_COMBO_BOX);
-static void
-gtk_combo_box_text_class_init (GtkComboBoxTextClass *klass)
+static GObject *
+gtk_combo_box_text_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
+ GObject *object;
+
+ object = G_OBJECT_CLASS (gtk_combo_box_text_parent_class)->constructor
+ (type, n_construct_properties, construct_properties);
+
+ if (!gtk_combo_box_get_has_entry (GTK_COMBO_BOX (object)))
+ {
+ GtkCellRenderer *cell;
+
+ cell = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), cell, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), cell,
+ "text", 0,
+ NULL);
+ }
+
+ return object;
}
static void
gtk_combo_box_text_init (GtkComboBoxText *combo_box)
{
GtkListStore *store;
- GtkCellRenderer *cell;
store = gtk_list_store_new (1, G_TYPE_STRING);
gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
g_object_unref (store);
+}
- gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (combo_box), 0);
+static void
+gtk_combo_box_text_class_init (GtkComboBoxTextClass *klass)
+{
+ GObjectClass *object_class;
- cell = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
- "text", 0,
- NULL);
+ object_class = (GObjectClass *)klass;
+ object_class->constructor = gtk_combo_box_text_constructor;
}
+
/**
* gtk_combo_box_text_new:
*
@@ -82,10 +102,11 @@ gtk_combo_box_text_init (GtkComboBoxText *combo_box)
GtkWidget *
gtk_combo_box_text_new (void)
{
- return g_object_new (GTK_TYPE_COMBO_BOX_TEXT, NULL);
+ return g_object_new (GTK_TYPE_COMBO_BOX_TEXT,
+ "entry-text-column", 0,
+ NULL);
}
-
/**
* gtk_combo_box_text_new_with_entry:
*
@@ -99,7 +120,10 @@ gtk_combo_box_text_new (void)
GtkWidget *
gtk_combo_box_text_new_with_entry (void)
{
- return g_object_new (GTK_TYPE_COMBO_BOX_TEXT, "has-entry", TRUE, NULL);
+ return g_object_new (GTK_TYPE_COMBO_BOX_TEXT,
+ "has-entry", TRUE,
+ "entry-text-column", 0,
+ NULL);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]