diff options
author | Søren Sandmann Pedersen <sandmann@daimi.au.dk> | 2010-11-10 02:55:40 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <sandmann@daimi.au.dk> | 2011-06-29 02:48:21 -0400 |
commit | ca77ee2a91f239ea1d7d6a471fd130320b05ea08 (patch) | |
tree | 23dc3150026dea467965f767e48815b034fa1cfb | |
parent | d72f13abe5839bac88ac00506733b1afaf1ff82c (diff) |
Eliminate caller view
-rw-r--r-- | sysprof.c | 207 | ||||
-rw-r--r-- | sysprof.glade | 82 | ||||
-rw-r--r-- | treeviewutils.c | 2 |
3 files changed, 78 insertions, 213 deletions
@@ -53,7 +53,6 @@ struct Application GtkWidget * main_window; - GtkTreeView * callers_view; GtkTreeView * descendants_view; GtkWidget * start_button; @@ -70,7 +69,6 @@ struct Application GtkWidget * screenshot_item; GtkWidget * about_item; GtkWidget * quit_item; - GtkWidget * vpaned; GtkTreeSelection * object_selection; @@ -230,7 +228,6 @@ update_sensitivity (Application *app) sensitive_reset_button); #endif - gtk_widget_set_sensitive (GTK_WIDGET (app->callers_view), sensitive_tree_views); gtk_widget_set_sensitive (GTK_WIDGET (app->descendants_view), sensitive_tree_views); gtk_widget_set_sensitive (GTK_WIDGET (app->samples_hbox), sensitive_samples_hbox); @@ -305,7 +302,6 @@ delete_data (Application *app) profile_free (app->profile); app->profile = NULL; - gtk_tree_view_set_model (GTK_TREE_VIEW (app->callers_view), NULL); gtk_tree_view_set_model (GTK_TREE_VIEW (app->descendants_view), NULL); } @@ -379,14 +375,6 @@ on_start_toggled (GtkWidget *widget, gpointer data) enum { - CALLERS_SELF, - CALLERS_TOTAL, - CALLERS_NAME, - CALLERS_OBJECT -}; - -enum -{ DESCENDANTS_SELF, DESCENDANTS_CUMULATIVE, DESCENDANTS_NAME, @@ -416,23 +404,28 @@ get_current_object (Application *app) static void set_row (FooTreeStore *store, GtkTreeIter *iter, - const char *name, double self, double total) + const char *name, double self, double total, const char *object) { foo_tree_store_set (store, iter, DESCENDANTS_NAME, name, DESCENDANTS_SELF, self, DESCENDANTS_CUMULATIVE, total, - DESCENDANTS_OBJECT, name, + DESCENDANTS_OBJECT, object, -1); } static void set_node (FooTreeStore *store, GtkTreeIter *iter, int size, ProfileDescendant *node) { + char *escaped = g_markup_escape_text (node->name, -1); + set_row (store, iter, - node->name, + escaped, node->self * 100 / (double)size, - node->cumulative * 100 / (double)(size)); + node->cumulative * 100 / (double)size, + node->name); + + g_free (escaped); } static void @@ -455,6 +448,36 @@ add_node (FooTreeStore *store, } static void +add_callers (FooTreeStore *store, + int size, + GtkTreeIter *parent, + ProfileCaller *callers) +{ + GtkTreeIter iter; + + while (callers) + { + if (callers->name) + { + foo_tree_store_insert (store, &iter, parent, 0); + foo_tree_store_set ( + store, &iter, + DESCENDANTS_NAME, callers->name, + DESCENDANTS_SELF, 100.0 * callers->self / size, + DESCENDANTS_CUMULATIVE, 100.0 * callers->total / size, +#if 0 + DESCENDANTS_SELF, (double)callers->self, + DESCENDANTS_TOTAL, (double)callers->total, +#endif + DESCENDANTS_OBJECT, callers->name, + -1); + } + + callers = callers->next; + } +} + +static void fill_descendants_tree (Application *app) { FooTreeStore *store; @@ -475,19 +498,29 @@ fill_descendants_tree (Application *app) { int size = profile_get_size (app->profile); GtkTreeIter iter, iter2; - ProfileDescendant *node = - profile_create_descendants (app->profile, object->name); + ProfileDescendant *descendants; + ProfileCaller *callers; - foo_tree_store_insert (store, &iter, NULL, 0); - set_node (store, &iter, size, node); + descendants = profile_create_descendants (app->profile, object->name); - foo_tree_store_insert (store, &iter2, &iter, 0); - set_row (store, &iter2, "<i>Descendants</i>", 2.0, 2.0); - add_node (store, size, &iter2, node->children); + foo_tree_store_insert (store, &iter, NULL, 0); + set_node (store, &iter, size, descendants); - foo_tree_store_insert (store, &iter2, &iter, 0); - set_row (store, &iter2, "<i>Callers</i>", 1.0, 1.0); + if (descendants->children) + { + foo_tree_store_insert (store, &iter2, &iter, 0); + set_row (store, &iter2, "<i>Descendants</i>", -1.0, -1.0, NULL); + add_node (store, size, &iter2, descendants->children); + profile_descendant_free (descendants); + } + if ((callers = profile_list_callers (app->profile, object->name))) + { + foo_tree_store_insert (store, &iter2, &iter, 0); + set_row (store, &iter2, "<i>Callers</i>", -2.0, -2.0, NULL); + add_callers (store, size, &iter2, callers); + profile_caller_free (callers); + } } } } @@ -501,87 +534,6 @@ fill_descendants_tree (Application *app) } static void -add_callers (GtkListStore *list_store, - Profile *profile, - ProfileCaller *callers) -{ - GtkTreeIter iter; - - if (!callers) - { - gtk_list_store_append (list_store, &iter); - - gtk_list_store_set ( - list_store, &iter, - CALLERS_NAME, "", - CALLERS_SELF, -1.0, - CALLERS_TOTAL, -1.0, -1); - } - - while (callers) - { - gchar *name; - double profile_size = profile_get_size (profile); - - if (callers->name) - name = callers->name; - else - name = "<spontaneous>"; - - gtk_list_store_append (list_store, &iter); - gtk_list_store_set ( - list_store, &iter, - CALLERS_NAME, name, - CALLERS_SELF, 100.0 * callers->self / profile_size, - CALLERS_TOTAL, 100.0 * callers->total / profile_size, -#if 0 - CALLERS_SELF, (double)callers->self, - CALLERS_TOTAL, (double)callers->total, -#endif - CALLERS_OBJECT, callers->name, - -1); - - callers = callers->next; - } -} - -static void -fill_callers_list (Application *app) -{ - GtkListStore *list_store; - - if (app->callers) - { - profile_caller_free (app->callers); - app->callers = NULL; - } - - list_store = - gtk_list_store_new (4, - G_TYPE_DOUBLE, - G_TYPE_DOUBLE, - G_TYPE_STRING, - G_TYPE_POINTER); - - if (app->profile) - { - char *object = get_current_object (app); - if (object) - { - app->callers = profile_list_callers (app->profile, object); - add_callers (list_store, app->profile, app->callers); - } - } - - tree_view_set_model_with_default_sort (app->callers_view, GTK_TREE_MODEL (list_store), - CALLERS_TOTAL, GTK_SORT_DESCENDING); - - g_object_unref (G_OBJECT (list_store)); - - gtk_tree_view_columns_autosize (app->callers_view); -} - -static void enter_display_mode (Application *app) { app->state = DISPLAYING; @@ -960,6 +912,9 @@ expand_descendants_tree (Application *app, gpointer object) DESCENDANTS_CUMULATIVE, &value, -1); + if (value < 0) + value = 100.0; + if (value >= best_value) { best_value = value; @@ -1193,10 +1148,6 @@ on_object_selection_changed (GtkTreeSelection *selection, if (!app->inhibit_forced_redraw) gdk_window_process_all_updates (); /* Display updated selection */ - - fill_callers_list (app); - - gtk_tree_view_columns_autosize (app->callers_view); } #if 0 @@ -1282,21 +1233,6 @@ on_descendants_row_activated (GtkTreeView *tree_view, } static void -on_callers_row_activated (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column, - gpointer data) -{ - Application *app = data; - -#if 0 - goto_object (app, tree_view, path, CALLERS_OBJECT); -#endif - - gtk_widget_grab_focus (GTK_WIDGET (app->callers_view)); -} - -static void on_screenshot_activated (GtkCheckMenuItem *menu_item, Application *app) { @@ -1327,9 +1263,7 @@ on_screenshot_close_button_clicked (GtkWidget *widget, } static void -set_sizes (GtkWindow *window, - GtkWindow *screenshot_window, - GtkWidget *vpaned) +set_sizes (GtkWindow *window, GtkWindow *screenshot_window) { GdkScreen *screen; int monitor_num; @@ -1347,8 +1281,6 @@ set_sizes (GtkWindow *window, gtk_window_resize (window, width, height); - gtk_paned_set_position (GTK_PANED (vpaned), 10 * height / 13); - width = monitor.width * 5 / 8; height = monitor.height * 5 / 8; @@ -1384,12 +1316,10 @@ gather_widgets (Application *app) { &app->screenshot_item, "screenshot_item" }, { &app->quit_item, "quit" }, { &app->about_item, "about" }, - { &app->callers_view, "callers_view" }, { &app->descendants_view, "descendants_view" }, { &app->screenshot_window, "screenshot_window" }, { &app->screenshot_textview, "screenshot_textview" }, { &app->screenshot_close_button, "screenshot_close_button" }, - { &app->vpaned, "vpaned" }, }; GladeXML *xml = glade_xml_new (GLADE_FILE, NULL, NULL); @@ -1434,7 +1364,6 @@ connect_signals (Application *app) { app->quit_item, "activate", on_delete, NULL }, { app->about_item, "activate", on_about_activated, app }, { app->object_selection, "changed", on_object_selection_changed, app }, - { app->callers_view, "row-activated", on_callers_row_activated, app }, { app->descendants_view, "row-activated", on_descendants_row_activated, app }, { app->descendants_view, "row-expanded", on_descendants_row_expanded_or_collapsed, app }, { app->descendants_view, "row-collapsed", on_descendants_row_expanded_or_collapsed, app }, @@ -1539,15 +1468,6 @@ build_gui (Application *app) /* TreeViews */ - /* callers view */ - gtk_tree_view_set_enable_search (app->callers_view, FALSE); - add_double_format_column (app->callers_view, _("Self"), - CALLERS_SELF, PCT_FORMAT); - add_double_format_column (app->callers_view, _("Total"), - CALLERS_TOTAL, PCT_FORMAT); - add_plain_text_column (app->callers_view, _("Callers"), - CALLERS_NAME); - /* descendants view */ gtk_tree_view_set_enable_search (app->descendants_view, FALSE); add_double_format_column (app->descendants_view, _("Self"), @@ -1564,8 +1484,7 @@ build_gui (Application *app) /* set sizes */ set_sizes (GTK_WINDOW (app->main_window), - GTK_WINDOW (app->screenshot_window), - app->vpaned); + GTK_WINDOW (app->screenshot_window)); /* hide/show widgets */ gtk_widget_show_all (app->main_window); diff --git a/sysprof.glade b/sysprof.glade index 9433f1b..5245901 100644 --- a/sysprof.glade +++ b/sysprof.glade @@ -664,80 +664,26 @@ </child> <child> - <widget class="GtkVBox" id="vbox2"> + <widget class="GtkScrolledWindow" id="scrolledwindow2"> <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> <child> - <widget class="GtkVPaned" id="vpaned"> + <widget class="GtkTreeView" id="descendants_view"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="position">0</property> - - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow2"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <property name="window_placement">GTK_CORNER_TOP_LEFT</property> - - <child> - <widget class="GtkTreeView" id="descendants_view"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="headers_visible">True</property> - <property name="rules_hint">False</property> - <property name="reorderable">False</property> - <property name="enable_search">True</property> - <property name="fixed_height_mode">False</property> - <property name="hover_selection">False</property> - <property name="hover_expand">False</property> - </widget> - </child> - </widget> - <packing> - <property name="shrink">True</property> - <property name="resize">False</property> - </packing> - </child> - - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow3"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <property name="window_placement">GTK_CORNER_TOP_LEFT</property> - - <child> - <widget class="GtkTreeView" id="callers_view"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="headers_visible">True</property> - <property name="rules_hint">False</property> - <property name="reorderable">False</property> - <property name="enable_search">True</property> - <property name="fixed_height_mode">False</property> - <property name="hover_selection">False</property> - <property name="hover_expand">False</property> - </widget> - </child> - </widget> - <packing> - <property name="shrink">True</property> - <property name="resize">True</property> - </packing> - </child> + <property name="headers_visible">True</property> + <property name="rules_hint">False</property> + <property name="reorderable">False</property> + <property name="enable_search">True</property> + <property name="fixed_height_mode">False</property> + <property name="hover_selection">False</property> + <property name="hover_expand">False</property> </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> </child> </widget> <packing> diff --git a/treeviewutils.c b/treeviewutils.c index 3d66ba9..af82da8 100644 --- a/treeviewutils.c +++ b/treeviewutils.c @@ -189,7 +189,7 @@ double_to_text (GtkTreeViewColumn *tree_column, gtk_tree_model_get (tree_model, iter, info->column, &d, -1); - if (d < 0) + if (d <= 0.0) text = g_strdup (""); else text = g_strdup_printf (info->format, d); |