Cleanups: fix deprecated g_type_class_add_private()
- use G_DECLARE_ and G_DEFINE_ macros - move all data into ClassNamePrivate - use _get_instance_private() This should not introduce any functional changes or breakage. Skipped two classes (EekKeyboard and EekboardContextService) for now in order not to break the build. These two classes are used in some very funky WIP code that tries to circumvent encapsulation. (Funky code is in eekboard/key-emitter.c and eekboard/eekboard-context-service.c)
This commit is contained in:
@ -36,15 +36,12 @@ enum {
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
G_DEFINE_TYPE (EekboardClient, eekboard_client, G_TYPE_DBUS_PROXY);
|
||||
|
||||
#define EEKBOARD_CLIENT_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEKBOARD_TYPE_CLIENT, EekboardClientPrivate))
|
||||
|
||||
struct _EekboardClientPrivate
|
||||
typedef struct _EekboardClientPrivate
|
||||
{
|
||||
GHashTable *context_hash;
|
||||
};
|
||||
} EekboardClientPrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (EekboardClient, eekboard_client, G_TYPE_DBUS_PROXY)
|
||||
|
||||
static void send_destroy_context (EekboardClient *client,
|
||||
EekboardContext *context,
|
||||
@ -53,7 +50,7 @@ static void send_destroy_context (EekboardClient *client,
|
||||
static void
|
||||
eekboard_client_real_destroyed (EekboardClient *self)
|
||||
{
|
||||
EekboardClientPrivate *priv = EEKBOARD_CLIENT_GET_PRIVATE(self);
|
||||
EekboardClientPrivate *priv = eekboard_client_get_instance_private (self);
|
||||
|
||||
// g_debug ("eekboard_client_real_destroyed");
|
||||
g_hash_table_remove_all (priv->context_hash);
|
||||
@ -63,7 +60,7 @@ static void
|
||||
eekboard_client_dispose (GObject *object)
|
||||
{
|
||||
EekboardClient *client = EEKBOARD_CLIENT(object);
|
||||
EekboardClientPrivate *priv = EEKBOARD_CLIENT_GET_PRIVATE(client);
|
||||
EekboardClientPrivate *priv = eekboard_client_get_instance_private (client);
|
||||
|
||||
if (priv->context_hash) {
|
||||
GHashTableIter iter;
|
||||
@ -86,9 +83,6 @@ eekboard_client_class_init (EekboardClientClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (gobject_class,
|
||||
sizeof (EekboardClientPrivate));
|
||||
|
||||
klass->destroyed = eekboard_client_real_destroyed;
|
||||
|
||||
gobject_class->dispose = eekboard_client_dispose;
|
||||
@ -115,8 +109,9 @@ eekboard_client_class_init (EekboardClientClass *klass)
|
||||
static void
|
||||
eekboard_client_init (EekboardClient *self)
|
||||
{
|
||||
self->priv = EEKBOARD_CLIENT_GET_PRIVATE(self);
|
||||
self->priv->context_hash =
|
||||
EekboardClientPrivate *priv = eekboard_client_get_instance_private (self);
|
||||
|
||||
priv->context_hash =
|
||||
g_hash_table_new_full (g_str_hash,
|
||||
g_str_equal,
|
||||
(GDestroyNotify)g_free,
|
||||
@ -189,7 +184,9 @@ on_context_destroyed (EekboardContext *context,
|
||||
gpointer user_data)
|
||||
{
|
||||
EekboardClient *client = user_data;
|
||||
g_hash_table_remove (client->priv->context_hash,
|
||||
EekboardClientPrivate *priv = eekboard_client_get_instance_private (client);
|
||||
|
||||
g_hash_table_remove (priv->context_hash,
|
||||
g_dbus_proxy_get_object_path (G_DBUS_PROXY(context)));
|
||||
}
|
||||
|
||||
@ -239,7 +236,9 @@ eekboard_client_create_context (EekboardClient *client,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_hash_table_insert (client->priv->context_hash,
|
||||
EekboardClientPrivate *priv = eekboard_client_get_instance_private (client);
|
||||
|
||||
g_hash_table_insert (priv->context_hash,
|
||||
g_strdup (object_path),
|
||||
g_object_ref (context));
|
||||
g_signal_connect (context, "destroyed",
|
||||
@ -284,9 +283,11 @@ eekboard_client_push_context (EekboardClient *client,
|
||||
g_return_if_fail (EEKBOARD_IS_CLIENT(client));
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
EekboardClientPrivate *priv = eekboard_client_get_instance_private (client);
|
||||
|
||||
object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(context));
|
||||
|
||||
context = g_hash_table_lookup (client->priv->context_hash,
|
||||
context = g_hash_table_lookup (priv->context_hash,
|
||||
object_path);
|
||||
if (!context)
|
||||
return;
|
||||
@ -394,8 +395,10 @@ eekboard_client_destroy_context (EekboardClient *client,
|
||||
g_return_if_fail (EEKBOARD_IS_CLIENT(client));
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
EekboardClientPrivate *priv = eekboard_client_get_instance_private (client);
|
||||
|
||||
object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(context));
|
||||
g_hash_table_remove (client->priv->context_hash, object_path);
|
||||
g_hash_table_remove (priv->context_hash, object_path);
|
||||
|
||||
send_destroy_context (client, context, cancellable);
|
||||
}
|
||||
|
||||
@ -26,22 +26,7 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define EEKBOARD_TYPE_CLIENT (eekboard_client_get_type())
|
||||
#define EEKBOARD_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_CLIENT, EekboardClient))
|
||||
#define EEKBOARD_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEKBOARD_TYPE_CLIENT, EekboardClientClass))
|
||||
#define EEKBOARD_IS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEKBOARD_TYPE_CLIENT))
|
||||
#define EEKBOARD_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEKBOARD_TYPE_CLIENT))
|
||||
#define EEKBOARD_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEKBOARD_TYPE_CLIENT, EekboardClientClass))
|
||||
|
||||
typedef struct _EekboardClient EekboardClient;
|
||||
typedef struct _EekboardClientClass EekboardClientClass;
|
||||
typedef struct _EekboardClientPrivate EekboardClientPrivate;
|
||||
|
||||
struct _EekboardClient {
|
||||
/*< private >*/
|
||||
GDBusProxy parent;
|
||||
|
||||
EekboardClientPrivate *priv;
|
||||
};
|
||||
G_DECLARE_DERIVABLE_TYPE (EekboardClient, eekboard_client, EEKBOARD, CLIENT, GDBusProxy)
|
||||
|
||||
struct _EekboardClientClass {
|
||||
/*< private >*/
|
||||
|
||||
@ -49,18 +49,15 @@ enum {
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (EekboardContext, eekboard_context, G_TYPE_DBUS_PROXY);
|
||||
|
||||
#define EEKBOARD_CONTEXT_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEKBOARD_TYPE_CONTEXT, EekboardContextPrivate))
|
||||
|
||||
struct _EekboardContextPrivate
|
||||
typedef struct _EekboardContextPrivate
|
||||
{
|
||||
gboolean visible;
|
||||
gboolean enabled;
|
||||
gboolean fullscreen;
|
||||
gint group;
|
||||
};
|
||||
} EekboardContextPrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (EekboardContext, eekboard_context, G_TYPE_DBUS_PROXY)
|
||||
|
||||
static void
|
||||
eekboard_context_real_g_signal (GDBusProxy *self,
|
||||
@ -69,6 +66,7 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
||||
GVariant *parameters)
|
||||
{
|
||||
EekboardContext *context = EEKBOARD_CONTEXT (self);
|
||||
EekboardContextPrivate *priv = eekboard_context_get_instance_private (context);
|
||||
|
||||
if (g_strcmp0 (signal_name, "Enabled") == 0) {
|
||||
g_signal_emit (context, signals[ENABLED], 0);
|
||||
@ -111,8 +109,8 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
||||
gboolean visible = FALSE;
|
||||
|
||||
g_variant_get (parameters, "(b)", &visible);
|
||||
if (visible != context->priv->visible) {
|
||||
context->priv->visible = visible;
|
||||
if (visible != priv->visible) {
|
||||
priv->visible = visible;
|
||||
g_object_notify (G_OBJECT(context), "visible");
|
||||
}
|
||||
return;
|
||||
@ -122,8 +120,8 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
||||
gint group = 0;
|
||||
|
||||
g_variant_get (parameters, "(i)", &group);
|
||||
if (group != context->priv->group) {
|
||||
context->priv->group = group;
|
||||
if (group != priv->group) {
|
||||
priv->group = group;
|
||||
/* g_object_notify (G_OBJECT(context), "group"); */
|
||||
}
|
||||
return;
|
||||
@ -135,13 +133,17 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
||||
static void
|
||||
eekboard_context_real_enabled (EekboardContext *self)
|
||||
{
|
||||
self->priv->enabled = TRUE;
|
||||
EekboardContextPrivate *priv = eekboard_context_get_instance_private (self);
|
||||
|
||||
priv->enabled = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
eekboard_context_real_disabled (EekboardContext *self)
|
||||
{
|
||||
self->priv->enabled = FALSE;
|
||||
EekboardContextPrivate *priv = eekboard_context_get_instance_private (self);
|
||||
|
||||
priv->enabled = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -164,9 +166,11 @@ eekboard_context_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
EekboardContext *context = EEKBOARD_CONTEXT(object);
|
||||
EekboardContextPrivate *priv = eekboard_context_get_instance_private (context);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_VISIBLE:
|
||||
g_value_set_boolean (value, context->priv->visible);
|
||||
g_value_set_boolean (value, priv->visible);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -181,9 +185,6 @@ eekboard_context_class_init (EekboardContextClass *klass)
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
g_type_class_add_private (gobject_class,
|
||||
sizeof (EekboardContextPrivate));
|
||||
|
||||
klass->enabled = eekboard_context_real_enabled;
|
||||
klass->disabled = eekboard_context_real_disabled;
|
||||
klass->destroyed = eekboard_context_real_destroyed;
|
||||
@ -288,7 +289,7 @@ eekboard_context_class_init (EekboardContextClass *klass)
|
||||
static void
|
||||
eekboard_context_init (EekboardContext *self)
|
||||
{
|
||||
self->priv = EEKBOARD_CONTEXT_GET_PRIVATE(self);
|
||||
/* void */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -485,7 +486,9 @@ eekboard_context_set_group (EekboardContext *context,
|
||||
{
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
if (context->priv->group != group) {
|
||||
EekboardContextPrivate *priv = eekboard_context_get_instance_private (context);
|
||||
|
||||
if (priv->group != group) {
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"SetGroup",
|
||||
g_variant_new ("(i)", group),
|
||||
@ -509,7 +512,10 @@ eekboard_context_get_group (EekboardContext *context,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
g_return_val_if_fail (EEKBOARD_IS_CONTEXT(context), 0);
|
||||
return context->priv->group;
|
||||
|
||||
EekboardContextPrivate *priv = eekboard_context_get_instance_private (context);
|
||||
|
||||
return priv->group;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -526,7 +532,9 @@ eekboard_context_show_keyboard (EekboardContext *context,
|
||||
{
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
if (context->priv->enabled) {
|
||||
EekboardContextPrivate *priv = eekboard_context_get_instance_private (context);
|
||||
|
||||
if (priv->enabled) {
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"ShowKeyboard",
|
||||
NULL,
|
||||
@ -551,7 +559,9 @@ eekboard_context_hide_keyboard (EekboardContext *context,
|
||||
{
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
if (context->priv->enabled) {
|
||||
EekboardContextPrivate *priv = eekboard_context_get_instance_private (context);
|
||||
|
||||
if (priv->enabled) {
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"HideKeyboard",
|
||||
NULL,
|
||||
@ -578,7 +588,9 @@ eekboard_context_press_keycode (EekboardContext *context,
|
||||
{
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
if (context->priv->enabled) {
|
||||
EekboardContextPrivate *priv = eekboard_context_get_instance_private (context);
|
||||
|
||||
if (priv->enabled) {
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"PressKeycode",
|
||||
g_variant_new ("(u)", keycode),
|
||||
@ -605,7 +617,9 @@ eekboard_context_release_keycode (EekboardContext *context,
|
||||
{
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
if (context->priv->enabled) {
|
||||
EekboardContextPrivate *priv = eekboard_context_get_instance_private (context);
|
||||
|
||||
if (priv->enabled) {
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"ReleaseKeycode",
|
||||
g_variant_new ("(u)", keycode),
|
||||
@ -627,7 +641,10 @@ gboolean
|
||||
eekboard_context_is_visible (EekboardContext *context)
|
||||
{
|
||||
g_return_val_if_fail (EEKBOARD_IS_CONTEXT(context), FALSE);
|
||||
return context->priv->enabled && context->priv->visible;
|
||||
|
||||
EekboardContextPrivate *priv = eekboard_context_get_instance_private (context);
|
||||
|
||||
return priv->enabled && priv->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -644,7 +661,10 @@ eekboard_context_set_enabled (EekboardContext *context,
|
||||
gboolean enabled)
|
||||
{
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
context->priv->enabled = enabled;
|
||||
|
||||
EekboardContextPrivate *priv = eekboard_context_get_instance_private (context);
|
||||
|
||||
priv->enabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -657,7 +677,10 @@ gboolean
|
||||
eekboard_context_is_enabled (EekboardContext *context)
|
||||
{
|
||||
g_return_val_if_fail (EEKBOARD_IS_CONTEXT(context), FALSE);
|
||||
return context->priv->enabled;
|
||||
|
||||
EekboardContextPrivate *priv = eekboard_context_get_instance_private (context);
|
||||
|
||||
return priv->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -674,7 +697,10 @@ eekboard_context_set_fullscreen (EekboardContext *context,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
if (context->priv->fullscreen != fullscreen) {
|
||||
|
||||
EekboardContextPrivate *priv = eekboard_context_get_instance_private (context);
|
||||
|
||||
if (priv->fullscreen != fullscreen) {
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"SetFullscreen",
|
||||
g_variant_new ("(b)", fullscreen),
|
||||
|
||||
@ -28,28 +28,7 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define EEKBOARD_TYPE_CONTEXT (eekboard_context_get_type())
|
||||
#define EEKBOARD_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_CONTEXT, EekboardContext))
|
||||
#define EEKBOARD_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEKBOARD_TYPE_CONTEXT, EekboardContextClass))
|
||||
#define EEKBOARD_IS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEKBOARD_TYPE_CONTEXT))
|
||||
#define EEKBOARD_IS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEKBOARD_TYPE_CONTEXT))
|
||||
#define EEKBOARD_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEKBOARD_TYPE_CONTEXT, EekboardContextClass))
|
||||
|
||||
typedef struct _EekboardContext EekboardContext;
|
||||
typedef struct _EekboardContextClass EekboardContextClass;
|
||||
typedef struct _EekboardContextPrivate EekboardContextPrivate;
|
||||
|
||||
/**
|
||||
* EekboardContext:
|
||||
*
|
||||
* The #EekboardContext structure contains only private data and
|
||||
* should only be accessed using the provided API.
|
||||
*/
|
||||
struct _EekboardContext {
|
||||
/*< private >*/
|
||||
GDBusProxy parent;
|
||||
|
||||
EekboardContextPrivate *priv;
|
||||
};
|
||||
G_DECLARE_DERIVABLE_TYPE (EekboardContext, eekboard_context, EEKBOARD, CONTEXT, GDBusProxy)
|
||||
|
||||
/**
|
||||
* EekboardContextClass:
|
||||
|
||||
@ -50,10 +50,8 @@ enum {
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
#define EEKBOARD_SERVICE_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEKBOARD_TYPE_SERVICE, EekboardServicePrivate))
|
||||
|
||||
struct _EekboardServicePrivate {
|
||||
typedef struct _EekboardServicePrivate
|
||||
{
|
||||
GDBusConnection *connection;
|
||||
SmPuriOSK0 *dbus_interface;
|
||||
GDBusNodeInfo *introspection_data;
|
||||
@ -61,9 +59,9 @@ struct _EekboardServicePrivate {
|
||||
char *object_path;
|
||||
|
||||
EekboardContextService *context; // unowned reference
|
||||
};
|
||||
} EekboardServicePrivate;
|
||||
|
||||
G_DEFINE_TYPE (EekboardService, eekboard_service, G_TYPE_OBJECT);
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (EekboardService, eekboard_service, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
eekboard_service_set_property (GObject *object,
|
||||
@ -72,19 +70,20 @@ eekboard_service_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
EekboardService *service = EEKBOARD_SERVICE(object);
|
||||
EekboardServicePrivate *priv = eekboard_service_get_instance_private (service);
|
||||
GDBusConnection *connection;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_OBJECT_PATH:
|
||||
if (service->priv->object_path)
|
||||
g_free (service->priv->object_path);
|
||||
service->priv->object_path = g_value_dup_string (value);
|
||||
if (priv->object_path)
|
||||
g_free (priv->object_path);
|
||||
priv->object_path = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_CONNECTION:
|
||||
connection = g_value_get_object (value);
|
||||
if (service->priv->connection)
|
||||
g_object_unref (service->priv->connection);
|
||||
service->priv->connection = g_object_ref (connection);
|
||||
if (priv->connection)
|
||||
g_object_unref (priv->connection);
|
||||
priv->connection = g_object_ref (connection);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -99,13 +98,14 @@ eekboard_service_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
EekboardService *service = EEKBOARD_SERVICE(object);
|
||||
EekboardServicePrivate *priv = eekboard_service_get_instance_private (service);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_OBJECT_PATH:
|
||||
g_value_set_string (value, service->priv->object_path);
|
||||
g_value_set_string (value, priv->object_path);
|
||||
break;
|
||||
case PROP_CONNECTION:
|
||||
g_value_set_object (value, service->priv->connection);
|
||||
g_value_set_object (value, priv->connection);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -117,20 +117,22 @@ static void
|
||||
eekboard_service_dispose (GObject *object)
|
||||
{
|
||||
EekboardService *service = EEKBOARD_SERVICE(object);
|
||||
if (service->priv->connection) {
|
||||
if (service->priv->registration_id > 0) {
|
||||
g_dbus_connection_unregister_object (service->priv->connection,
|
||||
service->priv->registration_id);
|
||||
service->priv->registration_id = 0;
|
||||
EekboardServicePrivate *priv = eekboard_service_get_instance_private (service);
|
||||
|
||||
if (priv->connection) {
|
||||
if (priv->registration_id > 0) {
|
||||
g_dbus_connection_unregister_object (priv->connection,
|
||||
priv->registration_id);
|
||||
priv->registration_id = 0;
|
||||
}
|
||||
|
||||
g_object_unref (service->priv->connection);
|
||||
service->priv->connection = NULL;
|
||||
g_object_unref (priv->connection);
|
||||
priv->connection = NULL;
|
||||
}
|
||||
|
||||
if (service->priv->introspection_data) {
|
||||
g_dbus_node_info_unref (service->priv->introspection_data);
|
||||
service->priv->introspection_data = NULL;
|
||||
if (priv->introspection_data) {
|
||||
g_dbus_node_info_unref (priv->introspection_data);
|
||||
priv->introspection_data = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (eekboard_service_parent_class)->dispose (object);
|
||||
@ -140,8 +142,9 @@ static void
|
||||
eekboard_service_finalize (GObject *object)
|
||||
{
|
||||
EekboardService *service = EEKBOARD_SERVICE(object);
|
||||
EekboardServicePrivate *priv = eekboard_service_get_instance_private (service);
|
||||
|
||||
g_free (service->priv->object_path);
|
||||
g_free (priv->object_path);
|
||||
|
||||
G_OBJECT_CLASS (eekboard_service_parent_class)->finalize (object);
|
||||
}
|
||||
@ -150,11 +153,13 @@ static gboolean
|
||||
handle_set_visible(SmPuriOSK0 *object, GDBusMethodInvocation *invocation,
|
||||
gboolean arg_visible, gpointer user_data) {
|
||||
EekboardService *service = user_data;
|
||||
if (service->priv->context) {
|
||||
EekboardServicePrivate *priv = eekboard_service_get_instance_private (service);
|
||||
|
||||
if (priv->context) {
|
||||
if (arg_visible) {
|
||||
eekboard_context_service_show_keyboard (service->priv->context);
|
||||
eekboard_context_service_show_keyboard (priv->context);
|
||||
} else {
|
||||
eekboard_context_service_hide_keyboard (service->priv->context);
|
||||
eekboard_context_service_hide_keyboard (priv->context);
|
||||
}
|
||||
}
|
||||
sm_puri_osk0_complete_set_visible(object, invocation);
|
||||
@ -165,18 +170,19 @@ static void
|
||||
eekboard_service_constructed (GObject *object)
|
||||
{
|
||||
EekboardService *service = EEKBOARD_SERVICE(object);
|
||||
EekboardServicePrivate *priv = eekboard_service_get_instance_private (service);
|
||||
|
||||
service->priv->dbus_interface = sm_puri_osk0_skeleton_new();
|
||||
sm_puri_osk0_set_visible(service->priv->dbus_interface, FALSE); // TODO: use actual value
|
||||
g_signal_connect(service->priv->dbus_interface, "handle-set-visible",
|
||||
priv->dbus_interface = sm_puri_osk0_skeleton_new();
|
||||
sm_puri_osk0_set_visible(priv->dbus_interface, FALSE); // TODO: use actual value
|
||||
g_signal_connect(priv->dbus_interface, "handle-set-visible",
|
||||
G_CALLBACK(handle_set_visible), service);
|
||||
|
||||
if (service->priv->connection && service->priv->object_path) {
|
||||
if (priv->connection && priv->object_path) {
|
||||
GError *error = NULL;
|
||||
|
||||
if (!g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(service->priv->dbus_interface),
|
||||
service->priv->connection,
|
||||
service->priv->object_path,
|
||||
if (!g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(priv->dbus_interface),
|
||||
priv->connection,
|
||||
priv->object_path,
|
||||
&error)) {
|
||||
g_warning("Error registering dbus object: %s\n", error->message);
|
||||
g_clear_error(&error);
|
||||
@ -190,9 +196,6 @@ eekboard_service_class_init (EekboardServiceClass *klass)
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
g_type_class_add_private (gobject_class,
|
||||
sizeof (EekboardServicePrivate));
|
||||
|
||||
klass->create_context = NULL;
|
||||
|
||||
gobject_class->constructed = eekboard_service_constructed;
|
||||
@ -250,8 +253,9 @@ eekboard_service_class_init (EekboardServiceClass *klass)
|
||||
static void
|
||||
eekboard_service_init (EekboardService *self)
|
||||
{
|
||||
self->priv = EEKBOARD_SERVICE_GET_PRIVATE(self);
|
||||
self->priv->context = NULL;
|
||||
EekboardServicePrivate *priv = eekboard_service_get_instance_private (self);
|
||||
|
||||
priv->context = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -271,7 +275,9 @@ eekboard_service_new (GDBusConnection *connection,
|
||||
|
||||
void
|
||||
eekboard_service_set_context(EekboardService *service,
|
||||
EekboardContextService *context)
|
||||
{
|
||||
EekboardServicePrivate *priv = eekboard_service_get_instance_private (service);
|
||||
|
||||
EekboardContextService *context) {
|
||||
service->priv->context = context;
|
||||
priv->context = context;
|
||||
}
|
||||
|
||||
@ -28,30 +28,7 @@ G_BEGIN_DECLS
|
||||
#define EEKBOARD_SERVICE_INTERFACE "sm.puri.OSK0"
|
||||
|
||||
#define EEKBOARD_TYPE_SERVICE (eekboard_service_get_type())
|
||||
#define EEKBOARD_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_SERVICE, EekboardService))
|
||||
#define EEKBOARD_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEKBOARD_TYPE_SERVICE, EekboardServiceClass))
|
||||
#define EEKBOARD_IS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEKBOARD_TYPE_SERVICE))
|
||||
#define EEKBOARD_IS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEKBOARD_TYPE_SERVICE))
|
||||
#define EEKBOARD_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEKBOARD_TYPE_SERVICE, EekboardServiceClass))
|
||||
|
||||
typedef struct _EekboardService EekboardService;
|
||||
typedef struct _EekboardServiceClass EekboardServiceClass;
|
||||
typedef struct _EekboardServicePrivate EekboardServicePrivate;
|
||||
|
||||
/**
|
||||
* EekboardService:
|
||||
*
|
||||
* Manages DBus interaction.
|
||||
*
|
||||
* The #EekboardService structure contains only private data and
|
||||
* should only be accessed using the provided API.
|
||||
*/
|
||||
struct _EekboardService {
|
||||
/*< private >*/
|
||||
GObject parent;
|
||||
|
||||
EekboardServicePrivate *priv;
|
||||
};
|
||||
G_DECLARE_DERIVABLE_TYPE (EekboardService, eekboard_service, EEKBOARD, SERVICE, GObject)
|
||||
|
||||
/**
|
||||
* EekboardServiceClass:
|
||||
|
||||
Reference in New Issue
Block a user