diff options
author | Darren Hart <dvhltc@us.ibm.com> | 2009-12-28 23:41:35 -0500 |
---|---|---|
committer | Darren Hart <dvhltc@us.ibm.com> | 2009-12-30 12:22:41 -0500 |
commit | 9703124e36ad78a1484138dbe010d587aed5a60b (patch) | |
tree | f8ffcbcbffc1d512e93dca0a42eb390c4a2ddef5 | |
parent | 6d1b5fd541ec3358c39f08f80d316fee8346a60d (diff) |
trace-cmd: Use fixed sized rows and columns in event-viewer.py
Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
-rwxr-xr-x | event-viewer.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/event-viewer.py b/event-viewer.py index bbafff0..a8ccd5b 100755 --- a/event-viewer.py +++ b/event-viewer.py | |||
@@ -7,6 +7,14 @@ from tracecmd import * | |||
7 | app = None | 7 | app = None |
8 | data_func_cnt = 0 | 8 | data_func_cnt = 0 |
9 | 9 | ||
10 | # In a "real" app these width should be determined at runtime testing max length | ||
11 | # strings in the current font. | ||
12 | TS_COL_W = 150 | ||
13 | CPU_COL_W = 35 | ||
14 | EVENT_COL_W = 150 | ||
15 | PID_COL_W = 75 | ||
16 | COMM_COL_W = 250 | ||
17 | |||
10 | class EventStore(gtk.ListStore): | 18 | class EventStore(gtk.ListStore): |
11 | def __init__(self, trace): | 19 | def __init__(self, trace): |
12 | gtk.ListStore.__init__(self, gobject.TYPE_PYOBJECT) | 20 | gtk.ListStore.__init__(self, gobject.TYPE_PYOBJECT) |
@@ -27,32 +35,43 @@ class EventStore(gtk.ListStore): | |||
27 | class EventView(gtk.TreeView): | 35 | class EventView(gtk.TreeView): |
28 | def __init__(self, model): | 36 | def __init__(self, model): |
29 | gtk.TreeView.__init__(self, model) | 37 | gtk.TreeView.__init__(self, model) |
38 | self.set_fixed_height_mode(True) | ||
30 | 39 | ||
31 | ts_col = gtk.TreeViewColumn("Time (s)") | 40 | ts_col = gtk.TreeViewColumn("Time (s)") |
41 | ts_col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) | ||
42 | ts_col.set_fixed_width(TS_COL_W) | ||
32 | ts_cell = gtk.CellRendererText() | 43 | ts_cell = gtk.CellRendererText() |
33 | ts_col.pack_start(ts_cell, False) | 44 | ts_col.pack_start(ts_cell, False) |
34 | ts_col.set_cell_data_func(ts_cell, self.data_func, "ts") | 45 | ts_col.set_cell_data_func(ts_cell, self.data_func, "ts") |
35 | self.append_column(ts_col) | 46 | self.append_column(ts_col) |
36 | 47 | ||
37 | cpu_col = gtk.TreeViewColumn("CPU") | 48 | cpu_col = gtk.TreeViewColumn("CPU") |
49 | cpu_col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) | ||
50 | cpu_col.set_fixed_width(CPU_COL_W) | ||
38 | cpu_cell = gtk.CellRendererText() | 51 | cpu_cell = gtk.CellRendererText() |
39 | cpu_col.pack_start(cpu_cell, False) | 52 | cpu_col.pack_start(cpu_cell, False) |
40 | cpu_col.set_cell_data_func(cpu_cell, self.data_func, "cpu") | 53 | cpu_col.set_cell_data_func(cpu_cell, self.data_func, "cpu") |
41 | self.append_column(cpu_col) | 54 | self.append_column(cpu_col) |
42 | 55 | ||
43 | event_col = gtk.TreeViewColumn("Event") | 56 | event_col = gtk.TreeViewColumn("Event") |
57 | event_col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) | ||
58 | event_col.set_fixed_width(EVENT_COL_W) | ||
44 | event_cell = gtk.CellRendererText() | 59 | event_cell = gtk.CellRendererText() |
45 | event_col.pack_start(event_cell, False) | 60 | event_col.pack_start(event_cell, False) |
46 | event_col.set_cell_data_func(event_cell, self.data_func, "event") | 61 | event_col.set_cell_data_func(event_cell, self.data_func, "event") |
47 | self.append_column(event_col) | 62 | self.append_column(event_col) |
48 | 63 | ||
49 | pid_col = gtk.TreeViewColumn("PID") | 64 | pid_col = gtk.TreeViewColumn("PID") |
65 | pid_col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) | ||
66 | pid_col.set_fixed_width(PID_COL_W) | ||
50 | pid_cell = gtk.CellRendererText() | 67 | pid_cell = gtk.CellRendererText() |
51 | pid_col.pack_start(pid_cell, False) | 68 | pid_col.pack_start(pid_cell, False) |
52 | pid_col.set_cell_data_func(pid_cell, self.data_func, "pid") | 69 | pid_col.set_cell_data_func(pid_cell, self.data_func, "pid") |
53 | self.append_column(pid_col) | 70 | self.append_column(pid_col) |
54 | 71 | ||
55 | comm_col = gtk.TreeViewColumn("Comm") | 72 | comm_col = gtk.TreeViewColumn("Comm") |
73 | comm_col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) | ||
74 | comm_col.set_fixed_width(COMM_COL_W) | ||
56 | comm_cell = gtk.CellRendererText() | 75 | comm_cell = gtk.CellRendererText() |
57 | comm_col.pack_start(comm_cell, False) | 76 | comm_col.pack_start(comm_cell, False) |
58 | comm_col.set_cell_data_func(comm_cell, self.data_func, "comm") | 77 | comm_col.set_cell_data_func(comm_cell, self.data_func, "comm") |
@@ -60,9 +79,6 @@ class EventView(gtk.TreeView): | |||
60 | 79 | ||
61 | def data_func(self, col, cell, model, iter, data): | 80 | def data_func(self, col, cell, model, iter, data): |
62 | global app, data_func_cnt | 81 | global app, data_func_cnt |
63 | data_func_cnt = data_func_cnt + 1 | ||
64 | if app: | ||
65 | app.inc_data_func() | ||
66 | 82 | ||
67 | ev = model.get_event(iter) | 83 | ev = model.get_event(iter) |
68 | if not ev: | 84 | if not ev: |
@@ -70,6 +86,9 @@ class EventView(gtk.TreeView): | |||
70 | if data == "ts": | 86 | if data == "ts": |
71 | cell.set_property("markup", "%d.%d" % (ev.ts/1000000000, | 87 | cell.set_property("markup", "%d.%d" % (ev.ts/1000000000, |
72 | ev.ts%1000000000)) | 88 | ev.ts%1000000000)) |
89 | data_func_cnt = data_func_cnt + 1 | ||
90 | if app: | ||
91 | app.inc_data_func() | ||
73 | return True | 92 | return True |
74 | if data == "cpu": | 93 | if data == "cpu": |
75 | cell.set_property("markup", ev.cpu) | 94 | cell.set_property("markup", ev.cpu) |
@@ -108,7 +127,7 @@ class EventViewerApp(gtk.Window): | |||
108 | # track how often the treeview data_func is called | 127 | # track how often the treeview data_func is called |
109 | self.data_func_label = gtk.Label("0") | 128 | self.data_func_label = gtk.Label("0") |
110 | hbox = gtk.HBox() | 129 | hbox = gtk.HBox() |
111 | hbox.pack_start(gtk.Label("Data Func Calls:"), False, False) | 130 | hbox.pack_start(gtk.Label("TS Data Func Calls:"), False, False) |
112 | hbox.pack_start(self.data_func_label, False, False) | 131 | hbox.pack_start(self.data_func_label, False, False) |
113 | 132 | ||
114 | vbox = gtk.VBox() | 133 | vbox = gtk.VBox() |