Show the right number of samples afte Open; remove shadows from menu bars

Sat Mar 26 19:26:52 2005  Søren Sandmann  <sandmann@redhat.com>

	* sysprof.c: Show the right number of samples afte Open; remove
	shadows from menu bars and toolbars; some other tweaks.
This commit is contained in:
Søren Sandmann
2005-03-27 00:31:01 +00:00
committed by Søren Sandmann Pedersen
parent cc25479579
commit 398603a85d
4 changed files with 251 additions and 208 deletions

View File

@ -1,3 +1,8 @@
Sat Mar 26 19:26:52 2005 Søren Sandmann <sandmann@redhat.com>
* sysprof.c: Show the right number of samples afte Open; remove
shadows from menu bars and toolbars; some other tweaks.
Sat Mar 26 11:26:00 2005 Soeren Sandmann <sandmann@redhat.com> Sat Mar 26 11:26:00 2005 Soeren Sandmann <sandmann@redhat.com>
* TODO: Updates * TODO: Updates

4
TODO
View File

@ -60,8 +60,6 @@
- consider caching [filename => bin_file] - consider caching [filename => bin_file]
- Make sure samples label shows correct nunber after Open
- Have kernel module report the file the address was found in - Have kernel module report the file the address was found in
Should avoid a lot of potential broken/raciness with dlopen etc. Should avoid a lot of potential broken/raciness with dlopen etc.
@ -98,6 +96,8 @@
DONE: DONE:
- Make sure samples label shows correct nunber after Open
- Move "samples" label to the toolbar, then get rid of statusbar. - Move "samples" label to the toolbar, then get rid of statusbar.
- crashes when you ctrl-click the selected item in the top left pane - crashes when you ctrl-click the selected item in the top left pane

391
sysprof.c
View File

@ -414,6 +414,29 @@ enum
DESCENDANTS_OBJECT DESCENDANTS_OBJECT
}; };
static ProfileObject *
get_current_object (Application *app)
{
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter selected;
ProfileObject *object;
selection = gtk_tree_view_get_selection (app->object_view);
if (gtk_tree_selection_get_selected (selection, &model, &selected))
{
gtk_tree_model_get (model, &selected,
OBJECT_OBJECT, &object,
-1);
return object;
}
else
{
return NULL;
}
}
static void static void
fill_main_list (Application *app) fill_main_list (Application *app)
{ {
@ -471,6 +494,171 @@ fill_main_list (Application *app)
gtk_tree_view_columns_autosize (app->object_view); gtk_tree_view_columns_autosize (app->object_view);
} }
static void
add_node (GtkTreeStore *store,
int size,
const GtkTreeIter *parent,
ProfileDescendant *node)
{
GtkTreeIter iter;
if (!node)
return;
gtk_tree_store_insert (store, &iter, (GtkTreeIter *)parent, 0);
gtk_tree_store_set (store, &iter,
DESCENDANTS_NAME, node->object->name,
DESCENDANTS_SELF, 100 * (node->self)/(double)size,
DESCENDANTS_NON_RECURSE, 100 * (node->non_recursion)/(double)size,
DESCENDANTS_TOTAL, 100 * (node->total)/(double)size,
DESCENDANTS_OBJECT, node->object,
-1);
add_node (store, size, parent, node->siblings);
add_node (store, size, &iter, node->children);
}
static void
fill_descendants_tree (Application *app)
{
GtkTreeStore *tree_store;
gpointer sort_state;
sort_state = save_sort_state (app->descendants_view);
if (app->descendants)
{
profile_descendant_free (app->descendants);
app->descendants = NULL;
}
tree_store =
gtk_tree_store_new (5,
G_TYPE_STRING,
G_TYPE_DOUBLE,
G_TYPE_DOUBLE,
G_TYPE_DOUBLE,
G_TYPE_POINTER);
if (app->profile)
{
ProfileObject *object = get_current_object (app);
if (object)
{
app->descendants =
profile_create_descendants (app->profile, object);
add_node (tree_store,
profile_get_size (app->profile), NULL, app->descendants);
}
}
gtk_tree_view_set_model (
app->descendants_view, GTK_TREE_MODEL (tree_store));
g_object_unref (G_OBJECT (tree_store));
if (!sort_state)
{
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (tree_store),
DESCENDANTS_NON_RECURSE,
GTK_SORT_DESCENDING);
}
else
{
restore_sort_state (app->descendants_view, sort_state);
}
gtk_tree_view_columns_autosize (app->descendants_view);
}
static void
add_callers (GtkListStore *list_store,
Profile *profile,
ProfileCaller *callers)
{
while (callers)
{
gchar *name;
GtkTreeIter iter;
double profile_size = profile_get_size (profile);
if (callers->object)
name = callers->object->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,
CALLERS_OBJECT, callers->object,
-1);
callers = callers->next;
}
}
static void
fill_callers_list (Application *app)
{
GtkListStore *list_store;
gpointer sort_state;
sort_state = save_sort_state (app->descendants_view);
if (app->callers)
{
profile_caller_free (app->callers);
app->callers = NULL;
}
list_store =
gtk_list_store_new (4,
G_TYPE_STRING,
G_TYPE_DOUBLE,
G_TYPE_DOUBLE,
G_TYPE_POINTER);
if (app->profile)
{
ProfileObject *object = get_current_object (app);
if (object)
{
app->callers = profile_list_callers (app->profile, object);
add_callers (list_store, app->profile, app->callers);
}
}
gtk_tree_view_set_model (
app->callers_view, GTK_TREE_MODEL (list_store));
g_object_unref (G_OBJECT (list_store));
if (!sort_state)
{
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store),
CALLERS_TOTAL,
GTK_SORT_DESCENDING);
}
else
{
restore_sort_state (app->callers_view, sort_state);
}
gtk_tree_view_columns_autosize (app->callers_view);
}
static void
fill_lists (Application *app)
{
fill_main_list (app);
fill_callers_list (app);
fill_descendants_tree (app);
}
static void static void
ensure_profile (Application *app) ensure_profile (Application *app)
{ {
@ -480,7 +668,7 @@ ensure_profile (Application *app)
/* take care of reentrancy */ /* take care of reentrancy */
app->profile = profile_new (app->stash); app->profile = profile_new (app->stash);
fill_main_list (app); fill_lists (app);
app->state = DISPLAYING; app->state = DISPLAYING;
@ -684,10 +872,12 @@ on_open_clicked (gpointer widget, gpointer data)
app->state = DISPLAYING; app->state = DISPLAYING;
app->n_samples = profile_get_size (profile);
app->profile = profile; app->profile = profile;
app->profile_from_file = TRUE; app->profile_from_file = TRUE;
fill_main_list (app); fill_lists (app);
update_sensitivity (app); update_sensitivity (app);
} }
@ -699,186 +889,6 @@ on_delete (GtkWidget *window)
gtk_main_quit (); gtk_main_quit ();
} }
static void
add_node (GtkTreeStore *store,
int size,
const GtkTreeIter *parent,
ProfileDescendant *node)
{
GtkTreeIter iter;
if (!node)
return;
gtk_tree_store_insert (store, &iter, (GtkTreeIter *)parent, 0);
gtk_tree_store_set (store, &iter,
DESCENDANTS_NAME, node->object->name,
DESCENDANTS_SELF, 100 * (node->self)/(double)size,
DESCENDANTS_NON_RECURSE, 100 * (node->non_recursion)/(double)size,
DESCENDANTS_TOTAL, 100 * (node->total)/(double)size,
DESCENDANTS_OBJECT, node->object,
-1);
add_node (store, size, parent, node->siblings);
add_node (store, size, &iter, node->children);
}
static ProfileObject *
get_current_object (Application *app)
{
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter selected;
ProfileObject *object;
selection = gtk_tree_view_get_selection (app->object_view);
if (gtk_tree_selection_get_selected (selection, &model, &selected))
{
gtk_tree_model_get (model, &selected,
OBJECT_OBJECT, &object,
-1);
return object;
}
else
{
return NULL;
}
}
static void
fill_descendants_tree (Application *app)
{
GtkTreeStore *tree_store;
gpointer sort_state;
sort_state = save_sort_state (app->descendants_view);
if (app->descendants)
{
profile_descendant_free (app->descendants);
app->descendants = NULL;
}
tree_store =
gtk_tree_store_new (5,
G_TYPE_STRING,
G_TYPE_DOUBLE,
G_TYPE_DOUBLE,
G_TYPE_DOUBLE,
G_TYPE_POINTER);
if (app->profile)
{
ProfileObject *object = get_current_object (app);
if (object)
{
app->descendants =
profile_create_descendants (app->profile, object);
add_node (tree_store,
profile_get_size (app->profile), NULL, app->descendants);
}
}
gtk_tree_view_set_model (
app->descendants_view, GTK_TREE_MODEL (tree_store));
g_object_unref (G_OBJECT (tree_store));
if (!sort_state)
{
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (tree_store),
DESCENDANTS_NON_RECURSE,
GTK_SORT_DESCENDING);
}
else
{
restore_sort_state (app->descendants_view, sort_state);
}
gtk_tree_view_columns_autosize (app->descendants_view);
}
static void
add_callers (GtkListStore *list_store,
Profile *profile,
ProfileCaller *callers)
{
while (callers)
{
gchar *name;
GtkTreeIter iter;
double profile_size = profile_get_size (profile);
if (callers->object)
name = callers->object->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,
CALLERS_OBJECT, callers->object,
-1);
callers = callers->next;
}
}
static void
fill_callers_list (Application *app)
{
GtkListStore *list_store;
gpointer sort_state;
sort_state = save_sort_state (app->descendants_view);
if (app->callers)
{
profile_caller_free (app->callers);
app->callers = NULL;
}
list_store =
gtk_list_store_new (4,
G_TYPE_STRING,
G_TYPE_DOUBLE,
G_TYPE_DOUBLE,
G_TYPE_POINTER);
if (app->profile)
{
ProfileObject *object = get_current_object (app);
if (object)
{
app->callers = profile_list_callers (app->profile, object);
add_callers (list_store, app->profile, app->callers);
}
}
gtk_tree_view_set_model (
app->callers_view, GTK_TREE_MODEL (list_store));
g_object_unref (G_OBJECT (list_store));
if (!sort_state)
{
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store),
CALLERS_TOTAL,
GTK_SORT_DESCENDING);
}
else
{
restore_sort_state (app->callers_view, sort_state);
}
gtk_tree_view_columns_autosize (app->callers_view);
}
static void static void
on_object_selection_changed (GtkTreeSelection *selection, gpointer data) on_object_selection_changed (GtkTreeSelection *selection, gpointer data)
{ {
@ -1001,6 +1011,21 @@ set_sizes (GtkWindow *window,
gtk_paned_set_position (GTK_PANED (hpaned), width / 2); gtk_paned_set_position (GTK_PANED (hpaned), width / 2);
} }
static void
set_shadows (GladeXML *xml)
{
/* Get rid of motif out-bevels */
gtk_rc_parse_string (
"style \"blah\" "
"{ "
" GtkToolbar::shadow_type = none "
" GtkMenuBar::shadow_type = none "
"} "
"widget \"*toolbar\" style : rc \"blah\"\n"
"widget \"*menubar\" style : rc \"blah\"\n"
);
}
static void static void
build_gui (Application *app) build_gui (Application *app)
{ {
@ -1008,6 +1033,8 @@ build_gui (Application *app)
GtkTreeSelection *selection; GtkTreeSelection *selection;
GtkTreeViewColumn *col; GtkTreeViewColumn *col;
set_shadows (xml);
xml = glade_xml_new ("./sysprof.glade", NULL, NULL); xml = glade_xml_new ("./sysprof.glade", NULL, NULL);
/* Main Window */ /* Main Window */

View File

@ -25,7 +25,7 @@
<property name="spacing">0</property> <property name="spacing">0</property>
<child> <child>
<widget class="GtkMenuBar" id="menubar1"> <widget class="GtkMenuBar" id="menubar">
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
@ -205,6 +205,17 @@
</packing> </packing>
</child> </child>
<child>
<widget class="GtkHSeparator" id="hseparator1">
<property name="visible">True</property>
</widget>
<packing>
<property name="padding">2</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child> <child>
<widget class="GtkHBox" id="hbox1"> <widget class="GtkHBox" id="hbox1">
<property name="visible">True</property> <property name="visible">True</property>
@ -212,7 +223,7 @@
<property name="spacing">0</property> <property name="spacing">0</property>
<child> <child>
<widget class="GtkToolbar" id="toolbar1"> <widget class="GtkToolbar" id="toolbar">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property> <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
<property name="tooltips">True</property> <property name="tooltips">True</property>
@ -330,7 +341,7 @@
</child> </child>
<child> <child>
<widget class="GtkToolbar" id="toolbar2"> <widget class="GtkToolbar" id="samples-toolbar">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property> <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
<property name="toolbar_style">GTK_TOOLBAR_BOTH_HORIZ</property> <property name="toolbar_style">GTK_TOOLBAR_BOTH_HORIZ</property>