[libdazzle] shortcuts: fix capture/bubble activation for default context
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] shortcuts: fix capture/bubble activation for default context
- Date: Thu, 20 Jul 2017 00:29:08 +0000 (UTC)
commit 779c1d736571fb64cbbbf5afdb164969489abf0d
Author: Christian Hergert <chergert redhat com>
Date: Wed Jul 19 17:28:06 2017 -0700
shortcuts: fix capture/bubble activation for default context
If we are not a global keybinding, we need to activate in the
proper capture/bubble as we work down/up the hierarchy. If we
don't attach to the default context, we won't locate the
keybinding when processing the context. This fixes that.
src/shortcuts/dzl-shortcut-controller.c | 6 ++++++
src/shortcuts/dzl-shortcut-private.h | 4 ++++
src/shortcuts/dzl-shortcut-theme.c | 21 +++++++++++++++++++++
3 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/src/shortcuts/dzl-shortcut-controller.c b/src/shortcuts/dzl-shortcut-controller.c
index 392efeb..8b2f554 100644
--- a/src/shortcuts/dzl-shortcut-controller.c
+++ b/src/shortcuts/dzl-shortcut-controller.c
@@ -1087,6 +1087,8 @@ dzl_shortcut_controller_add_command (DzlShortcutController *self,
if (chord != NULL)
{
+ DzlShortcutContext *context;
+
/* Add the chord to our chord table for lookups */
if (priv->commands_table == NULL)
priv->commands_table = dzl_shortcut_chord_table_new ();
@@ -1096,6 +1098,10 @@ dzl_shortcut_controller_add_command (DzlShortcutController *self,
manager = dzl_shortcut_controller_get_manager (self);
theme = _dzl_shortcut_manager_get_internal_theme (manager);
dzl_shortcut_theme_set_chord_for_command (theme, command_id, chord, phase);
+
+ /* Hook things up into the default context */
+ context = _dzl_shortcut_theme_find_default_context_with_phase (theme, priv->widget, phase);
+ dzl_shortcut_context_add_command (context, default_accel, command_id);
}
else
g_warning ("\"%s\" is not a valid accelerator chord", default_accel);
diff --git a/src/shortcuts/dzl-shortcut-private.h b/src/shortcuts/dzl-shortcut-private.h
index a599977..5d58c72 100644
--- a/src/shortcuts/dzl-shortcut-private.h
+++ b/src/shortcuts/dzl-shortcut-private.h
@@ -118,6 +118,10 @@ GtkTreeModel *_dzl_shortcut_theme_create_model (DzlShortcut
GHashTable *_dzl_shortcut_theme_get_contexts (DzlShortcutTheme *self);
DzlShortcutContext *_dzl_shortcut_theme_try_find_context_by_name (DzlShortcutTheme *self,
const gchar *name);
+DzlShortcutContext *_dzl_shortcut_theme_find_default_context_with_phase
+ (DzlShortcutTheme *self,
+ GtkWidget *widget,
+ DzlShortcutPhase phase);
void _dzl_shortcut_theme_set_manager (DzlShortcutTheme *self,
DzlShortcutManager *manager);
void _dzl_shortcut_theme_set_name (DzlShortcutTheme *self,
diff --git a/src/shortcuts/dzl-shortcut-theme.c b/src/shortcuts/dzl-shortcut-theme.c
index c962bcd..740e23d 100644
--- a/src/shortcuts/dzl-shortcut-theme.c
+++ b/src/shortcuts/dzl-shortcut-theme.c
@@ -317,6 +317,27 @@ dzl_shortcut_theme_find_default_context (DzlShortcutTheme *self,
return dzl_shortcut_theme_find_default_context_by_type (self, G_OBJECT_TYPE (widget));
}
+DzlShortcutContext *
+_dzl_shortcut_theme_find_default_context_with_phase (DzlShortcutTheme *self,
+ GtkWidget *widget,
+ DzlShortcutPhase phase)
+{
+ g_autofree gchar *free_me = NULL;
+ const gchar *name;
+
+ g_return_val_if_fail (DZL_IS_SHORTCUT_THEME (self), NULL);
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+ name = G_OBJECT_TYPE_NAME (widget);
+
+ if ((phase & DZL_SHORTCUT_PHASE_BUBBLE) != 0)
+ name = free_me = g_strdup_printf ("%s:bubble", name);
+ else if ((phase & DZL_SHORTCUT_PHASE_CAPTURE) != 0)
+ name = free_me = g_strdup_printf ("%s:capture", name);
+
+ return dzl_shortcut_theme_find_context_by_name (self, name);
+}
+
void
dzl_shortcut_theme_add_context (DzlShortcutTheme *self,
DzlShortcutContext *context)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]