Seperate out GDBus proxy into libeekboard from src/.
This commit is contained in:
57
eekboard/Makefile.am
Normal file
57
eekboard/Makefile.am
Normal file
@ -0,0 +1,57 @@
|
||||
# Copyright (C) 2011 Daiki Ueno <ueno@unixuser.org>
|
||||
# Copyright (C) 2011 Red Hat, Inc.
|
||||
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public License
|
||||
# as published by the Free Software Foundation; either version 2 of
|
||||
# the License, or (at your option) any later version.
|
||||
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301 USA
|
||||
|
||||
lib_LTLIBRARIES = libeekboard.la
|
||||
|
||||
libeekboard_headers = eekboard.h eekboard-proxy.h
|
||||
libeekboard_sources = eekboard-proxy.c
|
||||
|
||||
libeekboard_la_SOURCES = $(libeekboard_sources)
|
||||
libeekboard_la_CFLAGS = -I$(top_srcdir) $(GIO2_CFLAGS)
|
||||
libeekboard_la_LIBADD = $(top_builddir)/eek/libeek.la $(GIO2_LIBS)
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = \
|
||||
eekboard-$(EEK_API_VERSION).pc
|
||||
DISTCLEANFILES = \
|
||||
$(pkgconfig_DATA)
|
||||
|
||||
CLEANFILES =
|
||||
|
||||
-include $(INTROSPECTION_MAKEFILE)
|
||||
INTROSPECTION_GIRS =
|
||||
INTROSPECTION_SCANNER_ARGS = --add-include-path=$(builddir)
|
||||
INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
|
||||
|
||||
if HAVE_INTROSPECTION
|
||||
Eekboard@EEK_LIBRARY_SUFFIX@.gir: libeekboard.la
|
||||
Eekboard@EEK_LIBRARY_SUFFIX_U@_gir_INCLUDES = Eek@EEK_LIBRARY_SUFFIX@
|
||||
Eekboard@EEK_LIBRARY_SUFFIX_U@_gir_CFLAGS = $(libeekboard_la_CFLAGS)
|
||||
Eekboard@EEK_LIBRARY_SUFFIX_U@_gir_LIBS = libeekboard.la
|
||||
Eekboard@EEK_LIBRARY_SUFFIX_U@_gir_FILES = $(libeekboard_sources) $(libeekboard_headers)
|
||||
|
||||
INTROSPECTION_GIRS += Eekboard@EEK_LIBRARY_SUFFIX@.gir
|
||||
|
||||
girdir = $(datadir)/gir-1.0
|
||||
gir_DATA = $(INTROSPECTION_GIRS)
|
||||
|
||||
typelibdir = $(libdir)/girepository-1.0
|
||||
typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
|
||||
|
||||
CLEANFILES += $(gir_DATA) $(typelib_DATA)
|
||||
endif
|
||||
30
eekboard/eekboard-0.90.pc.in
Normal file
30
eekboard/eekboard-0.90.pc.in
Normal file
@ -0,0 +1,30 @@
|
||||
# Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
|
||||
# Copyright (C) 2010-2011 Red Hat, Inc.
|
||||
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public License
|
||||
# as published by the Free Software Foundation; either version 2 of
|
||||
# the License, or (at your option) any later version.
|
||||
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301 USA
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: Eekboard
|
||||
Description: A Library to Create Keyboard-like UI
|
||||
URL: http://ueno.github.com/eekboard/
|
||||
Version: @VERSION@
|
||||
Requires: gobject-2.0
|
||||
Libs: -L${libdir} -leek
|
||||
Cflags: -I${includedir}/eekboard-@EEK_API_VERSION@
|
||||
230
eekboard/eekboard-proxy.c
Normal file
230
eekboard/eekboard-proxy.c
Normal file
@ -0,0 +1,230 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
|
||||
* Copyright (C) 2010-2011 Red Hat, Inc.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include "eekboard-proxy.h"
|
||||
|
||||
enum {
|
||||
KEY_PRESSED,
|
||||
KEY_RELEASED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
struct _EekboardProxy {
|
||||
GDBusProxy parent;
|
||||
};
|
||||
|
||||
struct _EekboardProxyClass {
|
||||
GDBusProxyClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (EekboardProxy, eekboard_proxy, G_TYPE_DBUS_PROXY);
|
||||
|
||||
static void
|
||||
eekboard_proxy_real_g_signal (GDBusProxy *self,
|
||||
const gchar *sender_name,
|
||||
const gchar *signal_name,
|
||||
GVariant *parameters)
|
||||
{
|
||||
EekboardProxy *proxy = EEKBOARD_PROXY (self);
|
||||
guint *keycode;
|
||||
|
||||
if (g_strcmp0 (signal_name, "KeyPressed") == 0) {
|
||||
|
||||
g_variant_get (parameters, "(u)", &keycode);
|
||||
g_signal_emit_by_name (proxy, "key-pressed", keycode);
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_strcmp0 (signal_name, "KeyReleased") == 0) {
|
||||
g_variant_get (parameters, "(u)", &keycode);
|
||||
g_signal_emit_by_name (proxy, "key-released", keycode);
|
||||
return;
|
||||
}
|
||||
|
||||
g_return_if_reached ();
|
||||
}
|
||||
|
||||
static void
|
||||
eekboard_proxy_class_init (EekboardProxyClass *klass)
|
||||
{
|
||||
GDBusProxyClass *proxy_class = G_DBUS_PROXY_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
proxy_class->g_signal = eekboard_proxy_real_g_signal;
|
||||
|
||||
signals[KEY_PRESSED] =
|
||||
g_signal_new ("key-pressed",
|
||||
G_TYPE_FROM_CLASS(gobject_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__UINT,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_UINT);
|
||||
|
||||
signals[KEY_RELEASED] =
|
||||
g_signal_new ("key-released",
|
||||
G_TYPE_FROM_CLASS(gobject_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__UINT,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_UINT);
|
||||
}
|
||||
|
||||
static void
|
||||
eekboard_proxy_init (EekboardProxy *proxy)
|
||||
{
|
||||
}
|
||||
|
||||
EekboardProxy *
|
||||
eekboard_proxy_new (const gchar *path,
|
||||
GDBusConnection *connection,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
GInitable *initable;
|
||||
|
||||
g_assert (path != NULL);
|
||||
g_assert (G_IS_DBUS_CONNECTION(connection));
|
||||
|
||||
initable =
|
||||
g_initable_new (EEKBOARD_TYPE_PROXY,
|
||||
cancellable,
|
||||
error,
|
||||
"g-connection", connection,
|
||||
"g-name", "com.redhat.eekboard.Keyboard",
|
||||
"g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
|
||||
"g-interface-name", "com.redhat.eekboard.Keyboard",
|
||||
"g-object-path", path,
|
||||
NULL);
|
||||
if (initable != NULL)
|
||||
return EEKBOARD_PROXY (initable);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
proxy_call_async_ready_cb (GObject *source_object,
|
||||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GVariant *result;
|
||||
|
||||
result = g_dbus_proxy_call_finish (G_DBUS_PROXY(source_object),
|
||||
res,
|
||||
&error);
|
||||
// g_assert_no_error (error);
|
||||
if (result)
|
||||
g_variant_unref (result);
|
||||
}
|
||||
|
||||
void
|
||||
eekboard_proxy_set_keyboard (EekboardProxy *proxy, EekKeyboard *keyboard)
|
||||
{
|
||||
GVariant *variant;
|
||||
|
||||
variant = eek_serializable_serialize (EEK_SERIALIZABLE(keyboard));
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(proxy),
|
||||
"SetKeyboard",
|
||||
g_variant_new ("(v)", variant),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
NULL,
|
||||
proxy_call_async_ready_cb,
|
||||
NULL);
|
||||
g_variant_unref (variant);
|
||||
}
|
||||
|
||||
void
|
||||
eekboard_proxy_set_group (EekboardProxy *proxy, gint group)
|
||||
{
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(proxy),
|
||||
"SetGroup",
|
||||
g_variant_new ("(i)", group),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
NULL,
|
||||
proxy_call_async_ready_cb,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
eekboard_proxy_show (EekboardProxy *proxy)
|
||||
{
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(proxy),
|
||||
"Show",
|
||||
NULL,
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
NULL,
|
||||
proxy_call_async_ready_cb,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
eekboard_proxy_hide (EekboardProxy *proxy)
|
||||
{
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(proxy),
|
||||
"Hide",
|
||||
NULL,
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
NULL,
|
||||
proxy_call_async_ready_cb,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
eekboard_proxy_press_key (EekboardProxy *proxy,
|
||||
guint keycode)
|
||||
{
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(proxy),
|
||||
"PressKey",
|
||||
g_variant_new ("(u)", keycode),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
NULL,
|
||||
proxy_call_async_ready_cb,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
eekboard_proxy_release_key (EekboardProxy *proxy,
|
||||
guint keycode)
|
||||
{
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(proxy),
|
||||
"ReleaseKey",
|
||||
g_variant_new ("(u)", keycode),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
NULL,
|
||||
proxy_call_async_ready_cb,
|
||||
NULL);
|
||||
}
|
||||
52
eekboard/eekboard-proxy.h
Normal file
52
eekboard/eekboard-proxy.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
|
||||
* Copyright (C) 2010-2011 Red Hat, Inc.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef EEKBOARD_PROXY_H
|
||||
#define EEKBOARD_PROXY_H 1
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include "eek/eek.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define EEKBOARD_TYPE_PROXY (eekboard_proxy_get_type())
|
||||
#define EEKBOARD_PROXY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_PROXY, EekboardProxy))
|
||||
#define EEKBOARD_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEKBOARD_TYPE_PROXY, EekboardProxyClass))
|
||||
#define EEKBOARD_IS_PROXY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEKBOARD_TYPE_PROXY))
|
||||
#define EEKBOARD_IS_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEKBOARD_TYPE_PROXY))
|
||||
#define EEKBOARD_PROXY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEKBOARD_TYPE_PROXY, EekboardProxyClass))
|
||||
|
||||
typedef struct _EekboardProxy EekboardProxy;
|
||||
typedef struct _EekboardProxyClass EekboardProxyClass;
|
||||
|
||||
EekboardProxy *eekboard_proxy_new (const gchar *path,
|
||||
GDBusConnection *connection,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
void eekboard_proxy_set_keyboard (EekboardProxy *proxy,
|
||||
EekKeyboard *keyboard);
|
||||
void eekboard_proxy_set_group (EekboardProxy *proxy,
|
||||
gint group);
|
||||
void eekboard_proxy_show (EekboardProxy *proxy);
|
||||
void eekboard_proxy_hide (EekboardProxy *proxy);
|
||||
void eekboard_proxy_press_key (EekboardProxy *proxy,
|
||||
guint keycode);
|
||||
void eekboard_proxy_release_key (EekboardProxy *proxy,
|
||||
guint keycode);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* EEKBOARD_PROXY_H */
|
||||
23
eekboard/eekboard.h
Normal file
23
eekboard/eekboard.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Daiki Ueno <ueno@unixuser.org>
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef EEKBOARD_H
|
||||
#define EEKBOARD_H 1
|
||||
|
||||
#include "eekboard/eekboard-proxy.h"
|
||||
|
||||
#endif /* EEKBOARD_H */
|
||||
Reference in New Issue
Block a user