GTK4 Migration Patterns
GtkAccelGroup
GtkAccelGroup is deprecated in GTK4.
- •Replacement: Use
GtkShortcutController. - •Setup:
- •Create a
GtkShortcutController. - •Set scope to
GTK_SHORTCUT_SCOPE_MANAGED(for window/dialog scope). - •Add it to the widget with
gtk_widget_add_controller.
- •Create a
- •Callbacks:
- •Replace
GtkAccelGroupActivatecallbacks:void func(GtkAccelGroup*, GObject*, guint, GdkModifierType, gpointer) - •With
GtkShortcutFunccallbacks:gboolean func(GtkWidget*, GVariant*, gpointer)
- •Replace
- •Mapping:
- •Use
gtk_application_get_accels_for_actionto get accelerator strings. - •Parse them with
gtk_shortcut_trigger_parse_string. - •Bind them to actions using
gtk_callback_action_new.
- •Use