[gtk/wip/chergert/spellcheck] use keymap to get defaults
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/spellcheck] use keymap to get defaults
- Date: Fri, 12 Mar 2021 04:03:08 +0000 (UTC)
commit 7e222c20126009bc308c1c4cf1b7da4a837349d0
Author: Christian Hergert <chergert redhat com>
Date: Thu Mar 11 20:03:00 2021 -0800
use keymap to get defaults
the idea here is that per-windowing backends can provide specific
languages supported such as xkb, etc
gdk/gdkkeys.c | 13 ++++++++++++-
gdk/gdkkeysprivate.h | 4 ++++
gtk/gtkspellchecker.h | 1 -
gtk/gtkspelllanguage.c | 12 +++++++++++-
4 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/gdk/gdkkeys.c b/gdk/gdkkeys.c
index 90f42c5472..94985f53de 100644
--- a/gdk/gdkkeys.c
+++ b/gdk/gdkkeys.c
@@ -587,7 +587,7 @@ gdk_keymap_lookup_key (GdkKeymap *keymap,
* (state & ~consumed & ALL_ACCELS_MASK) == GDK_CONTROL_MASK)
* // Control was pressed
* ]|
- *
+ *
* An older interpretation @consumed_modifiers was that it contained
* all modifiers that might affect the translation of the key;
* this allowed accelerators to be stored with irrelevant consumed
@@ -814,3 +814,14 @@ gdk_keyval_convert_case (guint symbol,
if (upper)
*upper = xupper;
}
+
+const char * const *
+gdk_keymap_get_languages (GdkKeymap *keymap)
+{
+ g_return_val_if_fail (GDK_IS_KEYMAP (keymap), NULL);
+
+ if (GDK_KEYMAP_GET_CLASS (keymap)->get_languages)
+ return GDK_KEYMAP_GET_CLASS (keymap)->get_languages (keymap);
+
+ return NULL;
+}
diff --git a/gdk/gdkkeysprivate.h b/gdk/gdkkeysprivate.h
index db05785678..f910d3258a 100644
--- a/gdk/gdkkeysprivate.h
+++ b/gdk/gdkkeysprivate.h
@@ -60,6 +60,7 @@ struct _GdkKeymapClass
int *level,
GdkModifierType *consumed_modifiers);
guint (* get_modifier_state) (GdkKeymap *keymap);
+ const char * const * (* get_languages) (GdkKeymap *keymap);
/* Signals */
@@ -121,6 +122,9 @@ void gdk_keymap_get_cached_entries_for_keyval (GdkKeymap *keymap,
GdkKeymapKey **keys,
guint *n_keys);
+const char * const *
+ gdk_keymap_get_languages (GdkKeymap *keymap);
+
G_END_DECLS
#endif
diff --git a/gtk/gtkspellchecker.h b/gtk/gtkspellchecker.h
index 356b29b414..122ff2c1b0 100644
--- a/gtk/gtkspellchecker.h
+++ b/gtk/gtkspellchecker.h
@@ -64,7 +64,6 @@ void gtk_spell_checker_set_correction (GtkSpellChecker *sel
const char *correction,
gssize correction_length);
-
G_END_DECLS
#endif /* __GTK_SPELL_CHECKER_H__ */
diff --git a/gtk/gtkspelllanguage.c b/gtk/gtkspelllanguage.c
index 350886ec24..432252021e 100644
--- a/gtk/gtkspelllanguage.c
+++ b/gtk/gtkspelllanguage.c
@@ -19,6 +19,9 @@
#include "config.h"
+#include <gdk/gdkdisplayprivate.h>
+#include <gdk/gdkkeysprivate.h>
+
#include "gtkspelllanguageprivate.h"
struct _GtkSpellLanguage
@@ -142,7 +145,14 @@ _gtk_spell_language_get_defaults (void)
if (defaults == NULL)
{
- /* TODO: guess defaults */
+ GdkDisplay *display = gdk_display_get_default ();
+ GdkKeymap *keymap = gdk_display_get_keymap (display);
+ const char * const *languages = gdk_keymap_get_languages (keymap);
+
+ if (languages == NULL || languages[0] == NULL)
+ languages = g_get_language_names ();
+
+ defaults = g_strdupv ((char **)languages);
}
return (const char * const *)defaults;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]