forked from AuroraMiddleware/gtk
widget: Only create a controller if we have shortcuts
No point in creating objects that just hold empty lists.
This commit is contained in:
parent
3cd4eb0310
commit
34987c0b5c
@ -2459,9 +2459,12 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
|
||||
if (layout_manager_type != G_TYPE_INVALID)
|
||||
gtk_widget_set_layout_manager (widget, g_object_new (layout_manager_type, NULL));
|
||||
|
||||
controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (GTK_WIDGET_CLASS (g_class)->priv->shortcuts));
|
||||
gtk_event_controller_set_name (controller, "gtk-widget-class-shortcuts");
|
||||
gtk_widget_add_controller (widget, controller);
|
||||
if (g_list_model_get_n_items (G_LIST_MODEL (GTK_WIDGET_CLASS (g_class)->priv->shortcuts)) > 0)
|
||||
{
|
||||
controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (GTK_WIDGET_CLASS (g_class)->priv->shortcuts));
|
||||
gtk_event_controller_set_name (controller, "gtk-widget-class-shortcuts");
|
||||
gtk_widget_add_controller (widget, controller);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user