inspector: Drop the child property page

Child properties are on the way out.
This commit is contained in:
Matthias Clasen 2019-04-02 21:56:26 +00:00
parent 285e67c044
commit 4d6acd5d76
6 changed files with 13 additions and 158 deletions

View File

@ -104,7 +104,7 @@ show_node_prop_editor (NodePropEditor *npe)
popover = gtk_popover_new (GTK_WIDGET (npe->cnt->priv->node_tree));
gtk_popover_set_pointing_to (GTK_POPOVER (popover), &npe->rect);
editor = gtk_inspector_prop_editor_new (G_OBJECT (npe->node), npe->prop_name, FALSE);
editor = gtk_inspector_prop_editor_new (G_OBJECT (npe->node), npe->prop_name);
gtk_widget_show (editor);
gtk_container_add (GTK_CONTAINER (popover), editor);
@ -531,4 +531,3 @@ gtk_inspector_css_node_tree_get_node (GtkInspectorCssNodeTree *cnt)
}
// vim: set et sw=2 ts=2:
// vim: set et sw=2 ts=2:

View File

@ -49,7 +49,6 @@ struct _GtkInspectorPropEditorPrivate
{
GObject *object;
gchar *name;
gboolean is_child_property;
GtkWidget *editor;
};
@ -71,31 +70,9 @@ static guint signals[N_SIGNALS] = { 0 };
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorPropEditor, gtk_inspector_prop_editor, GTK_TYPE_BOX);
static gboolean
is_child_property (GParamSpec *pspec)
{
return g_param_spec_get_qdata (pspec, g_quark_from_string ("is-child-prop")) != NULL;
}
static GParamSpec *
mark_child_property (GParamSpec *pspec)
{
if (pspec)
g_param_spec_set_qdata (pspec, g_quark_from_string ("is-child-prop"), GINT_TO_POINTER (TRUE));
return pspec;
}
static GParamSpec *
find_property (GtkInspectorPropEditor *editor)
{
if (editor->priv->is_child_property)
{
GtkWidget *widget = GTK_WIDGET (editor->priv->object);
GtkWidget *parent = gtk_widget_get_parent (widget);
return mark_child_property (gtk_container_class_find_child_property (G_OBJECT_GET_CLASS (parent), editor->priv->name));
}
return g_object_class_find_property (G_OBJECT_GET_CLASS (editor->priv->object), editor->priv->name);
}
@ -135,10 +112,7 @@ g_object_connect_property (GObject *object,
gchar *with_detail;
DisconnectData *dd;
if (is_child_property (spec))
with_detail = g_strconcat ("child-notify::", spec->name, NULL);
else
with_detail = g_strconcat ("notify::", spec->name, NULL);
with_detail = g_strconcat ("notify::", spec->name, NULL);
dd = g_new (DisconnectData, 1);
@ -224,45 +198,19 @@ unblock_controller (GObject *controller)
static void
get_property_value (GObject *object, GParamSpec *pspec, GValue *value)
{
if (is_child_property (pspec))
{
GtkWidget *widget = GTK_WIDGET (object);
GtkWidget *parent = gtk_widget_get_parent (widget);
gtk_container_child_get_property (GTK_CONTAINER (parent),
widget, pspec->name, value);
}
else
g_object_get_property (object, pspec->name, value);
g_object_get_property (object, pspec->name, value);
}
static void
set_property_value (GObject *object, GParamSpec *pspec, GValue *value)
{
if (is_child_property (pspec))
{
GtkWidget *widget = GTK_WIDGET (object);
GtkWidget *parent = gtk_widget_get_parent (widget);
gtk_container_child_set_property (GTK_CONTAINER (parent),
widget, pspec->name, value);
}
else
g_object_set_property (object, pspec->name, value);
g_object_set_property (object, pspec->name, value);
}
static void
notify_property (GObject *object, GParamSpec *pspec)
{
if (is_child_property (pspec))
{
GtkWidget *widget = GTK_WIDGET (object);
GtkWidget *parent = gtk_widget_get_parent (widget);
gtk_container_child_notify (GTK_CONTAINER (parent), widget, pspec->name);
}
else
g_object_notify (object, pspec->name);
g_object_notify (object, pspec->name);
}
static void
@ -1766,10 +1714,6 @@ get_property (GObject *object,
g_value_set_string (value, r->priv->name);
break;
case PROP_IS_CHILD_PROPERTY:
g_value_set_boolean (value, r->priv->is_child_property);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@ -1795,10 +1739,6 @@ set_property (GObject *object,
r->priv->name = g_value_dup_string (value);
break;
case PROP_IS_CHILD_PROPERTY:
r->priv->is_child_property = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
break;
@ -1830,21 +1770,15 @@ gtk_inspector_prop_editor_class_init (GtkInspectorPropEditorClass *klass)
g_object_class_install_property (object_class, PROP_NAME,
g_param_spec_string ("name", "Name", "The property name",
NULL, G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_IS_CHILD_PROPERTY,
g_param_spec_boolean ("is-child-property", "Child property", "Whether this is a child property",
FALSE, G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
}
GtkWidget *
gtk_inspector_prop_editor_new (GObject *object,
const gchar *name,
gboolean is_child_property)
const gchar *name)
{
return g_object_new (GTK_TYPE_INSPECTOR_PROP_EDITOR,
"object", object,
"name", name,
"is-child-property", is_child_property,
NULL);
}

View File

@ -53,8 +53,7 @@ G_BEGIN_DECLS
GType gtk_inspector_prop_editor_get_type (void);
GtkWidget *gtk_inspector_prop_editor_new (GObject *object,
const gchar *name,
gboolean is_child_property);
const gchar *name);
gboolean gtk_inspector_prop_editor_should_expand (GtkInspectorPropEditor *editor);

View File

@ -54,7 +54,6 @@ enum
{
PROP_0,
PROP_OBJECT_TREE,
PROP_CHILD_PROPERTIES,
PROP_SEARCH_ENTRY
};
@ -65,7 +64,6 @@ struct _GtkInspectorPropListPrivate
GHashTable *prop_iters;
gulong notify_handler_id;
GtkInspectorObjectTree *object_tree;
gboolean child_properties;
GtkTreeViewColumn *name_column;
GtkTreeViewColumn *attribute_column;
GtkWidget *tree;
@ -163,10 +161,6 @@ get_property (GObject *object,
g_value_take_object (value, pl->priv->object_tree);
break;
case PROP_CHILD_PROPERTIES:
g_value_set_boolean (value, pl->priv->child_properties);
break;
case PROP_SEARCH_ENTRY:
g_value_take_object (value, pl->priv->search_entry);
break;
@ -191,10 +185,6 @@ set_property (GObject *object,
pl->priv->object_tree = g_value_get_object (value);
break;
case PROP_CHILD_PROPERTIES:
pl->priv->child_properties = g_value_get_boolean (value);
break;
case PROP_SEARCH_ENTRY:
pl->priv->search_entry = g_value_get_object (value);
break;
@ -242,7 +232,7 @@ row_activated (GtkTreeView *tv,
popover = gtk_popover_new (GTK_WIDGET (tv));
gtk_popover_set_pointing_to (GTK_POPOVER (popover), &rect);
editor = gtk_inspector_prop_editor_new (pl->priv->object, name, pl->priv->child_properties);
editor = gtk_inspector_prop_editor_new (pl->priv->object, name);
gtk_widget_show (editor);
gtk_container_add (GTK_CONTAINER (popover), editor);
@ -303,9 +293,6 @@ gtk_inspector_prop_list_class_init (GtkInspectorPropListClass *klass)
g_object_class_install_property (object_class, PROP_OBJECT_TREE,
g_param_spec_object ("object-tree", "Object Tree", "Object tree",
GTK_TYPE_WIDGET, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_CHILD_PROPERTIES,
g_param_spec_boolean ("child-properties", "Child properties", "Child properties",
FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_SEARCH_ENTRY,
g_param_spec_object ("search-entry", "Search Entry", "Search Entry",
@ -433,17 +420,7 @@ gtk_inspector_prop_list_update_prop (GtkInspectorPropList *pl,
gboolean writable;
g_value_init (&gvalue, prop->value_type);
if (pl->priv->child_properties)
{
GtkWidget *parent;
parent = gtk_widget_get_parent (GTK_WIDGET (pl->priv->object));
gtk_container_child_get_property (GTK_CONTAINER (parent),
GTK_WIDGET (pl->priv->object),
prop->name, &gvalue);
}
else
g_object_get_property (pl->priv->object, prop->name, &gvalue);
g_object_get_property (pl->priv->object, prop->name, &gvalue);
strdup_value_contents (&gvalue, &value, &type);
@ -535,33 +512,8 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
gtk_editable_set_text (GTK_EDITABLE (pl->priv->search_entry), "");
gtk_stack_set_visible_child_name (GTK_STACK (pl->priv->search_stack), "title");
if (pl->priv->child_properties)
{
GtkWidget *parent;
if (!GTK_IS_WIDGET (object))
{
gtk_widget_hide (GTK_WIDGET (pl));
return TRUE;
}
parent = gtk_widget_get_parent (GTK_WIDGET (object));
if (!parent || !GTK_IS_CONTAINER (parent))
{
gtk_widget_hide (GTK_WIDGET (pl));
return TRUE;
}
gtk_tree_view_column_set_visible (pl->priv->attribute_column, FALSE);
props = gtk_container_class_list_child_properties (G_OBJECT_GET_CLASS (parent), &num_properties);
}
else
{
gtk_tree_view_column_set_visible (pl->priv->attribute_column, GTK_IS_CELL_RENDERER (object));
props = g_object_class_list_properties (G_OBJECT_GET_CLASS (object), &num_properties);
}
gtk_tree_view_column_set_visible (pl->priv->attribute_column, GTK_IS_CELL_RENDERER (object));
props = g_object_class_list_properties (G_OBJECT_GET_CLASS (object), &num_properties);
pl->priv->object = object;
@ -585,10 +537,8 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
/* Listen for updates */
pl->priv->notify_handler_id =
g_signal_connect_object (object,
pl->priv->child_properties ? "child-notify" : "notify",
G_CALLBACK (gtk_inspector_prop_list_prop_changed_cb),
pl, 0);
g_signal_connect_object (object, "notify",
G_CALLBACK (gtk_inspector_prop_list_prop_changed_cb), pl, 0);
gtk_widget_show (GTK_WIDGET (pl));

View File

@ -69,7 +69,6 @@ set_selected_object (GtkInspectorWindow *iw,
gtk_label_set_label (GTK_LABEL (iw->object_title), title);
g_free (title);
gtk_inspector_prop_list_set_object (GTK_INSPECTOR_PROP_LIST (iw->child_prop_list), selected);
gtk_inspector_misc_info_set_object (GTK_INSPECTOR_MISC_INFO (iw->misc_info), selected);
gtk_inspector_css_node_tree_set_object (GTK_INSPECTOR_CSS_NODE_TREE (iw->widget_css_node_tree), selected);
gtk_inspector_size_groups_set_object (GTK_INSPECTOR_SIZE_GROUPS (iw->size_groups), selected);
@ -313,7 +312,6 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_details_button);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, select_object);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, prop_list);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, child_prop_list);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_css_node_tree);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_recorder);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_title);

View File

@ -276,17 +276,6 @@
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">child-prop-search</property>
<property name="child">
<object class="GtkSearchEntry" id="child_prop_search_entry">
<property name="margin">6</property>
<property name="max-width-chars">40</property>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
@ -311,26 +300,12 @@
<property name="title" translatable="yes">Properties</property>
<property name="child">
<object class="GtkInspectorPropList" id="prop_list">
<property name="child-properties">False</property>
<property name="object-tree">object_tree</property>
<property name="search-entry">prop_search_entry</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">child-properties</property>
<property name="title" translatable="yes">Child Properties</property>
<property name="child">
<object class="GtkInspectorPropList" id="child_prop_list">
<property name="child-properties">True</property>
<property name="object-tree">object_tree</property>
<property name="search-entry">child_prop_search_entry</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">css-nodes</property>