Rename EekboardServer to EekboardEekboard.

This commit is contained in:
Daiki Ueno
2011-02-24 10:31:09 +09:00
parent 7ef245d739
commit 3eeb7cd8ab
7 changed files with 155 additions and 152 deletions

View File

@ -20,10 +20,10 @@ lib_LTLIBRARIES = libeekboard.la
libeekboard_headers = \ libeekboard_headers = \
eekboard.h \ eekboard.h \
eekboard-server.h \ eekboard-eekboard.h \
eekboard-context.h eekboard-context.h
libeekboard_sources = \ libeekboard_sources = \
eekboard-server.c \ eekboard-eekboard.c \
eekboard-context.c eekboard-context.c
libeekboard_la_SOURCES = $(libeekboard_sources) libeekboard_la_SOURCES = $(libeekboard_sources)

View File

@ -17,58 +17,58 @@
*/ */
/** /**
* SECTION:eekboard-server * SECTION:eekboard-eekboard
* @short_description: D-Bus proxy of eekboard-server * @short_description: D-Bus proxy of eekboard-server
* *
* The #EekboardServer class provides a client side access to eekboard-server. * The #EekboardEekboard class provides a client side access to eekboard-server.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif /* HAVE_CONFIG_H */ #endif /* HAVE_CONFIG_H */
#include "eekboard/eekboard-server.h" #include "eekboard/eekboard-eekboard.h"
G_DEFINE_TYPE (EekboardServer, eekboard_server, G_TYPE_DBUS_PROXY); G_DEFINE_TYPE (EekboardEekboard, eekboard_eekboard, G_TYPE_DBUS_PROXY);
#define EEKBOARD_SERVER_GET_PRIVATE(obj) \ #define EEKBOARD_EEKBOARD_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEKBOARD_TYPE_SERVER, EekboardServerPrivate)) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEKBOARD_TYPE_EEKBOARD, EekboardEekboardPrivate))
struct _EekboardServerPrivate struct _EekboardEekboardPrivate
{ {
GHashTable *context_hash; GHashTable *context_hash;
}; };
static void static void
eekboard_server_dispose (GObject *object) eekboard_eekboard_dispose (GObject *object)
{ {
EekboardServerPrivate *priv = EEKBOARD_SERVER_GET_PRIVATE(object); EekboardEekboardPrivate *priv = EEKBOARD_EEKBOARD_GET_PRIVATE(object);
if (priv->context_hash) { if (priv->context_hash) {
g_hash_table_destroy (priv->context_hash); g_hash_table_destroy (priv->context_hash);
priv->context_hash = NULL; priv->context_hash = NULL;
} }
G_OBJECT_CLASS (eekboard_server_parent_class)->dispose (object); G_OBJECT_CLASS (eekboard_eekboard_parent_class)->dispose (object);
} }
static void static void
eekboard_server_class_init (EekboardServerClass *klass) eekboard_eekboard_class_init (EekboardEekboardClass *klass)
{ {
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (gobject_class, g_type_class_add_private (gobject_class,
sizeof (EekboardServerPrivate)); sizeof (EekboardEekboardPrivate));
gobject_class->dispose = eekboard_server_dispose; gobject_class->dispose = eekboard_eekboard_dispose;
} }
static void static void
eekboard_server_init (EekboardServer *self) eekboard_eekboard_init (EekboardEekboard *self)
{ {
EekboardServerPrivate *priv; EekboardEekboardPrivate *priv;
priv = self->priv = EEKBOARD_SERVER_GET_PRIVATE(self); priv = self->priv = EEKBOARD_EEKBOARD_GET_PRIVATE(self);
priv->context_hash = priv->context_hash =
g_hash_table_new_full (g_str_hash, g_hash_table_new_full (g_str_hash,
g_str_equal, g_str_equal,
@ -77,14 +77,14 @@ eekboard_server_init (EekboardServer *self)
} }
/** /**
* eekboard_server_new: * eekboard_eekboard_new:
* @connection: a #GDBusConnection * @connection: a #GDBusConnection
* @cancellable: a #GCancellable * @cancellable: a #GCancellable
* *
* Create a D-Bus proxy of eekboard-server. * Create a D-Bus proxy of eekboard-eekboard.
*/ */
EekboardServer * EekboardEekboard *
eekboard_server_new (GDBusConnection *connection, eekboard_eekboard_new (GDBusConnection *connection,
GCancellable *cancellable) GCancellable *cancellable)
{ {
GInitable *initable; GInitable *initable;
@ -94,7 +94,7 @@ eekboard_server_new (GDBusConnection *connection,
error = NULL; error = NULL;
initable = initable =
g_initable_new (EEKBOARD_TYPE_SERVER, g_initable_new (EEKBOARD_TYPE_EEKBOARD,
cancellable, cancellable,
&error, &error,
"g-connection", connection, "g-connection", connection,
@ -103,35 +103,35 @@ eekboard_server_new (GDBusConnection *connection,
"g-object-path", "/com/redhat/Eekboard/Server", "g-object-path", "/com/redhat/Eekboard/Server",
NULL); NULL);
if (initable != NULL) if (initable != NULL)
return EEKBOARD_SERVER (initable); return EEKBOARD_EEKBOARD (initable);
return NULL; return NULL;
} }
/** /**
* eekboard_server_create_context: * eekboard_eekboard_create_context:
* @server: an #EekboardServer * @eekboard: an #EekboardEekboard
* @client_name: name of the client * @client_name: name of the client
* @cancellable: a #GCancellable * @cancellable: a #GCancellable
* *
* Create a new input context. * Create a new input context.
*/ */
EekboardContext * EekboardContext *
eekboard_server_create_context (EekboardServer *server, eekboard_eekboard_create_context (EekboardEekboard *eekboard,
const gchar *client_name, const gchar *client_name,
GCancellable *cancellable) GCancellable *cancellable)
{ {
GVariant *variant; GVariant *variant;
const gchar *object_path; const gchar *object_path;
EekboardContext *context; EekboardContext *context;
EekboardServerPrivate *priv; EekboardEekboardPrivate *priv;
GError *error; GError *error;
GDBusConnection *connection; GDBusConnection *connection;
g_assert (EEKBOARD_IS_SERVER(server)); g_assert (EEKBOARD_IS_EEKBOARD(eekboard));
g_assert (client_name); g_assert (client_name);
error = NULL; error = NULL;
variant = g_dbus_proxy_call_sync (G_DBUS_PROXY(server), variant = g_dbus_proxy_call_sync (G_DBUS_PROXY(eekboard),
"CreateContext", "CreateContext",
g_variant_new ("(s)", client_name), g_variant_new ("(s)", client_name),
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
@ -142,14 +142,14 @@ eekboard_server_create_context (EekboardServer *server,
return NULL; return NULL;
g_variant_get (variant, "(&s)", &object_path); g_variant_get (variant, "(&s)", &object_path);
connection = g_dbus_proxy_get_connection (G_DBUS_PROXY(server)); connection = g_dbus_proxy_get_connection (G_DBUS_PROXY(eekboard));
context = eekboard_context_new (connection, object_path, cancellable); context = eekboard_context_new (connection, object_path, cancellable);
if (!context) { if (!context) {
g_variant_unref (variant); g_variant_unref (variant);
return NULL; return NULL;
} }
priv = EEKBOARD_SERVER_GET_PRIVATE(server); priv = EEKBOARD_EEKBOARD_GET_PRIVATE(eekboard);
g_hash_table_insert (priv->context_hash, g_hash_table_insert (priv->context_hash,
g_strdup (object_path), g_strdup (object_path),
g_object_ref (context)); g_object_ref (context));
@ -157,7 +157,7 @@ eekboard_server_create_context (EekboardServer *server,
} }
static void static void
server_async_ready_callback (GObject *source_object, eekboard_async_ready_callback (GObject *source_object,
GAsyncResult *res, GAsyncResult *res,
gpointer user_data) gpointer user_data)
{ {
@ -172,95 +172,95 @@ server_async_ready_callback (GObject *source_object,
} }
/** /**
* eekboard_server_push_context: * eekboard_eekboard_push_context:
* @server: an #EekboardServer * @eekboard: an #EekboardEekboard
* @context: an #EekboardContext * @context: an #EekboardContext
* @cancellable: a #GCancellable * @cancellable: a #GCancellable
* *
* Enable the input context @context and disable the others. * Enable the input context @context and disable the others.
*/ */
void void
eekboard_server_push_context (EekboardServer *server, eekboard_eekboard_push_context (EekboardEekboard *eekboard,
EekboardContext *context, EekboardContext *context,
GCancellable *cancellable) GCancellable *cancellable)
{ {
EekboardServerPrivate *priv; EekboardEekboardPrivate *priv;
const gchar *object_path; const gchar *object_path;
g_return_if_fail (EEKBOARD_IS_SERVER(server)); g_return_if_fail (EEKBOARD_IS_EEKBOARD(eekboard));
g_return_if_fail (EEKBOARD_IS_CONTEXT(context)); g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(context)); object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(context));
priv = EEKBOARD_SERVER_GET_PRIVATE(server); priv = EEKBOARD_EEKBOARD_GET_PRIVATE(eekboard);
context = g_hash_table_lookup (priv->context_hash, object_path); context = g_hash_table_lookup (priv->context_hash, object_path);
if (!context) if (!context)
return; return;
eekboard_context_set_enabled (context, TRUE); eekboard_context_set_enabled (context, TRUE);
g_dbus_proxy_call (G_DBUS_PROXY(server), g_dbus_proxy_call (G_DBUS_PROXY(eekboard),
"PushContext", "PushContext",
g_variant_new ("(s)", object_path), g_variant_new ("(s)", object_path),
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
-1, -1,
cancellable, cancellable,
server_async_ready_callback, eekboard_async_ready_callback,
NULL); NULL);
} }
/** /**
* eekboard_server_pop_context: * eekboard_eekboard_pop_context:
* @server: an #EekboardServer * @eekboard: an #EekboardEekboard
* @cancellable: a #GCancellable * @cancellable: a #GCancellable
* *
* Disable the current input context and enable the previous one. * Disable the current input context and enable the previous one.
*/ */
void void
eekboard_server_pop_context (EekboardServer *server, eekboard_eekboard_pop_context (EekboardEekboard *eekboard,
GCancellable *cancellable) GCancellable *cancellable)
{ {
g_return_if_fail (EEKBOARD_IS_SERVER(server)); g_return_if_fail (EEKBOARD_IS_EEKBOARD(eekboard));
g_dbus_proxy_call (G_DBUS_PROXY(server), g_dbus_proxy_call (G_DBUS_PROXY(eekboard),
"PopContext", "PopContext",
NULL, NULL,
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
-1, -1,
cancellable, cancellable,
server_async_ready_callback, eekboard_async_ready_callback,
NULL); NULL);
} }
/** /**
* eekboard_server_destroy_context: * eekboard_eekboard_destroy_context:
* @server: an #EekboardServer * @eekboard: an #EekboardEekboard
* @context: an #EekboardContext * @context: an #EekboardContext
* @cancellable: a #GCancellable * @cancellable: a #GCancellable
* *
* Remove @context from @server. * Remove @context from @eekboard.
*/ */
void void
eekboard_server_destroy_context (EekboardServer *server, eekboard_eekboard_destroy_context (EekboardEekboard *eekboard,
EekboardContext *context, EekboardContext *context,
GCancellable *cancellable) GCancellable *cancellable)
{ {
EekboardServerPrivate *priv; EekboardEekboardPrivate *priv;
const gchar *object_path; const gchar *object_path;
g_return_if_fail (EEKBOARD_IS_SERVER(server)); g_return_if_fail (EEKBOARD_IS_EEKBOARD(eekboard));
g_return_if_fail (EEKBOARD_IS_CONTEXT(context)); g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
priv = EEKBOARD_SERVER_GET_PRIVATE(server); priv = EEKBOARD_EEKBOARD_GET_PRIVATE(eekboard);
object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(context)); object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(context));
g_hash_table_remove (priv->context_hash, object_path); g_hash_table_remove (priv->context_hash, object_path);
g_dbus_proxy_call (G_DBUS_PROXY(server), g_dbus_proxy_call (G_DBUS_PROXY(eekboard),
"DestroyContext", "DestroyContext",
g_variant_new ("(s)", object_path), g_variant_new ("(s)", object_path),
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
-1, -1,
cancellable, cancellable,
server_async_ready_callback, eekboard_async_ready_callback,
NULL); NULL);
} }

View File

@ -0,0 +1,73 @@
/*
* 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_EEKBOARD_H
#define EEKBOARD_EEKBOARD_H 1
#include <gio/gio.h>
#include "eekboard/eekboard-context.h"
G_BEGIN_DECLS
#define EEKBOARD_TYPE_EEKBOARD (eekboard_eekboard_get_type())
#define EEKBOARD_EEKBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_EEKBOARD, EekboardEekboard))
#define EEKBOARD_EEKBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEKBOARD_TYPE_EEKBOARD, EekboardEekboardClass))
#define EEKBOARD_IS_EEKBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEKBOARD_TYPE_EEKBOARD))
#define EEKBOARD_IS_EEKBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEKBOARD_TYPE_EEKBOARD))
#define EEKBOARD_EEKBOARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEKBOARD_TYPE_EEKBOARD, EekboardEekboardClass))
typedef struct _EekboardEekboard EekboardEekboard;
typedef struct _EekboardEekboardClass EekboardEekboardClass;
typedef struct _EekboardEekboardPrivate EekboardEekboardPrivate;
struct _EekboardEekboard {
/*< private >*/
GDBusProxy parent;
EekboardEekboardPrivate *priv;
};
struct _EekboardEekboardClass {
/*< private >*/
GDBusProxyClass parent_class;
/*< private >*/
/* padding */
gpointer pdummy[24];
};
GType eekboard_eekboard_get_type (void) G_GNUC_CONST;
EekboardEekboard *eekboard_eekboard_new (GDBusConnection *connection,
GCancellable *cancellable);
EekboardContext *eekboard_eekboard_create_context
(EekboardEekboard *eekboard,
const gchar *client_name,
GCancellable *cancellable);
void eekboard_eekboard_push_context
(EekboardEekboard *eekboard,
EekboardContext *context,
GCancellable *cancellable);
void eekboard_eekboard_pop_context (EekboardEekboard *eekboard,
GCancellable *cancellable);
void eekboard_eekboard_destroy_context
(EekboardEekboard *eekboard,
EekboardContext *context,
GCancellable *cancellable);
G_END_DECLS
#endif /* EEKBOARD_EEKBOARD_H */

View File

@ -1,70 +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_SERVER_H
#define EEKBOARD_SERVER_H 1
#include <gio/gio.h>
#include "eekboard/eekboard-context.h"
G_BEGIN_DECLS
#define EEKBOARD_TYPE_SERVER (eekboard_server_get_type())
#define EEKBOARD_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_SERVER, EekboardServer))
#define EEKBOARD_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEKBOARD_TYPE_SERVER, EekboardServerClass))
#define EEKBOARD_IS_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEKBOARD_TYPE_SERVER))
#define EEKBOARD_IS_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEKBOARD_TYPE_SERVER))
#define EEKBOARD_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEKBOARD_TYPE_SERVER, EekboardServerClass))
typedef struct _EekboardServer EekboardServer;
typedef struct _EekboardServerClass EekboardServerClass;
typedef struct _EekboardServerPrivate EekboardServerPrivate;
struct _EekboardServer {
/*< private >*/
GDBusProxy parent;
EekboardServerPrivate *priv;
};
struct _EekboardServerClass {
/*< private >*/
GDBusProxyClass parent_class;
/*< private >*/
/* padding */
gpointer pdummy[24];
};
GType eekboard_server_get_type (void) G_GNUC_CONST;
EekboardServer *eekboard_server_new (GDBusConnection *connection,
GCancellable *cancellable);
EekboardContext *eekboard_server_create_context (EekboardServer *server,
const gchar *client_name,
GCancellable *cancellable);
void eekboard_server_push_context (EekboardServer *server,
EekboardContext *context,
GCancellable *cancellable);
void eekboard_server_pop_context (EekboardServer *server,
GCancellable *cancellable);
void eekboard_server_destroy_context (EekboardServer *server,
EekboardContext *context,
GCancellable *cancellable);
G_END_DECLS
#endif /* EEKBOARD_SERVER_H */

View File

@ -18,7 +18,7 @@
#ifndef EEKBOARD_H #ifndef EEKBOARD_H
#define EEKBOARD_H 1 #define EEKBOARD_H 1
#include "eekboard/eekboard-server.h" #include "eekboard/eekboard-eekboard.h"
#include "eekboard/eekboard-context.h" #include "eekboard/eekboard-context.h"
#endif /* EEKBOARD_H */ #endif /* EEKBOARD_H */

View File

@ -62,7 +62,7 @@ on_key_released (guint keycode, gpointer user_data)
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
EekboardServer *server = NULL; EekboardEekboard *eekboard = NULL;
EekboardContext *context = NULL; EekboardContext *context = NULL;
GDBusConnection *connection = NULL; GDBusConnection *connection = NULL;
GError *error; GError *error;
@ -86,14 +86,14 @@ main (int argc, char **argv)
goto out; goto out;
} }
server = eekboard_server_new (connection, NULL); eekboard = eekboard_eekboard_new (connection, NULL);
if (!server) { if (!eekboard) {
g_printerr ("Can't create server\n"); g_printerr ("Can't create eekboard\n");
retval = 1; retval = 1;
goto out; goto out;
} }
context = eekboard_server_create_context (server, context = eekboard_eekboard_create_context (eekboard,
"eekboard-client", "eekboard-client",
NULL); NULL);
if (!context) { if (!context) {
@ -102,7 +102,7 @@ main (int argc, char **argv)
goto out; goto out;
} }
eekboard_server_push_context (server, context, NULL); eekboard_eekboard_push_context (eekboard, context, NULL);
if (opt_set_keyboard) { if (opt_set_keyboard) {
GFile *file; GFile *file;

View File

@ -51,7 +51,7 @@ typedef struct _EekboardDesktopClientClass EekboardDesktopClientClass;
struct _EekboardDesktopClient { struct _EekboardDesktopClient {
GObject parent; GObject parent;
EekboardServer *server; EekboardEekboard *eekboard;
EekboardContext *context; EekboardContext *context;
EekKeyboard *keyboard; EekKeyboard *keyboard;
@ -119,16 +119,16 @@ eekboard_desktop_client_set_property (GObject *object,
case PROP_CONNECTION: case PROP_CONNECTION:
connection = g_value_get_object (value); connection = g_value_get_object (value);
client->server = eekboard_server_new (connection, NULL); client->eekboard = eekboard_eekboard_new (connection, NULL);
g_assert (client->server); g_assert (client->eekboard);
client->context = client->context =
eekboard_server_create_context (client->server, eekboard_eekboard_create_context (client->eekboard,
"eekboard-desktop-client", "eekboard-desktop-client",
NULL); NULL);
g_assert (client->context); g_assert (client->context);
eekboard_server_push_context (client->server, client->context, NULL); eekboard_eekboard_push_context (client->eekboard, client->context, NULL);
break; break;
default: default:
g_object_set_property (object, g_object_set_property (object,
@ -175,17 +175,17 @@ eekboard_desktop_client_dispose (GObject *object)
#endif /* HAVE_FAKEKEY */ #endif /* HAVE_FAKEKEY */
if (client->context) { if (client->context) {
if (client->server) { if (client->eekboard) {
eekboard_server_pop_context (client->server, NULL); eekboard_eekboard_pop_context (client->eekboard, NULL);
} }
g_object_unref (client->context); g_object_unref (client->context);
client->context = NULL; client->context = NULL;
} }
if (client->server) { if (client->eekboard) {
g_object_unref (client->server); g_object_unref (client->eekboard);
client->server = NULL; client->eekboard = NULL;
} }
if (client->keyboard) { if (client->keyboard) {
@ -239,7 +239,7 @@ eekboard_desktop_client_class_init (EekboardDesktopClientClass *klass)
static void static void
eekboard_desktop_client_init (EekboardDesktopClient *client) eekboard_desktop_client_init (EekboardDesktopClient *client)
{ {
client->server = NULL; client->eekboard = NULL;
client->context = NULL; client->context = NULL;
client->display = NULL; client->display = NULL;
client->xkl_engine = NULL; client->xkl_engine = NULL;