inspector: Small improvements to the resource tab
Move the close button to the header bar and center the info grid.
This commit is contained in:
@@ -26,6 +26,12 @@
|
||||
#include "gtktreestore.h"
|
||||
#include "gtktreeselection.h"
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_CLOSE_DETAILS_BUTTON
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
COLUMN_NAME,
|
||||
@@ -47,12 +53,14 @@ struct _GtkInspectorResourceListPrivate
|
||||
GtkWidget *info_grid;
|
||||
GtkWidget *stack;
|
||||
GtkWidget *tree;
|
||||
GtkWidget *close_details_button;
|
||||
GtkTreeViewColumn *count_column;
|
||||
GtkCellRenderer *count_renderer;
|
||||
GtkTreeViewColumn *size_column;
|
||||
GtkCellRenderer *size_renderer;
|
||||
};
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorResourceList, gtk_inspector_resource_list, GTK_TYPE_BOX)
|
||||
|
||||
static void
|
||||
@@ -218,6 +226,21 @@ close_details (GtkWidget *button,
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "list");
|
||||
}
|
||||
|
||||
static void
|
||||
visible_child_name_changed (GObject *obj, GParamSpec *pspec, GtkInspectorResourceList *sl)
|
||||
{
|
||||
const gchar *child;
|
||||
gboolean resources_visible;
|
||||
gboolean resource_details_visible;
|
||||
|
||||
child = gtk_stack_get_visible_child_name (GTK_STACK (gtk_widget_get_parent (GTK_WIDGET (sl))));
|
||||
resources_visible = g_strcmp0 (child, "resources") == 0;
|
||||
child = gtk_stack_get_visible_child_name (GTK_STACK (sl->priv->stack));
|
||||
resource_details_visible = g_strcmp0 (child, "details") == 0;
|
||||
|
||||
gtk_widget_set_visible (sl->priv->close_details_button, resources_visible && resource_details_visible);
|
||||
}
|
||||
|
||||
static void
|
||||
load_resources (GtkInspectorResourceList *sl)
|
||||
{
|
||||
@@ -273,26 +296,101 @@ on_map (GtkWidget *widget)
|
||||
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);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_resource_list_init (GtkInspectorResourceList *sl)
|
||||
{
|
||||
sl->priv = gtk_inspector_resource_list_get_instance_private (sl);
|
||||
|
||||
gtk_widget_init_template (GTK_WIDGET (sl));
|
||||
|
||||
gtk_tree_view_column_set_cell_data_func (sl->priv->count_column,
|
||||
sl->priv->count_renderer,
|
||||
count_data_func, sl, NULL);
|
||||
gtk_tree_view_column_set_cell_data_func (sl->priv->size_column,
|
||||
sl->priv->size_renderer,
|
||||
size_data_func, sl, NULL);
|
||||
|
||||
g_signal_connect (sl, "map", G_CALLBACK (on_map), NULL);
|
||||
load_resources (sl);
|
||||
g_signal_connect (sl->priv->stack, "notify::visible-child-name",
|
||||
G_CALLBACK (visible_child_name_changed), sl);
|
||||
}
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
GtkInspectorResourceList *rl = GTK_INSPECTOR_RESOURCE_LIST (object);
|
||||
|
||||
g_signal_connect (rl->priv->close_details_button, "clicked",
|
||||
G_CALLBACK (close_details), rl);
|
||||
|
||||
load_resources (rl);
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkInspectorResourceList *rl = GTK_INSPECTOR_RESOURCE_LIST (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_CLOSE_DETAILS_BUTTON:
|
||||
g_value_take_object (value, rl->priv->close_details_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)
|
||||
{
|
||||
GtkInspectorResourceList *rl = GTK_INSPECTOR_RESOURCE_LIST (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_CLOSE_DETAILS_BUTTON:
|
||||
rl->priv->close_details_button = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_resource_list_class_init (GtkInspectorResourceListClass *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;
|
||||
|
||||
widget_class->parent_set = parent_set;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_CLOSE_DETAILS_BUTTON,
|
||||
g_param_spec_object ("close-details-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/resource-list.ui");
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, model);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, buffer);
|
||||
@@ -311,7 +409,6 @@ gtk_inspector_resource_list_class_init (GtkInspectorResourceListClass *klass)
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, tree);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, row_activated);
|
||||
gtk_widget_class_bind_template_callback (widget_class, close_details);
|
||||
}
|
||||
|
||||
// vim: set et sw=2 ts=2:
|
||||
|
||||
@@ -87,6 +87,7 @@
|
||||
<property name="row-spacing">10</property>
|
||||
<property name="column-spacing">10</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="halign">center</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="name">
|
||||
<property name="visible">True</property>
|
||||
@@ -157,29 +158,6 @@
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">start</property>
|
||||
<signal name="clicked" handler="close_details"/>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">window-close-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">-1</property>
|
||||
<property name="top-attach">0</property>
|
||||
<property name="height">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
||||
@@ -110,7 +110,7 @@ visible_child_name_changed (GObject *obj, GParamSpec *pspec, GtkInspectorWindow
|
||||
object_details_visible = g_strcmp0 (child, "object-details") == 0;
|
||||
|
||||
gtk_widget_set_visible (iw->select_object, objects_visible);
|
||||
gtk_widget_set_visible (iw->close_details, objects_visible && object_details_visible);
|
||||
gtk_widget_set_visible (iw->close_object_details, objects_visible && object_details_visible);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -150,7 +150,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_stack);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_tree);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_details);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, close_details);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, close_object_details);
|
||||
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);
|
||||
|
||||
@@ -46,7 +46,7 @@ typedef struct
|
||||
GtkWidget *object_tree;
|
||||
GtkWidget *object_id;
|
||||
GtkWidget *object_details;
|
||||
GtkWidget *close_details;
|
||||
GtkWidget *close_object_details;
|
||||
GtkWidget *select_object;
|
||||
GtkWidget *prop_list;
|
||||
GtkWidget *child_prop_list;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="close_details">
|
||||
<object class="GtkButton" id="close_object_details">
|
||||
<property name="tooltip-text" translatable="yes">Show all Objects</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
@@ -51,6 +51,27 @@
|
||||
<property name="pack-type">start</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="close_resource_details">
|
||||
<property name="tooltip-text" translatable="yes">Show all Resources</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<signal name="clicked" handler="close_details"/>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">view-list-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">start</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child type="title">
|
||||
<object class="GtkStackSwitcher">
|
||||
<property name="visible">True</property>
|
||||
@@ -231,6 +252,7 @@
|
||||
<child>
|
||||
<object class="GtkInspectorResourceList">
|
||||
<property name="visible">True</property>
|
||||
<property name="close-details-button">close_resource_details</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">resources</property>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
N_("Select an Object");
|
||||
N_("Show all Objects");
|
||||
N_("Show all Resources");
|
||||
N_("Miscellaneous");
|
||||
N_("Properties");
|
||||
N_("Signals");
|
||||
|
||||
Reference in New Issue
Block a user