summaryrefslogtreecommitdiff
path: root/src/summary.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-12-04 16:52:52 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2007-12-04 16:52:52 +0000
commitf3ba4a775af355dae3511470ad46e2111418dde8 (patch)
tree3a5b4981d1caec06dc50c8c9c90d6f35e94f4277 /src/summary.c
parent87ed08fb805a6af242b5563f1a34f5d93c7ca173 (diff)
Add an initial client summary.
Diffstat (limited to 'src/summary.c')
-rw-r--r--src/summary.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/summary.c b/src/summary.c
new file mode 100644
index 0000000..44167fe
--- /dev/null
+++ b/src/summary.c
@@ -0,0 +1,106 @@
+/*
+ This file is part of odin, a memory profiler with fragmentation analysis.
+
+ Copyright (C) 2007 Chris Wilson <chris@chris-wilson.co.uk>
+
+ odin is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 3 of the
+ License, or (at your option) any later version.
+
+ odin is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with odin. If not, see <http://www.gnu.org/licenses/>/
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#include <gtk/gtk.h>
+
+#include "odin.h"
+#include "client.h"
+#include "allocators.h"
+
+struct _summary {
+ GtkFrame bin;
+
+ AllocatorsStore *store;
+};
+
+typedef struct _summary_class {
+ GtkFrameClass parent_class;
+} SummaryClass;
+
+static GType
+summary_get_type (void);
+
+G_DEFINE_TYPE (Summary, summary, GTK_TYPE_FRAME)
+
+static void
+summary_class_init (SummaryClass *klass)
+{
+}
+
+static void
+summary_init (Summary *self)
+{
+ GtkWidget *w, *sw;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+
+ self->store = allocators_store_new ();
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_container_add (GTK_CONTAINER (self), sw);
+ gtk_widget_show (sw);
+
+ w = gtk_tree_view_new_with_model ((GtkTreeModel *) self->store);
+ gtk_container_add (GTK_CONTAINER (sw), w);
+ gtk_widget_show (w);
+
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer),
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ "ellipsize-set", TRUE,
+ "width-chars", 50,
+ NULL);
+ column = gtk_tree_view_column_new_with_attributes ("Allocator",
+ renderer, "text", ALLOCATORS_FRAME, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (w), column);
+
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes ("Bytes",
+ renderer, NULL);
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column), renderer,
+ cell_layout_pretty_print_uint64, GUINT_TO_POINTER (ALLOCATORS_SIZE),
+ NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (w), column);
+
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes ("Count",
+ renderer, NULL);
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column), renderer,
+ cell_layout_pretty_print_uint, GUINT_TO_POINTER (ALLOCATORS_COUNT),
+ NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (w), column);
+
+}
+
+GtkWidget *
+summary_new (void)
+{
+ return g_object_new (summary_get_type (), NULL);
+}
+
+void
+summary_update (Summary *summary, Client *client)
+{
+ allocators_store_update_from_allocators (summary->store,
+ client->allocators);
+}