summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@l3000.localdomain>2010-11-11 15:13:04 -0500
committerSøren Sandmann Pedersen <sandmann@daimi.au.dk>2011-06-29 02:48:22 -0400
commit61024b626f11fffacdfcd4b4efef5b6f6da7481d (patch)
treed7967245d30b6647f515d5f1441ddb395409c689
parent54368af8658253affff6bb43fe078e6b20610eef (diff)
Improved scrolling
-rw-r--r--sysprof.c98
-rw-r--r--sysprof.glade2
2 files changed, 56 insertions, 44 deletions
diff --git a/sysprof.c b/sysprof.c
index 7ce0e66..6b5a33b 100644
--- a/sysprof.c
+++ b/sysprof.c
@@ -68,6 +68,7 @@ struct Application
GtkWidget * open_item;
GtkWidget * about_item;
GtkWidget * quit_item;
+ GtkWidget * scrolled_window;
GtkTreeSelection * object_selection;
@@ -839,19 +840,21 @@ expand_descendants_tree (Application *app, gpointer object)
int max_rows = 40; /* FIXME */
double top_value = 0.0;
GtkTreePath *first_path;
+ GtkTreePath *target;
+ GdkRectangle rect;
GList *list;
-
+ GtkAdjustment *adj;
+
if (!(first_path = find_object (model, object)))
return;
+ target = gtk_tree_path_copy (first_path);
+
+ gtk_tree_view_set_cursor (app->descendants_view, target,
+ NULL, FALSE);
+
gtk_tree_view_collapse_all (app->descendants_view);
- 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;
@@ -888,7 +891,7 @@ expand_descendants_tree (Application *app, gpointer object)
if (value < 0)
value = 100.0;
-
+
if (value >= best_value)
{
best_value = value;
@@ -940,6 +943,16 @@ expand_descendants_tree (Application *app, gpointer object)
for (list = all_paths; list != NULL; list = list->next)
gtk_tree_path_free (list->data);
+ gtk_tree_view_get_cell_area (app->descendants_view, target,
+ NULL, &rect);
+
+ adj = gtk_scrolled_window_get_vadjustment (app->scrolled_window);
+
+ gtk_tree_view_convert_bin_window_to_tree_coords (
+ app->descendants_view, 0, rect.y, NULL, &rect.y);
+
+ gtk_adjustment_set_value (adj, rect.y - 18);
+
g_list_free (all_paths);
}
@@ -989,25 +1002,25 @@ gather_widgets (Application *app)
const char *name;
} WidgetInfo;
- const WidgetInfo widgets[] =
- {
- { &app->main_window, "main_window" },
- { &app->start_button, "start_button" },
- { &app->profile_button, "profile_button" },
- { &app->reset_button, "reset_button" },
- { &app->save_as_button, "save_as_button" },
- { &app->dummy_button, "dummy_button" },
- { &app->samples_label, "samples_label" },
- { &app->samples_hbox, "samples_hbox" },
- { &app->start_item, "start_item" },
- { &app->profile_item, "profile_item" },
- { &app->reset_item, "reset_item" },
- { &app->open_item, "open_item" },
- { &app->save_as_item, "save_as_item" },
- { &app->quit_item, "quit" },
- { &app->about_item, "about" },
- { &app->descendants_view, "descendants_view" },
- };
+ const WidgetInfo widgets[] = {
+ { &app->main_window, "main_window" },
+ { &app->start_button, "start_button" },
+ { &app->profile_button, "profile_button" },
+ { &app->reset_button, "reset_button" },
+ { &app->save_as_button, "save_as_button" },
+ { &app->dummy_button, "dummy_button" },
+ { &app->samples_label, "samples_label" },
+ { &app->samples_hbox, "samples_hbox" },
+ { &app->start_item, "start_item" },
+ { &app->profile_item, "profile_item" },
+ { &app->reset_item, "reset_item" },
+ { &app->open_item, "open_item" },
+ { &app->save_as_item, "save_as_item" },
+ { &app->quit_item, "quit" },
+ { &app->about_item, "about" },
+ { &app->descendants_view, "descendants_view" },
+ { &app->scrolled_window, "scrolled_window" },
+ };
GladeXML *xml = glade_xml_new (GLADE_FILE, NULL, NULL);
int i;
@@ -1035,22 +1048,21 @@ connect_signals (Application *app)
gpointer data;
} SignalInfo;
- const SignalInfo signals[] =
- {
- { app->main_window, "delete_event", on_delete, NULL },
- { app->start_button, "toggled", on_start_toggled, app },
- { app->profile_button, "toggled", on_profile_toggled, app },
- { app->reset_button, "clicked", on_reset_clicked, app },
- { app->save_as_button, "clicked", on_save_as_clicked, app },
- { app->start_item, "activate", on_menu_item_activated, app->start_button },
- { app->profile_item, "activate", on_menu_item_activated, app->profile_button },
- { app->reset_item, "activate", on_reset_clicked, app },
- { app->open_item, "activate", on_open_clicked, app },
- { app->save_as_item, "activate", on_save_as_clicked, app },
- { app->quit_item, "activate", on_delete, NULL },
- { app->about_item, "activate", on_about_activated, app },
- { app->descendants_view, "row-activated", on_descendants_row_activated, app },
- };
+ const SignalInfo signals[] = {
+ { app->main_window, "delete_event", on_delete, NULL },
+ { app->start_button, "toggled", on_start_toggled, app },
+ { app->profile_button, "toggled", on_profile_toggled, app },
+ { app->reset_button, "clicked", on_reset_clicked, app },
+ { app->save_as_button, "clicked", on_save_as_clicked, app },
+ { app->start_item, "activate", on_menu_item_activated, app->start_button },
+ { app->profile_item, "activate", on_menu_item_activated, app->profile_button },
+ { app->reset_item, "activate", on_reset_clicked, app },
+ { app->open_item, "activate", on_open_clicked, app },
+ { app->save_as_item, "activate", on_save_as_clicked, app },
+ { app->quit_item, "activate", on_delete, NULL },
+ { app->about_item, "activate", on_about_activated, app },
+ { app->descendants_view, "row-activated", on_descendants_row_activated, app },
+ };
int i;
diff --git a/sysprof.glade b/sysprof.glade
index cacdb87..175f0dc 100644
--- a/sysprof.glade
+++ b/sysprof.glade
@@ -640,7 +640,7 @@
</child>
<child>
- <widget class="GtkScrolledWindow" id="scrolledwindow2">
+ <widget class="GtkScrolledWindow" id="scrolled_window">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>