[gnome-flashback] common: add GfKeybindingType
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] common: add GfKeybindingType
- Date: Sat, 30 Nov 2019 22:59:22 +0000 (UTC)
commit 5e9b47e354d1a0a36c34dce073acc4be6133ca69
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sat Nov 30 23:41:05 2019 +0200
common: add GfKeybindingType
And add it as parameter to modifiers-accelerator-activated signal.
https://gitlab.gnome.org/GNOME/gnome-flashback/issues/24
gnome-flashback/libcommon/Makefile.am | 27 ++++++++++++++
.../libcommon/gf-common-enum-types.c.in | 41 ++++++++++++++++++++++
.../libcommon/gf-common-enum-types.h.in | 21 +++++++++++
gnome-flashback/libcommon/gf-keybindings.c | 11 +++---
gnome-flashback/libcommon/gf-keybindings.h | 8 ++++-
.../libinput-sources/gf-input-source-manager.c | 37 +++++++++++--------
6 files changed, 125 insertions(+), 20 deletions(-)
---
diff --git a/gnome-flashback/libcommon/Makefile.am b/gnome-flashback/libcommon/Makefile.am
index a75cd5a..16a41ea 100644
--- a/gnome-flashback/libcommon/Makefile.am
+++ b/gnome-flashback/libcommon/Makefile.am
@@ -24,6 +24,7 @@ libcommon_la_SOURCES = \
gf-keybindings.h \
gf-popup-window.c \
gf-popup-window.h \
+ $(BUILT_SOURCES) \
$(NULL)
libcommon_la_LDFLAGS = \
@@ -35,4 +36,30 @@ libcommon_la_LIBADD = \
$(COMMON_LIBS) \
$(NULL)
+ENUM_TYPES = \
+ $(srcdir)/gf-keybindings.h \
+ $(NULL)
+
+gf-common-enum-types.c: gf-common-enum-types.c.in gf-common-enum-types.h $(ENUM_TYPES)
+ $(AM_V_GEN) $(GLIB_MKENUMS) --template $(srcdir)/gf-common-enum-types.c.in $(ENUM_TYPES) > \
+ gf-common-enum-types.c.tmp && mv gf-common-enum-types.c.tmp gf-common-enum-types.c
+
+gf-common-enum-types.h: gf-common-enum-types.h.in $(ENUM_TYPES)
+ $(AM_V_GEN) $(GLIB_MKENUMS) --template $(srcdir)/gf-common-enum-types.h.in $(ENUM_TYPES) > \
+ gf-common-enum-types.h.tmp && mv gf-common-enum-types.h.tmp gf-common-enum-types.h
+
+BUILT_SOURCES = \
+ gf-common-enum-types.c \
+ gf-common-enum-types.h \
+ $(NULL)
+
+EXTRA_DIST = \
+ gf-common-enum-types.c.in \
+ gf-common-enum-types.h.in \
+ $(NULL)
+
+CLEANFILES = \
+ $(BUILT_SOURCES) \
+ $(NULL)
+
-include $(top_srcdir)/git.mk
diff --git a/gnome-flashback/libcommon/gf-common-enum-types.c.in
b/gnome-flashback/libcommon/gf-common-enum-types.c.in
new file mode 100644
index 0000000..f680bd2
--- /dev/null
+++ b/gnome-flashback/libcommon/gf-common-enum-types.c.in
@@ -0,0 +1,41 @@
+/*** BEGIN file-header ***/
+#include "config.h"
+#include "gf-common-enum-types.h"
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+#include "@filename@"
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+
+GType
+@enum_name@_get_type (void)
+{
+ static volatile gsize g_enum_type_id;
+ static const G@Type@Value values[] =
+ {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+ { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+ { 0, NULL, NULL }
+ };
+
+ if (g_once_init_enter (&g_enum_type_id))
+ {
+ const gchar *string;
+ GType id;
+
+ string = g_intern_static_string ("@EnumName@");
+ id = g_@type@_register_static (string, values);
+
+ g_once_init_leave (&g_enum_type_id, id);
+ }
+
+ return g_enum_type_id;
+}
+/*** END value-tail ***/
diff --git a/gnome-flashback/libcommon/gf-common-enum-types.h.in
b/gnome-flashback/libcommon/gf-common-enum-types.h.in
new file mode 100644
index 0000000..8a5cecf
--- /dev/null
+++ b/gnome-flashback/libcommon/gf-common-enum-types.h.in
@@ -0,0 +1,21 @@
+/*** BEGIN file-header ***/
+#ifndef GF_COMMON_ENUM_TYPES_H
+#define GF_COMMON_ENUM_TYPES_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
+
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif
+/*** END file-tail ***/
diff --git a/gnome-flashback/libcommon/gf-keybindings.c b/gnome-flashback/libcommon/gf-keybindings.c
index af9e479..f743a9b 100644
--- a/gnome-flashback/libcommon/gf-keybindings.c
+++ b/gnome-flashback/libcommon/gf-keybindings.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 - 2015 Alberts Muktupāvels
+ * Copyright (C) 2014 - 2019 Alberts Muktupāvels
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,13 +16,14 @@
*/
#include "config.h"
+#include "gf-keybindings.h"
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
-#include "gf-keybindings.h"
+#include "gf-common-enum-types.h"
#define DESKTOP_INPUT_SOURCES_SCHEMA "org.gnome.desktop.input-sources"
@@ -580,7 +581,9 @@ process_iso_next_group (GfKeybindings *keybindings,
g_signal_emit (keybindings,
signals[SIGNAL_MODIFIERS_ACCELERATOR_ACTIVATED],
- 0, &freeze);
+ 0,
+ GF_KEYBINDING_ISO_NEXT_GROUP,
+ &freeze);
if (!freeze)
XUngrabKeyboard (keybindings->xdisplay, event->xkey.time);
@@ -839,7 +842,7 @@ gf_keybindings_class_init (GfKeybindingsClass *keybindings_class)
g_signal_new ("modifiers-accelerator-activated",
G_TYPE_FROM_CLASS (keybindings_class), G_SIGNAL_RUN_LAST,
0, g_signal_accumulator_first_wins, NULL, NULL,
- G_TYPE_BOOLEAN, 0);
+ G_TYPE_BOOLEAN, 1, GF_TYPE_KEYBINDING_TYPE);
properties[PROP_ISO_NEXT_GROUP] =
g_param_spec_boolean ("iso-next-group", "iso-next-group", "iso-next-group",
diff --git a/gnome-flashback/libcommon/gf-keybindings.h b/gnome-flashback/libcommon/gf-keybindings.h
index d8bb035..0d31b7d 100644
--- a/gnome-flashback/libcommon/gf-keybindings.h
+++ b/gnome-flashback/libcommon/gf-keybindings.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 - 2015 Alberts Muktupāvels
+ * Copyright (C) 2014 - 2019 Alberts Muktupāvels
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,9 +19,15 @@
#define GF_KEYBINDINGS_H
#include <glib-object.h>
+#include <gtk/gtk.h>
G_BEGIN_DECLS
+typedef enum
+{
+ GF_KEYBINDING_ISO_NEXT_GROUP
+} GfKeybindingType;
+
#define GF_TYPE_KEYBINDINGS gf_keybindings_get_type ()
G_DECLARE_FINAL_TYPE (GfKeybindings, gf_keybindings, GF, KEYBINDINGS, GObject)
diff --git a/gnome-flashback/libinput-sources/gf-input-source-manager.c
b/gnome-flashback/libinput-sources/gf-input-source-manager.c
index 89e8293..d78b17f 100644
--- a/gnome-flashback/libinput-sources/gf-input-source-manager.c
+++ b/gnome-flashback/libinput-sources/gf-input-source-manager.c
@@ -511,14 +511,13 @@ fade_finished_cb (GfInputSourcePopup *popup,
}
static gboolean
-modifiers_accelerator_activated_cb (GfKeybindings *keybindings,
- gpointer user_data)
+modifiers_accelerator_activated_cb (GfKeybindings *keybindings,
+ GfKeybindingType keybinding_type,
+ gpointer user_data)
{
GfInputSourceManager *manager;
guint size;
- GfInputSource *source;
GList *keys;
- guint next_index;
manager = GF_INPUT_SOURCE_MANAGER (user_data);
@@ -529,22 +528,30 @@ modifiers_accelerator_activated_cb (GfKeybindings *keybindings,
return TRUE;
}
- source = manager->current_source;
- if (source == NULL)
- source = (GfInputSource *) g_hash_table_lookup (manager->input_sources,
- GUINT_TO_POINTER (0));
-
keys = g_hash_table_get_keys (manager->input_sources);
keys = g_list_sort (keys, compare_indexes);
- next_index = gf_input_source_get_index (source ) + 1;
- if (next_index > GPOINTER_TO_UINT (g_list_nth_data (keys, size - 1)))
- next_index = 0;
+ if (keybinding_type == GF_KEYBINDING_ISO_NEXT_GROUP)
+ {
+ GfInputSource *current_source;
+ GfInputSource *next_source;
+ guint next_index;
+
+ current_source = manager->current_source;
+ if (current_source == NULL)
+ current_source = g_hash_table_lookup (manager->input_sources,
+ GUINT_TO_POINTER (0));
- source = (GfInputSource *) g_hash_table_lookup (manager->input_sources,
- GUINT_TO_POINTER (next_index));
+ next_index = gf_input_source_get_index (current_source ) + 1;
+ if (next_index > GPOINTER_TO_UINT (g_list_nth_data (keys, size - 1)))
+ next_index = 0;
+
+ next_source = g_hash_table_lookup (manager->input_sources,
+ GUINT_TO_POINTER (next_index));
+
+ gf_input_source_activate (next_source, TRUE);
+ }
- gf_input_source_activate (source, TRUE);
g_list_free (keys);
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]