diff -Nru fcitx-fbterm-0.1.4/CMakeLists.txt fcitx-fbterm-0.2.0/CMakeLists.txt --- fcitx-fbterm-0.1.4/CMakeLists.txt 2012-04-11 04:59:13.000000000 +0000 +++ fcitx-fbterm-0.2.0/CMakeLists.txt 2012-08-30 21:08:57.000000000 +0000 @@ -1,7 +1,12 @@ -project(fcitx-fbterm) cmake_minimum_required(VERSION 2.6) -FIND_PACKAGE(Gettext REQUIRED) -FIND_PACKAGE(Fcitx REQUIRED) + +project(fcitx-fbterm) + +find_package(PkgConfig REQUIRED) +find_package(Gettext REQUIRED) +find_package(Fcitx 4.2.6 REQUIRED) + +pkg_check_modules(FCITX_GCLIENT "fcitx-gclient>=4.2.6" REQUIRED) # uninstall target configure_file( diff -Nru fcitx-fbterm-0.1.4/debian/changelog fcitx-fbterm-0.2.0/debian/changelog --- fcitx-fbterm-0.1.4/debian/changelog 2012-08-25 02:01:50.000000000 +0000 +++ fcitx-fbterm-0.2.0/debian/changelog 2012-09-28 07:22:59.000000000 +0000 @@ -1,3 +1,9 @@ +fcitx-fbterm (0.2.0-1~oneiric) oneiric; urgency=low + + * Imported Upstream version 0.2.0 + + -- YunQiang Su Wed, 26 Sep 2012 20:56:38 +0800 + fcitx-fbterm (0.1.4-1~oneiric) oneiric; urgency=low * Fix debian/watch: googlecode diff -Nru fcitx-fbterm-0.1.4/debian/control fcitx-fbterm-0.2.0/debian/control --- fcitx-fbterm-0.1.4/debian/control 2012-04-10 07:46:51.000000000 +0000 +++ fcitx-fbterm-0.2.0/debian/control 2012-09-26 12:57:18.000000000 +0000 @@ -4,7 +4,7 @@ Maintainer: IME Packaging Team Uploaders: Aron Xu , YunQiang Su DM-Upload-Allowed: yes -Build-Depends: debhelper (>= 8), cmake, fcitx-libs-dev (>= 1:4.2.0), +Build-Depends: debhelper (>= 8), cmake, fcitx-libs-dev (>= 1:4.2.6), libdbus-glib-1-dev, gettext Standards-Version: 3.9.3 Homepage: http://code.google.com/p/fcitx diff -Nru fcitx-fbterm-0.1.4/scripts/fcitx-fbterm-helper fcitx-fbterm-0.2.0/scripts/fcitx-fbterm-helper --- fcitx-fbterm-0.1.4/scripts/fcitx-fbterm-helper 2012-04-11 04:59:13.000000000 +0000 +++ fcitx-fbterm-0.2.0/scripts/fcitx-fbterm-helper 2012-08-30 21:08:57.000000000 +0000 @@ -3,15 +3,23 @@ function Usage() { echo -e "$0 - Fcitx Fbterm launch helper" - echo -e "\t-l\t\tLaunch Fcitx automatically" - echo -e "\t-h\t\tPrint this help" + echo -e "\t-d [display number]\t\tspecify display number (For example 0)" + echo -e "\t-l\t\t\t\tLaunch Fcitx automatically" + echo -e "\t-h\t\t\t\tPrint this help" } LAUNCH=0 FCITX_RUN=0 -while getopts "lh" opt; do +if [ "x$SHELL" = "x" ]; then + echo "\$SHELL is not set" +fi + +while getopts "d:lh" opt; do case $opt in + d) + DISPLAY_NUM=$OPTARG + ;; l) LAUNCH=1 ;; @@ -22,6 +30,10 @@ esac done +if [ "x$DISPLAY_NUM" != "x" ]; then + export DISPLAY=":$DISPLAY_NUM" +fi + if [ "x$DISPLAY" != "x" ]; then number=`echo $DISPLAY | sed 's|\:\([0-9]\+\)\(\..*\)\?|\1|g'` if [ "x$number" == "x" ]; then @@ -34,7 +46,7 @@ fi echo "Test whether fcitx is running correctly with dbus..." -dbus-send --print-reply --type=method_call --session --dest=org.fcitx.Fcitx-$number /inputmethod org.freedesktop.DBus.Introspectable.Introspect > /dev/null 2>&1 +fcitx-remote > /dev/null 2>&1 if [ $? == "1" ]; then echo "Cannot communicate fcitx with DBus." @@ -54,18 +66,9 @@ echo "There is already a fcitx running, Fcitx cannot support multi instance currently" exit 1 fi - if [ "x$DISPLAY" != "x" ]; then - echo '$DISPLAY is set, but there is no fcitx running.' - echo "You'd better start it from X." - exit 1 - fi - if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then - echo "Launch DBus..." - toeval=`dbus-launch --sh-syntax` - eval "$toeval" - fi echo "Launch Fcitx..." - fcitx > /dev/null 2>&1 + fcitx -D > /dev/null 2>&1 & + fcitxpid=$! FCITX_RUN=1 fi @@ -73,13 +76,9 @@ echo "Launch fbterm..." fbterm -i fcitx-fbterm if [ "$LAUNCH" == "1" ] ; then - fcitxpid=`dbus-send --print-reply --type=method_call --session --dest=org.freedesktop.DBus / org.freedesktop.DBus.GetConnectionUnixProcessID string:org.fcitx.Fcitx-0 | grep uint32 | awk '{print $2}'` if ! test -z "$fcitxpid" ; then kill $fcitxpid fi - if ! test -z "$DBUS_SESSION_BUS_PID"; then - kill $DBUS_SESSION_BUS_PID - fi fi else echo '=========================================================' diff -Nru fcitx-fbterm-0.1.4/src/CMakeLists.txt fcitx-fbterm-0.2.0/src/CMakeLists.txt --- fcitx-fbterm-0.1.4/src/CMakeLists.txt 2012-04-11 04:59:13.000000000 +0000 +++ fcitx-fbterm-0.2.0/src/CMakeLists.txt 2012-08-30 21:08:57.000000000 +0000 @@ -1,44 +1,20 @@ - -pkg_check_modules(GLIB2 "glib-2.0" REQUIRED) -pkg_check_modules(GIO2 "gio-2.0 gio-unix-2.0" REQUIRED) -pkg_check_modules(DBUS_GLIB "dbus-glib-1" REQUIRED) - - -_pkgconfig_invoke("glib-2.0" GLIB2 GLIB_GENMARSHAL "" "--variable=glib_genmarshal") - -FIND_PROGRAM(GLIB_GENMARSHAL ${GLIB2_GLIB_GENMARSHAL}) - -add_custom_command(OUTPUT marshall.c - COMMAND ${GLIB_GENMARSHAL} --body --prefix=fcitx_marshall ${PROJECT_SOURCE_DIR}/src/marshall.list > marshall.c -) -add_custom_command(OUTPUT marshall.h - COMMAND ${GLIB_GENMARSHAL} --header --prefix=fcitx_marshall ${PROJECT_SOURCE_DIR}/src/marshall.list > marshall.h -) - include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} -${GLIB2_INCLUDE_DIRS} -${GIO2_INCLUDE_DIRS} -${DBUS_GLIB_INCLUDE_DIRS} ${FCITX4_FCITX_INCLUDE_DIRS} ${FCITX4_FCITX_UTILS_INCLUDE_DIRS} ${FCITX4_FCITX_CONFIG_INCLUDE_DIRS} +${FCITX_GCLIENT_INCLUDE_DIRS} ) link_directories( -${GLIB2_LIBRARY_DIRS} -${GIO2_LIBRARY_DIRS} -${DBUS_GLIB_LIBRARY_DIRS} ${FCITX4_FCITX_LIBRARY_DIRS} ${FCITX4_FCITX_UTILS_LIBRARY_DIRS} ${FCITX4_FCITX_CONFIG_LIBRARY_DIRS} +${FCITX_GCLIENT_LIBRARY_DIRS} ) set(fcitx_fbterm_SOURCES - marshall.c - marshall.h - client.c imapi.c fcitx-fbterm.c keycode.c @@ -47,9 +23,7 @@ add_executable(fcitx-fbterm ${fcitx_fbterm_SOURCES}) target_link_libraries(fcitx-fbterm - ${GLIB2_LIBRARIES} - ${DBUS_GLIB_LIBRARIES} - ${GIO2_LIBRARIES} + ${FCITX_GCLIENT_LIBRARIES} ${FCITX4_FCITX_LIBRARIES} ${FCITX4_FCITX_CONFIG_LIBRARIES} ${FCITX4_FCITX_UTILS_LIBRARIES} diff -Nru fcitx-fbterm-0.1.4/src/client.c fcitx-fbterm-0.2.0/src/client.c --- fcitx-fbterm-0.1.4/src/client.c 2012-04-11 04:59:13.000000000 +0000 +++ fcitx-fbterm-0.2.0/src/client.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,390 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010~2011 by CSSlayer * - * * - * 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 St, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "client.h" -#include "marshall.h" - -#define LOG_LEVEL DEBUG -#define IC_NAME_MAX 64 - -struct _FcitxIMClient { - DBusGConnection* conn; - DBusGProxy* proxy; - DBusGProxy* icproxy; - char icname[IC_NAME_MAX]; - int id; - DBusGProxy* dbusproxy; - FcitxIMClientConnectCallback connectcb; - FcitxIMClientDestroyCallback destroycb; - void *data; - FcitxHotkey triggerkey[2]; - char servicename[IC_NAME_MAX]; -}; - -static void FcitxIMClientCreateIC(FcitxIMClient* client); - -static void _destroy_cb(DBusGProxy *proxy, gpointer user_data); -static void _changed_cb(DBusGProxy* proxy, char* service, char* old_owner, char* new_owner, gpointer user_data); - -static void FcitxIMClientCreateICCallback(DBusGProxy *proxy, - DBusGProxyCall *call_id, - gpointer user_data); - -boolean IsFcitxIMClientValid(FcitxIMClient* client) -{ - if (client == NULL) - return false; - if (client->proxy == NULL || client->icproxy == NULL) - return false; - - return true; -} - -FcitxIMClient* FcitxIMClientOpen(FcitxIMClientConnectCallback connectcb, FcitxIMClientDestroyCallback destroycb, GObject* data) -{ - FcitxIMClient* client = fcitx_utils_malloc0(sizeof(FcitxIMClient)); - GError *error = NULL; - client->connectcb = connectcb; - client->destroycb = destroycb; - client->data = data; - client->conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error); - client->id = -1; - - /* You must have dbus to make it works */ - if (client->conn == NULL) - { - g_warning("%s", error->message); - free(client); - return NULL; - } - - client->dbusproxy = dbus_g_proxy_new_for_name(client->conn, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - - if (!client->dbusproxy) - { - g_object_unref(client->conn); - free(client); - return NULL; - } - sprintf(client->servicename, "%s-%d", FCITX_DBUS_SERVICE, fcitx_utils_get_display_number()); - dbus_g_object_register_marshaller(fcitx_marshall_VOID__STRING_STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_add_signal(client->dbusproxy, "NameOwnerChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(client->dbusproxy, "NameOwnerChanged", - G_CALLBACK(_changed_cb), client, NULL); - - client->triggerkey[0].sym = client->triggerkey[0].state = client->triggerkey[1].sym = client->triggerkey[1].state = 0; - - FcitxIMClientCreateIC(client); - return client; -} - -static void _changed_cb(DBusGProxy* proxy, char* service, char* old_owner, char* new_owner, gpointer user_data) -{ - FcitxLog(LOG_LEVEL, "_changed_cb"); - FcitxIMClient* client = (FcitxIMClient*) user_data; - if (g_str_equal(service, client->servicename)) - { - gboolean new_owner_good = new_owner && (new_owner[0] != '\0'); - if (new_owner_good) - { - if (client->proxy) - { - g_object_unref(client->proxy); - client->proxy = NULL; - } - - if (client->icproxy) - { - g_object_unref(client->icproxy); - client->icproxy = NULL; - } - - FcitxIMClientCreateIC(client); - } - } -} - -static void _destroy_cb(DBusGProxy *proxy, gpointer user_data) -{ - FcitxLog(LOG_LEVEL, "_destroy_cb"); - FcitxIMClient* client = (FcitxIMClient*) user_data; - if (client->proxy == proxy) - { - g_object_unref(client->proxy); - g_object_unref(client->icproxy); - client->proxy = NULL; - client->icproxy = NULL; - client->triggerkey[0].sym = client->triggerkey[0].state = client->triggerkey[1].sym = client->triggerkey[1].state = 0; - } - client->destroycb(client, client->data); -} - -void FcitxIMClientCreateIC(FcitxIMClient* client) -{ - GError* error = NULL; - - client->proxy = dbus_g_proxy_new_for_name_owner(client->conn, - client->servicename, - FCITX_IM_DBUS_PATH, - FCITX_IM_DBUS_INTERFACE, - &error); - - if (!client->proxy) - return; - - g_signal_connect(client->proxy, "destroy", G_CALLBACK( _destroy_cb), client); - - dbus_g_proxy_begin_call(client->proxy, "CreateIC", FcitxIMClientCreateICCallback, client, NULL, G_TYPE_INVALID); -} - -void FcitxIMClientCreateICCallback(DBusGProxy *proxy, - DBusGProxyCall *call_id, - gpointer user_data) -{ - FcitxIMClient* client = (FcitxIMClient*) user_data; - GError *error = NULL; - - guint arg1, arg2, arg3, arg4; - int id = -1; - dbus_g_proxy_end_call(proxy, call_id, &error, - G_TYPE_INT, &id, - G_TYPE_UINT, &arg1, - G_TYPE_UINT, &arg2, - G_TYPE_UINT, &arg3, - G_TYPE_UINT, &arg4, - G_TYPE_INVALID - ); - client->triggerkey[0].sym = arg1; - client->triggerkey[0].state = arg2; - client->triggerkey[1].sym = arg3; - client->triggerkey[1].state = arg4; - - if (id >= 0) - client->id = id; - else - return; - - sprintf(client->icname, FCITX_IC_DBUS_PATH, client->id); - - client->icproxy = dbus_g_proxy_new_for_name_owner(client->conn, - client->servicename, - client->icname, - FCITX_IC_DBUS_INTERFACE, - &error - ); - if (!client->icproxy) - return; - - dbus_g_proxy_add_signal(client->icproxy, "EnableIM", G_TYPE_INVALID); - dbus_g_proxy_add_signal(client->icproxy, "CloseIM", G_TYPE_INVALID); - dbus_g_proxy_add_signal(client->icproxy, "CommitString", G_TYPE_STRING, G_TYPE_INVALID); - - dbus_g_object_register_marshaller(fcitx_marshall_VOID__STRING_STRING_STRING_STRING_STRING_INT, - G_TYPE_NONE, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_INT, - G_TYPE_INVALID); - - dbus_g_proxy_add_signal(client->icproxy, "UpdateClientSideUI", - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_INT, - G_TYPE_INVALID); - - dbus_g_object_register_marshaller(fcitx_marshall_VOID__UINT_UINT_INT, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID); - - dbus_g_proxy_add_signal(client->icproxy, "ForwardKey", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID); - client->connectcb(client, client->data); -} - -void FcitxIMClientClose(FcitxIMClient* client) -{ - if (client->icproxy) - { - dbus_g_proxy_call_no_reply(client->icproxy, "DestroyIC", G_TYPE_INVALID); - } - DBusGProxy* icproxy = client->icproxy; - DBusGProxy* proxy = client->proxy; - client->icproxy = NULL; - client->proxy = NULL; - if (client->dbusproxy) - g_object_unref(client->dbusproxy); - if (proxy) - g_signal_handlers_disconnect_by_func(proxy, G_CALLBACK( _destroy_cb), client); - if (icproxy) - g_object_unref(icproxy); - if (proxy) - g_object_unref(proxy); - free(client); -} - -void FcitxIMClientEnableIC(FcitxIMClient* client) -{ - if (client->icproxy) - { - dbus_g_proxy_call_no_reply(client->icproxy, "EnableIC", G_TYPE_INVALID); - } -} - -void FcitxIMClientCloseIC(FcitxIMClient* client) -{ - if (client->icproxy) - { - dbus_g_proxy_call_no_reply(client->icproxy, "CloseIC", G_TYPE_INVALID); - } -} - -void FcitxIMClientFocusIn(FcitxIMClient* client) -{ - if (client->icproxy) - { - dbus_g_proxy_call_no_reply(client->icproxy, "FocusIn", G_TYPE_INVALID); - } -} - -void FcitxIMClientFocusOut(FcitxIMClient* client) -{ - if (client->icproxy) - { - dbus_g_proxy_call_no_reply(client->icproxy, "FocusOut", G_TYPE_INVALID); - } -} - -void FcitxIMClientReset(FcitxIMClient* client) -{ - if (client->icproxy) - { - dbus_g_proxy_call_no_reply(client->icproxy, "Reset", G_TYPE_INVALID); - } -} - -void FcitxIMClientSetCapacity(FcitxIMClient* client, FcitxCapacityFlags flags) -{ - uint32_t iflags = flags; - if (client->icproxy) - { - dbus_g_proxy_call_no_reply(client->icproxy, "SetCapacity", G_TYPE_UINT, iflags, G_TYPE_INVALID); - } -} - -void FcitxIMClientSetCursorLocation(FcitxIMClient* client, int x, int y) -{ - if (client->icproxy) - { - dbus_g_proxy_call_no_reply(client->icproxy, "SetCursorLocation", G_TYPE_INT, x, G_TYPE_INT, y, G_TYPE_INVALID); - } -} - - -int FcitxIMClientProcessKey(FcitxIMClient* client, uint32_t keyval, uint32_t keycode, uint32_t state, FcitxKeyEventType type, uint32_t t) -{ - int ret; - int itype = type; - GError* error = NULL; - if (!dbus_g_proxy_call(client->icproxy, "ProcessKeyEvent", - &error, - G_TYPE_UINT, keyval, - G_TYPE_UINT, keycode, - G_TYPE_UINT, state, - G_TYPE_INT, itype, - G_TYPE_UINT, t, - G_TYPE_INVALID, - G_TYPE_INT, &ret, - G_TYPE_INVALID - )) - { - return -1; - } - - return ret; -} - - -void FcitxIMClientConnectSignal(FcitxIMClient* imclient, - GCallback enableIM, - GCallback closeIM, - GCallback commitString, - GCallback forwardKey, - GCallback updateClientSideUI, - void* user_data, - GClosureNotify freefunc - ) -{ - dbus_g_proxy_connect_signal(imclient->icproxy, - "EnableIM", - enableIM, - user_data, - freefunc - ); - - dbus_g_proxy_connect_signal(imclient->icproxy, - "CloseIM", - closeIM, - user_data, - freefunc - ); - - dbus_g_proxy_connect_signal(imclient->icproxy, - "CommitString", - commitString, - user_data, - freefunc - ); - - dbus_g_proxy_connect_signal(imclient->icproxy, - "ForwardKey", - forwardKey, - user_data, - freefunc - ); - - dbus_g_proxy_connect_signal(imclient->icproxy, - "UpdateClientSideUI", - updateClientSideUI, - user_data, - freefunc - ); -} - -FcitxHotkey* FcitxIMClientGetTriggerKey(FcitxIMClient* client) -{ - return client->triggerkey; -} -// kate: indent-mode cstyle; space-indent on; indent-width 0; - diff -Nru fcitx-fbterm-0.1.4/src/client.h fcitx-fbterm-0.2.0/src/client.h --- fcitx-fbterm-0.1.4/src/client.h 2012-04-11 04:59:13.000000000 +0000 +++ fcitx-fbterm-0.2.0/src/client.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010~2011 by CSSlayer * - * * - * 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 St, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef FCITX_CLIENT_H -#define FCITX_CLIENT_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct _FcitxIMClient FcitxIMClient; - typedef void (*FcitxIMClientDestroyCallback)(FcitxIMClient* client, void* data); - typedef void (*FcitxIMClientConnectCallback)(FcitxIMClient* client, void* data); - - - FcitxIMClient* FcitxIMClientOpen(FcitxIMClientConnectCallback connectcb, FcitxIMClientDestroyCallback destroycb, GObject* data); - boolean IsFcitxIMClientValid(FcitxIMClient* client); - void FcitxIMClientClose(FcitxIMClient* client); - void FcitxIMClientEnableIC(FcitxIMClient* client); - void FcitxIMClientCloseIC(FcitxIMClient* client); - void FcitxIMClientFocusIn(FcitxIMClient* client); - void FcitxIMClientFocusOut(FcitxIMClient* client); - void FcitxIMClientSetCursorLocation(FcitxIMClient* client, int x, int y); - void FcitxIMClientSetCapacity(FcitxIMClient* client, FcitxCapacityFlags flags); - void FcitxIMClientReset(FcitxIMClient* client); - int FcitxIMClientProcessKey(FcitxIMClient* client, uint32_t keyval, uint32_t keycode, uint32_t state, FcitxKeyEventType type, uint32_t t); - void FcitxIMClientConnectSignal(FcitxIMClient* imclient, - GCallback enableIM, - GCallback closeIM, - GCallback commitString, - GCallback forwardKey, - GCallback updatePreedit, - void* user_data, - GClosureNotify freefunc - ); - FcitxHotkey* FcitxIMClientGetTriggerKey(FcitxIMClient* client); - -#ifdef __cplusplus -} -#endif - -#endif -// kate: indent-mode cstyle; space-indent on; indent-width 0; diff -Nru fcitx-fbterm-0.1.4/src/fcitx-fbterm.c fcitx-fbterm-0.2.0/src/fcitx-fbterm.c --- fcitx-fbterm-0.1.4/src/fcitx-fbterm.c 2012-04-11 04:59:13.000000000 +0000 +++ fcitx-fbterm-0.2.0/src/fcitx-fbterm.c 2012-08-30 21:08:57.000000000 +0000 @@ -24,8 +24,10 @@ #include #include #include +#include +#include +#include #include "imapi.h" -#include "client.h" #include "keycode.h" #include "keymap.h" @@ -62,18 +64,18 @@ static void update_fbterm_info(Info *info); static gboolean iochannel_fbterm_callback(GIOChannel *source, GIOCondition condition, gpointer data); -static void _fcitx_fbterm_connect_cb(FcitxIMClient* client, void* user_data); -static void _fcitx_fbterm_destroy_cb(FcitxIMClient* client, void* user_data); +static void _fcitx_fbterm_connect_cb(FcitxClient* client, void* user_data); +static void _fcitx_fbterm_destroy_cb(FcitxClient* client, void* user_data); static void -_fcitx_fbterm_enable_im_cb(DBusGProxy* proxy, void* user_data); +_fcitx_fbterm_enable_im_cb(FcitxClient* client, void* user_data); static void -_fcitx_fbterm_close_im_cb(DBusGProxy* proxy, void* user_data); +_fcitx_fbterm_close_im_cb(FcitxClient* client, void* user_data); static void -_fcitx_fbterm_commit_string_cb(DBusGProxy* proxy, char* str, void* user_data); +_fcitx_fbterm_commit_string_cb(FcitxClient* client, char* str, void* user_data); static void -_fcitx_fbterm_forward_key_cb(DBusGProxy* proxy, guint keyval, guint state, gint type, void* user_data); +_fcitx_fbterm_forward_key_cb(FcitxClient* client, guint keyval, guint state, gint type, void* user_data); static void -_fcitx_fbterm_update_client_side_ui_cb(DBusGProxy* proxy, char* auxup, char* auxdown, char* preedit, char* candidateword, char* _imname, int cursor_pos, void* user_data); +_fcitx_fbterm_update_client_side_ui_cb(FcitxClient* client, char* auxup, char* auxdown, char* preedit, char* candidateword, char* _imname, int cursor_pos, void* user_data); static unsigned text_width(char* str); static int bisearch(unsigned ucs, const struct interval *table, unsigned max); static int is_double_width(unsigned ucs); @@ -96,7 +98,7 @@ static int cursor_x; static int cursor_y; static GMainLoop *main_loop; -static FcitxIMClient* client; +static FcitxClient* client; static FcitxKeyState state; static int active = 0; static Info currentInfo; @@ -110,8 +112,8 @@ if (raw_mode) { init_keycode_state(); } - FcitxIMClientFocusIn(client); - FcitxIMClientEnableIC(client); + fcitx_client_focus_in(client); + fcitx_client_enable_ic(client); active = 1; } @@ -121,7 +123,7 @@ set_im_window(0, rect); set_im_window(1, rect); set_im_window(2, rect); - FcitxIMClientCloseIC(client); + fcitx_client_close_ic(client); state = 0; active = 0; } @@ -250,9 +252,9 @@ keysym = linux_keysym_to_fcitx_keysym(fallback_keysym, code); } - FcitxIMClientFocusIn(client); + fcitx_client_focus_in(client); - if (keysym == FcitxKey_None || FcitxIMClientProcessKey(client, keysym, code, state, (down ? FCITX_PRESS_KEY : FCITX_RELEASE_KEY), 0) <= 0) { + if (keysym == FcitxKey_None || fcitx_client_process_key_sync(client, keysym, code, state, (down ? FCITX_PRESS_KEY : FCITX_RELEASE_KEY), 0) <= 0) { char *str = keysym_to_term_string(linux_keysym, down); if (str) put_im_text(str, strlen(str)); @@ -286,57 +288,49 @@ return TRUE; } -void _fcitx_fbterm_connect_cb(FcitxIMClient* client, void* user_data) +void _fcitx_fbterm_connect_cb(FcitxClient* client, void* user_data) { - if (IsFcitxIMClientValid(client)) + if (fcitx_client_is_valid(client)) { - FcitxIMClientConnectSignal(client, - G_CALLBACK(_fcitx_fbterm_enable_im_cb), - G_CALLBACK(_fcitx_fbterm_close_im_cb), - G_CALLBACK(_fcitx_fbterm_commit_string_cb), - G_CALLBACK(_fcitx_fbterm_forward_key_cb), - G_CALLBACK(_fcitx_fbterm_update_client_side_ui_cb), - user_data, - NULL); - - FcitxCapacityFlags flags = CAPACITY_CLIENT_SIDE_UI; - FcitxIMClientSetCapacity(client, flags); + + FcitxCapacityFlags flags = CAPACITY_CLIENT_SIDE_UI | CAPACITY_CLIENT_SIDE_CONTROL_STATE; + fcitx_client_set_capacity(client, flags); if (active) { - FcitxIMClientFocusIn(client); - FcitxIMClientEnableIC(client); + fcitx_client_focus_in(client); + fcitx_client_enable_ic(client); } } } -void _fcitx_fbterm_destroy_cb(FcitxIMClient* client, void* user_data) +void _fcitx_fbterm_destroy_cb(FcitxClient* client, void* user_data) { state = 0; } -void _fcitx_fbterm_close_im_cb(DBusGProxy* proxy, void* user_data) +void _fcitx_fbterm_close_im_cb(FcitxClient* client, void* user_data) { state = 0; } -void _fcitx_fbterm_commit_string_cb(DBusGProxy* proxy, char* str, void* user_data) +void _fcitx_fbterm_commit_string_cb(FcitxClient* client, char* str, void* user_data) { unsigned short result_len = strlen(str); put_im_text( str, result_len ); } -void _fcitx_fbterm_enable_im_cb(DBusGProxy* proxy, void* user_data) +void _fcitx_fbterm_enable_im_cb(FcitxClient* client, void* user_data) { state = 0; } -void _fcitx_fbterm_forward_key_cb(DBusGProxy* proxy, guint keyval, guint state, gint type, void* user_data) +void _fcitx_fbterm_forward_key_cb(FcitxClient* client, guint keyval, guint state, gint type, void* user_data) { } -void _fcitx_fbterm_update_client_side_ui_cb(DBusGProxy* proxy, char* auxup, char* auxdown, char* preedit, char* candidateword, char* _imname, int cursor_pos, void* user_data) +void _fcitx_fbterm_update_client_side_ui_cb(FcitxClient* client, char* auxup, char* auxdown, char* preedit, char* candidateword, char* _imname, int cursor_pos, void* user_data) { snprintf(textup, BUFSIZE, "%s%s", auxup, preedit); snprintf(textdown, BUFSIZE, "%s%s", auxdown, candidateword); @@ -355,7 +349,14 @@ g_type_init(); - client = FcitxIMClientOpen(_fcitx_fbterm_connect_cb, _fcitx_fbterm_destroy_cb, NULL); + client = fcitx_client_new(); + g_signal_connect(client, "connected", G_CALLBACK(_fcitx_fbterm_connect_cb), NULL); + g_signal_connect(client, "disconnected", G_CALLBACK(_fcitx_fbterm_destroy_cb), NULL); + g_signal_connect(client, "enable-im", G_CALLBACK(_fcitx_fbterm_enable_im_cb), NULL); + g_signal_connect(client, "close-im", G_CALLBACK(_fcitx_fbterm_close_im_cb), NULL); + g_signal_connect(client, "forward-key", G_CALLBACK(_fcitx_fbterm_forward_key_cb), NULL); + g_signal_connect(client, "commit-string", G_CALLBACK(_fcitx_fbterm_commit_string_cb), NULL); + g_signal_connect(client, "update-client-side-ui", G_CALLBACK(_fcitx_fbterm_update_client_side_ui_cb), NULL); register_im_callbacks(cbs); connect_fbterm(1); @@ -363,7 +364,7 @@ main_loop = g_main_loop_new(NULL, FALSE); g_main_loop_run(main_loop); - FcitxIMClientClose(client); + g_object_unref(client); g_io_channel_unref(iochannel_fbterm); g_main_loop_unref(main_loop); diff -Nru fcitx-fbterm-0.1.4/src/marshall.list fcitx-fbterm-0.2.0/src/marshall.list --- fcitx-fbterm-0.1.4/src/marshall.list 2012-04-11 04:59:13.000000000 +0000 +++ fcitx-fbterm-0.2.0/src/marshall.list 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -VOID:UINT,UINT,INT -VOID:STRING,STRING,STRING -VOID:STRING,STRING,STRING,STRING,STRING,INT