1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
/*
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 "procmap.h"
#define _(x) x
struct _procmap {
GtkTreeView tv;
};
typedef struct _procmap_class {
GtkTreeViewClass parent_class;
} ProcmapClass;
static GType
procmap_get_type (void);
G_DEFINE_TYPE (Procmap, procmap, GTK_TYPE_TREE_VIEW)
static void
procmap_set_property (GObject *obj, guint id, const GValue *v, GParamSpec *spec)
{
Procmap *self = (Procmap *) obj;
switch (id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, spec);
break;
}
}
static void
procmap_get_property (GObject *obj, guint id, GValue *v, GParamSpec *spec)
{
Procmap *self = (Procmap *) obj;
switch (id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, spec);
break;
}
}
static void
procmap_class_init (ProcmapClass *klass)
{
GObjectClass *object_class = (GObjectClass *) klass;
GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
object_class->set_property = procmap_set_property;
object_class->get_property = procmap_get_property;
}
static void
procmap_init (Procmap *self)
{
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
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 ("Filename",
renderer, "text", PROCMAP_FILENAME, NULL);
gtk_tree_view_append_column (&self->tv, column);
renderer = gtk_cell_renderer_text_new ();
g_object_set (G_OBJECT (renderer),
"width-chars", 5,
NULL);
column = gtk_tree_view_column_new_with_attributes ("Mode",
renderer, "text", PROCMAP_MODE, NULL);
gtk_tree_view_append_column (&self->tv, column);
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Start",
renderer, "text", PROCMAP_START, NULL);
gtk_tree_view_column_set_sort_column_id (column, PROCMAP_START);
gtk_tree_view_append_column (&self->tv, column);
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("End",
renderer, "text", PROCMAP_END, NULL);
gtk_tree_view_append_column (&self->tv, column);
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Offset",
renderer, "text", PROCMAP_OFFSET, NULL);
gtk_tree_view_append_column (&self->tv, column);
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Size",
renderer, NULL);
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column), renderer,
cell_layout_pretty_print_uint, GUINT_TO_POINTER (PROCMAP_SIZE),
NULL);
gtk_tree_view_column_set_sort_column_id (column, PROCMAP_SIZE);
gtk_tree_view_append_column (&self->tv, column);
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("RSS",
renderer, NULL);
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column), renderer,
cell_layout_pretty_print_uint, GUINT_TO_POINTER (PROCMAP_RSS),
NULL);
gtk_tree_view_column_set_sort_column_id (column, PROCMAP_RSS);
gtk_tree_view_append_column (&self->tv, column);
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Dirty",
renderer, NULL);
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column), renderer,
cell_layout_pretty_print_uint, GUINT_TO_POINTER (PROCMAP_PRIVATE_DIRTY),
NULL);
gtk_tree_view_column_set_sort_column_id (column, PROCMAP_PRIVATE_DIRTY);
gtk_tree_view_append_column (&self->tv, column);
gtk_tree_view_set_grid_lines (&self->tv, GTK_TREE_VIEW_GRID_LINES_VERTICAL);
//gtk_widget_set_has_tooltip (GTK_WIDGET (self), TRUE);
}
GtkWidget *
procmap_new (void)
{
return g_object_new (procmap_get_type(),
/* insert a dummy model */
"model", procmap_store_new (0),
NULL);
}
|