[gtk/wip/matthiasc/shortcut: 98/106] Move shortcut manager initialization code
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/shortcut: 98/106] Move shortcut manager initialization code
- Date: Wed, 18 Mar 2020 00:07:29 +0000 (UTC)
commit 06657cc039780fa7975975029633a00ebb16012f
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 15 17:38:56 2020 -0400
Move shortcut manager initialization code
It is just too ugly to use quarks across multiple
source files, so add a private helper function that
attaches the controllers.
gtk/gtkshortcutmanager.c | 19 +++++++++++++++++++
gtk/gtkshortcutmanagerprivate.h | 12 ++++++++++++
gtk/gtkwidget.c | 16 ++--------------
3 files changed, 33 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkshortcutmanager.c b/gtk/gtkshortcutmanager.c
index db97448b67..4a8680e104 100644
--- a/gtk/gtkshortcutmanager.c
+++ b/gtk/gtkshortcutmanager.c
@@ -20,6 +20,7 @@
#include "config.h"
#include "gtkshortcutmanager.h"
+#include "gtkshortcutmanagerprivate.h"
#include "gtkconcatmodelprivate.h"
/**
@@ -33,6 +34,24 @@
G_DEFINE_INTERFACE (GtkShortcutManager, gtk_shortcut_manager, G_TYPE_OBJECT)
+void
+gtk_shortcut_manager_create_controllers (GtkWidget *widget)
+{
+ GtkConcatModel *model;
+ GtkEventController *controller;
+
+ model = gtk_concat_model_new (GTK_TYPE_SHORTCUT);
+ g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-bubble", model, g_object_unref);
+ controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
+ gtk_widget_add_controller (widget, controller);
+
+ model = gtk_concat_model_new (GTK_TYPE_SHORTCUT);
+ g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-capture", model, g_object_unref);
+ controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
+ gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
+ gtk_widget_add_controller (widget, controller);
+}
+
static GtkConcatModel *
gtk_shortcut_manager_get_model (GtkShortcutManager *self,
GtkPropagationPhase phase)
diff --git a/gtk/gtkshortcutmanagerprivate.h b/gtk/gtkshortcutmanagerprivate.h
new file mode 100644
index 0000000000..72424dba23
--- /dev/null
+++ b/gtk/gtkshortcutmanagerprivate.h
@@ -0,0 +1,12 @@
+#ifndef __GTK_SHORTCUT_MANAGER_PRIVATE_H__
+#define __GTK_SHORTCUT_MANAGER__PRIVATE_H__
+
+#include "gtkshortcutmanager.h"
+
+G_BEGIN_DECLS
+
+void gtk_shortcut_manager_create_controllers (GtkWidget *widget);
+
+G_END_DECLS
+
+#endif /* __GTK_SHORTCUT_MANAGER_PRIVATE_H__ */
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 8e82a35872..121d3f5e62 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -61,6 +61,7 @@
#include "gtkshortcut.h"
#include "gtkshortcutcontrollerprivate.h"
#include "gtkshortcutmanager.h"
+#include "gtkshortcutmanagerprivate.h"
#include "gtkshortcuttrigger.h"
#include "gtksizegroup-private.h"
#include "gtksnapshotprivate.h"
@@ -2460,20 +2461,7 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
priv->root = (GtkRoot *) widget;
if (g_type_is_a (G_TYPE_FROM_CLASS (g_class), GTK_TYPE_SHORTCUT_MANAGER))
- {
- GtkConcatModel *model;
-
- model = gtk_concat_model_new (GTK_TYPE_SHORTCUT);
- g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-bubble", model, g_object_unref);
- controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
- gtk_widget_add_controller (widget, controller);
-
- model = gtk_concat_model_new (GTK_TYPE_SHORTCUT);
- g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-capture", model, g_object_unref);
- controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
- gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
- gtk_widget_add_controller (widget, controller);
- }
+ gtk_shortcut_manager_create_controllers (widget);
layout_manager_type = gtk_widget_class_get_layout_manager_type (g_class);
if (layout_manager_type != G_TYPE_INVALID)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]