[gtk/debug-envvars-cleanup: 13/14] gtk: Use the new debug macros




commit f33f55bcbb33833c9edf7d02c3c82a0a3ecc6e0d
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Sep 23 10:11:59 2022 -0400

    gtk: Use the new debug macros

 gdk/gdkdebug.h                              |   2 +
 gsk/gskdebugprivate.h                       |   4 +
 gtk/a11y/gtkatspicache.c                    |  15 ++-
 gtk/a11y/gtkatspicontext.c                  |  35 ++++---
 gtk/a11y/gtkatspiroot.c                     |  12 +--
 gtk/gtkactionhelper.c                       |  31 +++---
 gtk/gtkatcontext.c                          |   5 +-
 gtk/gtkbuilder.c                            |  11 +-
 gtk/gtkbuilderparser.c                      |  12 +--
 gtk/gtkconstraintlayout.c                   |  15 ++-
 gtk/gtkconstraintsolver.c                   |  24 ++---
 gtk/gtkiconcache.c                          |   9 +-
 gtk/gtkicontheme.c                          |  64 ++++++------
 gtk/gtkimcontextquartz.c                    |  30 +++---
 gtk/gtkimmodule.c                           |   6 +-
 gtk/gtkmediafile.c                          |  12 +--
 gtk/gtkmenutrackeritem.c                    |  39 ++++---
 gtk/gtkprintbackend.c                       |   9 +-
 gtk/gtkshortcutaction.c                     |  14 ++-
 gtk/gtksizerequest.c                        |  43 ++++----
 gtk/gtkwidget.c                             |  12 +--
 modules/printbackends/gtkcupssecretsutils.c |  52 +++++-----
 modules/printbackends/gtkcupsutils.c        |  28 ++---
 modules/printbackends/gtkprintbackendcups.c | 155 +++++++++++-----------------
 modules/printbackends/gtkprintbackendfile.c |  16 ++-
 modules/printbackends/gtkprintbackendlpr.c  |  16 +--
 26 files changed, 315 insertions(+), 356 deletions(-)
---
diff --git a/gdk/gdkdebug.h b/gdk/gdkdebug.h
index 0dad93e828..94cc26aa6e 100644
--- a/gdk/gdkdebug.h
+++ b/gdk/gdkdebug.h
@@ -67,8 +67,10 @@ void             gdk_display_set_debug_flags    (GdkDisplay       *display,
     G_UNLIKELY (gdk_display_get_debug_flags (display) & GDK_DEBUG_##type)
 
 #define GDK_DISPLAY_DEBUG(display,type,...)                               \
+    G_STMT_START {                                                        \
     if (GDK_DISPLAY_DEBUG_CHECK (display,type))                           \
       gdk_debug_message (__VA_ARGS__);                                    \
+    } G_STMT_END
 
 #else /* !G_ENABLE_DEBUG */
 
diff --git a/gsk/gskdebugprivate.h b/gsk/gskdebugprivate.h
index 9714bec1a1..f02130190c 100644
--- a/gsk/gskdebugprivate.h
+++ b/gsk/gskdebugprivate.h
@@ -37,12 +37,16 @@ gboolean gsk_check_debug_flags (GskDebugFlags flags);
   G_UNLIKELY ((gsk_renderer_get_debug_flags (renderer) & GSK_DEBUG_ ## type) != 0)
 
 #define GSK_RENDERER_DEBUG(renderer,type,...)                               \
+    G_STMT_START {                                                          \
     if (GSK_RENDERER_DEBUG_CHECK (renderer,type))                           \
       gdk_debug_message (__VA_ARGS__);                                      \
+    } G_STMT_END
 
 #define GSK_DEBUG(type,...)                                                 \
+    G_STMT_START {                                                          \
     if (GSK_DEBUG_CHECK (type))                                             \
       gdk_debug_message (__VA_ARGS__);                                      \
+    } G_STMT_END
 
 #else
 
diff --git a/gtk/a11y/gtkatspicache.c b/gtk/a11y/gtkatspicache.c
index 6e85c5663f..3b16f24d6f 100644
--- a/gtk/a11y/gtkatspicache.c
+++ b/gtk/a11y/gtkatspicache.c
@@ -26,6 +26,7 @@
 #include "gtkatspirootprivate.h"
 #include "gtkatspiutilsprivate.h"
 #include "gtkdebug.h"
+#include "gtkprivate.h"
 
 #include "a11y/atspi/atspi-accessible.h"
 #include "a11y/atspi/atspi-application.h"
@@ -282,9 +283,8 @@ handle_cache_method (GDBusConnection       *connection,
 {
   GtkAtSpiCache *self = user_data;
 
-  GTK_NOTE (A11Y,
-            g_message ("[Cache] Method '%s' on interface '%s' for object '%s' from '%s'\n",
-                       method_name, interface_name, object_path, sender));
+  GTK_DEBUG (A11Y, "[Cache] Method '%s' on interface '%s' for object '%s' from '%s'",
+                   method_name, interface_name, object_path, sender);
 
 
   if (g_strcmp0 (method_name, "GetItems") == 0)
@@ -304,8 +304,7 @@ handle_cache_method (GDBusConnection       *connection,
 
       self->in_get_items = FALSE;
 
-      GTK_NOTE (A11Y,
-                g_message ("Returning %lu items\n", g_variant_n_children (items)));
+      GTK_DEBUG (A11Y, "Returning %lu items", g_variant_n_children (items));
 
       g_dbus_method_invocation_return_value (invocation, items);
     }
@@ -351,7 +350,7 @@ gtk_at_spi_cache_constructed (GObject *gobject)
                                      NULL,
                                      NULL);
 
-  GTK_NOTE (A11Y, g_message ("Cache registered at %s", self->cache_path));
+  GTK_DEBUG (A11Y, "Cache registered at %s", self->cache_path);
 
   G_OBJECT_CLASS (gtk_at_spi_cache_parent_class)->constructed (gobject);
 }
@@ -428,7 +427,7 @@ gtk_at_spi_cache_add_context (GtkAtSpiCache   *self,
   g_hash_table_insert (self->contexts_by_path, path_key, context);
   g_hash_table_insert (self->contexts_to_path, context, path_key);
 
-  GTK_NOTE (A11Y, g_message ("Adding context '%s' to cache", path_key));
+  GTK_DEBUG (A11Y, "Adding context '%s' to cache", path_key);
 
   /* GetItems is safe from re-entrancy, but we still don't want to
    * emit an unnecessary signal while we're collecting ATContexts
@@ -456,5 +455,5 @@ gtk_at_spi_cache_remove_context (GtkAtSpiCache   *self,
   g_hash_table_remove (self->contexts_to_path, context);
   g_hash_table_remove (self->contexts_by_path, path);
 
-  GTK_NOTE (A11Y, g_message ("Removing context '%s' from cache", path));
+  GTK_DEBUG (A11Y, "Removing context '%s' from cache", path);
 }
diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c
index 7b62a1ea81..b098377de5 100644
--- a/gtk/a11y/gtkatspicontext.c
+++ b/gtk/a11y/gtkatspicontext.c
@@ -42,6 +42,7 @@
 #include "a11y/atspi/atspi-component.h"
 
 #include "gtkdebug.h"
+#include "gtkprivate.h"
 #include "gtkeditable.h"
 #include "gtkentryprivate.h"
 #include "gtkroot.h"
@@ -461,7 +462,7 @@ handle_accessible_method (GDBusConnection       *connection,
 {
   GtkAtSpiContext *self = user_data;
 
-  GTK_NOTE (A11Y, g_message ("handling %s on %s", method_name, object_path));
+  GTK_DEBUG (A11Y, "handling %s on %s", method_name, object_path);
 
   if (g_strcmp0 (method_name, "GetRole") == 0)
     {
@@ -666,7 +667,7 @@ handle_accessible_get_property (GDBusConnection       *connection,
 
   GtkAccessible *accessible = gtk_at_context_get_accessible (GTK_AT_CONTEXT (self));
 
-  GTK_NOTE (A11Y, g_message ("handling GetProperty %s on %s", property_name, object_path));
+  GTK_DEBUG (A11Y, "handling GetProperty %s on %s", property_name, object_path);
 
   if (g_strcmp0 (property_name, "Name") == 0)
     {
@@ -1420,9 +1421,9 @@ gtk_at_spi_context_register_object (GtkAtSpiContext *self)
 
   self->interfaces = g_variant_ref_sink (g_variant_builder_end (&interfaces));
 
-  GTK_NOTE (A11Y, g_message ("Registered %d interfaces on object path '%s'",
-                             self->n_registered_objects,
-                             self->context_path));
+  GTK_DEBUG (A11Y, "Registered %d interfaces on object path '%s'",
+                   self->n_registered_objects,
+                   self->context_path);
 }
 
 static void
@@ -1549,9 +1550,9 @@ gtk_at_spi_context_unrealize (GtkATContext *context)
   GtkAtSpiContext *self = GTK_AT_SPI_CONTEXT (context);
   GtkAccessible *accessible = gtk_at_context_get_accessible (context);
 
-  GTK_NOTE (A11Y, g_message ("Unrealizing ATSPI context at '%s' for accessible '%s'",
-                             self->context_path,
-                             G_OBJECT_TYPE_NAME (accessible)));
+  GTK_DEBUG (A11Y, "Unrealizing ATSPI context at '%s' for accessible '%s'",
+                   self->context_path,
+                   G_OBJECT_TYPE_NAME (accessible));
 
   /* Notify ATs that the accessible object is going away */
   emit_defunct (self);
@@ -1592,7 +1593,7 @@ gtk_at_spi_context_init (GtkAtSpiContext *self)
 static char *
 get_bus_address_x11 (GdkDisplay *display)
 {
-  GTK_NOTE (A11Y, g_message ("Acquiring a11y bus via X11..."));
+  GTK_DEBUG (A11Y, "Acquiring a11y bus via X11...");
 
   Display *xdisplay = gdk_x11_display_get_xdisplay (display);
   Atom type_return;
@@ -1623,14 +1624,14 @@ get_bus_address_x11 (GdkDisplay *display)
 static char *
 get_bus_address_dbus (GdkDisplay *display)
 {
-  GTK_NOTE (A11Y, g_message ("Acquiring a11y bus via DBus..."));
+  GTK_DEBUG (A11Y, "Acquiring a11y bus via DBus...");
 
   GError *error = NULL;
   GDBusConnection *connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
 
   if (error != NULL)
     {
-      GTK_NOTE (A11Y, g_message ("Unable to acquire session bus: %s", error->message));
+      GTK_DEBUG (A11Y, "Unable to acquire session bus: %s", error->message);
       g_error_free (error);
       return NULL;
     }
@@ -1647,8 +1648,8 @@ get_bus_address_dbus (GdkDisplay *display)
                                   &error);
   if (error != NULL)
     {
-      GTK_NOTE (A11Y, g_message ("Unable to acquire the address of the accessibility bus: %s",
-                                 error->message));
+      GTK_DEBUG (A11Y, "Unable to acquire the address of the accessibility bus: %s",
+                       error->message);
       g_error_free (error);
     }
 
@@ -1681,7 +1682,7 @@ get_bus_address (GdkDisplay *display)
   bus_address = g_getenv ("AT_SPI_BUS_ADDRESS");
   if (bus_address != NULL && *bus_address != '\0')
     {
-      GTK_NOTE (A11Y, g_message ("Using ATSPI bus address from environment: %s", bus_address));
+      GTK_DEBUG (A11Y, "Using ATSPI bus address from environment: %s", bus_address);
       g_object_set_data_full (G_OBJECT (display), "-gtk-atspi-bus-address",
                               g_strdup (bus_address),
                               g_free);
@@ -1695,7 +1696,7 @@ get_bus_address (GdkDisplay *display)
         {
           char *addr = get_bus_address_dbus (display);
 
-          GTK_NOTE (A11Y, g_message ("Using ATSPI bus address from D-Bus: %s", addr));
+          GTK_DEBUG (A11Y, "Using ATSPI bus address from D-Bus: %s", addr);
           g_object_set_data_full (G_OBJECT (display), "-gtk-atspi-bus-address",
                                   addr,
                                   g_free);
@@ -1714,11 +1715,11 @@ get_bus_address (GdkDisplay *display)
           if (addr == NULL)
             {
               addr = get_bus_address_x11 (display);
-              GTK_NOTE (A11Y, g_message ("Using ATSPI bus address from X11: %s", addr));
+              GTK_DEBUG (A11Y, "Using ATSPI bus address from X11: %s", addr);
             }
           else
             {
-              GTK_NOTE (A11Y, g_message ("Using ATSPI bus address from D-Bus: %s", addr));
+              GTK_DEBUG (A11Y, "Using ATSPI bus address from D-Bus: %s", addr);
             }
 
           g_object_set_data_full (G_OBJECT (display), "-gtk-atspi-bus-address",
diff --git a/gtk/a11y/gtkatspiroot.c b/gtk/a11y/gtkatspiroot.c
index 1335c7fb24..b39d0938d4 100644
--- a/gtk/a11y/gtkatspiroot.c
+++ b/gtk/a11y/gtkatspiroot.c
@@ -507,9 +507,9 @@ on_registration_reply (GObject      *gobject,
                      &self->desktop_path);
       g_variant_unref (reply);
 
-      GTK_NOTE (A11Y, g_message ("Connected to the a11y registry at (%s, %s)",
-                                 self->desktop_name,
-                                 self->desktop_path));
+      GTK_DEBUG (A11Y, "Connected to the a11y registry at (%s, %s)",
+                       self->desktop_name,
+                       self->desktop_path);
     }
 
   /* Register the cache object */
@@ -581,9 +581,9 @@ root_register (gpointer user_data)
                                      NULL,
                                      NULL);
 
-  GTK_NOTE (A11Y, g_message ("Registering (%s, %s) on the a11y bus",
-                             unique_name,
-                             self->root_path));
+  GTK_DEBUG (A11Y, "Registering (%s, %s) on the a11y bus",
+                   unique_name,
+                   self->root_path);
 
   g_dbus_connection_call (self->connection,
                           "org.a11y.atspi.Registry",
diff --git a/gtk/gtkactionhelper.c b/gtk/gtkactionhelper.c
index 59da82a5dc..5bdeb02e74 100644
--- a/gtk/gtkactionhelper.c
+++ b/gtk/gtkactionhelper.c
@@ -24,6 +24,7 @@
 #include "gtkdebug.h"
 #include "gtktypebuiltins.h"
 #include "gtkmodelbuttonprivate.h"
+#include "gtkprivate.h"
 
 #include <string.h>
 
@@ -138,7 +139,7 @@ gtk_action_helper_action_added (GtkActionHelper    *helper,
                                 GVariant           *state,
                                 gboolean            should_emit_signals)
 {
-  GTK_NOTE(ACTIONS, g_message("%s: action %s added", "actionhelper", helper->action_name));
+  GTK_DEBUG (ACTIONS, "%s: action %s added", "actionhelper", helper->action_name);
 
   /* we can only activate if we have the correct type of parameter */
   helper->can_activate = (helper->target == NULL && parameter_type == NULL) ||
@@ -156,11 +157,11 @@ gtk_action_helper_action_added (GtkActionHelper    *helper,
       return;
     }
 
-  GTK_NOTE(ACTIONS, g_message ("%s: %s can be activated", "actionhelper", helper->action_name));
+  GTK_DEBUG (ACTIONS, "%s: %s can be activated", "actionhelper", helper->action_name);
 
   helper->enabled = enabled;
 
-  GTK_NOTE(ACTIONS, g_message ("%s: action %s is %s", "actionhelper", helper->action_name, enabled ? 
"enabled" : "disabled"));
+  GTK_DEBUG (ACTIONS, "%s: action %s is %s", "actionhelper", helper->action_name, enabled ? "enabled" : 
"disabled");
 
   if (helper->target != NULL && state != NULL)
     {
@@ -193,7 +194,7 @@ static void
 gtk_action_helper_action_removed (GtkActionHelper *helper,
                                   gboolean         should_emit_signals)
 {
-  GTK_NOTE(ACTIONS, g_message ("%s: action %s was removed", "actionhelper", helper->action_name));
+  GTK_DEBUG (ACTIONS, "%s: action %s was removed", "actionhelper", helper->action_name);
 
   if (!helper->can_activate)
     return;
@@ -221,7 +222,7 @@ static void
 gtk_action_helper_action_enabled_changed (GtkActionHelper *helper,
                                           gboolean         enabled)
 {
-  GTK_NOTE(ACTIONS, g_message ("%s: action %s: enabled changed to %d", "actionhelper",  helper->action_name, 
enabled));
+  GTK_DEBUG (ACTIONS, "%s: action %s: enabled changed to %d", "actionhelper",  helper->action_name, enabled);
 
   if (!helper->can_activate)
     return;
@@ -239,7 +240,7 @@ gtk_action_helper_action_state_changed (GtkActionHelper *helper,
 {
   gboolean was_active;
 
-  GTK_NOTE(ACTIONS, g_message ("%s: %s state changed", "actionhelper", helper->action_name));
+  GTK_DEBUG (ACTIONS, "%s: %s state changed", "actionhelper", helper->action_name);
 
   if (!helper->can_activate)
     return;
@@ -415,11 +416,15 @@ gtk_action_helper_set_action_name (GtkActionHelper *helper,
   if (g_strcmp0 (action_name, helper->action_name) == 0)
     return;
 
-  GTK_NOTE(ACTIONS,
-           if (action_name == NULL || !strchr (action_name, '.'))
-             g_message ("%s: action name %s doesn't look like 'app.' or 'win.'; "
-                        "it is unlikely to work",
-                        "actionhelper", action_name));
+#ifdef G_ENABLE_DEBUG
+  if (GTK_DEBUG_CHECK (ACTIONS))
+    {
+      if (action_name == NULL || !strchr (action_name, '.'))
+        gdk_debug_message ("%s: action name %s doesn't look like 'app.' or 'win.'; "
+                           "it is unlikely to work",
+                           "actionhelper", action_name);
+    }
+#endif
 
   /* Start by recording the current state of our properties so we know
    * what notify signals we will need to send.
@@ -448,7 +453,7 @@ gtk_action_helper_set_action_name (GtkActionHelper *helper,
                                          &enabled, &parameter_type,
                                          NULL, NULL, &state))
         {
-          GTK_NOTE(ACTIONS, g_message ("%s: action %s existed from the start", "actionhelper", 
helper->action_name));
+          GTK_DEBUG (ACTIONS, "%s: action %s existed from the start", "actionhelper", helper->action_name);
 
           gtk_action_helper_action_added (helper, enabled, parameter_type, state, FALSE);
 
@@ -457,7 +462,7 @@ gtk_action_helper_set_action_name (GtkActionHelper *helper,
         }
       else
         {
-          GTK_NOTE(ACTIONS, g_message ("%s: action %s missing from the start", "actionhelper", 
helper->action_name));
+          GTK_DEBUG (ACTIONS, "%s: action %s missing from the start", "actionhelper", helper->action_name);
           helper->enabled = FALSE;
         }
     }
diff --git a/gtk/gtkatcontext.c b/gtk/gtkatcontext.c
index 9205e9b5fd..aa4b9f51f2 100644
--- a/gtk/gtkatcontext.c
+++ b/gtk/gtkatcontext.c
@@ -36,6 +36,7 @@
 #include "gtkaccessiblevalueprivate.h"
 #include "gtkaccessibleprivate.h"
 #include "gtkdebug.h"
+#include "gtkprivate.h"
 #include "gtktestatcontextprivate.h"
 #include "gtktypebuiltins.h"
 
@@ -651,7 +652,7 @@ gtk_at_context_realize (GtkATContext *self)
   if (self->realized)
     return;
 
-  GTK_NOTE (A11Y, g_message ("Realizing AT context '%s'", G_OBJECT_TYPE_NAME (self)));
+  GTK_DEBUG (A11Y, "Realizing AT context '%s'", G_OBJECT_TYPE_NAME (self));
   GTK_AT_CONTEXT_GET_CLASS (self)->realize (self);
 
   self->realized = TRUE;
@@ -663,7 +664,7 @@ gtk_at_context_unrealize (GtkATContext *self)
   if (!self->realized)
     return;
 
-  GTK_NOTE (A11Y, g_message ("Unrealizing AT context '%s'", G_OBJECT_TYPE_NAME (self)));
+  GTK_DEBUG (A11Y, "Unrealizing AT context '%s'", G_OBJECT_TYPE_NAME (self));
   GTK_AT_CONTEXT_GET_CLASS (self)->unrealize (self);
 
   self->realized = FALSE;
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index 8b7ce86eda..ee546191d7 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -650,9 +650,8 @@ gtk_builder_get_internal_child (GtkBuilder   *builder,
       if (!info)
         break;
 
-      GTK_NOTE (BUILDER,
-                g_message ("Trying to get internal child %s from %s",
-                           childname, object_get_id (info->object)));
+      GTK_DEBUG (BUILDER, "Trying to get internal child %s from %s",
+                          childname, object_get_id (info->object));
 
       if (GTK_IS_BUILDABLE (info->object))
           obj = gtk_buildable_get_internal_child (GTK_BUILDABLE (info->object),
@@ -857,8 +856,7 @@ _gtk_builder_construct (GtkBuilder  *builder,
       if (G_IS_INITIALLY_UNOWNED (obj))
         g_object_ref_sink (obj);
 
-      GTK_NOTE (BUILDER,
-                g_message ("created %s of type %s", info->id, g_type_name (info->type)));
+      GTK_DEBUG (BUILDER, "created %s of type %s", info->id, g_type_name (info->type));
     }
   object_properties_destroy (&construct_parameters);
 
@@ -1032,8 +1030,7 @@ _gtk_builder_add (GtkBuilder *builder,
 
   parent = ((ObjectInfo*)child_info->parent)->object;
 
-  GTK_NOTE (BUILDER,
-            g_message ("adding %s to %s", object_get_id (object), object_get_id (parent)));
+  GTK_DEBUG (BUILDER, "adding %s to %s", object_get_id (object), object_get_id (parent));
 
   if (G_IS_LIST_STORE (parent))
     {
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c
index d02ad44d73..6f41b61943 100644
--- a/gtk/gtkbuilderparser.c
+++ b/gtk/gtkbuilderparser.c
@@ -648,9 +648,8 @@ parse_object (GtkBuildableParseContext  *context,
         {
           data->requested_object_level = data->cur_object_level;
 
-          GTK_NOTE (BUILDER,
-                    g_message ("requested object \"%s\" found at level %d",
-                               object_id, data->requested_object_level));
+          GTK_DEBUG (BUILDER, "requested object \"%s\" found at level %d",
+                              object_id, data->requested_object_level);
 
           data->inside_requested_object = TRUE;
         }
@@ -1848,7 +1847,7 @@ end_element (GtkBuildableParseContext  *context,
 {
   ParserData *data = (ParserData*)user_data;
 
-  GTK_NOTE (BUILDER, g_message ("</%s>", element_name));
+  GTK_DEBUG (BUILDER, "</%s>", element_name);
 
   if (data->subparser && data->subparser->start)
     {
@@ -1930,9 +1929,8 @@ end_element (GtkBuildableParseContext  *context,
       if (data->requested_objects && data->inside_requested_object &&
           (data->cur_object_level == data->requested_object_level))
         {
-          GTK_NOTE (BUILDER,
-                    g_message ("requested object end found at level %d",
-                               data->requested_object_level));
+          GTK_DEBUG (BUILDER, "requested object end found at level %d",
+                              data->requested_object_level);
 
           data->inside_requested_object = FALSE;
         }
diff --git a/gtk/gtkconstraintlayout.c b/gtk/gtkconstraintlayout.c
index 7d83b83d16..bcf33dd310 100644
--- a/gtk/gtkconstraintlayout.c
+++ b/gtk/gtkconstraintlayout.c
@@ -998,12 +998,11 @@ gtk_constraint_layout_measure (GtkLayoutManager *manager,
     gtk_constraint_solver_remove_edit_variable (solver, opposite_size);
   gtk_constraint_solver_end_edit (solver);
 
-  GTK_NOTE (LAYOUT,
-            g_print ("layout %p %s size: min %d nat %d (for opposite size: %d)\n",
+  GTK_DEBUG (LAYOUT, "layout %p %s size: min %d nat %d (for opposite size: %d)",
                      self,
                      orientation == GTK_ORIENTATION_HORIZONTAL ? "horizontal" : "vertical",
                      min_value, nat_value,
-                     for_size));
+                     for_size);
 
   if (minimum != NULL)
     *minimum = min_value;
@@ -1054,13 +1053,12 @@ gtk_constraint_layout_allocate (GtkLayoutManager *manager,
   stay_h = gtk_constraint_solver_add_stay_variable (solver,
                                                     layout_height,
                                                     GTK_CONSTRAINT_STRENGTH_REQUIRED);
-  GTK_NOTE (LAYOUT,
-            g_print ("Layout [%p]: { .x: %g, .y: %g, .w: %g, .h: %g }\n",
+  GTK_DEBUG (LAYOUT, "Layout [%p]: { .x: %g, .y: %g, .w: %g, .h: %g }",
                      self,
                      gtk_constraint_variable_get_value (layout_left),
                      gtk_constraint_variable_get_value (layout_top),
                      gtk_constraint_variable_get_value (layout_width),
-                     gtk_constraint_variable_get_value (layout_height)));
+                     gtk_constraint_variable_get_value (layout_height));
 
   for (child = _gtk_widget_get_first_child (widget);
        child != NULL;
@@ -1081,14 +1079,13 @@ gtk_constraint_layout_allocate (GtkLayoutManager *manager,
       var_height = get_child_attribute (self, child, GTK_CONSTRAINT_ATTRIBUTE_HEIGHT);
       var_baseline = get_child_attribute (self, child, GTK_CONSTRAINT_ATTRIBUTE_BASELINE);
 
-      GTK_NOTE (LAYOUT,
-                g_print ("Allocating child '%s'[%p] with { .x: %g, .y: %g, .w: %g, .h: %g, .b: %g }\n",
+      GTK_DEBUG (LAYOUT, "Allocating child '%s'[%p] with { .x: %g, .y: %g, .w: %g, .h: %g, .b: %g }",
                          gtk_widget_get_name (child), child,
                          gtk_constraint_variable_get_value (var_left),
                          gtk_constraint_variable_get_value (var_top),
                          gtk_constraint_variable_get_value (var_width),
                          gtk_constraint_variable_get_value (var_height),
-                         gtk_constraint_variable_get_value (var_baseline)));
+                         gtk_constraint_variable_get_value (var_baseline));
 
       child_alloc.x = floor (gtk_constraint_variable_get_value (var_left));
       child_alloc.y = floor (gtk_constraint_variable_get_value (var_top));
diff --git a/gtk/gtkconstraintsolver.c b/gtk/gtkconstraintsolver.c
index 4148cfc43a..dc562e4992 100644
--- a/gtk/gtkconstraintsolver.c
+++ b/gtk/gtkconstraintsolver.c
@@ -160,6 +160,7 @@
 #include "gtkconstraintexpressionprivate.h"
 
 #include "gtkdebug.h"
+#include "gtkprivate.h"
 
 #include <glib.h>
 #include <string.h>
@@ -796,7 +797,7 @@ gtk_constraint_solver_optimize (GtkConstraintSolver *self,
 
       if (min_ratio == DBL_MAX)
         {
-          GTK_NOTE (CONSTRAINTS, g_message ("Unbounded objective variable during optimization"));
+          GTK_DEBUG (CONSTRAINTS, "Unbounded objective variable during optimization");
           break;
         }
 
@@ -814,10 +815,9 @@ gtk_constraint_solver_optimize (GtkConstraintSolver *self,
       gtk_constraint_solver_pivot (self, entry, exit);
     }
 
-  GTK_NOTE (CONSTRAINTS,
-            g_message ("solver.optimize.time := %.3f ms (pass: %d)",
-                       (float) (g_get_monotonic_time () - start_time) / 1000.f,
-                       self->optimize_count));
+  GTK_DEBUG (CONSTRAINTS, "solver.optimize.time := %.3f ms (pass: %d)",
+                          (float) (g_get_monotonic_time () - start_time) / 1000.f,
+                          self->optimize_count);
 }
 
 /*< private >
@@ -1055,9 +1055,8 @@ gtk_constraint_solver_dual_optimize (GtkConstraintSolver *self)
       gtk_constraint_solver_pivot (self, entry_var, exit_var);
     }
 
-  GTK_NOTE (CONSTRAINTS,
-            g_message ("dual_optimize.time := %.3f ms",
-                       (float) (g_get_monotonic_time () - start_time) / 1000.f));
+  GTK_DEBUG (CONSTRAINTS, "dual_optimize.time := %.3f ms",
+                          (float) (g_get_monotonic_time () - start_time) / 1000.f);
 }
 
 static void
@@ -1198,8 +1197,8 @@ gtk_constraint_solver_choose_subject (GtkConstraintSolver *self,
 
   if (!G_APPROX_VALUE (gtk_constraint_expression_get_constant (expression), 0.0, 0.001))
     {
-      GTK_NOTE (CONSTRAINTS,
-                g_message ("Unable to satisfy required constraint (choose_subject)"));
+      GTK_DEBUG (CONSTRAINTS,
+                 "Unable to satisfy required constraint (choose_subject)");
       return NULL;
     }
 
@@ -1508,9 +1507,8 @@ gtk_constraint_solver_resolve (GtkConstraintSolver *solver)
 
   gtk_constraint_solver_reset_stay_constants (solver);
 
-  GTK_NOTE (CONSTRAINTS,
-            g_message ("resolve.time := %.3f ms",
-                       (float) (g_get_monotonic_time () - start_time) / 1000.f));
+  GTK_DEBUG (CONSTRAINTS, "resolve.time := %.3f ms",
+                          (float) (g_get_monotonic_time () - start_time) / 1000.f);
 
   solver->needs_solving = FALSE;
 }
diff --git a/gtk/gtkiconcache.c b/gtk/gtkiconcache.c
index 061b66f1cc..706de5450d 100644
--- a/gtk/gtkiconcache.c
+++ b/gtk/gtkiconcache.c
@@ -20,6 +20,7 @@
 #include "gtkdebug.h"
 #include "gtkiconcacheprivate.h"
 #include "gtkiconcachevalidatorprivate.h"
+#include "gtkprivate.h"
 
 #include <glib/gstdio.h>
 #include <gdk-pixbuf/gdk-pixdata.h>
@@ -66,7 +67,7 @@ gtk_icon_cache_unref (GtkIconCache *cache)
 
   if (cache->ref_count == 0)
     {
-      GTK_NOTE (ICONTHEME, g_message ("unmapping icon cache"));
+      GTK_DEBUG (ICONTHEME, "unmapping icon cache");
 
       if (cache->map)
         g_mapped_file_unref (cache->map);
@@ -87,7 +88,7 @@ gtk_icon_cache_new_for_path (const char *path)
    /* Check if we have a cache file */
   cache_filename = g_build_filename (path, "icon-theme.cache", NULL);
 
-  GTK_NOTE (ICONTHEME, g_message ("look for icon cache in %s", path));
+  GTK_DEBUG (ICONTHEME, "look for icon cache in %s", path);
 
   if (g_stat (path, &path_st) < 0)
     goto done;
@@ -98,7 +99,7 @@ gtk_icon_cache_new_for_path (const char *path)
   /* Verify cache is up-to-date */
   if (st.st_mtime < path_st.st_mtime)
     {
-      GTK_NOTE (ICONTHEME, g_message ("icon cache outdated"));
+      GTK_DEBUG (ICONTHEME, "icon cache outdated");
       goto done;
     }
 
@@ -127,7 +128,7 @@ gtk_icon_cache_new_for_path (const char *path)
     }
 #endif
 
-  GTK_NOTE (ICONTHEME, g_message ("found icon cache for %s", path));
+  GTK_DEBUG (ICONTHEME, "found icon cache for %s", path);
 
   cache = g_new0 (GtkIconCache, 1);
   cache->ref_count = 1;
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 4c39604132..159c841a5f 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -1346,8 +1346,7 @@ do_theme_change (GtkIconTheme *self)
   if (!self->themes_valid)
     return;
 
-  GTK_DISPLAY_NOTE (self->display, ICONTHEME,
-            g_message ("change to icon theme \"%s\"", self->current_theme));
+  GTK_DISPLAY_DEBUG (self->display, ICONTHEME, "change to icon theme \"%s\"", self->current_theme);
   blow_themes (self);
 
   queue_theme_changed (self);
@@ -2038,19 +2037,22 @@ load_themes (GtkIconTheme *self)
 
   self->last_stat_time = g_get_monotonic_time ();
 
-  GTK_DISPLAY_NOTE (self->display, ICONTHEME, {
-    GList *l;
-    GString *s;
-    s = g_string_new ("Current icon themes ");
-    for (l = self->themes; l; l = l->next)
-      {
-        IconTheme *theme = l->data;
-        g_string_append (s, theme->name);
-        g_string_append_c (s, ' ');
-      }
-    g_message ("%s", s->str);
-    g_string_free (s, TRUE);
-  });
+#ifdef G_ENABLE_DEBUG
+  if (GTK_DISPLAY_DEBUG_CHECK (self->display, ICONTHEME))
+    {
+      GList *l;
+      GString *s;
+      s = g_string_new ("Current icon themes ");
+      for (l = self->themes; l; l = l->next)
+        {
+          IconTheme *theme = l->data;
+          g_string_append (s, theme->name);
+          g_string_append_c (s, ' ');
+        }
+      gdk_debug_message ("%s", s->str);
+      g_string_free (s, TRUE);
+    }
+#endif
 }
 
 static gboolean
@@ -2169,9 +2171,13 @@ real_choose_icon (GtkIconTheme      *self,
   key.flags = flags;
 
   /* This is used in the icontheme unit test */
-  GTK_DISPLAY_NOTE (self->display, ICONTHEME,
-            for (i = 0; icon_names[i]; i++)
-              g_message ("\tlookup name: %s", icon_names[i]));
+#ifdef G_ENABLE_DEBUG
+  if (GTK_DISPLAY_DEBUG_CHECK (self->display, ICONTHEME))
+    {
+      for (i = 0; icon_names[i]; i++)
+        gdk_debug_message ("\tlookup name: %s", icon_names[i]);
+    }
+#endif
 
   icon = icon_cache_lookup (self, &key);
   if (icon)
@@ -2270,11 +2276,14 @@ real_choose_icon (GtkIconTheme      *self,
   /* Fall back to missing icon */
   if (icon == NULL)
     {
-      GTK_NOTE(ICONFALLBACK, {
-        char *s = g_strjoinv (", ", (char **)icon_names);
-        g_message ("No icon found in %s (or fallbacks) for: %s", self->current_theme, s);
-        g_free (s);
-      });
+#ifdef G_ENABLE_DEBUG
+      if (GTK_DEBUG_CHECK (ICONFALLBACK))
+        {
+          char *s = g_strjoinv (", ", (char **)icon_names);
+          gdk_debug_message ("No icon found in %s (or fallbacks) for: %s", self->current_theme, s);
+          g_free (s);
+        }
+#endif
       icon = icon_paintable_new ("image-missing", size, scale);
       icon->filename = g_strdup (IMAGE_MISSING_RESOURCE_PATH);
       icon->is_resource = TRUE;
@@ -2482,8 +2491,7 @@ gtk_icon_theme_lookup_icon (GtkIconTheme       *self,
   g_return_val_if_fail (icon_name != NULL, NULL);
   g_return_val_if_fail (scale >= 1, NULL);
 
-  GTK_DISPLAY_NOTE (self->display, ICONTHEME,
-                    g_message ("looking up icon %s for scale %d", icon_name, scale));
+  GTK_DISPLAY_DEBUG (self->display, ICONTHEME, "looking up icon %s for scale %d", icon_name, scale);
 
   gtk_icon_theme_lock (self);
 
@@ -3151,8 +3159,7 @@ scan_directory (GtkIconTheme  *self,
   const char *name;
   GHashTable *icons = NULL;
 
-  GTK_DISPLAY_NOTE (self->display, ICONTHEME,
-                    g_message ("scanning directory %s", full_dir));
+  GTK_DISPLAY_DEBUG (self->display, ICONTHEME, "scanning directory %s", full_dir);
 
   gdir = g_dir_open (full_dir, 0, NULL);
 
@@ -3193,8 +3200,7 @@ scan_resource_directory (GtkIconTheme  *self,
   char **children;
   int i;
 
-  GTK_DISPLAY_NOTE (self->display, ICONTHEME,
-                    g_message ("scanning resource directory %s", full_dir));
+  GTK_DISPLAY_DEBUG (self->display, ICONTHEME, "scanning resource directory %s", full_dir);
 
   children = g_resources_enumerate_children (full_dir, 0, NULL);
 
diff --git a/gtk/gtkimcontextquartz.c b/gtk/gtkimcontextquartz.c
index 1f4168479a..5ad4ea6a66 100644
--- a/gtk/gtkimcontextquartz.c
+++ b/gtk/gtkimcontextquartz.c
@@ -71,7 +71,7 @@ quartz_get_preedit_string (GtkIMContext *context,
 {
   GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
 
-  GTK_NOTE (MODULES, g_print ("quartz_get_preedit_string\n"));
+  GTK_DEBUG (MODULES, "quartz_get_preedit_string\n");
 
   if (str)
     *str = qc->preedit_str ? g_strdup (qc->preedit_str) : g_strdup ("");
@@ -126,7 +126,7 @@ output_result (GtkIMContext *context,
   marked_str = g_strdup (g_object_get_data (G_OBJECT (surface), TIC_MARKED_TEXT));
   if (fixed_str)
     {
-      GTK_NOTE (MODULES, g_print ("tic-insert-text: %s\n", fixed_str));
+      GTK_DEBUG (MODULES, "tic-insert-text: %s", fixed_str);
       g_free (qc->preedit_str);
       qc->preedit_str = NULL;
       g_object_set_data (G_OBJECT (surface), TIC_INSERT_TEXT, NULL);
@@ -136,7 +136,7 @@ output_result (GtkIMContext *context,
       unsigned int filtered =
           GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (surface),
                                                GIC_FILTER_KEY));
-      GTK_NOTE (MODULES, g_print ("filtered, %d\n", filtered));
+      GTK_DEBUG (MODULES, "filtered, %d", filtered);
       if (filtered)
         retval = TRUE;
       else
@@ -144,7 +144,7 @@ output_result (GtkIMContext *context,
     }
   if (marked_str)
     {
-      GTK_NOTE (MODULES, g_print ("tic-marked-text: %s\n", marked_str));
+      GTK_DEBUG (MODULES, "tic-marked-text: %s", marked_str);
       qc->cursor_index =
           GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (surface),
                                                TIC_SELECTED_POS));
@@ -177,7 +177,7 @@ quartz_filter_keypress (GtkIMContext *context,
   guint keyval;
   guint keycode;
 
-  GTK_NOTE (MODULES, g_print ("quartz_filter_keypress\n"));
+  GTK_DEBUG (MODULES, "quartz_filter_keypress");
 
   if (!GDK_IS_MACOS_SURFACE (qc->client_surface))
     return FALSE;
@@ -220,7 +220,7 @@ quartz_filter_keypress (GtkIMContext *context,
   g_object_set_data (G_OBJECT (qc->client_surface),
                      TIC_IN_KEY_DOWN,
                      GUINT_TO_POINTER (FALSE));
-  GTK_NOTE (MODULES, g_print ("quartz_filter_keypress done\n"));
+  GTK_DEBUG (MODULES, "quartz_filter_keypress done");
 
   return retval;
 }
@@ -257,7 +257,7 @@ discard_preedit (GtkIMContext *context)
 static void
 quartz_reset (GtkIMContext *context)
 {
-  GTK_NOTE (MODULES, g_print ("quartz_reset\n"));
+  GTK_DEBUG (MODULES, "quartz_reset");
   discard_preedit (context);
 }
 
@@ -267,7 +267,7 @@ quartz_set_client_surface (GtkIMContext *context,
 {
   GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
 
-  GTK_NOTE (MODULES, g_print ("quartz_set_client_surface: %p\n", widget));
+  GTK_DEBUG (MODULES, "quartz_set_client_surface: %p", widget);
 
   qc->client_widget = widget;
   qc->client_surface = NULL;
@@ -284,7 +284,7 @@ quartz_set_client_surface (GtkIMContext *context,
 static void
 quartz_focus_in (GtkIMContext *context)
 {
-  GTK_NOTE (MODULES, g_print ("quartz_focus_in\n"));
+  GTK_DEBUG (MODULES, "quartz_focus_in");
 
   GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
   qc->focused = TRUE;
@@ -293,7 +293,7 @@ quartz_focus_in (GtkIMContext *context)
 static void
 quartz_focus_out (GtkIMContext *context)
 {
-  GTK_NOTE (MODULES, g_print ("quartz_focus_out\n"));
+  GTK_DEBUG (MODULES, "quartz_focus_out");
 
   GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
   qc->focused = FALSE;
@@ -310,7 +310,7 @@ quartz_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
   int sx, sy;
   double wx, wy;
 
-  GTK_NOTE (MODULES, g_print ("quartz_set_cursor_location\n"));
+  GTK_DEBUG (MODULES, "quartz_set_cursor_location");
 
   if (!qc->client_surface || !qc->client_widget)
     return;
@@ -341,7 +341,7 @@ quartz_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
 static void
 quartz_set_use_preedit (GtkIMContext *context, gboolean use_preedit)
 {
-  GTK_NOTE (MODULES, g_print ("quartz_set_use_preedit: %d\n", use_preedit));
+  GTK_DEBUG (MODULES, "quartz_set_use_preedit: %d", use_preedit);
 }
 
 static void
@@ -353,7 +353,7 @@ commit_cb (GtkIMContext *context, const char *str, GtkIMContextQuartz *qc)
 static void
 imquartz_finalize (GObject *obj)
 {
-  GTK_NOTE (MODULES, g_print ("imquartz_finalize\n"));
+  GTK_DEBUG (MODULES, "imquartz_finalize");
 
   GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (obj);
   g_free (qc->preedit_str);
@@ -370,7 +370,7 @@ imquartz_finalize (GObject *obj)
 static void
 gtk_im_context_quartz_class_init (GtkIMContextQuartzClass *class)
 {
-  GTK_NOTE (MODULES, g_print ("gtk_im_context_quartz_class_init\n"));
+  GTK_DEBUG (MODULES, "gtk_im_context_quartz_class_init");
 
   GtkIMContextClass *klass = GTK_IM_CONTEXT_CLASS (class);
   GObjectClass *object_class = G_OBJECT_CLASS (class);
@@ -390,7 +390,7 @@ gtk_im_context_quartz_class_init (GtkIMContextQuartzClass *class)
 static void
 gtk_im_context_quartz_init (GtkIMContextQuartz *qc)
 {
-  GTK_NOTE (MODULES, g_print ("gtk_im_context_quartz_init\n"));
+  GTK_DEBUG (MODULES, "gtk_im_context_quartz_init");
 
   qc->preedit_str = g_strdup ("");
   qc->cursor_index = 0;
diff --git a/gtk/gtkimmodule.c b/gtk/gtkimmodule.c
index d252d2fce3..4c36cbe251 100644
--- a/gtk/gtkimmodule.c
+++ b/gtk/gtkimmodule.c
@@ -242,8 +242,7 @@ gtk_im_module_ensure_extension_point (void)
   if (registered)
     return;
 
-  GTK_NOTE (MODULES,
-            g_print ("Registering extension point %s\n", GTK_IM_MODULE_EXTENSION_POINT_NAME));
+  GTK_DEBUG (MODULES, "Registering extension point %s", GTK_IM_MODULE_EXTENSION_POINT_NAME);
 
   ep = g_io_extension_point_register (GTK_IM_MODULE_EXTENSION_POINT_NAME);
   g_io_extension_point_set_required_type (ep, GTK_TYPE_IM_CONTEXT);
@@ -279,8 +278,7 @@ gtk_im_modules_init (void)
   paths = _gtk_get_module_path ("immodules");
   for (i = 0; paths[i]; i++)
     {
-      GTK_NOTE (MODULES,
-                g_print ("Scanning io modules in %s\n", paths[i]));
+      GTK_DEBUG (MODULES, "Scanning io modules in %s", paths[i]);
       g_io_modules_scan_all_in_directory_with_scope (paths[i], scope);
     }
   g_strfreev (paths);
diff --git a/gtk/gtkmediafile.c b/gtk/gtkmediafile.c
index fa1f12d2a1..ea6df0560b 100644
--- a/gtk/gtkmediafile.c
+++ b/gtk/gtkmediafile.c
@@ -22,6 +22,7 @@
 #include "gtkmediafileprivate.h"
 
 #include "gtkdebug.h"
+#include "gtkprivate.h"
 #include "gtkintl.h"
 #include "gtkmodulesprivate.h"
 #include "gtknomediafileprivate.h"
@@ -186,7 +187,7 @@ gtk_media_file_get_extension (void)
   GIOExtension *e;
   GIOExtensionPoint *ep;
 
-  GTK_NOTE (MODULES, g_print ("Looking up MediaFile extension\n"));
+  GTK_DEBUG (MODULES, "Looking up MediaFile extension");
 
   ep = g_io_extension_point_lookup (GTK_MEDIA_FILE_EXTENSION_POINT_NAME);
   e = NULL;
@@ -246,7 +247,8 @@ gtk_media_file_get_impl_type (void)
   e = gtk_media_file_get_extension ();
   impl_type = g_io_extension_get_type (e);
 
-  GTK_NOTE (MODULES, g_print ("Using %s from \"%s\" extension\n", g_type_name (impl_type), 
g_io_extension_get_name (e)));
+  GTK_DEBUG (MODULES, "Using %s from \"%s\" extension",
+             g_type_name (impl_type), g_io_extension_get_name (e));
 
   return impl_type;
 }
@@ -609,8 +611,7 @@ gtk_media_file_extension_init (void)
   char **paths;
   int i;
 
-  GTK_NOTE (MODULES,
-            g_print ("Registering extension point %s\n", GTK_MEDIA_FILE_EXTENSION_POINT_NAME));
+  GTK_DEBUG (MODULES, "Registering extension point %s", GTK_MEDIA_FILE_EXTENSION_POINT_NAME);
 
   ep = g_io_extension_point_register (GTK_MEDIA_FILE_EXTENSION_POINT_NAME);
   g_io_extension_point_set_required_type (ep, GTK_TYPE_MEDIA_FILE);
@@ -622,8 +623,7 @@ gtk_media_file_extension_init (void)
   paths = _gtk_get_module_path ("media");
   for (i = 0; paths[i]; i++)
     {
-      GTK_NOTE (MODULES,
-                g_print ("Scanning io modules in %s\n", paths[i]));
+      GTK_DEBUG (MODULES, "Scanning io modules in %s", paths[i]);
       g_io_modules_scan_all_in_directory_with_scope (paths[i], scope);
     }
   g_strfreev (paths);
diff --git a/gtk/gtkmenutrackeritem.c b/gtk/gtkmenutrackeritem.c
index 8b459c7a41..f938b3fe1d 100644
--- a/gtk/gtkmenutrackeritem.c
+++ b/gtk/gtkmenutrackeritem.c
@@ -23,6 +23,7 @@
 #include "gtkactionmuxerprivate.h"
 #include "gtkdebug.h"
 #include "gtkintl.h"
+#include "gtkprivate.h"
 
 #include <string.h>
 
@@ -302,7 +303,7 @@ gtk_menu_tracker_item_action_added (GtkActionObserver   *observer,
   GtkMenuTrackerItemRole old_role;
   guint n_changed;
 
-  GTK_NOTE(ACTIONS, g_message ("menutracker: action %s added", action_name));
+  GTK_DEBUG (ACTIONS, "menutracker: action %s added", action_name);
 
   old_sensitive = self->sensitive;
   old_toggled = self->toggled;
@@ -316,22 +317,22 @@ gtk_menu_tracker_item_action_added (GtkActionObserver   *observer,
 
   if (!self->can_activate)
     {
-      GTK_NOTE(ACTIONS, g_message ("menutracker: action %s can't be activated due to parameter type mismatch 
"
-                                   "(parameter type %s, target type %s)",
-                                   action_name,
-                                   parameter_type ? g_variant_type_peek_string (parameter_type) : "NULL",
-                                   action_target ? g_variant_get_type_string (action_target) : "NULL"));
+      GTK_DEBUG (ACTIONS, "menutracker: action %s can't be activated due to parameter type mismatch "
+                          "(parameter type %s, target type %s)",
+                          action_name,
+                          parameter_type ? g_variant_type_peek_string (parameter_type) : "NULL",
+                          action_target ? g_variant_get_type_string (action_target) : "NULL");
 
       if (action_target)
         g_variant_unref (action_target);
       return;
     }
 
-  GTK_NOTE(ACTIONS, g_message ("menutracker: action %s can be activated", action_name));
+  GTK_DEBUG (ACTIONS, "menutracker: action %s can be activated", action_name);
 
   self->sensitive = enabled;
 
-  GTK_NOTE(ACTIONS, g_message ("menutracker: action %s is %s", action_name, enabled ? "enabled" : 
"disabled"));
+  GTK_DEBUG (ACTIONS, "menutracker: action %s is %s", action_name, enabled ? "enabled" : "disabled");
 
   if (action_target != NULL && state != NULL)
     {
@@ -387,7 +388,7 @@ gtk_menu_tracker_item_action_enabled_changed (GtkActionObserver   *observer,
 {
   GtkMenuTrackerItem *self = GTK_MENU_TRACKER_ITEM (observer);
 
-  GTK_NOTE(ACTIONS, g_message ("menutracker: action %s: enabled changed to %d", action_name, enabled));
+  GTK_DEBUG (ACTIONS, "menutracker: action %s: enabled changed to %d", action_name, enabled);
 
   if (!self->can_activate)
     return;
@@ -412,7 +413,7 @@ gtk_menu_tracker_item_action_state_changed (GtkActionObserver   *observer,
   GVariant *action_target;
   gboolean was_toggled;
 
-  GTK_NOTE(ACTIONS, g_message ("menutracker: action %s: state changed", action_name));
+  GTK_DEBUG (ACTIONS, "menutracker: action %s: state changed", action_name);
 
   if (!self->can_activate)
     return;
@@ -445,7 +446,7 @@ gtk_menu_tracker_item_action_removed (GtkActionObserver   *observer,
   gboolean was_sensitive, was_toggled;
   GtkMenuTrackerItemRole old_role;
 
-  GTK_NOTE(ACTIONS, g_message ("menutracker: action %s was removed", action_name));
+  GTK_DEBUG (ACTIONS, "menutracker: action %s was removed", action_name);
 
   if (!self->can_activate)
     return;
@@ -562,10 +563,14 @@ _gtk_menu_tracker_item_new (GtkActionObservable *observable,
 
       action_name = strrchr (self->action_and_target, '|') + 1;
 
-      GTK_NOTE(ACTIONS,
-               if (!strchr (action_name, '.'))
-                 g_message ("menutracker: action name %s doesn't look like 'app.' or 'win.'; "
-                            "it is unlikely to work", action_name));
+#ifdef G_ENABLE_DEBUG
+      if (GTK_DEBUG_CHECK (ACTIONS))
+        {
+          if (!strchr (action_name, '.'))
+            gdk_debug_message ("menutracker: action name %s doesn't look like 'app.' or 'win.'; "
+                               "it is unlikely to work", action_name);
+        }
+#endif
 
       state = NULL;
 
@@ -574,12 +579,12 @@ _gtk_menu_tracker_item_new (GtkActionObservable *observable,
 
       if (found)
         {
-          GTK_NOTE(ACTIONS, g_message ("menutracker: action %s existed from the start", action_name));
+          GTK_DEBUG (ACTIONS, "menutracker: action %s existed from the start", action_name);
           gtk_menu_tracker_item_action_added (GTK_ACTION_OBSERVER (self), observable, action_name, 
parameter_type, enabled, state);
         }
       else
         {
-          GTK_NOTE(ACTIONS, g_message ("menutracker: action %s missing from the start", action_name));
+          GTK_DEBUG (ACTIONS, "menutracker: action %s missing from the start", action_name);
           gtk_menu_tracker_item_update_visibility (self);
         }
 
diff --git a/gtk/gtkprintbackend.c b/gtk/gtkprintbackend.c
index 9e628a5704..292e6d7bc9 100644
--- a/gtk/gtkprintbackend.c
+++ b/gtk/gtkprintbackend.c
@@ -88,8 +88,7 @@ gtk_print_backends_init (void)
   char **paths;
   int i;
 
-  GTK_NOTE (MODULES,
-            g_print ("Registering extension point %s\n", GTK_PRINT_BACKEND_EXTENSION_POINT_NAME));
+  GTK_DEBUG (MODULES, "Registering extension point %s", GTK_PRINT_BACKEND_EXTENSION_POINT_NAME);
 
   ep = g_io_extension_point_register (GTK_PRINT_BACKEND_EXTENSION_POINT_NAME);
   g_io_extension_point_set_required_type (ep, GTK_TYPE_PRINT_BACKEND);
@@ -99,8 +98,7 @@ gtk_print_backends_init (void)
   paths = _gtk_get_module_path ("printbackends");
   for (i = 0; paths[i]; i++)
     {
-      GTK_NOTE (MODULES,
-                g_print ("Scanning io modules in %s\n", paths[i]));
+      GTK_DEBUG (MODULES, "Scanning io modules in %s", paths[i]);
       g_io_modules_scan_all_in_directory_with_scope (paths[i], scope);
     }
   g_strfreev (paths);
@@ -159,8 +157,7 @@ gtk_print_backend_load_modules (void)
       if (!ext)
         continue;
 
-      GTK_NOTE (PRINTING,
-                g_print ("Found %s print backend\n", backends[i]));
+      GTK_DEBUG (PRINTING, "Found %s print backend", backends[i]);
 
       type = g_io_extension_get_type (ext);
       backend = g_object_new (type, NULL);
diff --git a/gtk/gtkshortcutaction.c b/gtk/gtkshortcutaction.c
index ccb46e327d..2d2d413900 100644
--- a/gtk/gtkshortcutaction.c
+++ b/gtk/gtkshortcutaction.c
@@ -57,6 +57,7 @@
 #include "gtkintl.h"
 #include "gtkwidgetprivate.h"
 #include "gtkdebug.h"
+#include "gtkprivate.h"
 
 /* {{{ GtkShortcutAction */
 
@@ -161,11 +162,14 @@ gtk_shortcut_action_activate (GtkShortcutAction      *self,
   g_return_val_if_fail (GTK_IS_SHORTCUT_ACTION (self), FALSE);
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  GTK_NOTE (KEYBINDINGS, {
-            char *act = gtk_shortcut_action_to_string (self);
-            g_print ("Shortcut action activate on %s: %s\n", G_OBJECT_TYPE_NAME (widget), act);
-            g_free (act);
-            });
+#ifdef G_ENABLE_DEBUG
+  if (GTK_DEBUG_CHECK (KEYBINDINGS))
+    {
+      char *act = gtk_shortcut_action_to_string (self);
+      gdk_debug_message ("Shortcut action activate on %s: %s", G_OBJECT_TYPE_NAME (widget), act);
+      g_free (act);
+    }
+#endif
 
   return GTK_SHORTCUT_ACTION_GET_CLASS (self)->activate (self, flags, widget, args);
 }
diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c
index 637a705f87..100b3db809 100644
--- a/gtk/gtksizerequest.c
+++ b/gtk/gtksizerequest.c
@@ -427,26 +427,29 @@ gtk_widget_query_size_for_orientation (GtkWidget        *widget,
 
   g_assert (min_size <= nat_size);
 
-  GTK_DISPLAY_NOTE (_gtk_widget_get_display (widget), SIZE_REQUEST, {
-            GString *s;
-
-            s = g_string_new ("");
-            g_string_append_printf (s, "[%p] %s\t%s: %d is minimum %d and natural: %d",
-                                    widget, G_OBJECT_TYPE_NAME (widget),
-                                    orientation == GTK_ORIENTATION_HORIZONTAL
-                                    ? "width for height"
-                                    : "height for width",
-                                    for_size, min_size, nat_size);
-           if (min_baseline != -1 || nat_baseline != -1)
-              {
-                g_string_append_printf (s, ", baseline %d/%d",
-                                        min_baseline, nat_baseline);
-              }
-           g_string_append_printf (s, " (hit cache: %s)\n",
-                                   found_in_cache ? "yes" : "no");
-            g_printerr ("%s", s->str);
-            g_string_free (s, TRUE);
-           });
+#ifdef G_ENABLE_DEBUG
+  if (GTK_DISPLAY_DEBUG_CHECK (_gtk_widget_get_display (widget), SIZE_REQUEST))
+    {
+      GString *s;
+
+      s = g_string_new ("");
+      g_string_append_printf (s, "[%p] %s\t%s: %d is minimum %d and natural: %d",
+                              widget, G_OBJECT_TYPE_NAME (widget),
+                              orientation == GTK_ORIENTATION_HORIZONTAL
+                              ? "width for height"
+                              : "height for width",
+                              for_size, min_size, nat_size);
+      if (min_baseline != -1 || nat_baseline != -1)
+        {
+          g_string_append_printf (s, ", baseline %d/%d",
+                                  min_baseline, nat_baseline);
+        }
+      g_string_append_printf (s, " (hit cache: %s)\n",
+                              found_in_cache ? "yes" : "no");
+      g_printerr ("%s", s->str);
+      g_string_free (s, TRUE);
+    }
+#endif
 }
 
 /**
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index dda5a1f042..2a90295270 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -8412,9 +8412,9 @@ gtk_widget_accessible_get_at_context (GtkAccessible *accessible)
 
   if (priv->in_destruction)
     {
-      GTK_NOTE (A11Y, g_message ("ATContext for widget ā€œ%sā€ [%p] accessed during destruction",
-                                 G_OBJECT_TYPE_NAME (self),
-                                 self));
+      GTK_DEBUG (A11Y, "ATContext for widget ā€œ%sā€ [%p] accessed during destruction",
+                       G_OBJECT_TYPE_NAME (self),
+                       self);
       return NULL;
     }
 
@@ -12485,9 +12485,9 @@ gtk_widget_class_add_action (GtkWidgetClass  *widget_class,
 {
   GtkWidgetClassPrivate *priv = widget_class->priv;
 
-  GTK_NOTE(ACTIONS, g_message ("%sClass: Adding %s action\n",
-                               g_type_name (G_TYPE_FROM_CLASS (widget_class)),
-                               action->name));
+  GTK_DEBUG (ACTIONS, "%sClass: Adding %s action",
+                      g_type_name (G_TYPE_FROM_CLASS (widget_class)),
+                      action->name);
 
   action->next = priv->actions;
   priv->actions = action;
diff --git a/modules/printbackends/gtkcupssecretsutils.c b/modules/printbackends/gtkcupssecretsutils.c
index 47e707b114..d7a50fbbc3 100644
--- a/modules/printbackends/gtkcupssecretsutils.c
+++ b/modules/printbackends/gtkcupssecretsutils.c
@@ -20,6 +20,7 @@
 #include <string.h>
 
 #include <gtk/gtk.h>
+#include "gtkprivate.h"
 
 #include "gtkcupssecretsutils.h"
 
@@ -69,8 +70,7 @@ create_attributes (const char   *printer_uri,
 
   if (printer_uri == NULL)
     {
-      GTK_NOTE (PRINTING,
-                g_print ("create_attributes called with invalid parameters.\n"));
+      GTK_DEBUG (PRINTING, "create_attributes called with invalid parameters.");
       return NULL;
     }
 
@@ -128,7 +128,7 @@ get_secret_cb (GObject      *source_object,
                                                  "Attributes");
   if (attributes == NULL)
     {
-      GTK_NOTE (PRINTING, g_print ("Failed to lookup attributes.\n"));
+      GTK_DEBUG (PRINTING, "Failed to lookup attributes.");
       g_variant_unref (output);
       g_task_return_pointer (task, NULL, NULL);
       return;
@@ -173,7 +173,7 @@ get_secret_cb (GObject      *source_object,
   if (pw_field == -1)
     {
       /* should not happen... */
-      GTK_NOTE (PRINTING, g_print ("No password required?.\n"));
+      GTK_DEBUG (PRINTING, "No password required?.");
       g_variant_unref (output);
       goto fail;
     }
@@ -188,7 +188,7 @@ get_secret_cb (GObject      *source_object,
       g_variant_unref (output);
       if (secret == NULL || g_variant_n_children (secret) != 4)
         {
-          GTK_NOTE (PRINTING, g_print ("Get secret response invalid.\n"));
+          GTK_DEBUG (PRINTING, "Get secret response invalid.");
           if (secret != NULL)
             g_variant_unref (secret);
           goto fail;
@@ -202,7 +202,7 @@ get_secret_cb (GObject      *source_object,
 
       if (ba_passwd == NULL)
         {
-          GTK_NOTE (PRINTING, g_print ("Invalid / no secret found.\n"));
+          GTK_DEBUG (PRINTING, "Invalid / no secret found.");
           g_variant_unref (s_value);
           goto fail;
         }
@@ -216,8 +216,8 @@ get_secret_cb (GObject      *source_object,
       if (auth_info[i] == NULL)
         {
           /* Error out if we did not find everything */
-          GTK_NOTE (PRINTING, g_print ("Failed to lookup required attribute: %s.\n",
-                                       task_data->auth_info_required[i]));
+          GTK_DEBUG (PRINTING, "Failed to lookup required attribute: %s.",
+                               task_data->auth_info_required[i]);
           goto fail;
         }
     }
@@ -227,7 +227,7 @@ get_secret_cb (GObject      *source_object,
 
 fail:
   /* Error out */
-  GTK_NOTE (PRINTING, g_print ("Failed to lookup secret.\n"));
+  GTK_DEBUG (PRINTING, "Failed to lookup secret.");
   required_len = g_strv_length (task_data->auth_info_required);
   for (i = 0; i < required_len; i++)
     {
@@ -263,7 +263,7 @@ create_item_cb (GObject      *source_object,
   g_variant_get (output, "(&o&o)", &item, NULL);
   if (item != NULL && strlen (item) > 1)
     {
-      GTK_NOTE (PRINTING, g_print ("Successfully stored auth info.\n"));
+      GTK_DEBUG (PRINTING, "Successfully stored auth info.");
       g_task_return_pointer (task, NULL, NULL);
       return;
     }
@@ -316,14 +316,14 @@ do_store_auth_info (GTask *task)
   g_free (additional_attrs);
   if (attributes == NULL)
     {
-      GTK_NOTE (PRINTING, g_print ("Failed to create attributes.\n"));
+      GTK_DEBUG (PRINTING, "Failed to create attributes.");
       g_task_return_pointer (task, NULL, NULL);
       return;
     }
 
   if (password == NULL)
     {
-      GTK_NOTE (PRINTING, g_print ("No secret to store.\n"));
+      GTK_DEBUG (PRINTING, "No secret to store.");
       g_task_return_pointer (task, NULL, NULL);
       return;
     }
@@ -387,7 +387,7 @@ prompt_completed_cb (GDBusConnection *connection,
 
   if (dismissed == NULL)
     {
-      GTK_NOTE (PRINTING, g_print ("Invalid prompt signal.\n"));
+      GTK_DEBUG (PRINTING, "Invalid prompt signal.");
       g_task_return_pointer (task, NULL, NULL);
       return;
     }
@@ -397,7 +397,7 @@ prompt_completed_cb (GDBusConnection *connection,
 
   if (is_dismissed)
     {
-      GTK_NOTE (PRINTING, g_print ("Collection unlock dismissed.\n"));
+      GTK_DEBUG (PRINTING, "Collection unlock dismissed.");
       g_task_return_pointer (task, NULL, NULL);
       return;
     }
@@ -560,7 +560,7 @@ unlock_read_alias_cb (GObject      *source_object,
 
   if (subresult == NULL)
     {
-      GTK_NOTE (PRINTING, g_print ("Invalid ReadAlias response.\n"));
+      GTK_DEBUG (PRINTING, "Invalid ReadAlias response.");
       g_task_return_pointer (task, NULL, NULL);
       return;
     }
@@ -616,7 +616,7 @@ item_proxy_cb (GObject      *source_object,
 
   if (locked == NULL)
     {
-      GTK_NOTE (PRINTING, g_print ("Failed to look up \"Locked\" property on item.\n"));
+      GTK_DEBUG (PRINTING, "Failed to look up \"Locked\" property on item.");
       g_task_return_pointer (task, NULL, NULL);
       return;
     }
@@ -699,8 +699,7 @@ search_items_cb (GObject      *source_object,
 
       if (item_paths == NULL)
         {
-          GTK_NOTE (PRINTING,
-                    g_print ("SearchItems returned invalid result.\n"));
+          GTK_DEBUG (PRINTING, "SearchItems returned invalid result.");
           continue;
         }
 
@@ -732,7 +731,7 @@ search_items_cb (GObject      *source_object,
 
   if (!found_item)
     {
-      GTK_NOTE (PRINTING, g_print ("No match found in secrets service.\n"));
+      GTK_DEBUG (PRINTING, "No match found in secrets service.");
       g_task_return_pointer (task, NULL, NULL);
       return;
     }
@@ -765,7 +764,7 @@ open_session_cb (GObject      *source_object,
 
   if (session_variant == NULL)
     {
-      GTK_NOTE (PRINTING, g_print ("Invalid session path response.\n"));
+      GTK_DEBUG (PRINTING, "Invalid session path response.");
       g_variant_unref (output);
       g_task_return_pointer (task, NULL, NULL);
       return;
@@ -775,7 +774,7 @@ open_session_cb (GObject      *source_object,
 
   if (task_data->session_path == NULL)
     {
-      GTK_NOTE (PRINTING, g_print ("Invalid session path string value.\n"));
+      GTK_DEBUG (PRINTING, "Invalid session path string value.");
       g_variant_unref (session_variant);
       g_variant_unref (output);
       g_task_return_pointer (task, NULL, NULL);
@@ -795,7 +794,7 @@ open_session_cb (GObject      *source_object,
           secrets_attrs = create_attributes (task_data->printer_uri, NULL, NULL);
           if (secrets_attrs == NULL)
             {
-              GTK_NOTE (PRINTING, g_print ("Failed to create attributes.\n"));
+              GTK_DEBUG (PRINTING, "Failed to create attributes.");
               g_task_return_pointer (task, NULL, NULL);
               return;
             }
@@ -1001,14 +1000,12 @@ store_done_cb (GObject      *source_object,
 
   if (error != NULL)
     {
-      GTK_NOTE (PRINTING,
-                g_print ("Failed to store auth info: %s\n", error->message));
+      GTK_DEBUG (PRINTING, "Failed to store auth info: %s", error->message);
       g_error_free (error);
     }
 
   g_object_unref (task);
-  GTK_NOTE (PRINTING,
-            g_print ("gtk_cups_secrets_service_store finished.\n"));
+  GTK_DEBUG (PRINTING, "gtk_cups_secrets_service_store finished.");
 }
 
 /**
@@ -1029,8 +1026,7 @@ gtk_cups_secrets_service_store (char        **auth_info,
 
   if (auth_info == NULL || auth_info_labels == NULL || printer_uri == NULL)
     {
-      GTK_NOTE (PRINTING,
-                g_print ("Invalid call to gtk_cups_secrets_service_store.\n"));
+      GTK_DEBUG (PRINTING, "Invalid call to gtk_cups_secrets_service_store.");
       return;
     }
 
diff --git a/modules/printbackends/gtkcupsutils.c b/modules/printbackends/gtkcupsutils.c
index 7955302819..325dc4880e 100644
--- a/modules/printbackends/gtkcupsutils.c
+++ b/modules/printbackends/gtkcupsutils.c
@@ -20,6 +20,7 @@
 #include "config.h"
 #include <gtk/gtk.h>
 #include "gtkcupsutils.h"
+#include "gtkprivate.h"
 
 #include <errno.h>
 #include <unistd.h>
@@ -693,8 +694,7 @@ _post_send (GtkCupsRequest *request)
   char length[255];
   struct stat data_info;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
 
   request->poll_state = GTK_CUPS_HTTP_WRITE;
 
@@ -745,8 +745,7 @@ _post_write_request (GtkCupsRequest *request)
 {
   ipp_state_t ipp_status;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
 
   request->poll_state = GTK_CUPS_HTTP_WRITE;
   
@@ -786,8 +785,7 @@ _post_write_data (GtkCupsRequest *request)
   char buffer[_GTK_CUPS_MAX_CHUNK_SIZE];
   http_status_t http_status;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
 
   request->poll_state = GTK_CUPS_HTTP_WRITE;
   
@@ -941,8 +939,7 @@ _post_check (GtkCupsRequest *request)
 
   http_status = request->last_status;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s - status %i\n", G_STRFUNC, http_status));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s - status %i", G_STRFUNC, http_status);
 
   request->poll_state = GTK_CUPS_HTTP_READ;
 
@@ -1135,8 +1132,7 @@ _post_read_response (GtkCupsRequest *request)
 {
   ipp_state_t ipp_status;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
 
   request->poll_state = GTK_CUPS_HTTP_READ;
 
@@ -1172,8 +1168,7 @@ _post_read_response (GtkCupsRequest *request)
 static void 
 _get_send (GtkCupsRequest *request)
 {
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
 
   request->poll_state = GTK_CUPS_HTTP_WRITE;
 
@@ -1232,8 +1227,7 @@ _get_check (GtkCupsRequest *request)
 {
   http_status_t http_status;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
 
   http_status = request->last_status;
 
@@ -1406,8 +1400,7 @@ _get_read_data (GtkCupsRequest *request)
   GIOStatus io_status;
   GError *error;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
 
   error = NULL;
 
@@ -1416,8 +1409,7 @@ _get_read_data (GtkCupsRequest *request)
   bytes = httpRead2 (request->http, buffer, sizeof (buffer));
   request->bytes_received += bytes;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %"G_GSIZE_FORMAT" bytes read\n", bytes));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %"G_GSIZE_FORMAT" bytes read", bytes);
 
   io_status =
     g_io_channel_write_chars (request->data_io, 
diff --git a/modules/printbackends/gtkprintbackendcups.c b/modules/printbackends/gtkprintbackendcups.c
index 9a713da0e4..41774a0bdd 100644
--- a/modules/printbackends/gtkprintbackendcups.c
+++ b/modules/printbackends/gtkprintbackendcups.c
@@ -48,6 +48,7 @@
 #include <gtk/gtkprintbackendprivate.h>
 #include <gtk/gtkunixprint.h>
 #include <gtk/gtkprinterprivate.h>
+#include <gtk/gtkprivate.h>
 
 #include "gtkprintbackendcups.h"
 #include "gtkprintercups.h"
@@ -291,8 +292,7 @@ g_io_module_query (void)
 GtkPrintBackend *
 gtk_print_backend_cups_new (void)
 {
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: Creating a new CUPS print backend object\n"));
+  GTK_DEBUG (PRINTING, "CUPS Backend: Creating a new CUPS print backend object");
 
   return g_object_new (GTK_TYPE_PRINT_BACKEND_CUPS, NULL);
 }
@@ -365,8 +365,7 @@ _cairo_write_to_cups (void                *closure,
 
   error = NULL;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: Writing %i byte chunk to temp file\n", length));
+  GTK_DEBUG (PRINTING, "CUPS Backend: Writing %i byte chunk to temp file", length);
 
   while (length > 0)
     {
@@ -374,16 +373,15 @@ _cairo_write_to_cups (void                *closure,
 
       if (error != NULL)
        {
-         GTK_NOTE (PRINTING,
-                    g_print ("CUPS Backend: Error writing to temp file, %s\n",
-                             error->message));
+         GTK_DEBUG (PRINTING, "CUPS Backend: Error writing to temp file, %s",
+                             error->message);
 
           g_error_free (error);
          return CAIRO_STATUS_WRITE_ERROR;
        }
 
-      GTK_NOTE (PRINTING,
-                g_print ("CUPS Backend: Wrote %"G_GSIZE_FORMAT" bytes to temp file\n", written));
+      GTK_DEBUG (PRINTING, "CUPS Backend: Wrote %"G_GSIZE_FORMAT" bytes to temp file",
+                           written);
 
       data += written;
       length -= written;
@@ -496,8 +494,7 @@ typedef struct {
 static void
 cups_free_print_stream_data (CupsPrintStreamData *data)
 {
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
 
   if (data->dnotify)
     data->dnotify (data->user_data);
@@ -515,8 +512,7 @@ cups_print_cb (GtkPrintBackendCups *print_backend,
   GError *error = NULL;
   CupsPrintStreamData *ps = user_data;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
 
   if (gtk_cups_result_is_error (result))
     error = g_error_new_literal (gtk_print_error_quark (),
@@ -707,8 +703,7 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend         *print_backend,
   char  printer_absolute_uri[HTTP_MAX_URI];
   http_t *http = NULL;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
 
   cups_printer = GTK_PRINTER_CUPS (gtk_print_job_get_printer (job));
   settings = gtk_print_job_get_settings (job);
@@ -735,10 +730,9 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend         *print_backend,
         {
           GError *error = NULL;
 
-          GTK_NOTE (PRINTING,
-                    g_warning ("CUPS Backend: Error connecting to %s:%d",
+          GTK_DEBUG (PRINTING, "CUPS Backend: Error connecting to %s:%d",
                                cups_printer->hostname,
-                               cups_printer->port));
+                               cups_printer->port);
 
           error = g_error_new (gtk_print_error_quark (),
                                GTK_CUPS_ERROR_GENERAL,
@@ -836,9 +830,8 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend         *print_backend,
       g_strv_length (cups_printer->auth_info_required) == 1 &&
       g_strcmp0 (cups_printer->auth_info_required[0], "negotiate") == 0)
     {
-      GTK_NOTE (PRINTING,
-                g_print ("CUPS Backend: Ignoring auth-info-required \"%s\"\n",
-                         cups_printer->auth_info_required[0]));
+      GTK_DEBUG (PRINTING, "CUPS Backend: Ignoring auth-info-required \"%s\"",
+                           cups_printer->auth_info_required[0]);
     }
   else if (cups_printer->auth_info_required != NULL)
     {
@@ -915,8 +908,7 @@ gtk_print_backend_cups_finalize (GObject *object)
 {
   GtkPrintBackendCups *backend_cups;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: finalizing CUPS backend module\n"));
+  GTK_DEBUG (PRINTING, "CUPS Backend: finalizing CUPS backend module");
 
   backend_cups = GTK_PRINT_BACKEND_CUPS (object);
 
@@ -959,8 +951,7 @@ gtk_print_backend_cups_dispose (GObject *object)
   GtkPrintBackendCups *backend_cups;
   int i;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
 
   backend_cups = GTK_PRINT_BACKEND_CUPS (object);
 
@@ -1061,8 +1052,7 @@ gtk_print_backend_cups_set_password (GtkPrintBackend  *backend,
     {
       char *key = g_strconcat (username, "@", hostname, NULL);
       g_hash_table_insert (cups_backend->auth, key, g_strdup (password));
-      GTK_NOTE (PRINTING,
-                g_print ("CUPS backend: caching password for %s\n", key));
+      GTK_DEBUG (PRINTING, "CUPS backend: caching password for %s", key);
     }
 
   g_free (cups_backend->username);
@@ -1160,8 +1150,7 @@ request_password (gpointer data)
 
   if (password && dispatch->request->password_state != GTK_CUPS_PASSWORD_NOT_VALID)
     {
-      GTK_NOTE (PRINTING,
-                g_print ("CUPS backend: using stored password for %s\n", key));
+      GTK_DEBUG (PRINTING, "CUPS backend: using stored password for %s", key);
 
       overwrite_and_free (dispatch->request->password);
       dispatch->request->password = g_strdup (password);
@@ -1348,14 +1337,13 @@ lookup_auth_info_cb (GObject      *source_object,
     {
       if (error != NULL)
         {
-          GTK_NOTE (PRINTING,
-                    g_print ("Failed to look up auth info: %s\n", error->message));
+          GTK_DEBUG (PRINTING, "Failed to look up auth info: %s", error->message);
           g_error_free (error);
         }
       else
         {
           /* Error note should have been shown by the function causing this */
-          GTK_NOTE (PRINTING, g_print ("Failed to look up auth info.\n"));
+          GTK_DEBUG (PRINTING, "Failed to look up auth info.");
         }
       dispatch->backend->authentication_lock = FALSE;
       g_object_unref (task);
@@ -1521,8 +1509,7 @@ cups_dispatch_watch_check (GSource *source)
   GtkCupsPollState poll_state;
   gboolean result;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s <source %p>\n", G_STRFUNC, source));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s <source %p>", G_STRFUNC, source);
 
   dispatch = (GtkPrintCupsDispatchWatch *) source;
 
@@ -1559,8 +1546,7 @@ cups_dispatch_watch_prepare (GSource *source,
 
   dispatch = (GtkPrintCupsDispatchWatch *) source;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s <source %p>\n", G_STRFUNC, source));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s <source %p>", G_STRFUNC, source);
 
   *timeout_ = -1;
 
@@ -1588,17 +1574,15 @@ cups_dispatch_watch_dispatch (GSource     *source,
 
   result = gtk_cups_request_get_result (dispatch->request);
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s <source %p>\n", G_STRFUNC, source));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s <source %p>", G_STRFUNC, source);
 
   if (gtk_cups_result_is_error (result))
     {
-      GTK_NOTE (PRINTING,
-                g_print("Error result: %s (type %i, status %i, code %i)\n",
-                        gtk_cups_result_get_error_string (result),
-                        gtk_cups_result_get_error_type (result),
-                        gtk_cups_result_get_error_status (result),
-                        gtk_cups_result_get_error_code (result)));
+      GTK_DEBUG (PRINTING, "Error result: %s (type %i, status %i, code %i)",
+                           gtk_cups_result_get_error_string (result),
+                           gtk_cups_result_get_error_type (result),
+                           gtk_cups_result_get_error_status (result),
+                           gtk_cups_result_get_error_code (result));
      }
 
   ep_callback (GTK_PRINT_BACKEND (dispatch->backend), result, user_data);
@@ -1612,8 +1596,7 @@ cups_dispatch_watch_finalize (GSource *source)
   GtkPrintCupsDispatchWatch *dispatch;
   GtkCupsResult *result;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s <source %p>\n", G_STRFUNC, source));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s <source %p>", G_STRFUNC, source);
 
   dispatch = (GtkPrintCupsDispatchWatch *) source;
 
@@ -1634,8 +1617,7 @@ cups_dispatch_watch_finalize (GSource *source)
         username = cupsUser ();
 
       key = g_strconcat (username, "@", hostname, NULL);
-      GTK_NOTE (PRINTING,
-                g_print ("CUPS backend: removing stored password for %s\n", key));
+      GTK_DEBUG (PRINTING, "CUPS backend: removing stored password for %s", key);
       g_hash_table_remove (dispatch->backend->auth, key);
       g_free (key);
 
@@ -1693,8 +1675,8 @@ cups_request_execute (GtkPrintBackendCups              *print_backend,
                                                          sizeof (GtkPrintCupsDispatchWatch));
   g_source_set_static_name (&dispatch->source, "GTK CUPS backend");
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s <source %p> - Executing cups request on server '%s' and resource 
'%s'\n", G_STRFUNC, dispatch, request->server, request->resource));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s <source %p> - Executing cups request on server '%s' and resource 
'%s'",
+                       G_STRFUNC, dispatch, request->server, request->resource);
 
   dispatch->request = request;
   dispatch->backend = g_object_ref (print_backend);
@@ -2438,8 +2420,7 @@ cups_printer_handle_attribute (GtkPrintBackendCups *cups_backend,
     }
   else
     {
-      GTK_NOTE (PRINTING,
-               g_print ("CUPS Backend: Attribute %s ignored\n", ippGetName (attr)));
+      GTK_DEBUG (PRINTING, "CUPS Backend: Attribute %s ignored", ippGetName (attr));
     }
 }
 
@@ -2482,16 +2463,14 @@ cups_create_printer (GtkPrintBackendCups *cups_backend,
     {
       cups_printer->printer_uri = g_strdup (info->member_uris);
       /* TODO if member_uris is a class we need to recursively find a printer */
-      GTK_NOTE (PRINTING,
-               g_print ("CUPS Backend: Found class with printer %s\n",
-                        info->member_uris));
+      GTK_DEBUG (PRINTING, "CUPS Backend: Found class with printer %s",
+                           info->member_uris);
     }
   else
     {
       cups_printer->printer_uri = g_strdup (info->printer_uri);
-      GTK_NOTE (PRINTING,
-               g_print ("CUPS Backend: Found printer %s\n",
-                        info->printer_uri));
+      GTK_DEBUG (PRINTING, "CUPS Backend: Found printer %s",
+                           info->printer_uri);
     }
 
   httpSeparateURI (HTTP_URI_CODING_ALL, cups_printer->printer_uri,
@@ -2504,8 +2483,8 @@ cups_create_printer (GtkPrintBackendCups *cups_backend,
   if (strncmp (resource, "/printers/", 10) == 0)
     {
       cups_printer->ppd_name = g_strdup (resource + 10);
-      GTK_NOTE (PRINTING,
-               g_print ("CUPS Backend: Setting ppd name '%s' for printer/class '%s'\n", 
cups_printer->ppd_name, info->printer_name));
+      GTK_DEBUG (PRINTING, "CUPS Backend: Setting ppd name '%s' for printer/class '%s'",
+                           cups_printer->ppd_name, info->printer_name);
     }
 
   gethostname (uri, sizeof (uri));
@@ -2741,8 +2720,7 @@ typedef struct {
 static void
 request_printer_info_data_free (RequestPrinterInfoData *data)
 {
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
   httpClose (data->http);
   g_object_unref (data->printer);
   g_free (data);
@@ -2761,16 +2739,14 @@ cups_request_printer_info_cb (GtkPrintBackendCups *cups_backend,
   gboolean                status_changed = FALSE;
   ipp_t                  *response;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
 
   if (gtk_cups_result_is_error (result))
     {
-      GTK_NOTE (PRINTING,
-                g_warning ("CUPS Backend: Error getting printer info: %s %d %d",
+      GTK_DEBUG (PRINTING, "CUPS Backend: Error getting printer info: %s %d %d",
                            gtk_cups_result_get_error_string (result),
                            gtk_cups_result_get_error_type (result),
-                           gtk_cups_result_get_error_code (result)));
+                           gtk_cups_result_get_error_code (result));
 
       goto done;
     }
@@ -2979,13 +2955,12 @@ cups_create_local_printer_cb (GtkPrintBackendCups *print_backend,
           printer_name = g_strdup (g_strrstr (ippGetString (attr, 0, NULL), "/") + 1);
         }
 
-      GTK_NOTE (PRINTING,
-                g_print ("CUPS Backend: Created local printer %s\n", printer_name));
+      GTK_DEBUG (PRINTING, "CUPS Backend: Created local printer %s", printer_name);
     }
   else
     {
-      GTK_NOTE (PRINTING,
-                g_print ("CUPS Backend: Creating of local printer failed: %d\n", ippGetStatusCode 
(response)));
+      GTK_DEBUG (PRINTING, "CUPS Backend: Creating of local printer failed: %d",
+                           ippGetStatusCode (response));
     }
 
   iter = g_list_find_custom (print_backend->temporary_queues_in_construction, printer_name, (GCompareFunc) 
g_strcmp0);
@@ -3015,8 +2990,7 @@ create_temporary_queue (GtkPrintBackendCups *backend,
   if (iter != NULL)
     return;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: Creating local printer %s\n", printer_name));
+  GTK_DEBUG (PRINTING, "CUPS Backend: Creating local printer %s", printer_name);
 
   backend->temporary_queues_in_construction = g_list_prepend (backend->temporary_queues_in_construction, 
g_strdup (printer_name));
 
@@ -3175,10 +3149,9 @@ avahi_connection_test_cb (GObject      *source_object,
     }
   else
     {
-      GTK_NOTE (PRINTING,
-                g_warning ("CUPS Backend: Can not connect to %s: %s\n",
+      GTK_DEBUG (PRINTING, "CUPS Backend: Can not connect to %s: %s",
                            data->address,
-                           error->message));
+                           error->message);
       g_error_free (error);
     }
 
@@ -3680,18 +3653,16 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
 
   list_has_changed = FALSE;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
 
   cups_backend->list_printers_pending = FALSE;
 
   if (gtk_cups_result_is_error (result))
     {
-      GTK_NOTE (PRINTING,
-                g_warning ("CUPS Backend: Error getting printer list: %s %d %d",
+      GTK_DEBUG (PRINTING, "CUPS Backend: Error getting printer list: %s %d %d",
                            gtk_cups_result_get_error_string (result),
                            gtk_cups_result_get_error_type (result),
-                           gtk_cups_result_get_error_code (result)));
+                           gtk_cups_result_get_error_code (result));
 
       if (gtk_cups_result_get_error_type (result) == GTK_CUPS_ERROR_AUTH &&
           gtk_cups_result_get_error_code (result) == 1)
@@ -3998,8 +3969,7 @@ typedef struct {
 static void
 get_ppd_data_free (GetPPDData *data)
 {
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
   httpClose (data->http);
   g_io_channel_unref (data->ppd_io);
   g_object_unref (data->printer);
@@ -4014,8 +3984,7 @@ cups_request_ppd_cb (GtkPrintBackendCups *print_backend,
   GtkPrinter *printer;
   struct stat data_info;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
 
   printer = GTK_PRINTER (data->printer);
   GTK_PRINTER_CUPS (printer)->reading_ppd = FALSE;
@@ -4111,8 +4080,7 @@ cups_request_ppd (GtkPrinter *printer)
 
   error = NULL;
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: %s\n", G_STRFUNC));
+  GTK_DEBUG (PRINTING, "CUPS Backend: %s", G_STRFUNC);
 
   if (cups_printer->remote && !cups_printer->avahi_browsed)
     {
@@ -4186,9 +4154,8 @@ cups_request_ppd (GtkPrinter *printer)
 
   if (error != NULL)
     {
-      GTK_NOTE (PRINTING,
-                g_warning ("CUPS Backend: Failed to create temp file, %s\n",
-                           error->message));
+      GTK_DEBUG (PRINTING, "CUPS Backend: Failed to create temp file, %s",
+                           error->message);
       g_error_free (error);
       httpClose (http);
       g_free (ppd_filename);
@@ -4220,9 +4187,8 @@ cups_request_ppd (GtkPrinter *printer)
                                     cups_printer->ipp_version_major,
                                     cups_printer->ipp_version_minor);
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS Backend: Requesting resource %s to be written to temp file %s\n", resource, 
ppd_filename));
-
+  GTK_DEBUG (PRINTING, "CUPS Backend: Requesting resource %s to be written to temp file %s",
+                       resource, ppd_filename);
 
   cups_printer->reading_ppd = TRUE;
   GTK_PRINT_BACKEND_CUPS (print_backend)->reading_ppds++;
@@ -4602,8 +4568,7 @@ ppd_text_to_utf8 (ppd_file_t *ppd_file,
 
   if (res == NULL)
     {
-      GTK_NOTE (PRINTING,
-                g_warning ("CUPS Backend: Unable to convert PPD text\n"));
+      GTK_DEBUG (PRINTING, "CUPS Backend: Unable to convert PPD text");
       res = g_strdup ("???");
     }
 
diff --git a/modules/printbackends/gtkprintbackendfile.c b/modules/printbackends/gtkprintbackendfile.c
index 94718820c4..0275492f65 100644
--- a/modules/printbackends/gtkprintbackendfile.c
+++ b/modules/printbackends/gtkprintbackendfile.c
@@ -36,6 +36,7 @@
 
 #include "gtk/gtk.h"
 #include "gtk/gtkprinterprivate.h"
+#include "gtk/gtkprivate.h"
 
 #include "gtkprintbackendfile.h"
 
@@ -282,8 +283,7 @@ _cairo_write (void                *closure,
 
   error = NULL;
 
-  GTK_NOTE (PRINTING,
-            g_print ("FILE Backend: Writing %u byte chunk to temp file\n", length));
+  GTK_DEBUG (PRINTING, "FILE Backend: Writing %u byte chunk to temp file", length);
 
   while (length > 0) 
     {
@@ -295,8 +295,7 @@ _cairo_write (void                *closure,
         {
           if (error != NULL)
             {
-              GTK_NOTE (PRINTING,
-                        g_print ("FILE Backend: Error writing to temp file, %s\n", error->message));
+              GTK_DEBUG (PRINTING, "FILE Backend: Error writing to temp file, %s", error->message);
 
               g_error_free (error);
             }
@@ -304,8 +303,7 @@ _cairo_write (void                *closure,
          return CAIRO_STATUS_WRITE_ERROR;
        }    
 
-      GTK_NOTE (PRINTING,
-                g_print ("FILE Backend: Wrote %zd bytes to temp file\n", written));
+      GTK_DEBUG (PRINTING, "FILE Backend: Wrote %zd bytes to temp file", written);
       
       data += written;
       length -= written;
@@ -436,8 +434,7 @@ file_write (GIOChannel   *source,
 
       if (error != NULL)
         {
-          GTK_NOTE (PRINTING,
-                    g_print ("FILE Backend: %s\n", error->message));
+          GTK_DEBUG (PRINTING, "FILE Backend: %s", error->message);
 
           g_error_free (error);
         }
@@ -445,8 +442,7 @@ file_write (GIOChannel   *source,
       return FALSE;
     }
 
-  GTK_NOTE (PRINTING,
-            g_print ("FILE Backend: Writing %"G_GSIZE_FORMAT" byte chunk to target file\n", bytes_read));
+  GTK_DEBUG (PRINTING, "FILE Backend: Writing %"G_GSIZE_FORMAT" byte chunk to target file", bytes_read);
 
   return TRUE;
 }
diff --git a/modules/printbackends/gtkprintbackendlpr.c b/modules/printbackends/gtkprintbackendlpr.c
index 44c40a1626..f3029e64ae 100644
--- a/modules/printbackends/gtkprintbackendlpr.c
+++ b/modules/printbackends/gtkprintbackendlpr.c
@@ -155,8 +155,7 @@ _cairo_write (void                *closure,
 
   error = NULL;
 
-  GTK_NOTE (PRINTING,
-            g_print ("LPR Backend: Writing %i byte chunk to temp file\n", length));
+  GTK_DEBUG (PRINTING, "LPR Backend: Writing %i byte chunk to temp file", length);
 
   while (length > 0) 
     {
@@ -164,15 +163,13 @@ _cairo_write (void                *closure,
 
       if (error != NULL)
        {
-         GTK_NOTE (PRINTING,
-                     g_print ("LPR Backend: Error writing to temp file, %s\n", error->message));
+         GTK_DEBUG (PRINTING, "LPR Backend: Error writing to temp file, %s", error->message);
 
           g_error_free (error);
          return CAIRO_STATUS_WRITE_ERROR;
        }    
 
-      GTK_NOTE (PRINTING,
-                g_print ("LPR Backend: Wrote %" G_GSIZE_FORMAT " bytes to temp file\n", written));
+      GTK_DEBUG (PRINTING, "LPR Backend: Wrote %" G_GSIZE_FORMAT " bytes to temp file", written);
 
       data += written;
       length -= written;
@@ -274,8 +271,7 @@ lpr_write (GIOChannel   *source,
 
       if (error != NULL)
         {
-          GTK_NOTE (PRINTING,
-                    g_print ("LPR Backend: %s\n", error->message));
+          GTK_DEBUG (PRINTING, "LPR Backend: %s", error->message);
 
           g_error_free (error);
         } 
@@ -283,9 +279,7 @@ lpr_write (GIOChannel   *source,
       return FALSE;
     }
 
-  GTK_NOTE (PRINTING,
-            g_print ("LPR Backend: Writing %" G_GSIZE_FORMAT " byte chunk to lpr pipe\n", bytes_read));
-
+  GTK_DEBUG (PRINTING, "LPR Backend: Writing %" G_GSIZE_FORMAT " byte chunk to lpr pipe", bytes_read);
 
   return TRUE;
 }


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