New debug macros

master
Yevgen Muntyan 2007-08-20 22:15:58 -05:00
parent c0967bfcfd
commit e9e1d0107a
36 changed files with 240 additions and 141 deletions

View File

@ -17,7 +17,7 @@ AC_DEFUN([_MOO_AC_CHECK_COMPILER_OPTIONS],[
#
AC_DEFUN_ONCE([MOO_AC_DEBUG],[
MOO_DEBUG="no"
MOO_DEBUG_ENABLED="no"
MOO_DEBUG_CFLAGS=
AC_ARG_ENABLE(tests,
@ -35,14 +35,14 @@ AM_CONDITIONAL(MOO_ENABLE_TESTS, test x$MOO_ENABLE_TESTS = "xyes")
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug],[enable debug options (default = NO)]),[
if test "x$enable_debug" = "xno"; then
MOO_DEBUG="no"
MOO_DEBUG_ENABLED="no"
else
MOO_DEBUG="yes"
MOO_DEBUG_ENABLED="yes"
fi
],[
MOO_DEBUG="no"
MOO_DEBUG_ENABLED="no"
])
AM_CONDITIONAL(MOO_DEBUG, test x$MOO_DEBUG = "xyes")
AM_CONDITIONAL(MOO_DEBUG_ENABLED, test x$MOO_DEBUG_ENABLED = "xyes")
_moo_all_warnings="no"
AC_ARG_ENABLE(all-warnings,
@ -96,10 +96,10 @@ if $_MOO_GCC; then
fi
fi
if test "x$MOO_DEBUG" = "xyes"; then
if test "x$MOO_DEBUG_ENABLED" = "xyes"; then
_moo_debug_flags="-DG_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED dnl
-DGDK_DISABLE_DEPRECATED -DENABLE_DEBUG -DENABLE_PROFILE dnl
-DG_ENABLE_DEBUG -DG_ENABLE_PROFILE -DMOO_DEBUG=1"
-DG_ENABLE_DEBUG -DG_ENABLE_PROFILE -DMOO_DEBUG_ENABLED=1"
else
_moo_debug_flags="-DNDEBUG=1 -DG_DISABLE_CAST_CHECKS -DG_DISABLE_ASSERT"
fi

View File

@ -56,6 +56,7 @@
<exe>medit/medit</exe>
<vars>
<var name="LANGUAGE">ru</var>
<var name="MOO_DEBUG">misc,input</var>
</vars>
</run>
</medit-project>

View File

@ -94,9 +94,9 @@ endif
if MOO_ENABLE_TESTS
export_flags = -export-symbols-regex ".*"
else
if MOO_DEBUG # && !MOO_ENABLE_TESTS
if MOO_DEBUG_ENABLED # && !MOO_ENABLE_TESTS
export_flags = -export-symbols-regex ".*"
else # !MOO_DEBUG && !MOO_ENABLE_TESTS
else # !MOO_DEBUG_ENABLED && !MOO_ENABLE_TESTS
export_flags = -export-symbols-regex "^(moo_).*"
endif
endif

View File

@ -33,6 +33,7 @@
#include "mooutils/moostock.h"
#include "mooutils/mooutils-fs.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include "mooutils/mooi18n.h"
#include "mooutils/xdgmime/xdgmime.h"
#include <glib/gmappedfile.h>

View File

@ -50,7 +50,9 @@
#include "mooapp/mooapp-private.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-thread.h"
#include "mooutils/mooutils-debug.h"
MOO_DEBUG_INIT(input, TRUE)
#define MAX_BUFFER_SIZE 4096
@ -138,7 +140,7 @@ commit (GString **buffer)
if (!(*buffer)->len)
{
_moo_message ("%s: got empty command", G_STRLOC);
moo_dmsg ("%s: got empty command", G_STRLOC);
return;
}
@ -244,11 +246,11 @@ try_send (const char *pipe_dir_name,
g_return_val_if_fail (name && name[0], FALSE);
filename = get_pipe_path (pipe_dir_name, name);
_moo_message ("try_send: sending data to `%s'", filename);
moo_dmsg ("try_send: sending data to `%s'", filename);
if (!g_file_test (filename, G_FILE_TEST_EXISTS))
{
_moo_message ("try_send: file %s doesn't exist", filename);
moo_dmsg ("try_send: file %s doesn't exist", filename);
goto out;
}
@ -273,7 +275,7 @@ _moo_app_input_send_msg (const char *appname,
g_return_val_if_fail (appname != NULL, FALSE);
g_return_val_if_fail (data != NULL, FALSE);
_moo_message ("_moo_app_input_send_msg: sending data to %s", name ? name : "NONE");
moo_dmsg ("_moo_app_input_send_msg: sending data to %s", name ? name : "NONE");
pipe_dir_name = get_pipe_dir (appname);
g_return_val_if_fail (pipe_dir_name != NULL, FALSE);
@ -445,8 +447,8 @@ read_input (G_GNUC_UNUSED GIOChannel *source,
if (condition & (G_IO_ERR | G_IO_HUP))
{
_moo_message ("%s: %s", G_STRLOC,
(condition & G_IO_ERR) ? "G_IO_ERR" : "G_IO_HUP");
moo_dmsg ("%s: %s", G_STRLOC,
(condition & G_IO_ERR) ? "G_IO_ERR" : "G_IO_HUP");
goto remove;
}
@ -466,9 +468,9 @@ read_input (G_GNUC_UNUSED GIOChannel *source,
if (n <= 0)
{
if (n < 0)
_moo_message ("%s: %s", G_STRLOC, g_strerror (errno));
moo_dmsg ("%s: %s", G_STRLOC, g_strerror (errno));
else
_moo_message ("%s: EOF", G_STRLOC);
moo_dmsg ("%s: EOF", G_STRLOC);
goto remove;
}
@ -880,9 +882,8 @@ input_channel_start (InputChannel *ch,
return FALSE;
}
if (0)
_moo_message ("%s: opened input pipe %s with fd %d",
G_STRLOC, ch->path, ch->fd);
moo_dmsg ("%s: opened input pipe %s with fd %d",
G_STRLOC, ch->path, ch->fd);
if (!input_channel_start_io (ch->fd, (GIOFunc) read_input, ch,
&ch->io, &ch->io_watch))
@ -945,11 +946,11 @@ do_send (const char *filename,
gboolean result = FALSE;
int fd;
_moo_message ("do_send: sending data to `%s'", filename);
moo_dmsg ("do_send: sending data to `%s'", filename);
if (!g_file_test (filename, G_FILE_TEST_EXISTS))
{
_moo_message ("do_send: file `%s' doesn't exist", filename);
moo_dmsg ("do_send: file `%s' doesn't exist", filename);
return FALSE;
}
@ -957,7 +958,7 @@ do_send (const char *filename,
if (fd == -1)
{
_moo_message ("do_send: could not open `%s': %s", filename, g_strerror (errno));
moo_dmsg ("do_send: could not open `%s': %s", filename, g_strerror (errno));
return FALSE;
}
@ -965,7 +966,7 @@ do_send (const char *filename,
close (fd);
if (result)
_moo_message ("do_send: successfully sent stuff to `%s'", filename);
moo_dmsg ("do_send: successfully sent stuff to `%s'", filename);
return result;
}

View File

@ -22,6 +22,7 @@
#include "mooutils/mooglade.h"
#include "mooutils/mooutils-fs.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include "mooutils/moospawn.h"
#include "mooutils/mootype-macros.h"
#include <gtk/gtk.h>

View File

@ -23,9 +23,8 @@
#include "mooedit/mooeditwindow.h"
#include "mooedit/moooutputfilterregex.h"
#include "mooedit/mooedit-enums.h"
#include "mooutils/mooutils-misc.h"
#include <gtk/gtkwindow.h>
#include <gtk/gtktextview.h>
#include "mooutils/mooutils-debug.h"
#include <gtk/gtk.h>
#include <string.h>

View File

@ -16,9 +16,11 @@
#include "mooedit/mooeditprefs.h"
#include "mooutils/mooprefs.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include <glib/gregex.h>
#include <string.h>
MOO_DEBUG_INIT(filters, FALSE)
#define ELEMENT_FILTER_SETTINGS MOO_EDIT_PREFS_PREFIX "/filter-settings"
#define ELEMENT_SETTING "setting"
@ -205,10 +207,9 @@ filter_setting_match (FilterSetting *setting,
{
if (g_regex_match (setting->regex, filename, 0, NULL))
{
if (0)
_moo_message ("file '%s' matched pattern '%s': config '%s'",
filename, g_regex_get_pattern (setting->regex),
setting->config);
moo_dmsg ("file '%s' matched pattern '%s': config '%s'",
filename, g_regex_get_pattern (setting->regex),
setting->config);
return setting->config;
}

View File

@ -16,7 +16,7 @@
#include "mooutils/moomarshals.h"
#ifdef MOO_DEBUG
#ifdef MOO_DEBUG_ENABLED
#define WANT_CHECKS 1
#else
#define WANT_CHECKS 0

View File

@ -14,7 +14,7 @@
#include "mooedit/moooutputfilter.h"
#include "mooedit/mooeditor.h"
#include "mooutils/moomarshals.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include <string.h>

View File

@ -17,6 +17,7 @@
#include "mooedit/mooplugin-loader.h"
#include "mooedit/mooplugin.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include <string.h>
#include <stdlib.h>
#include <gmodule.h>

View File

@ -23,6 +23,7 @@
#include "mooutils/mooprefsdialog.h"
#include "mooutils/moostock.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include <string.h>
#include <gmodule.h>
#include <gobject/gvaluecollector.h>

View File

@ -21,8 +21,11 @@
#include "mooedit/mooprintpreview-glade.h"
#include "mooutils/mooutils-gobject.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include <cairo-pdf.h>
MOO_DEBUG_INIT(printing, TRUE)
#ifdef __WIN32__
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -367,9 +370,9 @@ moo_print_preview_set_zoom (MooPrintPreview *preview,
gtk_widget_queue_draw (preview->priv->darea);
if (zoom_to_fit)
_moo_message ("zoom_to_fit");
moo_dmsg ("zoom_to_fit");
else
_moo_message ("zoom: %s", zoom_factor_names[zoom]);
moo_dmsg ("zoom: %s", zoom_factor_names[zoom]);
}
static void
@ -393,9 +396,9 @@ moo_print_preview_zoom_in (MooPrintPreview *preview,
g_return_if_fail (change == -1 || change == 1);
if (change < 0)
_moo_message ("zoom out");
moo_dmsg ("zoom out");
else
_moo_message ("zoom in");
moo_dmsg ("zoom in");
}

View File

@ -28,7 +28,7 @@ static void bt_data_free (BTData *data,
#define NODE_IS_ROOT(node__) (!(node__)->parent)
#if 0 && defined(MOO_DEBUG)
#if 0 && defined(MOO_DEBUG_ENABLED)
#define WANT_CHECK_INTEGRITY
static void CHECK_INTEGRITY (BTree *tree, gboolean check_capacity);
#else

View File

@ -23,6 +23,7 @@
#include "mooutils/moodialogs.h"
#include "mooutils/mooi18n.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include <sys/types.h>
#include <time.h>
#include <errno.h>
@ -33,6 +34,8 @@
#include <cairo-win32.h>
#endif
MOO_DEBUG_INIT(printing, TRUE)
#define SEPARATOR_POINTS 1.
#define PREFS_FONT MOO_EDIT_PREFS_PREFIX "/print/font"
@ -343,7 +346,7 @@ moo_print_operation_finalize (GObject *object)
g_free (op->priv->tm);
g_free (op->priv);
_moo_message ("moo_print_operation_finalize");
moo_dmsg ("moo_print_operation_finalize");
G_OBJECT_CLASS(_moo_print_operation_parent_class)->finalize (object);
}
@ -454,7 +457,7 @@ _moo_print_operation_init (MooPrintOperation *op)
{
op->priv = g_new0 (MooPrintOperationPrivate, 1);
_moo_message ("_moo_print_operation_init");
moo_dmsg ("_moo_print_operation_init");
gtk_print_operation_set_print_settings (GTK_PRINT_OPERATION (op),
global_print_settings);
@ -536,7 +539,7 @@ _moo_edit_page_setup (GtkWidget *parent)
g_return_if_fail (!parent || GTK_IS_WIDGET (parent));
_moo_message ("_moo_edit_page_setup");
moo_dmsg ("_moo_edit_page_setup");
if (parent)
parent = gtk_widget_get_toplevel (parent);
@ -694,10 +697,10 @@ moo_print_operation_calc_page_size (MooPrintOperation *op,
page->text_x = page->x;
page->text_width = page->width;
_moo_message ("page size: %f, %f - %f in, %f in",
page->width, page->height,
page->width / gtk_print_context_get_dpi_x (context),
page->height / gtk_print_context_get_dpi_y (context));
moo_dmsg ("page size: %f, %f - %f in, %f in",
page->width, page->height,
page->width / gtk_print_context_get_dpi_x (context),
page->height / gtk_print_context_get_dpi_y (context));
header_footer_get_size (settings->header, op, context,
default_font, MOO_PRINT_HEADER);
@ -726,10 +729,10 @@ moo_print_operation_calc_page_size (MooPrintOperation *op,
page->height = gtk_print_context_get_height (context);
}
_moo_message ("printable area size: %f, %f - %f in, %f in",
page->width, page->height,
page->width / gtk_print_context_get_dpi_x (context),
page->height / gtk_print_context_get_dpi_y (context));
moo_dmsg ("printable area size: %f, %f - %f in, %f in",
page->width, page->height,
page->width / gtk_print_context_get_dpi_x (context),
page->height / gtk_print_context_get_dpi_y (context));
if (GET_OPTION (op, MOO_PRINT_LINE_NUMBERS))
create_ln_layout (op, context, default_font);
@ -768,8 +771,8 @@ moo_print_operation_paginate (MooPrintOperation *op)
int line_no;
int offset;
_moo_message ("moo_print_operation_paginate");
_moo_message ("page height: %f", op->priv->page.height);
moo_dmsg ("moo_print_operation_paginate");
moo_dmsg ("page height: %f", op->priv->page.height);
if (op->priv->pages)
g_array_free (op->priv->pages, TRUE);
@ -870,7 +873,7 @@ moo_print_operation_paginate (MooPrintOperation *op)
gtk_print_operation_set_n_pages (GTK_PRINT_OPERATION (op), op->priv->pages->len);
_moo_message ("moo_print_operation_paginate done");
moo_dmsg ("moo_print_operation_paginate done");
}
@ -923,7 +926,7 @@ moo_print_operation_begin_print (GtkPrintOperation *operation,
g_return_if_fail (op->priv->first_line < gtk_text_buffer_get_line_count (op->priv->buffer));
g_return_if_fail (op->priv->last_line < gtk_text_buffer_get_line_count (op->priv->buffer));
_moo_message ("moo_print_operation_begin_print");
moo_dmsg ("moo_print_operation_begin_print");
moo_print_operation_load_prefs (op);
settings = op->priv->settings;
@ -993,8 +996,8 @@ moo_print_operation_begin_print (GtkPrintOperation *operation,
moo_print_operation_paginate (op);
_moo_message ("begin_print: %d pages in %f s", op->priv->pages->len,
g_timer_elapsed (timer, NULL));
moo_dmsg ("begin_print: %d pages in %f s", op->priv->pages->len,
g_timer_elapsed (timer, NULL));
g_timer_destroy (timer);
if (!op->priv->tm)
@ -1021,7 +1024,7 @@ moo_print_operation_begin_print (GtkPrintOperation *operation,
if (op->priv->preview)
_moo_print_preview_start (op->priv->preview);
_moo_message ("moo_print_operation_begin_print done");
moo_dmsg ("moo_print_operation_begin_print done");
}
@ -1187,7 +1190,7 @@ fill_layout (MooPrintOperation *op,
segm_start = *start;
start_index = gtk_text_iter_get_line_index (start);
#if 0
_moo_message ("line %d, start at %d\n", gtk_text_iter_get_line (start), start_index);
moo_dmsg ("line %d, start at %d\n", gtk_text_iter_get_line (start), start_index);
#endif
while (gtk_text_iter_compare (&segm_start, end) < 0)
@ -1358,7 +1361,7 @@ print_page (MooPrintOperation *op,
double offset;
int line_no;
_moo_message ("print_page %d", page);
moo_dmsg ("print_page %d", page);
cairo_set_source_rgb (cr, 0., 0., 0.);
@ -1417,7 +1420,7 @@ print_page (MooPrintOperation *op,
line_no += 1;
}
_moo_message ("print_page done");
moo_dmsg ("print_page done");
}
@ -1468,7 +1471,7 @@ moo_print_operation_draw_page (GtkPrintOperation *operation,
}
#endif
#if 0 && defined(MOO_DEBUG) && !defined(__WIN32__)
#if 0 && defined(MOO_DEBUG_ENABLED) && !defined(__WIN32__)
cairo_save (cr);
cairo_set_line_width (cr, 1.);
cairo_set_source_rgb (cr, 1., 0., 0.);
@ -1495,7 +1498,7 @@ moo_print_operation_draw_page (GtkPrintOperation *operation,
pango_cairo_update_layout (cr, op->priv->settings->footer->layout);
print_page (op, &start, &end, page, cr);
_moo_message ("page %d: %f s", page, g_timer_elapsed (timer, NULL));
moo_dmsg ("page %d: %f s", page, g_timer_elapsed (timer, NULL));
g_timer_destroy (timer);
}
@ -1508,7 +1511,7 @@ moo_print_operation_end_print (GtkPrintOperation *operation,
g_return_if_fail (op->priv->buffer != NULL);
_moo_message ("moo_print_operation_end_print");
moo_dmsg ("moo_print_operation_end_print");
if (MOO_IS_EDIT (op->priv->doc))
_moo_edit_set_state (MOO_EDIT (op->priv->doc),
@ -1987,13 +1990,13 @@ moo_print_operation_preview (GtkPrintOperation *op,
{
GtkWidget *dialog;
_moo_message ("moo_print_operation_preview");
moo_dmsg ("moo_print_operation_preview");
dialog = _moo_print_preview_new (MOO_PRINT_OPERATION (op), preview, context);
gtk_widget_show (dialog);
g_signal_connect_swapped (dialog, "response", G_CALLBACK (preview_response), op);
_moo_message ("moo_print_operation_preview done");
moo_dmsg ("moo_print_operation_preview done");
return TRUE;
}

View File

@ -19,6 +19,7 @@
#include "mooedit/mooeditaction-factory.h"
#include "mooedit/mookeyfile.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include "mooutils/mooaccel.h"
#include "mooutils/mooi18n.h"
#include "mooutils/mooaction-private.h"

View File

@ -25,6 +25,7 @@
#include "moofileview/moofileicons.h"
#include "mooutils/mooutils-fs.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include "mooutils/moocompat.h"
#include "mooutils/moomarshals.h"
#include "mooutils/xdgmime/xdgmime.h"
@ -81,8 +82,7 @@ _moo_file_find_mime_type (MooFile *file,
if (!file->mime_type || !file->mime_type[0])
{
/* this should not happen */
if (1)
_moo_message ("%s: oops, %s", G_STRLOC, file->display_name);
_moo_message ("%s: oops, %s", G_STRLOC, file->display_name);
file->mime_type = MIME_TYPE_UNKNOWN;
}

View File

@ -21,6 +21,7 @@
#include "mooutils/moomarshals.h"
#include "mooutils/mooutils-gobject.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>

View File

@ -18,14 +18,16 @@
#include "moofileview/moofileicons.h"
#include "moofileview/symlink.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include "mooutils/moostock.h"
#include "mooutils/xdgmime/xdgmime.h"
#include <gtk/gtk.h>
#include <string.h>
#define DEBUG_MESSAGES 0
#define MOO_ICON_EMBLEM_LEN 2
MOO_DEBUG_INIT(icons, FALSE)
typedef struct {
GdkPixbuf **special_icons[MOO_ICON_INVALID];
GHashTable *mime_icons;
@ -409,8 +411,7 @@ get_named_icon (GtkIconTheme *icon_theme,
if (pixbuf && (gdk_pixbuf_get_width (pixbuf) < 5 ||
gdk_pixbuf_get_height (pixbuf) < 5))
{
if (DEBUG_MESSAGES)
_moo_message ("%s: got zero size icon '%s'", G_STRLOC, icon_name);
moo_dmsg ("%s: got zero size icon '%s'", G_STRLOC, icon_name);
g_object_unref (pixbuf);
pixbuf = NULL;
}
@ -446,8 +447,8 @@ create_named_icon (GtkIconTheme *icon_theme,
{
pixbuf = get_named_icon (icon_theme, name, pixel_size);
if (!pixbuf && DEBUG_MESSAGES)
_moo_message ("could not load '%s' icon", name);
if (!pixbuf)
moo_dmsg ("could not load '%s' icon", name);
}
va_end (args);
@ -455,8 +456,8 @@ create_named_icon (GtkIconTheme *icon_theme,
if (!pixbuf && fallback_stock)
{
pixbuf = gtk_widget_render_icon (widget, fallback_stock, size, NULL);
if (!pixbuf && DEBUG_MESSAGES)
_moo_message ("could not load stock '%s' icon", fallback_stock);
if (!pixbuf)
moo_dmsg ("could not load stock '%s' icon", fallback_stock);
}
if (!pixbuf)
@ -596,8 +597,8 @@ create_mime_icon_type (GtkIconTheme *icon_theme,
icon_name = g_string_new ("gnome-mime-");
g_string_append_len (icon_name, mime_type, separator - mime_type);
pixbuf = get_named_icon (icon_theme, icon_name->str, pixel_size);
if (DEBUG_MESSAGES && pixbuf)
_moo_message ("got icon '%s' for mime type '%s'", icon_name->str, mime_type);
if (pixbuf)
moo_dmsg ("got icon '%s' for mime type '%s'", icon_name->str, mime_type);
g_string_free (icon_name, TRUE);
}
@ -616,8 +617,8 @@ create_mime_icon_type (GtkIconTheme *icon_theme,
/* foo */
icon_name = g_string_new_len (mime_type, separator - mime_type);
pixbuf = get_named_icon (icon_theme, icon_name->str, pixel_size);
if (DEBUG_MESSAGES && pixbuf)
_moo_message ("got icon '%s' for mime type '%s'", icon_name->str, mime_type);
if (pixbuf)
moo_dmsg ("got icon '%s' for mime type '%s'", icon_name->str, mime_type);
g_string_free (icon_name, TRUE);
}
@ -649,8 +650,8 @@ create_mime_icon_exact (GtkIconTheme *icon_theme,
g_string_append_c (icon_name, '-');
g_string_append (icon_name, separator + 1);
pixbuf = get_named_icon (icon_theme, icon_name->str, pixel_size);
if (DEBUG_MESSAGES && pixbuf)
_moo_message ("got icon '%s' for mime type '%s'", icon_name->str, mime_type);
if (pixbuf)
moo_dmsg ("got icon '%s' for mime type '%s'", icon_name->str, mime_type);
g_string_free (icon_name, TRUE);
}
@ -662,8 +663,8 @@ create_mime_icon_exact (GtkIconTheme *icon_theme,
g_string_append_c (icon_name, '-');
g_string_append (icon_name, separator + 1);
pixbuf = get_named_icon (icon_theme, icon_name->str, pixel_size);
if (DEBUG_MESSAGES && pixbuf)
_moo_message ("got icon '%s' for mime type '%s'", icon_name->str, mime_type);
if (pixbuf)
moo_dmsg ("got icon '%s' for mime type '%s'", icon_name->str, mime_type);
g_string_free (icon_name, TRUE);
}
@ -688,21 +689,20 @@ create_mime_icon (GtkWidget *widget,
{
pixbuf = get_named_icon (icon_theme, "unknown", pixel_size);
if (DEBUG_MESSAGES && pixbuf)
_moo_message ("got 'unknown' icon for '%s'", mime_type);
if (pixbuf)
moo_dmsg ("got 'unknown' icon for '%s'", mime_type);
if (!pixbuf)
{
pixbuf = create_special_icon (widget, MOO_ICON_FILE, size);
if (DEBUG_MESSAGES && pixbuf)
_moo_message ("got FILE icon for '%s'", mime_type);
if (pixbuf)
moo_dmsg ("got FILE icon for '%s'", mime_type);
}
if (!pixbuf)
{
if (DEBUG_MESSAGES)
_moo_message ("getting fallback icon for mime type '%s'", mime_type);
moo_dmsg ("getting fallback icon for mime type '%s'", mime_type);
pixbuf = create_fallback_icon (widget, size);
}
@ -723,8 +723,8 @@ create_mime_icon (GtkWidget *widget,
for (p = parent_types; *p && !pixbuf; ++p)
{
pixbuf = create_mime_icon (widget, *p, size);
if (DEBUG_MESSAGES && pixbuf)
_moo_message ("used mime type '%s' icon for '%s'", *p, mime_type);
if (pixbuf)
moo_dmsg ("used mime type '%s' icon for '%s'", *p, mime_type);
}
g_free (parent_types);

View File

@ -27,7 +27,7 @@
#include <io.h>
#endif
#if 0 && MOO_DEBUG
#if 0 && MOO_DEBUG_ENABLED
#define DEBUG_MESSAGE g_message
#else
static void DEBUG_MESSAGE (G_GNUC_UNUSED const char *format, ...)

View File

@ -34,6 +34,7 @@
#include "mooutils/mooutils-gobject.h"
#include "mooutils/mooutils-fs.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include "mooutils/moodialogs.h"
#include "mooutils/moofiltermgr.h"
#include "mooutils/moouixml.h"

View File

@ -91,7 +91,7 @@ static void _hash_table_remove (FileList *flist,
MooFile *file);
#ifdef MOO_DEBUG
#ifdef MOO_DEBUG_ENABLED
#if 0
#define DEFINE_CHECK_FILE_LIST_INTEGRITY
static void CHECK_FILE_LIST_INTEGRITY (FileList *flist)
@ -115,7 +115,7 @@ static void CHECK_FILE_LIST_INTEGRITY (FileList *flist)
}
}
#endif
#endif /* MOO_DEBUG */
#endif /* MOO_DEBUG_ENABLED */
#ifndef DEFINE_CHECK_FILE_LIST_INTEGRITY
#define CHECK_FILE_LIST_INTEGRITY(flist)

View File

@ -416,12 +416,12 @@ G_STMT_START { \
ITER_SET_DIR(ip, is_dir); \
} G_STMT_END
#ifdef MOO_DEBUG
#ifdef MOO_DEBUG_ENABLED
#if 0
#define DEFINE_CHECK_ITER
static void CHECK_ITER (MooFolderModel *model, GtkTreeIter *iter);
#endif
#endif /* MOO_DEBUG */
#endif /* MOO_DEBUG_ENABLED */
#ifndef DEFINE_CHECK_ITER
#define CHECK_ITER(model,iter)
@ -611,7 +611,7 @@ model_remove_moo_file (MooFile *file,
}
#ifdef MOO_DEBUG
#ifdef MOO_DEBUG_ENABLED
#if 1
#define CHECK_ORDER(order,n) \
G_STMT_START { \
@ -626,7 +626,7 @@ G_STMT_START { \
g_free (check); \
} G_STMT_END
#endif
#endif /* MOO_DEBUG */
#endif /* MOO_DEBUG_ENABLED */
#ifndef CHECK_ORDER
#define CHECK_ORDER(order,n)
#endif

View File

@ -520,7 +520,7 @@ moo_python_api_init (void)
api.py_none = (gpointer) Py_None;
#ifndef MOO_DEBUG
#ifndef MOO_DEBUG_ENABLED
api.py_true = (MooPyObject*) Py_True;
api.py_false = (MooPyObject*) Py_False;
#else

View File

@ -51,10 +51,10 @@ G_BEGIN_DECLS
#define SCROLL_GRANULARITY 3
#ifdef MOO_DEBUG
#ifdef MOO_DEBUG_ENABLED
#define DEFAULT_MONOSPACE_FONT "Courier New 11"
#else
#define DEFAULT_MONOSPACE_FONT "Monospace 10"
#define DEFAULT_MONOSPACE_FONT "Monospace"
#endif

View File

@ -50,7 +50,7 @@ typedef enum
CHECK_ITER(iter__)
#ifdef MOO_DEBUG
#ifdef MOO_DEBUG_ENABLED
static void CHECK_ITER (const MooTermIter *iter)
{
g_assert (iter->term != NULL);

View File

@ -21,6 +21,7 @@
#include "mooutils/moomarshals.h"
#include "mooutils/mooutils-gobject.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include <string.h>

View File

@ -129,7 +129,7 @@ gboolean _moo_term_line_wrapped_chk__ (MooTermLine *line);
#define _moo_term_line_set_wrapped(line__) (line__)->wrapped = TRUE
#ifdef MOO_DEBUG
#ifdef MOO_DEBUG_ENABLED
#define _moo_term_line_get_cell(line__,index__) (_moo_term_line_get_cell_chk__(line__, index__))
#define _moo_term_line_get_char(line__,index__) (_moo_term_line_get_char_chk__(line__, index__))
#define _moo_term_line_get_tags(line__,index__) (_moo_term_line_get_tags_chk__(line__, index__))

View File

@ -21,6 +21,7 @@
#include "mooterm/pty.h"
#include "mooutils/moomarshals.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include <sys/types.h>
#include <sys/wait.h>

View File

@ -129,7 +129,7 @@ set_modified (MooMarkupNode *node,
{
if (node->doc)
{
#ifdef MOO_DEBUG
#ifdef MOO_DEBUG_ENABLED
if (modified && !node->doc->modified && node->doc->track_modified)
{
g_message ("markup doc %s modified",

View File

@ -366,7 +366,7 @@ moo_prefs_set_modified (gboolean modified)
{
MooPrefs *prefs = instance ();
#ifdef MOO_DEBUG
#ifdef MOO_DEBUG_ENABLED
if (modified && !prefs->rc_modified)
{
g_message ("%s: prefs modified", G_STRLOC);

View File

@ -0,0 +1,71 @@
/*
* mooutils-debug.h
*
* Copyright (C) 2004-2007 by Yevgen Muntyan <muntyan@math.tamu.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* See COPYING file that comes with this distribution.
*/
#ifndef MOO_UTILS_DEBUG_H
#define MOO_UTILS_DEBUG_H
#include <glib.h>
#include <stdarg.h>
G_BEGIN_DECLS
#ifdef MOO_DEBUG_ENABLED
#define MOO_DEBUG_INIT(domain, def_enabled) \
static const char *moo_debug_domain = "moo-debug-" #domain; \
static gboolean \
_moo_debug_enabled (void) \
{ \
static int enabled = -1; \
if (enabled == -1) \
enabled = moo_debug_enabled (#domain, def_enabled); \
return enabled; \
} \
\
inline static void \
moo_dmsg (const char *format, ...) G_GNUC_PRINTF (1, 2); \
\
inline static void \
moo_dmsg (const char *format, ...) \
{ \
va_list args; \
if (_moo_debug_enabled ()) \
{ \
va_start (args, format); \
g_logv (moo_debug_domain, \
G_LOG_LEVEL_MESSAGE, \
format, args); \
va_end (args); \
} \
}
void _moo_message (const char *format, ...) G_GNUC_PRINTF (1, 2);
gboolean moo_debug_enabled (const char *var,
gboolean def_enabled);
#define MOO_DEBUG(whatever) G_STMT_START {whatever;} G_STMT_END
#else
#define MOO_DEBUG_INIT(domain, def_enabled)
#define moo_dmsg(format, args...) G_STMT_START {} G_STMT_END
#define _moo_message(format, args...) G_STMT_START {} G_STMT_END
#define MOO_DEBUG(whatever) G_STMT_START {} G_STMT_END
#endif
G_END_DECLS
#endif /* MOO_UTILS_DEBUG_H */

View File

@ -16,7 +16,7 @@
#endif
#include "mooutils/mooutils-fs.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include "mooutils/moocompat.h"
#include <string.h>

View File

@ -17,6 +17,7 @@
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-fs.h"
#include "mooutils/mooutils-debug.h"
#include "mooutils/moologwindow-glade.h"
#include "mooutils/mooglade.h"
#include "mooutils/mooi18n.h"
@ -1599,40 +1600,6 @@ moo_data_dir_type_get_type (void)
}
static gboolean
_moo_debug_enabled (void)
{
#ifndef MOO_DEBUG
static gboolean enabled;
static gboolean been_here;
if (!been_here)
{
been_here = TRUE;
enabled = g_getenv ("MOO_DEBUG") != NULL;
}
return enabled;
#else
return TRUE;
#endif
}
void
_moo_message (const char *format,
...)
{
if (_moo_debug_enabled ())
{
va_list args;
va_start (args, format);
g_logv (G_LOG_DOMAIN "-debug", G_LOG_LEVEL_MESSAGE, format, args);
va_end (args);
}
}
void
_moo_widget_set_tooltip (GtkWidget *widget,
const char *tip)
@ -2057,3 +2024,49 @@ _moo_intern_string (const char *string)
}
#endif
}
gboolean
moo_debug_enabled (const char *domain,
gboolean def_enabled)
{
const char *val;
val = g_getenv ("MOO_DEBUG");
if (!val || !val[0])
return def_enabled;
if (!strcmp (val, "none"))
return FALSE;
if (!strcmp (val, "all"))
return TRUE;
return strstr (val, domain) != NULL;
}
#undef _moo_message
void
_moo_message (const char *format,
...)
{
static int enabled = -1;
if (enabled == -1)
{
enabled = moo_debug_enabled ("misc",
#ifdef MOO_DEBUG_ENABLED
TRUE);
#else
FALSE);
#endif
}
if (enabled)
{
va_list args;
va_start (args, format);
g_logv (G_LOG_DOMAIN "-debug", G_LOG_LEVEL_MESSAGE, format, args);
va_end (args);
}
}

View File

@ -42,8 +42,6 @@ void moo_set_log_func_silent (void);
void moo_reset_log_func (void);
void moo_segfault (void);
void _moo_message (const char *format,
...);
void moo_disable_win32_error_message (void);
void moo_enable_win32_error_message (void);

View File

@ -379,7 +379,7 @@ _moo_tree_helper_set_modified (MooTreeHelper *helper,
{
g_return_if_fail (MOO_IS_TREE_HELPER (helper));
#ifdef MOO_DEBUG
#ifdef MOO_DEBUG_ENABLED
if (!helper->modified && modified)
{
g_message ("%s: helper modified", G_STRLOC);