Use G_SOURCE_CONTINUE/REMOVE

Now that GLib provides these macros, we should use them
to make the code more readable.
This commit is contained in:
Matthias Clasen 2012-01-30 19:12:27 -05:00
parent 7a080413ad
commit 585a6652d5
27 changed files with 43 additions and 45 deletions

View File

@ -23,14 +23,14 @@ apply_changes_gradually (gpointer data)
if (fraction < 1.0)
{
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), fraction);
return TRUE;
return G_SOURCE_CONTINUE;
}
else
{
/* Close automatically once changes are fully applied. */
gtk_widget_destroy (assistant);
assistant = NULL;
return FALSE;
return G_SOURCE_REMOVE;
}
}

View File

@ -60,7 +60,7 @@ spinner_timeout (gpointer data)
guint pulse;
if (model == NULL)
return FALSE;
return G_SOURCE_REMOVE;
gtk_tree_model_get_iter_first (model, &iter);
gtk_tree_model_get (model, &iter,
@ -77,7 +77,7 @@ spinner_timeout (gpointer data)
COLUMN_ACTIVE, TRUE,
-1);
return TRUE;
return G_SOURCE_CONTINUE;
}
static GtkTreeModel *

View File

@ -180,7 +180,7 @@ timeout (gpointer data)
GDK_THREADS_LEAVE ();
frame_num++;
return TRUE;
return G_SOURCE_CONTINUE;
}
static guint timeout_id;

View File

@ -29,8 +29,7 @@ static gboolean
search_progress (gpointer data)
{
gtk_entry_progress_pulse (GTK_ENTRY (data));
return TRUE;
return G_SOURCE_CONTINUE;
}
static void

View File

@ -49,7 +49,7 @@ scroll_to_end (GtkTextView *textview)
if (count > 150)
count = 0;
return TRUE;
return G_SOURCE_CONTINUE;
}
/* Scroll to the bottom of the buffer.
@ -100,7 +100,7 @@ scroll_to_bottom (GtkTextView *textview)
if (count > 40)
count = 0;
return TRUE;
return G_SOURCE_CONTINUE;
}
static guint

View File

@ -350,7 +350,7 @@ interactive_canvas_real_drag_leave (gpointer data)
gtk_widget_queue_draw (widget);
}
return FALSE;
return G_SOURCE_REMOVE;
}
static void

View File

@ -121,9 +121,9 @@ Here's a simple example:
do_small_part_of_task ();
if (task_complete)
return FALSE; /* removes the idle handler */
return G_SOURCE_REMOVE; /* removes the idle handler */
else
return TRUE; /* runs the idle handler again */
return G_SOURCE_CONTINUE; /* runs the idle handler again */
}
g_idle_add (my_idle_handler, NULL);

View File

@ -483,7 +483,7 @@ process_input_idle_cb (GdkBroadwayDisplay *display)
{
display->process_input_idle = 0;
process_input_messages (display);
return FALSE;
return G_SOURCE_REMOVE;
}
static void

View File

@ -895,7 +895,7 @@ gdk_threads_add_idle (GSourceFunc function,
*
* self->timeout_id = 0;
*
* return FALSE;
* return G_SOURCE_REMOVE;
* }
*
* static void some_widget_do_stuff_later (SomeWidget *self)

View File

@ -221,7 +221,7 @@ startup_timeout (void *data)
std->timeout_id = g_timeout_add_seconds ((min_timeout + 500)/1000, startup_timeout, std);
/* always remove this one, but we may have reinstalled another one. */
return FALSE;
return G_SOURCE_REMOVE;
}

View File

@ -1598,7 +1598,7 @@ idle_will_quit (gpointer data)
gtk_widget_destroy (dialog);
}
return FALSE;
return G_SOURCE_REMOVE;
}
static pascal OSErr

View File

@ -2017,7 +2017,7 @@ gtk_clipboard_store_timeout (GtkClipboard *clipboard)
{
g_main_loop_quit (clipboard->store_loop);
return FALSE;
return G_SOURCE_REMOVE;
}
/**

View File

@ -1072,7 +1072,7 @@ gtk_drag_begin_idle (gpointer arg)
[types release];
if ((nswindow = get_toplevel_nswindow (info->source_widget)) == NULL)
return FALSE;
return G_SOURCE_REMOVE;
/* Ref the context. It's unreffed when the drag has been aborted */
g_object_ref (info->context);
@ -1084,7 +1084,7 @@ gtk_drag_begin_idle (gpointer arg)
if (drag_image == NULL)
{
g_object_unref (info->context);
return FALSE;
return G_SOURCE_REMOVE;
}
point.x -= info->hot_x;
@ -1103,7 +1103,7 @@ gtk_drag_begin_idle (gpointer arg)
[pool release];
return FALSE;
return G_SOURCE_REMOVE;
}
/* Fake protocol to let us call GdkNSView gdkWindow without including
* gdk/GdkNSView.h (which we can't because it pulls in the internal-only
@ -1858,7 +1858,7 @@ static gboolean
drag_drop_finished_idle_cb (gpointer data)
{
gtk_drag_source_info_destroy (data);
return FALSE;
return G_SOURCE_REMOVE;
}
static void

View File

@ -1068,7 +1068,7 @@ find_printer_idle (gpointer data)
printer_finder_free (finder);
return FALSE;
return G_SOURCE_REMOVE;
}
static void

View File

@ -682,7 +682,7 @@ button_callback (gpointer data)
gdk_event_free ((GdkEvent *) bc->event);
g_free (data);
return FALSE;
return G_SOURCE_REMOVE;
}
static UINT taskbar_created_msg = 0;

View File

@ -86,7 +86,7 @@ wait_for_idle_idle (gpointer data)
{
wait_for_idle_id = 0;
return FALSE;
return G_SOURCE_REMOVE;
}
static void

View File

@ -211,7 +211,7 @@ on_timeout (gpointer data)
GDK_THREADS_LEAVE ();
return FALSE; /* don't call me again */
return G_SOURCE_REMOVE; /* don't call me again */
}
static gboolean

View File

@ -843,7 +843,7 @@ request_password (gpointer data)
gint i;
if (dispatch->backend->authentication_lock)
return FALSE;
return G_SOURCE_REMOVE;
httpGetHostname (dispatch->request->http, hostname, sizeof (hostname));
if (is_address_local (hostname))
@ -956,7 +956,7 @@ request_password (gpointer data)
g_free (auth_info_visible);
g_free (key);
return FALSE;
return G_SOURCE_REMOVE;
}
static void
@ -1040,10 +1040,10 @@ check_auth_info (gpointer user_data)
dispatch->request->auth_info = NULL;
}
return FALSE;
return G_SOURCE_REMOVE;
}
return TRUE;
return G_SOURCE_CONTINUE;
}
static gboolean
@ -1612,7 +1612,7 @@ cups_job_info_poll_timeout (gpointer user_data)
else
cups_request_job_info (data);
return FALSE;
return G_SOURCE_REMOVE;
}
static void

View File

@ -802,7 +802,7 @@ papi_display_printer_status (gpointer user_data)
papi_printer = GTK_PRINTER_PAPI (printer);
if (papiServiceCreate (&service, NULL, NULL, NULL, NULL, PAPI_ENCRYPT_NEVER,
NULL) != PAPI_OK)
return FALSE;
return G_SOURCE_REMOVE;
if (papiPrinterQuery (service, papi_printer->printer_name, NULL, NULL,
&current_printer) != PAPI_OK)
@ -845,7 +845,7 @@ papi_display_printer_status (gpointer user_data)
papiServiceDestroy (service);
gtk_printer_set_has_details (printer, TRUE);
return FALSE;
return G_SOURCE_REMOVE;
}
static void

View File

@ -549,7 +549,7 @@ test_printer_prepare_for_print (GtkPrinter *printer,
}
static gboolean
test_printer_details_aquired_cb (GtkPrinter *printer)
test_printer_details_acquired_cb (GtkPrinter *printer)
{
gboolean success;
gint weight;
@ -565,7 +565,7 @@ test_printer_details_aquired_cb (GtkPrinter *printer)
gtk_printer_set_has_details (printer, success);
g_signal_emit_by_name (printer, "details-acquired", success);
return FALSE;
return G_SOURCE_REMOVE;
}
static void
@ -590,7 +590,7 @@ test_printer_request_details (GtkPrinter *printer)
else
time *= 1000;
g_timeout_add (time, (GSourceFunc) test_printer_details_aquired_cb, printer);
g_timeout_add (time, (GSourceFunc) test_printer_details_acquired_cb, printer);
}

View File

@ -50,7 +50,7 @@ compare_focus (gpointer data)
g_print ("gtk focus: %s != atk focus: %s\n",
get_name (gtk_focus), get_name (atk_focus));
return TRUE;
return G_SOURCE_CONTINUE;
}
static void

View File

@ -198,7 +198,7 @@ quit_when_idle (gpointer loop)
{
g_main_loop_quit (loop);
return FALSE;
return G_SOURCE_REMOVE;
}
static void

View File

@ -3656,7 +3656,7 @@ entry_progress_timeout (gpointer data)
gtk_entry_set_progress_fraction (GTK_ENTRY (data), fraction);
}
return TRUE;
return G_SOURCE_CONTINUE;
}
static void
@ -9047,7 +9047,7 @@ idle_test (GtkWidget *label)
sprintf (buffer, "count: %d", ++count);
gtk_label_set_text (GTK_LABEL (label), buffer);
return TRUE;
return G_SOURCE_CONTINUE;
}
static void

View File

@ -74,7 +74,7 @@ idle_func (gpointer data)
{
g_print ("keep me busy\n");
return TRUE;
return G_SOURCE_CONTINUE;
}
static gboolean

View File

@ -63,9 +63,8 @@ scroll_layout (gpointer data)
GtkAdjustment *adj;
adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (layout));
gtk_adjustment_set_value (adj,
gtk_adjustment_get_value (adj) + 5.0);
return TRUE;
gtk_adjustment_set_value (adj, gtk_adjustment_get_value (adj) + 5.0);
return G_SOURCE_CONTINUE;
}
static guint layout_timeout;

View File

@ -407,7 +407,7 @@ dance (gpointer treeview)
check_sanity (treeview);
return TRUE;
return G_SOURCE_CONTINUE;
}
static void

View File

@ -70,7 +70,7 @@ show_error (gpointer data)
G_CALLBACK (response_cb), NULL);
gtk_widget_show (dialog);
return FALSE;
return G_SOURCE_REMOVE;
}
int