[心得] scim-array on openSUSE 12.3

看板Array (行列輸入法)作者 (呆子)時間11年前 (2013/03/31 08:14), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
最近將 openSUSE 升到 12.3,發現 scim-array 會編譯失敗 看錯誤的訊息,是因為 Gtk+ API 的變動所造成的影響。 我自己修改以後,確定可以編譯成功並且可以使用,我參考 Gtk+ 的文 件以後,使用 GTK_CHECK_VERSION 區隔開不同版本間的 API,但是 我只能確定在 openSUSE 12.3 上是 work 的 @@ 下面是修改的地方: --- scim-array-1.0.1/src/scim_array_imengine_setup.cpp 2008-05-03 20:47:46.000000000 +0800 +++ scim-array-1.0.1-patch/src/scim_array_imengine_setup.cpp 2013-03-31 07:01:09.000000000 +0800 @@ -149,58 +149,104 @@ static void on_default_key_selection_clicked (GtkButton *button, gpointer user_data); + +#if GTK_CHECK_VERSION(2,12,0) +static GtkWidget * +create_options_page(); +#else static GtkWidget * create_options_page(GtkTooltips *tooltip); - +#endif // Function implementations. +#if GTK_CHECK_VERSION(2,12,0) static GtkWidget * -create_options_page(GtkTooltips *tooltips) +create_options_page() +#else +static GtkWidget * +create_options_page(GtkTooltips *tooltip); +#endif { GtkWidget *vbox; GtkWidget *button; +#if GTK_CHECK_VERSION(3,2,0) + vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12); +#else vbox = gtk_vbox_new (FALSE, 12); +#endif gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); button = gtk_check_button_new_with_mnemonic (_("Show Special Code")); gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); +#if GTK_CHECK_VERSION(2,12,0) + gtk_widget_set_tooltip_text(button, + _("To notify if the character has the special code")); +#else gtk_tooltips_set_tip(tooltips, button, _("To notify if the character has the special code"), NULL); +#endif g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(on_default_toggle_button_toggled), NULL); show_special_code_button = button; button = gtk_check_button_new_with_mnemonic(_("Only Special Code Input Mode")); gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); +#if GTK_CHECK_VERSION(2,12,0) + gtk_widget_set_tooltip_text(button, + _("If the character has the special code, you will be confined to use it")); +#else gtk_tooltips_set_tip(tooltips, button, _("If the character has the special code, you will be confined to use it"), NULL); +#endif g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(on_default_toggle_button_toggled), NULL); special_code_only_button = button; button = gtk_check_button_new_with_mnemonic(_("Use Phrase Library")); gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); +#if GTK_CHECK_VERSION(2,12,0) + gtk_widget_set_tooltip_text(button, + _("Turn on phrase input mode. (Enable after restart)")); +#else gtk_tooltips_set_tip(tooltips, button, _("Turn on phrase input mode. (Enable after restart)"), NULL); +#endif g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(on_default_toggle_button_toggled), NULL); phrases_library_button = button; +#if GTK_CHECK_VERSION(3,4,0) + GtkWidget *table = gtk_grid_new(); +#else GtkWidget *table = gtk_table_new ( 2, 2, TRUE ); +#endif + gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, TRUE, 0); GtkWidget *label = gtk_label_new(_("En/Ch Mode Switch Key")); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); gtk_misc_set_padding (GTK_MISC (label), 4, 0); +#if GTK_CHECK_VERSION(3,4,0) + gtk_grid_attach(GTK_GRID(table), label, 0, 1, 0, 1); +#else gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (GTK_FILL), 4, 4); + (GtkAttachOptions) (GTK_FILL), 4, 4); +#endif +#if GTK_CHECK_VERSION(3,2,0) + GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12); +#else GtkWidget *hbox = gtk_hbox_new(FALSE, 12); +#endif GtkWidget *entry = gtk_entry_new(); +#if GTK_CHECK_VERSION(2,0,0) + gtk_editable_set_editable (GTK_EDITABLE (entry), FALSE); +#else gtk_entry_set_editable (GTK_ENTRY (entry), FALSE); +#endif gtk_entry_set_text (GTK_ENTRY (entry), ""); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, TRUE, 0); g_signal_connect(G_OBJECT(entry), "changed", @@ -212,19 +258,35 @@ create_options_page(GtkTooltips *tooltip g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK (on_default_key_selection_clicked), ec_change_key_text); +#if GTK_CHECK_VERSION(3,4,0) + gtk_grid_attach(GTK_GRID(table), hbox, 1, 2, 0, 1); +#else gtk_table_attach_defaults(GTK_TABLE(table), hbox, 1, 2, 0, 1); +#endif label = gtk_label_new(_("Half/Full Width Mode Switch Key")); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); gtk_misc_set_padding (GTK_MISC (label), 4, 0); +#if GTK_CHECK_VERSION(3,4,0) + gtk_grid_attach(GTK_GRID(table), label, 0, 1, 1, 2); +#else gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 4, 4); +#endif +#if GTK_CHECK_VERSION(3,2,0) + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12); +#else hbox = gtk_hbox_new(FALSE, 12); +#endif entry = gtk_entry_new(); +#if GTK_CHECK_VERSION(2,0,0) + gtk_editable_set_editable (GTK_EDITABLE (entry), FALSE); +#else gtk_entry_set_editable (GTK_ENTRY (entry), FALSE); +#endif gtk_entry_set_text (GTK_ENTRY (entry), ""); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, TRUE, 0); g_signal_connect(G_OBJECT(entry), "changed", @@ -248,15 +310,25 @@ create_setup_window () GtkWidget *notebook; GtkWidget *label; GtkWidget *page; +#if GTK_CHECK_VERSION(2,12,0) +#else GtkTooltips *tooltips; +#endif +#if GTK_CHECK_VERSION(2,12,0) +#else tooltips = gtk_tooltips_new (); +#endif // Create the Notebook. notebook = gtk_notebook_new (); // Create the first page. +#if GTK_CHECK_VERSION(2,12,0) + page = create_options_page(); +#else page = create_options_page(tooltips); +#endif label = gtk_label_new (_("Options")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label); 修改以後的檔案 (source code): https://sites.google.com/site/ray2501/ scim-array-patch/scim-array-1.0.1-patch.zip?attredirects=0&d=1 Diff 檔: https://sites.google.com/site/ray2501/ scim-array-patch/scim_array_imengine_setup.diff?attredirects=0&d=1 上面的連結請二行合成一行。 -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 115.43.69.56
文章代碼(AID): #1HLt_uIb (Array)
文章代碼(AID): #1HLt_uIb (Array)