mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
Add new tree_view_foreach_visible() function.
Wed Nov 9 00:24:11 2005 Soeren Sandmann <sandmann@redhat.com> * treeviewutils.[ch]: Add new tree_view_foreach_visible() function. * sysprof.c: Add update_screenshot_window() function.
This commit is contained in:
committed by
Søren Sandmann Pedersen
parent
00244118a2
commit
c3ce4ef8c5
@ -1,3 +1,10 @@
|
|||||||
|
Wed Nov 9 00:24:11 2005 Soeren Sandmann <sandmann@redhat.com>
|
||||||
|
|
||||||
|
* treeviewutils.[ch]: Add new tree_view_foreach_visible()
|
||||||
|
function.
|
||||||
|
|
||||||
|
* sysprof.c: Add update_screenshot_window() function.
|
||||||
|
|
||||||
Mon Nov 7 23:42:26 2005 Soeren Sandmann <sandmann@redhat.com>
|
Mon Nov 7 23:42:26 2005 Soeren Sandmann <sandmann@redhat.com>
|
||||||
|
|
||||||
* sysprof.c: Add beginning of a screenshot
|
* sysprof.c: Add beginning of a screenshot
|
||||||
|
|||||||
6
TODO
6
TODO
@ -184,6 +184,12 @@ Before 1.2:
|
|||||||
UI: "generate screenshot" menu item pops up a window with
|
UI: "generate screenshot" menu item pops up a window with
|
||||||
a text area + a radio buttons "text/html". When you flick
|
a text area + a radio buttons "text/html". When you flick
|
||||||
them, the text area is automatically updated.
|
them, the text area is automatically updated.
|
||||||
|
- beginning in CVS:
|
||||||
|
- why does the window not remember its position when
|
||||||
|
you close it with the close button, but does remember
|
||||||
|
it when you use the wm button or the menu item? It actually
|
||||||
|
seems that it only forgets the position when you click the
|
||||||
|
button with the mouse. But not if you use the keyboard ...
|
||||||
|
|
||||||
- Find out how gdb does backtraces; they may have a better way. Also
|
- Find out how gdb does backtraces; they may have a better way. Also
|
||||||
find out what dwarf2 is and how to use it. Look into libunwind.
|
find out what dwarf2 is and how to use it. Look into libunwind.
|
||||||
|
|||||||
88
sysprof.c
88
sysprof.c
@ -238,8 +238,8 @@ update_sensitivity (Application *app)
|
|||||||
else
|
else
|
||||||
gtk_widget_hide (app->screenshot_window);
|
gtk_widget_hide (app->screenshot_window);
|
||||||
|
|
||||||
gtk_check_menu_item_set_active (
|
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (app->screenshot_item),
|
||||||
GTK_CHECK_MENU_ITEM (app->screenshot_item), app->screenshot_window_visible);
|
app->screenshot_window_visible);
|
||||||
|
|
||||||
queue_show_samples (app);
|
queue_show_samples (app);
|
||||||
}
|
}
|
||||||
@ -781,7 +781,7 @@ on_save_as_clicked (gpointer widget,
|
|||||||
|
|
||||||
set_busy (app->main_window, FALSE);
|
set_busy (app->main_window, FALSE);
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
||||||
{
|
{
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
@ -875,7 +875,7 @@ on_open_clicked (gpointer widget,
|
|||||||
|
|
||||||
set_busy (app->main_window, FALSE);
|
set_busy (app->main_window, FALSE);
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
||||||
{
|
{
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
@ -1007,6 +1007,14 @@ expand_descendants_tree (Application *app)
|
|||||||
}
|
}
|
||||||
|
|
||||||
all_paths = g_list_remove (all_paths, best_path);
|
all_paths = g_list_remove (all_paths, best_path);
|
||||||
|
|
||||||
|
if (!all_paths && n_rows == 1)
|
||||||
|
{
|
||||||
|
/* Always expand at least once */
|
||||||
|
gtk_tree_view_expand_row (GTK_TREE_VIEW (app->descendants_view),
|
||||||
|
best_path, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
gtk_tree_path_free (best_path);
|
gtk_tree_path_free (best_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1016,9 +1024,59 @@ expand_descendants_tree (Application *app)
|
|||||||
g_list_free (all_paths);
|
g_list_free (all_paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int text_width;
|
||||||
|
int self_width;
|
||||||
|
int cumulative_width;
|
||||||
|
} Widths;
|
||||||
|
|
||||||
|
static void
|
||||||
|
compute_widths (GtkTreeView *view,
|
||||||
|
GtkTreePath *path,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkTreeModel *model = gtk_tree_view_get_model (view);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_text (GtkTreeView *view,
|
||||||
|
GtkTreePath *path,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
Application *app = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_screenshot_window (Application *app)
|
||||||
|
{
|
||||||
|
typedef gboolean (* GtkTreeModelForeachFunc) (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
|
||||||
|
|
||||||
|
/* FIXME: clear the text buffer here */
|
||||||
|
|
||||||
|
if (app->descendants)
|
||||||
|
{
|
||||||
|
Widths widths;
|
||||||
|
|
||||||
|
widths.text_width = 0;
|
||||||
|
widths.self_width = 0;
|
||||||
|
widths.cumulative_width = 0;
|
||||||
|
|
||||||
|
tree_view_foreach_visible (app->descendants_view,
|
||||||
|
compute_widths,
|
||||||
|
&widths);
|
||||||
|
|
||||||
|
tree_view_foreach_visible (app->descendants_view,
|
||||||
|
add_text,
|
||||||
|
app);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_object_selection_changed (GtkTreeSelection *selection,
|
on_object_selection_changed (GtkTreeSelection *selection,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
Application *app = data;
|
Application *app = data;
|
||||||
|
|
||||||
@ -1032,6 +1090,8 @@ on_object_selection_changed (GtkTreeSelection *selection,
|
|||||||
if (get_current_object (app))
|
if (get_current_object (app))
|
||||||
expand_descendants_tree (app);
|
expand_descendants_tree (app);
|
||||||
|
|
||||||
|
update_screenshot_window (app);
|
||||||
|
|
||||||
set_busy (app->main_window, FALSE);
|
set_busy (app->main_window, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1150,6 +1210,7 @@ on_screenshot_close_button_clicked (GtkWidget *widget,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
set_sizes (GtkWindow *window,
|
set_sizes (GtkWindow *window,
|
||||||
|
GtkWindow *screenshot_window,
|
||||||
GtkWidget *hpaned,
|
GtkWidget *hpaned,
|
||||||
GtkWidget *vpaned)
|
GtkWidget *vpaned)
|
||||||
{
|
{
|
||||||
@ -1171,6 +1232,12 @@ set_sizes (GtkWindow *window,
|
|||||||
|
|
||||||
gtk_paned_set_position (GTK_PANED (vpaned), height / 2);
|
gtk_paned_set_position (GTK_PANED (vpaned), height / 2);
|
||||||
gtk_paned_set_position (GTK_PANED (hpaned), width / 2);
|
gtk_paned_set_position (GTK_PANED (hpaned), width / 2);
|
||||||
|
|
||||||
|
width = monitor.width * 5 / 8;
|
||||||
|
height = monitor.height * 5/ 8;
|
||||||
|
|
||||||
|
gtk_window_resize (screenshot_window, width, height);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1225,9 +1292,6 @@ build_gui (Application *app)
|
|||||||
G_CALLBACK (on_delete), NULL);
|
G_CALLBACK (on_delete), NULL);
|
||||||
|
|
||||||
gtk_widget_realize (GTK_WIDGET (app->main_window));
|
gtk_widget_realize (GTK_WIDGET (app->main_window));
|
||||||
set_sizes (GTK_WINDOW (app->main_window),
|
|
||||||
glade_xml_get_widget (xml, "hpaned"),
|
|
||||||
glade_xml_get_widget (xml, "vpaned"));
|
|
||||||
|
|
||||||
/* Tool items */
|
/* Tool items */
|
||||||
|
|
||||||
@ -1326,7 +1390,7 @@ build_gui (Application *app)
|
|||||||
|
|
||||||
gtk_widget_grab_focus (GTK_WIDGET (app->object_view));
|
gtk_widget_grab_focus (GTK_WIDGET (app->object_view));
|
||||||
|
|
||||||
/* Screenshot window */
|
/* screenshot window */
|
||||||
app->screenshot_window = glade_xml_get_widget (xml, "screenshot_window");
|
app->screenshot_window = glade_xml_get_widget (xml, "screenshot_window");
|
||||||
app->screenshot_textview = glade_xml_get_widget (xml, "screenshot_textview");
|
app->screenshot_textview = glade_xml_get_widget (xml, "screenshot_textview");
|
||||||
app->screenshot_close_button = glade_xml_get_widget (xml, "screenshot_close_button");
|
app->screenshot_close_button = glade_xml_get_widget (xml, "screenshot_close_button");
|
||||||
@ -1337,6 +1401,12 @@ build_gui (Application *app)
|
|||||||
g_signal_connect (app->screenshot_close_button, "clicked",
|
g_signal_connect (app->screenshot_close_button, "clicked",
|
||||||
G_CALLBACK (on_screenshot_close_button_clicked), app);
|
G_CALLBACK (on_screenshot_close_button_clicked), app);
|
||||||
|
|
||||||
|
/* set sizes */
|
||||||
|
set_sizes (GTK_WINDOW (app->main_window),
|
||||||
|
GTK_WINDOW (app->screenshot_window),
|
||||||
|
glade_xml_get_widget (xml, "hpaned"),
|
||||||
|
glade_xml_get_widget (xml, "vpaned"));
|
||||||
|
|
||||||
/* hide/show widgets */
|
/* hide/show widgets */
|
||||||
gtk_widget_show_all (app->main_window);
|
gtk_widget_show_all (app->main_window);
|
||||||
gtk_widget_hide (app->dummy_button);
|
gtk_widget_hide (app->dummy_button);
|
||||||
|
|||||||
@ -230,3 +230,41 @@ restore_sort_state (GtkTreeView *view, gpointer st)
|
|||||||
|
|
||||||
gtk_tree_sortable_sort_column_changed (GTK_TREE_SORTABLE (model));
|
gtk_tree_sortable_sort_column_changed (GTK_TREE_SORTABLE (model));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
process_iter (GtkTreeView *view,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
VisibleCallback callback,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkTreeModel *model = gtk_tree_view_get_model (view);
|
||||||
|
GtkTreePath *path;
|
||||||
|
GtkTreeIter child;
|
||||||
|
|
||||||
|
path = gtk_tree_model_get_path (model, iter);
|
||||||
|
|
||||||
|
callback (view, path, iter, data);
|
||||||
|
|
||||||
|
if (gtk_tree_view_row_expanded (view, path)) {
|
||||||
|
if (gtk_tree_model_iter_children (model, &child, iter)) {
|
||||||
|
do {
|
||||||
|
process_iter (view, &child, callback, data);
|
||||||
|
} while (gtk_tree_model_iter_next (model, &child));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_tree_path_free (path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tree_view_foreach_visible (GtkTreeView *view,
|
||||||
|
VisibleCallback callback,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkTreeModel *model = gtk_tree_view_get_model (view);
|
||||||
|
GtkTreeIter iter;
|
||||||
|
|
||||||
|
if (gtk_tree_model_get_iter_first (model, &iter))
|
||||||
|
process_iter (view, &iter, callback, data);
|
||||||
|
}
|
||||||
|
|||||||
@ -43,3 +43,11 @@ GtkTreeViewColumn *add_pointer_column (GtkTreeView *view,
|
|||||||
gpointer save_sort_state (GtkTreeView *view);
|
gpointer save_sort_state (GtkTreeView *view);
|
||||||
void restore_sort_state (GtkTreeView *view,
|
void restore_sort_state (GtkTreeView *view,
|
||||||
gpointer state);
|
gpointer state);
|
||||||
|
|
||||||
|
typedef void (* VisibleCallback) (GtkTreeView *view,
|
||||||
|
GtkTreePath *path,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer data);
|
||||||
|
void tree_view_foreach_visible (GtkTreeView *view,
|
||||||
|
VisibleCallback callback,
|
||||||
|
gpointer data);
|
||||||
|
|||||||
Reference in New Issue
Block a user