[gtk/matthiasc/for-master: 11/14] shortcutcontroller: Add a way to update accels
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 11/14] shortcutcontroller: Add a way to update accels
- Date: Thu, 17 Jun 2021 13:00:30 +0000 (UTC)
commit 3254a3feab8a770a4235df47c66ea76fb7b1e58d
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jun 17 08:31:13 2021 -0400
shortcutcontroller: Add a way to update accels
This will be used to make accel changes propagate.
gtk/gtkshortcutcontroller.c | 22 +++++++++++++++++-----
gtk/gtkshortcutcontrollerprivate.h | 2 ++
2 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkshortcutcontroller.c b/gtk/gtkshortcutcontroller.c
index 75d4829fe0..01bc60208c 100644
--- a/gtk/gtkshortcutcontroller.c
+++ b/gtk/gtkshortcutcontroller.c
@@ -480,16 +480,17 @@ update_accel (GtkShortcut *shortcut,
g_free (accel);
}
-static void
-gtk_shortcut_controller_set_widget (GtkEventController *controller,
- GtkWidget *widget)
+void
+gtk_shortcut_controller_update_accels (GtkShortcutController *self)
{
- GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (controller);
GListModel *shortcuts = self->shortcuts;
+ GtkWidget *widget;
GtkActionMuxer *muxer;
guint i, p;
- GTK_EVENT_CONTROLLER_CLASS (gtk_shortcut_controller_parent_class)->set_widget (controller, widget);
+ widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (self));
+ if (!widget)
+ return;
muxer = _gtk_widget_get_action_muxer (widget, TRUE);
for (i = 0, p = g_list_model_get_n_items (shortcuts); i < p; i++)
@@ -499,6 +500,17 @@ gtk_shortcut_controller_set_widget (GtkEventController *controller,
update_accel (shortcut, muxer, TRUE);
g_object_unref (shortcut);
}
+}
+
+static void
+gtk_shortcut_controller_set_widget (GtkEventController *controller,
+ GtkWidget *widget)
+{
+ GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (controller);
+
+ GTK_EVENT_CONTROLLER_CLASS (gtk_shortcut_controller_parent_class)->set_widget (controller, widget);
+
+ gtk_shortcut_controller_update_accels (self);
if (_gtk_widget_get_root (widget))
gtk_shortcut_controller_root (self);
diff --git a/gtk/gtkshortcutcontrollerprivate.h b/gtk/gtkshortcutcontrollerprivate.h
index db1b52cecc..af622910d7 100644
--- a/gtk/gtkshortcutcontrollerprivate.h
+++ b/gtk/gtkshortcutcontrollerprivate.h
@@ -25,4 +25,6 @@
void gtk_shortcut_controller_root (GtkShortcutController *controller);
void gtk_shortcut_controller_unroot (GtkShortcutController *controller);
+void gtk_shortcut_controller_update_accels (GtkShortcutController *self);
+
#endif /* __GTK_SHORTCUT_CONTROLLER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]