mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-16 15:14:17 +00:00
inspector: Small reshuffling
Move the scrolled window into GtkInspectorWidgetTree.
This commit is contained in:
parent
bee90aa8c8
commit
e8f9e7d472
@ -30,6 +30,7 @@
|
|||||||
#include "widget-tree.h"
|
#include "widget-tree.h"
|
||||||
|
|
||||||
#include "gtkcelllayout.h"
|
#include "gtkcelllayout.h"
|
||||||
|
#include "gtktreeview.h"
|
||||||
#include "gtkpopover.h"
|
#include "gtkpopover.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "gtkmenuitem.h"
|
#include "gtkmenuitem.h"
|
||||||
#include "gtksettings.h"
|
#include "gtksettings.h"
|
||||||
#include "gtktextview.h"
|
#include "gtktextview.h"
|
||||||
|
#include "gtktreeview.h"
|
||||||
#include "gtktreeselection.h"
|
#include "gtktreeselection.h"
|
||||||
#include "gtktreestore.h"
|
#include "gtktreestore.h"
|
||||||
#include "gtktreemodelsort.h"
|
#include "gtktreemodelsort.h"
|
||||||
@ -65,6 +66,7 @@ enum
|
|||||||
|
|
||||||
struct _GtkInspectorWidgetTreePrivate
|
struct _GtkInspectorWidgetTreePrivate
|
||||||
{
|
{
|
||||||
|
GtkTreeView *tree;
|
||||||
GtkTreeStore *model;
|
GtkTreeStore *model;
|
||||||
GHashTable *iters;
|
GHashTable *iters;
|
||||||
gulong map_hook;
|
gulong map_hook;
|
||||||
@ -73,7 +75,7 @@ struct _GtkInspectorWidgetTreePrivate
|
|||||||
|
|
||||||
static guint widget_tree_signals[LAST_SIGNAL] = { 0 };
|
static guint widget_tree_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorWidgetTree, gtk_inspector_widget_tree, GTK_TYPE_TREE_VIEW)
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorWidgetTree, gtk_inspector_widget_tree, GTK_TYPE_BOX)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_widget_selected (GtkTreeSelection *selection,
|
on_widget_selected (GtkTreeSelection *selection,
|
||||||
@ -198,6 +200,7 @@ gtk_inspector_widget_tree_class_init (GtkInspectorWidgetTreeClass *klass)
|
|||||||
|
|
||||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/widget-tree.ui");
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/widget-tree.ui");
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorWidgetTree, model);
|
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorWidgetTree, model);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorWidgetTree, tree);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_widget_selected);
|
gtk_widget_class_bind_template_callback (widget_class, on_widget_selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +211,7 @@ gtk_inspector_widget_tree_get_selected_object (GtkInspectorWidgetTree *wt)
|
|||||||
GtkTreeSelection *sel;
|
GtkTreeSelection *sel;
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
|
|
||||||
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (wt));
|
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (wt->priv->tree));
|
||||||
|
|
||||||
if (gtk_tree_selection_get_selected (sel, &model, &iter))
|
if (gtk_tree_selection_get_selected (sel, &model, &iter))
|
||||||
{
|
{
|
||||||
@ -339,20 +342,6 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
|
|||||||
|
|
||||||
g_free (address);
|
g_free (address);
|
||||||
|
|
||||||
if (GTK_IS_TREE_MODEL_SORT (object))
|
|
||||||
{
|
|
||||||
GObject *child = G_OBJECT (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (object)));
|
|
||||||
if (child)
|
|
||||||
gtk_inspector_widget_tree_append_object (wt, child, &iter, "model");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GTK_IS_TREE_MODEL_FILTER (object))
|
|
||||||
{
|
|
||||||
GObject *child = G_OBJECT (gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (object)));
|
|
||||||
if (child)
|
|
||||||
gtk_inspector_widget_tree_append_object (wt, child, &iter, "model");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GTK_IS_CONTAINER (object))
|
if (GTK_IS_CONTAINER (object))
|
||||||
{
|
{
|
||||||
FindAllData data;
|
FindAllData data;
|
||||||
@ -368,6 +357,20 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
|
|||||||
* children in the GtkContainer sense, but which we still want
|
* children in the GtkContainer sense, but which we still want
|
||||||
* to show in the tree right away.
|
* to show in the tree right away.
|
||||||
*/
|
*/
|
||||||
|
if (GTK_IS_TREE_MODEL_SORT (object))
|
||||||
|
{
|
||||||
|
GObject *child = G_OBJECT (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (object)));
|
||||||
|
if (child)
|
||||||
|
gtk_inspector_widget_tree_append_object (wt, child, &iter, "model");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GTK_IS_TREE_MODEL_FILTER (object))
|
||||||
|
{
|
||||||
|
GObject *child = G_OBJECT (gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (object)));
|
||||||
|
if (child)
|
||||||
|
gtk_inspector_widget_tree_append_object (wt, child, &iter, "model");
|
||||||
|
}
|
||||||
|
|
||||||
if (GTK_IS_MENU_ITEM (object))
|
if (GTK_IS_MENU_ITEM (object))
|
||||||
{
|
{
|
||||||
GtkWidget *submenu;
|
GtkWidget *submenu;
|
||||||
@ -524,7 +527,7 @@ gtk_inspector_widget_tree_scan (GtkInspectorWidgetTree *wt,
|
|||||||
}
|
}
|
||||||
g_list_free (toplevels);
|
g_list_free (toplevels);
|
||||||
|
|
||||||
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (wt));
|
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (wt->priv->tree));
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@ -558,9 +561,9 @@ gtk_inspector_widget_tree_select_object (GtkInspectorWidgetTree *wt,
|
|||||||
if (gtk_inspector_widget_tree_find_object (wt, object, &iter))
|
if (gtk_inspector_widget_tree_find_object (wt, object, &iter))
|
||||||
{
|
{
|
||||||
GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (wt->priv->model), &iter);
|
GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (wt->priv->model), &iter);
|
||||||
gtk_tree_view_expand_to_path (GTK_TREE_VIEW (wt), path);
|
gtk_tree_view_expand_to_path (GTK_TREE_VIEW (wt->priv->tree), path);
|
||||||
gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (wt)), &iter);
|
gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (wt->priv->tree)), &iter);
|
||||||
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (wt), path, NULL, FALSE, 0, 0);
|
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (wt->priv->tree), path, NULL, FALSE, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
#ifndef _GTK_INSPECTOR_WIDGET_TREE_H_
|
#ifndef _GTK_INSPECTOR_WIDGET_TREE_H_
|
||||||
#define _GTK_INSPECTOR_WIDGET_TREE_H_
|
#define _GTK_INSPECTOR_WIDGET_TREE_H_
|
||||||
|
|
||||||
#include <gtk/gtktreeview.h>
|
#include <gtk/gtkbox.h>
|
||||||
|
#include <gtk/gtktreemodel.h>
|
||||||
|
|
||||||
#define GTK_TYPE_INSPECTOR_WIDGET_TREE (gtk_inspector_widget_tree_get_type())
|
#define GTK_TYPE_INSPECTOR_WIDGET_TREE (gtk_inspector_widget_tree_get_type())
|
||||||
#define GTK_INSPECTOR_WIDGET_TREE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_WIDGET_TREE, GtkInspectorWidgetTree))
|
#define GTK_INSPECTOR_WIDGET_TREE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_WIDGET_TREE, GtkInspectorWidgetTree))
|
||||||
@ -37,13 +38,13 @@ typedef struct _GtkInspectorWidgetTreePrivate GtkInspectorWidgetTreePrivate;
|
|||||||
|
|
||||||
typedef struct _GtkInspectorWidgetTree
|
typedef struct _GtkInspectorWidgetTree
|
||||||
{
|
{
|
||||||
GtkTreeView parent;
|
GtkBox parent;
|
||||||
GtkInspectorWidgetTreePrivate *priv;
|
GtkInspectorWidgetTreePrivate *priv;
|
||||||
} GtkInspectorWidgetTree;
|
} GtkInspectorWidgetTree;
|
||||||
|
|
||||||
typedef struct _GtkInspectorWidgetTreeClass
|
typedef struct _GtkInspectorWidgetTreeClass
|
||||||
{
|
{
|
||||||
GtkTreeViewClass parent;
|
GtkBoxClass parent;
|
||||||
|
|
||||||
void (*widget_changed) (GtkInspectorWidgetTree *tree);
|
void (*widget_changed) (GtkInspectorWidgetTree *tree);
|
||||||
} GtkInspectorWidgetTreeClass;
|
} GtkInspectorWidgetTreeClass;
|
||||||
|
@ -10,7 +10,20 @@
|
|||||||
<column type="gboolean"/>
|
<column type="gboolean"/>
|
||||||
</columns>
|
</columns>
|
||||||
</object>
|
</object>
|
||||||
<template class="GtkInspectorWidgetTree" parent="GtkTreeView">
|
<template class="GtkInspectorWidgetTree" parent="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkScrolledWindow">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="hscrollbar-policy">automatic</property>
|
||||||
|
<property name="vscrollbar-policy">always</property>
|
||||||
|
<property name="shadow-type">in</property>
|
||||||
|
<property name="width-request">250</property>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeView" id="tree">
|
||||||
|
<property name="visible">True</property>
|
||||||
<property name="model">model</property>
|
<property name="model">model</property>
|
||||||
<property name="enable-search">True</property>
|
<property name="enable-search">True</property>
|
||||||
<property name="search-column">2</property>
|
<property name="search-column">2</property>
|
||||||
@ -80,5 +93,9 @@
|
|||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</template>
|
</template>
|
||||||
</interface>
|
</interface>
|
||||||
|
@ -43,29 +43,15 @@
|
|||||||
<child>
|
<child>
|
||||||
<object class="GtkStack" id="top_stack">
|
<object class="GtkStack" id="top_stack">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<child>
|
|
||||||
<object class="GtkBox">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkPaned">
|
<object class="GtkPaned">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="orientation">horizontal</property>
|
<property name="orientation">horizontal</property>
|
||||||
<child>
|
|
||||||
<object class="GtkScrolledWindow">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="hscrollbar-policy">automatic</property>
|
|
||||||
<property name="vscrollbar-policy">always</property>
|
|
||||||
<property name="shadow-type">in</property>
|
|
||||||
<property name="width-request">250</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkInspectorWidgetTree" id="widget_tree">
|
<object class="GtkInspectorWidgetTree" id="widget_tree">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<signal name="widget-changed" handler="on_widget_tree_selection_changed"/>
|
<signal name="widget-changed" handler="on_widget_tree_selection_changed"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
<packing>
|
||||||
<property name="resize">True</property>
|
<property name="resize">True</property>
|
||||||
<property name="shrink">True</property>
|
<property name="shrink">True</property>
|
||||||
@ -272,8 +258,6 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
<packing>
|
||||||
<property name="name">objects</property>
|
<property name="name">objects</property>
|
||||||
<property name="title" translatable="yes">Objects</property>
|
<property name="title" translatable="yes">Objects</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user