diff options
Diffstat (limited to 'misc/scim-chewing/gtk.patch')
-rw-r--r-- | misc/scim-chewing/gtk.patch | 859 |
1 files changed, 859 insertions, 0 deletions
diff --git a/misc/scim-chewing/gtk.patch b/misc/scim-chewing/gtk.patch new file mode 100644 index 0000000000000..dd65d6d64b782 --- /dev/null +++ b/misc/scim-chewing/gtk.patch @@ -0,0 +1,859 @@ +commit 3cbe332e6b15ed674513d0b28e1966ff2bae1b45 +Author: Andrew Lee (李健秋) <ajqlee@debian.org> +Date: Fri Jul 6 01:22:55 2012 +0800 + + Import upstream snapshot. + +diff --git a/src/scim_chewing_imengine_setup.cpp b/src/scim_chewing_imengine_setup.cpp +index 75a9f51..c14eb74 100644 +--- a/src/scim_chewing_imengine_setup.cpp ++++ b/src/scim_chewing_imengine_setup.cpp +@@ -165,7 +165,10 @@ static GList *selKey_type_list = 0; + static GList *selKey_num_list = 0; + static GList *chieng_mode_list = 0; + // static GtkWidget * __widget_show_candidate_comment= 0; ++#if GTK_CHECK_VERSION(2, 12, 0) ++#else + static GtkTooltips * __widget_tooltips = 0; ++#endif + + static KeyboardConfigData __config_keyboards[] = + { +@@ -322,7 +325,11 @@ static GtkWidget *create_options_page() + { + GtkWidget *vbox; + ++#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); + + __widget_add_phrase_forward = +@@ -336,9 +343,15 @@ static GtkWidget *create_options_page() + G_CALLBACK( on_default_toggle_button_toggled ), + &__config_add_phrase_forward ); + ++#if GTK_CHECK_VERSION(2, 12, 0) ++ gtk_widget_set_tooltip_text( ++ __widget_add_phrase_forward, ++ _( "Whether to add Phrase forward or not." )); ++#else + gtk_tooltips_set_tip( + __widget_tooltips, __widget_add_phrase_forward, + _( "Whether to add Phrase forward or not." ), NULL ); ++#endif + + __widget_phrase_choice_rearward = + gtk_check_button_new_with_mnemonic( _( "_Rearward phrase choice" ) ); +@@ -351,9 +364,15 @@ static GtkWidget *create_options_page() + G_CALLBACK( on_default_toggle_button_toggled ), + &__config_phrase_choice_rearward ); + ++#if GTK_CHECK_VERSION(2, 12, 0) ++ gtk_widget_set_tooltip_text( ++ __widget_phrase_choice_rearward, ++ _( "The behavior for phrase choice to be rearward or not." )); ++#else + gtk_tooltips_set_tip( + __widget_tooltips, __widget_phrase_choice_rearward, + _( "The behavior for phrase choice to be rearward or not." ), NULL ); ++#endif + + __widget_auto_shift_cursor = + gtk_check_button_new_with_mnemonic( _( "_Automatically shift cursor" ) ); +@@ -366,9 +385,15 @@ static GtkWidget *create_options_page() + G_CALLBACK( on_default_toggle_button_toggled ), + &__config_auto_shift_cursor ); + ++#if GTK_CHECK_VERSION(2, 12, 0) ++ gtk_widget_set_tooltip_text( ++ __widget_auto_shift_cursor, ++ _( "Automatically shift cursor after selection." )); ++#else + gtk_tooltips_set_tip( + __widget_tooltips, __widget_auto_shift_cursor, + _( "Automatically shift cursor after selection." ), NULL ); ++#endif + + __widget_esc_clean_all_buffer = + gtk_check_button_new_with_mnemonic(_( "_Esc key to clean all buffer" ) ); +@@ -381,9 +406,15 @@ static GtkWidget *create_options_page() + G_CALLBACK( on_default_toggle_button_toggled ), + &__config_esc_clean_all_buffer ); + ++#if GTK_CHECK_VERSION(2, 12, 0) ++ gtk_widget_set_tooltip_text( ++ __widget_esc_clean_all_buffer, ++ _( "Assign Esc key to clean all keyboard buffer or not." )); ++#else + gtk_tooltips_set_tip( + __widget_tooltips, __widget_esc_clean_all_buffer, + _( "Assign Esc key to clean all keyboard buffer or not." ), NULL ); ++#endif + + __widget_space_as_selection = + gtk_check_button_new_with_mnemonic( _( "_SpaceKey as selection key" ) ); +@@ -396,9 +427,15 @@ static GtkWidget *create_options_page() + G_CALLBACK( on_default_toggle_button_toggled ), + &__config_space_as_selection ); + ++#if GTK_CHECK_VERSION(2, 12, 0) ++ gtk_widget_set_tooltip_text( ++ __widget_space_as_selection, ++ _( "Whether SpaceKey is used as selection key or not." )); ++#else + gtk_tooltips_set_tip( + __widget_tooltips, __widget_space_as_selection, + _( "Whether SpaceKey is used as selection key or not." ), NULL ); ++#endif + + return vbox; + } +@@ -487,7 +524,7 @@ static GtkWidget *create_keyboard_page() + gtk_table_attach (GTK_TABLE (table), __config_keyboards [i].entry, 1, 2, i, i+1, + (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), + (GtkAttachOptions) (GTK_FILL), 4, 4); +- gtk_entry_set_editable (GTK_ENTRY (__config_keyboards[i].entry), FALSE); ++ gtk_editable_set_editable (GTK_EDITABLE (__config_keyboards[i].entry), FALSE); + + __config_keyboards[i].button = gtk_button_new_with_label ("..."); + gtk_widget_show (__config_keyboards[i].button); +@@ -508,26 +545,46 @@ static GtkWidget *create_keyboard_page() + } + + for (i = 0; __config_keyboards [i].key; ++ i) { ++#if GTK_CHECK_VERSION(2, 12, 0) ++ gtk_widget_set_tooltip_text(__config_keyboards [i].entry, ++ _(__config_keyboards [i].tooltip)); ++#else + gtk_tooltips_set_tip (__widget_tooltips, __config_keyboards [i].entry, + _(__config_keyboards [i].tooltip), NULL); ++#endif + } + ++#if GTK_CHECK_VERSION(2, 4, 0) ++ __widget_chieng_mode = gtk_combo_box_text_new_with_entry(); ++#else + // Setup chieng_mode combo box + __widget_chieng_mode = gtk_combo_new(); ++#endif + gtk_widget_show (__widget_chieng_mode); + + for (i = 0; + i < (sizeof(builtin_chieng_mode) / sizeof(builtin_chieng_mode[0])); + i++) { ++#if GTK_CHECK_VERSION(2, 4, 0) ++ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(__widget_chieng_mode), ++ builtin_chieng_mode[ i ] ); ++#else + chieng_mode_list = g_list_append( + chieng_mode_list, + (void *) builtin_chieng_mode[ i ] ); ++#endif + } + ++#if GTK_CHECK_VERSION(2, 4, 0) ++ gtk_editable_set_editable ( ++ GTK_EDITABLE (gtk_bin_get_child (GTK_BIN (__widget_chieng_mode))), ++ FALSE); ++#else + gtk_combo_set_popdown_strings (GTK_COMBO (__widget_chieng_mode), chieng_mode_list); + g_list_free(chieng_mode_list); + gtk_combo_set_use_arrows (GTK_COMBO (__widget_chieng_mode), TRUE); + gtk_editable_set_editable (GTK_EDITABLE (GTK_ENTRY (GTK_COMBO (__widget_chieng_mode)->entry)), FALSE); ++#endif + label = gtk_label_new (_("Initial trigger Chinese/English mode:")); + gtk_widget_show (label); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); +@@ -538,30 +595,55 @@ static GtkWidget *create_keyboard_page() + gtk_table_attach (GTK_TABLE (table), __widget_chieng_mode, 1, 2, 2, 3, + (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), + (GtkAttachOptions) (GTK_FILL), 4, 4); ++#if GTK_CHECK_VERSION(2, 12, 0) ++ gtk_widget_set_tooltip_text( ++ gtk_bin_get_child (GTK_BIN (__widget_chieng_mode)), ++ _("Change the default Chinese/English mode on every trigger")); ++#else + gtk_tooltips_set_tip (__widget_tooltips, GTK_COMBO (__widget_chieng_mode)->entry, + _("Change the default Chinese/English mode on every trigger"), NULL); ++#endif + g_signal_connect( ++#if GTK_CHECK_VERSION(2, 4, 0) ++ G_OBJECT (gtk_bin_get_child (GTK_BIN (__widget_chieng_mode))), ++#else + (gpointer) GTK_ENTRY(GTK_COMBO(__widget_chieng_mode)->entry), ++#endif + "changed", + G_CALLBACK (on_default_editable_changed), + &(__config_chieng_mode_data)); + ++#if GTK_CHECK_VERSION(2, 4, 0) ++ __widget_selKey_num = gtk_combo_box_text_new_with_entry(); ++#else + // Setup selKey_num combo box + __widget_selKey_num = gtk_combo_new(); ++#endif + gtk_widget_show (__widget_selKey_num); + + for (i = 0; + i < (sizeof(builtin_selectkeys_num) / sizeof(builtin_selectkeys_num[0])); + i++) { ++#if GTK_CHECK_VERSION(2, 4, 0) ++ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(__widget_selKey_num), ++ builtin_selectkeys_num[ i ] ); ++#else + selKey_num_list = g_list_append( + selKey_num_list, + (void *) builtin_selectkeys_num[ i ] ); ++#endif + } + ++#if GTK_CHECK_VERSION(2, 4, 0) ++ gtk_editable_set_editable ( ++ GTK_EDITABLE (gtk_bin_get_child (GTK_BIN (__widget_selKey_num))), ++ FALSE); ++#else + gtk_combo_set_popdown_strings (GTK_COMBO (__widget_selKey_num), selKey_num_list); + g_list_free(selKey_num_list); + gtk_combo_set_use_arrows (GTK_COMBO (__widget_selKey_num), TRUE); + gtk_editable_set_editable (GTK_EDITABLE (GTK_ENTRY (GTK_COMBO (__widget_selKey_num)->entry)), FALSE); ++#endif + label = gtk_label_new (_("Number of Selection Keys :")); + gtk_widget_show (label); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); +@@ -572,30 +654,52 @@ static GtkWidget *create_keyboard_page() + gtk_table_attach (GTK_TABLE (table), __widget_selKey_num, 1, 2, 3, 4, + (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), + (GtkAttachOptions) (GTK_FILL), 4, 4); ++#if GTK_CHECK_VERSION(2, 12, 0) ++ gtk_widget_set_tooltip_text(gtk_bin_get_child (GTK_BIN (__widget_selKey_num)), ++ _("Change the default number of selection keys")); ++#else + gtk_tooltips_set_tip (__widget_tooltips, GTK_COMBO (__widget_selKey_num)->entry, + _("Change the default number of selection keys"), NULL); ++#endif + g_signal_connect( ++#if GTK_CHECK_VERSION(2, 4, 0) ++ G_OBJECT(gtk_bin_get_child(GTK_BIN(__widget_selKey_num))), ++#else + (gpointer) GTK_ENTRY(GTK_COMBO(__widget_selKey_num)->entry), ++#endif + "changed", + G_CALLBACK (on_default_editable_changed), + &(__config_selKey_num_data)); + ++#if GTK_CHECK_VERSION(2, 4, 0) ++ __widget_selKey_type = gtk_combo_box_text_new_with_entry(); ++#else + // Setup selKey combo box + __widget_selKey_type = gtk_combo_new(); ++#endif + gtk_widget_show (__widget_selKey_type); + + for (i = 0; + i < (sizeof(builtin_selectkeys) / sizeof(builtin_selectkeys[0])); + i++) { ++#if GTK_CHECK_VERSION(2, 4, 0) ++ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(__widget_selKey_type), ++ builtin_selectkeys[ i ] ); ++#else + selKey_type_list = g_list_append( + selKey_type_list, + (void *) builtin_selectkeys[ i ] ); ++#endif + } + ++#if GTK_CHECK_VERSION(2, 4, 0) ++ gtk_editable_set_editable (GTK_EDITABLE (gtk_bin_get_child (GTK_BIN (__widget_selKey_type))), FALSE); ++#else + gtk_combo_set_popdown_strings (GTK_COMBO (__widget_selKey_type), selKey_type_list); + g_list_free(selKey_type_list); + gtk_combo_set_use_arrows (GTK_COMBO (__widget_selKey_type), TRUE); + gtk_editable_set_editable (GTK_EDITABLE (GTK_ENTRY (GTK_COMBO (__widget_selKey_type)->entry)), FALSE); ++#endif + label = gtk_label_new (_("Customized Selection Keys:")); + gtk_widget_show (label); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); +@@ -606,30 +710,54 @@ static GtkWidget *create_keyboard_page() + gtk_table_attach (GTK_TABLE (table), __widget_selKey_type, 1, 2, 4, 5, + (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), + (GtkAttachOptions) (GTK_FILL), 4, 4); ++#if GTK_CHECK_VERSION(2, 12, 0) ++ gtk_widget_set_tooltip_text(gtk_bin_get_child (GTK_BIN (__widget_selKey_type)), ++ _("Change the default selection keys")); ++#else + gtk_tooltips_set_tip (__widget_tooltips, GTK_COMBO (__widget_selKey_type)->entry, + _("Change the default selection keys"), NULL); ++#endif + g_signal_connect( ++#if GTK_CHECK_VERSION(2, 4, 0) ++ G_OBJECT(gtk_bin_get_child(GTK_BIN(__widget_selKey_type))), ++#else + (gpointer) GTK_ENTRY(GTK_COMBO(__widget_selKey_type)->entry), ++#endif + "changed", + G_CALLBACK (on_default_editable_changed), + &(__config_selKey_type_data)); + ++#if GTK_CHECK_VERSION(2, 4, 0) ++ __widget_kb_type = gtk_combo_box_text_new_with_entry(); ++#else + // Setup KB_TYPE combo box + __widget_kb_type = gtk_combo_new(); ++#endif + gtk_widget_show (__widget_kb_type); + + for (i = 0; + i < (int) (sizeof(builtin_keymaps) / sizeof(_builtin_keymap)); + i++) { ++#if GTK_CHECK_VERSION(2, 4, 0) ++ gtk_combo_box_text_append_text( ++ GTK_COMBO_BOX_TEXT(__widget_kb_type), ++ builtin_keymaps[ i ].translated_name.c_str() ); ++#else + kb_type_list = g_list_append( + kb_type_list, + (void *) builtin_keymaps[ i ].translated_name.c_str() ); ++#endif + } + ++#if GTK_CHECK_VERSION(2, 4, 0) ++ gtk_editable_set_editable (GTK_EDITABLE (gtk_bin_get_child (GTK_BIN (__widget_kb_type))), FALSE); ++#else + gtk_combo_set_popdown_strings (GTK_COMBO (__widget_kb_type), kb_type_list); + g_list_free(kb_type_list); + gtk_combo_set_use_arrows (GTK_COMBO (__widget_kb_type), TRUE); + gtk_editable_set_editable (GTK_EDITABLE (GTK_ENTRY (GTK_COMBO (__widget_kb_type)->entry)), FALSE); ++#endif ++ + label = gtk_label_new (_("Use keyboard type:")); + gtk_widget_show (label); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); +@@ -640,10 +768,19 @@ static GtkWidget *create_keyboard_page() + gtk_table_attach (GTK_TABLE (table), __widget_kb_type, 1, 2, 5, 6, + (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), + (GtkAttachOptions) (GTK_FILL), 4, 4); ++#if GTK_CHECK_VERSION(2, 12, 0) ++ gtk_widget_set_tooltip_text(gtk_bin_get_child (GTK_BIN (__widget_kb_type)), ++ _("Change the default keyboard layout type")); ++#else + gtk_tooltips_set_tip (__widget_tooltips, GTK_COMBO (__widget_kb_type)->entry, + _("Change the default keyboard layout type"), NULL); ++#endif + g_signal_connect( ++#if GTK_CHECK_VERSION(2, 4, 0) ++ G_OBJECT(gtk_bin_get_child(GTK_BIN(__widget_kb_type))), ++#else + (gpointer) GTK_ENTRY(GTK_COMBO(__widget_kb_type)->entry), ++#endif + "changed", + G_CALLBACK (on_default_editable_changed), + &(__config_kb_type_data_translated)); +@@ -661,7 +798,11 @@ static GtkWidget *create_color_button_page() + gtk_widget_show (table); + + for (int i = 0; i < SCIM_CONFIG_IMENGINE_CHEWING_PREEDIT_BGCOLOR_NUM; i++) { ++#if GTK_CHECK_VERSION(3, 0, 0) ++ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); ++#else + hbox = gtk_hbox_new (FALSE, 0); ++#endif + gtk_widget_show (hbox); + sprintf(color_button_name_string, + SCIM_CONFIG_IMENGINE_CHEWING_PREEDIT_BGCOLOR_ "_%d", i + 1); +@@ -684,7 +825,10 @@ static GtkWidget *create_setup_window() + GtkWidget *label; + GtkWidget *page; + ++#if GTK_CHECK_VERSION(2, 12, 0) ++#else + __widget_tooltips = gtk_tooltips_new (); ++#endif + + // Create the Notebook. + notebook = gtk_notebook_new (); +@@ -788,10 +932,14 @@ void setup_widget_value() + if (index_keymap < 0) + index_keymap = 0; + ++#if GTK_CHECK_VERSION(2, 4, 0) ++ gtk_combo_box_set_active(GTK_COMBO_BOX(__widget_kb_type), index_keymap); ++#else + gtk_entry_set_text ( + GTK_ENTRY(GTK_COMBO(__widget_kb_type)->entry), + builtin_keymaps[index_keymap].translated_name.c_str() + ); ++#endif + + /* selKey */ + int index_selectkeys = sizeof(builtin_selectkeys) / sizeof(builtin_selectkeys[0]) - 1; +@@ -804,10 +952,14 @@ void setup_widget_value() + if (index_selectkeys < 0) + index_selectkeys = 0; + ++#if GTK_CHECK_VERSION(2, 4, 0) ++ gtk_combo_box_set_active(GTK_COMBO_BOX(__widget_selKey_type), index_selectkeys); ++#else + gtk_entry_set_text ( + GTK_ENTRY(GTK_COMBO(__widget_selKey_type)->entry), + builtin_selectkeys[index_selectkeys] + ); ++#endif + + /* selKey_num */ + int index_selectkeys_num = +@@ -821,10 +973,14 @@ void setup_widget_value() + if (index_selectkeys_num < 0) + index_selectkeys_num = 0; + ++#if GTK_CHECK_VERSION(2, 4, 0) ++ gtk_combo_box_set_active(GTK_COMBO_BOX(__widget_selKey_num), index_selectkeys_num); ++#else + gtk_entry_set_text ( + GTK_ENTRY(GTK_COMBO(__widget_selKey_num)->entry), + builtin_selectkeys_num[index_selectkeys_num] + ); ++#endif + + /* chieng_mode */ + int index_chieng_mode = +@@ -838,10 +994,14 @@ void setup_widget_value() + if (index_chieng_mode < 0) + index_chieng_mode = 0; + ++#if GTK_CHECK_VERSION(2, 4, 0) ++ gtk_combo_box_set_active(GTK_COMBO_BOX(__widget_chieng_mode), index_chieng_mode); ++#else + gtk_entry_set_text ( + GTK_ENTRY(GTK_COMBO(__widget_chieng_mode)->entry), + builtin_chieng_mode[index_chieng_mode] + ); ++#endif + } + + void load_config( const ConfigPointer &config ) +@@ -1087,7 +1247,11 @@ static GtkWidget *create_color_button (const char *config_key) + if (!entry) + return NULL; + ++#if GTK_CHECK_VERSION(3, 0, 0) ++ GtkWidget *hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); ++#else + GtkWidget *hbox = gtk_hbox_new (FALSE, 0); ++#endif + gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); + gtk_widget_show (hbox); + +diff --git a/src/scim_color_button.cpp b/src/scim_color_button.cpp +index 0b3930c..36df131 100644 +--- a/src/scim_color_button.cpp ++++ b/src/scim_color_button.cpp +@@ -68,9 +68,14 @@ typedef enum + static void scim_color_button_class_init (ScimChewingColorButtonClass *klass); + static void scim_color_button_init (ScimChewingColorButton *object); + ++#if GTK_CHECK_VERSION(3, 0, 0) ++static void scim_color_button_destroy (GtkWidget *object); ++static gboolean scim_color_button_draw (GtkWidget *widget, cairo_t *cr); ++#else + static void scim_color_button_destroy (GtkObject *object); + static gboolean scim_color_button_expose (GtkWidget *widget, + GdkEventExpose *eevent); ++#endif + static gboolean scim_color_button_button_press (GtkWidget *widget, + GdkEventButton *bevent); + static gboolean scim_color_button_button_release (GtkWidget *widget, +@@ -110,7 +115,6 @@ scim_color_button_get_type (void) + static void + scim_color_button_class_init (ScimChewingColorButtonClass *klass) + { +- GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + parent_class = (GtkDrawingAreaClass *) g_type_class_peek_parent (klass); +@@ -124,9 +128,15 @@ scim_color_button_class_init (ScimChewingColorButtonClass *klass) + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + ++#if GTK_CHECK_VERSION(3, 0, 0) ++ widget_class->destroy = scim_color_button_destroy; ++ widget_class->draw = scim_color_button_draw; ++#else ++ GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass); + gtk_object_class->destroy = scim_color_button_destroy; +- + widget_class->expose_event = scim_color_button_expose; ++#endif ++ + widget_class->button_press_event = scim_color_button_button_press; + widget_class->button_release_event = scim_color_button_button_release; + } +@@ -135,8 +145,13 @@ static void + scim_color_button_init (ScimChewingColorButton *object) + { + /*set default color */ ++#if GTK_CHECK_VERSION(3, 0, 0) ++ gdk_rgba_parse (&object->fg_color, "#000000"); ++ gdk_rgba_parse (&object->bg_color, "#ffffff"); ++#else + gdk_color_parse ("#000000", &object->fg_color); + gdk_color_parse ("#ffffff", &object->bg_color); ++#endif + + gtk_widget_add_events (GTK_WIDGET (object), + GDK_BUTTON_PRESS_MASK | +@@ -145,7 +160,11 @@ scim_color_button_init (ScimChewingColorButton *object) + + + static void ++#if GTK_CHECK_VERSION(3, 0, 0) ++scim_color_button_destroy (GtkWidget *object) ++#else + scim_color_button_destroy (GtkObject *object) ++#endif + { + ScimChewingColorButton *button = SCIM_COLOR_BUTTON (object); + +@@ -160,19 +179,38 @@ scim_color_button_destroy (GtkObject *object) + button->swap_icon = NULL; + } + ++#if GTK_CHECK_VERSION(3, 0, 0) ++ GTK_WIDGET_CLASS (parent_class)->destroy (object); ++#else + GTK_OBJECT_CLASS (parent_class)->destroy (object); ++#endif + } + + static void + scim_color_button_draw_rect (ScimChewingColorButton *button, ++#if GTK_CHECK_VERSION(3, 0, 0) ++ GdkWindow *drawable, ++ cairo_t *cr, ++#else + GdkDrawable *drawable, + GdkGC *gc, ++#endif + gint x, + gint y, + gint width, + gint height, +- GdkColor *color) ++#if GTK_CHECK_VERSION(3, 0, 0) ++ GdkRGBA *color ++#else ++ GdkColor *color ++#endif ++ ) + { ++#if GTK_CHECK_VERSION(3, 0, 0) ++ gdk_cairo_set_source_rgba (cr, color); ++ cairo_rectangle (cr, x, y, width, height); ++ cairo_fill (cr); ++#else + gint rowstride; + guchar r, g, b; + gint xx, yy; +@@ -211,23 +249,38 @@ scim_color_button_draw_rect (ScimChewingColorButton *button, + GDK_RGB_DITHER_MAX, + button->render_buf, + rowstride); ++#endif + } + + static gboolean ++#if GTK_CHECK_VERSION(3, 0, 0) ++scim_color_button_draw (GtkWidget *widget, ++ cairo_t *cr) ++#else + scim_color_button_expose (GtkWidget *widget, + GdkEventExpose *eevent) ++#endif + { + ScimChewingColorButton *button = SCIM_COLOR_BUTTON (widget); + gint width, height; + gint swap_w = 0, swap_h = 0; + gint rect_w, rect_h; + ++#if GTK_CHECK_VERSION(2, 18, 0) ++ if (!gtk_widget_is_drawable (widget)) ++#else + if (!GTK_WIDGET_DRAWABLE (widget)) ++#endif + return FALSE; +- ++ ++#if GTK_CHECK_VERSION(3, 0, 0) ++ width = gdk_window_get_width(gtk_widget_get_window (widget)); ++ height = gdk_window_get_height(gtk_widget_get_window (widget)); ++#else + width = widget->allocation.width; + height = widget->allocation.height; +- ++#endif ++ + /* draw the swap colors pixbuf */ + if (!button->swap_icon) { + button->swap_icon +@@ -241,9 +294,14 @@ scim_color_button_expose (GtkWidget *widget, + } + + if (swap_w < width / 2 && swap_h < height / 2) { ++#if GTK_CHECK_VERSION(3, 0, 0) ++ gdk_cairo_set_source_pixbuf (cr, button->swap_icon, width - swap_w, 0); ++ cairo_paint (cr); ++#else + gdk_draw_pixbuf (widget->window, NULL, button->swap_icon, + 0, 0, width - swap_w, 0, swap_w, swap_h, + GDK_RGB_DITHER_NORMAL, 0, 0); ++#endif + } else { + swap_w = swap_h = 0; + } +@@ -259,37 +317,78 @@ scim_color_button_expose (GtkWidget *widget, + button->rect_width = rect_w; + button->rect_height = rect_h; + +- + /* draw the background area */ + scim_color_button_draw_rect (button, ++#if GTK_CHECK_VERSION(2, 14, 0) ++ gtk_widget_get_window (widget), ++#else + widget->window, ++#endif ++#if GTK_CHECK_VERSION(3, 0, 0) ++ cr, ++#else + widget->style->fg_gc[0], ++#endif + (width - rect_w), + (height - rect_h), + rect_w, rect_h, + &button->bg_color); + +- gtk_paint_shadow (widget->style, widget->window, GTK_STATE_NORMAL, ++#if GTK_CHECK_VERSION(3, 0, 0) ++ GtkStyleContext *style = gtk_widget_get_style_context(widget); ++ gtk_style_context_save (style); ++ gtk_style_context_set_state (style, GTK_STATE_FLAG_NORMAL); ++ gtk_render_frame (style, cr, width - rect_w, height - rect_h, rect_w, rect_h); ++#else ++ gtk_paint_shadow (widget->style, ++#if GTK_CHECK_VERSION(2, 14, 0) ++ gtk_widget_get_window (widget), ++#else ++ widget->window, ++#endif ++ GTK_STATE_NORMAL, + GTK_SHADOW_IN, + NULL, widget, NULL, + (width - rect_w), + (height - rect_h), + rect_w, rect_h); +- ++#endif + + /* draw the foreground area */ + scim_color_button_draw_rect (button, ++#if GTK_CHECK_VERSION(2, 14, 0) ++ gtk_widget_get_window (widget), ++#else + widget->window, ++#endif ++#if GTK_CHECK_VERSION(3, 0, 0) ++ cr, ++#else + widget->style->fg_gc[0], ++#endif + 0, 0, + rect_w, rect_h, + &button->fg_color); + +- gtk_paint_shadow (widget->style, widget->window, GTK_STATE_NORMAL, ++#if GTK_CHECK_VERSION(3, 0, 0) ++ style = gtk_widget_get_style_context(widget); ++ gtk_style_context_save (style); ++ gtk_style_context_set_state (style, GTK_STATE_FLAG_NORMAL); ++ gtk_render_frame (style, cr, 0, 0, rect_w, rect_h); ++#else ++ gtk_paint_shadow ( ++ widget->style, ++#if GTK_CHECK_VERSION(2, 14, 0) ++ gtk_widget_get_window (widget), ++#else ++ widget->window, ++#endif ++ GTK_STATE_NORMAL, + GTK_SHADOW_IN, + NULL, widget, NULL, + 0, 0, + rect_w, rect_h); ++#endif + + return TRUE; + } +@@ -299,11 +398,16 @@ scim_color_button_target (ScimChewingColorButton *button, + gint x, + gint y) + { ++#if GTK_CHECK_VERSION(3, 0, 0) ++ gint width = gdk_window_get_width(gtk_widget_get_window (GTK_WIDGET(button))); ++ gint height = gdk_window_get_height(gtk_widget_get_window (GTK_WIDGET(button))); ++#else + gint width = GTK_WIDGET (button)->allocation.width; + gint height = GTK_WIDGET (button)->allocation.height; ++#endif + gint rect_w = button->rect_width; + gint rect_h = button->rect_height; +- ++ + if (x > 0 && x < rect_w && y > 0 && y < rect_h) + return FOREGROUND_AREA; + else if (x > (width - rect_w) && x < width && +@@ -324,7 +428,11 @@ scim_color_button_open_color_dialog (ScimChewingColorButton *button, gboolean fg + { + GtkWidget *dialog; + const gchar *title; ++#if GTK_CHECK_VERSION(3, 0, 0) ++ GdkRGBA *color; ++#else + GdkColor *color; ++#endif + gint result; + + title = fg ? _("Foreground color") : _("Background color"); +@@ -332,16 +440,38 @@ scim_color_button_open_color_dialog (ScimChewingColorButton *button, gboolean fg + + dialog = gtk_color_selection_dialog_new (title); + +- gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel), +- color); ++#if GTK_CHECK_VERSION(3, 0, 0) ++ gtk_color_selection_set_current_rgba ( ++ GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (dialog))), ++ color); ++#else ++ gtk_color_selection_set_current_color ( ++#if GTK_CHECK_VERSION(2, 14, 0) ++ GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (dialog))), ++#else ++ GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel), ++#endif ++ color); ++#endif + gtk_widget_show (dialog); + + result = gtk_dialog_run (GTK_DIALOG (dialog)); + + switch (result) { + case GTK_RESPONSE_OK: +- gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel), +- color); ++#if GTK_CHECK_VERSION(3, 0, 0) ++ gtk_color_selection_get_current_rgba ( ++ GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (dialog))), ++ color); ++#else ++ gtk_color_selection_get_current_color ( ++#if GTK_CHECK_VERSION(2, 14, 0) ++ GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (dialog))), ++#else ++ GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel), ++#endif ++ color); ++#endif + g_signal_emit (button, button_signals[COLOR_CHANGED], 0); + break; + default: +@@ -355,6 +485,11 @@ scim_color_button_open_color_dialog (ScimChewingColorButton *button, gboolean fg + static void + scim_color_button_swap_color (ScimChewingColorButton *button) + { ++#if GTK_CHECK_VERSION(3, 0, 0) ++ GdkRGBA tmp = button->fg_color; ++ button->fg_color = button->bg_color; ++ button->bg_color = tmp; ++#else + GdkColor tmp; + tmp.red = button->fg_color.red; + tmp.green = button->fg_color.green; +@@ -367,6 +502,7 @@ scim_color_button_swap_color (ScimChewingColorButton *button) + button->bg_color.red = tmp.red; + button->bg_color.green = tmp.green; + button->bg_color.blue = tmp.blue; ++#endif + g_signal_emit (button, button_signals[COLOR_CHANGED], 0); + } + +@@ -457,14 +593,29 @@ scim_color_button_get_colors (ScimChewingColorButton *button, + + g_snprintf (fg_color_str, G_N_ELEMENTS (fg_color_str), + "#%02X%02X%02X", ++#if GTK_CHECK_VERSION(3, 0, 0) ++ static_cast<unsigned int>(255*button->fg_color.red), ++ static_cast<unsigned int>(255*button->fg_color.green), ++ static_cast<unsigned int>(255*button->fg_color.blue) ++#else + ((button->fg_color.red)>>8), + ((button->fg_color.green)>>8), +- ((button->fg_color.blue)>>8)); ++ ((button->fg_color.blue)>>8) ++#endif ++ ); + g_snprintf (bg_color_str, G_N_ELEMENTS (bg_color_str), + "#%02X%02X%02X", ++#if GTK_CHECK_VERSION(3, 0, 0) ++ static_cast<unsigned int>(255*button->bg_color.red), ++ static_cast<unsigned int>(255*button->bg_color.green), ++ static_cast<unsigned int>(255*button->bg_color.blue) ++#else + ((button->bg_color.red)>>8), + ((button->bg_color.green)>>8), +- ((button->bg_color.blue)>>8)); ++ ((button->bg_color.blue)>>8) ++#endif ++ ); ++ + *fg_value = String (fg_color_str); + *bg_value = String (bg_color_str); + +@@ -476,6 +627,10 @@ scim_color_button_set_colors (ScimChewingColorButton *button, + const String &fg_value, + const String &bg_value) + { ++#if GTK_CHECK_VERSION(3, 0, 0) ++ gdk_rgba_parse (&button->fg_color, fg_value.c_str()); ++ gdk_rgba_parse (&button->bg_color, bg_value.c_str()); ++#else + GdkColor fg_color, bg_color; + gdk_color_parse (fg_value.c_str (), &fg_color); + gdk_color_parse (bg_value.c_str (), &bg_color); +@@ -486,6 +641,7 @@ scim_color_button_set_colors (ScimChewingColorButton *button, + button->bg_color.red = bg_color.red; + button->bg_color.green = bg_color.green; + button->bg_color.blue = bg_color.blue; ++#endif + + return TRUE; + } +diff --git a/src/scim_color_button.h b/src/scim_color_button.h +index ca09877..fc24bb9 100644 +--- a/src/scim_color_button.h ++++ b/src/scim_color_button.h +@@ -53,8 +53,13 @@ struct _ScimChewingColorButton + gint rect_height; + gint click_target; + ++#if GTK_CHECK_VERSION(3, 0, 0) ++ GdkRGBA fg_color; ++ GdkRGBA bg_color; ++#else + GdkColor fg_color; + GdkColor bg_color; ++#endif + }; + + struct _ScimChewingColorButtonClass |