[gtk/inspector-display: 7/14] inspector: Make object tree respect inspected display
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/inspector-display: 7/14] inspector: Make object tree respect inspected display
- Date: Sat, 7 Dec 2019 20:04:24 +0000 (UTC)
commit 1437b0856c4342199aa1f902d550869f19130982
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Dec 7 11:49:30 2019 -0500
inspector: Make object tree respect inspected display
Stop using gdk_display_get_dfault and use the
inspected display instead.
gtk/inspector/object-tree.c | 50 +++++++++++++++++++++++++--------------------
gtk/inspector/object-tree.h | 3 +++
gtk/inspector/window.c | 2 ++
3 files changed, 33 insertions(+), 22 deletions(-)
---
diff --git a/gtk/inspector/object-tree.c b/gtk/inspector/object-tree.c
index 8c5189c2d1..e0e1f4c2ff 100644
--- a/gtk/inspector/object-tree.c
+++ b/gtk/inspector/object-tree.c
@@ -29,6 +29,7 @@
#include "object-tree.h"
#include "prop-list.h"
+#include "window.h"
#include "gtkbuildable.h"
#include "gtkbutton.h"
@@ -66,7 +67,6 @@ enum
LAST_SIGNAL
};
-
struct _GtkInspectorObjectTreePrivate
{
GtkListBox *list;
@@ -810,6 +810,9 @@ destroy_controller (GtkEventController *controller)
gtk_widget_remove_controller (gtk_event_controller_get_widget (controller), controller);
}
+static gboolean toplevel_filter_func (gpointer item,
+ gpointer data);
+
static void
map (GtkWidget *widget)
{
@@ -1116,7 +1119,7 @@ toplevel_filter_func (gpointer item,
}
static GListModel *
-create_root_model (void)
+create_root_model (GdkDisplay *display)
{
GtkFilterListModel *filter;
GtkFlattenListModel *flatten;
@@ -1129,15 +1132,14 @@ create_root_model (void)
item = g_application_get_default ();
if (item)
g_list_store_append (special, item);
- g_list_store_append (special, gtk_settings_get_default ());
+ g_list_store_append (special, gtk_settings_get_for_display (display));
g_list_store_append (list, special);
g_object_unref (special);
filter = gtk_filter_list_model_new_for_type (G_TYPE_OBJECT);
gtk_filter_list_model_set_filter_func (filter,
toplevel_filter_func,
- g_object_ref (gdk_display_get_default ()),
- g_object_unref);
+ display, NULL);
gtk_filter_list_model_set_model (filter, gtk_window_get_toplevels ());
g_list_store_append (list, filter);
g_object_unref (filter);
@@ -1150,28 +1152,11 @@ create_root_model (void)
static void
gtk_inspector_object_tree_init (GtkInspectorObjectTree *wt)
{
- GListModel *root_model;
-
wt->priv = gtk_inspector_object_tree_get_instance_private (wt);
gtk_widget_init_template (GTK_WIDGET (wt));
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (wt->priv->search_bar),
GTK_EDITABLE (wt->priv->search_entry));
-
- root_model = create_root_model ();
- wt->priv->tree_model = gtk_tree_list_model_new (FALSE,
- root_model,
- FALSE,
- create_model_for_object,
- NULL,
- NULL);
- g_object_unref (root_model);
-
- gtk_list_box_bind_model (wt->priv->list,
- G_LIST_MODEL (wt->priv->tree_model),
- gtk_inspector_object_tree_create_list_widget,
- wt,
- NULL);
}
static void
@@ -1295,3 +1280,24 @@ gtk_inspector_object_tree_select_object (GtkInspectorObjectTree *wt,
g_object_unref (row_item);
}
+void
+gtk_inspector_object_tree_set_display (GtkInspectorObjectTree *wt,
+ GdkDisplay *display)
+{
+ GListModel *root_model;
+
+ root_model = create_root_model (display);
+ wt->priv->tree_model = gtk_tree_list_model_new (FALSE,
+ root_model,
+ FALSE,
+ create_model_for_object,
+ NULL,
+ NULL);
+ g_object_unref (root_model);
+
+ gtk_list_box_bind_model (wt->priv->list,
+ G_LIST_MODEL (wt->priv->tree_model),
+ gtk_inspector_object_tree_create_list_widget,
+ wt,
+ NULL);
+}
diff --git a/gtk/inspector/object-tree.h b/gtk/inspector/object-tree.h
index ee7cf98f8b..fe9e0cc7bd 100644
--- a/gtk/inspector/object-tree.h
+++ b/gtk/inspector/object-tree.h
@@ -67,6 +67,9 @@ void gtk_inspector_object_tree_activate_object (GtkInspectorObjectTree
GObject *gtk_inspector_object_tree_get_selected (GtkInspectorObjectTree *wt);
+void gtk_inspector_object_tree_set_display (GtkInspectorObjectTree *wt,
+ GdkDisplay *display);
+
G_END_DECLS
diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c
index 97acc43865..24c2f20515 100644
--- a/gtk/inspector/window.c
+++ b/gtk/inspector/window.c
@@ -265,6 +265,8 @@ gtk_inspector_window_constructed (GObject *object)
G_OBJECT_CLASS (gtk_inspector_window_parent_class)->constructed (object);
g_object_set_data (G_OBJECT (iw->inspected_display), "-gtk-inspector", iw);
+
+ gtk_inspector_object_tree_set_display (GTK_INSPECTOR_OBJECT_TREE (iw->object_tree), iw->inspected_display);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]