Merge branch 'cleanups' into 'master'
C-side Cleanups See merge request Librem5/squeekboard!300
This commit is contained in:
@ -25,8 +25,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "eekboard/eekboard-service.h"
|
||||
#include "eek/eek.h"
|
||||
#include "eekboard/eekboard-context-service.h"
|
||||
#include "dbus.h"
|
||||
#include "imservice.h"
|
||||
#include "outputs.h"
|
||||
#include "server-context-service.h"
|
||||
@ -38,7 +39,9 @@
|
||||
/// Global application state
|
||||
struct squeekboard {
|
||||
struct squeek_wayland wayland;
|
||||
EekboardContextService *context;
|
||||
DBusHandler *dbus_handler;
|
||||
EekboardContextService *settings_context;
|
||||
ServerContextService *ui_context;
|
||||
struct imservice *imservice;
|
||||
};
|
||||
|
||||
@ -72,25 +75,6 @@ on_name_lost (GDBusConnection *connection,
|
||||
exit (1);
|
||||
}
|
||||
|
||||
static void
|
||||
on_destroyed (EekboardService *service,
|
||||
gpointer user_data)
|
||||
{
|
||||
(void)service;
|
||||
GMainLoop *loop = user_data;
|
||||
|
||||
g_main_loop_quit (loop);
|
||||
}
|
||||
|
||||
static EekboardContextService *create_context() {
|
||||
EekboardContextService *context = server_context_service_new ();
|
||||
g_object_set_data_full (G_OBJECT(context),
|
||||
"owner", g_strdup ("sender"),
|
||||
(GDestroyNotify)g_free);
|
||||
eekboard_context_service_enable (context);
|
||||
return context;
|
||||
}
|
||||
|
||||
// Wayland
|
||||
|
||||
static void
|
||||
@ -211,7 +195,7 @@ main (int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
instance.context = create_context();
|
||||
instance.settings_context = eekboard_context_service_new();
|
||||
|
||||
// set up dbus
|
||||
|
||||
@ -259,17 +243,16 @@ main (int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
|
||||
EekboardService *service = eekboard_service_new (connection, EEKBOARD_SERVICE_PATH);
|
||||
DBusHandler *service = dbus_handler_new(connection, DBUS_SERVICE_PATH);
|
||||
|
||||
if (service == NULL) {
|
||||
g_printerr ("Can't create dbus server\n");
|
||||
exit (1);
|
||||
} else {
|
||||
eekboard_service_set_context(service, instance.context);
|
||||
}
|
||||
instance.dbus_handler = service;
|
||||
|
||||
guint owner_id = g_bus_own_name_on_connection (connection,
|
||||
EEKBOARD_SERVICE_INTERFACE,
|
||||
DBUS_SERVICE_INTERFACE,
|
||||
G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||
on_name_acquired,
|
||||
on_name_lost,
|
||||
@ -282,9 +265,9 @@ main (int argc, char **argv)
|
||||
|
||||
struct imservice *imservice = NULL;
|
||||
if (instance.wayland.input_method_manager) {
|
||||
imservice = get_imservice(instance.context,
|
||||
instance.wayland.input_method_manager,
|
||||
instance.wayland.seat);
|
||||
imservice = get_imservice(instance.wayland.input_method_manager,
|
||||
instance.wayland.seat,
|
||||
instance.settings_context);
|
||||
if (imservice) {
|
||||
instance.imservice = imservice;
|
||||
} else {
|
||||
@ -292,12 +275,23 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
ServerContextService *ui_context = server_context_service_new(instance.settings_context);
|
||||
if (!ui_context) {
|
||||
g_error("Could not initialize GUI");
|
||||
exit(1);
|
||||
}
|
||||
instance.ui_context = ui_context;
|
||||
if (instance.imservice) {
|
||||
imservice_set_ui(instance.imservice, instance.ui_context);
|
||||
}
|
||||
if (instance.dbus_handler) {
|
||||
dbus_handler_set_ui_context(instance.dbus_handler, instance.ui_context);
|
||||
}
|
||||
|
||||
session_register();
|
||||
|
||||
GMainLoop *loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
g_signal_connect (service, "destroyed", G_CALLBACK(on_destroyed), loop);
|
||||
|
||||
g_main_loop_run (loop);
|
||||
|
||||
g_bus_unown_name (owner_id);
|
||||
|
||||
Reference in New Issue
Block a user