Seperate out GDBus proxy into libeekboard from src/.
This commit is contained in:
@ -22,15 +22,6 @@ bin_PROGRAMS = \
|
||||
eekboard-client \
|
||||
eekboard-server \
|
||||
eekboard-xml
|
||||
noinst_LIBRARIES = libeekboard.a
|
||||
|
||||
libeekboard_a_headers = proxy.h
|
||||
|
||||
libeekboard_a_CFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
$(GIO2_CFLAGS)
|
||||
|
||||
libeekboard_a_SOURCES = proxy.c
|
||||
|
||||
eekboard_system_client_CFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
@ -41,8 +32,7 @@ eekboard_system_client_CFLAGS = \
|
||||
$(LIBXKLAVIER_CFLAGS)
|
||||
|
||||
eekboard_system_client_LDADD = \
|
||||
libeekboard.a \
|
||||
$(top_builddir)/eek/libeek.la \
|
||||
$(top_builddir)/eekboard/libeekboard.la \
|
||||
$(top_builddir)/eek/libeek-xkl.la \
|
||||
$(GIO2_LIBS) \
|
||||
$(GTK_LIBS) \
|
||||
@ -73,8 +63,7 @@ eekboard_server_CFLAGS = \
|
||||
$(GTK_CFLAGS)
|
||||
|
||||
eekboard_server_LDADD = \
|
||||
libeekboard.a \
|
||||
$(top_builddir)/eek/libeek.la \
|
||||
$(top_builddir)/eekboard/libeekboard.la \
|
||||
$(top_builddir)/eek/libeek-gtk.la \
|
||||
$(GIO2_LIBS) \
|
||||
$(GTK_LIBS)
|
||||
@ -92,8 +81,7 @@ eekboard_client_CFLAGS = \
|
||||
$(GIO2_CFLAGS)
|
||||
|
||||
eekboard_client_LDADD = \
|
||||
libeekboard.a \
|
||||
$(top_builddir)/eek/libeek.la \
|
||||
$(top_builddir)/eekboard/libeekboard.la \
|
||||
$(GIO2_LIBS)
|
||||
|
||||
eekboard_client_SOURCES = client-main.c
|
||||
@ -115,8 +103,11 @@ eekboard_xml_LDADD = \
|
||||
eekboard_xml_headers = xklutil.h
|
||||
eekboard_xml_SOURCES = xklutil.c xml-main.c
|
||||
|
||||
eekboarddir = $(includedir)/eekboard-$(EEK_API_VERSION)/eekboard
|
||||
eekboard_HEADERS = \
|
||||
$(libeekboard_headers)
|
||||
|
||||
noinst_HEADERS = \
|
||||
$(libeekboard_a_headers) \
|
||||
$(eekboard_system_client_headers) \
|
||||
$(eekboard_client_headers) \
|
||||
$(eekboard_server_headers) \
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "config.h"
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include "proxy.h"
|
||||
#include "eekboard/eekboard.h"
|
||||
|
||||
static gchar *opt_set_keyboard = NULL;
|
||||
static gint opt_set_group = -1;
|
||||
|
||||
230
src/proxy.c
230
src/proxy.c
@ -1,230 +0,0 @@
|
||||
/*
|
||||
* 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 "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
src/proxy.h
52
src/proxy.h
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* 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 */
|
||||
@ -33,8 +33,8 @@
|
||||
|
||||
#include "eek/eek.h"
|
||||
#include "eek/eek-xkl.h"
|
||||
#include "eekboard/eekboard.h"
|
||||
#include "system-client.h"
|
||||
#include "proxy.h"
|
||||
|
||||
#define CSW 640
|
||||
#define CSH 480
|
||||
|
||||
Reference in New Issue
Block a user