diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-01-07 17:36:49 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-01-07 17:36:49 -0500 |
commit | 6f8a3e5ab5a4b24364ab8e3bf36f3d0dad73dbf9 (patch) | |
tree | a988b341a03c4a7e346d452edf791010b83b38f3 | |
parent | cf09cc6e3cc4d8ccde399348fbbe4adb912c1ba0 (diff) |
tree-view: Have event filter list only expand rows not full or empty
The list of events for the event filters, now only expands the system
rows that are not full or empty. That is, if the system is checked
it is not expanded. If the system is not checked and has no events
checked, then it is not expanded.
But if the system is not checked, and there are events checked
(even all events) then the row is expanded.
This makes dealing with lots of events much easier.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | trace-filter.c | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/trace-filter.c b/trace-filter.c index ab30b1f..4d75fb5 100644 --- a/trace-filter.c +++ b/trace-filter.c | |||
@@ -280,6 +280,74 @@ static void event_cursor_changed(GtkTreeView *treeview, gpointer data) | |||
280 | gtk_tree_path_free(path); | 280 | gtk_tree_path_free(path); |
281 | } | 281 | } |
282 | 282 | ||
283 | static gboolean child_set(GtkTreeModel *model, GtkTreeIter *parent) | ||
284 | { | ||
285 | GtkTreeIter iter; | ||
286 | gboolean active; | ||
287 | |||
288 | if (!gtk_tree_model_iter_children(model, &iter, parent)) | ||
289 | return FALSE; | ||
290 | |||
291 | for (;;) { | ||
292 | |||
293 | gtk_tree_model_get(model, &iter, | ||
294 | COL_ACTIVE, &active, | ||
295 | -1); | ||
296 | |||
297 | if (active) | ||
298 | return TRUE; | ||
299 | |||
300 | if (!gtk_tree_model_iter_next(model, &iter)) | ||
301 | break; | ||
302 | } | ||
303 | |||
304 | return FALSE; | ||
305 | } | ||
306 | |||
307 | static void expand_rows(GtkTreeView *tree, GtkTreeModel *model, | ||
308 | gboolean all_events, | ||
309 | gchar **systems, gint *events) | ||
310 | { | ||
311 | GtkTreePath *path; | ||
312 | GtkTreeIter all; | ||
313 | GtkTreeIter sys; | ||
314 | gboolean active; | ||
315 | |||
316 | /* Expand the "All Events" row */ | ||
317 | path = gtk_tree_path_new_from_string("0"); | ||
318 | |||
319 | gtk_tree_view_expand_row(tree, path, FALSE); | ||
320 | |||
321 | gtk_tree_path_free(path); | ||
322 | |||
323 | if (all_events) | ||
324 | return; | ||
325 | |||
326 | /* Expand the system rows that are not full or empty */ | ||
327 | |||
328 | if (!gtk_tree_model_get_iter_first(model, &all)) | ||
329 | return; | ||
330 | |||
331 | if (!gtk_tree_model_iter_children(model, &sys, &all)) | ||
332 | return; | ||
333 | |||
334 | for (;;) { | ||
335 | |||
336 | gtk_tree_model_get(model, &sys, | ||
337 | COL_ACTIVE, &active, | ||
338 | -1); | ||
339 | |||
340 | if (!active && child_set(model, &sys)) { | ||
341 | path = gtk_tree_model_get_path(model, &sys); | ||
342 | gtk_tree_view_expand_row(tree, path, FALSE); | ||
343 | gtk_tree_path_free(path); | ||
344 | } | ||
345 | |||
346 | if (!gtk_tree_model_iter_next(model, &sys)) | ||
347 | break; | ||
348 | } | ||
349 | } | ||
350 | |||
283 | static GtkWidget * | 351 | static GtkWidget * |
284 | create_event_list_view(struct tracecmd_input *handle, | 352 | create_event_list_view(struct tracecmd_input *handle, |
285 | gboolean all_events, gchar **systems, | 353 | gboolean all_events, gchar **systems, |
@@ -319,8 +387,8 @@ create_event_list_view(struct tracecmd_input *handle, | |||
319 | 387 | ||
320 | gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), | 388 | gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), |
321 | GTK_SELECTION_NONE); | 389 | GTK_SELECTION_NONE); |
322 | 390 | ||
323 | gtk_tree_view_expand_all(GTK_TREE_VIEW(view)); | 391 | expand_rows(GTK_TREE_VIEW(view), model, all_events, systems, events); |
324 | 392 | ||
325 | g_signal_connect_swapped (view, "cursor-changed", | 393 | g_signal_connect_swapped (view, "cursor-changed", |
326 | G_CALLBACK (event_cursor_changed), | 394 | G_CALLBACK (event_cursor_changed), |