Rename EekboardDevice to EekboardKeyboard.

This commit is contained in:
Daiki Ueno
2011-02-18 11:39:16 +09:00
parent 22a51a2813
commit fdd9c3d0ee
8 changed files with 169 additions and 161 deletions

View File

@ -18,8 +18,8 @@
lib_LTLIBRARIES = libeekboard.la
libeekboard_headers = eekboard.h eekboard-device.h
libeekboard_sources = eekboard-device.c
libeekboard_headers = eekboard.h eekboard-keyboard.h
libeekboard_sources = eekboard-keyboard.c
libeekboard_la_SOURCES = $(libeekboard_sources)
libeekboard_la_CFLAGS = -I$(top_srcdir) $(GIO2_CFLAGS)

View File

@ -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_DEVICE_H
#define EEKBOARD_DEVICE_H 1
#include <gio/gio.h>
#include "eek/eek.h"
G_BEGIN_DECLS
#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 _EekboardDevice EekboardDevice;
typedef struct _EekboardDeviceClass EekboardDeviceClass;
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_DEVICE_H */

View File

@ -19,7 +19,7 @@
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include "eekboard-device.h"
#include "eekboard-keyboard.h"
enum {
KEY_PRESSED,
@ -29,35 +29,35 @@ enum {
static guint signals[LAST_SIGNAL] = { 0, };
struct _EekboardDevice {
struct _EekboardKeyboard {
GDBusProxy parent;
};
struct _EekboardDeviceClass {
struct _EekboardKeyboardClass {
GDBusProxyClass parent_class;
};
G_DEFINE_TYPE (EekboardDevice, eekboard_device, G_TYPE_DBUS_PROXY);
G_DEFINE_TYPE (EekboardKeyboard, eekboard_keyboard, G_TYPE_DBUS_PROXY);
static void
eekboard_device_real_g_signal (GDBusProxy *self,
eekboard_keyboard_real_g_signal (GDBusProxy *self,
const gchar *sender_name,
const gchar *signal_name,
GVariant *parameters)
{
EekboardDevice *device = EEKBOARD_DEVICE (self);
EekboardKeyboard *keyboard = EEKBOARD_KEYBOARD (self);
guint *keycode;
if (g_strcmp0 (signal_name, "KeyPressed") == 0) {
g_variant_get (parameters, "(u)", &keycode);
g_signal_emit_by_name (device, "key-pressed", keycode);
g_signal_emit_by_name (keyboard, "key-pressed", keycode);
return;
}
if (g_strcmp0 (signal_name, "KeyReleased") == 0) {
g_variant_get (parameters, "(u)", &keycode);
g_signal_emit_by_name (device, "key-released", keycode);
g_signal_emit_by_name (keyboard, "key-released", keycode);
return;
}
@ -65,12 +65,12 @@ eekboard_device_real_g_signal (GDBusProxy *self,
}
static void
eekboard_device_class_init (EekboardDeviceClass *klass)
eekboard_keyboard_class_init (EekboardKeyboardClass *klass)
{
GDBusProxyClass *proxy_class = G_DBUS_PROXY_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
proxy_class->g_signal = eekboard_device_real_g_signal;
proxy_class->g_signal = eekboard_keyboard_real_g_signal;
signals[KEY_PRESSED] =
g_signal_new ("key-pressed",
@ -98,15 +98,15 @@ eekboard_device_class_init (EekboardDeviceClass *klass)
}
static void
eekboard_device_init (EekboardDevice *device)
eekboard_keyboard_init (EekboardKeyboard *keyboard)
{
}
EekboardDevice *
eekboard_device_new (const gchar *path,
GDBusConnection *connection,
GCancellable *cancellable,
GError **error)
EekboardKeyboard *
eekboard_keyboard_new (const gchar *path,
GDBusConnection *connection,
GCancellable *cancellable,
GError **error)
{
GInitable *initable;
@ -114,18 +114,18 @@ eekboard_device_new (const gchar *path,
g_assert (G_IS_DBUS_CONNECTION(connection));
initable =
g_initable_new (EEKBOARD_TYPE_DEVICE,
g_initable_new (EEKBOARD_TYPE_KEYBOARD,
cancellable,
error,
"g-connection", connection,
"g-name", "com.redhat.eekboard.Device",
"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.Device",
"g-interface-name", "com.redhat.eekboard.Keyboard",
"g-object-path", path,
NULL);
if (initable != NULL)
return EEKBOARD_DEVICE (initable);
return EEKBOARD_KEYBOARD (initable);
return NULL;
}
@ -146,13 +146,14 @@ proxy_call_async_ready_cb (GObject *source_object,
}
void
eekboard_device_set_keyboard (EekboardDevice *device, EekKeyboard *keyboard)
eekboard_keyboard_set_description (EekboardKeyboard *keyboard,
EekKeyboard *description)
{
GVariant *variant;
variant = eek_serializable_serialize (EEK_SERIALIZABLE(keyboard));
g_dbus_proxy_call (G_DBUS_PROXY(device),
"SetKeyboard",
variant = eek_serializable_serialize (description);
g_dbus_proxy_call (G_DBUS_PROXY(keyboard),
"SetDescription",
g_variant_new ("(v)", variant),
G_DBUS_CALL_FLAGS_NONE,
-1,
@ -163,10 +164,10 @@ eekboard_device_set_keyboard (EekboardDevice *device, EekKeyboard *keyboard)
}
void
eekboard_device_set_group (EekboardDevice *device,
gint group)
eekboard_keyboard_set_group (EekboardKeyboard *keyboard,
gint group)
{
g_dbus_proxy_call (G_DBUS_PROXY(device),
g_dbus_proxy_call (G_DBUS_PROXY(keyboard),
"SetGroup",
g_variant_new ("(i)", group),
G_DBUS_CALL_FLAGS_NONE,
@ -177,9 +178,9 @@ eekboard_device_set_group (EekboardDevice *device,
}
void
eekboard_device_show (EekboardDevice *device)
eekboard_keyboard_show (EekboardKeyboard *keyboard)
{
g_dbus_proxy_call (G_DBUS_PROXY(device),
g_dbus_proxy_call (G_DBUS_PROXY(keyboard),
"Show",
NULL,
G_DBUS_CALL_FLAGS_NONE,
@ -190,9 +191,9 @@ eekboard_device_show (EekboardDevice *device)
}
void
eekboard_device_hide (EekboardDevice *device)
eekboard_keyboard_hide (EekboardKeyboard *keyboard)
{
g_dbus_proxy_call (G_DBUS_PROXY(device),
g_dbus_proxy_call (G_DBUS_PROXY(keyboard),
"Hide",
NULL,
G_DBUS_CALL_FLAGS_NONE,
@ -203,10 +204,10 @@ eekboard_device_hide (EekboardDevice *device)
}
void
eekboard_device_press_key (EekboardDevice *device,
guint keycode)
eekboard_keyboard_press_key (EekboardKeyboard *keyboard,
guint keycode)
{
g_dbus_proxy_call (G_DBUS_PROXY(device),
g_dbus_proxy_call (G_DBUS_PROXY(keyboard),
"PressKey",
g_variant_new ("(u)", keycode),
G_DBUS_CALL_FLAGS_NONE,
@ -217,10 +218,10 @@ eekboard_device_press_key (EekboardDevice *device,
}
void
eekboard_device_release_key (EekboardDevice *device,
guint keycode)
eekboard_keyboard_release_key (EekboardKeyboard *keyboard,
guint keycode)
{
g_dbus_proxy_call (G_DBUS_PROXY(device),
g_dbus_proxy_call (G_DBUS_PROXY(keyboard),
"ReleaseKey",
g_variant_new ("(u)", keycode),
G_DBUS_CALL_FLAGS_NONE,

View File

@ -0,0 +1,53 @@
/*
* 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_KEYBOARD_H
#define EEKBOARD_KEYBOARD_H 1
#include <gio/gio.h>
#include "eek/eek.h"
G_BEGIN_DECLS
#define EEKBOARD_TYPE_KEYBOARD (eekboard_keyboard_get_type())
#define EEKBOARD_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_KEYBOARD, EekboardKeyboard))
#define EEKBOARD_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEKBOARD_TYPE_KEYBOARD, EekboardKeyboardClass))
#define EEKBOARD_IS_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEKBOARD_TYPE_KEYBOARD))
#define EEKBOARD_IS_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEKBOARD_TYPE_KEYBOARD))
#define EEKBOARD_KEYBOARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEKBOARD_TYPE_KEYBOARD, EekboardKeyboardClass))
typedef struct _EekboardKeyboard EekboardKeyboard;
typedef struct _EekboardKeyboardClass EekboardKeyboardClass;
EekboardKeyboard *eekboard_keyboard_new (const gchar *path,
GDBusConnection *connection,
GCancellable *cancellable,
GError **error);
void eekboard_keyboard_set_description
(EekboardKeyboard *keyboard,
EekKeyboard *description);
void eekboard_keyboard_set_group (EekboardKeyboard *keyboard,
gint group);
void eekboard_keyboard_show (EekboardKeyboard *keyboard);
void eekboard_keyboard_hide (EekboardKeyboard *keyboard);
void eekboard_keyboard_press_key (EekboardKeyboard *keyboard,
guint keycode);
void eekboard_keyboard_release_key (EekboardKeyboard *keyboard,
guint keycode);
G_END_DECLS
#endif /* EEKBOARD_KEYBOARD_H */

View File

@ -18,6 +18,6 @@
#ifndef EEKBOARD_H
#define EEKBOARD_H 1
#include "eekboard/eekboard-device.h"
#include "eekboard/eekboard-keyboard.h"
#endif /* EEKBOARD_H */