[gtk/wip/matthiasc/shortcut: 98/102] Only create a class shortcut controller if we have shortcuts
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/shortcut: 98/102] Only create a class shortcut controller if we have shortcuts
- Date: Tue, 17 Mar 2020 05:03:59 +0000 (UTC)
commit dc1e78d4d061d3b1bb2d27e06daba55f97d73439
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 15 18:24:52 2020 -0400
Only create a class shortcut controller if we have shortcuts
No point in creating objects that just hold empty lists.
gtk/gtkwidget.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 7826d1a534..41e0815286 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -2467,9 +2467,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);
+ }
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]