[gtk+] inspector: Small improvements to the resource tab
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] inspector: Small improvements to the resource tab
- Date: Sat, 11 Oct 2014 05:00:51 +0000 (UTC)
commit 7b20bb917fffc2e48312c0463ac4251c75c36211
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Oct 11 00:58:47 2014 -0400
inspector: Small improvements to the resource tab
Move the close button to the header bar and center the info grid.
gtk/inspector/resource-list.c | 101 +++++++++++++++++++++++++++++++++++++++-
gtk/inspector/resource-list.ui | 24 +---------
gtk/inspector/window.c | 4 +-
gtk/inspector/window.h | 2 +-
gtk/inspector/window.ui | 24 +++++++++-
gtk/inspector/window.ui.h | 1 +
6 files changed, 127 insertions(+), 29 deletions(-)
---
diff --git a/gtk/inspector/resource-list.c b/gtk/inspector/resource-list.c
index 928a8d5..59ecdd6 100644
--- a/gtk/inspector/resource-list.c
+++ b/gtk/inspector/resource-list.c
@@ -28,6 +28,12 @@
enum
{
+ PROP_0,
+ PROP_CLOSE_DETAILS_BUTTON
+};
+
+enum
+{
COLUMN_NAME,
COLUMN_PATH,
COLUMN_COUNT,
@@ -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
@@ -219,6 +227,21 @@ close_details (GtkWidget *button,
}
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)
{
gint count = 0;
@@ -274,25 +297,100 @@ on_map (GtkWidget *widget)
}
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:
diff --git a/gtk/inspector/resource-list.ui b/gtk/inspector/resource-list.ui
index 299ac1f..3ad78bf 100644
--- a/gtk/inspector/resource-list.ui
+++ b/gtk/inspector/resource-list.ui
@@ -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>
diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c
index d47adfd..d853938 100644
--- a/gtk/inspector/window.c
+++ b/gtk/inspector/window.c
@@ -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);
diff --git a/gtk/inspector/window.h b/gtk/inspector/window.h
index 7801ee8..f3ad51b 100644
--- a/gtk/inspector/window.h
+++ b/gtk/inspector/window.h
@@ -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;
diff --git a/gtk/inspector/window.ui b/gtk/inspector/window.ui
index 07bbec7..e8f47ea 100644
--- a/gtk/inspector/window.ui
+++ b/gtk/inspector/window.ui
@@ -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>
diff --git a/gtk/inspector/window.ui.h b/gtk/inspector/window.ui.h
index 57143ed..98870a8 100644
--- a/gtk/inspector/window.ui.h
+++ b/gtk/inspector/window.ui.h
@@ -1,5 +1,6 @@
N_("Select an Object");
N_("Show all Objects");
+N_("Show all Resources");
N_("Miscellaneous");
N_("Properties");
N_("Signals");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]