Commit 3eeb7cd8 authored by Daiki Ueno's avatar Daiki Ueno
Browse files

Rename EekboardServer to EekboardEekboard.

parent 7ef245d7
......@@ -20,10 +20,10 @@ lib_LTLIBRARIES = libeekboard.la
libeekboard_headers = \
eekboard.h \
eekboard-server.h \
eekboard-eekboard.h \
eekboard-context.h
libeekboard_sources = \
eekboard-server.c \
eekboard-eekboard.c \
eekboard-context.c
libeekboard_la_SOURCES = $(libeekboard_sources)
......
......@@ -17,58 +17,58 @@
*/
/**
* SECTION:eekboard-server
* SECTION:eekboard-eekboard
* @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
#include "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) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEKBOARD_TYPE_SERVER, EekboardServerPrivate))
#define EEKBOARD_EEKBOARD_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEKBOARD_TYPE_EEKBOARD, EekboardEekboardPrivate))
struct _EekboardServerPrivate
struct _EekboardEekboardPrivate
{
GHashTable *context_hash;
};
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) {
g_hash_table_destroy (priv->context_hash);
priv->context_hash = NULL;
}
G_OBJECT_CLASS (eekboard_server_parent_class)->dispose (object);
G_OBJECT_CLASS (eekboard_eekboard_parent_class)->dispose (object);
}
static void
eekboard_server_class_init (EekboardServerClass *klass)
eekboard_eekboard_class_init (EekboardEekboardClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
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
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 =
g_hash_table_new_full (g_str_hash,
g_str_equal,
......@@ -77,15 +77,15 @@ eekboard_server_init (EekboardServer *self)
}
/**
* eekboard_server_new:
* eekboard_eekboard_new:
* @connection: a #GDBusConnection
* @cancellable: a #GCancellable
*
* Create a D-Bus proxy of eekboard-server.
* Create a D-Bus proxy of eekboard-eekboard.
*/
EekboardServer *
eekboard_server_new (GDBusConnection *connection,
GCancellable *cancellable)
EekboardEekboard *
eekboard_eekboard_new (GDBusConnection *connection,
GCancellable *cancellable)
{
GInitable *initable;
GError *error;
......@@ -94,7 +94,7 @@ eekboard_server_new (GDBusConnection *connection,
error = NULL;
initable =
g_initable_new (EEKBOARD_TYPE_SERVER,
g_initable_new (EEKBOARD_TYPE_EEKBOARD,
cancellable,
&error,
"g-connection", connection,
......@@ -103,35 +103,35 @@ eekboard_server_new (GDBusConnection *connection,
"g-object-path", "/com/redhat/Eekboard/Server",
NULL);
if (initable != NULL)
return EEKBOARD_SERVER (initable);
return EEKBOARD_EEKBOARD (initable);
return NULL;
}
/**
* eekboard_server_create_context:
* @server: an #EekboardServer
* eekboard_eekboard_create_context:
* @eekboard: an #EekboardEekboard
* @client_name: name of the client
* @cancellable: a #GCancellable
*
* Create a new input context.
*/
EekboardContext *
eekboard_server_create_context (EekboardServer *server,
const gchar *client_name,
GCancellable *cancellable)
eekboard_eekboard_create_context (EekboardEekboard *eekboard,
const gchar *client_name,
GCancellable *cancellable)
{
GVariant *variant;
const gchar *object_path;
EekboardContext *context;
EekboardServerPrivate *priv;
EekboardEekboardPrivate *priv;
GError *error;
GDBusConnection *connection;
g_assert (EEKBOARD_IS_SERVER(server));
g_assert (EEKBOARD_IS_EEKBOARD(eekboard));
g_assert (client_name);
error = NULL;
variant = g_dbus_proxy_call_sync (G_DBUS_PROXY(server),
variant = g_dbus_proxy_call_sync (G_DBUS_PROXY(eekboard),
"CreateContext",
g_variant_new ("(s)", client_name),
G_DBUS_CALL_FLAGS_NONE,
......@@ -142,14 +142,14 @@ eekboard_server_create_context (EekboardServer *server,
return NULL;
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);
if (!context) {
g_variant_unref (variant);
return NULL;
}
priv = EEKBOARD_SERVER_GET_PRIVATE(server);
priv = EEKBOARD_EEKBOARD_GET_PRIVATE(eekboard);
g_hash_table_insert (priv->context_hash,
g_strdup (object_path),
g_object_ref (context));
......@@ -157,7 +157,7 @@ eekboard_server_create_context (EekboardServer *server,
}
static void
server_async_ready_callback (GObject *source_object,
eekboard_async_ready_callback (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
......@@ -172,95 +172,95 @@ server_async_ready_callback (GObject *source_object,
}
/**
* eekboard_server_push_context:
* @server: an #EekboardServer
* eekboard_eekboard_push_context:
* @eekboard: an #EekboardEekboard
* @context: an #EekboardContext
* @cancellable: a #GCancellable
*
* Enable the input context @context and disable the others.
*/
void
eekboard_server_push_context (EekboardServer *server,
EekboardContext *context,
GCancellable *cancellable)
eekboard_eekboard_push_context (EekboardEekboard *eekboard,
EekboardContext *context,
GCancellable *cancellable)
{
EekboardServerPrivate *priv;
EekboardEekboardPrivate *priv;
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));
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);
if (!context)
return;
eekboard_context_set_enabled (context, TRUE);
g_dbus_proxy_call (G_DBUS_PROXY(server),
g_dbus_proxy_call (G_DBUS_PROXY(eekboard),
"PushContext",
g_variant_new ("(s)", object_path),
G_DBUS_CALL_FLAGS_NONE,
-1,
cancellable,
server_async_ready_callback,
eekboard_async_ready_callback,
NULL);
}
/**
* eekboard_server_pop_context:
* @server: an #EekboardServer
* eekboard_eekboard_pop_context:
* @eekboard: an #EekboardEekboard
* @cancellable: a #GCancellable
*
* Disable the current input context and enable the previous one.
*/
void
eekboard_server_pop_context (EekboardServer *server,
GCancellable *cancellable)
eekboard_eekboard_pop_context (EekboardEekboard *eekboard,
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",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
cancellable,
server_async_ready_callback,
eekboard_async_ready_callback,
NULL);
}
/**
* eekboard_server_destroy_context:
* @server: an #EekboardServer
* eekboard_eekboard_destroy_context:
* @eekboard: an #EekboardEekboard
* @context: an #EekboardContext
* @cancellable: a #GCancellable
*
* Remove @context from @server.
* Remove @context from @eekboard.
*/
void
eekboard_server_destroy_context (EekboardServer *server,
EekboardContext *context,
GCancellable *cancellable)
eekboard_eekboard_destroy_context (EekboardEekboard *eekboard,
EekboardContext *context,
GCancellable *cancellable)
{
EekboardServerPrivate *priv;
EekboardEekboardPrivate *priv;
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));
priv = EEKBOARD_SERVER_GET_PRIVATE(server);
priv = EEKBOARD_EEKBOARD_GET_PRIVATE(eekboard);
object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(context));
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",
g_variant_new ("(s)", object_path),
G_DBUS_CALL_FLAGS_NONE,
-1,
cancellable,
server_async_ready_callback,
eekboard_async_ready_callback,
NULL);
}
......@@ -15,33 +15,33 @@
* 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
#ifndef EEKBOARD_EEKBOARD_H
#define EEKBOARD_EEKBOARD_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))
#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 _EekboardServer EekboardServer;
typedef struct _EekboardServerClass EekboardServerClass;
typedef struct _EekboardServerPrivate EekboardServerPrivate;
typedef struct _EekboardEekboard EekboardEekboard;
typedef struct _EekboardEekboardClass EekboardEekboardClass;
typedef struct _EekboardEekboardPrivate EekboardEekboardPrivate;
struct _EekboardServer {
struct _EekboardEekboard {
/*< private >*/
GDBusProxy parent;
EekboardServerPrivate *priv;
EekboardEekboardPrivate *priv;
};
struct _EekboardServerClass {
struct _EekboardEekboardClass {
/*< private >*/
GDBusProxyClass parent_class;
......@@ -50,21 +50,24 @@ struct _EekboardServerClass {
gpointer pdummy[24];
};
GType eekboard_server_get_type (void) G_GNUC_CONST;
GType eekboard_eekboard_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);
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_SERVER_H */
#endif /* EEKBOARD_EEKBOARD_H */
......@@ -18,7 +18,7 @@
#ifndef EEKBOARD_H
#define EEKBOARD_H 1
#include "eekboard/eekboard-server.h"
#include "eekboard/eekboard-eekboard.h"
#include "eekboard/eekboard-context.h"
#endif /* EEKBOARD_H */
......@@ -62,7 +62,7 @@ on_key_released (guint keycode, gpointer user_data)
int
main (int argc, char **argv)
{
EekboardServer *server = NULL;
EekboardEekboard *eekboard = NULL;
EekboardContext *context = NULL;
GDBusConnection *connection = NULL;
GError *error;
......@@ -86,14 +86,14 @@ main (int argc, char **argv)
goto out;
}
server = eekboard_server_new (connection, NULL);
if (!server) {
g_printerr ("Can't create server\n");
eekboard = eekboard_eekboard_new (connection, NULL);
if (!eekboard) {
g_printerr ("Can't create eekboard\n");
retval = 1;
goto out;
}
context = eekboard_server_create_context (server,
context = eekboard_eekboard_create_context (eekboard,
"eekboard-client",
NULL);
if (!context) {
......@@ -102,7 +102,7 @@ main (int argc, char **argv)
goto out;
}
eekboard_server_push_context (server, context, NULL);
eekboard_eekboard_push_context (eekboard, context, NULL);
if (opt_set_keyboard) {
GFile *file;
......
......@@ -51,7 +51,7 @@ typedef struct _EekboardDesktopClientClass EekboardDesktopClientClass;
struct _EekboardDesktopClient {
GObject parent;
EekboardServer *server;
EekboardEekboard *eekboard;
EekboardContext *context;
EekKeyboard *keyboard;
......@@ -119,16 +119,16 @@ eekboard_desktop_client_set_property (GObject *object,
case PROP_CONNECTION:
connection = g_value_get_object (value);
client->server = eekboard_server_new (connection, NULL);
g_assert (client->server);
client->eekboard = eekboard_eekboard_new (connection, NULL);
g_assert (client->eekboard);
client->context =
eekboard_server_create_context (client->server,
eekboard_eekboard_create_context (client->eekboard,
"eekboard-desktop-client",
NULL);
g_assert (client->context);
eekboard_server_push_context (client->server, client->context, NULL);
eekboard_eekboard_push_context (client->eekboard, client->context, NULL);
break;
default:
g_object_set_property (object,
......@@ -175,17 +175,17 @@ eekboard_desktop_client_dispose (GObject *object)
#endif /* HAVE_FAKEKEY */
if (client->context) {
if (client->server) {
eekboard_server_pop_context (client->server, NULL);
if (client->eekboard) {
eekboard_eekboard_pop_context (client->eekboard, NULL);
}
g_object_unref (client->context);
client->context = NULL;
}
if (client->server) {
g_object_unref (client->server);
client->server = NULL;
if (client->eekboard) {
g_object_unref (client->eekboard);
client->eekboard = NULL;
}
if (client->keyboard) {
......@@ -239,7 +239,7 @@ eekboard_desktop_client_class_init (EekboardDesktopClientClass *klass)
static void
eekboard_desktop_client_init (EekboardDesktopClient *client)
{
client->server = NULL;
client->eekboard = NULL;
client->context = NULL;
client->display = NULL;
client->xkl_engine = NULL;
......
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