mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-17 06:10:15 +00:00
inspector: Reserve space for buttons
Make the button area in the top left a stack that is parallel to the main page stack. This avoids size changes as we switch between pages.
This commit is contained in:
parent
e2949e7bf7
commit
713d3834f6
@ -303,19 +303,6 @@ close_details (GtkWidget *button,
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->buttons), "list");
|
||||
}
|
||||
|
||||
static void
|
||||
visible_child_name_changed (GObject *obj, GParamSpec *pspec, GtkInspectorResourceList *sl)
|
||||
{
|
||||
const gchar *child;
|
||||
gboolean resources_visible;
|
||||
|
||||
child = gtk_stack_get_visible_child_name (GTK_STACK (gtk_widget_get_parent (GTK_WIDGET (sl))));
|
||||
resources_visible = g_strcmp0 (child, "resources") == 0;
|
||||
|
||||
gtk_widget_set_visible (sl->priv->buttons, resources_visible);
|
||||
gtk_widget_set_sensitive (sl->priv->open_details_button, can_show_details (sl));
|
||||
}
|
||||
|
||||
static void
|
||||
load_resources (GtkInspectorResourceList *sl)
|
||||
{
|
||||
@ -369,15 +356,7 @@ on_map (GtkWidget *widget)
|
||||
|
||||
gtk_tree_view_expand_all (GTK_TREE_VIEW (sl->priv->tree));
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "list");
|
||||
}
|
||||
|
||||
static void
|
||||
parent_set (GtkWidget *widget, GtkWidget *old_parent)
|
||||
{
|
||||
if (old_parent)
|
||||
g_signal_handlers_disconnect_by_func (old_parent, visible_child_name_changed, widget);
|
||||
g_signal_connect (gtk_widget_get_parent (widget), "notify::visible-child-name",
|
||||
G_CALLBACK (visible_child_name_changed), widget);
|
||||
gtk_widget_set_sensitive (sl->priv->open_details_button, can_show_details (sl));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -600,8 +579,6 @@ gtk_inspector_resource_list_init (GtkInspectorResourceList *sl)
|
||||
size_data_func, sl, NULL);
|
||||
|
||||
g_signal_connect (sl, "map", G_CALLBACK (on_map), NULL);
|
||||
g_signal_connect (sl->priv->stack, "notify::visible-child-name",
|
||||
G_CALLBACK (visible_child_name_changed), sl);
|
||||
|
||||
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (sl->priv->search_bar),
|
||||
GTK_ENTRY (sl->priv->search_entry));
|
||||
@ -687,8 +664,6 @@ gtk_inspector_resource_list_class_init (GtkInspectorResourceListClass *klass)
|
||||
object_class->constructed = constructed;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
widget_class->parent_set = parent_set;
|
||||
|
||||
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));
|
||||
|
@ -244,27 +244,6 @@ type_data_free (gpointer data)
|
||||
g_free (type_data);
|
||||
}
|
||||
|
||||
static void
|
||||
visible_child_name_changed (GObject *obj, GParamSpec *pspec, GtkInspectorStatistics *sl)
|
||||
{
|
||||
const gchar *child;
|
||||
gboolean visible;
|
||||
|
||||
child = gtk_stack_get_visible_child_name (GTK_STACK (gtk_widget_get_parent (GTK_WIDGET (sl))));
|
||||
visible = g_strcmp0 (child, "statistics") == 0;
|
||||
|
||||
gtk_widget_set_visible (sl->priv->button, visible);
|
||||
}
|
||||
|
||||
static void
|
||||
parent_set (GtkWidget *widget, GtkWidget *old_parent)
|
||||
{
|
||||
if (old_parent)
|
||||
g_signal_handlers_disconnect_by_func (old_parent, visible_child_name_changed, widget);
|
||||
g_signal_connect (gtk_widget_get_parent (widget), "notify::visible-child-name",
|
||||
G_CALLBACK (visible_child_name_changed), widget);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
key_press_event (GtkWidget *window,
|
||||
GdkEvent *event,
|
||||
@ -452,8 +431,6 @@ gtk_inspector_statistics_class_init (GtkInspectorStatisticsClass *klass)
|
||||
object_class->constructed = constructed;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
widget_class->parent_set = parent_set;
|
||||
|
||||
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));
|
||||
|
@ -126,30 +126,12 @@ open_object_details (GtkWidget *button, GtkInspectorWindow *iw)
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_buttons), "details");
|
||||
}
|
||||
|
||||
static void
|
||||
visible_child_name_changed (GObject *obj, GParamSpec *pspec, GtkInspectorWindow *iw)
|
||||
{
|
||||
const gchar *child;
|
||||
gboolean objects_visible;
|
||||
|
||||
child = gtk_stack_get_visible_child_name (GTK_STACK (iw->top_stack));
|
||||
objects_visible = g_strcmp0 (child, "objects") == 0;
|
||||
|
||||
gtk_widget_set_visible (iw->select_object, objects_visible);
|
||||
gtk_widget_set_visible (iw->object_buttons, objects_visible);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_window_init (GtkInspectorWindow *iw)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (iw));
|
||||
|
||||
gtk_window_group_add_window (gtk_window_group_new (), GTK_WINDOW (iw));
|
||||
|
||||
g_signal_connect (iw->top_stack, "notify::visible-child-name",
|
||||
G_CALLBACK (visible_child_name_changed), iw);
|
||||
g_signal_connect (iw->object_stack, "notify::visible-child-name",
|
||||
G_CALLBACK (visible_child_name_changed), iw);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -9,34 +9,40 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="show-close-button">True</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="select_object">
|
||||
<object class="GtkStack" id="button_stack">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip-text" translatable="yes">Select an Object</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<signal name="clicked" handler="gtk_inspector_on_inspect"/>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<property name="visible-child-name" bind-source="top_stack" bind-property="visible-child-name"/>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">find-location-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">start</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStack" id="object_buttons">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="object_details_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip-text" translatable="yes">Show Details</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="select_object">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip-text" translatable="yes">Select an Object</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<signal name="clicked" handler="gtk_inspector_on_inspect"/>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">find-location-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStack" id="object_buttons">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="object_details_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip-text" translatable="yes">Show Details</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<signal name="clicked" handler="open_object_details"/>
|
||||
@ -77,15 +83,18 @@
|
||||
<property name="name">details</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">start</property>
|
||||
<property name="name">objects</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="record_statistics_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip-text" translatable="yes">Collect Statistics</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
@ -99,11 +108,14 @@
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">start</property>
|
||||
<property name="name">statistics</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStack" id="resource_buttons">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
@ -148,9 +160,38 @@
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">start</property>
|
||||
<property name="name">resources</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">css</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">visual</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">general</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">start</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child type="title">
|
||||
<object class="GtkStackSwitcher">
|
||||
<property name="visible">True</property>
|
||||
|
Loading…
Reference in New Issue
Block a user