[packages/scim-chewing] - added gtk3 patch from git; now builds with gtk+3-based scim 1.4.x - pl

qboosh qboosh at pld-linux.org
Thu Sep 13 19:15:56 CEST 2012


commit ffb5699f0d7ba95fe01642b3cc84ea57dc655d31
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Thu Sep 13 19:16:34 2012 +0200

    - added gtk3 patch from git; now builds with gtk+3-based scim 1.4.x
    - pl

 scim-chewing-gtk3.patch | 851 ++++++++++++++++++++++++++++++++++++++++++++++++
 scim-chewing.spec       |  23 +-
 2 files changed, 868 insertions(+), 6 deletions(-)
---
diff --git a/scim-chewing.spec b/scim-chewing.spec
index cc9fc0a..f819b27 100644
--- a/scim-chewing.spec
+++ b/scim-chewing.spec
@@ -1,4 +1,5 @@
 Summary:	Chewing Chinese input method for SCIM
+Summary(pl.UTF-8):	Metoda wprowadzania znaków chińskich Chewing dla SCIM-a
 Name:		scim-chewing
 Version:	0.3.4
 Release:	1
@@ -6,20 +7,30 @@ License:	GPL v2+
 Group:		Libraries
 Source0:	http://chewing.csie.net/download/scim/%{name}-%{version}.tar.bz2
 # Source0-md5:	c37bd1e7198776117e68b7aa1060896d
+Patch0:		%{name}-gtk3.patch
 URL:		http://chewing.csie.net/
-BuildRequires:	scim-devel
-BuildRequires:	libchewing-devel >= 0.3.2
-Requires:	scim
+BuildRequires:	gettext-devel >= 0.14.1
+BuildRequires:	intltool >= 0.34.0
+BuildRequires:	libchewing-devel >= 0.3.3
+BuildRequires:	libstdc++-devel
+BuildRequires:	scim-devel >= 1.0.0
+Requires:	libchewing >= 0.3.3
+Requires:	scim >= 1.0.0
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %description
 This package provides Chewing Chinese input method for SCIM.
 
+%description -l pl.UTF-8
+Metoda wprowadzania znaków chińskich Chewing dla SCIM-a.
+
 %prep
 %setup -q
+%patch0 -p1
 
 %build
-%configure
+%configure \
+	--disable-static
 %{__make}
 
 %install
@@ -28,7 +39,7 @@ rm -rf $RPM_BUILD_ROOT
 %{__make} install \
 	DESTDIR=$RPM_BUILD_ROOT
 
-%{__rm} $RPM_BUILD_ROOT%{_libdir}/scim-1.0/*/*/*.{la,a}
+%{__rm} $RPM_BUILD_ROOT%{_libdir}/scim-1.0/*/*/*.la
 
 %find_lang %{name}
 
@@ -37,7 +48,7 @@ rm -rf $RPM_BUILD_ROOT
 
 %files -f %{name}.lang
 %defattr(644,root,root,755)
-%doc README AUTHORS
+%doc AUTHORS ChangeLog NEWS README TODO
 %attr(755,root,root) %{_libdir}/scim-1.0/*/SetupUI/chewing-imengine-setup.so
 %attr(755,root,root) %{_libdir}/scim-1.0/*/IMEngine/chewing.so
 %{_datadir}/scim/icons/scim-chewing.png
diff --git a/scim-chewing-gtk3.patch b/scim-chewing-gtk3.patch
new file mode 100644
index 0000000..dbc6a32
--- /dev/null
+++ b/scim-chewing-gtk3.patch
@@ -0,0 +1,851 @@
+diff --git a/src/scim_chewing_imengine_setup.cpp b/src/scim_chewing_imengine_setup.cpp
+index 75a9f51..daeca10 100644
+--- a/src/scim_chewing_imengine_setup.cpp
++++ b/src/scim_chewing_imengine_setup.cpp
+@@ -165,7 +165,10 @@ struct ColorConfigData {
+ 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,43 @@ 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)
++#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 +592,56 @@ 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(
++#if GTK_CHECK_VERSION(2, 4, 0)
++			__widget_chieng_mode,
++#else
++			GTK_COMBO (__widget_chieng_mode)->entry,
++#endif
++			_("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(__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)
++#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 +652,51 @@ 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(__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(__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)
++#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 +707,53 @@ 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(__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(__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)
++#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 +764,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(__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(__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 +794,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 +821,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 +928,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 +948,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 +969,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 +990,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 +1243,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..1e2efb2 100644
+--- a/src/scim_color_button.cpp
++++ b/src/scim_color_button.cpp
+@@ -68,9 +68,14 @@ 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 @@ static gboolean scim_color_button_button_release  (GtkWidget      *widget,
+ 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 @@ static gboolean scim_color_button_button_release  (GtkWidget      *widget,
+   		  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 gboolean scim_color_button_button_release  (GtkWidget      *widget,
+ 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 @@ static gboolean scim_color_button_button_release  (GtkWidget      *widget,
+ 
+ 
+ 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 @@ static gboolean scim_color_button_button_release  (GtkWidget      *widget,
+         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,40 @@ static gboolean scim_color_button_button_release  (GtkWidget      *widget,
+                         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)
++    GtkAllocation allocation;
++    gtk_widget_get_allocation (widget, &allocation);
++    width = allocation.width;
++    height = allocation.height;
++#else
+     width  = widget->allocation.width;
+     height = widget->allocation.height;
+-  
++#endif
++
+     /*  draw the swap colors pixbuf  */
+     if (!button->swap_icon) {
+         button->swap_icon
+@@ -241,9 +296,14 @@ static gboolean scim_color_button_button_release  (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;
+     }
+@@ -262,34 +322,76 @@ static gboolean scim_color_button_button_release  (GtkWidget      *widget,
+   
+     /*  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,8 +401,15 @@ static gboolean scim_color_button_button_release  (GtkWidget      *widget,
+                           gint            x,
+                           gint            y)
+ {
++#if GTK_CHECK_VERSION(3, 0, 0)
++    GtkAllocation allocation;
++    gtk_widget_get_allocation (GTK_WIDGET (button), &allocation);
++    gint width = allocation.width;
++    gint height = allocation.height;
++#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;
+   
+@@ -324,7 +433,11 @@ static gboolean scim_color_button_button_release  (GtkWidget      *widget,
+ {
+     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 +445,38 @@ static gboolean scim_color_button_button_release  (GtkWidget      *widget,
+     
+     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 +490,11 @@ static gboolean scim_color_button_button_release  (GtkWidget      *widget,
+ 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 +507,7 @@ static gboolean scim_color_button_button_release  (GtkWidget      *widget,
+     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 +598,28 @@ static gboolean scim_color_button_button_release  (GtkWidget      *widget,
+ 
+     g_snprintf (fg_color_str, G_N_ELEMENTS (fg_color_str),
+                 "#%02X%02X%02X", 
++#if GTK_CHECK_VERSION(3, 0, 0)
++                static_cast<unsigned char>(255*button->fg_color.red),
++                static_cast<unsigned char>(255*button->fg_color.green),
++                static_cast<unsigned char>(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 char>(255*button->bg_color.red),
++                static_cast<unsigned char>(255*button->bg_color.green),
++                static_cast<unsigned char>(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 +631,16 @@ static gboolean scim_color_button_button_release  (GtkWidget      *widget,
+                               const String &fg_value,
+                               const String &bg_value)
+ {
++#if GTK_CHECK_VERSION(3, 0, 0)
++    const char *fg_str = fg_value.c_str();
++    const char *bg_str = bg_value.c_str();
++    if (fg_str[0] == '#')
++        ++fg_str;
++    if (bg_str[0] == '#')
++        ++bg_str;
++    gdk_rgba_parse (&button->fg_color, fg_str); 
++    gdk_rgba_parse (&button->bg_color, bg_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 +651,7 @@ static gboolean scim_color_button_button_release  (GtkWidget      *widget,
+     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
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/scim-chewing.git/commitdiff/ffb5699f0d7ba95fe01642b3cc84ea57dc655d31



More information about the pld-cvs-commit mailing list