mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 22:41:43 +00:00
inspector: Stop using ::hierarchy-changed
Use the new root and unroot vfuncs instead.
This commit is contained in:
parent
f9041230c6
commit
47249431e3
@ -814,28 +814,33 @@ destroy_controller (GtkEventController *controller)
|
||||
}
|
||||
|
||||
static void
|
||||
on_hierarchy_changed (GtkWidget *widget,
|
||||
GtkWidget *previous_toplevel)
|
||||
root (GtkWidget *widget)
|
||||
{
|
||||
GtkInspectorObjectTree *wt = GTK_INSPECTOR_OBJECT_TREE (widget);
|
||||
GtkEventController *controller;
|
||||
GtkWidget *toplevel;
|
||||
|
||||
if (previous_toplevel)
|
||||
g_object_set_data (G_OBJECT (previous_toplevel), "object-controller", NULL);
|
||||
GTK_WIDGET_CLASS (gtk_inspector_object_tree_parent_class)->root (widget);
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (widget);
|
||||
|
||||
if (!GTK_IS_WINDOW (toplevel))
|
||||
return;
|
||||
|
||||
controller = gtk_event_controller_key_new ();
|
||||
g_object_set_data_full (G_OBJECT (toplevel), "object-controller", controller, (GDestroyNotify)destroy_controller);
|
||||
g_signal_connect (controller, "key-pressed", G_CALLBACK (key_pressed), widget);
|
||||
gtk_widget_add_controller (toplevel, controller);
|
||||
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (wt->priv->search_bar),
|
||||
toplevel);
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (wt->priv->search_bar), toplevel);
|
||||
}
|
||||
|
||||
static void
|
||||
unroot (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *toplevel;
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (widget);
|
||||
g_object_set_data (G_OBJECT (toplevel), "object-controller", NULL);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_inspector_object_tree_parent_class)->unroot (widget);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -1191,6 +1196,9 @@ gtk_inspector_object_tree_class_init (GtkInspectorObjectTreeClass *klass)
|
||||
|
||||
object_class->dispose = gtk_inspector_object_tree_dispose;
|
||||
|
||||
widget_class->root = root;
|
||||
widget_class->unroot = unroot;
|
||||
|
||||
signals[OBJECT_ACTIVATED] =
|
||||
g_signal_new ("object-activated",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
@ -1216,7 +1224,6 @@ gtk_inspector_object_tree_class_init (GtkInspectorObjectTreeClass *klass)
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorObjectTree, type_size_group);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorObjectTree, name_size_group);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorObjectTree, label_size_group);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_hierarchy_changed);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_search_changed);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_row_activated);
|
||||
gtk_widget_class_bind_template_callback (widget_class, next_match);
|
||||
|
@ -1,7 +1,6 @@
|
||||
<interface domain="gtk40">
|
||||
<template class="GtkInspectorObjectTree" parent="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<signal name="hierarchy-changed" handler="on_hierarchy_changed"/>
|
||||
<child>
|
||||
<object class="GtkSearchBar" id="search_bar">
|
||||
<property name="show-close-button">1</property>
|
||||
|
@ -110,26 +110,31 @@ destroy_controller (GtkEventController *controller)
|
||||
}
|
||||
|
||||
static void
|
||||
hierarchy_changed (GtkWidget *widget,
|
||||
GtkWidget *previous_toplevel)
|
||||
root (GtkWidget *widget)
|
||||
{
|
||||
GtkEventController *controller;
|
||||
GtkWidget *toplevel;
|
||||
|
||||
if (previous_toplevel)
|
||||
g_object_set_data (G_OBJECT (previous_toplevel), "prop-controller", NULL);
|
||||
GTK_WIDGET_CLASS (gtk_inspector_prop_list_parent_class)->root (widget);
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (widget);
|
||||
|
||||
if (!GTK_IS_WINDOW (toplevel))
|
||||
return;
|
||||
|
||||
controller = gtk_event_controller_key_new ();
|
||||
g_object_set_data_full (G_OBJECT (toplevel), "prop-controller", controller, (GDestroyNotify)destroy_controller);
|
||||
g_signal_connect (controller, "key-pressed", G_CALLBACK (key_pressed), widget);
|
||||
gtk_widget_add_controller (toplevel, controller);
|
||||
}
|
||||
|
||||
static void
|
||||
unroot (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *toplevel;
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (widget);
|
||||
g_object_set_data (G_OBJECT (toplevel), "prop-controller", NULL);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_inspector_prop_list_parent_class)->unroot (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_prop_list_init (GtkInspectorPropList *pl)
|
||||
{
|
||||
@ -292,6 +297,9 @@ gtk_inspector_prop_list_class_init (GtkInspectorPropListClass *klass)
|
||||
object_class->set_property = set_property;
|
||||
object_class->constructed = constructed;
|
||||
|
||||
widget_class->root = root;
|
||||
widget_class->unroot = unroot;
|
||||
|
||||
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));
|
||||
@ -309,7 +317,6 @@ gtk_inspector_prop_list_class_init (GtkInspectorPropListClass *klass)
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorPropList, tree);
|
||||
gtk_widget_class_bind_template_callback (widget_class, row_activated);
|
||||
gtk_widget_class_bind_template_callback (widget_class, search_close_clicked);
|
||||
gtk_widget_class_bind_template_callback (widget_class, hierarchy_changed);
|
||||
}
|
||||
|
||||
/* Like g_strdup_value_contents, but keeps the type name separate */
|
||||
|
@ -12,7 +12,6 @@
|
||||
</object>
|
||||
<template class="GtkInspectorPropList" parent="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<signal name="hierarchy-changed" handler="hierarchy_changed"/>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="expand">1</property>
|
||||
|
@ -476,28 +476,33 @@ destroy_controller (GtkEventController *controller)
|
||||
}
|
||||
|
||||
static void
|
||||
on_hierarchy_changed (GtkWidget *widget,
|
||||
GtkWidget *previous_toplevel)
|
||||
root (GtkWidget *widget)
|
||||
{
|
||||
GtkInspectorResourceList *sl = GTK_INSPECTOR_RESOURCE_LIST (widget);
|
||||
GtkEventController *controller;
|
||||
GtkWidget *toplevel;
|
||||
|
||||
if (previous_toplevel)
|
||||
g_object_set_data (G_OBJECT (previous_toplevel), "resource-controller", NULL);
|
||||
GTK_WIDGET_CLASS (gtk_inspector_resource_list_parent_class)->root (widget);
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (widget);
|
||||
|
||||
if (!GTK_IS_WINDOW (toplevel))
|
||||
return;
|
||||
|
||||
controller = gtk_event_controller_key_new ();
|
||||
g_object_set_data_full (G_OBJECT (toplevel), "resource-controller", controller, (GDestroyNotify)destroy_controller);
|
||||
g_signal_connect (controller, "key-pressed", G_CALLBACK (key_pressed), widget);
|
||||
gtk_widget_add_controller (toplevel, controller);
|
||||
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (sl->priv->search_bar),
|
||||
toplevel);
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (sl->priv->search_bar), toplevel);
|
||||
}
|
||||
|
||||
static void
|
||||
unroot (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *toplevel;
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (widget);
|
||||
g_object_set_data (G_OBJECT (toplevel), "resource-controller", NULL);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_inspector_resource_list_parent_class)->unroot (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -705,6 +710,9 @@ gtk_inspector_resource_list_class_init (GtkInspectorResourceListClass *klass)
|
||||
object_class->constructed = constructed;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
widget_class->root = root;
|
||||
widget_class->unroot = unroot;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_BUTTONS,
|
||||
g_param_spec_object ("buttons", NULL, NULL,
|
||||
GTK_TYPE_WIDGET, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
@ -731,7 +739,6 @@ gtk_inspector_resource_list_class_init (GtkInspectorResourceListClass *klass)
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, row_activated);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_selection_changed);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_hierarchy_changed);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_search_changed);
|
||||
gtk_widget_class_bind_template_callback (widget_class, next_match);
|
||||
gtk_widget_class_bind_template_callback (widget_class, previous_match);
|
||||
|
@ -9,7 +9,6 @@
|
||||
</object>
|
||||
<object class="GtkTextBuffer" id="buffer"/>
|
||||
<template class="GtkInspectorResourceList" parent="GtkBox">
|
||||
<signal name="hierarchy-changed" handler="on_hierarchy_changed"/>
|
||||
<child>
|
||||
<object class="GtkStack" id="stack">
|
||||
<child>
|
||||
|
@ -327,28 +327,33 @@ destroy_controller (GtkEventController *controller)
|
||||
}
|
||||
|
||||
static void
|
||||
hierarchy_changed (GtkWidget *widget,
|
||||
GtkWidget *previous_toplevel)
|
||||
root (GtkWidget *widget)
|
||||
{
|
||||
GtkInspectorStatistics *sl = GTK_INSPECTOR_STATISTICS (widget);
|
||||
GtkEventController *controller;
|
||||
GtkWidget *toplevel;
|
||||
|
||||
if (previous_toplevel)
|
||||
g_object_set_data (G_OBJECT (previous_toplevel), "statistics-controller", NULL);
|
||||
GTK_WIDGET_CLASS (gtk_inspector_statistics_parent_class)->root (widget);
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (widget);
|
||||
|
||||
if (!GTK_IS_WINDOW (toplevel))
|
||||
return;
|
||||
|
||||
controller = gtk_event_controller_key_new ();
|
||||
g_object_set_data_full (G_OBJECT (toplevel), "statistics-controller", controller, (GDestroyNotify)destroy_controller);
|
||||
g_signal_connect (controller, "key-pressed", G_CALLBACK (key_pressed), widget);
|
||||
gtk_widget_add_controller (toplevel, controller);
|
||||
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (sl->priv->search_bar),
|
||||
toplevel);
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (sl->priv->search_bar), toplevel);
|
||||
}
|
||||
|
||||
static void
|
||||
unroot (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *toplevel;
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (widget);
|
||||
g_object_set_data (G_OBJECT (toplevel), "statistics-controller", NULL);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_inspector_statistics_parent_class)->unroot (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -376,7 +381,6 @@ gtk_inspector_statistics_init (GtkInspectorStatistics *sl)
|
||||
|
||||
gtk_tree_view_set_search_entry (sl->priv->view, GTK_EDITABLE (sl->priv->search_entry));
|
||||
gtk_tree_view_set_search_equal_func (sl->priv->view, match_row, sl, NULL);
|
||||
g_signal_connect (sl, "hierarchy-changed", G_CALLBACK (hierarchy_changed), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -462,6 +466,9 @@ gtk_inspector_statistics_class_init (GtkInspectorStatisticsClass *klass)
|
||||
object_class->constructed = constructed;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
widget_class->root = root;
|
||||
widget_class->unroot = unroot;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_BUTTON,
|
||||
g_param_spec_object ("button", NULL, NULL,
|
||||
GTK_TYPE_WIDGET, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
Loading…
Reference in New Issue
Block a user