summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Davis <bluesabre@users.noreply.github.com>2022-07-26 05:47:40 -0400
committerGitHub <noreply@github.com>2022-07-26 05:47:40 -0400
commite49dad963dd6035a34acd6b391f14a27fe73ddb5 (patch)
tree1256dd45d1e923d70bb098abd16fb929351eea4b
parent288e8834f15493afb81d51b51835b7e419b10b9f (diff)
parentf4de54246a677ccc77a9f1efc871beaebe1bec40 (diff)
downloadlightdm-gtk-greeter-git-e49dad963dd6035a34acd6b391f14a27fe73ddb5.tar.gz
Merge pull request #121 from kbucheli/configurable_keyboard_layouts
support configuring the keyboard layouts of the ~layout indicator
-rw-r--r--data/lightdm-gtk-greeter.conf3
-rw-r--r--src/greeterconfiguration.h1
-rw-r--r--src/lightdm-gtk-greeter.c44
3 files changed, 47 insertions, 1 deletions
diff --git a/data/lightdm-gtk-greeter.conf b/data/lightdm-gtk-greeter.conf
index 4b1637c..858b40a 100644
--- a/data/lightdm-gtk-greeter.conf
+++ b/data/lightdm-gtk-greeter.conf
@@ -32,7 +32,8 @@
# Panel:
# panel-position = top|bottom ("top" by default)
# clock-format = strftime-format string, e.g. %H:%M
-# indicators = semi-colon ";" separated list of allowed indicator modules. Built-in indicators include "~a11y", "~language", "~session", "~power", "~clock", "~host", "~spacer". Unity indicators can be represented by short name (e.g. "sound", "power"), service file name, or absolute path
+# indicators = semi-colon ";" separated list of allowed indicator modules. Built-in indicators include "~a11y", "~language", "~session", "~power", "~clock", "~host", "~spacer", "~layout". Unity indicators can be represented by short name (e.g. "sound", "power"), service file name, or absolute path
+# keyboard-layouts = semi-colon ";" separated list keyboard layouts to be listed by the "~layout" indicator (empty by default which provides all available layouts)
#
# Accessibility:
# a11y-states = states of accessibility features: "name" - save state on exit, "-name" - disabled at start (default value for unlisted), "+name" - enabled at start. Allowed names: contrast, font, keyboard, reader.
diff --git a/src/greeterconfiguration.h b/src/greeterconfiguration.h
index e45f889..24028c1 100644
--- a/src/greeterconfiguration.h
+++ b/src/greeterconfiguration.h
@@ -33,6 +33,7 @@
#define CONFIG_KEY_ROUND_USER_IMAGE "round-user-image"
#define CONFIG_KEY_HIGHLIGHT_LOGGED_USER "highlight-logged-user"
#define CONFIG_KEY_KEYBOARD "keyboard"
+#define CONFIG_KEY_KEYBOARD_LAYOUTS "keyboard-layouts"
#define CONFIG_KEY_READER "reader"
#define CONFIG_KEY_CLOCK_FORMAT "clock-format"
#define CONFIG_KEY_ACTIVE_MONITOR "active-monitor"
diff --git a/src/lightdm-gtk-greeter.c b/src/lightdm-gtk-greeter.c
index 555aa96..88cc44b 100644
--- a/src/lightdm-gtk-greeter.c
+++ b/src/lightdm-gtk-greeter.c
@@ -1764,6 +1764,13 @@ layout_selected_cb (GtkCheckMenuItem *menuitem, gpointer user_data)
static void
update_layouts_menu (void)
{
+ gchar **layouts;
+ gsize num_layouts = 0;
+
+ layouts = config_get_string_list (NULL, CONFIG_KEY_KEYBOARD_LAYOUTS, NULL);
+ if (layouts)
+ num_layouts = g_strv_length (layouts);
+
#ifdef HAVE_LIBXKLAVIER
XklConfigRegistry *registry;
XklConfigRec *config;
@@ -1792,6 +1799,23 @@ update_layouts_menu (void)
const gchar *variant = config->variants[i] ? config->variants[i] : "";
gchar *label = strlen (variant) > 0 ? g_strdup_printf ("%s_%s", layout, variant) : g_strdup (layout);
+ /* is the keyboard layout part of keyboard-layouts? */
+ if (num_layouts) {
+ gboolean layout_in_config = FALSE;
+ for (gint j = 0; j < num_layouts; ++j)
+ {
+ if (g_strcmp0 (layouts[j], label) == 0)
+ {
+ layout_in_config = TRUE;
+ break;
+ }
+ }
+ if (!layout_in_config) {
+ g_free(label);
+ continue;
+ }
+ }
+
GtkWidget *menuitem = gtk_radio_menu_item_new (menu_group);
menu_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menuitem));
@@ -1828,6 +1852,23 @@ update_layouts_menu (void)
for (item = lightdm_get_layouts (); item; item = g_list_next (item))
{
LightDMLayout *layout = item->data;
+
+ /* is the keyboard layout part of keyboard-layouts? */
+ if (num_layouts) {
+ gboolean layout_in_config = FALSE;
+ for (gint j = 0; j < num_layouts; ++j)
+ {
+ if (g_strcmp0 (layouts[j], lightdm_layout_get_name (layout)) == 0)
+ {
+ layout_in_config = TRUE;
+ break;
+ }
+ }
+ if (!layout_in_config) {
+ continue;
+ }
+ }
+
GtkWidget *menuitem = gtk_radio_menu_item_new (menu_group);
menu_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menuitem));
@@ -1842,6 +1883,9 @@ update_layouts_menu (void)
gtk_widget_show (GTK_WIDGET (menuitem));
}
#endif
+
+ if (layouts)
+ g_strfreev (layouts);
}
static void