forked from AuroraMiddleware/gtk
inspector: Move the record button up
Give all the page space to the content.
This commit is contained in:
parent
1ddace0a5f
commit
5f701cf4c9
@ -26,6 +26,12 @@
|
||||
#include "gtkcellrenderertext.h"
|
||||
#include "gtkcelllayout.h"
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_BUTTON
|
||||
};
|
||||
|
||||
struct _GtkInspectorStatisticsPrivate
|
||||
{
|
||||
GtkWidget *stack;
|
||||
@ -137,13 +143,13 @@ update_type_counts (gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_record (GtkToggleToolButton *button,
|
||||
toggle_record (GtkToggleButton *button,
|
||||
GtkInspectorStatistics *sl)
|
||||
{
|
||||
if (gtk_toggle_tool_button_get_active (button) == (sl->priv->update_source_id != 0))
|
||||
if (gtk_toggle_button_get_active (button) == (sl->priv->update_source_id != 0))
|
||||
return;
|
||||
|
||||
if (gtk_toggle_tool_button_get_active (button))
|
||||
if (gtk_toggle_button_get_active (button))
|
||||
{
|
||||
sl->priv->update_source_id = gdk_threads_add_timeout_seconds (1,
|
||||
update_type_counts,
|
||||
@ -235,6 +241,27 @@ 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 void
|
||||
gtk_inspector_statistics_init (GtkInspectorStatistics *sl)
|
||||
{
|
||||
@ -264,6 +291,20 @@ gtk_inspector_statistics_init (GtkInspectorStatistics *sl)
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "excuse");
|
||||
}
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
GtkInspectorStatistics *sl = GTK_INSPECTOR_STATISTICS (object);
|
||||
|
||||
g_signal_connect (sl->priv->button, "toggled",
|
||||
G_CALLBACK (toggle_record), sl);
|
||||
|
||||
if (has_instance_counts ())
|
||||
update_type_counts (sl);
|
||||
else
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "excuse");
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
@ -277,14 +318,63 @@ finalize (GObject *object)
|
||||
G_OBJECT_CLASS (gtk_inspector_statistics_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkInspectorStatistics *sl = GTK_INSPECTOR_STATISTICS (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_BUTTON:
|
||||
g_value_take_object (value, sl->priv->button);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkInspectorStatistics *sl = GTK_INSPECTOR_STATISTICS (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_BUTTON:
|
||||
sl->priv->button = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_statistics_class_init (GtkInspectorStatisticsClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
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));
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/statistics.ui");
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, view);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, stack);
|
||||
@ -297,8 +387,6 @@ gtk_inspector_statistics_class_init (GtkInspectorStatisticsClass *klass)
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, renderer_self2);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, column_cumulative2);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, renderer_cumulative2);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, button);
|
||||
gtk_widget_class_bind_template_callback (widget_class, toggle_record);
|
||||
}
|
||||
|
||||
// vim: set et sw=2 ts=2:
|
||||
|
@ -22,27 +22,12 @@
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkToolbar" id="toolbar">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-size">small-toolbar</property>
|
||||
<child>
|
||||
<object class="GtkToggleToolButton" id="button">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">media-record-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Collect Statistics</property>
|
||||
<signal name="toggled" handler="toggle_record"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="hscrollbar-policy">automatic</property>
|
||||
<property name="vscrollbar-policy">always</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="view">
|
||||
<property name="visible">True</property>
|
||||
|
@ -1,4 +1,3 @@
|
||||
N_("Collect Statistics");
|
||||
N_("Type");
|
||||
N_("Self 1");
|
||||
N_("Cumulative 1");
|
||||
@ -6,6 +5,4 @@ N_("Self 2");
|
||||
N_("Cumulative 2");
|
||||
N_("Self");
|
||||
N_("Cumulative");
|
||||
N_("Self");
|
||||
N_("Cumulative");
|
||||
N_("Enable statistics with GOBJECT_DEBUG=instance-count");
|
||||
|
@ -82,6 +82,26 @@
|
||||
<property name="pack-type">start</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="record_statistics_button">
|
||||
<property name="tooltip-text" translatable="yes">Collect Statistics</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">media-record-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="resource_buttons">
|
||||
<child>
|
||||
@ -316,6 +336,7 @@
|
||||
<child>
|
||||
<object class="GtkInspectorStatistics">
|
||||
<property name="visible">True</property>
|
||||
<property name="button">record_statistics_button</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">statistics</property>
|
||||
|
@ -1,6 +1,7 @@
|
||||
N_("Select an Object");
|
||||
N_("Show Details");
|
||||
N_("Show all Objects");
|
||||
N_("Collect Statistics");
|
||||
N_("Show Details");
|
||||
N_("Show all Resources");
|
||||
N_("Miscellaneous");
|
||||
|
Loading…
Reference in New Issue
Block a user