[gtk+] Use G_SOURCE_CONTINUE/REMOVE



commit 585a6652d5ca2123a15290ee3138fb8c36ad14cc
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jan 30 19:12:27 2012 -0500

    Use G_SOURCE_CONTINUE/REMOVE
    
    Now that GLib provides these macros, we should use them
    to make the code more readable.

 demos/gtk-demo/assistant.c                       |    4 ++--
 demos/gtk-demo/list_store.c                      |    4 ++--
 demos/gtk-demo/pixbufs.c                         |    2 +-
 demos/gtk-demo/search_entry.c                    |    3 +--
 demos/gtk-demo/textscroll.c                      |    4 ++--
 demos/gtk-demo/toolpalette.c                     |    2 +-
 docs/reference/gtk/other_software.sgml           |    4 ++--
 gdk/broadway/gdkdisplay-broadway.c               |    2 +-
 gdk/gdk.c                                        |    2 +-
 gdk/x11/gdkapplaunchcontext-x11.c                |    2 +-
 gtk/gtkapplication.c                             |    2 +-
 gtk/gtkclipboard.c                               |    2 +-
 gtk/gtkdnd-quartz.c                              |    8 ++++----
 gtk/gtkprintoperation-unix.c                     |    2 +-
 gtk/gtkstatusicon.c                              |    2 +-
 gtk/tests/filechooser.c                          |    2 +-
 modules/input/gtkimcontextmultipress.c           |    2 +-
 modules/printbackends/cups/gtkprintbackendcups.c |   10 +++++-----
 modules/printbackends/papi/gtkprintbackendpapi.c |    4 ++--
 modules/printbackends/test/gtkprintbackendtest.c |    6 +++---
 tests/a11y/testfocus.c                           |    2 +-
 tests/reftests/gtk-reftest.c                     |    2 +-
 tests/testgtk.c                                  |    4 ++--
 tests/testimage.c                                |    2 +-
 tests/testoffscreen.c                            |    5 ++---
 tests/testtreechanging.c                         |    2 +-
 tests/testvolumebutton.c                         |    2 +-
 27 files changed, 43 insertions(+), 45 deletions(-)
---
diff --git a/demos/gtk-demo/assistant.c b/demos/gtk-demo/assistant.c
index 5d7a460..7d7fbcd 100644
--- a/demos/gtk-demo/assistant.c
+++ b/demos/gtk-demo/assistant.c
@@ -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;
     }
 }
 
diff --git a/demos/gtk-demo/list_store.c b/demos/gtk-demo/list_store.c
index 40d113d..e5d2dff 100644
--- a/demos/gtk-demo/list_store.c
+++ b/demos/gtk-demo/list_store.c
@@ -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 *
diff --git a/demos/gtk-demo/pixbufs.c b/demos/gtk-demo/pixbufs.c
index ed1ed81..9b29b5a 100644
--- a/demos/gtk-demo/pixbufs.c
+++ b/demos/gtk-demo/pixbufs.c
@@ -180,7 +180,7 @@ timeout (gpointer data)
   GDK_THREADS_LEAVE ();
 
   frame_num++;
-  return TRUE;
+  return G_SOURCE_CONTINUE;
 }
 
 static guint timeout_id;
diff --git a/demos/gtk-demo/search_entry.c b/demos/gtk-demo/search_entry.c
index 53d1234..03b7288 100644
--- a/demos/gtk-demo/search_entry.c
+++ b/demos/gtk-demo/search_entry.c
@@ -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
diff --git a/demos/gtk-demo/textscroll.c b/demos/gtk-demo/textscroll.c
index a6cef0e..dae9b43 100644
--- a/demos/gtk-demo/textscroll.c
+++ b/demos/gtk-demo/textscroll.c
@@ -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
diff --git a/demos/gtk-demo/toolpalette.c b/demos/gtk-demo/toolpalette.c
index 73ab5c1..1a45fc1 100644
--- a/demos/gtk-demo/toolpalette.c
+++ b/demos/gtk-demo/toolpalette.c
@@ -350,7 +350,7 @@ interactive_canvas_real_drag_leave (gpointer data)
       gtk_widget_queue_draw (widget);
     }
 
-  return FALSE;
+  return G_SOURCE_REMOVE;
 }
 
 static void
diff --git a/docs/reference/gtk/other_software.sgml b/docs/reference/gtk/other_software.sgml
index 4b413a2..dde4295 100644
--- a/docs/reference/gtk/other_software.sgml
+++ b/docs/reference/gtk/other_software.sgml
@@ -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);
diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c
index f2babc8..861560e 100644
--- a/gdk/broadway/gdkdisplay-broadway.c
+++ b/gdk/broadway/gdkdisplay-broadway.c
@@ -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
diff --git a/gdk/gdk.c b/gdk/gdk.c
index d1793c9..f34da89 100644
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -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)
diff --git a/gdk/x11/gdkapplaunchcontext-x11.c b/gdk/x11/gdkapplaunchcontext-x11.c
index 825be75..9fa33044 100644
--- a/gdk/x11/gdkapplaunchcontext-x11.c
+++ b/gdk/x11/gdkapplaunchcontext-x11.c
@@ -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;
 }
 
 
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c
index ac54e1e..d5bdd73 100644
--- a/gtk/gtkapplication.c
+++ b/gtk/gtkapplication.c
@@ -1598,7 +1598,7 @@ idle_will_quit (gpointer data)
       gtk_widget_destroy (dialog);
     }
 
-  return FALSE;
+  return G_SOURCE_REMOVE;
 }
 
 static pascal OSErr
diff --git a/gtk/gtkclipboard.c b/gtk/gtkclipboard.c
index 7b223ff..5f5a471 100644
--- a/gtk/gtkclipboard.c
+++ b/gtk/gtkclipboard.c
@@ -2017,7 +2017,7 @@ gtk_clipboard_store_timeout (GtkClipboard *clipboard)
 {
   g_main_loop_quit (clipboard->store_loop);
   
-  return FALSE;
+  return G_SOURCE_REMOVE;
 }
 
 /**
diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c
index 6b3d123..a1754ae 100644
--- a/gtk/gtkdnd-quartz.c
+++ b/gtk/gtkdnd-quartz.c
@@ -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
diff --git a/gtk/gtkprintoperation-unix.c b/gtk/gtkprintoperation-unix.c
index e220e59..4fae6d7 100644
--- a/gtk/gtkprintoperation-unix.c
+++ b/gtk/gtkprintoperation-unix.c
@@ -1068,7 +1068,7 @@ find_printer_idle (gpointer data)
   
   printer_finder_free (finder);
 
-  return FALSE;
+  return G_SOURCE_REMOVE;
 }
 
 static void
diff --git a/gtk/gtkstatusicon.c b/gtk/gtkstatusicon.c
index 1dffba8..6f7bf89 100644
--- a/gtk/gtkstatusicon.c
+++ b/gtk/gtkstatusicon.c
@@ -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;
diff --git a/gtk/tests/filechooser.c b/gtk/tests/filechooser.c
index 3d82eef..69cac21 100644
--- a/gtk/tests/filechooser.c
+++ b/gtk/tests/filechooser.c
@@ -86,7 +86,7 @@ wait_for_idle_idle (gpointer data)
 {
   wait_for_idle_id = 0;
 
-  return FALSE;
+  return G_SOURCE_REMOVE;
 }
 
 static void
diff --git a/modules/input/gtkimcontextmultipress.c b/modules/input/gtkimcontextmultipress.c
index 23578e0..2f2b7b1 100644
--- a/modules/input/gtkimcontextmultipress.c
+++ b/modules/input/gtkimcontextmultipress.c
@@ -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
diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
index d52cb4d..c338ae5 100644
--- a/modules/printbackends/cups/gtkprintbackendcups.c
+++ b/modules/printbackends/cups/gtkprintbackendcups.c
@@ -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
diff --git a/modules/printbackends/papi/gtkprintbackendpapi.c b/modules/printbackends/papi/gtkprintbackendpapi.c
index c10b207..4ce3fb6 100644
--- a/modules/printbackends/papi/gtkprintbackendpapi.c
+++ b/modules/printbackends/papi/gtkprintbackendpapi.c
@@ -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  
diff --git a/modules/printbackends/test/gtkprintbackendtest.c b/modules/printbackends/test/gtkprintbackendtest.c
index 14c8e52..b10432b 100644
--- a/modules/printbackends/test/gtkprintbackendtest.c
+++ b/modules/printbackends/test/gtkprintbackendtest.c
@@ -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);
 }
 
 
diff --git a/tests/a11y/testfocus.c b/tests/a11y/testfocus.c
index 131a82a..c438f6d 100644
--- a/tests/a11y/testfocus.c
+++ b/tests/a11y/testfocus.c
@@ -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
diff --git a/tests/reftests/gtk-reftest.c b/tests/reftests/gtk-reftest.c
index 5b002f1..ae41d32 100644
--- a/tests/reftests/gtk-reftest.c
+++ b/tests/reftests/gtk-reftest.c
@@ -198,7 +198,7 @@ quit_when_idle (gpointer loop)
 {
   g_main_loop_quit (loop);
 
-  return FALSE;
+  return G_SOURCE_REMOVE;
 }
 
 static void
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 203ecb4..655868b 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -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
diff --git a/tests/testimage.c b/tests/testimage.c
index 2f0da45..73072ed 100644
--- a/tests/testimage.c
+++ b/tests/testimage.c
@@ -74,7 +74,7 @@ idle_func (gpointer data)
 {
   g_print ("keep me busy\n");
 
-  return TRUE;
+  return G_SOURCE_CONTINUE;
 }
 
 static gboolean
diff --git a/tests/testoffscreen.c b/tests/testoffscreen.c
index ff9ba6b..62589b5 100644
--- a/tests/testoffscreen.c
+++ b/tests/testoffscreen.c
@@ -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;
diff --git a/tests/testtreechanging.c b/tests/testtreechanging.c
index 106fc37..478e5fc 100644
--- a/tests/testtreechanging.c
+++ b/tests/testtreechanging.c
@@ -407,7 +407,7 @@ dance (gpointer treeview)
 
   check_sanity (treeview);
 
-  return TRUE;
+  return G_SOURCE_CONTINUE;
 }
 
 static void
diff --git a/tests/testvolumebutton.c b/tests/testvolumebutton.c
index 29b3e33..85e7469 100644
--- a/tests/testvolumebutton.c
+++ b/tests/testvolumebutton.c
@@ -70,7 +70,7 @@ show_error (gpointer data)
                     G_CALLBACK (response_cb), NULL);
   gtk_widget_show (dialog);
 
-  return FALSE;
+  return G_SOURCE_REMOVE;
 }
 
 int



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]