mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
Update screenshot window in an idle handler to deal with the case where
2007-03-24 Soren Sandmann <sandmann@daimi.au.dk> * sysprof.c (update_screenshot_window): Update screenshot window in an idle handler to deal with the case where someone presses "Shift Right Arrow" svn path=/trunk/; revision=362
This commit is contained in:
committed by
Søren Sandmann Pedersen
parent
7b821752f9
commit
0cc4c86195
@ -1,3 +1,9 @@
|
|||||||
|
2007-03-24 Soren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
|
* sysprof.c (update_screenshot_window): Update screenshot window
|
||||||
|
in an idle handler to deal with the case where someone presses
|
||||||
|
"Shift Right Arrow"
|
||||||
|
|
||||||
Mon Mar 5 16:55:39 2007 Søren Sandmann <sandmann@redhat.com>
|
Mon Mar 5 16:55:39 2007 Søren Sandmann <sandmann@redhat.com>
|
||||||
|
|
||||||
* binfile.c (already_warned): New function. Only warn once about
|
* binfile.c (already_warned): New function. Only warn once about
|
||||||
|
|||||||
63
sysprof.c
63
sysprof.c
@ -82,6 +82,7 @@ struct Application
|
|||||||
ProfileCaller * callers;
|
ProfileCaller * callers;
|
||||||
|
|
||||||
int timeout_id;
|
int timeout_id;
|
||||||
|
int update_screenshot_id;
|
||||||
|
|
||||||
char * loaded_profile;
|
char * loaded_profile;
|
||||||
|
|
||||||
@ -253,13 +254,19 @@ set_busy (GtkWidget *widget,
|
|||||||
gboolean busy)
|
gboolean busy)
|
||||||
{
|
{
|
||||||
GdkCursor *cursor;
|
GdkCursor *cursor;
|
||||||
|
GdkWindow *window;
|
||||||
|
|
||||||
if (busy)
|
if (busy)
|
||||||
cursor = gdk_cursor_new (GDK_WATCH);
|
cursor = gdk_cursor_new (GDK_WATCH);
|
||||||
else
|
else
|
||||||
cursor = NULL;
|
cursor = NULL;
|
||||||
|
|
||||||
gdk_window_set_cursor (widget->window, cursor);
|
if (GTK_IS_TEXT_VIEW (widget))
|
||||||
|
window = gtk_text_view_get_window (GTK_TEXT_VIEW (widget), GTK_TEXT_WINDOW_TEXT);
|
||||||
|
else
|
||||||
|
window = widget->window;
|
||||||
|
|
||||||
|
gdk_window_set_cursor (window, cursor);
|
||||||
|
|
||||||
if (cursor)
|
if (cursor)
|
||||||
gdk_cursor_unref (cursor);
|
gdk_cursor_unref (cursor);
|
||||||
@ -1112,10 +1119,16 @@ add_text (GtkTreeView *view,
|
|||||||
g_free (name);
|
g_free (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
update_screenshot_window (Application *app)
|
update_screenshot_window_idle (gpointer data)
|
||||||
{
|
{
|
||||||
GtkTextBuffer *text_buffer =
|
Application *app = data;
|
||||||
|
GtkTextBuffer *text_buffer;
|
||||||
|
|
||||||
|
if (!app->screenshot_window_visible)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
text_buffer =
|
||||||
gtk_text_view_get_buffer (GTK_TEXT_VIEW (app->screenshot_textview));
|
gtk_text_view_get_buffer (GTK_TEXT_VIEW (app->screenshot_textview));
|
||||||
|
|
||||||
gtk_text_buffer_set_text (text_buffer, "", -1);
|
gtk_text_buffer_set_text (text_buffer, "", -1);
|
||||||
@ -1141,6 +1154,41 @@ update_screenshot_window (Application *app)
|
|||||||
|
|
||||||
g_string_free (info.text, TRUE);
|
g_string_free (info.text, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app->update_screenshot_id = 0;
|
||||||
|
|
||||||
|
if (app->screenshot_window_visible)
|
||||||
|
{
|
||||||
|
set_busy (app->screenshot_window, FALSE);
|
||||||
|
set_busy (app->screenshot_textview, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_screenshot_window (Application *app)
|
||||||
|
{
|
||||||
|
/* We do this in an idle handler to deal with the case where
|
||||||
|
* someone presses Shift-RightArrow on the root of a huge
|
||||||
|
* profile. This causes a ton of 'expanded' notifications,
|
||||||
|
* each of which would cause us to traverse the tree and
|
||||||
|
* update the screenshot window.
|
||||||
|
*/
|
||||||
|
if (app->update_screenshot_id)
|
||||||
|
g_source_remove (app->update_screenshot_id);
|
||||||
|
|
||||||
|
if (app->screenshot_window_visible)
|
||||||
|
{
|
||||||
|
/* don't swamp the X server with cursor change requests */
|
||||||
|
if (!app->update_screenshot_id)
|
||||||
|
{
|
||||||
|
set_busy (app->screenshot_window, TRUE);
|
||||||
|
set_busy (app->screenshot_textview, TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
app->update_screenshot_id = g_idle_add (update_screenshot_window_idle, app);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1152,7 +1200,6 @@ on_descendants_row_expanded_or_collapsed (GtkTreeView *tree,
|
|||||||
update_screenshot_window (app);
|
update_screenshot_window (app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_object_selection_changed (GtkTreeSelection *selection,
|
on_object_selection_changed (GtkTreeSelection *selection,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
@ -1161,6 +1208,8 @@ on_object_selection_changed (GtkTreeSelection *selection,
|
|||||||
|
|
||||||
set_busy (app->main_window, TRUE);
|
set_busy (app->main_window, TRUE);
|
||||||
|
|
||||||
|
update_screenshot_window (app);
|
||||||
|
|
||||||
gdk_window_process_all_updates (); /* Display updated selection */
|
gdk_window_process_all_updates (); /* Display updated selection */
|
||||||
|
|
||||||
fill_descendants_tree (app);
|
fill_descendants_tree (app);
|
||||||
@ -1169,8 +1218,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1265,6 +1312,8 @@ on_screenshot_activated (GtkCheckMenuItem *menu_item,
|
|||||||
{
|
{
|
||||||
app->screenshot_window_visible = gtk_check_menu_item_get_active (menu_item);
|
app->screenshot_window_visible = gtk_check_menu_item_get_active (menu_item);
|
||||||
|
|
||||||
|
update_screenshot_window (app);
|
||||||
|
|
||||||
update_sensitivity (app);
|
update_sensitivity (app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user