rewrite config, add helper module and property in toolbar for launch unikey-setup
authorMr.LeQuocTuan <Mr.LeQuocTuan@79bd180b-0a32-48ee-ac55-ada8cae9df61>
Sat, 4 Jul 2009 04:14:24 +0000 (04:14 +0000)
committerMr.LeQuocTuan <Mr.LeQuocTuan@79bd180b-0a32-48ee-ac55-ada8cae9df61>
Sat, 4 Jul 2009 04:14:24 +0000 (04:14 +0000)
git-svn-id: svn://localhost/trunk@38 79bd180b-0a32-48ee-ac55-ada8cae9df61

19 files changed:
po/POTFILES.in
po/scim-unikey.pot
po/vi.po
setup/Makefile.am
setup/config_utils.cpp [new file with mode: 0644]
setup/config_utils.h [new file with mode: 0644]
setup/dlg_macro_table.cpp [new file with mode: 0644]
setup/dlg_macro_table.h [new file with mode: 0644]
setup/dlg_main_setup.cpp [new file with mode: 0644]
setup/dlg_main_setup.h [new file with mode: 0644]
setup/scim_unikey_helper.cpp [new file with mode: 0644]
setup/scim_unikey_setup.cpp
setup/scimkeyselection.h [deleted file]
setup/setup-macro.glade [new file with mode: 0644]
setup/setup-main.glade [new file with mode: 0644]
setup/unikey_setup.cpp [new file with mode: 0644]
src/Makefile.am
src/scim_unikey_const.h
src/scim_unikey_imengine.cpp

index 90bf9f7b469c86b6270c24543739004f55dc2f4b..7db539a8632e77f6bd63cb93ea36ca5a59b81211 100644 (file)
@@ -1,4 +1,7 @@
 # List of source files which contain translatable strings.
 src/scim_unikey_imengine.cpp
 setup/scim_unikey_setup.cpp
+setup/scim_unikey_helper.cpp
+setup/setup-main.glade
+setup/setup-macro.glade
 
index 3c30b4374be65a0c04aab451da17b6c47f6777d2..74f3970b6021ef5653f3416c2656255595ad68dc 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: scim-unikey 0.3~r32\n"
 "Report-Msgid-Bugs-To: mr.lequoctuan@gmail.com\n"
-"POT-Creation-Date: 2009-07-01 19:50+0700\n"
+"POT-Creation-Date: 2009-07-04 10:59+0700\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -21,10 +21,9 @@ msgid ""
 "This IME work best when environment variable are\n"
 "- GTK_IM_MODULE=scim-bridge\n"
 "- QT_IM_MODULE=xim\n"
-" If you use preedit, you don't not need that\n"
 "\n"
 "Some time, in some application, you \"must\"\n"
-"enable Preedit to type best\n"
+"enable Preedit to input properly\n"
 "\n"
 "In some application, scim can't enable,\n"
 "this is not a bug of scim-unikey.\n"
@@ -38,128 +37,139 @@ msgid ""
 "  http://forum.ubuntu-vn.org/viewforum.php?f=85"
 msgstr ""
 
-#: src/scim_unikey_imengine.cpp:685
+#: src/scim_unikey_imengine.cpp:684
 msgid "Choose input method"
 msgstr ""
 
-#: src/scim_unikey_imengine.cpp:702
+#: src/scim_unikey_imengine.cpp:701
 msgid "Choose output charset"
 msgstr ""
 
-#: src/scim_unikey_imengine.cpp:717
+#: src/scim_unikey_imengine.cpp:716
 msgid "Options"
 msgstr ""
 
-#: src/scim_unikey_imengine.cpp:719
+#: src/scim_unikey_imengine.cpp:718
 msgid "Configure Unikey here"
 msgstr ""
 
-#: src/scim_unikey_imengine.cpp:725 setup/scim_unikey_setup.cpp:146
+#: src/scim_unikey_imengine.cpp:724 setup/setup-main.glade:144
 msgid "Enable spell check"
 msgstr ""
 
-#: src/scim_unikey_imengine.cpp:727 setup/scim_unikey_setup.cpp:152
+#: src/scim_unikey_imengine.cpp:726
 msgid "If enable, you can decrease mistake when typing"
 msgstr ""
 
-#: src/scim_unikey_imengine.cpp:733 setup/scim_unikey_setup.cpp:155
+#: src/scim_unikey_imengine.cpp:732 setup/setup-main.glade:156
 msgid "Auto restore keys with invalid words"
 msgstr ""
 
-#: src/scim_unikey_imengine.cpp:735 setup/scim_unikey_setup.cpp:161
+#: src/scim_unikey_imengine.cpp:734
 msgid ""
 "When typing a word not in Vietnamese,\n"
 "it will auto restore keystroke into original"
 msgstr ""
 
-#: src/scim_unikey_imengine.cpp:742 setup/scim_unikey_setup.cpp:165
+#: src/scim_unikey_imengine.cpp:741 setup/setup-main.glade:168
 msgid "Use oà, uý (instead of òa, úy)"
 msgstr ""
 
-#: src/scim_unikey_imengine.cpp:750 setup/scim_unikey_setup.cpp:171
+#: src/scim_unikey_imengine.cpp:749 setup/setup-main.glade:180
 msgid "Allow type with more freedom"
 msgstr ""
 
-#: src/scim_unikey_imengine.cpp:758 setup/scim_unikey_setup.cpp:184
+#: src/scim_unikey_imengine.cpp:757
 msgid "Enable Macro"
 msgstr ""
 
-#: src/scim_unikey_imengine.cpp:765
+#: src/scim_unikey_imengine.cpp:764
 msgid "Enable PreEdit"
 msgstr ""
 
-#: src/scim_unikey_imengine.cpp:767 setup/scim_unikey_setup.cpp:250
+#: src/scim_unikey_imengine.cpp:766
 msgid ""
 "This option is best for most application\n"
 "But you may don't like it because it have an underline when typing"
 msgstr ""
 
-#: src/scim_unikey_imengine.cpp:774 setup/scim_unikey_setup.cpp:207
+#: src/scim_unikey_imengine.cpp:773
 msgid "Process W at word begin"
 msgstr ""
 
-#: src/scim_unikey_imengine.cpp:776 setup/scim_unikey_setup.cpp:213
+#: src/scim_unikey_imengine.cpp:775
 msgid ""
 "If enable, type W at begin\n"
 "of word will change to Ư."
 msgstr ""
 
-#: setup/scim_unikey_setup.cpp:104
+#: src/scim_unikey_imengine.cpp:781
+msgid "Run Setup"
+msgstr ""
+
+#: setup/scim_unikey_setup.cpp:64 setup/scim_unikey_helper.cpp:36
 msgid "Unikey Setup"
 msgstr ""
 
-#: setup/scim_unikey_setup.cpp:137
-msgid "Unikey option"
+#: setup/scim_unikey_setup.cpp:94
+msgid ""
+"This setup has been detach from scim-setup.\n"
+"Please run Setup by right click on scim tray icon,\n"
+"choose Unikey setup or click on below button."
 msgstr ""
 
-#: setup/scim_unikey_setup.cpp:177
-msgid "Macro option"
+#: setup/scim_unikey_setup.cpp:102
+msgid "_Run setup"
 msgstr ""
 
-#: setup/scim_unikey_setup.cpp:190
-msgid "Macro Table"
+#: setup/scim_unikey_helper.cpp:38
+msgid "Launch a GUI program to setup Unikey"
 msgstr ""
 
-#: setup/scim_unikey_setup.cpp:196
-msgid "Edit the macro table for Macro function"
+#: setup/setup-main.glade:58
+msgid "Input method:"
 msgstr ""
 
-#: setup/scim_unikey_setup.cpp:200
-msgid "Telex option"
+#: setup/setup-main.glade:69
+msgid "Output charset: "
 msgstr ""
 
-#: setup/scim_unikey_setup.cpp:217
-msgid "Typing mode"
+#: setup/setup-main.glade:119
+msgid "<b>Input/Output</b>"
 msgstr ""
 
-#: setup/scim_unikey_setup.cpp:228
-msgid "Mode switch key:"
+#: setup/setup-main.glade:195
+msgid "Enable _macro"
 msgstr ""
 
-#: setup/scim_unikey_setup.cpp:244
-msgid "Preedit is default"
+#: setup/setup-main.glade:208
+msgid "_Edit macro"
 msgstr ""
 
-#: setup/scim_unikey_setup.cpp:401
-msgid "Macro table definition"
+#: setup/setup-main.glade:226
+msgid "Process _W at word begin"
 msgstr ""
 
-#: setup/scim_unikey_setup.cpp:429
-msgid "Word"
+#: setup/setup-main.glade:244
+msgid "<b>Options</b>"
 msgstr ""
 
-#: setup/scim_unikey_setup.cpp:437
-msgid "Replace with"
+#: setup/setup-main.glade:264 setup/setup-macro.glade:101
+msgid "gtk-ok"
 msgstr ""
 
-#: setup/scim_unikey_setup.cpp:444
-msgid "Delete"
+#: setup/setup-main.glade:278 setup/setup-macro.glade:115
+msgid "gtk-cancel"
+msgstr ""
+
+#: setup/setup-macro.glade:15
+msgid "Macro table definition"
 msgstr ""
 
-#: setup/scim_unikey_setup.cpp:449
-msgid "Delete All"
+#: setup/setup-macro.glade:57
+msgid "gtk-delete"
 msgstr ""
 
-#: setup/scim_unikey_setup.cpp:601
-msgid "(replace text)"
+#: setup/setup-macro.glade:71
+msgid "Delete _all"
 msgstr ""
index f113bb883fc59736867dcb4c3edcc39dbbe29a5d..157782374d0fb9189df27ccf6972d23707a4eb38 100644 (file)
--- a/po/vi.po
+++ b/po/vi.po
@@ -2,7 +2,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: scim-unikey\n"
 "Report-Msgid-Bugs-To: mr.lequoctuan@gmail.com\n"
-"POT-Creation-Date: 2009-07-01 19:50+0700\n"
+"POT-Creation-Date: 2009-07-04 10:59+0700\n"
 "PO-Revision-Date: \n"
 "Last-Translator: Le Quoc Tuan <mr.lequoctuan@gmail.com>\n"
 "Language-Team: Le Quoc Tuan <mr.lequoctuan@gmail.com>\n"
@@ -18,10 +18,9 @@ msgid ""
 "This IME work best when environment variable are\n"
 "- GTK_IM_MODULE=scim-bridge\n"
 "- QT_IM_MODULE=xim\n"
-" If you use preedit, you don't not need that\n"
 "\n"
 "Some time, in some application, you \"must\"\n"
-"enable Preedit to type best\n"
+"enable Preedit to input properly\n"
 "\n"
 "In some application, scim can't enable,\n"
 "this is not a bug of scim-unikey.\n"
@@ -34,12 +33,12 @@ msgid ""
 "For other support goto:\n"
 "  http://forum.ubuntu-vn.org/viewforum.php?f=85"
 msgstr ""
-"IME này hoạt động tốt nhất khi giá trị biến mi trường là\n"
+"IME này hoạt động tốt nhất khi giá trị biến môi trường là\n"
 "- GTK_IM_MODULE=scim-bridge\n"
-"- QT_IM_MODULE=ximNếu bạn dùng preedit, bạn không cần điều đó\n"
+"- QT_IM_MODULE=xim\n"
 "\n"
 "Thỉnh thoảng, trong một vài ứng dụng, bạn \"phải\"\n"
-"bật chức năng Preedit để gõ được tốt\n"
+"bật chức năng Preedit để có thể gõ được chính xác\n"
 "\n"
 "Trong vài ứng dụng, scim không thể bật,\n"
 "đây không phải là bug của scim-unikey.\n"
@@ -52,35 +51,35 @@ msgstr ""
 "Để nhận được sự hỗ trợ hãy ghé thăm:\n"
 "  http://forum.ubuntu-vn.org/viewforum.php?f=85"
 
-#: src/scim_unikey_imengine.cpp:685
+#: src/scim_unikey_imengine.cpp:684
 msgid "Choose input method"
 msgstr "Chọn kiểu gõ"
 
-#: src/scim_unikey_imengine.cpp:702
+#: src/scim_unikey_imengine.cpp:701
 msgid "Choose output charset"
 msgstr "Chọn bảng mã"
 
-#: src/scim_unikey_imengine.cpp:717
+#: src/scim_unikey_imengine.cpp:716
 msgid "Options"
 msgstr "Tùy chọn"
 
-#: src/scim_unikey_imengine.cpp:719
+#: src/scim_unikey_imengine.cpp:718
 msgid "Configure Unikey here"
 msgstr "Cấu hình Unikey ở đây"
 
-#: src/scim_unikey_imengine.cpp:725 setup/scim_unikey_setup.cpp:146
+#: src/scim_unikey_imengine.cpp:724 setup/setup-main.glade:144
 msgid "Enable spell check"
 msgstr "Bật kiểm tra chính tả"
 
-#: src/scim_unikey_imengine.cpp:727 setup/scim_unikey_setup.cpp:152
+#: src/scim_unikey_imengine.cpp:726
 msgid "If enable, you can decrease mistake when typing"
 msgstr "Nếu bật, bạn có thể giảm lỗi chính tả khi gõ"
 
-#: src/scim_unikey_imengine.cpp:733 setup/scim_unikey_setup.cpp:155
+#: src/scim_unikey_imengine.cpp:732 setup/setup-main.glade:156
 msgid "Auto restore keys with invalid words"
 msgstr "Tự động khôi phục phím với từ sai"
 
-#: src/scim_unikey_imengine.cpp:735 setup/scim_unikey_setup.cpp:161
+#: src/scim_unikey_imengine.cpp:734
 msgid ""
 "When typing a word not in Vietnamese,\n"
 "it will auto restore keystroke into original"
@@ -88,23 +87,23 @@ msgstr ""
 "Khi gõ một từ không phải tiếng Việt,\n"
 "nó sẽ tự động khôi phục phím gốc"
 
-#: src/scim_unikey_imengine.cpp:742 setup/scim_unikey_setup.cpp:165
+#: src/scim_unikey_imengine.cpp:741 setup/setup-main.glade:168
 msgid "Use oà, uý (instead of òa, úy)"
 msgstr "Đặt dấu oà, uý (thay vì òa, úy)"
 
-#: src/scim_unikey_imengine.cpp:750 setup/scim_unikey_setup.cpp:171
+#: src/scim_unikey_imengine.cpp:749 setup/setup-main.glade:180
 msgid "Allow type with more freedom"
 msgstr "Cho phép gõ tự do"
 
-#: src/scim_unikey_imengine.cpp:758 setup/scim_unikey_setup.cpp:184
+#: src/scim_unikey_imengine.cpp:757
 msgid "Enable Macro"
 msgstr "Cho phép gõ tắt"
 
-#: src/scim_unikey_imengine.cpp:765
+#: src/scim_unikey_imengine.cpp:764
 msgid "Enable PreEdit"
 msgstr "Bật PreEdit"
 
-#: src/scim_unikey_imengine.cpp:767 setup/scim_unikey_setup.cpp:250
+#: src/scim_unikey_imengine.cpp:766
 msgid ""
 "This option is best for most application\n"
 "But you may don't like it because it have an underline when typing"
@@ -112,11 +111,11 @@ msgstr ""
 "Tùy chọn này thì tốt cho hầu hết mọi ứng dụng\n"
 "Nhưng bạn có thể không thích nó, bởi vì nó có một đường gạch chân khi gõ"
 
-#: src/scim_unikey_imengine.cpp:774 setup/scim_unikey_setup.cpp:207
+#: src/scim_unikey_imengine.cpp:773
 msgid "Process W at word begin"
 msgstr "Xử lý phím W ở đầu từ"
 
-#: src/scim_unikey_imengine.cpp:776 setup/scim_unikey_setup.cpp:213
+#: src/scim_unikey_imengine.cpp:775
 msgid ""
 "If enable, type W at begin\n"
 "of word will change to Ư."
@@ -124,63 +123,113 @@ msgstr ""
 "Nếu bật, gõ W ở đầu\n"
 "của từ sẽ chuyển thành Ư."
 
-#: setup/scim_unikey_setup.cpp:104
+#: src/scim_unikey_imengine.cpp:781
+msgid "Run Setup"
+msgstr "Chạy trình cài đặt"
+
+#: setup/scim_unikey_setup.cpp:64 setup/scim_unikey_helper.cpp:36
 msgid "Unikey Setup"
 msgstr "Cài đặt Unikey"
 
-#: setup/scim_unikey_setup.cpp:137
-msgid "Unikey option"
-msgstr "Tùy chọn Unikey"
+#: setup/scim_unikey_setup.cpp:94
+msgid ""
+"This setup has been detach from scim-setup.\n"
+"Please run Setup by right click on scim tray icon,\n"
+"choose Unikey setup or click on below button."
+msgstr ""
+"Cài đặt ở đây đã được tách ra khỏi scim-setup.\n"
+"Vui lòng chạy trình cài đặt bằng cách click vào biểu tượng scim,\n"
+"sau đó chọn Chạy trình cài đặt hoặc click vào nút bên dưới."
+
+#: setup/scim_unikey_setup.cpp:102
+msgid "_Run setup"
+msgstr "Chạy trình cài đặt"
 
-#: setup/scim_unikey_setup.cpp:177
-msgid "Macro option"
-msgstr "Tùy chọn gõ tắt"
+#: setup/scim_unikey_helper.cpp:38
+msgid "Launch a GUI program to setup Unikey"
+msgstr "Chạy chương trình để cài đặt Unikey"
 
-#: setup/scim_unikey_setup.cpp:190
-msgid "Macro Table"
-msgstr "Bảng gõ tắt"
+#: setup/setup-main.glade:58
+msgid "Input method:"
+msgstr "Kiểu gõ: "
 
-#: setup/scim_unikey_setup.cpp:196
-msgid "Edit the macro table for Macro function"
-msgstr "Soạn thảo bảng gõ tắt cho chức năng gõ tắt"
+#: setup/setup-main.glade:69
+msgid "Output charset: "
+msgstr "Bảng mã: "
 
-#: setup/scim_unikey_setup.cpp:200
-msgid "Telex option"
-msgstr "Tùy chọn cho Telex"
+#: setup/setup-main.glade:119
+msgid "<b>Input/Output</b>"
+msgstr "<b>Nhập/Xuất</b>"
 
-#: setup/scim_unikey_setup.cpp:217
-msgid "Typing mode"
-msgstr "Chế độ gõ"
+#: setup/setup-main.glade:195
+msgid "Enable _macro"
+msgstr "Bật gõ tắt"
 
-#: setup/scim_unikey_setup.cpp:228
-msgid "Mode switch key:"
-msgstr "Phím chuyển chế độ"
+#: setup/setup-main.glade:208
+msgid "_Edit macro"
+msgstr "Sửa bảng gõ tắt"
 
-#: setup/scim_unikey_setup.cpp:244
-msgid "Preedit is default"
-msgstr "Preedit là mặc định"
+#: setup/setup-main.glade:226
+msgid "Process _W at word begin"
+msgstr "Sử lý phím _W ở đầu từ"
+
+#: setup/setup-main.glade:244
+msgid "<b>Options</b>"
+msgstr "<b>Tùy chọn</b>"
+
+#: setup/setup-main.glade:264 setup/setup-macro.glade:101
+msgid "gtk-ok"
+msgstr ""
+
+#: setup/setup-main.glade:278 setup/setup-macro.glade:115
+msgid "gtk-cancel"
+msgstr ""
 
-#: setup/scim_unikey_setup.cpp:401
+#: setup/setup-macro.glade:15
 msgid "Macro table definition"
 msgstr "Định nghĩa bảng gõ tắt"
 
-#: setup/scim_unikey_setup.cpp:429
-msgid "Word"
-msgstr "Từ"
+#: setup/setup-macro.glade:57
+msgid "gtk-delete"
+msgstr ""
+
+#: setup/setup-macro.glade:71
+msgid "Delete _all"
+msgstr "Xóa _hết"
+
+#, fuzzy
+#~ msgid "scim-unikey Setup"
+#~ msgstr "Cài đặt Unikey"
+
+#~ msgid "Unikey option"
+#~ msgstr "Tùy chọn Unikey"
+
+#~ msgid "Macro option"
+#~ msgstr "Tùy chọn gõ tắt"
+
+#~ msgid "Macro Table"
+#~ msgstr "Bảng gõ tắt"
+
+#~ msgid "Edit the macro table for Macro function"
+#~ msgstr "Soạn thảo bảng gõ tắt cho chức năng gõ tắt"
+
+#~ msgid "Telex option"
+#~ msgstr "Tùy chọn cho Telex"
+
+#~ msgid "Typing mode"
+#~ msgstr "Chế độ gõ"
 
-#: setup/scim_unikey_setup.cpp:437
-msgid "Replace with"
-msgstr "Thay thế bởi"
+#~ msgid "Mode switch key:"
+#~ msgstr "Phím chuyển chế độ"
 
-#: setup/scim_unikey_setup.cpp:444
-msgid "Delete"
-msgstr "Xóa"
+#~ msgid "Preedit is default"
+#~ msgstr "Preedit là mặc định"
 
-#: setup/scim_unikey_setup.cpp:449
-msgid "Delete All"
-msgstr "Xóa tất cả"
+#~ msgid "Word"
+#~ msgstr "Từ"
 
-#: setup/scim_unikey_setup.cpp:601
-msgid "(replace text)"
-msgstr "(chuỗi thay thế)"
+#~ msgid "Replace with"
+#~ msgstr "Thay thế bởi"
 
+#~ msgid "(replace text)"
+#~ msgstr "(chuỗi thay thế)"
index 10c72a1c100acd6495831ef8acaad46aa1d53132..c2b3c3b48bac9d03c9b36efbf4fce010d227c579 100644 (file)
@@ -4,21 +4,64 @@ INCLUDES = \
        -I$(top_srcdir)/ukengine \
        -I$(top_srcdir)/src \
        -DSCIM_ICONDIR=\"@SCIM_ICONDIR@\" \
-       -DSCIM_UNIKEY_VERSION=\"@PACKAGE_VERSION@\"
+       -DSCIM_UNIKEY_VERSION=\"@PACKAGE_VERSION@\" \
+       -DGLADE_DATA_DIR=\"$(pkgdatadir)/setup\" \
+       -DLOCALEDIR=\"$(localedir)\" \
+    -DLIBEXECDIR=\"$(libexecdir)\" \
+    -Wall
 
+noinst_HEADERS = \
+    dlg_main_setup.h \
+    dlg_macro_table.h \
+    config_utils.h
+
+
+glade_DATA = \
+    setup-main.glade \
+    setup-macro.glade
+
+gladedir = $(pkgdatadir)/setup
+
+EXTRA_DIST = $(glade_DATA)
+
+
+libexec_PROGRAMS = scim-setup-unikey
+
+scim_setup_unikey_SOURCES = \
+    unikey_setup.cpp \
+    dlg_main_setup.cpp \
+    dlg_macro_table.cpp \
+    config_utils.cpp
+
+scim_setup_unikey_CXXFLAGS = \
+    @SCIM_GTKUTILS_CFLAGS@ \
+    @SCIM_CFLAGS@
+
+scim_setup_unikey_LDFLAGS = \
+       @SCIM_GTKUTILS_LIBS@ \
+    @SCIM_LIBS@ \
+       $(top_builddir)/ukengine/libunikey-scim.la
+
+
+# helper module: for launch setup
+helperdir                   = @SCIM_MODULEDIR@/Helper
+helper_LTLIBRARIES           = unikey-helper.la
+unikey_helper_la_SOURCES    = scim_unikey_helper.cpp
+
+unikey_helper_la_CFLAGS     = @SCIM_CFLAGS@
+unikey_helper_la_CXXFLAGS   = $(unikey_setup_la_CFLAGS)
+unikey_helper_la_LDFLAGS    = -avoid-version -rpath $(helperdir) \
+                              -module @LIBTOOL_EXPORT_OPTIONS@
+
+# setup module
 setupdir                    = @SCIM_MODULEDIR@/SetupUI
 setup_LTLIBRARIES           = unikey-setup.la
 unikey_setup_la_SOURCES     = scim_unikey_setup.cpp
 
-noinst_HEADERS = scimkeyselection.h
-
-unikey_setup_la_LIBADD      = $(top_builddir)/ukengine/libunikey-scim.la
-
-unikey_setup_la_CFLAGS      = @SCIM_GTKUTILS_CFLAGS@ @SCIM_CFLAGS@
-unikey_setup_la_CXXFLAGS    = @SCIM_GTKUTILS_CFLAGS@ @SCIM_CFLAGS@
+unikey_setup_la_CFLAGS      = @SCIM_GTKUTILS_CFLAGS@
+unikey_setup_la_CXXFLAGS    = $(unikey_setup_la_CFLAGS)
 unikey_setup_la_LDFLAGS     = -avoid-version -rpath $(setupdir) \
                               -module @LIBTOOL_EXPORT_OPTIONS@ \
-                              @SCIM_GTKUTILS_LIBS@ @SCIM_LIBS@ \
-                              $(top_builddir)/src/unikey_la-scim_unikey_utils.lo
-endif
+                              @SCIM_GTKUTILS_LIBS@
 
+endif
diff --git a/setup/config_utils.cpp b/setup/config_utils.cpp
new file mode 100644 (file)
index 0000000..6c83826
--- /dev/null
@@ -0,0 +1,212 @@
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "dlg_main_setup.h"
+
+#include "scim_unikey_const.h"
+
+#define get_macro_file() (g_build_filename(g_getenv("HOME"), SCIM_IMENGINE_UNIKEY_MACROPATH, NULL))
+void scim_set_config(const gchar* key, GType t, gpointer data);
+gboolean scim_get_config(const gchar* key, GType t, gpointer data);
+
+void set_default_config(UnikeyMainSetupOptions* opt)
+{
+    opt->input_method = 0;
+    opt->output_charset = 0;
+
+    opt->enableSpellcheck = SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED_DEF;
+    opt->autoRestoreNonVn = SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE_DEF;
+    opt->modernStyle = SCIM_IMENGINE_UNIKEY_MODERNSTYLE_DEF;
+    opt->freeMarking = SCIM_IMENGINE_UNIKEY_FREEMARKING_DEF;
+    opt->enableMacro = SCIM_IMENGINE_UNIKEY_MACROENABLED_DEF;
+
+    opt->processwatbegin = SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN_DEF;
+
+    opt->macrofile = get_macro_file();
+}
+
+void read_config(UnikeyMainSetupOptions* opt)
+{
+    gboolean b;
+    int k;
+    gboolean t;
+    //gchar* s;
+
+    // get Input method
+    b = scim_get_config(SCIM_IMENGINE_UNIKEY_INPUTMETHOD, G_TYPE_INT, &k);
+    if (b == TRUE)
+    {
+        opt->input_method = k;
+    }
+    // END get Input method
+
+    // get Output charset
+    b = scim_get_config(SCIM_IMENGINE_UNIKEY_OUTPUTCHARSET, G_TYPE_INT, &k);
+    if (b == TRUE)
+    {
+        opt->output_charset = k;
+    }
+    // END get Output charset
+
+    // get Spellcheck
+    b = scim_get_config(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, G_TYPE_BOOLEAN, &t);
+    if (b == TRUE)
+    {
+        opt->enableSpellcheck = t;
+    }
+    // END get Spellcheck
+
+    // get autoRestoreNonVn
+    b = scim_get_config(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, G_TYPE_BOOLEAN, &t);
+    if (b == TRUE)
+    {
+        opt->autoRestoreNonVn = t;
+    }
+    // END get autoRestoreNonVn
+
+    // get modernStyle
+    b = scim_get_config(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, G_TYPE_BOOLEAN, &t);
+    if (b == TRUE)
+    {
+        opt->modernStyle = t;
+    }
+    // END get modernStyle
+
+    // get freeMarking
+    b = scim_get_config(SCIM_IMENGINE_UNIKEY_FREEMARKING, G_TYPE_BOOLEAN, &t);
+    if (b == TRUE)
+    {
+        opt->freeMarking = t;
+    }
+    // END get freeMarking
+
+    // get enableMacro
+    b = scim_get_config(SCIM_IMENGINE_UNIKEY_MACROENABLED, G_TYPE_BOOLEAN, &t);
+    if (b == TRUE)
+    {
+        opt->enableMacro = t;
+    }
+    // END get enableMacro
+
+    // get ProcessWAtBegin
+    b = scim_get_config(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, G_TYPE_BOOLEAN, &t);
+    if (b == TRUE)
+    {
+        opt->processwatbegin = t;
+    }
+    // END get ProcessWAtBegin
+}
+
+void write_config(UnikeyMainSetupOptions* opt)
+{
+    scim_set_config(SCIM_IMENGINE_UNIKEY_INPUTMETHOD, G_TYPE_INT, &opt->input_method);
+    scim_set_config(SCIM_IMENGINE_UNIKEY_OUTPUTCHARSET, G_TYPE_INT, &opt->output_charset);
+    scim_set_config(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, G_TYPE_BOOLEAN, &opt->enableSpellcheck);
+    scim_set_config(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, G_TYPE_BOOLEAN, &opt->autoRestoreNonVn);
+    scim_set_config(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, G_TYPE_BOOLEAN, &opt->modernStyle);
+    scim_set_config(SCIM_IMENGINE_UNIKEY_FREEMARKING, G_TYPE_BOOLEAN, &opt->freeMarking);
+    scim_set_config(SCIM_IMENGINE_UNIKEY_MACROENABLED, G_TYPE_BOOLEAN, &opt->enableMacro);
+    scim_set_config(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, G_TYPE_BOOLEAN, &opt->processwatbegin);
+}
+
+int force_engine_to_reload_config()
+{
+    return system("scim-config-agent --reload > /dev/null");
+}
+
+void scim_set_config(const gchar* key, GType t, gpointer data)
+{
+    gchar** argv;
+    gchar s[1024];
+    gchar* output;
+
+    argv = (gchar**)g_malloc(sizeof(gchar*)*4);
+    argv[0] = (gchar*)"scim-config-agent";
+    argv[1] = (gchar*)"--set";
+    argv[3] = (gchar*)NULL;
+
+    strcpy(s, key);
+    strcat(s, "=");
+
+    switch (t)
+    {
+    case G_TYPE_BOOLEAN:
+        strcat(s, *(gboolean*)data?"true":"false");
+        break;
+    case G_TYPE_INT:
+        sprintf(s+strlen(s), "%d", *(gint*)data);
+        break;
+    case G_TYPE_STRING:
+        strcat(s, *(gchar**)data);
+        break;
+    }
+
+    argv[2] = (gchar*)s;
+
+    g_spawn_sync(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &output, NULL, NULL, NULL);
+    free(output);
+}
+
+gboolean scim_get_config(const gchar* key, GType t, gpointer data)
+{
+    gchar** argv;
+    gchar* output;
+
+    argv = (gchar**)g_malloc(sizeof(gchar*)*4);
+    argv[0] = (gchar*)"scim-config-agent";
+    argv[1] = (gchar*)"--get";
+    argv[2] = (gchar*)key;
+    argv[3] = (gchar*)NULL;
+
+    g_spawn_sync(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &output, NULL, NULL, NULL);
+
+    free(argv);
+
+    output[strlen(output)-1] = 0;
+
+    if (strcmp(output, "Failed to get key value.") == 0)
+    {
+        free(output);
+        return FALSE;
+    }
+
+    gboolean* pb;
+    gint* pi;
+    gchar** pc;
+
+    switch(t)
+    {
+    case G_TYPE_BOOLEAN:
+        pb = (gboolean*)data;
+        if (strcmp(output, "true") == 0)
+            *pb = TRUE;
+        else if (strcmp(output, "false") == 0)
+            *pb = FALSE;
+        else
+        {
+            free(output);
+            return FALSE;
+        }
+        break;
+    case G_TYPE_INT:
+        pi = (gint*)data;
+        if (isalpha(output[0]))
+        {
+            free(output);
+            return FALSE;
+        }
+        else
+            *pi = atoi(output);
+        break;
+    case G_TYPE_STRING:
+        pc = (gchar**)data;
+        *pc = output;
+        return TRUE;
+    }
+
+    free(output);
+
+    return TRUE;
+}
+
diff --git a/setup/config_utils.h b/setup/config_utils.h
new file mode 100644 (file)
index 0000000..9c11b07
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __CONFIG_UTILS_H__
+#define __CONFIG_UTILS_H__
+
+void set_default_config(UnikeyMainSetupOptions* opt);
+void read_config(UnikeyMainSetupOptions* opt);
+void write_config(UnikeyMainSetupOptions* opt);
+int force_engine_to_reload_config();
+
+#endif
+
diff --git a/setup/dlg_macro_table.cpp b/setup/dlg_macro_table.cpp
new file mode 100644 (file)
index 0000000..80224fd
--- /dev/null
@@ -0,0 +1,328 @@
+#include <gtk/gtk.h>
+#include <string.h>
+
+#include <libintl.h>
+#include "keycons.h"
+#include "mactab.h"
+#include "dlg_macro_table.h"
+
+#define _(str) gettext(str)
+
+
+#define STR_NULL_ITEM "..."
+#define MACRO_DEFAULT_VALUE _("(replace text)")
+
+enum {COL_KEY = 0, COL_VALUE, NUM_COLS};
+
+void key_edited_cb (GtkCellRendererText *celltext,
+                    const gchar *string_path,
+                    const gchar *newkey,
+                    gpointer user_data);
+void value_edited_cb(GtkCellRendererText *celltext,
+                     const gchar *string_path,
+                     const gchar *newvalue,
+                     gpointer data);
+void remove_macro_clicked_cb(GtkButton *button, gpointer user_data);
+void removeall_macro_clicked_cb(GtkButton *button, gpointer user_data);
+void check_last_macro_in_list(GtkListStore* list);
+
+
+GtkWidget* unikey_macro_dialog_new()
+{
+    GtkBuilder* builder = gtk_builder_new();
+
+    gtk_builder_add_from_file(builder, GLADE_DATA_DIR "/setup-macro.glade", NULL);
+
+    GtkWidget* dialog = GTK_WIDGET(gtk_builder_get_object(builder, "dlg_macro_table"));
+
+    // init macro list
+    GtkListStore* list = GTK_LIST_STORE(gtk_builder_get_object(builder, "list_macro"));
+    check_last_macro_in_list(list);
+
+    GtkTreeView* tree = GTK_TREE_VIEW(gtk_builder_get_object(builder, "tree_macro"));
+    g_object_set_data(G_OBJECT(dialog), "tree_macro", tree);
+
+    GtkTreeViewColumn* col;
+    GtkCellRenderer* render;
+
+// create key column
+    render = gtk_cell_renderer_text_new();
+    g_object_set(render,
+                 "editable", TRUE,
+                 "width-chars", MAX_MACRO_KEY_LEN+8,
+                 NULL);
+    g_signal_connect(render, "edited", G_CALLBACK(key_edited_cb), tree);
+    col = gtk_tree_view_column_new_with_attributes(_("Word"),
+                                                   render,
+                                                   "text",
+                                                   COL_KEY,
+                                                   NULL);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_append_column(tree, col);
+
+// create value column
+    render = gtk_cell_renderer_text_new();
+    g_object_set(render,
+                 "editable", TRUE,
+                 NULL);
+    g_signal_connect(render, "edited", G_CALLBACK(value_edited_cb), tree);
+    col = gtk_tree_view_column_new_with_attributes(_("Replace with"),
+                                                   render,
+                                                   "text",
+                                                   COL_VALUE,
+                                                   NULL);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_append_column(tree, col);
+
+    GtkWidget* btn;
+
+    // connect signal
+    btn = GTK_WIDGET(gtk_builder_get_object(builder, "btn_remove"));
+    g_signal_connect(btn, "clicked", G_CALLBACK(remove_macro_clicked_cb), tree);
+
+    // connect signal
+    btn = GTK_WIDGET(gtk_builder_get_object(builder, "btn_removeall"));
+    g_signal_connect(btn, "clicked", G_CALLBACK(removeall_macro_clicked_cb), tree);
+
+    g_object_unref(builder);
+
+    return dialog;
+}
+
+void unikey_macro_dialog_load_macro(GtkDialog* dialog, CMacroTable macro)
+{
+    GtkTreeView* tree;
+    GtkListStore* list;
+    GtkTreeIter iter;
+    gchar key[MAX_MACRO_KEY_LEN*3];
+    gchar value[MAX_MACRO_TEXT_LEN*3];
+    UKBYTE* p;
+    int inLen, maxOutLen;
+    int i, ret;
+
+    tree = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(dialog), "tree_macro"));
+    list = GTK_LIST_STORE(gtk_tree_view_get_model(tree));
+    
+    gtk_list_store_clear(list);
+
+    for (i = 0 ; i < macro.getCount(); i++)
+    {
+        // get key and convert to XUTF charset
+        p = (UKBYTE*)macro.getKey(i);
+        inLen = -1;
+        maxOutLen = sizeof(key);
+        ret = VnConvert(CONV_CHARSET_VNSTANDARD, CONV_CHARSET_XUTF8,
+                        p, (UKBYTE*)key,
+                        &inLen, &maxOutLen);
+        if (ret != 0)
+            continue;
+
+        // get value and convert to XUTF charset
+        p = (UKBYTE*)macro.getText(i);
+        inLen = -1;
+        maxOutLen = sizeof(value);
+        ret = VnConvert(CONV_CHARSET_VNSTANDARD, CONV_CHARSET_XUTF8,
+                        p, (UKBYTE*)value,
+                        &inLen, &maxOutLen);
+        if (ret != 0)
+            continue;
+
+        // append to liststore
+        gtk_list_store_append(list, &iter);
+        gtk_list_store_set(list, &iter, COL_KEY, key, COL_VALUE, value, -1);
+    }
+
+    check_last_macro_in_list(list);
+
+    // select first iter
+    GtkTreeSelection* select = gtk_tree_view_get_selection(tree);
+    gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list), &iter);
+    gtk_tree_selection_select_iter(select, &iter);
+}
+
+void unikey_macro_dialog_save_macro(GtkDialog* dialog, CMacroTable* macro)
+{
+    GtkTreeView* tree;
+    GtkTreeModel* model;
+    GtkTreeIter iter;
+    gboolean b;
+    gchar *key, *value;
+
+    macro->resetContent();
+
+    tree = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(dialog), "tree_macro"));
+    model = GTK_TREE_MODEL(gtk_tree_view_get_model(tree));
+
+    b = gtk_tree_model_get_iter_first(model, &iter);
+    while (b == TRUE)
+    {
+        gtk_tree_model_get(model, &iter, COL_KEY, &key, COL_VALUE, &value, -1);
+
+        if (strcasecmp(key, STR_NULL_ITEM) != 0)
+        {
+            macro->addItem(key, value, CONV_CHARSET_XUTF8);
+        }
+
+        b = gtk_tree_model_iter_next(model, &iter);
+    }
+}
+
+void key_edited_cb (GtkCellRendererText *celltext,
+                    const gchar *string_path,
+                    const gchar *newkey,
+                    gpointer data)
+{
+    GtkTreeView *tree;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    gchar *key, *oldkey, *oldvalue;
+    gchar nkey[MAX_MACRO_KEY_LEN];
+    gboolean b;
+
+    tree = GTK_TREE_VIEW(data);
+    model = gtk_tree_view_get_model(tree);
+
+    strncpy(nkey, newkey, MAX_MACRO_KEY_LEN-1);
+    nkey[MAX_MACRO_KEY_LEN-1] = '\0';
+
+    if (strcmp(nkey, STR_NULL_ITEM) == 0
+        || (strlen(STR_NULL_ITEM) != 0 && strlen(nkey) == 0))
+    {
+        return;
+    }
+
+    // check if any key same as newkey
+    b = gtk_tree_model_get_iter_first(model, &iter);
+    while (b)
+    {
+        gtk_tree_model_get(model, &iter, COL_KEY, &key, -1);
+        if (strcasecmp(key, nkey) == 0)
+        {
+            return;
+        }
+
+        b = gtk_tree_model_iter_next(model, &iter);
+    }
+    // end check
+
+    // get iter of newkey
+    gtk_tree_model_get_iter_from_string(model, &iter, string_path);
+    // get old value of that iter
+    gtk_tree_model_get(model, &iter, COL_KEY, &oldkey, COL_VALUE, &oldvalue, -1);
+
+    gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_KEY, nkey, -1);
+
+    if (strcmp(oldkey, STR_NULL_ITEM) == 0)
+    {
+        gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_VALUE, MACRO_DEFAULT_VALUE);
+    }
+
+    check_last_macro_in_list(GTK_LIST_STORE(model));
+}
+
+void value_edited_cb(GtkCellRendererText *celltext,
+                     const gchar *string_path,
+                     const gchar *newvalue,
+                     gpointer data)
+{
+    GtkTreeView *tree;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    gchar *key;
+    gchar value[MAX_MACRO_TEXT_LEN];
+
+    tree = GTK_TREE_VIEW(data);
+    model = gtk_tree_view_get_model(tree);
+
+    gtk_tree_model_get_iter_from_string(model, &iter, string_path);
+
+    gtk_tree_model_get(model, &iter, COL_KEY, &key, -1);
+
+    strncpy(value, newvalue, MAX_MACRO_TEXT_LEN-1);
+    value[MAX_MACRO_TEXT_LEN-1] = '\0';
+
+    if (strcmp(key, STR_NULL_ITEM) != 0)
+    {
+        gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_VALUE, value, -1);
+    }
+}
+
+void remove_macro_clicked_cb(GtkButton *button, gpointer user_data)
+{
+    GtkTreeView     *treeview;
+    GtkListStore    *list;
+    GtkTreeSelection*select;
+    GtkTreeIter     iter;
+    gchar           *key;
+
+    treeview = GTK_TREE_VIEW(user_data);
+
+    select = gtk_tree_view_get_selection(treeview);
+
+    list = GTK_LIST_STORE(gtk_tree_view_get_model(treeview));
+
+    if (gtk_tree_selection_get_selected(select, NULL, &iter) == TRUE)
+    {
+        gtk_tree_model_get(GTK_TREE_MODEL(list), &iter, COL_KEY, &key, -1);
+
+        if (strcmp(key, STR_NULL_ITEM) != 0)
+        {
+            gtk_list_store_remove(list, &iter);
+        }
+
+        gtk_tree_selection_select_iter(select, &iter); // select current index
+    }
+}
+
+void removeall_macro_clicked_cb(GtkButton *button, gpointer data)
+{
+    GtkTreeView* tree;
+    GtkListStore* list;
+    GtkTreeIter iter;
+    GtkTreeSelection* select;
+
+    tree = GTK_TREE_VIEW(data);
+    list = GTK_LIST_STORE(gtk_tree_view_get_model(tree));
+
+    gtk_list_store_clear(list);
+
+    check_last_macro_in_list(list);
+
+    select = gtk_tree_view_get_selection(tree);
+
+    gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list), &iter);
+
+    gtk_tree_selection_select_iter(select, &iter);
+}
+
+void check_last_macro_in_list(GtkListStore* list)
+{
+    GtkTreeIter iter;
+    gchar *key;
+    gint n;
+
+    // get number item in list
+    n = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(list), NULL);
+
+    if (n > 0)
+    {
+        // get last item
+        gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(list), &iter, NULL, n-1);
+
+        // get key of item
+        gtk_tree_model_get(GTK_TREE_MODEL(list), &iter, COL_KEY, &key, -1);
+    }
+
+    // if key is value used for NULL item
+    if (strcmp(key, STR_NULL_ITEM) == 0)
+    {
+        return;
+    }
+
+    // if last item is valid item or no item in list, add new NULL item
+    gtk_list_store_append(list, &iter);
+    gtk_list_store_set(list, &iter,
+                       COL_KEY, STR_NULL_ITEM,
+                       COL_VALUE, STR_NULL_ITEM,
+                       -1);
+}
diff --git a/setup/dlg_macro_table.h b/setup/dlg_macro_table.h
new file mode 100644 (file)
index 0000000..d254679
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __UNIKEY_MACRO_TABLE_H__
+#define __UNIKEY_MACRO_TABLE_H__
+
+#include "mactab.h"
+
+GtkWidget* unikey_macro_dialog_new();
+void unikey_macro_dialog_load_macro(GtkDialog* dialog, CMacroTable macro);
+void unikey_macro_dialog_save_macro(GtkDialog* dialog, CMacroTable* macro);
+
+#endif
diff --git a/setup/dlg_main_setup.cpp b/setup/dlg_main_setup.cpp
new file mode 100644 (file)
index 0000000..fc24144
--- /dev/null
@@ -0,0 +1,211 @@
+#include <gtk/gtk.h>
+
+#include "dlg_macro_table.h"
+#include "dlg_main_setup.h"
+
+enum {COL_IM_NAME = 0};
+enum {COL_OC_NAME = 0};
+
+void macro_enable_toggle_cb(GtkToggleButton* btn, gpointer user_data);
+void macro_edit_button_cb(GtkButton* btn, gpointer user_data);
+
+
+GtkWidget* unikey_main_setup_dialog_new()
+{
+    GtkBuilder* builder = gtk_builder_new();
+
+    gtk_builder_add_from_file(builder, GLADE_DATA_DIR "/setup-main.glade", NULL);
+
+    GtkDialog* dlg = GTK_DIALOG(gtk_builder_get_object(builder, "dlg_main_setup"));
+
+
+    // set data for input method combobox
+    GtkComboBox* cbb_im = GTK_COMBO_BOX(gtk_builder_get_object(builder, "cbb_input_method"));
+    GtkTreeModel* list_im = GTK_TREE_MODEL(gtk_builder_get_object(builder, "list_input_method"));
+
+    gtk_combo_box_set_model(cbb_im, list_im); // set model
+
+    GtkCellRenderer* render = gtk_cell_renderer_text_new();
+    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(cbb_im), render, TRUE);
+
+    gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(cbb_im),
+                                   render,
+                                   "text", COL_IM_NAME,
+                                   NULL);  // set Column Input method name
+    // END set data for input method combobox
+
+
+    // set data for output charset combobox
+    GtkComboBox* cbb_oc = GTK_COMBO_BOX(gtk_builder_get_object(builder, "cbb_output_charset"));
+    GtkTreeModel* list_oc = GTK_TREE_MODEL(gtk_builder_get_object(builder, "list_output_charset"));
+
+    gtk_combo_box_set_model(cbb_oc, list_oc); // set model
+
+    render = gtk_cell_renderer_text_new();
+    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(cbb_oc), render, TRUE);
+
+    gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(cbb_oc),
+                                   render,
+                                   "text", COL_OC_NAME,
+                                   NULL);  // set Column output charset nam
+    // END set data for output charset combobox
+
+    // set callback
+    GtkWidget* btn = GTK_WIDGET(gtk_builder_get_object(builder, "btn_macroedit")); // macro_edit button
+    g_signal_connect(btn, "clicked", G_CALLBACK(macro_edit_button_cb), dlg);
+
+    GtkWidget* wid = GTK_WIDGET(gtk_builder_get_object(builder, "check_macroenable")); // enable macro checkbox
+    g_signal_connect(wid, "toggled", G_CALLBACK(macro_enable_toggle_cb), btn);
+    // END set callback
+
+    // save object pointer for future use
+    g_object_set_data(G_OBJECT(dlg), "cbb_input_method", cbb_im);
+    g_object_set_data(G_OBJECT(dlg), "cbb_output_charset", cbb_oc);
+    g_object_set_data(G_OBJECT(dlg), "check_macroenable", wid);
+    g_object_set_data(G_OBJECT(dlg), "btn_macroedit", btn);
+    g_object_set_data(G_OBJECT(dlg),
+                      "check_spellcheck",
+                      gtk_builder_get_object(builder, "check_spellcheck"));
+    g_object_set_data(G_OBJECT(dlg),
+                      "check_autorestorenonvn",
+                      gtk_builder_get_object(builder, "check_autorestorenonvn"));
+    g_object_set_data(G_OBJECT(dlg),
+                      "check_modernstyle",
+                      gtk_builder_get_object(builder, "check_modernstyle"));
+    g_object_set_data(G_OBJECT(dlg),
+                      "check_freemarking",
+                      gtk_builder_get_object(builder, "check_freemarking"));
+    g_object_set_data(G_OBJECT(dlg),
+                      "check_processwatbegin",
+                      gtk_builder_get_object(builder, "check_processwatbegin"));
+    // END save object pointer
+
+    g_object_unref(builder);
+
+    return GTK_WIDGET(dlg);
+}
+
+void unikey_main_setup_set_values(const GtkDialog* dlg, const UnikeyMainSetupOptions *opt)
+{
+    GtkWidget* wid;
+
+// set input method
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "cbb_input_method"));
+    gtk_combo_box_set_active(GTK_COMBO_BOX(wid), opt->input_method);
+
+// set output charset
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "cbb_output_charset"));
+    gtk_combo_box_set_active(GTK_COMBO_BOX(wid), opt->output_charset);
+
+// set spellcheck?
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "check_spellcheck"));
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid), opt->enableSpellcheck);
+
+// set autorestorenonvn?
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "check_autorestorenonvn"));
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid), opt->autoRestoreNonVn);
+
+// set modernstyle?
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "check_modernstyle"));
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid), opt->modernStyle);
+
+// set freemarking?
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "check_freemarking"));
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid), opt->freeMarking);
+
+// set macroenable?
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "check_macroenable"));
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid), opt->enableMacro);
+
+// if disable macro, disable btn_macroedit
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "btn_macroedit"));
+    gtk_widget_set_sensitive(wid, opt->enableMacro);
+
+// set processwatbegin?
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "check_processwatbegin"));
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid), opt->processwatbegin);
+
+// set macro file name data
+    g_object_set_data(G_OBJECT(dlg), "macrofile", opt->macrofile);
+}
+
+void unikey_main_setup_get_values(const GtkDialog* dlg, UnikeyMainSetupOptions *opt)
+{
+    GtkWidget* wid;
+
+// get input method
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "cbb_input_method"));
+    opt->input_method = gtk_combo_box_get_active(GTK_COMBO_BOX(wid));
+
+// get output charset
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "cbb_output_charset"));
+    opt->output_charset = gtk_combo_box_get_active(GTK_COMBO_BOX(wid));
+
+// get spellcheck?
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "check_spellcheck"));
+    opt->enableSpellcheck = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wid));
+
+// get autorestorenonvn?
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "check_autorestorenonvn"));
+    opt->autoRestoreNonVn = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wid));
+
+// get modernstyle?
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "check_modernstyle"));
+    opt->modernStyle = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wid));
+
+// get freemarking?
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "check_freemarking"));
+    opt->freeMarking = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wid));
+
+// get macroenable?
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "check_macroenable"));
+    opt->enableMacro = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wid));
+
+// get processwatbegin?
+    wid = GTK_WIDGET(g_object_get_data(G_OBJECT(dlg), "check_processwatbegin"));
+    opt->processwatbegin = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wid));
+}
+
+void macro_enable_toggle_cb(GtkToggleButton* btn, gpointer user_data)
+{
+    gboolean b = gtk_toggle_button_get_active(btn);
+    gtk_widget_set_sensitive(GTK_WIDGET(user_data), b);
+}
+
+void macro_edit_button_cb(GtkButton* btn, gpointer user_data)
+{
+    GtkWidget* parent_dlg = GTK_WIDGET(user_data);
+
+    gtk_widget_set_sensitive(parent_dlg, FALSE);
+
+    GtkWidget* dlg = unikey_macro_dialog_new();
+
+    gchar* macrofile = (gchar*)(g_object_get_data(G_OBJECT(parent_dlg), "macrofile"));
+
+    CMacroTable macro;
+    macro.init();
+    macro.loadFromFile(macrofile);
+
+    unikey_macro_dialog_load_macro(GTK_DIALOG(dlg), macro);
+
+    int ret = gtk_dialog_run(GTK_DIALOG(dlg));
+
+    if (ret == GTK_RESPONSE_OK)
+    {
+        unikey_macro_dialog_save_macro(GTK_DIALOG(dlg), &macro);
+
+        GFile* f = g_file_get_parent(g_file_new_for_path(macrofile));
+        if (g_file_query_exists(f, NULL) == FALSE)
+        {
+            g_file_make_directory_with_parents(f, NULL, NULL);
+        }
+        g_object_unref(f);
+
+        macro.writeToFile(macrofile);
+    }
+
+    gtk_widget_destroy(dlg);
+
+    gtk_widget_set_sensitive(parent_dlg, TRUE);
+}
+
diff --git a/setup/dlg_main_setup.h b/setup/dlg_main_setup.h
new file mode 100644 (file)
index 0000000..8f20fff
--- /dev/null
@@ -0,0 +1,22 @@
+#include <gtk/gtk.h>
+
+typedef struct
+{
+    int input_method;
+    int output_charset;
+    
+    gboolean enableSpellcheck;
+    gboolean autoRestoreNonVn;
+    gboolean modernStyle;
+    gboolean freeMarking;
+    gboolean enableMacro;
+    gboolean processwatbegin;
+
+    gchar* macrofile;
+} UnikeyMainSetupOptions;
+
+GtkWidget* unikey_main_setup_dialog_new();
+
+void unikey_main_setup_set_values(const GtkDialog* dlg, const UnikeyMainSetupOptions *opt);
+void unikey_main_setup_get_values(const GtkDialog* dlg, UnikeyMainSetupOptions *opt);
+
diff --git a/setup/scim_unikey_helper.cpp b/setup/scim_unikey_helper.cpp
new file mode 100644 (file)
index 0000000..2b7cf2e
--- /dev/null
@@ -0,0 +1,74 @@
+/**
+   Scim-Unikey Input Method
+
+   Copyright (C) 2008-2009 Ubuntu-VN <http://www.ubuntu-vn.org>
+   Author: Le Quoc Tuan <mr.lequoctuan@gmail.com>
+   Home: http://scim-unikey.googlecode.com
+   License: GNU LESSER GENERAL PUBLIC LICENSE v2.1
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define Uses_SCIM_CONFIG_BASE
+#define Uses_SCIM_CONFIG_PATH
+#define Uses_SCIM_MODULE
+#define Uses_SCIM_IMENGINE_MODULE
+#define Uses_SCIM_HELPER
+#define Uses_STL_MAP
+
+#include <libintl.h>
+#define _(String) dgettext(PACKAGE_NAME,String)
+
+#include <scim.h>
+#include "scim_unikey_const.h"
+
+#define scim_module_init                        unikey_helper_LTX_scim_module_init
+#define scim_module_exit                        unikey_helper_LTX_scim_module_exit
+#define scim_helper_module_number_of_helpers    unikey_helper_LTX_scim_helper_module_number_of_helpers
+#define scim_helper_module_get_helper_info      unikey_helper_LTX_scim_helper_module_get_helper_info
+#define scim_helper_module_run_helper           unikey_helper_LTX_scim_helper_module_run_helper
+
+using namespace scim;
+
+static HelperInfo __helper_info (String("d64561de-c638-427e-9f9c-dd84e15043ab"),
+                                                                String(_("Unikey Setup")),
+                                                                String(SCIM_ICONDIR)+String(SCIM_UNIKEY_ICON_MAIN),
+                                                                String(_("Launch a GUI program to setup Unikey")),
+                                                                SCIM_HELPER_STAND_ALONE);
+
+extern "C"
+{
+       void scim_module_init()
+       {
+       }
+
+       void scim_module_exit()
+       {
+       }
+
+       unsigned int scim_helper_module_number_of_helpers()
+       {
+               return 1;
+       }
+
+       bool scim_helper_module_get_helper_info(unsigned int idx, HelperInfo &info)
+       {
+               if (idx == 0)
+               {
+                       info = __helper_info;
+                       return true;
+               }
+               return false;
+       }
+
+       void scim_helper_module_run_helper(const String &uuid, const ConfigPointer &config, const String &display)
+       {
+               if (uuid == "d64561de-c638-427e-9f9c-dd84e15043ab")
+               {
+                       system(LIBEXECDIR "/scim-setup-unikey &");
+               }
+       }
+}
+
index cb8bd8c5436ffb2dffff27654715b8738436c7fe..1084a4ff9e3fa7d5702a4c8432b717caee37701f 100644 (file)
 #include <string.h>
 
 #include <scim.h>
-#include "scim_unikey_const.h"
-#include "scim_unikey_utils.h"
-#include "keycons.h"
-#include "mactab.h"
-#include "scimkeyselection.h"
 
 using namespace scim;
 
@@ -40,44 +35,9 @@ using namespace scim;
 #define scim_setup_module_save_config     unikey_setup_LTX_scim_setup_module_save_config
 #define scim_setup_module_query_changed   unikey_setup_LTX_scim_setup_module_query_changed
 
-static bool    __have_changed                       = false;
-
-static bool    __unikey_preedit                     = SCIM_IMENGINE_UNIKEY_PREEDIT_DEF;
-static bool    __unikey_freemarking                 = SCIM_IMENGINE_UNIKEY_FREEMARKING_DEF;
-static bool    __unikey_modernstyle                 = SCIM_IMENGINE_UNIKEY_MODERNSTYLE_DEF;
-static bool    __unikey_macroenabled                = SCIM_IMENGINE_UNIKEY_MACROENABLED_DEF;
-static bool    __unikey_spellcheckenabled           = SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED_DEF;
-static bool    __unikey_autononvnrestore            = SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE_DEF;
-static bool    __unikey_processwatwordbegin       = SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN_DEF;
-
-static GtkTooltips  *__widget_tooltips              = 0;
-static GtkWidget    *__widget_preedit               = 0;
-static GtkWidget    *__widget_preedit_skey          = 0;
-static GtkWidget    *__widget_freemarking           = 0;
-static GtkWidget    *__widget_modernstyle           = 0;
-static GtkWidget    *__widget_macroenabled          = 0;
-static GtkWidget    *__widget_spellcheckenabled     = 0;
-static GtkWidget    *__widget_autononvnrestore      = 0;
-static GtkWidget    *__widget_processwatwordbegin   = 0;
-static CMacroTable  __macStore;
+void run_setup_button_cb(GtkButton* btn, gpointer user_data);
 
 static GtkWidget* create_setup_window();
-static void load_config(const ConfigPointer &config);
-static void save_config(const ConfigPointer &config);
-static bool query_changed();
-
-static void setup_widget_value();
-static GtkListStore* create_and_fill_list_store();
-
-static void on_default_toggle_button_toggled(GtkToggleButton *togglebutton, gpointer user_data);
-static void on_macrotable_button_clicked(GtkButton *button, gpointer user_data);
-static void on_key_edited (GtkCellRendererText *celltext, const gchar *string_path, const gchar *new_text, gpointer data);
-static void on_replace_edited (GtkCellRendererText *celltext, const gchar *string_path, const gchar *new_text, gpointer data);
-static void on_end_macro_table(GtkListStore *liststore);
-static void on_del_macro_clicked(GtkButton *button, gpointer user_data);
-static void on_delall_macro_clicked(GtkButton *button, gpointer user_data);
-static gboolean iter_2_macro(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
-static void on_hotkey_button_clicked(GtkButton *button, gpointer user_data);
 
 extern "C"
 {
@@ -111,17 +71,15 @@ extern "C"
 
     void scim_setup_module_load_config(const ConfigPointer &config)
     {
-        load_config(config);
     }
 
     void scim_setup_module_save_config(const ConfigPointer &config)
     {
-        save_config(config);
     }
 
     bool scim_setup_module_query_changed()
     {
-        return query_changed();
+        return FALSE;
     }
 } // extern "C"
 
@@ -130,541 +88,28 @@ static GtkWidget* create_setup_window()
     static GtkWidget *window = 0;
     if (!window)
     {
-        gtk_window_set_default_icon_from_file(SCIM_ICONDIR SCIM_UNIKEY_ICON_FILENAME, NULL);
-        __widget_tooltips = gtk_tooltips_new();
-
-// create Unikey option frame
-        GtkWidget *frUkOpt = gtk_frame_new(_("Unikey option"));
-        gtk_container_set_border_width(GTK_CONTAINER(frUkOpt), 5);
-
-        // create box for frame
-        GtkWidget *vbox = gtk_vbox_new(true, 0);
-        gtk_container_add(GTK_CONTAINER(frUkOpt), vbox);
-
-
-        // create spellcheck checkbox
-        __widget_spellcheckenabled = gtk_check_button_new_with_label(_("Enable spell check"));
-        gtk_box_pack_start(GTK_BOX(vbox), __widget_spellcheckenabled, false, false, 0);
-        gtk_container_set_border_width(GTK_CONTAINER(__widget_spellcheckenabled), 5);
-        g_signal_connect(__widget_spellcheckenabled, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_spellcheckenabled);
-
-        gtk_tooltips_set_tip (__widget_tooltips, __widget_spellcheckenabled,
-                              _("If enable, you can decrease mistake when typing"), NULL);
-
-        // create autononvnrestore checkbox
-        __widget_autononvnrestore = gtk_check_button_new_with_label(_("Auto restore keys with invalid words"));
-        gtk_box_pack_start(GTK_BOX(vbox), __widget_autononvnrestore, false, false, 0);
-        gtk_container_set_border_width(GTK_CONTAINER(__widget_autononvnrestore), 5);
-        g_signal_connect(__widget_autononvnrestore, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_autononvnrestore);
-
-        gtk_tooltips_set_tip (__widget_tooltips, __widget_autononvnrestore,
-                              _("When typing a word not in Vietnamese,\n"
-                              "it will auto restore keystroke into original"), NULL);
-
-        // create modernstyle checkbox
-        __widget_modernstyle = gtk_check_button_new_with_label(_("Use oà, uý (instead of òa, úy)"));
-        gtk_box_pack_start(GTK_BOX(vbox), __widget_modernstyle, false, false, 0);
-        gtk_container_set_border_width(GTK_CONTAINER(__widget_modernstyle), 5);
-        g_signal_connect(__widget_modernstyle, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_modernstyle);
-
-        // create freemarking checkbox
-        __widget_freemarking = gtk_check_button_new_with_label(_("Allow type with more freedom"));
-        gtk_box_pack_start(GTK_BOX(vbox), __widget_freemarking, false, false, 0);
-        gtk_container_set_border_width(GTK_CONTAINER(__widget_freemarking), 5);
-        g_signal_connect(__widget_freemarking, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_freemarking);
-
-// create Macro option frame
-        GtkWidget* frMacro = gtk_frame_new(_("Macro option"));
-        gtk_container_set_border_width(GTK_CONTAINER(frMacro), 5);
-
-        vbox = gtk_vbox_new(true, 0);
-        gtk_container_add(GTK_CONTAINER(frMacro), vbox);
-
-        // create macroenabled checkbox
-        __widget_macroenabled = gtk_check_button_new_with_label(_("Enable Macro"));
-        gtk_box_pack_start(GTK_BOX(vbox), __widget_macroenabled, false, false, 0);
-        gtk_container_set_border_width(GTK_CONTAINER(__widget_macroenabled), 5);
-        g_signal_connect(__widget_macroenabled, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_macroenabled);
-
-        // create macroedit button
-        GtkWidget* __widget_macrotable = gtk_button_new_with_label(_("Macro Table"));
-        gtk_box_pack_start(GTK_BOX(vbox), __widget_macrotable, false, false, 0);
-        gtk_container_set_border_width(GTK_CONTAINER(__widget_macrotable), 5);
-        g_signal_connect(__widget_macrotable, "clicked", G_CALLBACK(on_macrotable_button_clicked), NULL);
-
-        gtk_tooltips_set_tip (__widget_tooltips, __widget_macrotable,
-                              _("Edit the macro table for Macro function"), NULL);
-
-
-// create Telex option frame
-        GtkWidget *frTelex = gtk_frame_new(_("Telex option"));
-        gtk_container_set_border_width(GTK_CONTAINER(frTelex), 5);
-
-        vbox = gtk_vbox_new(true, 0);
-        gtk_container_add(GTK_CONTAINER(frTelex), vbox);
-
-        // create process w at word begin checkbox
-        __widget_processwatwordbegin = gtk_check_button_new_with_label(_("Process W at word begin"));
-        gtk_box_pack_start(GTK_BOX(vbox), __widget_processwatwordbegin, false, false, 0);
-        gtk_container_set_border_width(GTK_CONTAINER(__widget_processwatwordbegin), 5);
-        g_signal_connect(__widget_processwatwordbegin, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_processwatwordbegin);
+        window = gtk_vbox_new(TRUE, 0);
 
-        gtk_tooltips_set_tip (__widget_tooltips, __widget_processwatwordbegin,
-                              _("If enable, type W at begin\n"
-                              "of word will change to Ư."), NULL);
+        GtkWidget* label = gtk_label_new(_(
+                "This setup has been detach from scim-setup.\n"
+                "Please run Setup by right click on scim tray icon,\n"
+                "choose Unikey setup or click on below button."));
 
-// create preedit frame
-        GtkWidget *frPreEdit = gtk_frame_new(_("Typing mode"));
-        gtk_container_set_border_width(GTK_CONTAINER(frPreEdit), 5);
+        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
 
-        vbox = gtk_vbox_new(true, 0);
-        gtk_container_add(GTK_CONTAINER(frPreEdit), vbox);
+        gtk_box_pack_start(GTK_BOX(window), label, TRUE, FALSE, 0);
 
-        // create preedit switch key
-        GtkWidget *psbox = gtk_hbox_new(false, 0);
-        gtk_box_pack_start(GTK_BOX(vbox), psbox, false, false, 0);
+        GtkWidget* btn_runsetup = gtk_button_new_with_mnemonic(_("_Run setup"));
+        gtk_signal_connect(GTK_OBJECT(btn_runsetup), "clicked", G_CALLBACK(run_setup_button_cb), NULL);
+        gtk_box_pack_start(GTK_BOX(window), btn_runsetup, TRUE, FALSE, 0);
 
-
-        GtkWidget *lpskey = gtk_label_new(_("Mode switch key:"));
-        gtk_box_pack_start(GTK_BOX(psbox), lpskey, false, false, 5);
-
-
-        GtkWidget *bpskey = gtk_button_new_with_label("...");
-        gtk_box_pack_end(GTK_BOX(psbox), bpskey, false, false, 0);
-        gtk_container_set_border_width(GTK_CONTAINER(bpskey), 5);
-
-        __widget_preedit_skey = gtk_entry_new();
-        gtk_entry_set_editable(GTK_ENTRY(__widget_preedit_skey), false);
-        gtk_box_pack_end(GTK_BOX(psbox), __widget_preedit_skey, true, true, 0);
-
-        g_signal_connect(bpskey, "clicked", G_CALLBACK(on_hotkey_button_clicked), __widget_preedit_skey);
-
-
-        // create preedit checkbox
-        __widget_preedit = gtk_check_button_new_with_label(_("Preedit is default"));
-        gtk_box_pack_start(GTK_BOX(vbox), __widget_preedit, false, false, 0);
-        gtk_container_set_border_width(GTK_CONTAINER(__widget_preedit), 5);
-        g_signal_connect(__widget_preedit, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_preedit);
-
-        gtk_tooltips_set_tip (__widget_tooltips, __widget_preedit,
-                              _("This option is best for most application\n"
-                              "But you may don't like it because it have an underline when typing"), NULL);
-
-
-// Create the toplevel box.
-        window = gtk_vbox_new(false, 0);
-
-        GtkWidget* hbox = gtk_hbox_new(false, 0);
-        gtk_box_pack_start(GTK_BOX(window), hbox, true, true, 0);
-        gtk_box_pack_start(GTK_BOX(window), frPreEdit, true, true, 0);
-
-        
-        vbox = gtk_vbox_new(false, 0);
-        // add frame to hbox
-        gtk_box_pack_start(GTK_BOX(hbox), frUkOpt, true, true, 0);
-        gtk_box_pack_start(GTK_BOX(hbox), vbox, true, true, 0);
-
-        // add frame to vbox
-        gtk_box_pack_start(GTK_BOX(vbox), frMacro, true, true, 0);
-        gtk_box_pack_start(GTK_BOX(vbox), frTelex, true, true, 0);
-
-        setup_widget_value();
         gtk_widget_show_all(window);
     }
     return window;
 }
 
-static void setup_widget_value()
-{
-    if (__widget_preedit)
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_preedit), __unikey_preedit);
-
-    if (__widget_spellcheckenabled)
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_spellcheckenabled), __unikey_spellcheckenabled);
-
-    if (__widget_autononvnrestore)
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_autononvnrestore), __unikey_autononvnrestore);
-
-    if (__widget_modernstyle)
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_modernstyle), __unikey_modernstyle);
-
-    if (__widget_freemarking)
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_freemarking), __unikey_freemarking);
-
-    if (__widget_macroenabled)
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_macroenabled), __unikey_macroenabled);
-
-    if (__widget_processwatwordbegin)
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_processwatwordbegin), __unikey_processwatwordbegin);
-}
-
-static void load_config(const ConfigPointer &config)
-{
-    if (!config.null())
-    {
-        bool t;
-        t = config->read(SCIM_IMENGINE_UNIKEY_PREEDIT, &__unikey_preedit);
-        if (!t) __unikey_preedit = SCIM_IMENGINE_UNIKEY_PREEDIT_DEF;
-
-        String s;        
-        t = config->read(SCIM_IMENGINE_UNIKEY_PREEDIT_SWITCH_KEY, &s);
-        gtk_entry_set_text(GTK_ENTRY(__widget_preedit_skey), t?s.c_str():SCIM_IMENGINE_UNIKEY_PREEDIT_SWITCH_KEY_DEF);
-
-        t = config->read(SCIM_IMENGINE_UNIKEY_FREEMARKING, &__unikey_freemarking);
-        if (!t) __unikey_freemarking = SCIM_IMENGINE_UNIKEY_FREEMARKING_DEF;
-
-        t = config->read(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, &__unikey_modernstyle);
-        if (!t) __unikey_modernstyle = SCIM_IMENGINE_UNIKEY_MODERNSTYLE_DEF;
-
-        t = config->read(SCIM_IMENGINE_UNIKEY_MACROENABLED, &__unikey_macroenabled);
-        if (!t) __unikey_macroenabled = SCIM_IMENGINE_UNIKEY_MACROENABLED_DEF;
-
-        t = config->read(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, &__unikey_spellcheckenabled);
-        if (!t) __unikey_spellcheckenabled = SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED_DEF;
-
-        t = config->read(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, &__unikey_autononvnrestore);
-        if (!t) __unikey_autononvnrestore = SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE_DEF;
-
-        t = config->read(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, &__unikey_processwatwordbegin);
-        if (!t) __unikey_processwatwordbegin = SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN_DEF;
-
-        __macStore.init();
-        __macStore.loadFromFile(getMacroFile());
-
-        setup_widget_value();
-        __have_changed = false;
-    }
-}
-
-static void save_config(const ConfigPointer &config)
-{
-    if (!config.null())
-    {
-        config->write(SCIM_IMENGINE_UNIKEY_PREEDIT, __unikey_preedit);
-        String s = String(gtk_entry_get_text(GTK_ENTRY(__widget_preedit_skey)));
-        config->write(SCIM_IMENGINE_UNIKEY_PREEDIT_SWITCH_KEY, s);
-        config->write(SCIM_IMENGINE_UNIKEY_FREEMARKING, __unikey_freemarking);
-        config->write(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, __unikey_modernstyle);
-        config->write(SCIM_IMENGINE_UNIKEY_MACROENABLED, __unikey_macroenabled);
-        config->write(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, __unikey_spellcheckenabled);
-        config->write(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, __unikey_autononvnrestore);
-        config->write(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, __unikey_autononvnrestore);
-        config->write(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, __unikey_processwatwordbegin);
-
-        s = String(getMacroFile());
-        FILE *f = fopen(s.c_str(), "wt");
-        if (f == NULL)
-        {
-            s = s.substr(0, s.rfind('/'));
-            int tmp=system((String("mkdir ") + s).c_str());
-        }
-        else
-            fclose(f);
-
-        __macStore.writeToFile(getMacroFile());
-
-        __have_changed = false;
-    }
-}
-
-static bool query_changed()
-{
-    return __have_changed;
-}
-
-static void on_default_toggle_button_toggled(GtkToggleButton *togglebutton, gpointer user_data)
-{
-    bool *toggle = static_cast<bool*> (user_data);
-
-    if (toggle)
-    {
-        *toggle = gtk_toggle_button_get_active (togglebutton);
-        __have_changed = true;
-    }
-}
-
-enum {COL_KEY = 0, COL_REPLACE, NUM_COLS};
-
-static void on_macrotable_button_clicked(GtkButton *button, gpointer user_data)
-{
-    GtkWidget           *dialog;
-    GtkWidget           *treeview;
-    GtkTreeModel        *model;
-    GtkTreeViewColumn   *col;
-    GtkWidget           *contentarea;
-    GtkWidget           *hbox, *vbox;
-    GtkCellRenderer     *renderer;
-
-// create main dialog
-    dialog = gtk_dialog_new();
-    gtk_window_set_default_size(GTK_WINDOW(dialog), 600, 300);
-    gtk_window_set_title(GTK_WINDOW(dialog), _("Macro table definition"));
-    gtk_dialog_add_buttons(GTK_DIALOG(dialog),
-                           GTK_STOCK_OK, GTK_RESPONSE_OK,
-                           GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                           NULL);
-
-    //contentarea = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); // only for GTK >= 2.14
-    contentarea = GTK_DIALOG(dialog)->vbox;
-
-    hbox = gtk_hbox_new (false, 5);
-    gtk_container_add(GTK_CONTAINER(contentarea), hbox);
-
-// create scroll window and tree view
-    model = GTK_TREE_MODEL(create_and_fill_list_store());
-
-    treeview = gtk_tree_view_new_with_model (model);
-
-    GtkWidget *scroll = gtk_scrolled_window_new(NULL, NULL);
-    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-
-    gtk_box_pack_start(GTK_BOX(hbox), scroll, true, true, 0);
-    gtk_container_add(GTK_CONTAINER(scroll), treeview);
-
-// create key column
-    renderer = gtk_cell_renderer_text_new();
-    g_object_set(renderer, "editable", true, NULL);
-    g_object_set(renderer, "width-chars", MAX_MACRO_KEY_LEN+4, NULL);
-    g_signal_connect(renderer, "edited", G_CALLBACK(on_key_edited), model);
-    col = gtk_tree_view_column_new_with_attributes(_("Word"), renderer, "text", COL_KEY, NULL);
-    gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), col);
-
-// create replace column
-    renderer = gtk_cell_renderer_text_new();
-    g_object_set(renderer, "editable", true, NULL);
-    //g_object_set(renderer, "width-chars", MAX_MACRO_KEY_LEN*3, NULL);
-    g_signal_connect(renderer, "edited", G_CALLBACK(on_replace_edited), model);
-    col = gtk_tree_view_column_new_with_attributes(_("Replace with"), renderer, "text", COL_REPLACE, NULL);
-    gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), col);
-
-    vbox = gtk_vbox_new (false, 0);
-    gtk_box_pack_end(GTK_BOX(hbox), vbox, false, false, 6);
-
-// create Del button
-    GtkWidget* btDel = gtk_button_new_with_label (_("Delete"));
-    gtk_box_pack_start(GTK_BOX(vbox), btDel, false, true, 3);
-    g_signal_connect(btDel, "clicked", G_CALLBACK(on_del_macro_clicked), treeview);
-
-// create DelAll button
-    GtkWidget *btDelAll = gtk_button_new_with_label (_("Delete All"));
-    gtk_box_pack_start(GTK_BOX(vbox), btDelAll, false, true, 3);
-    g_signal_connect(btDelAll, "clicked", G_CALLBACK(on_delall_macro_clicked), model);
-
-    gtk_widget_show_all(dialog);
-    gint result = gtk_dialog_run(GTK_DIALOG(dialog));
-
-// save Macro Table
-    if (result == GTK_RESPONSE_OK)
-    {
-        __macStore.init();
-        gtk_tree_model_foreach(model, iter_2_macro, NULL);
-
-        __have_changed = true;
-    }
-
-    g_object_unref(model);
-    gtk_widget_destroy(dialog);
-}
-
-static void on_end_macro_table(GtkListStore *liststore)
-{
-    GtkTreeIter     iter;
-    gchar           *lastkey;
-    gint n;
-
-    n = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(liststore), NULL);
-    if (n)
-    {
-        gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(liststore), &iter, NULL, n-1);
-    }
-    else
-    {
-        gtk_list_store_append(liststore, &iter);
-        gtk_list_store_set(liststore, &iter, COL_KEY, "...", COL_REPLACE, "...", -1);
-        return;
-    }
-
-    gtk_tree_model_get(GTK_TREE_MODEL(liststore), &iter, COL_KEY, &lastkey, -1);
-    if (strcmp(lastkey, "...") || n==0)
-    {
-        gtk_list_store_append(liststore, &iter);
-        gtk_list_store_set(liststore, &iter, COL_KEY, "...", COL_REPLACE, "...", -1);
-    }
-}
-
-static void on_del_macro_clicked(GtkButton *button, gpointer user_data)
+void run_setup_button_cb(GtkButton* btn, gpointer user_data)
 {
-    GtkTreeView     *treeview;
-    GtkListStore    *liststore;
-    GtkTreeSelection*tselect;
-    GtkTreeIter     iter;
-    gchar           *lastkey;
-
-    treeview = GTK_TREE_VIEW(user_data);
-    tselect = gtk_tree_view_get_selection(treeview);
-
-    if (gtk_tree_selection_get_selected(tselect, NULL, &iter))
-    {
-        liststore = GTK_LIST_STORE(gtk_tree_view_get_model(treeview));
-        gtk_tree_model_get(GTK_TREE_MODEL(liststore), &iter, COL_KEY, &lastkey, -1);
-        if (strcmp(lastkey, "..."))
-            gtk_list_store_remove(liststore, &iter);
-    }
-}
-
-static void on_delall_macro_clicked(GtkButton *button, gpointer user_data)
-{
-    GtkListStore    *liststore;
-    GtkTreeIter     iter;
-
-    liststore = GTK_LIST_STORE(user_data);
-
-    gtk_list_store_clear(liststore);
-    on_end_macro_table(liststore);
-}
-
-static GtkListStore* create_and_fill_list_store()
-{
-    GtkListStore*   liststore;
-    GtkTreeIter     iter;
-    FILE            *f;
-    char            key[MAX_MACRO_KEY_LEN*3], replace[MAX_MACRO_TEXT_LEN*3];
-    UKBYTE          *p;
-    int             i, inLen, maxOutLen, ret;
-
-    liststore = gtk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_STRING);
-
-// add key and replace to liststore
-    for (int i=0 ; i < __macStore.getCount() ; i++)
-    {
-        p = (UKBYTE *)__macStore.getKey(i);
-        inLen = -1;
-        maxOutLen = sizeof(key);
-        ret = VnConvert(CONV_CHARSET_VNSTANDARD, CONV_CHARSET_UNIUTF8,
-                        (UKBYTE *) p, (UKBYTE *)key,
-                        &inLen, &maxOutLen);
-        if (ret != 0)
-            continue;
-
-        p = (UKBYTE *)__macStore.getText(i);
-        inLen = -1;
-        maxOutLen = sizeof(replace);
-        ret = VnConvert(CONV_CHARSET_VNSTANDARD, CONV_CHARSET_UNIUTF8,
-                        p, (UKBYTE *)replace,
-                        &inLen, &maxOutLen);
-        if (ret != 0)
-            continue;
-
-        gtk_list_store_append(liststore, &iter);
-        gtk_list_store_set(liststore, &iter, COL_KEY, key, COL_REPLACE, replace, -1);
-    }
-
-    on_end_macro_table(liststore);
-    return liststore;
+    system(LIBEXECDIR "/scim-setup-unikey &");
 }
 
-static void on_key_edited (GtkCellRendererText *celltext, const gchar *string_path, const gchar *new_text, gpointer data)
-{
-    GtkTreeModel    *model;
-    GtkTreeIter     iter;
-    gchar           *curkey, *oldkey, *oldreplace;
-    bool            b;
-
-    model = GTK_TREE_MODEL (data);
-
-    if (strlen(new_text) <= 0 || strcmp(new_text, "...") == 0)
-    {
-        return;
-    }
-    else if (strlen(new_text) >= MAX_MACRO_KEY_LEN)
-    {
-        curkey = (gchar*)new_text;
-        curkey[MAX_MACRO_KEY_LEN-1] = '\0';
-    }
-
-    b = gtk_tree_model_get_iter_first(model, &iter);
-    while (b)
-    {
-        gtk_tree_model_get(model, &iter, COL_KEY, &curkey, -1);
-        if (strcasecmp(curkey, new_text) == 0)
-            return;
-
-        b = gtk_tree_model_iter_next(model, &iter);
-    }
-
-    gtk_tree_model_get_iter_from_string(model, &iter, string_path);
-    gtk_tree_model_get(model, &iter, COL_KEY, &oldkey, COL_REPLACE, &oldreplace, -1);
-
-    gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_KEY, new_text, -1);
-    if (!strcmp(oldkey, "..."))
-    {
-        gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_REPLACE, _("(replace text)"));
-    }
-
-    on_end_macro_table(GTK_LIST_STORE(model));
-}
-
-static void on_replace_edited (GtkCellRendererText *celltext, const gchar *string_path, const gchar *new_text, gpointer data)
-{
-    GtkTreeModel    *model;
-    GtkTreeIter     iter;
-    gchar           *oldkey, *tmp;
-
-    model = GTK_TREE_MODEL (data);
-    gtk_tree_model_get_iter_from_string(model, &iter, string_path);
-
-    gtk_tree_model_get(model, &iter, COL_KEY, &oldkey, -1);
-
-    if (strlen(new_text) >= MAX_MACRO_TEXT_LEN)
-    {
-        tmp = (gchar*)new_text;
-        tmp[MAX_MACRO_TEXT_LEN-1] = '\0';
-    }
-
-    if (strcmp(oldkey, "...") != 0)
-    {
-        gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_REPLACE, new_text, -1);
-    }
-}
-
-static gboolean iter_2_macro(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
-{
-    gchar   *key, *replace;
-    GtkTreeIter c;
-
-    c = *iter;
-
-    if (!gtk_tree_model_iter_next(model, &c))
-        return true;
-    gtk_tree_model_get(model, iter, COL_KEY, &key, COL_REPLACE, &replace, -1);
-
-    __macStore.addItem(key, replace, CONV_CHARSET_XUTF8);
-
-    return false;
-}
-
-static void on_hotkey_button_clicked (GtkButton *button, gpointer data)
-{
-    GtkWidget *wid = (GtkWidget*)data;
-
-    GtkWidget *dialog = scim_key_selection_dialog_new("Edit hotkey");
-    gint r;
-    const gchar *hotkeys = gtk_entry_get_text(GTK_ENTRY(wid));
-    
-    if (hotkeys)
-    {
-        scim_key_selection_dialog_set_keys(
-            SCIM_KEY_SELECTION_DIALOG(dialog), hotkeys);
-    }
-
-    r = gtk_dialog_run(GTK_DIALOG(dialog));
-
-    if (r == GTK_RESPONSE_OK)
-    {
-        const gchar *newkeys = scim_key_selection_dialog_get_keys(SCIM_KEY_SELECTION_DIALOG(dialog));
-        gtk_entry_set_text(GTK_ENTRY(wid), newkeys?newkeys:"");
-        __have_changed = true;
-    }
-
-    gtk_widget_destroy(dialog);
-}
diff --git a/setup/scimkeyselection.h b/setup/scimkeyselection.h
deleted file mode 100644 (file)
index 686725b..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-#ifndef __SCIM_KEY_SELECTION_H__
-#define __SCIM_KEY_SELECTION_H__
-
-#include <gtk/gtk.h>
-#include <scim.h>
-
-G_BEGIN_DECLS
-
-#define SCIM_TYPE_KEY_SELECTION            (scim_key_selection_get_type ())
-#define SCIM_KEY_SELECTION(obj)            (GTK_CHECK_CAST ((obj), SCIM_TYPE_KEY_SELECTION, ScimKeySelection))
-#define SCIM_KEY_SELECTION_CLASS(klass)    (GTK_CHECK_CLASS_CAST ((klass), SCIM_TYPE_KEY_SELECTION, ScimKeySelectionClass))
-#define SCIM_IS_KEY_SELECTION(obj)         (GTK_CHECK_TYPE ((obj), SCIM_TYPE_KEY_SELECTION))
-#define SCIM_IS_KEY_SELECTION_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SCIM_TYPE_KEY_SELECTION))
-#define SCIM_KEY_SELECTION_GET_CLASS(obj)  (GTK_CHECK_GET_CLASS ((obj), SCIM_TYPE_KEY_SELECTION, ScimKeySelectionClass))
-
-#define SCIM_TYPE_KEY_SELECTION_DIALOG            (scim_key_selection_dialog_get_type ())
-#define SCIM_KEY_SELECTION_DIALOG(obj)            (GTK_CHECK_CAST ((obj), SCIM_TYPE_KEY_SELECTION_DIALOG, ScimKeySelectionDialog))
-#define SCIM_KEY_SELECTION_DIALOG_CLASS(klass)    (GTK_CHECK_CLASS_CAST ((klass), SCIM_TYPE_KEY_SELECTION_DIALOG, ScimKeySelectionDialogClass))
-#define SCIM_IS_KEY_SELECTION_DIALOG(obj)         (GTK_CHECK_TYPE ((obj), SCIM_TYPE_KEY_SELECTION_DIALOG))
-#define SCIM_IS_KEY_SELECTION_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SCIM_TYPE_KEY_SELECTION_DIALOG))
-#define SCIM_KEY_SELECTION_DIALOG_GET_CLASS(obj)  (GTK_CHECK_GET_CLASS ((obj), SCIM_TYPE_KEY_SELECTION_DIALOG, ScimKeySelectionDialogClass))
-
-typedef struct _ScimKeySelection       ScimKeySelection;
-typedef struct _ScimKeySelectionClass  ScimKeySelectionClass;
-
-typedef struct _ScimKeySelectionDialog       ScimKeySelectionDialog;
-typedef struct _ScimKeySelectionDialogClass  ScimKeySelectionDialogClass;
-
-struct _ScimKeySelection
-{
-    GtkVBox  vbox;
-
-    GtkWidget *toggle_ctrl;
-    GtkWidget *toggle_alt;
-    GtkWidget *toggle_shift;
-    GtkWidget *toggle_meta;
-    GtkWidget *toggle_super;
-    GtkWidget *toggle_hyper;
-    GtkWidget *toggle_release;
-    GtkWidget *key_code;
-
-    GtkWidget        *list_view;
-    GtkTreeSelection *list_selection;
-    GtkListStore     *list_model;
-
-    gchar            *keys;
-};
-
-struct _ScimKeySelectionClass
-{
-    GtkVBoxClass parent_class;
-
-    void (*changed) (ScimKeySelection *keyselection);
-};
-
-struct _ScimKeySelectionDialog
-{
-    GtkDialog parent_instance;
-
-    GtkWidget *keysel;
-
-    GtkWidget *main_vbox;
-    GtkWidget *action_area;
-
-    GtkWidget *ok_button;
-    GtkWidget *cancel_button;
-};
-
-struct _ScimKeySelectionDialogClass
-{
-    GtkDialogClass parent_class;
-
-    /* Padding for future expansion */
-    void (*_gtk_reserved1) (void);
-    void (*_gtk_reserved2) (void);
-    void (*_gtk_reserved3) (void);
-    void (*_gtk_reserved4) (void);
-};
-
-GType                 scim_key_selection_get_type        (void) G_GNUC_CONST;
-
-GtkWidget*            scim_key_selection_new             (void);
-
-void                  scim_key_selection_set_keys        (ScimKeySelection       *keyselection,
-                                                          const gchar            *keys);
-
-void                  scim_key_selection_append_keys     (ScimKeySelection       *keyselection,
-                                                          const gchar            *keys);
-
-
-G_CONST_RETURN gchar* scim_key_selection_get_keys        (ScimKeySelection       *keyselection);
-
-
-GType                 scim_key_selection_dialog_get_type (void) G_GNUC_CONST;
-GtkWidget*            scim_key_selection_dialog_new      (const gchar            *title);
-void                  scim_key_selection_dialog_set_keys (ScimKeySelectionDialog *ksd,
-                                                          const gchar            *keys);
-G_CONST_RETURN gchar* scim_key_selection_dialog_get_keys (ScimKeySelectionDialog *ksd);
-
-G_END_DECLS
-
-#endif /* __GTK_KEY_SELECTION_H__ */
-
-/*
-vi:ts=4:nowrap:ai:expandtab
-*/
diff --git a/setup/setup-macro.glade b/setup/setup-macro.glade
new file mode 100644 (file)
index 0000000..2328e47
--- /dev/null
@@ -0,0 +1,145 @@
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 2.12 -->
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkListStore" id="list_macro">
+    <columns>
+      <!-- column-name keys -->
+      <column type="gchararray"/>
+      <!-- column-name values -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
+  <object class="GtkDialog" id="dlg_macro_table">
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Macro table definition</property>
+    <property name="modal">True</property>
+    <property name="window_position">center</property>
+    <property name="default_width">650</property>
+    <property name="default_height">350</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="type_hint">normal</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox5">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkHBox" id="main_macro_box">
+            <property name="visible">True</property>
+            <property name="spacing">6</property>
+            <child>
+              <object class="GtkScrolledWindow" id="macro_scroll_window">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hscrollbar_policy">automatic</property>
+                <property name="vscrollbar_policy">automatic</property>
+                <child>
+                  <object class="GtkTreeView" id="tree_macro">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="model">list_macro</property>
+                    <property name="search_column">0</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="vbox1">
+                <property name="visible">True</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">5</property>
+                <child>
+                  <object class="GtkButton" id="btn_remove">
+                    <property name="label" translatable="yes">gtk-delete</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_stock">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="btn_removeall">
+                    <property name="label" translatable="yes">Delete _all</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="image">img_remove</property>
+                    <property name="use_underline">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area5">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="btn_ok">
+                <property name="label" translatable="yes">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="btn_cancel">
+                <property name="label" translatable="yes">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-5">btn_ok</action-widget>
+      <action-widget response="-6">btn_cancel</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkImage" id="img_remove">
+    <property name="visible">True</property>
+    <property name="stock">gtk-delete</property>
+  </object>
+</interface>
diff --git a/setup/setup-main.glade b/setup/setup-main.glade
new file mode 100644 (file)
index 0000000..969ed49
--- /dev/null
@@ -0,0 +1,337 @@
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 2.12 -->
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkListStore" id="list_input_method">
+    <columns>
+      <!-- column-name inputmethodname -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Telex</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Vni</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Simple Telex</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Simple Telex 2</col>
+      </row>
+    </data>
+  </object>
+  <object class="GtkDialog" id="dlg_main_setup">
+    <property name="border_width">5</property>
+    <property name="window_position">center</property>
+    <property name="type_hint">normal</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox3">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkVBox" id="vbox1">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkFrame" id="fr_input_output">
+                <property name="visible">True</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
+                <child>
+                  <object class="GtkAlignment" id="alignment1">
+                    <property name="visible">True</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkHBox" id="box_io">
+                        <property name="visible">True</property>
+                        <child>
+                          <object class="GtkVBox" id="vbox11">
+                            <property name="visible">True</property>
+                            <property name="homogeneous">True</property>
+                            <child>
+                              <object class="GtkLabel" id="label3">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">Input method:</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label4">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">Output charset: </property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkVBox" id="vbox12">
+                            <property name="visible">True</property>
+                            <child>
+                              <object class="GtkComboBox" id="cbb_input_method">
+                                <property name="visible">True</property>
+                                <property name="model">list_input_method</property>
+                              </object>
+                              <packing>
+                                <property name="padding">2</property>
+                                <property name="pack_type">end</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBox" id="cbb_output_charset">
+                                <property name="visible">True</property>
+                                <property name="model">list_output_charset</property>
+                              </object>
+                              <packing>
+                                <property name="padding">2</property>
+                                <property name="pack_type">end</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Input/Output&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkFrame" id="frame1">
+                <property name="visible">True</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
+                <child>
+                  <object class="GtkAlignment" id="alignment2">
+                    <property name="visible">True</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkVBox" id="vbox2">
+                        <property name="visible">True</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">4</property>
+                        <child>
+                          <object class="GtkCheckButton" id="check_spellcheck">
+                            <property name="label" translatable="yes">Enable spell check</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkCheckButton" id="check_autorestorenonvn">
+                            <property name="label" translatable="yes">Auto restore keys with invalid words</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkCheckButton" id="check_modernstyle">
+                            <property name="label" translatable="yes">Use o&#xE0;, u&#xFD; (instead of &#xF2;a, &#xFA;y)</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkCheckButton" id="check_freemarking">
+                            <property name="label" translatable="yes">Allow type with more freedom</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkHBox" id="hbox1">
+                            <property name="visible">True</property>
+                            <child>
+                              <object class="GtkCheckButton" id="check_macroenable">
+                                <property name="label" translatable="yes">Enable _macro</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkButton" id="btn_macroedit">
+                                <property name="label" translatable="yes">_Edit macro</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="image">img_edit</property>
+                              </object>
+                              <packing>
+                                <property name="fill">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="position">4</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkCheckButton" id="check_processwatbegin">
+                            <property name="label" translatable="yes">Process _W at word begin</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_underline">True</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="position">5</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label2">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Options&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area3">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="btn_main_ok">
+                <property name="label" translatable="yes">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="btn_main_cancel">
+                <property name="label" translatable="yes">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-5">btn_main_ok</action-widget>
+      <action-widget response="-6">btn_main_cancel</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkImage" id="img_edit">
+    <property name="visible">True</property>
+    <property name="stock">gtk-edit</property>
+  </object>
+  <object class="GtkListStore" id="list_output_charset">
+    <columns>
+      <!-- column-name outputcharsetname -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Unicode</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">TCVN3</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">VNI Win</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">VIQR</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">CString</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">NCR Decimal</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">NCR Hex</col>
+      </row>
+    </data>
+  </object>
+</interface>
diff --git a/setup/unikey_setup.cpp b/setup/unikey_setup.cpp
new file mode 100644 (file)
index 0000000..90f253d
--- /dev/null
@@ -0,0 +1,48 @@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <libintl.h>
+#include <locale.h>
+#include <gtk/gtk.h>
+
+#include "dlg_main_setup.h"
+#include "config_utils.h"
+#include "scim_unikey_const.h"
+
+int main(int argc, char** argv)
+{
+    setlocale(LC_ALL, "");
+    bindtextdomain(PACKAGE_NAME, LOCALEDIR);
+    textdomain(PACKAGE_NAME);
+
+    gtk_init(&argc, &argv);
+
+    gtk_window_set_default_icon_from_file(SCIM_ICONDIR SCIM_UNIKEY_ICON_MAIN, NULL);
+
+    GtkWidget* main_dlg = unikey_main_setup_dialog_new(); // create main dlg
+
+    gtk_signal_connect(GTK_OBJECT(main_dlg), "destroy", gtk_main_quit, NULL); // connect with signal
+
+    UnikeyMainSetupOptions opt; // create option
+    set_default_config(&opt); // create default option
+
+    read_config(&opt); // read config
+
+    unikey_main_setup_set_values(GTK_DIALOG(main_dlg), &opt); // set config for dialog
+
+    int ret = gtk_dialog_run(GTK_DIALOG(main_dlg));
+
+    if (ret == GTK_RESPONSE_OK) // if pressed OK
+    {
+        unikey_main_setup_get_values(GTK_DIALOG(main_dlg), &opt); // get config from dialog
+
+        write_config(&opt);
+
+        force_engine_to_reload_config();
+    }
+
+    return 0;
+}
+
index 44e1c41e5aa12780b961ce6de6980a8a696681f5..a1999c060ac40bd9f8e3c361a66e73b58713b564 100644 (file)
@@ -1,7 +1,8 @@
 INCLUDES = \
        -I$(top_srcdir)/ukengine \
        -DSCIM_ICONDIR=\"@SCIM_ICONDIR@\" \
-       -DSCIM_UNIKEY_VERSION=\"@PACKAGE_VERSION@\"
+       -DSCIM_UNIKEY_VERSION=\"@PACKAGE_VERSION@\" \
+    -DLIBEXECDIR=\"$(libexecdir)\"
 
 imenginedir                = @SCIM_MODULEDIR@/IMEngine
 imengine_LTLIBRARIES       = unikey.la
index 6153bbc29ec1408697b29057ee1ecf240a594006..db9a7962d5530710636ade55ff5ee7146e207d3d 100644 (file)
@@ -10,7 +10,7 @@
 #if !defined (__SCIM_UNIKEY_IMENGINE_CONST_H)
 #define __SCIM_UNIKEY_IMENGINE_CONST_H
 
-#define SCIM_UNIKEY_ICON_FILENAME                       "/scim-unikey.png"
+#define SCIM_UNIKEY_ICON_MAIN                           "/scim-unikey.png"
 #define SCIM_UNIKEY_ICON_CONFIGURE                      "/scim-unikey-configure.png"
 #define SCIM_UNIKEY_ICON_CHECK                          "/scim-unikey-check.png"
 
index 01f81fb614105166cda8a5130e56c242d8ec906b..f1ea1d360b5601a2cdb77ef544a8e6210c4203f6 100644 (file)
@@ -134,11 +134,10 @@ WideString UnikeyFactory::get_help() const
 {
     return utf8_mbstowcs(_("This IME work best when environment variable are\n"
                            "- GTK_IM_MODULE=scim-bridge\n"
-                           "- QT_IM_MODULE=xim\n"
-                           " If you use preedit, you don't not need that\n\n"
-                           
+                           "- QT_IM_MODULE=xim\n\n"
+
                            "Some time, in some application, you \"must\"\n"
-                           "enable Preedit to type best\n\n"
+                           "enable Preedit to input properly\n\n"
 
                            "In some application, scim can't enable,\n"
                            "this is not a bug of scim-unikey.\n"
@@ -153,7 +152,7 @@ WideString UnikeyFactory::get_help() const
 }
 String UnikeyFactory::get_icon_file() const
 {
-    return String(SCIM_ICONDIR SCIM_UNIKEY_ICON_FILENAME);
+    return String(SCIM_ICONDIR SCIM_UNIKEY_ICON_MAIN);
 }
 
 IMEngineInstancePointer UnikeyFactory::create_instance(const String & encoding, int id)
@@ -777,6 +776,13 @@ PropertyList UnikeyInstance::CreatePropertyList()
                    "of word will change to Ư."));
     props.push_back(prop);
 
+    // config gui
+    prop.set_key("/Unikey/Options/RunSetup");
+    prop.set_label(_("Run Setup"));
+    prop.set_icon(SCIM_ICONDIR SCIM_UNIKEY_ICON_MAIN);
+    prop.set_tip("");
+    props.push_back(prop);
+
     return props;
 }
 
@@ -913,6 +919,12 @@ void UnikeyInstance::trigger_property(const String &property)
         change = true;
     }
 
+// run setup
+    else if (property == "/Unikey/Options/RunSetup")
+    {
+        system(LIBEXECDIR "/scim-setup-unikey &");
+    }
+
     if (change)
     {
         __config->flush();
@@ -920,3 +932,4 @@ void UnikeyInstance::trigger_property(const String &property)
         focus_in();
     }
 }
+