Skip to content

Commit

Permalink
keyboard: Make accountsservice optional
Browse files Browse the repository at this point in the history
The api needed for syncing input sources is an Ubuntu patch to
libaccountsservice, so disable sync when it's unavailable.
  • Loading branch information
mtwebster committed Jan 28, 2022
1 parent f4aefc2 commit 04443a8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
8 changes: 7 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ if dbussystemdir == ''
endif

# dependencies
accountsservice_dep = dependency('accountsservice')
cinnamon_desktop_required = '>= 4.8.0'
canberra = dependency('libcanberra-gtk3')
cinnamon_desktop = dependency('cinnamon-desktop', version: cinnamon_desktop_required)
Expand Down Expand Up @@ -116,6 +115,13 @@ csd_conf.set_quoted('LIBEXECDIR', join_paths(prefix, libexecdir))
csd_conf.set_quoted('SYSCONFDIR', sysconfdir)
csd_conf.set_quoted('LIBDIR', libdir)

accountsservice_dep = dependency('accountsservice', required: false)
if accountsservice_dep.found()
if cc.has_function('act_user_set_input_sources', dependencies: accountsservice_dep, prefix : '#include <act/act.h>')
csd_conf.set('CAN_SET_ACCOUNTSSERVICE_INPUT_SOURCES', 1)
endif
endif

if gudev.found()
cargs += '-DHAVE_GUDEV'
endif
Expand Down
10 changes: 10 additions & 0 deletions plugins/keyboard/csd-keyboard-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
#include <gdk/gdkx.h>
#include <gtk/gtk.h>

#ifdef CAN_SET_ACCOUNTSSERVICE_INPUT_SOURCES
#include <act/act.h>
#endif // CAN_SET_ACCOUNTSSERVICE_INPUT_SOURCES

#include "cinnamon-settings-profile.h"
#include "csd-keyboard-manager.h"
Expand Down Expand Up @@ -357,6 +359,7 @@ set_gtk_im_module (CsdKeyboardManager *manager,
g_free (current_module);
}

#ifdef CAN_SET_ACCOUNTSSERVICE_INPUT_SOURCES
static void
user_notify_is_loaded_cb (GObject *object,
GParamSpec *pspec,
Expand Down Expand Up @@ -417,15 +420,20 @@ manager_notify_is_loaded_cb (GObject *object,
user_notify_is_loaded_cb, user_data);
}
}
#endif // CAN_SET_ACCOUNTSSERVICE_INPUT_SOURCES


static void
update_gtk_im_module (CsdKeyboardManager *manager)
{
GSettings *interface_settings;
GVariant *sources;

#ifdef CAN_SET_ACCOUNTSSERVICE_INPUT_SOURCES
ActUserManager *user_manager;
gboolean user_manager_loaded;
#endif // CAN_SET_ACCOUNTSSERVICE_INPUT_SOURCES

/* Gtk+ uses the IM module advertised in XSETTINGS so, if we
* have IBus input sources, we want it to load that
* module. Otherwise we can use the default "simple" module
Expand All @@ -438,6 +446,7 @@ update_gtk_im_module (CsdKeyboardManager *manager)
g_object_unref (interface_settings);
g_variant_unref (sources);

#ifdef CAN_SET_ACCOUNTSSERVICE_INPUT_SOURCES
user_manager = act_user_manager_get_default ();
g_object_get (user_manager, "is-loaded", &user_manager_loaded, NULL);
if (user_manager_loaded)
Expand All @@ -449,6 +458,7 @@ update_gtk_im_module (CsdKeyboardManager *manager)
"notify::is-loaded",
G_CALLBACK (manager_notify_is_loaded_cb),
manager->input_sources_settings);
#endif // CAN_SET_ACCOUNTSSERVICE_INPUT_SOURCES
}

static void
Expand Down
5 changes: 4 additions & 1 deletion plugins/keyboard/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ keyboard_sources = [
]

keyboard_deps = [
accountsservice_dep,
common_dep,
csd_dep,
gtk,
libnotify,
x11
]

if accountsservice_dep.found()
keyboard_deps += accountsservice_dep
endif

executable(
'csd-keyboard',
keyboard_sources,
Expand Down

0 comments on commit 04443a8

Please sign in to comment.