[gtk+/wip/matthiasc/kill-key-events2: 43/48] about dialog: Stop using ::key-press-event
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/matthiasc/kill-key-events2: 43/48] about dialog: Stop using ::key-press-event
- Date: Thu, 8 Feb 2018 02:36:57 +0000 (UTC)
commit 103459b54d01f0f5957ba7d35b70312242d7b7cc
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Feb 7 19:17:11 2018 -0500
about dialog: Stop using ::key-press-event
Use a key event controller instead.
gtk/gtkaboutdialog.c | 29 ++++++++++++++++++++---------
gtk/ui/gtkaboutdialog.ui | 2 --
2 files changed, 20 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c
index e3fdb5d..3e42f89 100644
--- a/gtk/gtkaboutdialog.c
+++ b/gtk/gtkaboutdialog.c
@@ -60,6 +60,7 @@
#include "gtkintl.h"
#include "gtkdialogprivate.h"
#include "gtkeventcontrollermotion.h"
+#include "gtkeventcontrollerkey.h"
#include "gtkgesturemultipress.h"
@@ -188,6 +189,8 @@ struct _GtkAboutDialogPrivate
GtkGesture *system_press;
GtkEventController *license_motion;
GtkEventController *system_motion;
+ GtkEventController *license_key;
+ GtkEventController *system_key;
GtkLicense license_type;
@@ -244,8 +247,10 @@ static gboolean gtk_about_dialog_activate_link (GtkAboutDialog
const gchar *uri);
static gboolean emit_activate_link (GtkAboutDialog *about,
const gchar *uri);
-static gboolean text_view_key_press_event (GtkWidget *text_view,
- GdkEventKey *event,
+static gboolean text_view_key_pressed (GtkEventController *controller,
+ guint keyval,
+ guint keycode,
+ GdkModifierType state,
GtkAboutDialog *about);
static void text_view_released (GtkGestureMultiPress *press,
int n,
@@ -609,7 +614,6 @@ gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkAboutDialog, system_view);
gtk_widget_class_bind_template_callback (widget_class, emit_activate_link);
- gtk_widget_class_bind_template_callback (widget_class, text_view_key_press_event);
gtk_widget_class_bind_template_callback (widget_class, stack_visible_child_notify);
}
@@ -781,6 +785,10 @@ gtk_about_dialog_init (GtkAboutDialog *about)
g_signal_connect (priv->license_motion, "motion", G_CALLBACK (text_view_motion), about);
priv->system_motion = gtk_event_controller_motion_new (priv->system_view);
g_signal_connect (priv->system_motion, "motion", G_CALLBACK (text_view_motion), about);
+ priv->license_key = gtk_event_controller_key_new (priv->license_view);
+ g_signal_connect (priv->license_key, "key-pressed", G_CALLBACK (text_view_key_pressed), about);
+ priv->system_key = gtk_event_controller_key_new (priv->system_view);
+ g_signal_connect (priv->system_key, "key-pressed", G_CALLBACK (text_view_key_pressed), about);
/* force defaults */
gtk_about_dialog_set_program_name (about, NULL);
@@ -822,6 +830,8 @@ gtk_about_dialog_finalize (GObject *object)
g_object_unref (priv->system_press);
g_object_unref (priv->license_motion);
g_object_unref (priv->system_motion);
+ g_object_unref (priv->license_key);
+ g_object_unref (priv->system_key);
G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
}
@@ -1928,16 +1938,17 @@ follow_if_link (GtkAboutDialog *about,
}
static gboolean
-text_view_key_press_event (GtkWidget *text_view,
- GdkEventKey *event,
- GtkAboutDialog *about)
+text_view_key_pressed (GtkEventController *controller,
+ guint keyval,
+ guint keycode,
+ GdkModifierType state,
+ GtkAboutDialog *about)
{
+ GtkWidget *text_view;
GtkTextIter iter;
GtkTextBuffer *buffer;
- guint keyval;
- if (!gdk_event_get_keyval ((GdkEvent *) event, &keyval))
- return GDK_EVENT_PROPAGATE;
+ text_view = gtk_event_controller_get_widget (controller);
switch (keyval)
{
diff --git a/gtk/ui/gtkaboutdialog.ui b/gtk/ui/gtkaboutdialog.ui
index 62d5492..f48ed4c 100644
--- a/gtk/ui/gtkaboutdialog.ui
+++ b/gtk/ui/gtkaboutdialog.ui
@@ -157,7 +157,6 @@
<property name="left-margin">8</property>
<property name="right-margin">8</property>
<property name="cursor-visible">0</property>
- <signal name="key-press-event" handler="text_view_key_press_event" swapped="no"/>
</object>
</child>
</object>
@@ -184,7 +183,6 @@
<property name="left-margin">8</property>
<property name="right-margin">8</property>
<property name="cursor-visible">0</property>
- <signal name="key-press-event" handler="text_view_key_press_event" swapped="no"/>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]