Commit 89c5c46d authored by Daiki Ueno's avatar Daiki Ueno
Browse files

Rename EekboardProxy to EekboardDevice.

parent ab43010a
......@@ -18,8 +18,8 @@
lib_LTLIBRARIES = libeekboard.la
libeekboard_headers = eekboard.h eekboard-proxy.h
libeekboard_sources = eekboard-proxy.c
libeekboard_headers = eekboard.h eekboard-device.h
libeekboard_sources = eekboard-device.c
libeekboard_la_SOURCES = $(libeekboard_sources)
libeekboard_la_CFLAGS = -I$(top_srcdir) $(GIO2_CFLAGS)
......
......@@ -19,7 +19,7 @@
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include "eekboard-proxy.h"
#include "eekboard-device.h"
enum {
KEY_PRESSED,
......@@ -29,35 +29,35 @@ enum {
static guint signals[LAST_SIGNAL] = { 0, };
struct _EekboardProxy {
struct _EekboardDevice {
GDBusProxy parent;
};
struct _EekboardProxyClass {
struct _EekboardDeviceClass {
GDBusProxyClass parent_class;
};
G_DEFINE_TYPE (EekboardProxy, eekboard_proxy, G_TYPE_DBUS_PROXY);
G_DEFINE_TYPE (EekboardDevice, eekboard_device, G_TYPE_DBUS_PROXY);
static void
eekboard_proxy_real_g_signal (GDBusProxy *self,
eekboard_device_real_g_signal (GDBusProxy *self,
const gchar *sender_name,
const gchar *signal_name,
GVariant *parameters)
{
EekboardProxy *proxy = EEKBOARD_PROXY (self);
EekboardDevice *device = EEKBOARD_DEVICE (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);
g_signal_emit_by_name (device, "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);
g_signal_emit_by_name (device, "key-released", keycode);
return;
}
......@@ -65,12 +65,12 @@ eekboard_proxy_real_g_signal (GDBusProxy *self,
}
static void
eekboard_proxy_class_init (EekboardProxyClass *klass)
eekboard_device_class_init (EekboardDeviceClass *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;
proxy_class->g_signal = eekboard_device_real_g_signal;
signals[KEY_PRESSED] =
g_signal_new ("key-pressed",
......@@ -98,15 +98,15 @@ eekboard_proxy_class_init (EekboardProxyClass *klass)
}
static void
eekboard_proxy_init (EekboardProxy *proxy)
eekboard_device_init (EekboardDevice *device)
{
}
EekboardProxy *
eekboard_proxy_new (const gchar *path,
GDBusConnection *connection,
GCancellable *cancellable,
GError **error)
EekboardDevice *
eekboard_device_new (const gchar *path,
GDBusConnection *connection,
GCancellable *cancellable,
GError **error)
{
GInitable *initable;
......@@ -114,7 +114,7 @@ eekboard_proxy_new (const gchar *path,
g_assert (G_IS_DBUS_CONNECTION(connection));
initable =
g_initable_new (EEKBOARD_TYPE_PROXY,
g_initable_new (EEKBOARD_TYPE_DEVICE,
cancellable,
error,
"g-connection", connection,
......@@ -125,7 +125,7 @@ eekboard_proxy_new (const gchar *path,
"g-object-path", path,
NULL);
if (initable != NULL)
return EEKBOARD_PROXY (initable);
return EEKBOARD_DEVICE (initable);
return NULL;
}
......@@ -146,12 +146,12 @@ proxy_call_async_ready_cb (GObject *source_object,
}
void
eekboard_proxy_set_keyboard (EekboardProxy *proxy, EekKeyboard *keyboard)
eekboard_device_set_keyboard (EekboardDevice *device, EekKeyboard *keyboard)
{
GVariant *variant;
variant = eek_serializable_serialize (EEK_SERIALIZABLE(keyboard));
g_dbus_proxy_call (G_DBUS_PROXY(proxy),
g_dbus_proxy_call (G_DBUS_PROXY(device),
"SetKeyboard",
g_variant_new ("(v)", variant),
G_DBUS_CALL_FLAGS_NONE,
......@@ -163,9 +163,10 @@ eekboard_proxy_set_keyboard (EekboardProxy *proxy, EekKeyboard *keyboard)
}
void
eekboard_proxy_set_group (EekboardProxy *proxy, gint group)
eekboard_device_set_group (EekboardDevice *device,
gint group)
{
g_dbus_proxy_call (G_DBUS_PROXY(proxy),
g_dbus_proxy_call (G_DBUS_PROXY(device),
"SetGroup",
g_variant_new ("(i)", group),
G_DBUS_CALL_FLAGS_NONE,
......@@ -176,9 +177,9 @@ eekboard_proxy_set_group (EekboardProxy *proxy, gint group)
}
void
eekboard_proxy_show (EekboardProxy *proxy)
eekboard_device_show (EekboardDevice *device)
{
g_dbus_proxy_call (G_DBUS_PROXY(proxy),
g_dbus_proxy_call (G_DBUS_PROXY(device),
"Show",
NULL,
G_DBUS_CALL_FLAGS_NONE,
......@@ -189,9 +190,9 @@ eekboard_proxy_show (EekboardProxy *proxy)
}
void
eekboard_proxy_hide (EekboardProxy *proxy)
eekboard_device_hide (EekboardDevice *device)
{
g_dbus_proxy_call (G_DBUS_PROXY(proxy),
g_dbus_proxy_call (G_DBUS_PROXY(device),
"Hide",
NULL,
G_DBUS_CALL_FLAGS_NONE,
......@@ -202,10 +203,10 @@ eekboard_proxy_hide (EekboardProxy *proxy)
}
void
eekboard_proxy_press_key (EekboardProxy *proxy,
guint keycode)
eekboard_device_press_key (EekboardDevice *device,
guint keycode)
{
g_dbus_proxy_call (G_DBUS_PROXY(proxy),
g_dbus_proxy_call (G_DBUS_PROXY(device),
"PressKey",
g_variant_new ("(u)", keycode),
G_DBUS_CALL_FLAGS_NONE,
......@@ -216,10 +217,10 @@ eekboard_proxy_press_key (EekboardProxy *proxy,
}
void
eekboard_proxy_release_key (EekboardProxy *proxy,
guint keycode)
eekboard_device_release_key (EekboardDevice *device,
guint keycode)
{
g_dbus_proxy_call (G_DBUS_PROXY(proxy),
g_dbus_proxy_call (G_DBUS_PROXY(device),
"ReleaseKey",
g_variant_new ("(u)", keycode),
G_DBUS_CALL_FLAGS_NONE,
......
......@@ -15,38 +15,38 @@
* 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
#ifndef EEKBOARD_DEVICE_H
#define EEKBOARD_DEVICE_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))
#define EEKBOARD_TYPE_DEVICE (eekboard_device_get_type())
#define EEKBOARD_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_DEVICE, EekboardDevice))
#define EEKBOARD_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEKBOARD_TYPE_DEVICE, EekboardDeviceClass))
#define EEKBOARD_IS_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEKBOARD_TYPE_DEVICE))
#define EEKBOARD_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEKBOARD_TYPE_DEVICE))
#define EEKBOARD_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEKBOARD_TYPE_DEVICE, EekboardDeviceClass))
typedef struct _EekboardProxy EekboardProxy;
typedef struct _EekboardProxyClass EekboardProxyClass;
typedef struct _EekboardDevice EekboardDevice;
typedef struct _EekboardDeviceClass EekboardDeviceClass;
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);
EekboardDevice *eekboard_device_new (const gchar *path,
GDBusConnection *connection,
GCancellable *cancellable,
GError **error);
void eekboard_device_set_keyboard (EekboardDevice *device,
EekKeyboard *keyboard);
void eekboard_device_set_group (EekboardDevice *device,
gint group);
void eekboard_device_show (EekboardDevice *device);
void eekboard_device_hide (EekboardDevice *device);
void eekboard_device_press_key (EekboardDevice *device,
guint keycode);
void eekboard_device_release_key (EekboardDevice *device,
guint keycode);
G_END_DECLS
#endif /* EEKBOARD_PROXY_H */
#endif /* EEKBOARD_DEVICE_H */
......@@ -18,6 +18,6 @@
#ifndef EEKBOARD_H
#define EEKBOARD_H 1
#include "eekboard/eekboard-proxy.h"
#include "eekboard/eekboard-device.h"
#endif /* EEKBOARD_H */
......@@ -62,7 +62,7 @@ on_key_released (guint keycode, gpointer user_data)
int
main (int argc, char **argv)
{
EekboardProxy *proxy = NULL;
EekboardDevice *device = NULL;
GDBusConnection *connection = NULL;
GError *error;
GOptionContext *context;
......@@ -86,10 +86,10 @@ main (int argc, char **argv)
}
error = NULL;
proxy = eekboard_proxy_new ("/com/redhat/eekboard/Keyboard",
connection,
NULL,
&error);
device = eekboard_device_new ("/com/redhat/eekboard/Device",
connection,
NULL,
&error);
if (error) {
g_printerr ("%s\n", error->message);
retval = 1;
......@@ -118,42 +118,42 @@ main (int argc, char **argv)
g_object_unref (input);
keyboard = eek_keyboard_new (layout, 640, 480);
g_object_unref (layout);
eekboard_proxy_set_keyboard (proxy, keyboard);
eekboard_device_set_keyboard (device, keyboard);
g_object_unref (keyboard);
}
if (opt_set_group >= 0) {
eekboard_proxy_set_group (proxy, opt_set_group);
eekboard_device_set_group (device, opt_set_group);
}
if (opt_show) {
eekboard_proxy_show (proxy);
eekboard_device_show (device);
}
if (opt_hide) {
eekboard_proxy_hide (proxy);
eekboard_device_hide (device);
}
if (opt_press_key >= 0) {
eekboard_proxy_press_key (proxy, opt_press_key);
eekboard_device_press_key (device, opt_press_key);
}
if (opt_release_key >= 0) {
eekboard_proxy_release_key (proxy, opt_release_key);
eekboard_device_release_key (device, opt_release_key);
}
if (opt_listen) {
g_signal_connect (proxy, "key-pressed",
g_signal_connect (device, "key-pressed",
G_CALLBACK(on_key_pressed), NULL);
g_signal_connect (proxy, "key-released",
g_signal_connect (device, "key-released",
G_CALLBACK(on_key_released), NULL);
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
}
out:
if (proxy)
g_object_unref (proxy);
if (device)
g_object_unref (device);
if (connection)
g_object_unref (connection);
if (loop)
......
This diff is collapsed.
......@@ -43,7 +43,7 @@ enum {
static const gchar introspection_xml[] =
"<node>"
" <interface name='com.redhat.eekboard.Keyboard'>"
" <interface name='com.redhat.eekboard.Device'>"
" <method name='SetKeyboard'>"
" <arg type='v' name='keyboard'/>"
" </method>"
......@@ -253,9 +253,9 @@ on_key_pressed (EekKeyboard *keyboard,
error = NULL;
g_dbus_connection_emit_signal (server->connection,
"com.redhat.eekboard.Keyboard",
"/com/redhat/eekboard/Keyboard",
"com.redhat.eekboard.Keyboard",
"com.redhat.eekboard.Device",
"/com/redhat/eekboard/Device",
"com.redhat.eekboard.Device",
"KeyPressed",
g_variant_new ("(u)",
eek_key_get_keycode (key)),
......@@ -273,9 +273,9 @@ on_key_released (EekKeyboard *keyboard,
error = NULL;
g_dbus_connection_emit_signal (server->connection,
"com.redhat.eekboard.Keyboard",
"/com/redhat/eekboard/Keyboard",
"com.redhat.eekboard.Keyboard",
"com.redhat.eekboard.Device",
"/com/redhat/eekboard/Device",
"com.redhat.eekboard.Device",
"KeyReleased",
g_variant_new ("(u)",
eek_key_get_keycode (key)),
......@@ -481,7 +481,7 @@ eekboard_server_start (EekboardServer *server)
error = NULL;
registration_id = g_dbus_connection_register_object
(server->connection,
"/com/redhat/eekboard/Keyboard",
"/com/redhat/eekboard/Device",
server->introspection_data->interfaces[0],
&interface_vtable,
server,
......@@ -493,7 +493,7 @@ eekboard_server_start (EekboardServer *server)
server->owner_id =
g_bus_own_name_on_connection (server->connection,
"com.redhat.eekboard.Keyboard",
"com.redhat.eekboard.Device",
G_BUS_NAME_OWNER_FLAGS_NONE,
on_name_acquired,
on_name_lost,
......
......@@ -50,7 +50,7 @@ typedef struct _EekboardSystemClientClass EekboardSystemClientClass;
struct _EekboardSystemClient {
GObject parent;
EekboardProxy *proxy;
EekboardDevice *device;
EekKeyboard *keyboard;
GdkDisplay *display;
......@@ -117,7 +117,7 @@ eekboard_system_client_set_property (GObject *object,
case PROP_CONNECTION:
connection = g_value_get_object (value);
error = NULL;
client->proxy = eekboard_proxy_new ("/com/redhat/eekboard/Keyboard",
client->device = eekboard_device_new ("/com/redhat/eekboard/Device",
connection,
NULL,
&error);
......@@ -146,9 +146,9 @@ eekboard_system_client_dispose (GObject *object)
eekboard_system_client_disable_fakekey (client);
#endif /* HAVE_FAKEKEY */
if (client->proxy) {
g_object_unref (client->proxy);
client->proxy = NULL;
if (client->device) {
g_object_unref (client->device);
client->device = NULL;
}
#ifdef HAVE_FAKEKEY
......@@ -191,7 +191,7 @@ eekboard_system_client_init (EekboardSystemClient *client)
client->display = NULL;
client->xkl_engine = NULL;
client->xkl_config_registry = NULL;
client->proxy = NULL;
client->device = NULL;
client->key_pressed_handler = 0;
client->key_released_handler = 0;
client->xkl_config_changed_handler = 0;
......@@ -337,12 +337,12 @@ focus_listener_cb (const AccessibleEvent *event,
case SPI_ROLE_TERMINAL:
case SPI_ROLE_ENTRY:
if (g_strcmp0 (event->type, "focus") == 0 || event->detail1 == 1)
eekboard_proxy_show (client->proxy);
eekboard_device_show (client->device);
default:
;
}
} else
eekboard_proxy_hide (client->proxy);
eekboard_device_hide (client->device);
return FALSE;
}
......@@ -364,9 +364,9 @@ keystroke_listener_cb (const AccessibleKeystroke *stroke,
}
if (stroke->type == SPI_KEY_PRESSED)
eekboard_proxy_press_key (client->proxy, stroke->keycode);
eekboard_device_press_key (client->device, stroke->keycode);
else
eekboard_proxy_release_key (client->proxy, stroke->keycode);
eekboard_device_release_key (client->device, stroke->keycode);
return TRUE;
}
#endif /* HAVE_CSPI */
......@@ -422,7 +422,7 @@ set_keyboard (EekboardSystemClient *client)
keyboard_name = g_strdup_printf ("keyboard%d", keyboard_serial++);
eek_element_set_name (EEK_ELEMENT(client->keyboard), keyboard_name);
eekboard_proxy_set_keyboard (client->proxy, client->keyboard);
eekboard_device_set_keyboard (client->device, client->keyboard);
}
static void
......@@ -438,7 +438,7 @@ on_xkl_state_changed (XklEngine *xklengine,
gint group = eek_keyboard_get_group (client->keyboard);
if (group != value) {
eek_keyboard_set_group (client->keyboard, value);
eekboard_proxy_set_group (client->proxy, value);
eekboard_device_set_group (client->device, value);
}
}
}
......@@ -462,7 +462,7 @@ get_fakekey_modifiers (EekModifierType modifiers)
}
static void
on_key_pressed (EekboardProxy *proxy,
on_key_pressed (EekboardDevice *device,
guint keycode,
gpointer user_data)
{
......@@ -495,7 +495,7 @@ on_key_pressed (EekboardProxy *proxy,
}
static void
on_key_released (EekboardProxy *proxy,
on_key_released (EekboardDevice *device,
guint keycode,
gpointer user_data)
{
......@@ -526,10 +526,10 @@ eekboard_system_client_enable_fakekey (EekboardSystemClient *client)
g_assert (client->fakekey);
client->key_pressed_handler =
g_signal_connect (client->proxy, "key-pressed",
g_signal_connect (client->device, "key-pressed",
G_CALLBACK(on_key_pressed), client);
client->key_released_handler =
g_signal_connect (client->proxy, "key-pressed",
g_signal_connect (client->device, "key-pressed",
G_CALLBACK(on_key_released), client);
return TRUE;
......@@ -541,13 +541,13 @@ eekboard_system_client_disable_fakekey (EekboardSystemClient *client)
if (client->fakekey)
fakekey_release (client->fakekey);
if (g_signal_handler_is_connected (client->proxy,
if (g_signal_handler_is_connected (client->device,
client->key_pressed_handler))
g_signal_handler_disconnect (client->proxy,
g_signal_handler_disconnect (client->device,
client->key_pressed_handler);
if (g_signal_handler_is_connected (client->proxy,
if (g_signal_handler_is_connected (client->device,
client->key_released_handler))
g_signal_handler_disconnect (client->proxy,
g_signal_handler_disconnect (client->device,
client->key_released_handler);
}
#endif /* HAVE_FAKEKEY */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment