summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchoehwanjin <choe.hwanjin@gmail.com>2014-09-24 23:47:56 +0900
committerchoehwanjin <choe.hwanjin@gmail.com>2014-09-24 23:47:56 +0900
commit5cdec610ef74dd8bf73c67081b36b62f850257d9 (patch)
treea5648616bb1dacc6d0f172c7013a8b951a112d87
parent4f90882eadb6630b5200fcbe43d823918f48794a (diff)
parent8157550e394c478680925cc26a592ad10ceae1ee (diff)
downloadibus-hangul-5cdec610ef74dd8bf73c67081b36b62f850257d9.tar.gz
Merge pull request #22 from changwoo/python3
Python3 migration
-rw-r--r--setup/Makefile.am10
-rw-r--r--setup/hangul_keyboard_list.c43
-rw-r--r--setup/ibus-setup-hangul.in2
-rw-r--r--setup/main.py32
4 files changed, 27 insertions, 60 deletions
diff --git a/setup/Makefile.am b/setup/Makefile.am
index 4f52178..0eacf7b 100644
--- a/setup/Makefile.am
+++ b/setup/Makefile.am
@@ -31,13 +31,6 @@ setup_hanguldir = $(pkgdatadir)/setup
libexec_SCRIPTS = ibus-setup-hangul
-setuplibdir = $(pkglibdir)/setup
-setuplib_PROGRAMS = hangul_keyboard_list
-
-hangul_keyboard_list_SOURCES = hangul_keyboard_list.c
-hangul_keyboard_list_CFLAGS = $(HANGUL_CFLAGS)
-hangul_keyboard_list_LDADD = $(HANGUL_LIBS)
-
desktop_in_files = ibus-setup-hangul.desktop.in
desktop_DATA = ibus-setup-hangul.desktop
desktopdir = $(datadir)/applications
@@ -76,7 +69,8 @@ config.py: config.py.in Makefile
-e 's&@SETUP_PKGLIBDIR@&$(pkglibdir)&g' $< > $@
ibus-setup-hangul: ibus-setup-hangul.in config.py Makefile
- sed -e 's&@SETUP_PKGDATADIR@&$(pkgdatadir)&g' $< > $@
+ sed -e 's&@SETUP_PKGDATADIR@&$(pkgdatadir)&g' \
+ -e 's&\@PYTHON\@&$(PYTHON)&g' $< > $@
install-exec-hook:
$(mkdir_p) $(DESTDIR)$(bindir)
diff --git a/setup/hangul_keyboard_list.c b/setup/hangul_keyboard_list.c
deleted file mode 100644
index d47e1ea..0000000
--- a/setup/hangul_keyboard_list.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* vim:set et sw=4 sts=4: */
-/* ibus-hangul - The Hangul Engine For IBus
- * Copyright (C) 2010-2011 Choe Hwanjin <choe.hwanjin@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <locale.h>
-#include <hangul.h>
-
-int main()
-{
- int n;
- int i;
-
- setlocale(LC_ALL, "");
-
- n = hangul_ic_get_n_keyboards();
- for (i = 0; i < n; ++i) {
- const char* id;
- const char* name;
-
- id = hangul_ic_get_keyboard_id(i);
- name = hangul_ic_get_keyboard_name(i);
-
- printf("%s\t%s\n", id, name);
- }
-
- return 0;
-}
diff --git a/setup/ibus-setup-hangul.in b/setup/ibus-setup-hangul.in
index a2c87f9..de65297 100644
--- a/setup/ibus-setup-hangul.in
+++ b/setup/ibus-setup-hangul.in
@@ -19,5 +19,5 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-exec python @SETUP_PKGDATADIR@/setup/main.py $@
+exec @PYTHON@ @SETUP_PKGDATADIR@/setup/main.py $@
diff --git a/setup/main.py b/setup/main.py
index 6dff317..18a21ab 100644
--- a/setup/main.py
+++ b/setup/main.py
@@ -26,11 +26,30 @@ from gi.repository import IBus
import locale
import gettext
import config
-import subprocess
from keycapturedialog import KeyCaptureDialog
_ = lambda a : gettext.dgettext(config.gettext_package, a)
+
+def get_hangul_keyboard_list():
+ from ctypes import CDLL, c_int, c_char_p
+ libhangul = CDLL('libhangul.so.1')
+ libhangul.hangul_ic_get_n_keyboards.argtypes = []
+ libhangul.hangul_ic_get_n_keyboards.restype = c_int
+ libhangul.hangul_ic_get_keyboard_id.argtypes = [c_int]
+ libhangul.hangul_ic_get_keyboard_id.restype = c_char_p
+ libhangul.hangul_ic_get_keyboard_name.argtypes = [c_int]
+ libhangul.hangul_ic_get_keyboard_name.restype = c_char_p
+
+ n = libhangul.hangul_ic_get_n_keyboards()
+ list = []
+ for i in range(n):
+ id = libhangul.hangul_ic_get_keyboard_id(i).decode('UTF-8')
+ name = libhangul.hangul_ic_get_keyboard_name(i).decode('UTF-8')
+ list.append((id, name))
+ return list
+
+
class Setup ():
def __init__ (self, bus):
self.__bus = bus
@@ -43,17 +62,14 @@ class Setup ():
self.__builder.add_from_file(ui_file)
# Hangul tab
- pipe = subprocess.Popen([config.setuplibdir + '/hangul_keyboard_list'], stdout = subprocess.PIPE)
- list = pipe.communicate()[0].split('\n')
+ list = get_hangul_keyboard_list()
self.__hangul_keyboard = self.__builder.get_object("HangulKeyboard")
model = Gtk.ListStore(str, str, int)
i = 0
- for line in list:
- items = line.split('\t')
- if len(items) > 1:
- model.append([items[1], items[0], i])
- i+=1
+ for (id, name) in list:
+ model.append([name, id, i])
+ i+=1
self.__hangul_keyboard.set_model(model)
renderer = Gtk.CellRendererText()