[glade] Added debug flags and --enable-debug configure option.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] Added debug flags and --enable-debug configure option.
- Date: Sun, 28 Apr 2013 11:45:06 +0000 (UTC)
commit b1d730a945aeb0cf34a86e048ca2a4f0b76b5c58
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Sun Apr 28 20:24:02 2013 +0900
Added debug flags and --enable-debug configure option.
Also fixed warnings for versioning errors and such, GladeVerifyFlags was
not properly defined.
configure.ac | 19 +++++++++++++++++++
gladeui/Makefile.am | 2 ++
gladeui/glade-app.c | 2 ++
gladeui/glade-debug.c | 33 +++++++++++++++++++++++++++++++++
gladeui/glade-debug.h | 23 ++++++++++++++++++++++-
gladeui/glade-project.c | 29 +++++++++++++++++++++++++++++
gladeui/glade-project.h | 6 +++---
gladeui/glade.h | 1 +
plugins/gtk+/Makefile.am | 1 +
9 files changed, 112 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3e23183..4636574 100644
--- a/configure.ac
+++ b/configure.ac
@@ -90,6 +90,24 @@ if test "x$GCC" = "xyes"; then
fi
AC_SUBST(PLUGINS_WARN_CFLAGS)
+
+dnl ================================================================
+dnl Collect some arguments.
+dnl ================================================================
+AC_ARG_ENABLE(debug,
+ [AC_HELP_STRING([--enable-debug],
+ [enable debug build [default=no]])],,
+ [enable_debug="no"])
+
+AM_CONDITIONAL([GLADE_DEBUG],[test "x$enable_debug" = "xyes"])
+
+if test "x$enable_debug" = "xyes"; then
+ GLADE_DEBUG_FLAGS=-DGLADE_ENABLE_DEBUG
+else
+ GLADE_DEBUG_FLAGS=
+fi
+AC_SUBST(GLADE_DEBUG_FLAGS)
+
dnl ================================================================
dnl Gettext stuff.
dnl ================================================================
@@ -330,6 +348,7 @@ Configuration:
Source code location: ${srcdir}
Compiler: ${CC}
+ Debug Enabled: ${enable_debug}
GTK+ UNIX Print Widgets: ${have_unix_print}
PYTHON Widgets support: ${have_python}
Gladeui Catalog: ${enable_gladeui}
diff --git a/gladeui/Makefile.am b/gladeui/Makefile.am
index c7b31f5..88b143b 100644
--- a/gladeui/Makefile.am
+++ b/gladeui/Makefile.am
@@ -11,6 +11,7 @@ glade_previewer_CPPFLAGS = \
$(GTK_CFLAGS) \
$(GTK_MAC_CFLAGS) \
$(WARN_CFLAGS) \
+ $(GLADE_DEBUG_FLAGS) \
$(AM_CPPFLAGS)
glade_previewer_CFLAGS = \
@@ -130,6 +131,7 @@ libgladeui_2_la_CPPFLAGS = \
$(GTK_MAC_BUNDLE_FLAG) \
$(GTK_MAC_CFLAGS) \
$(WARN_CFLAGS) \
+ $(GLADE_DEBUG_FLAGS) \
$(AM_CPPFLAGS)
libgladeui_2_la_CFLAGS = \
diff --git a/gladeui/glade-app.c b/gladeui/glade-app.c
index b263527..2f9106e 100644
--- a/gladeui/glade-app.c
+++ b/gladeui/glade-app.c
@@ -208,6 +208,8 @@ glade_init_check (void)
if (check_initialised)
return;
+ glade_init_debug_flags ();
+
/* Make sure path accessors work on osx */
build_package_paths ();
diff --git a/gladeui/glade-debug.c b/gladeui/glade-debug.c
index 4fa85a1..b836356 100644
--- a/gladeui/glade-debug.c
+++ b/gladeui/glade-debug.c
@@ -69,3 +69,36 @@ glade_setup_log_handlers ()
glade_set_log_handler ("Gtk");
glade_set_log_handler ("Gdk");
}
+
+static GladeDebugFlag glade_debug_flags = 0;
+
+
+static const GDebugKey glade_debug_keys[] = {
+ { "verify", GLADE_DEBUG_VERIFY }
+};
+
+guint
+glade_get_debug_flags (void)
+{
+ return glade_debug_flags;
+}
+
+void
+glade_init_debug_flags (void)
+{
+ static gboolean initialized = FALSE;
+
+ if (G_UNLIKELY (!initialized))
+ {
+ const gchar *env_string;
+
+ initialized = TRUE;
+
+ env_string = g_getenv ("GLADE_DEBUG");
+ if (env_string != NULL)
+ glade_debug_flags =
+ g_parse_debug_string (env_string,
+ glade_debug_keys,
+ G_N_ELEMENTS (glade_debug_keys));
+ }
+}
diff --git a/gladeui/glade-debug.h b/gladeui/glade-debug.h
index 4fc00df..fab2343 100644
--- a/gladeui/glade-debug.h
+++ b/gladeui/glade-debug.h
@@ -3,7 +3,28 @@
G_BEGIN_DECLS
-void glade_setup_log_handlers (void);
+typedef enum {
+ GLADE_DEBUG_VERIFY = (1 << 0)
+} GladeDebugFlag;
+
+#ifdef GLADE_ENABLE_DEBUG
+
+#define GLADE_NOTE(type,action) \
+ G_STMT_START { \
+ if (glade_get_debug_flags () & GLADE_DEBUG_##type) \
+ { action; }; \
+ } G_STMT_END
+
+#else /* !GLADE_ENABLE_DEBUG */
+
+#define GLADE_NOTE(type, action)
+
+#endif /* GLADE_ENABLE_DEBUG */
+
+void glade_init_debug_flags (void);
+guint glade_get_debug_flags (void);
+
+void glade_setup_log_handlers (void);
G_END_DECLS
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index 1bc014e..08d1e83 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -2757,6 +2757,11 @@ glade_project_verify_property_internal (GladeProject *project,
if ((flags & GLADE_VERIFY_VERSIONS) != 0 &&
!GPC_VERSION_CHECK (pclass, target_major, target_minor))
{
+ GLADE_NOTE (VERIFY, g_print ("VERIFY: Property '%s' of adaptor %s not available in version %d.%d\n",
+ glade_property_class_id (pclass),
+ glade_widget_adaptor_get_name (adaptor),
+ target_major, target_minor));
+
if (forwidget)
{
tooltip = g_strdup_printf (PROP_VERSION_CONFLICT_MSGFMT,
@@ -2783,6 +2788,10 @@ glade_project_verify_property_internal (GladeProject *project,
else if ((flags & GLADE_VERIFY_DEPRECATIONS) != 0 &&
glade_property_class_deprecated (pclass))
{
+ GLADE_NOTE (VERIFY, g_print ("VERIFY: Property '%s' of adaptor %s is deprecated\n",
+ glade_property_class_id (pclass),
+ glade_widget_adaptor_get_name (adaptor)));
+
if (forwidget)
glade_property_set_support_warning (property, FALSE, PROP_DEPRECATED_MSG);
else
@@ -2858,6 +2867,11 @@ glade_project_verify_signal_internal (GladeWidget *widget,
if ((flags & GLADE_VERIFY_VERSIONS) != 0 &&
!GSC_VERSION_CHECK (signal_class, target_major, target_minor))
{
+ GLADE_NOTE (VERIFY, g_print ("VERIFY: Signal '%s' of adaptor %s not avalable in version %d.%d\n",
+ glade_signal_get_name (signal),
+ glade_widget_adaptor_get_name (adaptor),
+ target_major, target_minor));
+
if (forwidget)
{
gchar *warning;
@@ -2883,6 +2897,10 @@ glade_project_verify_signal_internal (GladeWidget *widget,
else if ((flags & GLADE_VERIFY_DEPRECATIONS) != 0 &&
glade_signal_class_deprecated (signal_class))
{
+ GLADE_NOTE (VERIFY, g_print ("VERIFY: Signal '%s' of adaptor %s is deprecated\n",
+ glade_signal_get_name (signal),
+ glade_widget_adaptor_get_name (adaptor)));
+
if (forwidget)
glade_signal_set_support_warning (signal, SIGNAL_DEPRECATED_MSG);
else
@@ -3024,6 +3042,8 @@ glade_project_verify (GladeProject *project, gboolean saving, GladeVerifyFlags f
GString *string = g_string_new (NULL);
GList *list;
gboolean ret = TRUE;
+
+ GLADE_NOTE (VERIFY, g_print ("VERIFY: glade_project_verify() start\n"));
for (list = project->priv->objects; list; list = list->next)
{
@@ -3062,6 +3082,8 @@ glade_project_verify (GladeProject *project, gboolean saving, GladeVerifyFlags f
g_string_free (string, TRUE);
+ GLADE_NOTE (VERIFY, g_print ("VERIFY: glade_project_verify() end\n"));
+
return ret;
}
@@ -3105,6 +3127,10 @@ glade_project_verify_adaptor (GladeProject *project,
if ((flags & GLADE_VERIFY_VERSIONS) != 0 &&
!GWA_VERSION_CHECK (adaptor_iter, target_major, target_minor))
{
+ GLADE_NOTE (VERIFY, g_print ("VERIFY: Adaptor '%s' not available in version %d.%d\n",
+ glade_widget_adaptor_get_name (adaptor_iter),
+ target_major, target_minor));
+
if (forwidget)
g_string_append_printf (string,
WIDGET_VERSION_CONFLICT_MSGFMT,
@@ -3127,6 +3153,9 @@ glade_project_verify_adaptor (GladeProject *project,
if ((flags & GLADE_VERIFY_DEPRECATIONS) != 0 &&
GWA_DEPRECATED (adaptor_iter))
{
+ GLADE_NOTE (VERIFY, g_print ("VERIFY: Adaptor '%s' is deprecated\n",
+ glade_widget_adaptor_get_name (adaptor_iter)));
+
if (forwidget)
{
if (string->len)
diff --git a/gladeui/glade-project.h b/gladeui/glade-project.h
index 1f37291..8a8f52d 100644
--- a/gladeui/glade-project.h
+++ b/gladeui/glade-project.h
@@ -77,9 +77,9 @@ typedef enum
*
*/
typedef enum {
- GLADE_VERIFY_VERSIONS,
- GLADE_VERIFY_DEPRECATIONS,
- GLADE_VERIFY_UNRECOGNIZED
+ GLADE_VERIFY_VERSIONS = (1 << 0),
+ GLADE_VERIFY_DEPRECATIONS = (1 << 1),
+ GLADE_VERIFY_UNRECOGNIZED = (1 << 2)
} GladeVerifyFlags;
struct _GladeProject
diff --git a/gladeui/glade.h b/gladeui/glade.h
index 88f6dc6..bcd1e90 100644
--- a/gladeui/glade.h
+++ b/gladeui/glade.h
@@ -48,5 +48,6 @@
#include <gladeui/glade-displayable-values.h>
#include <gladeui/glade-cell-renderer-icon.h>
#include <gladeui/glade-cursor.h>
+#include <gladeui/glade-debug.h>
#endif /* __GLADE_H__ */
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 4e807c3..8358a1c 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -16,6 +16,7 @@ libgladegtk_la_CPPFLAGS = \
-DG_LOG_DOMAIN=\"GladeUI-GTK\" \
$(GTK_CFLAGS) \
$(PLUGINS_WARN_CFLAGS) \
+ $(GLADE_DEBUG_FLAGS) \
$(AM_CPPFLAGS)
libgladegtk_la_CFLAGS = $(AM_CFLAGS)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]