[gnome-flashback] common: rename FlashbackKeyBindings to GfKeybindings
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] common: rename FlashbackKeyBindings to GfKeybindings
- Date: Sat, 19 Sep 2015 21:32:58 +0000 (UTC)
commit 368dcd7c76cb5224ada826aec4f6304a676d8ad8
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Sep 20 00:31:53 2015 +0300
common: rename FlashbackKeyBindings to GfKeybindings
gnome-flashback/libcommon/gf-keybindings.c | 525 ++++++++++++++++-----------
gnome-flashback/libcommon/gf-keybindings.h | 40 +--
gnome-flashback/libshell/flashback-shell.c | 22 +-
3 files changed, 331 insertions(+), 256 deletions(-)
---
diff --git a/gnome-flashback/libcommon/gf-keybindings.c b/gnome-flashback/libcommon/gf-keybindings.c
index cd44449..b759672 100644
--- a/gnome-flashback/libcommon/gf-keybindings.c
+++ b/gnome-flashback/libcommon/gf-keybindings.c
@@ -19,83 +19,45 @@
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
-
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include "gf-keybindings.h"
-struct _FlashbackKeyBindingsPrivate {
- GHashTable *table;
+struct _GfKeybindings
+{
+ GObject parent;
- Display *xdisplay;
- Window xwindow;
+ GHashTable *table;
- guint ignored_modifier_mask;
-};
+ Display *xdisplay;
+ Window xwindow;
-enum {
- BINDING_ACTIVATED,
- LAST_SIGNAL
+ guint meta_mask;
+ guint super_mask;
+ guint hyper_mask;
+ guint ignore_mask;
};
-static guint signals[LAST_SIGNAL] = { 0 };
-
-typedef struct {
- const gchar *name;
- guint action;
- guint keyval;
- guint keycode;
- guint modifiers;
-} KeyBinding;
-
-static guint MetaMask = 0;
-static guint SuperMask = 0;
-static guint HyperMask = 0;
-static guint NumLockMask = 0;
-static guint ScrollLockMask = 0;
-
-G_DEFINE_TYPE_WITH_PRIVATE (FlashbackKeyBindings, flashback_key_bindings, G_TYPE_OBJECT)
-
-static gboolean
-devirtualize_modifiers (GdkModifierType modifiers,
- GdkModifierType gdk_mask,
- unsigned int real_mask,
- unsigned int *mask)
+typedef struct
{
- if (modifiers & gdk_mask)
- {
- if (real_mask == 0)
- return FALSE;
+ const gchar *name;
+ guint action;
+ guint keyval;
+ guint keycode;
+ guint modifiers;
+} Keybinding;
+
+enum
+{
+ SIGNAL_ACCELERATOR_ACTIVATED,
- *mask |= real_mask;
- }
+ LAST_SIGNAL
+};
- return TRUE;
-}
+static guint signals[LAST_SIGNAL] = { 0 };
-static gboolean
-get_real_modifiers (GdkModifierType modifiers,
- guint *mask)
-{
- gboolean devirtualized;
-
- devirtualized = TRUE;
- *mask = 0;
-
- devirtualized &= devirtualize_modifiers (modifiers, GDK_SHIFT_MASK, ShiftMask, mask);
- devirtualized &= devirtualize_modifiers (modifiers, GDK_CONTROL_MASK, ControlMask, mask);
- devirtualized &= devirtualize_modifiers (modifiers, GDK_MOD1_MASK, Mod1Mask, mask);
- devirtualized &= devirtualize_modifiers (modifiers, GDK_META_MASK, MetaMask, mask);
- devirtualized &= devirtualize_modifiers (modifiers, GDK_HYPER_MASK, HyperMask, mask);
- devirtualized &= devirtualize_modifiers (modifiers, GDK_SUPER_MASK, SuperMask, mask);
- devirtualized &= devirtualize_modifiers (modifiers, GDK_MOD2_MASK, Mod2Mask, mask);
- devirtualized &= devirtualize_modifiers (modifiers, GDK_MOD3_MASK, Mod3Mask, mask);
- devirtualized &= devirtualize_modifiers (modifiers, GDK_MOD4_MASK, Mod4Mask, mask);
- devirtualized &= devirtualize_modifiers (modifiers, GDK_MOD5_MASK, Mod5Mask, mask);
-
- return devirtualized;
-}
+G_DEFINE_TYPE (GfKeybindings, gf_keybindings, G_TYPE_OBJECT)
static GVariant *
build_parameters (guint device_id,
@@ -106,9 +68,13 @@ build_parameters (guint device_id,
GVariant *parameters;
builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
- g_variant_builder_add (builder, "{sv}", "device-id", g_variant_new_uint32 (device_id));
- g_variant_builder_add (builder, "{sv}", "timestamp", g_variant_new_uint32 (timestamp));
- g_variant_builder_add (builder, "{sv}", "action-mode", g_variant_new_uint32 (action_mode));
+
+ g_variant_builder_add (builder, "{sv}", "device-id",
+ g_variant_new_uint32 (device_id));
+ g_variant_builder_add (builder, "{sv}", "timestamp",
+ g_variant_new_uint32 (timestamp));
+ g_variant_builder_add (builder, "{sv}", "action-mode",
+ g_variant_new_uint32 (action_mode));
parameters = g_variant_new ("a{sv}", builder);
g_variant_builder_unref (builder);
@@ -121,219 +87,350 @@ filter_func (GdkXEvent *xevent,
GdkEvent *event,
gpointer user_data)
{
- FlashbackKeyBindings *bindings;
+ GfKeybindings *keybindings;
XEvent *ev;
+ GList *values;
+ GList *l;
+
+ keybindings = GF_KEYBINDINGS (user_data);
+ ev = (XEvent *) xevent;
- bindings = FLASHBACK_KEY_BINDINGS (user_data);
- ev = xevent;
+ XAllowEvents (keybindings->xdisplay, AsyncKeyboard, ev->xkey.time);
- XAllowEvents (bindings->priv->xdisplay, AsyncKeyboard, ev->xkey.time);
+ if (ev->type != KeyPress)
+ return GDK_FILTER_CONTINUE;
- if (ev->type == KeyPress)
+ values = g_hash_table_get_values (keybindings->table);
+
+ for (l = values; l; l = l->next)
{
- GList *values, *l;
+ Keybinding *keybinding;
+ guint state;
- values = g_hash_table_get_values (bindings->priv->table);
+ keybinding = (Keybinding *) l->data;
+ state = ev->xkey.state & 0xff & ~(keybindings->ignore_mask);
- for (l = values; l; l = l->next)
+ if (keybinding->keycode == ev->xkey.keycode &&
+ keybinding->modifiers == state)
{
- KeyBinding *binding = l->data;
-
- if (binding->keycode == ev->xkey.keycode &&
- binding->modifiers == (ev->xkey.state & 0xff & ~(bindings->priv->ignored_modifier_mask)))
- {
- GVariant *parameters;
+ GVariant *parameters;
- parameters = build_parameters (0, 0, 0);
+ parameters = build_parameters (0, 0, 0);
- XUngrabKeyboard (bindings->priv->xdisplay, ev->xkey.time);
- g_signal_emit (bindings, signals[BINDING_ACTIVATED], 0,
- binding->action, parameters);
+ XUngrabKeyboard (keybindings->xdisplay, ev->xkey.time);
+ g_signal_emit (keybindings, signals[SIGNAL_ACCELERATOR_ACTIVATED],
+ 0, keybinding->action, parameters);
- break;
- }
+ break;
}
-
- g_list_free (values);
}
+ g_list_free (values);
+
return GDK_FILTER_CONTINUE;
}
static void
-flashback_key_bindings_change_keygrab (FlashbackKeyBindings *bindings,
- gboolean grab,
- gint keyval,
- guint keycode,
- guint modifiers)
+change_keygrab (GfKeybindings *keybindings,
+ gboolean grab,
+ gint keyval,
+ guint keycode,
+ guint modifiers)
{
- guint ignored_mask;
-
- gdk_error_trap_push ();
-
- ignored_mask = 0;
- while (ignored_mask <= bindings->priv->ignored_modifier_mask) {
- if (ignored_mask & ~(bindings->priv->ignored_modifier_mask)) {
- ++ignored_mask;
- continue;
- }
-
- if (grab)
- XGrabKey (bindings->priv->xdisplay, keycode,
- modifiers | ignored_mask,
- bindings->priv->xwindow,
- True,
- GrabModeAsync, GrabModeSync);
- else
- XUngrabKey (bindings->priv->xdisplay, keycode,
- modifiers | ignored_mask,
- bindings->priv->xwindow);
-
- ++ignored_mask;
- }
-
- gdk_error_trap_pop_ignored ();
+ guint ignore_mask;
+ gint error_code;
+
+ ignore_mask = 0;
+ while (ignore_mask <= keybindings->ignore_mask)
+ {
+ if (ignore_mask & ~(keybindings->ignore_mask))
+ {
+ ++ignore_mask;
+ continue;
+ }
+
+ gdk_error_trap_push ();
+
+ if (grab)
+ {
+ XGrabKey (keybindings->xdisplay, keycode, modifiers | ignore_mask,
+ keybindings->xwindow, True, GrabModeAsync, GrabModeSync);
+ }
+ else
+ {
+ XUngrabKey (keybindings->xdisplay, keycode, modifiers | ignore_mask,
+ keybindings->xwindow);
+ }
+
+ error_code = gdk_error_trap_pop ();
+ if (error_code != 0)
+ {
+ g_debug ("Failed to grab/ ungrab key. Error code - %d", error_code);
+ }
+
+ ++ignore_mask;
+ }
}
-static void
-flashback_key_bindings_finalize (GObject *object)
+static guint
+get_next_action (void)
{
- FlashbackKeyBindings *bindings;
+ static guint action;
- bindings = FLASHBACK_KEY_BINDINGS (object);
+ return ++action;
+}
- gdk_window_remove_filter (NULL, filter_func, bindings);
+static gboolean
+devirtualize_modifiers (GdkModifierType modifiers,
+ GdkModifierType gdk_mask,
+ unsigned int real_mask,
+ unsigned int *mask)
+{
+ if (modifiers & gdk_mask)
+ {
+ if (real_mask == 0)
+ return FALSE;
- if (bindings->priv->table) {
- g_hash_table_destroy (bindings->priv->table);
- bindings->priv->table = NULL;
- }
+ *mask |= real_mask;
+ }
- G_OBJECT_CLASS (flashback_key_bindings_parent_class)->finalize (object);
+ return TRUE;
+}
+
+static gboolean
+get_real_modifiers (GfKeybindings *keybindings,
+ GdkModifierType modifiers,
+ guint *mask)
+{
+ gboolean devirtualized;
+
+ devirtualized = TRUE;
+ *mask = 0;
+
+ devirtualized &= devirtualize_modifiers (modifiers, GDK_SHIFT_MASK,
+ ShiftMask, mask);
+
+ devirtualized &= devirtualize_modifiers (modifiers, GDK_CONTROL_MASK,
+ ControlMask, mask);
+
+ devirtualized &= devirtualize_modifiers (modifiers, GDK_MOD1_MASK,
+ Mod1Mask, mask);
+
+ devirtualized &= devirtualize_modifiers (modifiers, GDK_META_MASK,
+ keybindings->meta_mask, mask);
+
+ devirtualized &= devirtualize_modifiers (modifiers, GDK_HYPER_MASK,
+ keybindings->hyper_mask, mask);
+
+ devirtualized &= devirtualize_modifiers (modifiers, GDK_SUPER_MASK,
+ keybindings->super_mask, mask);
+
+ devirtualized &= devirtualize_modifiers (modifiers, GDK_MOD2_MASK,
+ Mod2Mask, mask);
+
+ devirtualized &= devirtualize_modifiers (modifiers, GDK_MOD3_MASK,
+ Mod3Mask, mask);
+
+ devirtualized &= devirtualize_modifiers (modifiers, GDK_MOD4_MASK,
+ Mod4Mask, mask);
+
+ devirtualized &= devirtualize_modifiers (modifiers, GDK_MOD5_MASK,
+ Mod5Mask, mask);
+
+ return devirtualized;
}
static void
-flashback_key_bindings_init (FlashbackKeyBindings *bindings)
+gf_keybindings_dispose (GObject *object)
{
- FlashbackKeyBindingsPrivate *priv;
+ GfKeybindings *keybindings;
- bindings->priv = flashback_key_bindings_get_instance_private (bindings);
- priv = bindings->priv;
+ keybindings = GF_KEYBINDINGS (object);
- priv->xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
- priv->xwindow = XDefaultRootWindow (priv->xdisplay);
- priv->table = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+ if (keybindings->table != NULL)
+ {
+ g_hash_table_destroy (keybindings->table);
+ keybindings->table = NULL;
+ }
- MetaMask = XkbKeysymToModifiers (priv->xdisplay, XK_Meta_L);
- if (MetaMask == 0)
- MetaMask = XkbKeysymToModifiers (priv->xdisplay, XK_Meta_R);
+ G_OBJECT_CLASS (gf_keybindings_parent_class)->dispose (object);
+}
- SuperMask = XkbKeysymToModifiers (priv->xdisplay, XK_Super_L);
- if (SuperMask == 0)
- SuperMask = XkbKeysymToModifiers (priv->xdisplay, XK_Super_R);
+static void
+gf_keybindings_finalize (GObject *object)
+{
+ GfKeybindings *keybindings;
- HyperMask = XkbKeysymToModifiers (priv->xdisplay, XK_Hyper_L);
- if (HyperMask == 0)
- HyperMask = XkbKeysymToModifiers (priv->xdisplay, XK_Hyper_R);
+ keybindings = GF_KEYBINDINGS (object);
- NumLockMask = XkbKeysymToModifiers (priv->xdisplay, XK_Num_Lock);
- ScrollLockMask = XkbKeysymToModifiers (priv->xdisplay, XK_Scroll_Lock);
+ gdk_window_remove_filter (NULL, filter_func, keybindings);
- priv->ignored_modifier_mask = NumLockMask | ScrollLockMask | LockMask;
+ G_OBJECT_CLASS (gf_keybindings_parent_class)->finalize (object);
+}
- gdk_window_add_filter (NULL, filter_func, bindings);
+static void
+gf_keybindings_class_init (GfKeybindingsClass *keybindings_class)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (keybindings_class);
+
+ object_class->dispose = gf_keybindings_dispose;
+ object_class->finalize = gf_keybindings_finalize;
+
+ /**
+ * GfKeybindings::accelerator-activated:
+ * @keybindings: the object on which the signal is emitted
+ * @action: keybinding action from gf_keybindings_grab
+ * @parameters: keybinding parameters - a{sv}
+ *
+ * The ::accelerator-activated signal is emitted each time when keybinding
+ * is activated by user.
+ */
+ signals[SIGNAL_ACCELERATOR_ACTIVATED] =
+ g_signal_new ("accelerator-activated",
+ G_TYPE_FROM_CLASS (keybindings_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL, G_TYPE_NONE,
+ 2, G_TYPE_UINT, G_TYPE_VARIANT);
}
static void
-flashback_key_bindings_class_init (FlashbackKeyBindingsClass *class)
+gf_keybindings_init (GfKeybindings *keybindings)
{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
-
- object_class->finalize = flashback_key_bindings_finalize;
-
- signals[BINDING_ACTIVATED] =
- g_signal_new ("binding-activated",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (FlashbackKeyBindingsClass, binding_activated),
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 2,
- G_TYPE_UINT,
- G_TYPE_VARIANT);
+ GdkDisplay *display;
+ guint meta_mask;
+ guint super_mask;
+ guint hyper_mask;
+ guint num_lock_mask;
+ guint scroll_lock_mask;
+
+ keybindings->table = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+
+ display = gdk_display_get_default ();
+ keybindings->xdisplay = gdk_x11_display_get_xdisplay (display);
+ keybindings->xwindow = XDefaultRootWindow (keybindings->xdisplay);
+
+ meta_mask = XkbKeysymToModifiers (keybindings->xdisplay, XK_Meta_L);
+ if (meta_mask == 0)
+ meta_mask = XkbKeysymToModifiers (keybindings->xdisplay, XK_Meta_R);
+
+ super_mask = XkbKeysymToModifiers (keybindings->xdisplay, XK_Super_L);
+ if (super_mask == 0)
+ super_mask = XkbKeysymToModifiers (keybindings->xdisplay, XK_Super_R);
+
+ hyper_mask = XkbKeysymToModifiers (keybindings->xdisplay, XK_Hyper_L);
+ if (hyper_mask == 0)
+ hyper_mask = XkbKeysymToModifiers (keybindings->xdisplay, XK_Hyper_R);
+
+ num_lock_mask = XkbKeysymToModifiers (keybindings->xdisplay, XK_Num_Lock);
+ scroll_lock_mask = XkbKeysymToModifiers (keybindings->xdisplay,
+ XK_Scroll_Lock);
+
+ keybindings->meta_mask = meta_mask;
+ keybindings->super_mask = super_mask;
+ keybindings->hyper_mask = hyper_mask;
+ keybindings->ignore_mask = num_lock_mask | scroll_lock_mask | LockMask;
+
+ gdk_window_add_filter (NULL, filter_func, keybindings);
}
-FlashbackKeyBindings *
-flashback_key_bindings_new (void)
+/**
+ * gf_keybindings_new:
+ *
+ * Creates a new #GfKeybindings.
+ *
+ * Returns: (transfer full): a newly created #GfKeybindings.
+ */
+GfKeybindings *
+gf_keybindings_new (void)
{
- return g_object_new (FLASHBACK_TYPE_KEY_BINDINGS, NULL);
+ return g_object_new (GF_TYPE_KEYBINDINGS, NULL);
}
+/**
+ * gf_keybindings_grab:
+ * @keybindings: a #GfKeybindings
+ * @accelerator: a string representing an accelerator
+ *
+ * Add keybinding.
+ *
+ * Returns: the keybinding action if the keybinding was added successfully,
+ * otherwise 0.
+ */
guint
-flashback_key_bindings_grab (FlashbackKeyBindings *bindings,
- const gchar *accelerator)
+gf_keybindings_grab (GfKeybindings *keybindings,
+ const gchar *accelerator)
{
- KeyBinding *binding;
- guint keyval;
- GdkModifierType modifiers;
- guint real_modifiers;
- guint keycode;
- static guint next_action = 0;
+ guint keyval;
+ GdkModifierType modifiers;
+ guint keycode;
+ guint real_modifiers;
+ guint action;
+ gpointer paction;
+ Keybinding *keybinding;
- gtk_accelerator_parse (accelerator, &keyval, &modifiers);
- if (!gtk_accelerator_valid (keyval, modifiers)) {
- return 0;
- }
+ gtk_accelerator_parse (accelerator, &keyval, &modifiers);
- if (keyval == 0)
- return 0;
+ if (!gtk_accelerator_valid (keyval, modifiers))
+ return 0;
- keycode = XKeysymToKeycode (bindings->priv->xdisplay, keyval);
- if (keycode == 0)
- return 0;
+ if (keyval == 0)
+ return 0;
- if (!get_real_modifiers (modifiers, &real_modifiers))
- return 0;
+ keycode = XKeysymToKeycode (keybindings->xdisplay, keyval);
- flashback_key_bindings_change_keygrab (bindings,
- TRUE,
- keyval,
- keycode,
- real_modifiers);
+ if (keycode == 0)
+ return 0;
- binding = g_new0 (KeyBinding, 1);
+ if (!get_real_modifiers (keybindings, modifiers, &real_modifiers))
+ return 0;
- binding->name = accelerator;
- binding->action = ++next_action;
- binding->keyval = keyval;
- binding->keycode = keycode;
- binding->modifiers = real_modifiers;
+ action = get_next_action();
+ paction = GUINT_TO_POINTER (action);
+ keybinding = g_new0 (Keybinding, 1);
- g_hash_table_insert (bindings->priv->table, GUINT_TO_POINTER (binding->action), binding);
+ keybinding->name = accelerator;
+ keybinding->action = action;
+ keybinding->keyval = keyval;
+ keybinding->keycode = keycode;
+ keybinding->modifiers = real_modifiers;
- return binding->action;
+ change_keygrab (keybindings, TRUE, keyval, keycode, real_modifiers);
+
+ g_hash_table_insert (keybindings->table, paction, keybinding);
+
+ return action;
}
+/**
+ * gf_keybindings_ungrab:
+ * @keybindings: a #GfKeybindings
+ * @action: a keybinding action
+ *
+ * Remove keybinding.
+ *
+ * Returns: %TRUE if the keybinding was removed successfully
+ */
gboolean
-flashback_key_bindings_ungrab (FlashbackKeyBindings *bindings,
- guint action)
+gf_keybindings_ungrab (GfKeybindings *keybindings,
+ guint action)
{
- KeyBinding *binding;
+ gpointer paction;
+ gpointer pkeybinding;
+ Keybinding *keybinding;
- binding = (KeyBinding *) g_hash_table_lookup (bindings->priv->table,
- GUINT_TO_POINTER (action));
+ paction = GUINT_TO_POINTER (action);
+ pkeybinding = g_hash_table_lookup (keybindings->table, paction);
+ keybinding = (Keybinding *) pkeybinding;
- if (binding == NULL)
- return FALSE;
+ if (keybinding == NULL)
+ return FALSE;
- flashback_key_bindings_change_keygrab (bindings,
- FALSE,
- binding->keyval,
- binding->keycode,
- binding->modifiers);
+ change_keygrab (keybindings, FALSE, keybinding->keyval,
+ keybinding->keycode, keybinding->modifiers);
- g_hash_table_remove (bindings->priv->table,
- GUINT_TO_POINTER (action));
+ g_hash_table_remove (keybindings->table, paction);
- return TRUE;
+ return TRUE;
}
diff --git a/gnome-flashback/libcommon/gf-keybindings.h b/gnome-flashback/libcommon/gf-keybindings.h
index 959245d..23ce7be 100644
--- a/gnome-flashback/libcommon/gf-keybindings.h
+++ b/gnome-flashback/libcommon/gf-keybindings.h
@@ -15,45 +15,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef FLASHBACK_KEY_BINDINGS_H
-#define FLASHBACK_KEY_BINDINGS_H
+#ifndef GF_KEYBINDINGS_H
+#define GF_KEYBINDINGS_H
#include <glib-object.h>
G_BEGIN_DECLS
-#define FLASHBACK_TYPE_KEY_BINDINGS (flashback_key_bindings_get_type ())
-#define FLASHBACK_KEY_BINDINGS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), FLASHBACK_TYPE_KEY_BINDINGS,
FlashbackKeyBindings))
-#define FLASHBACK_KEY_BINDINGS_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), FLASHBACK_TYPE_KEY_BINDINGS,
FlashbackKeyBindingsClass))
-#define FLASHBACK_IS_KEY_BINDINGS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), FLASHBACK_TYPE_KEY_BINDINGS))
-#define FLASHBACK_IS_KEY_BINDINGS_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), FLASHBACK_TYPE_KEY_BINDINGS))
-#define FLASHBACK_KEY_BINDINGS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), FLASHBACK_TYPE_KEY_BINDINGS,
FlashbackKeyBindingsClass))
+#define GF_TYPE_KEYBINDINGS gf_keybindings_get_type ()
+G_DECLARE_FINAL_TYPE (GfKeybindings, gf_keybindings, GF, KEYBINDINGS, GObject)
-typedef struct _FlashbackKeyBindings FlashbackKeyBindings;
-typedef struct _FlashbackKeyBindingsClass FlashbackKeyBindingsClass;
-typedef struct _FlashbackKeyBindingsPrivate FlashbackKeyBindingsPrivate;
+GfKeybindings *gf_keybindings_new (void);
-struct _FlashbackKeyBindings {
- GObject parent;
- FlashbackKeyBindingsPrivate *priv;
-};
+guint gf_keybindings_grab (GfKeybindings *keybindings,
+ const gchar *accelerator);
-struct _FlashbackKeyBindingsClass {
- GObjectClass parent_class;
-
- void (*binding_activated) (FlashbackKeyBindings *bindings,
- guint action,
- GVariant *parameters);
-};
-
-GType flashback_key_bindings_get_type (void);
-
-FlashbackKeyBindings *flashback_key_bindings_new (void);
-
-guint flashback_key_bindings_grab (FlashbackKeyBindings *bindings,
- const gchar *accelerator);
-gboolean flashback_key_bindings_ungrab (FlashbackKeyBindings *bindings,
- guint action);
+gboolean gf_keybindings_ungrab (GfKeybindings *keybindings,
+ guint action);
G_END_DECLS
diff --git a/gnome-flashback/libshell/flashback-shell.c b/gnome-flashback/libshell/flashback-shell.c
index bde0119..e633a59 100644
--- a/gnome-flashback/libshell/flashback-shell.c
+++ b/gnome-flashback/libshell/flashback-shell.c
@@ -41,7 +41,7 @@ struct _FlashbackShell
GDBusInterfaceSkeleton *iface;
/* key-grabber */
- FlashbackKeyBindings *bindings;
+ GfKeybindings *keybindings;
GHashTable *grabbed_accelerators;
GHashTable *grabbers;
@@ -56,10 +56,10 @@ struct _FlashbackShell
G_DEFINE_TYPE (FlashbackShell, flashback_shell, G_TYPE_OBJECT)
static void
-binding_activated (FlashbackKeyBindings *bindings,
- guint action,
- GVariant *parameters,
- gpointer user_data)
+accelerator_activated (GfKeybindings *keybindings,
+ guint action,
+ GVariant *parameters,
+ gpointer user_data)
{
FlashbackShell *shell;
FlashbackDBusShell *dbus_shell;
@@ -74,14 +74,14 @@ static gint
real_grab (FlashbackShell *shell,
const gchar *accelerator)
{
- return flashback_key_bindings_grab (shell->bindings, accelerator);
+ return gf_keybindings_grab (shell->keybindings, accelerator);
}
static gboolean
real_ungrab (FlashbackShell *shell,
gint action)
{
- return flashback_key_bindings_ungrab (shell->bindings, action);
+ return gf_keybindings_ungrab (shell->keybindings, action);
}
static void
@@ -418,7 +418,7 @@ flashback_shell_finalize (GObject *object)
shell->grabbers = NULL;
}
- g_clear_object (&shell->bindings);
+ g_clear_object (&shell->keybindings);
g_clear_object (&shell->labeler);
g_clear_object (&shell->osd);
@@ -441,9 +441,9 @@ flashback_shell_init (FlashbackShell *shell)
shell->grabbed_accelerators = g_hash_table_new_full (NULL, NULL, NULL, g_free);
shell->grabbers = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- shell->bindings = flashback_key_bindings_new ();
- g_signal_connect (shell->bindings, "binding-activated",
- G_CALLBACK (binding_activated), shell);
+ shell->keybindings = gf_keybindings_new ();
+ g_signal_connect (shell->keybindings, "accelerator-activated",
+ G_CALLBACK (accelerator_activated), shell);
shell->labeler = flashback_monitor_labeler_new ();
shell->osd = flashback_osd_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]