Commit b1d730a9 authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

Added debug flags and --enable-debug configure option.

Also fixed warnings for versioning errors and such, GladeVerifyFlags was
not properly defined.
parent e3d3b8ab
......@@ -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}
......
......@@ -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 = \
......
......@@ -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 ();
......
......@@ -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));
}
}
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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__ */
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment