aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2010-10-28 03:43:25 +0800
committerMilan Crha <mcrha@redhat.com>2010-10-28 03:43:25 +0800
commit2de2e7f12f3b4e5944732d1c2172a3d174d5a219 (patch)
tree8630b1ae27ddbaa9f09656b21fe512f31f15118a
parent9662ac73ccc857e04b941596eb58f72ecf01b76f (diff)
downloadgsoc2013-evolution-2de2e7f12f3b4e5944732d1c2172a3d174d5a219.tar.gz
gsoc2013-evolution-2de2e7f12f3b4e5944732d1c2172a3d174d5a219.tar.zst
gsoc2013-evolution-2de2e7f12f3b4e5944732d1c2172a3d174d5a219.zip
Workaround GtkComboBoxText/GtkComboBoxEntry in .ui files
-rw-r--r--addressbook/gui/contact-editor/contact-editor.ui8
-rw-r--r--calendar/gui/dialogs/event-page.ui2
-rw-r--r--e-util/e-datetime-format.c2
-rw-r--r--e-util/e-util.c8
-rw-r--r--e-util/gtk-compat.h66
-rw-r--r--filter/filter.ui2
-rw-r--r--mail/mail-config.ui6
-rw-r--r--smime/gui/smime-ui.ui2
-rw-r--r--widgets/misc/e-dateedit.c24
9 files changed, 103 insertions, 17 deletions
diff --git a/addressbook/gui/contact-editor/contact-editor.ui b/addressbook/gui/contact-editor/contact-editor.ui
index 88c90c1c31..1c0dcca2ac 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="GtkComboBox" id="combobox-email-1">
+ <object class="GtkComboBoxText" id="combobox-email-1">
<property name="visible">True</property>
<property name="model">model2</property>
<child>
@@ -392,7 +392,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox-email-3">
+ <object class="GtkComboBoxText" id="combobox-email-3">
<property name="visible">True</property>
<property name="model">model3</property>
<child>
@@ -410,7 +410,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox-email-2">
+ <object class="GtkComboBoxText" id="combobox-email-2">
<property name="visible">True</property>
<property name="model">model4</property>
<child>
@@ -428,7 +428,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox-email-4">
+ <object class="GtkComboBoxText" id="combobox-email-4">
<property name="visible">True</property>
<property name="model">model5</property>
<child>
diff --git a/calendar/gui/dialogs/event-page.ui b/calendar/gui/dialogs/event-page.ui
index 17919048a6..fe3ece21ca 100644
--- a/calendar/gui/dialogs/event-page.ui
+++ b/calendar/gui/dialogs/event-page.ui
@@ -1059,7 +1059,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="alarm-time-combobox">
+ <object class="GtkComboBoxText" 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/e-datetime-format.c b/e-util/e-datetime-format.c
index e78b8cfe5e..f5155be612 100644
--- a/e-util/e-datetime-format.c
+++ b/e-util/e-datetime-format.c
@@ -513,7 +513,7 @@ e_datetime_format_add_setup_widget (GtkWidget *table, gint row, const gchar *com
store = gtk_list_store_new (1, G_TYPE_STRING);
combo = g_object_new (
- GTK_TYPE_COMBO_BOX,
+ GTK_TYPE_COMBO_BOX_TEXT,
"model", store,
"has-entry", TRUE,
"entry-text-column", 0,
diff --git a/e-util/e-util.c b/e-util/e-util.c
index 22f792c3a7..f27b3f3660 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -57,6 +57,14 @@
#include "e-util.h"
#include "e-util-private.h"
+#include "gtk-compat.h"
+
+#if !GTK_CHECK_VERSION (2,23,0)
+ #undef GtkComboBoxText
+ ENSURE_GTK_COMBO_BOX_TEXT_TYPE
+#else
+ ENSURE_GTK_COMBO_BOX_ENTRY_TYPE
+#endif
/**
* e_get_gnome2_user_dir:
diff --git a/e-util/gtk-compat.h b/e-util/gtk-compat.h
index 3b9c7ef2e9..9dfa8a6bc0 100644
--- a/e-util/gtk-compat.h
+++ b/e-util/gtk-compat.h
@@ -12,10 +12,76 @@
#define gtk_combo_box_text_get_active_text gtk_combo_box_get_active_text
#define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX
#define GtkComboBoxText GtkComboBox
+
+/* The below can be used only once in sources */
+#define ENSURE_GTK_COMBO_BOX_TEXT_TYPE \
+ GType gtk_combo_box_text_get_type (void); \
+ typedef struct _GtkComboBoxText GtkComboBoxText; \
+ typedef struct _GtkComboBoxTextClass GtkComboBoxTextClass; \
+ \
+ struct _GtkComboBoxText { \
+ GtkComboBox parent; \
+ }; \
+ \
+ struct _GtkComboBoxTextClass { \
+ GtkComboBoxClass parent_class; \
+ }; \
+ \
+ \
+ G_DEFINE_TYPE (GtkComboBoxText, gtk_combo_box_text, GTK_TYPE_COMBO_BOX) \
+ \
+ static void gtk_combo_box_text_init (GtkComboBoxText *cbt) {} \
+ static void gtk_combo_box_text_class_init (GtkComboBoxTextClass *kl) {}
+
#endif
#if GTK_CHECK_VERSION (2,23,0)
#define GTK_COMBO_BOX_ENTRY GTK_COMBO_BOX
+
+#define ENSURE_GTK_COMBO_BOX_ENTRY_TYPE \
+ GType gtk_combo_box_entry_get_type (void); \
+ typedef struct _GtkComboBoxEntry GtkComboBoxEntry; \
+ typedef struct _GtkComboBoxEntryClass GtkComboBoxEntryClass; \
+ \
+ struct _GtkComboBoxEntry { \
+ GtkComboBoxText parent; \
+ }; \
+ \
+ struct _GtkComboBoxEntryClass { \
+ GtkComboBoxTextClass parent_class; \
+ }; \
+ \
+ G_DEFINE_TYPE (GtkComboBoxEntry, gtk_combo_box_entry, GTK_TYPE_COMBO_BOX_TEXT)\
+ \
+ static GObject * \
+ gtk_combo_box_entry_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties) \
+ { \
+ GObjectConstructParam *params = g_new0 (GObjectConstructParam, n_construct_properties + 1);\
+ GValue val = {0}; \
+ GObject *res; \
+ gint ii; \
+ \
+ for (ii = 0; ii < n_construct_properties; ii++) { \
+ params[ii] = construct_properties[ii]; \
+ } \
+ \
+ g_value_init (&val, G_TYPE_BOOLEAN); \
+ g_value_set_boolean (&val, TRUE); \
+ \
+ params[n_construct_properties].pspec = g_object_class_find_property (G_OBJECT_CLASS (gtk_combo_box_entry_parent_class), "has-entry");\
+ params[n_construct_properties].value = &val; \
+ \
+ res = G_OBJECT_CLASS (gtk_combo_box_entry_parent_class)->constructor (type, n_construct_properties + 1, params);\
+ \
+ g_free (params); \
+ return res; \
+ } \
+ static void gtk_combo_box_entry_init (GtkComboBoxEntry *cbt) {} \
+ static void gtk_combo_box_entry_class_init (GtkComboBoxEntryClass *kl) \
+ { \
+ GObjectClass *object_class = G_OBJECT_CLASS (kl); \
+ object_class->constructor = gtk_combo_box_entry_constructor; \
+ }
#else
#define gtk_combo_box_set_entry_text_column \
gtk_combo_box_entry_set_text_column
diff --git a/filter/filter.ui b/filter/filter.ui
index b2e11f6fc1..a7e981c936 100644
--- a/filter/filter.ui
+++ b/filter/filter.ui
@@ -107,7 +107,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="filter_source_combobox">
+ <object class="GtkComboBoxText" id="filter_source_combobox">
<property name="visible">True</property>
<property name="model">model1</property>
<child>
diff --git a/mail/mail-config.ui b/mail/mail-config.ui
index 7252206a56..171205c94b 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="GtkComboBox" id="comboboxEmptyTrashDays">
+ <object class="GtkComboBoxText" 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="GtkComboBox" id="default_junk_plugin">
+ <object class="GtkComboBoxText" 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="GtkComboBox" id="junk_empty_combobox">
+ <object class="GtkComboBoxText" id="junk_empty_combobox">
<property name="visible">True</property>
<property name="model">model2</property>
<child>
diff --git a/smime/gui/smime-ui.ui b/smime/gui/smime-ui.ui
index 3d3dd28939..0f876ea36e 100644
--- a/smime/gui/smime-ui.ui
+++ b/smime/gui/smime-ui.ui
@@ -1332,7 +1332,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="cert_combobox">
+ <object class="GtkComboBoxText" 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 da3c9dbad5..5045a1d53f 100644
--- a/widgets/misc/e-dateedit.c
+++ b/widgets/misc/e-dateedit.c
@@ -573,11 +573,22 @@ create_children (EDateEdit *dedit)
time_store = gtk_list_store_new (1, G_TYPE_STRING);
#if GTK_CHECK_VERSION(2,23,0)
priv->time_combo = g_object_new (
- GTK_TYPE_COMBO_BOX,
+ GTK_TYPE_COMBO_BOX_TEXT,
"model", time_store,
"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);
@@ -1581,16 +1592,16 @@ static void
rebuild_time_popup (EDateEdit *dedit)
{
EDateEditPrivate *priv;
- GtkComboBoxText *combo;
+ GtkListStore *list_store;
+ GtkTreeIter iter;
gchar buffer[40];
struct tm tmp_tm;
gint hour, min;
priv = dedit->priv;
- combo = GTK_COMBO_BOX_TEXT (priv->time_combo);
-
- gtk_list_store_clear (GTK_LIST_STORE (gtk_combo_box_get_model (combo)));
+ list_store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (priv->time_combo)));
+ gtk_list_store_clear (list_store);
/* Fill the struct tm with some sane values. */
tmp_tm.tm_year = 2000;
@@ -1633,7 +1644,8 @@ rebuild_time_popup (EDateEdit *dedit)
if (!priv->use_24_hour_format && buffer[0] == '0')
buffer[0] = ' ';
- gtk_combo_box_text_append_text (combo, buffer);
+ gtk_list_store_append (list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, buffer, -1);
}
}
}