--- a/src/scim_canna_imengine_setup.cpp +++ b/src/scim_canna_imengine_setup.cpp @@ -152,7 +152,9 @@ // Internal data declaration. static bool __have_changed = true; +#if !GTK_CHECK_VERSION(2, 12, 0) static GtkTooltips * __widget_tooltips = 0; +#endif static BoolConfigData __config_bool_common [] = { @@ -284,11 +286,17 @@ entry); gtk_widget_show (entry->widget); +#if !GTK_CHECK_VERSION(2, 12, 0) if (!__widget_tooltips) __widget_tooltips = gtk_tooltips_new(); +#endif if (entry->tooltip) +#if GTK_CHECK_VERSION(2, 12, 0) + gtk_widget_set_tooltip_text (entry->widget, _(entry->tooltip)); +#else gtk_tooltips_set_tip (__widget_tooltips, entry->widget, _(entry->tooltip), NULL); +#endif return entry->widget; } @@ -324,11 +332,17 @@ (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL), 4, 4); +#if !GTK_CHECK_VERSION(2, 12, 0) if (!__widget_tooltips) __widget_tooltips = gtk_tooltips_new(); +#endif if (entry->tooltip) +#if GTK_CHECK_VERSION(2, 12, 0) + gtk_widget_set_tooltip_text (GTK_WIDGET (entry->widget), _(entry->tooltip)); +#else gtk_tooltips_set_tip (__widget_tooltips, GTK_WIDGET (entry->widget), _(entry->tooltip), NULL); +#endif return GTK_WIDGET (entry->widget); } @@ -351,31 +365,53 @@ (GtkAttachOptions) (GTK_FILL), 4, 4); gtk_widget_show (label); +#if GTK_CHECK_VERSION(2, 4, 0) + entry->widget = gtk_combo_box_text_new_with_entry (); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), + gtk_bin_get_child (GTK_BIN (entry->widget))); + gtk_editable_set_editable (GTK_EDITABLE (gtk_bin_get_child (GTK_BIN (entry->widget))), FALSE); +#else entry->widget = gtk_combo_new (); gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_COMBO (entry->widget)->entry); gtk_combo_set_value_in_list (GTK_COMBO (entry->widget), TRUE, FALSE); gtk_combo_set_case_sensitive (GTK_COMBO (entry->widget), TRUE); - gtk_entry_set_editable (GTK_ENTRY (GTK_COMBO (entry->widget)->entry), + gtk_editable_set_editable (GTK_EDITABLE (GTK_COMBO (entry->widget)->entry), FALSE); +#endif gtk_widget_show (GTK_WIDGET (entry->widget)); gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (entry->widget), 1, 2, idx, idx + 1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL), 4, 4); +#if GTK_CHECK_VERSION(2, 4, 0) + g_object_set_data (G_OBJECT (gtk_bin_get_child (GTK_BIN (entry->widget))), + DATA_POINTER_KEY, + (gpointer) candidates_p); + g_signal_connect ((gpointer) gtk_bin_get_child (GTK_BIN (entry->widget)), "changed", + G_CALLBACK (on_default_combo_changed), + entry); +#else g_object_set_data (G_OBJECT (GTK_COMBO (entry->widget)->entry), DATA_POINTER_KEY, (gpointer) candidates_p); - g_signal_connect ((gpointer) GTK_COMBO (entry->widget)->entry, "changed", G_CALLBACK (on_default_combo_changed), entry); +#endif + +#if !GTK_CHECK_VERSION(2, 12, 0) if (!__widget_tooltips) __widget_tooltips = gtk_tooltips_new(); +#endif if (entry->tooltip) +#if GTK_CHECK_VERSION(2, 12, 0) + gtk_widget_set_tooltip_text (GTK_WIDGET (entry->widget), _(entry->tooltip)); +#else gtk_tooltips_set_tip (__widget_tooltips, GTK_WIDGET (entry->widget), _(entry->tooltip), NULL); +#endif return GTK_WIDGET (entry->widget); } @@ -403,11 +439,17 @@ { GtkWidget *vbox, *frame, *table, *check, *widget; +#if GTK_CHECK_VERSION(3, 0, 0) + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); +#else vbox = gtk_vbox_new (FALSE, 0); +#endif gtk_widget_show (vbox); +#if !GTK_CHECK_VERSION(2, 12, 0) if (!__widget_tooltips) __widget_tooltips = gtk_tooltips_new(); +#endif /* specify initialize file name */ frame = gtk_frame_new (""); @@ -455,7 +497,11 @@ { GtkWidget *vbox, *table; +#if GTK_CHECK_VERSION(3, 0, 0) + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); +#else vbox = gtk_vbox_new (FALSE, 0); +#endif gtk_widget_show (vbox); table = gtk_table_new (2, 2, FALSE); @@ -480,7 +526,11 @@ GtkWidget *vbox, *label; gchar str[256]; +#if GTK_CHECK_VERSION(3, 0, 0) + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); +#else vbox = gtk_vbox_new (FALSE, 0); +#endif gtk_widget_show (vbox); g_snprintf ( @@ -547,8 +597,23 @@ } static void -setup_combo_value (GtkCombo *combo, const String & str) +setup_combo_value (GtkWidget *combo, const String & str) { +#if GTK_CHECK_VERSION(2, 4, 0) + ComboConfigCandidate *data + = static_cast + (g_object_get_data (G_OBJECT (gtk_bin_get_child (GTK_BIN (combo))), + DATA_POINTER_KEY)); + + gint default_index = -1; + for (unsigned int i = 0; data[i].label; i++) { + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _(data[i].label)); + if (!strcmp (data[i].data, str.c_str ())) + default_index = i; + } + if (default_index != -1) + gtk_combo_box_set_active (GTK_COMBO_BOX (combo), default_index); +#else GList *list = NULL; const char *defval = NULL; @@ -563,11 +628,12 @@ defval = _(data[i].label); } - gtk_combo_set_popdown_strings (combo, list); + gtk_combo_set_popdown_strings (GTK_COMBO (combo), list); g_list_free (list); if (defval) - gtk_entry_set_text (GTK_ENTRY (combo->entry), defval); + gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (combo)->entry), defval); +#endif } static void @@ -582,8 +648,13 @@ for (unsigned int i = 0; i < __config_string_common_num; i++) { StringConfigData &entry = __config_string_common[i]; +#if GTK_CHECK_VERSION(2, 12, 0) + if (entry.widget && GTK_IS_COMBO_BOX (entry.widget)) + setup_combo_value (entry.widget, entry.value); +#else if (entry.widget && GTK_IS_COMBO (entry.widget)) - setup_combo_value (GTK_COMBO (entry.widget), entry.value); + setup_combo_value (entry.widget, entry.value); +#endif else if (entry.widget && GTK_IS_ENTRY (entry.widget)) gtk_entry_set_text (GTK_ENTRY (entry.widget), entry.value.c_str ());