[gtk/wip/matthiasc/popup4: 15/79] root: Add api for mnemonics
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/popup4: 15/79] root: Add api for mnemonics
- Date: Sun, 21 Apr 2019 16:36:10 +0000 (UTC)
commit b604a7d2bcbeb58acf3fbd3725ca6e1fcbbae6f0
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 3 22:23:49 2019 -0500
root: Add api for mnemonics
Copy the add/remove_mnemonic and activate_key apis
from GtkWindow.
gtk/gtkroot.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkroot.h | 17 +++++++++++++
gtk/gtkrootprivate.h | 3 +++
3 files changed, 89 insertions(+)
---
diff --git a/gtk/gtkroot.c b/gtk/gtkroot.c
index d5f287fc4d..48d950151c 100644
--- a/gtk/gtkroot.c
+++ b/gtk/gtkroot.c
@@ -68,6 +68,27 @@ gtk_root_default_check_resize (GtkRoot *self)
{
}
+static void
+gtk_root_default_add_mnemonic (GtkRoot *self,
+ guint keyval,
+ GtkWidget *target)
+{
+}
+
+static void
+gtk_root_default_remove_mnemonic (GtkRoot *self,
+ guint keyval,
+ GtkWidget *target)
+{
+}
+
+static gboolean
+gtk_root_default_activate_key (GtkRoot *self,
+ GdkEventKey *event)
+{
+ return FALSE;
+}
+
static void
gtk_root_default_init (GtkRootInterface *iface)
{
@@ -75,6 +96,9 @@ gtk_root_default_init (GtkRootInterface *iface)
iface->get_renderer = gtk_root_default_get_renderer;
iface->get_surface_transform = gtk_root_default_get_surface_transform;
iface->check_resize = gtk_root_default_check_resize;
+ iface->add_mnemonic = gtk_root_default_add_mnemonic;
+ iface->remove_mnemonic = gtk_root_default_remove_mnemonic;
+ iface->activate_key = gtk_root_default_activate_key;
g_object_interface_install_property (iface,
g_param_spec_object ("focus-widget",
@@ -425,3 +449,48 @@ gtk_root_queue_restyle (GtkRoot *root)
gtk_root_set_restyle_pending (root, TRUE);
gtk_root_start_layout_phase (root);
}
+
+/**
+ * gtk_root_add_mnemonic:
+ * @root: a #GtkRoot
+ * @keyval: the mnemonic
+ * @target: the widget that gets activated by the mnemonic
+ *
+ * Adds a mnemonic to this root.
+ */
+void
+gtk_root_add_mnemonic (GtkRoot *root,
+ guint keyval,
+ GtkWidget *target)
+{
+ g_return_if_fail (GTK_ROOT (root));
+
+ GTK_ROOT_GET_IFACE (root)->add_mnemonic (root, keyval, target);
+}
+
+/**
+ * gtk_root_remove_mnemonic:
+ * @root: a #GtkRoot
+ * @keyval: the mnemonic
+ * @target: the widget that gets activated by the mnemonic
+ *
+ * Removes a mnemonic from this root.
+ */
+void
+gtk_root_remove_mnemonic (GtkRoot *root,
+ guint keyval,
+ GtkWidget *target)
+{
+ g_return_if_fail (GTK_ROOT (root));
+
+ GTK_ROOT_GET_IFACE (root)->remove_mnemonic (root, keyval, target);
+}
+
+gboolean
+gtk_root_activate_key (GtkRoot *root,
+ GdkEventKey *event)
+{
+ g_return_val_if_fail (GTK_ROOT (root), FALSE);
+
+ return GTK_ROOT_GET_IFACE (root)->activate_key (root, event);
+}
diff --git a/gtk/gtkroot.h b/gtk/gtkroot.h
index a3935efff1..77ad31f7e5 100644
--- a/gtk/gtkroot.h
+++ b/gtk/gtkroot.h
@@ -52,6 +52,15 @@ struct _GtkRootInterface
int *x,
int *y);
void (* check_resize) (GtkRoot *root);
+
+ void (* add_mnemonic) (GtkRoot *root,
+ guint keyval,
+ GtkWidget *target);
+ void (* remove_mnemonic) (GtkRoot *root,
+ guint keyval,
+ GtkWidget *target);
+ gboolean (* activate_key) (GtkRoot *root,
+ GdkEventKey *event);
};
GDK_AVAILABLE_IN_ALL
@@ -73,6 +82,14 @@ GtkWidget * gtk_root_get_default (GtkRoot *self);
GDK_AVAILABLE_IN_ALL
gboolean gtk_root_activate_default (GtkRoot *self);
+GDK_AVAILABLE_IN_ALL
+void gtk_root_add_mnemonic (GtkRoot *root,
+ guint keyval,
+ GtkWidget *target);
+GDK_AVAILABLE_IN_ALL
+void gtk_root_remove_mnemonic (GtkRoot *root,
+ guint keyval,
+ GtkWidget *target);
G_END_DECLS
diff --git a/gtk/gtkrootprivate.h b/gtk/gtkrootprivate.h
index bbba7c2977..3b583661c0 100644
--- a/gtk/gtkrootprivate.h
+++ b/gtk/gtkrootprivate.h
@@ -16,6 +16,9 @@ void gtk_root_queue_restyle (GtkRoot
void gtk_root_start_layout_phase (GtkRoot *self);
void gtk_root_stop_layout_phase (GtkRoot *self);
+gboolean gtk_root_activate_key (GtkRoot *self,
+ GdkEventKey *event);
+
enum {
GTK_ROOT_PROP_FOCUS_WIDGET,
GTK_ROOT_PROP_DEFAULT_WIDGET,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]