[gtk+] inspector: Build out the resource information
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] inspector: Build out the resource information
- Date: Mon, 19 May 2014 11:29:15 +0000 (UTC)
commit c665564374de33c95023b86ec85a7654901ba240
Author: Matthias Clasen <mclasen redhat com>
Date: Mon May 19 07:10:33 2014 -0400
inspector: Build out the resource information
Show type and size for each resource.
gtk/inspector/resource-list.c | 28 +++++++++--
gtk/inspector/resource-list.ui | 113 ++++++++++++++++++++++++++++++---------
2 files changed, 111 insertions(+), 30 deletions(-)
---
diff --git a/gtk/inspector/resource-list.c b/gtk/inspector/resource-list.c
index 7727820..d08bfbb 100644
--- a/gtk/inspector/resource-list.c
+++ b/gtk/inspector/resource-list.c
@@ -31,6 +31,9 @@ struct _GtkInspectorResourceListPrivate
GtkTextBuffer *buffer;
GtkWidget *image;
GtkWidget *content;
+ GtkWidget *type_label;
+ GtkWidget *size_label;
+ GtkWidget *info_grid;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorResourceList, gtk_inspector_resource_list, GTK_TYPE_BOX)
@@ -89,9 +92,12 @@ selection_changed (GtkTreeSelection *selection,
gsize size;
GError *error = NULL;
+ gtk_widget_hide (rl->priv->info_grid);
+
gtk_tree_model_get (GTK_TREE_MODEL (rl->priv->model), &iter,
COLUMN_PATH, &path,
-1);
+
if (g_str_has_suffix (path, "/"))
{
gtk_text_buffer_set_text (rl->priv->buffer, "", -1);
@@ -107,8 +113,21 @@ selection_changed (GtkTreeSelection *selection,
}
else
{
+ gchar *text;
+
data = g_bytes_get_data (bytes, &size);
type = g_content_type_guess (NULL, data, size, NULL);
+
+ text = g_content_type_get_description (type);
+ gtk_label_set_text (GTK_LABEL (rl->priv->type_label), text);
+ g_free (text);
+
+ text = g_format_size (size);
+ gtk_label_set_text (GTK_LABEL (rl->priv->size_label), text);
+ g_free (text);
+
+ gtk_widget_show (rl->priv->info_grid);
+
if (g_content_type_is_a (type, "text/*"))
{
gtk_text_buffer_set_text (rl->priv->buffer, data, -1);
@@ -121,12 +140,10 @@ selection_changed (GtkTreeSelection *selection,
}
else
{
- gchar *content;
- content = g_content_type_get_description (type);
- gtk_text_buffer_set_text (rl->priv->buffer, content, -1);
- g_free (content);
+ gtk_text_buffer_set_text (rl->priv->buffer, "", 0);
gtk_stack_set_visible_child_name (GTK_STACK (rl->priv->content), "text");
}
+
g_free (type);
g_bytes_unref (bytes);
}
@@ -165,6 +182,9 @@ gtk_inspector_resource_list_class_init (GtkInspectorResourceListClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, buffer);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, content);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, image);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, type_label);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, size_label);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, info_grid);
gtk_widget_class_bind_template_callback (widget_class, selection_changed);
}
diff --git a/gtk/inspector/resource-list.ui b/gtk/inspector/resource-list.ui
index a7226b9..46f3f05 100644
--- a/gtk/inspector/resource-list.ui
+++ b/gtk/inspector/resource-list.ui
@@ -7,7 +7,7 @@
</columns>
</object>
<object class="GtkTextBuffer" id="buffer">
- <property name="text"></property>
+ <property name="text"/>
</object>
<template class="GtkInspectorResourceList" parent="GtkBox">
<property name="orientation">horizontal</property>
@@ -19,7 +19,7 @@
<property name="vscrollbar-policy">always</property>
<property name="shadow-type">in</property>
<child>
- <object class= "GtkTreeView">
+ <object class="GtkTreeView">
<property name="visible">True</property>
<property name="model">model</property>
<child internal-child="selection">
@@ -46,45 +46,106 @@
</object>
</child>
<child>
- <object class="GtkStack" id="content">
+ <object class="GtkBox">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkScrolledWindow">
- <property name="visible">True</property>
- <property name="expand">True</property>
- <property name="hscrollbar-policy">automatic</property>
- <property name="vscrollbar-policy">automatic</property>
- <property name="shadow-type">in</property>
+ <object class="GtkGrid" id="info_grid">
+ <property name="row-spacing">10</property>
+ <property name="column-spacing">10</property>
+ <property name="margin">20</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Type:</property>
+ <property name="halign">end</property>
+ <property name="valign">baseline</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="type_label">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="valign">baseline</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
<child>
- <object class="GtkTextView">
+ <object class="GtkLabel">
<property name="visible">True</property>
- <property name="editable">False</property>
- <property name="buffer">buffer</property>
+ <property name="label" translatable="yes">Size:</property>
+ <property name="halign">end</property>
+ <property name="valign">baseline</property>
</object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="size_label">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="valign">baseline</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">1</property>
+ </packing>
</child>
</object>
- <packing>
- <property name="name">text</property>
- </packing>
</child>
<child>
- <object class="GtkScrolledWindow">
+ <object class="GtkStack" id="content">
<property name="visible">True</property>
- <property name="expand">True</property>
- <property name="hscrollbar-policy">automatic</property>
- <property name="vscrollbar-policy">automatic</property>
- <property name="shadow-type">in</property>
<child>
- <object class="GtkImage" id="image">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
+ <property name="expand">True</property>
+ <property name="hscrollbar-policy">automatic</property>
+ <property name="vscrollbar-policy">automatic</property>
+ <property name="shadow-type">in</property>
+ <child>
+ <object class="GtkTextView">
+ <property name="visible">True</property>
+ <property name="margin">20</property>
+ <property name="editable">False</property>
+ <property name="buffer">buffer</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="name">text</property>
+ </packing>
+ </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">automatic</property>
+ <property name="shadow-type">in</property>
+ <child>
+ <object class="GtkImage" id="image">
+ <property name="visible">True</property>
+ <property name="margin">20</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ </object>
+ </child>
</object>
+ <packing>
+ <property name="name">image</property>
+ </packing>
</child>
</object>
- <packing>
- <property name="name">image</property>
- </packing>
</child>
</object>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]