Permalink
Browse files

fixed the compile error caused by gtk_combo_box_text_new()

GtkComboBoxText was implemented in GTK since 2.24, while in some
Linux Distro such as Ubuntu10.10 or older versions, on which the
GTK version is 2.22 or old, it would cause a compile error.

I reimplemented the combo box using gtk_combo_box_new_text()
instead of gtk_combo_box_text_new() to solve this problem.

Signed-off-by: levin li <levin108@gmail.com>
  • Loading branch information...
levin108 committed Apr 13, 2012
1 parent 8481162 commit bcd0f5c756e42c873e620894bda3023c495021b2
Showing with 23 additions and 20 deletions.
  1. +4 −2 src/preference.c
  2. +19 −18 src/preference.h
View
@@ -253,14 +253,14 @@ select_pref_add_entry(GtkWidget *section, guint pos, HybridPrefEntry *entry)
if (entry->tooltip)
gtk_widget_set_tooltip_markup(label, entry->tooltip);
- combo = gtk_combo_box_text_new();
+ combo = gtk_combo_box_new_text();
if (entry->type_num == PREF_KEY_SELECT) {
value.str = hybrid_pref_get_string(entry->win->pref, entry->key);
} else {
value.num = hybrid_pref_get_int(entry->win->pref, entry->key);
}
for (i = 0;options[i].name;i++) {
- gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo),
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo),
options[i].name);
if (entry->type_num == PREF_KEY_SELECT) {
if (!g_strcmp0(options[i].value.str, value.str))
@@ -270,6 +270,8 @@ select_pref_add_entry(GtkWidget *section, guint pos, HybridPrefEntry *entry)
active = i;
}
}
+ if (-1 == active)
+ active = 0;
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), active);
entry->data = data = g_new0(str_o_int, i + 2);
View
@@ -80,28 +80,29 @@ typedef struct {
#ifdef __cplusplus
extern "C" {
#endif
- /* TODO: add padding etc to have a better look~~ */
- HybridPrefWin *hybrid_pref_win_new(HybridPref *pref, const gchar *title);
- /* VBox */
- GtkWidget *hybrid_pref_win_add_tab(HybridPrefWin *pref_win,
+/* TODO: add padding etc to have a better look~~ */
+HybridPrefWin *hybrid_pref_win_new(HybridPref *pref, const gchar *title);
+
+/* VBox */
+GtkWidget *hybrid_pref_win_add_tab(HybridPrefWin *pref_win,
+ const gchar *name);
+/* Table */
+GtkWidget *hybrid_pref_tab_add_section(GtkWidget *tab,
const gchar *name);
- /* Table */
- GtkWidget *hybrid_pref_tab_add_section(GtkWidget *tab,
- const gchar *name);
- void hybrid_pref_section_add_entry(HybridPrefWin *pref_win,
- GtkWidget *section,
- PrefKeyType type,
- gchar *name, gchar *key,
- gchar *tooltip, gpointer data);
-
- /* connect close signal and show. */
- void hybrid_pref_win_finish(HybridPrefWin *pref_win);
+void hybrid_pref_section_add_entry(HybridPrefWin *pref_win,
+ GtkWidget *section,
+ PrefKeyType type,
+ gchar *name, gchar *key,
+ gchar *tooltip, gpointer data);
+
+/* connect close signal and show. */
+void hybrid_pref_win_finish(HybridPrefWin *pref_win);
/**
- * Create the preference window, if exists, just present the window.
- */
- void hybrid_pref_create(void);
+* Create the preference window, if exists, just present the window.
+*/
+void hybrid_pref_create(void);
#ifdef __cplusplus
}

0 comments on commit bcd0f5c

Please sign in to comment.