[gtk/wip/matthiasc/popup4: 11/76] root: Add an activate_focus api
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/popup4: 11/76] root: Add an activate_focus api
- Date: Sat, 20 Apr 2019 17:32:24 +0000 (UTC)
commit 9a929ffc009fc174497bf2304d531fe36cc1a208
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Mar 16 14:47:11 2019 -0400
root: Add an activate_focus api
This makes sense to parallel what GtkWindow has,
and for key bindings.
gtk/gtkroot.c | 23 +++++++++++++++++++++++
gtk/gtkroot.h | 2 ++
2 files changed, 25 insertions(+)
---
diff --git a/gtk/gtkroot.c b/gtk/gtkroot.c
index 2ce455b040..d5f287fc4d 100644
--- a/gtk/gtkroot.c
+++ b/gtk/gtkroot.c
@@ -201,6 +201,29 @@ gtk_root_get_focus (GtkRoot *self)
return focus;
}
+/**
+ * gtk_root_activate_focus:
+ * @self: a #GtkRoot
+ *
+ * Activates the current focused widget within the root.
+ *
+ * Returns: %TRUE if a widget got activated.
+ **/
+gboolean
+gtk_root_activate_focus (GtkRoot *self)
+{
+ GtkWidget *focus_widget;
+
+ g_return_val_if_fail (GTK_IS_ROOT (self), FALSE);
+
+ focus_widget = gtk_root_get_focus (self);
+
+ if (focus_widget && gtk_widget_is_sensitive (focus_widget))
+ return gtk_widget_activate (focus_widget);
+
+ return FALSE;
+}
+
/**
* gtk_root_set_default:
* @self: a #GtkRoot
diff --git a/gtk/gtkroot.h b/gtk/gtkroot.h
index e4b0b96a71..a3935efff1 100644
--- a/gtk/gtkroot.h
+++ b/gtk/gtkroot.h
@@ -62,6 +62,8 @@ void gtk_root_set_focus (GtkRoot *self,
GtkWidget *focus);
GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_root_get_focus (GtkRoot *self);
+GDK_AVAILABLE_IN_ALL
+gboolean gtk_root_activate_focus (GtkRoot *self);
GDK_AVAILABLE_IN_ALL
void gtk_root_set_default (GtkRoot *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]