summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <sandmann@daimi.au.dk>2010-11-09 10:25:55 -0500
committerSøren Sandmann Pedersen <sandmann@daimi.au.dk>2011-06-29 02:48:21 -0400
commit6b3611854a3d598ff5e191ed5b57bd13b4793025 (patch)
tree095cbcdc0f8a212d2931d011246c3b92aa2cdbad
parentbb50c1ef214e1dc8f307ed055b0412f5d7002284 (diff)
Expand on double-click
-rw-r--r--stackstash.c2
-rw-r--r--sysprof.c73
2 files changed, 56 insertions, 19 deletions
diff --git a/stackstash.c b/stackstash.c
index 44912e4..4496110 100644
--- a/stackstash.c
+++ b/stackstash.c
@@ -226,6 +226,8 @@ stack_stash_add_trace (StackStash *stash,
*
* Not sure what can be done about it aside from actually fixing
* x86-64 to get stacktraces.
+ *
+ * Actually, using a hash table here might work.
*/
prev = NULL;
for (match = *location; match; prev = match, match = match->siblings)
diff --git a/sysprof.c b/sysprof.c
index 34f57db..9f03d7e 100644
--- a/sysprof.c
+++ b/sysprof.c
@@ -379,9 +379,9 @@ on_start_toggled (GtkWidget *widget, gpointer data)
enum
{
- CALLERS_NAME,
CALLERS_SELF,
CALLERS_TOTAL,
+ CALLERS_NAME,
CALLERS_OBJECT
};
@@ -539,9 +539,9 @@ fill_callers_list (Application *app)
list_store =
gtk_list_store_new (4,
- G_TYPE_STRING,
G_TYPE_DOUBLE,
G_TYPE_DOUBLE,
+ G_TYPE_STRING,
G_TYPE_POINTER);
if (app->profile)
@@ -848,8 +848,44 @@ on_delete (GtkWidget *window,
gtk_main_quit ();
}
+static GtkTreePath *
+find_object (GtkTreeModel *model, gpointer object)
+{
+ GtkTreeIter iter;
+ gboolean found = FALSE;
+
+ if (gtk_tree_model_get_iter_first (model, &iter))
+ {
+ do
+ {
+ char *list_object;
+
+ gtk_tree_model_get (model, &iter,
+ DESCENDANTS_OBJECT, &list_object,
+ -1);
+
+ if (list_object == object)
+ {
+ found = TRUE;
+ break;
+ }
+ }
+ while (gtk_tree_model_iter_next (model, &iter));
+ }
+
+ if (found)
+ {
+ GtkTreePath *path =
+ gtk_tree_model_get_path (model, &iter);
+
+ return path;
+ }
+
+ return NULL;
+}
+
static void
-expand_descendants_tree (Application *app)
+expand_descendants_tree (Application *app, gpointer object)
{
GtkTreeModel *model = gtk_tree_view_get_model (app->descendants_view);
GtkTreeIter iter;
@@ -860,8 +896,16 @@ expand_descendants_tree (Application *app)
GtkTreePath *first_path;
GList *list;
- first_path = gtk_tree_path_new_first();
+ gtk_tree_view_collapse_all (app->descendants_view);
+
+ first_path = find_object (model, object);
+ gtk_tree_view_set_cursor (app->descendants_view, first_path,
+ NULL, FALSE);
+
+ gtk_tree_view_scroll_to_cell (app->descendants_view, first_path, NULL,
+ FALSE, 0, 0);
+
all_paths = g_list_prepend (all_paths, first_path);
n_rows = 1;
@@ -1133,17 +1177,6 @@ on_object_selection_changed (GtkTreeSelection *selection,
fill_callers_list (app);
gtk_tree_view_columns_autosize (app->callers_view);
-
- gtk_widget_set_size_request (app->callers_view, 2, 2);
- gtk_widget_hide (app->callers_view);
- gtk_widget_show (app->callers_view);
-
- gtk_widget_set_size_request (app->callers_view, -1, -1);
-
-#if 0
- if (get_current_object (app))
- expand_descendants_tree (app);
-#endif
}
#if 0
@@ -1216,12 +1249,16 @@ on_descendants_row_activated (GtkTreeView *tree_view,
gpointer data)
{
Application *app = data;
+ gpointer object;
#if 0
goto_object (app, tree_view, path, DESCENDANTS_OBJECT);
#endif
gtk_widget_grab_focus (GTK_WIDGET (app->descendants_view));
+
+ if ((object = get_current_object (app)))
+ expand_descendants_tree (app, object);
}
static void
@@ -1484,13 +1521,12 @@ build_gui (Application *app)
/* callers view */
gtk_tree_view_set_enable_search (app->callers_view, FALSE);
- col = add_plain_text_column (app->callers_view, _("Callers"),
- CALLERS_NAME);
add_double_format_column (app->callers_view, _("Self"),
CALLERS_SELF, PCT_FORMAT);
add_double_format_column (app->callers_view, _("Total"),
CALLERS_TOTAL, PCT_FORMAT);
- gtk_tree_view_column_set_expand (col, TRUE);
+ add_plain_text_column (app->callers_view, _("Callers"),
+ CALLERS_NAME);
/* descendants view */
gtk_tree_view_set_enable_search (app->descendants_view, FALSE);
@@ -1500,7 +1536,6 @@ build_gui (Application *app)
DESCENDANTS_CUMULATIVE, PCT_FORMAT);
col = add_plain_text_column (app->descendants_view, _("Name"),
DESCENDANTS_NAME);
- gtk_tree_view_column_set_expand (col, TRUE);
gtk_tree_view_set_expander_column (app->descendants_view, col);
app->object_selection = gtk_tree_view_get_selection (app->descendants_view);