From 2de2e7f12f3b4e5944732d1c2172a3d174d5a219 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 27 Oct 2010 21:43:25 +0200 Subject: Workaround GtkComboBoxText/GtkComboBoxEntry in .ui files --- e-util/gtk-compat.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'e-util/gtk-compat.h') 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 -- cgit v1.2.3