forked from AuroraMiddleware/gtk
shortcutcontroller: Add a way to update accels
This will be used to make accel changes propagate.
This commit is contained in:
parent
d5054f9b99
commit
3254a3feab
@ -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);
|
||||
|
@ -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__ */
|
||||
|
Loading…
Reference in New Issue
Block a user