[gtk/more-root] root: Add focus and default widgets
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/more-root] root: Add focus and default widgets
- Date: Fri, 22 Feb 2019 04:54:21 +0000 (UTC)
commit 6e735f709bd8a4df52b3430fbf6e3ae10eebb9bd
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Feb 21 23:51:05 2019 -0500
root: Add focus and default widgets
These are part of what GtkRoot will manage.
Use the GtkRoot api for them in the inspector.
gtk/gtkroot.c | 30 ++++++++++++++++++++++++++++++
gtk/gtkroot.h | 2 ++
gtk/gtkrootprivate.h | 2 ++
gtk/gtkwindow.c | 23 +++++++++++++++++++++++
gtk/inspector/misc-info.c | 7 ++++---
5 files changed, 61 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkroot.c b/gtk/gtkroot.c
index 1907786e95..9bf018d8b2 100644
--- a/gtk/gtkroot.c
+++ b/gtk/gtkroot.c
@@ -58,12 +58,26 @@ gtk_root_default_get_surface_transform (GtkRoot *self,
*y = 0;
}
+static GtkWidget *
+gtk_root_default_get_focus (GtkRoot *self)
+{
+ return NULL;
+}
+
+static GtkWidget *
+gtk_root_default_get_default (GtkRoot *self)
+{
+ return NULL;
+}
+
static void
gtk_root_default_init (GtkRootInterface *iface)
{
iface->get_display = gtk_root_default_get_display;
iface->get_renderer = gtk_root_default_get_renderer;
iface->get_surface_transform = gtk_root_default_get_surface_transform;
+ iface->get_focus = gtk_root_default_get_focus;
+ iface->get_default = gtk_root_default_get_default;
}
GdkDisplay *
@@ -102,3 +116,19 @@ gtk_root_get_surface_transform (GtkRoot *self,
iface = GTK_ROOT_GET_IFACE (self);
return iface->get_surface_transform (self, x, y);
}
+
+GtkWidget *
+gtk_root_get_focus (GtkRoot *self)
+{
+ g_return_val_if_fail (GTK_IS_ROOT (self), NULL);
+
+ return GTK_ROOT_GET_IFACE (self)->get_focus (self);
+}
+
+GtkWidget *
+gtk_root_get_default (GtkRoot *self)
+{
+ g_return_val_if_fail (GTK_IS_ROOT (self), NULL);
+
+ return GTK_ROOT_GET_IFACE (self)->get_default (self);
+}
diff --git a/gtk/gtkroot.h b/gtk/gtkroot.h
index e3494fcc7a..6dabde6162 100644
--- a/gtk/gtkroot.h
+++ b/gtk/gtkroot.h
@@ -51,6 +51,8 @@ struct _GtkRootInterface
void (* get_surface_transform) (GtkRoot *root,
int *x,
int *y);
+ GtkWidget * (* get_focus) (GtkRoot *root);
+ GtkWidget * (* get_default) (GtkRoot *root);
};
diff --git a/gtk/gtkrootprivate.h b/gtk/gtkrootprivate.h
index 07ddc380e5..355b49f470 100644
--- a/gtk/gtkrootprivate.h
+++ b/gtk/gtkrootprivate.h
@@ -11,6 +11,8 @@ GskRenderer * gtk_root_get_renderer (GtkRoot
void gtk_root_get_surface_transform (GtkRoot *self,
int *x,
int *y);
+GtkWidget * gtk_root_get_focus (GtkRoot *self);
+GtkWidget * gtk_root_get_default (GtkRoot *self);
G_END_DECLS
#endif /* __GTK_ROOT_PRIVATE_H__ */
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 8682969454..399b7b0059 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -2534,12 +2534,35 @@ gtk_window_root_get_surface_transform (GtkRoot *root,
*y = margin.top + border.top + padding.top;
}
+static GtkWidget *
+gtk_window_root_get_focus (GtkRoot *root)
+{
+ GtkWindow *window = GTK_WINDOW (root);
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
+
+ if (priv->initial_focus)
+ return priv->initial_focus;
+ else
+ return priv->focus_widget;
+}
+
+static GtkWidget *
+gtk_window_root_get_default (GtkRoot *root)
+{
+ GtkWindow *window = GTK_WINDOW (root);
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
+
+ return priv->default_widget;
+}
+
static void
gtk_window_root_interface_init (GtkRootInterface *iface)
{
iface->get_display = gtk_window_root_get_display;
iface->get_renderer = gtk_window_root_get_renderer;
iface->get_surface_transform = gtk_window_root_get_surface_transform;
+ iface->get_focus = gtk_window_root_get_focus;
+ iface->get_default = gtk_window_root_get_default;
}
/**
diff --git a/gtk/inspector/misc-info.c b/gtk/inspector/misc-info.c
index 9c3b3ec05f..d0687222b8 100644
--- a/gtk/inspector/misc-info.c
+++ b/gtk/inspector/misc-info.c
@@ -29,6 +29,7 @@
#include "gtkframe.h"
#include "gtkbutton.h"
#include "gtkwidgetprivate.h"
+#include "gtkrootprivate.h"
struct _GtkInspectorMiscInfoPrivate {
@@ -190,7 +191,7 @@ update_default_widget (GtkInspectorMiscInfo *sl)
{
GtkWidget *widget;
- widget = gtk_window_get_default_widget (GTK_WINDOW (sl->priv->object));
+ widget = gtk_root_get_default (GTK_ROOT (sl->priv->object));
if (widget)
{
gchar *tmp;
@@ -222,7 +223,7 @@ update_focus_widget (GtkInspectorMiscInfo *sl)
{
GtkWidget *widget;
- widget = gtk_window_get_focus (GTK_WINDOW (sl->priv->object));
+ widget = gtk_root_get_focus (GTK_ROOT (sl->priv->object));
if (widget)
{
gchar *tmp;
@@ -355,7 +356,7 @@ update_info (gpointer data)
gtk_buildable_get_name (GTK_BUILDABLE (sl->priv->object)));
}
- if (GTK_IS_WINDOW (sl->priv->object))
+ if (GTK_IS_ROOT (sl->priv->object))
{
update_default_widget (sl);
update_focus_widget (sl);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]