Commit f2374329 authored by Christian Persch's avatar Christian Persch

Use gdk_threads_add_idle. Bug #504571.

svn path=/trunk/; revision=19222
parent 629fad2f
2007-12-22 Christian Persch <chpe@gnome.org>
* modules/other/gail/gail.c:
* modules/other/gail/gailbutton.c:
* modules/other/gail/gailcell.c:
* modules/other/gail/gailcombo.c:
* modules/other/gail/gailcombo.h:
* modules/other/gail/gailcombobox.c:
* modules/other/gail/gailentry.c:
* modules/other/gail/gailexpander.c:
* modules/other/gail/gailmenuitem.c:
* modules/other/gail/gailnotebook.c:
* modules/other/gail/gailnotebookpage.c:
* modules/other/gail/gailnotebookpage.h:
* modules/other/gail/gailoptionmenu.c:
* modules/other/gail/gailrange.c:
* modules/other/gail/gailtextview.c:
* modules/other/gail/gailtreeview.c:
* modules/other/gail/gailtreeview.h:
* modules/other/gail/gailwindow.c: Use gdk_threads_add_idle.
Bug #504571.
2007-12-22 Matthias Clasen <mclasen@redhat.com>
* modules/other/gail/gailclist.c: Chain up the finalizer (#504570,
......
......@@ -509,12 +509,9 @@ gail_switch_page_watcher (GSignalInvocationHint *ihint,
return TRUE;
}
static gint
static gboolean
gail_focus_idle_handler (gpointer data)
{
GDK_THREADS_ENTER();
focus_notify_handler = 0;
/*
* The widget which was to receive focus may have been removed
......@@ -522,10 +519,7 @@ gail_focus_idle_handler (gpointer data)
if (!next_focus_widget)
{
if (next_focus_widget != data)
{
GDK_THREADS_LEAVE ();
return FALSE;
}
return FALSE;
}
else
{
......@@ -536,8 +530,7 @@ gail_focus_idle_handler (gpointer data)
gail_focus_notify (data);
GDK_THREADS_LEAVE ();
return FALSE;
return FALSE;
}
static void
......@@ -656,7 +649,7 @@ gail_focus_notify_when_idle (GtkWidget *widget)
}
}
focus_notify_handler = g_idle_add (gail_focus_idle_handler, widget);
focus_notify_handler = gdk_threads_add_idle (gail_focus_idle_handler, widget);
}
static gboolean
......
......@@ -547,7 +547,7 @@ gail_button_do_action (AtkAction *action,
}
g_queue_push_head (button->action_queue, (gpointer) i);
if (!button->action_idle_handler)
button->action_idle_handler = g_idle_add (idle_do_action, button);
button->action_idle_handler = gdk_threads_add_idle (idle_do_action, button);
break;
default:
return_value = FALSE;
......@@ -564,8 +564,6 @@ idle_do_action (gpointer data)
GailButton *gail_button;
GdkEvent tmp_event;
GDK_THREADS_ENTER ();
gail_button = GAIL_BUTTON (data);
gail_button->action_idle_handler = 0;
widget = GTK_ACCESSIBLE (gail_button)->widget;
......@@ -578,10 +576,7 @@ idle_do_action (gpointer data)
if (widget == NULL /* State is defunct */ ||
!GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
{
GDK_THREADS_LEAVE ();
return FALSE;
}
return FALSE;
else
gtk_widget_event (widget, &tmp_event);
......@@ -627,9 +622,7 @@ idle_do_action (gpointer data)
}
}
GDK_THREADS_LEAVE ();
return FALSE;
return FALSE;
}
static gint
......
......@@ -510,7 +510,7 @@ gail_cell_action_do_action (AtkAction *action,
if (cell->action_idle_handler)
return FALSE;
cell->action_func = info->do_action_func;
cell->action_idle_handler = g_idle_add (idle_do_action, cell);
cell->action_idle_handler = gdk_threads_add_idle (idle_do_action, cell);
return TRUE;
}
......@@ -519,14 +519,10 @@ idle_do_action (gpointer data)
{
GailCell *cell;
GDK_THREADS_ENTER ();
cell = GAIL_CELL (data);
cell->action_idle_handler = 0;
cell->action_func (cell);
GDK_THREADS_LEAVE ();
return FALSE;
}
......
......@@ -187,16 +187,12 @@ notify_deselect (gpointer data)
{
GailCombo *combo;
GDK_THREADS_ENTER ();
combo = GAIL_COMBO (data);
combo->old_selection = NULL;
combo->deselect_idle_handler = 0;
g_signal_emit_by_name (data, "selection_changed");
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -205,15 +201,11 @@ notify_select (gpointer data)
{
GailCombo *combo;
GDK_THREADS_ENTER ();
combo = GAIL_COMBO (data);
combo->select_idle_handler = 0;
g_signal_emit_by_name (data, "selection_changed");
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -240,7 +232,7 @@ gail_combo_selection_changed_gtk (GtkWidget *widget,
{
gail_combo->old_selection = slist->data;
if (gail_combo->select_idle_handler == 0)
gail_combo->select_idle_handler = g_idle_add (notify_select, gail_combo);
gail_combo->select_idle_handler = gdk_threads_add_idle (notify_select, gail_combo);
}
if (gail_combo->deselect_idle_handler)
{
......@@ -251,7 +243,7 @@ gail_combo_selection_changed_gtk (GtkWidget *widget,
else
{
if (gail_combo->deselect_idle_handler == 0)
gail_combo->deselect_idle_handler = g_idle_add (notify_deselect, gail_combo);
gail_combo->deselect_idle_handler = gdk_threads_add_idle (notify_deselect, gail_combo);
if (gail_combo->select_idle_handler)
{
g_source_remove (gail_combo->select_idle_handler);
......@@ -344,7 +336,7 @@ gail_combo_do_action (AtkAction *action,
if (combo->action_idle_handler)
return FALSE;
combo->action_idle_handler = g_idle_add (idle_do_action, combo);
combo->action_idle_handler = gdk_threads_add_idle (idle_do_action, combo);
return TRUE;
}
else
......@@ -369,17 +361,12 @@ idle_do_action (gpointer data)
gboolean do_popup;
GdkEvent tmp_event;
GDK_THREADS_ENTER ();
gail_combo = GAIL_COMBO (data);
gail_combo->action_idle_handler = 0;
widget = GTK_ACCESSIBLE (gail_combo)->widget;
if (widget == NULL /* State is defunct */ ||
!GTK_WIDGET_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
{
GDK_THREADS_LEAVE ();
return FALSE;
}
return FALSE;
combo = GTK_COMBO (widget);
......@@ -399,6 +386,7 @@ idle_do_action (gpointer data)
gtk_widget_event (action_widget, &tmp_event);
/* FIXME !*/
g_idle_add (_gail_combo_button_release, combo);
}
else
......@@ -409,11 +397,10 @@ idle_do_action (gpointer data)
action_widget = combo->popwin;
gtk_widget_event (action_widget, &tmp_event);
/* FIXME !*/
g_idle_add (_gail_combo_popup_release, combo);
}
GDK_THREADS_LEAVE ();
return FALSE;
}
......
......@@ -42,10 +42,10 @@ struct _GailCombo
{
GailContainer parent;
gpointer old_selection;
gchar *press_description;
guint action_idle_handler;
gpointer old_selection;
guint action_idle_handler;
guint select_idle_handler;
guint deselect_idle_handler;
};
......
......@@ -379,7 +379,7 @@ gail_combo_box_do_action (AtkAction *action,
if (combo_box->action_idle_handler)
return FALSE;
combo_box->action_idle_handler = g_idle_add (idle_do_action, combo_box);
combo_box->action_idle_handler = gdk_threads_add_idle (idle_do_action, combo_box);
return TRUE;
}
else
......@@ -395,17 +395,12 @@ idle_do_action (gpointer data)
AtkObject *popup;
gboolean do_popup;
GDK_THREADS_ENTER ();
gail_combo_box = GAIL_COMBO_BOX (data);
gail_combo_box->action_idle_handler = 0;
widget = GTK_ACCESSIBLE (gail_combo_box)->widget;
if (widget == NULL || /* State is defunct */
!GTK_WIDGET_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
{
GDK_THREADS_LEAVE ();
return FALSE;
}
return FALSE;
combo_box = GTK_COMBO_BOX (widget);
......@@ -416,8 +411,6 @@ idle_do_action (gpointer data)
else
gtk_combo_box_popdown (combo_box);
GDK_THREADS_LEAVE ();
return FALSE;
}
......
......@@ -1067,14 +1067,10 @@ idle_notify_insert (gpointer data)
{
GailEntry *entry;
GDK_THREADS_ENTER ();
entry = GAIL_ENTRY (data);
entry->insert_idle_handler = 0;
gail_entry_notify_insert (entry);
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -1117,7 +1113,7 @@ _gail_entry_insert_text_cb (GtkEntry *entry,
* or in an idle handler if it not updated.
*/
if (gail_entry->insert_idle_handler == 0)
gail_entry->insert_idle_handler = g_idle_add (idle_notify_insert, gail_entry);
gail_entry->insert_idle_handler = gdk_threads_add_idle (idle_notify_insert, gail_entry);
}
static gunichar
......@@ -1274,7 +1270,7 @@ gail_entry_do_action (AtkAction *action,
if (entry->action_idle_handler)
return_value = FALSE;
else
entry->action_idle_handler = g_idle_add (idle_do_action, entry);
entry->action_idle_handler = gdk_threads_add_idle (idle_do_action, entry);
break;
default:
return_value = FALSE;
......@@ -1289,22 +1285,15 @@ idle_do_action (gpointer data)
GailEntry *entry;
GtkWidget *widget;
GDK_THREADS_ENTER ();
entry = GAIL_ENTRY (data);
entry->action_idle_handler = 0;
widget = GTK_ACCESSIBLE (entry)->widget;
if (widget == NULL /* State is defunct */ ||
!GTK_WIDGET_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
{
GDK_THREADS_LEAVE ();
return FALSE;
}
return FALSE;
gtk_widget_activate (widget);
GDK_THREADS_LEAVE ();
return FALSE;
}
......
......@@ -434,7 +434,7 @@ gail_expander_do_action (AtkAction *action,
if (expander->action_idle_handler)
return_value = FALSE;
else
expander->action_idle_handler = g_idle_add (idle_do_action, expander);
expander->action_idle_handler = gdk_threads_add_idle (idle_do_action, expander);
break;
default:
return_value = FALSE;
......@@ -449,24 +449,17 @@ idle_do_action (gpointer data)
GtkWidget *widget;
GailExpander *gail_expander;
GDK_THREADS_ENTER ();
gail_expander = GAIL_EXPANDER (data);
gail_expander->action_idle_handler = 0;
widget = GTK_ACCESSIBLE (gail_expander)->widget;
if (widget == NULL /* State is defunct */ ||
!GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
{
GDK_THREADS_LEAVE ();
return FALSE;
}
return FALSE;
gtk_widget_activate (widget);
GDK_THREADS_LEAVE ();
return FALSE;
return FALSE;
}
static gint
......
......@@ -311,8 +311,11 @@ gail_menu_item_do_action (AtkAction *action,
return FALSE;
else
{
g_object_ref (gail_menu_item);
gail_menu_item->action_idle_handler = g_idle_add (idle_do_action, gail_menu_item);
gail_menu_item->action_idle_handler =
gdk_threads_add_idle_full (G_PRIORITY_DEFAULT_IDLE,
idle_do_action,
g_object_ref (gail_menu_item),
(GDestroyNotify) g_object_unref);
}
return TRUE;
}
......@@ -352,18 +355,12 @@ idle_do_action (gpointer data)
GailMenuItem *menu_item;
gboolean item_mapped;
GDK_THREADS_ENTER ();
menu_item = GAIL_MENU_ITEM (data);
menu_item->action_idle_handler = 0;
item = GTK_ACCESSIBLE (menu_item)->widget;
if (item == NULL /* State is defunct */ ||
!GTK_WIDGET_SENSITIVE (item) || !GTK_WIDGET_VISIBLE (item))
{
g_object_unref (menu_item);
GDK_THREADS_LEAVE ();
return FALSE;
}
item_parent = gtk_widget_get_parent (item);
gtk_menu_shell_select_item (GTK_MENU_SHELL (item_parent), item);
......@@ -376,9 +373,6 @@ idle_do_action (gpointer data)
if (!item_mapped)
ensure_menus_unposted (menu_item);
g_object_unref (menu_item);
GDK_THREADS_LEAVE ();
return FALSE;
}
......
......@@ -310,7 +310,7 @@ gail_notebook_real_notify_gtk (GObject *obj,
{
if (gail_notebook->idle_focus_id)
g_source_remove (gail_notebook->idle_focus_id);
gail_notebook->idle_focus_id = g_idle_add (gail_notebook_check_focus_tab, atk_obj);
gail_notebook->idle_focus_id = gdk_threads_add_idle (gail_notebook_check_focus_tab, atk_obj);
}
}
else
......@@ -337,6 +337,10 @@ gail_notebook_finalize (GObject *object)
}
g_list_free (notebook->page_cache);
if (notebook->idle_focus_id)
g_source_remove (notebook->idle_focus_id);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
......@@ -593,9 +597,8 @@ gail_notebook_focus_cb (GtkWidget *widget,
{
case GTK_DIR_LEFT:
case GTK_DIR_RIGHT:
if (gail_notebook->idle_focus_id)
g_source_remove (gail_notebook->idle_focus_id);
gail_notebook->idle_focus_id = g_idle_add (gail_notebook_check_focus_tab, atk_obj);
if (gail_notebook->idle_focus_id == 0)
gail_notebook->idle_focus_id = gdk_threads_add_idle (gail_notebook_check_focus_tab, atk_obj);
break;
default:
break;
......@@ -612,8 +615,6 @@ gail_notebook_check_focus_tab (gpointer data)
GailNotebook *gail_notebook;
GtkNotebook *gtk_notebook;
GDK_THREADS_ENTER ();
atk_obj = ATK_OBJECT (data);
gail_notebook = GAIL_NOTEBOOK (atk_obj);
widget = GTK_ACCESSIBLE (atk_obj)->widget;
......@@ -623,10 +624,7 @@ gail_notebook_check_focus_tab (gpointer data)
gail_notebook->idle_focus_id = 0;
if (!gtk_notebook->focus_tab)
{
GDK_THREADS_LEAVE ();
return FALSE;
}
return FALSE;
old_focus_page_num = gail_notebook->focus_tab_page;
focus_page_num = g_list_index (gtk_notebook->children, gtk_notebook->focus_tab->data);
......@@ -640,8 +638,6 @@ gail_notebook_check_focus_tab (gpointer data)
g_object_unref (obj);
}
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -651,5 +647,8 @@ gail_notebook_destroyed (gpointer data)
GailNotebook *gail_notebook = GAIL_NOTEBOOK (data);
if (gail_notebook->idle_focus_id)
g_source_remove (gail_notebook->idle_focus_id);
{
g_source_remove (gail_notebook->idle_focus_id);
gail_notebook->idle_focus_id = 0;
}
}
......@@ -184,12 +184,12 @@ notify_child_added (gpointer data)
GailNotebookPage *page;
AtkObject *atk_object, *atk_parent;
GDK_THREADS_ENTER ();
g_return_val_if_fail (GAIL_IS_NOTEBOOK_PAGE (data), FALSE);
page = GAIL_NOTEBOOK_PAGE (data);
atk_object = ATK_OBJECT (data);
page->notify_child_added_id = 0;
/* The widget page->notebook may be deleted before this handler is called */
if (page->notebook != NULL)
{
......@@ -198,8 +198,6 @@ notify_child_added (gpointer data)
g_signal_emit_by_name (atk_parent, "children_changed::add", page->index, atk_object, NULL);
}
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -236,7 +234,7 @@ gail_notebook_page_new (GtkNotebook *notebook,
atk_object->role = ATK_ROLE_PAGE_TAB;
atk_object->layer = ATK_LAYER_WIDGET;
g_idle_add (notify_child_added, atk_object);
page->notify_child_added_id = gdk_threads_add_idle (notify_child_added, atk_object);
/*
* We get notified of changes to the label
*/
......@@ -329,8 +327,10 @@ gail_notebook_page_finalize (GObject *object)
if (page->textutil)
g_object_unref (page->textutil);
G_OBJECT_CLASS (parent_class)->finalize (object);
if (page->notify_child_added_id)
g_source_remove (page->notify_child_added_id);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static G_CONST_RETURN gchar*
......
......@@ -47,6 +47,7 @@ struct _GailNotebookPage
GtkNotebookPage *page;
gint index;
guint notify_child_added_id;
GailTextUtil *textutil;
};
......
......@@ -256,7 +256,7 @@ gail_option_menu_do_action (AtkAction *action,
if (button->action_idle_handler)
return_value = FALSE;
else
button->action_idle_handler = g_idle_add (idle_do_action, button);
button->action_idle_handler = gdk_threads_add_idle (idle_do_action, button);
break;
default:
return_value = FALSE;
......@@ -273,18 +273,13 @@ idle_do_action (gpointer data)
GdkEvent tmp_event;
GailButton *gail_button;
GDK_THREADS_ENTER ();
gail_button = GAIL_BUTTON (data);
gail_button->action_idle_handler = 0;
widget = GTK_ACCESSIBLE (gail_button)->widget;
if (widget == NULL /* State is defunct */ ||
!GTK_WIDGET_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
{
GDK_THREADS_LEAVE ();
return FALSE;
}
return FALSE;
button = GTK_BUTTON (widget);
......@@ -303,9 +298,7 @@ idle_do_action (gpointer data)
gtk_widget_event (widget, &tmp_event);
GDK_THREADS_LEAVE ();
return FALSE;
return FALSE;
}
static gint
......
......@@ -412,7 +412,7 @@ gail_range_do_action (AtkAction *action,
if (range->action_idle_handler)
return_value = FALSE;
else
range->action_idle_handler = g_idle_add (idle_do_action, range);
range->action_idle_handler = gdk_threads_add_idle (idle_do_action, range);
}
else
return_value = FALSE;
......@@ -425,22 +425,15 @@ idle_do_action (gpointer data)
GailRange *range;
GtkWidget *widget;
GDK_THREADS_ENTER ();
range = GAIL_RANGE (data);
range->action_idle_handler = 0;
widget = GTK_ACCESSIBLE (range)->widget;
if (widget == NULL /* State is defunct */ ||
!GTK_WIDGET_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
{
GDK_THREADS_LEAVE ();
return FALSE;
}
gtk_widget_activate (widget);
GDK_THREADS_LEAVE ();
return FALSE;
}
......
......@@ -1591,7 +1591,7 @@ _gail_text_view_changed_cb (GtkTextBuffer *buffer,
{
if (!gail_text_view->insert_notify_handler)
{
gail_text_view->insert_notify_handler = g_idle_add (insert_idle_handler, accessible);
gail_text_view->insert_notify_handler = gdk_threads_add_idle (insert_idle_handler, accessible);
}
return;
}
......@@ -1680,8 +1680,6 @@ insert_idle_handler (gpointer data)
GailTextView *gail_text_view;
GtkTextBuffer *buffer;
GDK_THREADS_ENTER ();
gail_text_view = GAIL_TEXT_VIEW (data);
g_signal_emit_by_name (data,
......@@ -1703,8 +1701,6 @@ insert_idle_handler (gpointer data)
gail_text_view->previous_selection_bound = get_selection_bound (buffer);
}
GDK_THREADS_LEAVE ();
return FALSE;
}
......
......@@ -687,7 +687,11 @@ gail_tree_view_finalize (GObject *object)
/* remove any idle handlers still pending */
if (view->idle_garbage_collect_id)
g_source_remove (view->idle_garbage_collect_id);
g_source_remove (view->idle_garbage_collect_id);
if (view->idle_cursor_changed_id)
g_source_remove (view->idle_cursor_changed_id);
if (view->idle_expand_id)
g_source_remove (view->idle_expand_id);
if (view->caption)
g_object_unref (view->caption);
......@@ -2299,8 +2303,9 @@ gail_tree_view_expand_row_gtk (GtkTreeView *tree_view,
*/
/* this seems wrong since it overwrites any other pending expand handlers... */
gailview->idle_expand_path = gtk_tree_path_copy (path);
if (gailview->idle_expand_id) g_source_remove (gailview->idle_expand_id);
gailview->idle_expand_id = g_idle_add (idle_expand_row, gailview);
if (gailview->idle_expand_id)
g_source_remove (gailview->idle_expand_id);
gailview->idle_expand_id = gdk_threads_add_idle (idle_expand_row, gailview);
return FALSE;
}
......@@ -2314,7 +2319,7 @@ idle_expand_row (gpointer data)
GtkTreeModel *tree_model;
gint n_inserted, row;
GDK_THREADS_ENTER ();
gailview->idle_expand_id = 0;
path = gailview->idle_expand_path;
tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (gailview)->widget);
......@@ -2322,14 +2327,11 @@ idle_expand_row (gpointer data)
g_assert (GTK_IS_TREE_VIEW (tree_view));
tree_model = gtk_tree_view_get_model(tree_view);
g_assert (GTK_IS_TREE_MODEL (tree_model));
if (!tree_model)
return FALSE;
if (!path || !gtk_tree_model_get_iter (tree_model, &iter, path))
{
GDK_THREADS_LEAVE ();
return FALSE;
}
return FALSE;
/*
* Update visibility of cells below expansion row
......@@ -2358,7 +2360,6 @@ idle_expand_row (gpointer data)
else
{
/* We can get here if the row expanded callback deleted the row */
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -2380,8 +2381,6 @@ idle_expand_row (gpointer data)
gtk_tree_path_free (path);
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -2661,45 +2660,42 @@ columns_changed (GtkTreeView *tree_view)
static void
cursor_changed (GtkTreeView *tree_view)
{
GailTreeView *gailview;
gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view)));
if (gailview->idle_cursor_changed_id != 0)
return;
/*
* We notify the focus change in a idle handler so that the processing
* of the cursor change is completed when the focus handler is called.
* This will allow actions to be called in the focus handler
*/
g_idle_add (idle_cursor_changed, gtk_widget_get_accessible (GTK_WIDGET (tree_view)));
gailview->idle_cursor_changed_id = gdk_threads_add_idle (idle_cursor_changed, gailview);
}
static gint
idle_cursor_changed (gpointer data)
{
GailTreeView *gail_tree_view = GAIL_TREE_VIEW (data);
GtkTreeView *tree_view;
GtkWidget *widget;
AtkObject *parent;
AtkObject *cell;
GDK_THREADS_ENTER ();
gail_tree_view->idle_cursor_changed_id = 0;
parent = ATK_OBJECT (data);
widget = GTK_ACCESSIBLE (parent)->widget;
widget = GTK_ACCESSIBLE (gail_tree_view)->widget;
/*
* Widget has been deleted
*/
if (widget == NULL)
{
GDK_THREADS_LEAVE ();
return FALSE;
}
return FALSE;
tree_view = GTK_TREE_VIEW (widget);
cell = gail_tree_view_ref_focus_cell (tree_view);