mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-17 07:30:09 +00:00
parent
eecd5823d0
commit
0657a53940
@ -62,6 +62,14 @@ enum
|
||||
COLUMN_PROP_LOCATION
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_NODE,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
struct _GtkInspectorCssNodeTreePrivate
|
||||
{
|
||||
GtkWidget *node_tree;
|
||||
@ -76,6 +84,8 @@ struct _GtkInspectorCssNodeTreePrivate
|
||||
GtkCssNode *node;
|
||||
};
|
||||
|
||||
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorCssNodeTree, gtk_inspector_css_node_tree, GTK_TYPE_BOX)
|
||||
|
||||
typedef struct {
|
||||
@ -168,6 +178,41 @@ gtk_inspector_css_node_tree_unset_node (GtkInspectorCssNodeTree *cnt)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_css_node_tree_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkInspectorCssNodeTree *cnt = GTK_INSPECTOR_CSS_NODE_TREE (object);
|
||||
GtkInspectorCssNodeTreePrivate *priv = cnt->priv;
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_NODE:
|
||||
g_value_set_object (value, priv->node);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_css_node_tree_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id)
|
||||
{
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_css_node_tree_finalize (GObject *object)
|
||||
{
|
||||
@ -202,8 +247,19 @@ gtk_inspector_css_node_tree_class_init (GtkInspectorCssNodeTreeClass *klass)
|
||||
|
||||
ensure_css_sections ();
|
||||
|
||||
object_class->set_property = gtk_inspector_css_node_tree_set_property;
|
||||
object_class->get_property = gtk_inspector_css_node_tree_get_property;
|
||||
object_class->finalize = gtk_inspector_css_node_tree_finalize;
|
||||
|
||||
properties[PROP_NODE] =
|
||||
g_param_spec_object ("node",
|
||||
"Node",
|
||||
"Currently inspected CSS node",
|
||||
GTK_TYPE_CSS_NODE,
|
||||
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/css-node-tree.ui");
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssNodeTree, node_tree);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssNodeTree, node_name_column);
|
||||
@ -458,8 +514,21 @@ gtk_inspector_css_node_tree_set_node (GtkInspectorCssNodeTree *cnt,
|
||||
gtk_inspector_css_node_tree_unset_node (cnt);
|
||||
|
||||
priv->node = node;
|
||||
|
||||
if (node)
|
||||
{
|
||||
g_signal_connect (node, "style-changed", G_CALLBACK (gtk_inspector_css_node_tree_update_style_cb), cnt);
|
||||
}
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (cnt), properties[PROP_NODE]);
|
||||
}
|
||||
|
||||
GtkCssNode *
|
||||
gtk_inspector_css_node_tree_get_node (GtkInspectorCssNodeTree *cnt)
|
||||
{
|
||||
GtkInspectorCssNodeTreePrivate *priv = cnt->priv;
|
||||
|
||||
return priv->node;
|
||||
}
|
||||
|
||||
// vim: set et sw=2 ts=2:
|
||||
// vim: set et sw=2 ts=2:
|
||||
|
@ -54,6 +54,8 @@ GType gtk_inspector_css_node_tree_get_type (void);
|
||||
void gtk_inspector_css_node_tree_set_object (GtkInspectorCssNodeTree *cnt,
|
||||
GObject *object);
|
||||
|
||||
GtkCssNode * gtk_inspector_css_node_tree_get_node (GtkInspectorCssNodeTree *cnt);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif // _GTK_INSPECTOR_CSS_NODE_TREE_H_
|
||||
|
@ -44,16 +44,17 @@
|
||||
#include "magnifier.h"
|
||||
#include "recorder.h"
|
||||
|
||||
#include "gtklabel.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkstack.h"
|
||||
#include "gtktreeviewcolumn.h"
|
||||
#include "gtkmodulesprivate.h"
|
||||
#include "gtkwindowprivate.h"
|
||||
#include "gtkwindowgroup.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gdk-private.h"
|
||||
#include "gskrendererprivate.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkcsswidgetnodeprivate.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkmodulesprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkstack.h"
|
||||
#include "gtktreeviewcolumn.h"
|
||||
#include "gtkwindowgroup.h"
|
||||
#include "gtkwindowprivate.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW)
|
||||
|
||||
@ -118,6 +119,29 @@ on_object_selected (GtkInspectorObjectTree *wt,
|
||||
gtk_inspector_flash_widget (iw, GTK_WIDGET (selected));
|
||||
}
|
||||
|
||||
static void
|
||||
notify_node (GtkInspectorCssNodeTree *cnt,
|
||||
GParamSpec *pspec,
|
||||
GtkInspectorWindow *iw)
|
||||
{
|
||||
GtkCssNode *node;
|
||||
GtkWidget *widget = NULL;
|
||||
|
||||
for (node = gtk_inspector_css_node_tree_get_node (cnt);
|
||||
node != NULL;
|
||||
node = gtk_css_node_get_parent (node))
|
||||
{
|
||||
if (!GTK_IS_CSS_WIDGET_NODE (node))
|
||||
continue;
|
||||
|
||||
widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (node));
|
||||
if (widget != NULL)
|
||||
break;
|
||||
}
|
||||
if (widget)
|
||||
gtk_inspector_flash_widget (iw, widget);
|
||||
}
|
||||
|
||||
static void
|
||||
close_object_details (GtkWidget *button, GtkInspectorWindow *iw)
|
||||
{
|
||||
@ -296,6 +320,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
|
||||
gtk_widget_class_bind_template_callback (widget_class, open_object_details);
|
||||
gtk_widget_class_bind_template_callback (widget_class, close_object_details);
|
||||
gtk_widget_class_bind_template_callback (widget_class, object_details_changed);
|
||||
gtk_widget_class_bind_template_callback (widget_class, notify_node);
|
||||
}
|
||||
|
||||
static GdkDisplay *
|
||||
|
@ -330,7 +330,9 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkInspectorCssNodeTree" id="widget_css_node_tree"/>
|
||||
<object class="GtkInspectorCssNodeTree" id="widget_css_node_tree">
|
||||
<signal name="notify::node" handler="notify_node"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">css-nodes</property>
|
||||
<property name="title" translatable="yes">CSS Nodes</property>
|
||||
|
Loading…
Reference in New Issue
Block a user