diff options
author | Milan Crha <mcrha@redhat.com> | 2010-10-28 03:43:25 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2010-10-28 03:43:25 +0800 |
commit | 2de2e7f12f3b4e5944732d1c2172a3d174d5a219 (patch) | |
tree | 8630b1ae27ddbaa9f09656b21fe512f31f15118a /e-util | |
parent | 9662ac73ccc857e04b941596eb58f72ecf01b76f (diff) | |
download | gsoc2013-evolution-2de2e7f12f3b4e5944732d1c2172a3d174d5a219.tar gsoc2013-evolution-2de2e7f12f3b4e5944732d1c2172a3d174d5a219.tar.gz gsoc2013-evolution-2de2e7f12f3b4e5944732d1c2172a3d174d5a219.tar.bz2 gsoc2013-evolution-2de2e7f12f3b4e5944732d1c2172a3d174d5a219.tar.lz gsoc2013-evolution-2de2e7f12f3b4e5944732d1c2172a3d174d5a219.tar.xz gsoc2013-evolution-2de2e7f12f3b4e5944732d1c2172a3d174d5a219.tar.zst gsoc2013-evolution-2de2e7f12f3b4e5944732d1c2172a3d174d5a219.zip |
Workaround GtkComboBoxText/GtkComboBoxEntry in .ui files
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-datetime-format.c | 2 | ||||
-rw-r--r-- | e-util/e-util.c | 8 | ||||
-rw-r--r-- | e-util/gtk-compat.h | 66 |
3 files changed, 75 insertions, 1 deletions
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 |