Commit 721c3bc1 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen
Browse files

Replace a lot of idle and timeout calls by the new gdk_threads api.

2006-12-22  Matthias Clasen  <mclasen@redhat.com>

        * *.c: Replace a lot of idle and timeout calls by
        the new gdk_threads api.
parent 7854bd1b
2006-12-22 Matthias Clasen <mclasen@redhat.com>
* *.c: Replace a lot of idle and timeout calls by
the new gdk_threads api.
* gdk/gdk.symbols:
* gdk/gdk.h:
* gdk/gdk.c: Add functions to allow threadsafe handling
......
......@@ -255,7 +255,7 @@ start_progressive_loading (GtkWidget *image)
* The timeout simply simulates a slow data source by inserting
* pauses in the reading process.
*/
load_timeout = g_timeout_add (150,
load_timeout = gdk_threads_add_timeout (150,
progressive_timeout,
image);
}
......
......@@ -187,7 +187,9 @@ timeout (gpointer data)
: MAX (127, fabs (255 * cos (f * 2.0 * G_PI)))));
}
GDK_THREADS_ENTER ();
gtk_widget_queue_draw (da);
GDK_THREADS_LEAVE ();
frame_num++;
return TRUE;
......
......@@ -225,7 +225,7 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (window), da);
timeout_id = g_timeout_add (FRAME_DELAY, timeout, NULL);
timeout_id = gdk_threads_add_timeout (FRAME_DELAY, timeout, NULL);
gtk_widget_show_all (window);
gtk_main ();
......
......@@ -301,7 +301,7 @@ start_progressive_loading (GtkWidget *image)
* The timeout simply simulates a slow data source by inserting
* pauses in the reading process.
*/
lc->load_timeout = g_timeout_add (100,
lc->load_timeout = gdk_threads_add_timeout (100,
progressive_timeout,
image);
}
......
......@@ -628,7 +628,7 @@ main (int argc, char **argv)
status.readlen = readlen;
status.timeout = g_timeout_add (100, update_timeout, &status);
status.timeout = gdk_threads_add_timeout (100, update_timeout, &status);
}
#endif
}
......
......@@ -90,7 +90,7 @@ static void
realize_callback (GtkWidget *widget,
WidgetInfo *info)
{
g_timeout_add (500, (GSourceFunc)adjust_size_callback, info);
gdk_threads_add_timeout (500, (GSourceFunc)adjust_size_callback, info);
}
static WidgetInfo *
......
......@@ -585,8 +585,8 @@ gtk_dial_update_mouse( GtkDial *dial, gint x, gint y )
if (dial->timer)
g_source_remove (dial->timer);
dial->timer = g_timeout_add (SCROLL_DELAY_LENGTH,
(GtkFunction) gtk_dial_timer,
dial->timer = gdk_threads_add_timeout (SCROLL_DELAY_LENGTH,
(GSourceFunc) gtk_dial_timer,
(gpointer) dial);
}
}
......
......@@ -134,7 +134,7 @@ int main( int argc,
gtk_widget_show (pdata->pbar);
/* Add a timer callback to update the value of the progress bar */
pdata->timer = g_timeout_add (100, progress_timeout, pdata);
pdata->timer = gdk_threads_add_timeout (100, progress_timeout, pdata);
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
......
......@@ -100,9 +100,7 @@ gdk_window_directfb_process_all_updates (void)
static gboolean
gdk_window_update_idle (gpointer data)
{
GDK_THREADS_ENTER ();
gdk_window_directfb_process_all_updates ();
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -115,7 +113,7 @@ gdk_window_schedule_update (GdkWindow *window)
if (!update_idle)
{
update_idle = g_idle_add_full (GDK_PRIORITY_REDRAW,
update_idle = gdk_threads_add_idle (GDK_PRIORITY_REDRAW,
gdk_window_update_idle, NULL, NULL);
}
}
......
......@@ -209,6 +209,23 @@ guint gdk_threads_add_timeout (guint interval,
gpointer data);
guint gdk_threads_add_idle_full (gint priority,
GSourceFunc function,
gpointer data,
GDestroyNotify notify);
guint gdk_threads_add_idle (GSourceFunc function,
gpointer data);
guint gdk_threads_add_timeout_full (gint priority,
guint interval,
GSourceFunc function,
gpointer data,
GDestroyNotify notify);
guint gdk_threads_add_timeout (guint interval,
GSourceFunc function,
gpointer data);
#ifdef G_THREADS_ENABLED
# define GDK_THREADS_ENTER() G_STMT_START { \
if (gdk_threads_lock) \
......
......@@ -2240,9 +2240,7 @@ static gboolean debug_updates = FALSE;
static gboolean
gdk_window_update_idle (gpointer data)
{
GDK_THREADS_ENTER ();
gdk_window_process_all_updates ();
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -2255,7 +2253,7 @@ gdk_window_schedule_update (GdkWindow *window)
if (!update_idle)
{
update_idle = g_idle_add_full (GDK_PRIORITY_REDRAW,
update_idle = gdk_threads_add_idle_full (GDK_PRIORITY_REDRAW,
gdk_window_update_idle, NULL, NULL);
}
}
......
......@@ -690,7 +690,7 @@ set_ignore_core (gboolean ignore)
}
else
if (!ignore_core_timer)
ignore_core_timer = g_timeout_add (PROXIMITY_OUT_DELAY,
ignore_core_timer = gdk_threads_add_timeout (PROXIMITY_OUT_DELAY,
ignore_core_timefunc, NULL);
}
#endif /* HAVE_WINTAB */
......
......@@ -1490,12 +1490,8 @@ gtk_real_button_released (GtkButton *button)
static gboolean
button_activate_timeout (gpointer data)
{
GDK_THREADS_ENTER ();
gtk_button_finish_activate (data, TRUE);
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -1520,7 +1516,7 @@ gtk_real_button_activate (GtkButton *button)
gtk_grab_add (widget);
button->activate_timeout = g_timeout_add (ACTIVATE_TIMEOUT,
button->activate_timeout = gdk_threads_add_timeout (ACTIVATE_TIMEOUT,
button_activate_timeout,
button);
button->button_down = TRUE;
......
......@@ -2374,8 +2374,6 @@ calendar_timer (gpointer data)
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar);
gboolean retval = FALSE;
GDK_THREADS_ENTER ();
if (priv->timer)
{
calendar_arrow_action (calendar, priv->click_child);
......@@ -2389,7 +2387,7 @@ calendar_timer (gpointer data)
g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL);
priv->need_timer = FALSE;
priv->timer = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
priv->timer = gdk_threads_add_timeout_full (G_PRIORITY_DEFAULT_IDLE,
timeout * SCROLL_DELAY_FACTOR,
(GSourceFunc) calendar_timer,
(gpointer) calendar, NULL);
......@@ -2398,8 +2396,6 @@ calendar_timer (gpointer data)
retval = TRUE;
}
GDK_THREADS_LEAVE ();
return retval;
}
......@@ -2420,7 +2416,7 @@ calendar_start_spinning (GtkCalendar *calendar,
g_object_get (settings, "gtk-timeout-initial", &timeout, NULL);
priv->need_timer = TRUE;
priv->timer = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
priv->timer = gdk_threads_add_timeout_full (G_PRIORITY_DEFAULT_IDLE,
timeout,
(GSourceFunc) calendar_timer,
(gpointer) calendar, NULL);
......
......@@ -1741,8 +1741,6 @@ popdown_timeout (gpointer data)
{
GtkCellRendererTextPrivate *priv;
GDK_THREADS_ENTER ();
priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (data);
priv->entry_menu_popdown_timeout = 0;
......@@ -1750,8 +1748,6 @@ popdown_timeout (gpointer data)
if (!GTK_WIDGET_HAS_FOCUS (priv->entry))
gtk_cell_renderer_text_editing_done (GTK_CELL_EDITABLE (priv->entry), data);
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -1768,7 +1764,7 @@ gtk_cell_renderer_text_popup_unmap (GtkMenu *menu,
if (priv->entry_menu_popdown_timeout)
return;
priv->entry_menu_popdown_timeout = g_timeout_add (500, popdown_timeout,
priv->entry_menu_popdown_timeout = gdk_threads_add_timeout (500, popdown_timeout,
data);
}
......
......@@ -1862,6 +1862,8 @@ gtk_clipboard_store (GtkClipboard *clipboard)
if (!gdk_display_supports_clipboard_persistence (clipboard->display))
return;
g_object_ref (clipboard);
clipboard_widget = get_clipboard_widget (clipboard->display);
clipboard->notify_signal_id = g_signal_connect (clipboard_widget, "selection_notify_event",
G_CALLBACK (gtk_clipboard_selection_notify), clipboard);
......@@ -1893,6 +1895,8 @@ gtk_clipboard_store (GtkClipboard *clipboard)
clipboard->notify_signal_id = 0;
clipboard->storing_selection = FALSE;
g_object_unref (clipboard);
}
/* Stores all clipboard selections on all displays, called from
......
......@@ -5264,7 +5264,7 @@ gtk_clist_motion (GtkWidget *widget,
if (clist->htimer)
return FALSE;
clist->htimer = g_timeout_add
clist->htimer = gdk_threads_add_timeout
(SCROLL_TIME, (GSourceFunc) horizontal_timeout, clist);
if (!((x < 0 && clist->hadjustment->value == 0) ||
......@@ -5296,7 +5296,7 @@ gtk_clist_motion (GtkWidget *widget,
if (clist->vtimer)
return FALSE;
clist->vtimer = g_timeout_add (SCROLL_TIME,
clist->vtimer = gdk_threads_add_timeout (SCROLL_TIME,
(GSourceFunc) vertical_timeout, clist);
if (clist->drag_button &&
......@@ -7039,26 +7039,18 @@ do_fake_motion (GtkWidget *widget)
static gint
horizontal_timeout (GtkCList *clist)
{
GDK_THREADS_ENTER ();
clist->htimer = 0;
do_fake_motion (GTK_WIDGET (clist));
GDK_THREADS_LEAVE ();
return FALSE;
}
static gint
vertical_timeout (GtkCList *clist)
{
GDK_THREADS_ENTER ();
clist->vtimer = 0;
do_fake_motion (GTK_WIDGET (clist));
GDK_THREADS_LEAVE ();
return FALSE;
}
......
......@@ -69,7 +69,7 @@ static void gtk_combo_unrealize (GtkWidget *widget);
static void gtk_combo_destroy (GtkObject *combo);
static GtkListItem *gtk_combo_find (GtkCombo *combo);
static gchar * gtk_combo_func (GtkListItem *li);
static gint gtk_combo_focus_idle (GtkCombo *combo);
static gboolean gtk_combo_focus_idle (GtkCombo *combo);
static gint gtk_combo_entry_focus_out (GtkEntry *entry,
GdkEventFocus *event,
GtkCombo *combo);
......@@ -411,6 +411,7 @@ gtk_combo_entry_focus_out (GtkEntry * entry, GdkEventFocus * event, GtkCombo * c
g_cclosure_new_object (G_CALLBACK (gtk_combo_focus_idle),
G_OBJECT (combo)));
g_source_attach (focus_idle, NULL);
g_source_unref (focus_idle);
/*g_signal_stop_emission_by_name (entry, "focus_out_event"); */
return TRUE;
......
......@@ -3032,8 +3032,6 @@ list_popup_resize_idle (gpointer user_data)
GtkComboBox *combo_box;
gint x, y, width, height;
GDK_THREADS_ENTER ();
combo_box = GTK_COMBO_BOX (user_data);
if (combo_box->priv->tree_view &&
......@@ -3047,8 +3045,6 @@ list_popup_resize_idle (gpointer user_data)
combo_box->priv->resize_idle_id = 0;
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -3057,7 +3053,7 @@ gtk_combo_box_list_popup_resize (GtkComboBox *combo_box)
{
if (!combo_box->priv->resize_idle_id)
combo_box->priv->resize_idle_id =
g_idle_add (list_popup_resize_idle, combo_box);
gdk_threads_add_idle (list_popup_resize_idle, combo_box);
}
static void
......@@ -3582,7 +3578,7 @@ gtk_combo_box_list_button_pressed (GtkWidget *widget,
combo_box->priv->auto_scroll = FALSE;
if (combo_box->priv->scroll_timer == 0)
combo_box->priv->scroll_timer = g_timeout_add (SCROLL_TIME,
combo_box->priv->scroll_timer = gdk_threads_add_timeout (SCROLL_TIME,
(GSourceFunc) gtk_combo_box_list_scroll_timeout,
combo_box);
......@@ -3776,8 +3772,6 @@ gtk_combo_box_list_scroll_timeout (GtkComboBox *combo_box)
{
gint x, y;
GDK_THREADS_ENTER ();
if (combo_box->priv->auto_scroll)
{
gdk_window_get_pointer (combo_box->priv->tree_view->window,
......@@ -3785,8 +3779,6 @@ gtk_combo_box_list_scroll_timeout (GtkComboBox *combo_box)
gtk_combo_box_list_auto_scroll (combo_box, x, y);
}
GDK_THREADS_LEAVE ();
return TRUE;
}
......@@ -5175,8 +5167,6 @@ popdown_idle (gpointer data)
{
GtkComboBox *combo_box;
GDK_THREADS_ENTER ();
combo_box = GTK_COMBO_BOX (data);
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo_box));
......@@ -5184,8 +5174,6 @@ popdown_idle (gpointer data)
g_object_unref (combo_box);
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -5193,7 +5181,7 @@ static void
popdown_handler (GtkWidget *widget,
gpointer data)
{
g_idle_add (popdown_idle, g_object_ref (data));
gdk_threads_add_idle (popdown_idle, g_object_ref (data));
}
static gboolean
......@@ -5201,8 +5189,6 @@ popup_idle (gpointer data)
{
GtkComboBox *combo_box;
GDK_THREADS_ENTER ();
combo_box = GTK_COMBO_BOX (data);
if (GTK_IS_MENU (combo_box->priv->popup_widget) &&
......@@ -5217,8 +5203,6 @@ popup_idle (gpointer data)
combo_box->priv->popup_idle_id = 0;
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -5253,7 +5237,7 @@ gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
*/
if (combo_box->priv->is_cell_renderer &&
combo_box->priv->cell_view && !combo_box->priv->tree_view)
combo_box->priv->popup_idle_id = g_idle_add (popup_idle, combo_box);
combo_box->priv->popup_idle_id = gdk_threads_add_idle (popup_idle, combo_box);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment