gnome-games r8450 - in trunk: aisleriot libgames-support
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8450 - in trunk: aisleriot libgames-support
- Date: Tue, 6 Jan 2009 18:19:03 +0000 (UTC)
Author: chpe
Date: Tue Jan 6 18:19:03 2009
New Revision: 8450
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8450&view=rev
Log:
dd debug support, copied from gnome-terminal/vte.
Added:
trunk/libgames-support/games-debug.c
trunk/libgames-support/games-debug.h
Modified:
trunk/aisleriot/sol.c
trunk/libgames-support/Makefile.am
trunk/libgames-support/games-card-theme-kde.c
trunk/libgames-support/games-card-theme.c
trunk/libgames-support/games-runtime.c
trunk/libgames-support/games-sound.c
Modified: trunk/aisleriot/sol.c
==============================================================================
--- trunk/aisleriot/sol.c (original)
+++ trunk/aisleriot/sol.c Tue Jan 6 18:19:03 2009
@@ -56,6 +56,7 @@
#define HELP_EXT "xhtml"
#endif /* G_OS_WIN32 */
+#include <libgames-support/games-debug.h>
#include <libgames-support/games-files.h>
#include <libgames-support/games-stock.h>
#include <libgames-support/games-runtime.h>
@@ -689,6 +690,8 @@
g_thread_init (NULL);
#endif
+ _games_debug_init ();
+
if (!games_runtime_init ("aisleriot"))
return 1;
Modified: trunk/libgames-support/Makefile.am
==============================================================================
--- trunk/libgames-support/Makefile.am (original)
+++ trunk/libgames-support/Makefile.am Tue Jan 6 18:19:03 2009
@@ -34,6 +34,8 @@
games-card-theme-fixed.c \
games-conf.c \
games-conf.h \
+ games-debug.c \
+ games-debug.h \
games-files.c \
games-files.h \
games-help.c \
Modified: trunk/libgames-support/games-card-theme-kde.c
==============================================================================
--- trunk/libgames-support/games-card-theme-kde.c (original)
+++ trunk/libgames-support/games-card-theme-kde.c Tue Jan 6 18:19:03 2009
@@ -24,6 +24,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtk.h>
+#include "games-debug.h"
#include "games-find-file.h"
#include "games-files.h"
#include "games-preimage.h"
@@ -142,7 +143,8 @@
#endif
if (!rsvg_handle_get_dimensions_sub (preimage->rsvg_handle, &dimension, node)) {
- g_print ("Failed to get dim for '%s'\n", node);
+ _games_debug_print (GAMES_DEBUG_CARD_THEME,
+ "Failed to get dim for '%s'\n", node);
return NULL;
}
@@ -153,7 +155,8 @@
#endif
if (!rsvg_handle_get_position_sub (preimage->rsvg_handle, &position, node)) {
- g_print ("Failed to get pos for '%s'\n", node);
+ _games_debug_print (GAMES_DEBUG_CARD_THEME,
+ "Failed to get pos for '%s'\n", node);
return NULL;
}
@@ -163,7 +166,8 @@
(t3 - t2) * 1.0 / CLOCKS_PER_SEC, node,
(t3 - t1)* 1.0 / CLOCKS_PER_SEC);
- g_print ("card %s position %d:%d dimension %d:%d\n", node, position.x, position.y, dimension.width, dimension.height);
+ _games_debug_print (GAMES_DEBUG_CARD_THEME,
+ "card %s position %d:%d dimension %d:%d\n", node, position.x, position.y, dimension.width, dimension.height);
#endif
card_width = ((double) games_preimage_get_width (preimage)) / N_COLS;
@@ -190,7 +194,8 @@
(t4 - t3) * 1.0 / CLOCKS_PER_SEC, node,
(t4 - t1)* 1.0 / CLOCKS_PER_SEC);
- g_print ("Returning %p\n", subpixbuf);
+ _games_debug_print (GAMES_DEBUG_CARD_THEME,
+ "Returning %p\n", subpixbuf);
#endif
return subpixbuf;
Modified: trunk/libgames-support/games-card-theme.c
==============================================================================
--- trunk/libgames-support/games-card-theme.c (original)
+++ trunk/libgames-support/games-card-theme.c Tue Jan 6 18:19:03 2009
@@ -25,6 +25,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtk.h>
+#include "games-debug.h"
#include "games-find-file.h"
#include "games-files.h"
#include "games-preimage.h"
@@ -655,8 +656,9 @@
info->data = data;
info->destroy_notify = destroy_notify;
- g_print ("Created GamesCardThemeInfo for type=%s path=%s filename=%s display-name=%s\n",
- g_type_name (type), path, filename, display_name);
+ _games_debug_print (GAMES_DEBUG_CARD_THEME,
+ "Created GamesCardThemeInfo for type=%s path=%s filename=%s display-name=%s\n",
+ g_type_name (type), path, filename, display_name);
return info;
}
Added: trunk/libgames-support/games-debug.c
==============================================================================
--- (empty file)
+++ trunk/libgames-support/games-debug.c Tue Jan 6 18:19:03 2009
@@ -0,0 +1,40 @@
+/*
+ * Copyright  2002,2003 Red Hat, Inc.
+ *
+ * This is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <config.h>
+
+#include <glib.h>
+
+#include "games-debug.h"
+
+GamesDebugFlags _games_debug_flags;
+
+void
+_games_debug_init (void)
+{
+#ifdef GNOME_ENABLE_DEBUG
+ const GDebugKey keys[] = {
+ { "card-theme", GAMES_DEBUG_CARD_THEME },
+ { "sound ", GAMES_DEBUG_SOUND }
+ };
+
+ _games_debug_flags = g_parse_debug_string (g_getenv ("GAMES_DEBUG"),
+ keys, G_N_ELEMENTS (keys));
+#endif /* GNOME_ENABLE_DEBUG */
+}
+
Added: trunk/libgames-support/games-debug.h
==============================================================================
--- (empty file)
+++ trunk/libgames-support/games-debug.h Tue Jan 6 18:19:03 2009
@@ -0,0 +1,72 @@
+/*
+ * Copyright  2002 Red Hat, Inc.
+ *
+ * This is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/* The interfaces in this file are subject to change at any time. */
+
+#ifndef GNOME_ENABLE_DEBUG_H
+#define GNOME_ENABLE_DEBUG_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define GAMES_DEBUG_LAST_RESERVED_BIT (8)
+
+typedef enum {
+ GAMES_DEBUG_CARD_THEME = 1 << 0,
+ GAMES_DEBUG_RUNTIME = 1 << 1,
+ GAMES_DEBUG_SOUND = 1 << 2,
+} GamesDebugFlags;
+
+void _games_debug_init (void);
+
+extern GamesDebugFlags _games_debug_flags;
+static inline gboolean _games_debug_on (GamesDebugFlags flags) G_GNUC_CONST G_GNUC_UNUSED;
+
+static inline gboolean
+_games_debug_on (GamesDebugFlags flags)
+{
+ return (_games_debug_flags & flags) == flags;
+}
+
+#ifdef GNOME_ENABLE_DEBUG
+#define _GAMES_DEBUG_IF(flags) if (G_UNLIKELY (_games_debug_on (flags)))
+#else
+#define _GAMES_DEBUG_IF(flags) if (0)
+#endif
+
+#if defined(__GNUC__) && G_HAVE_GNUC_VARARGS
+#define _games_debug_print(flags, fmt, ...) \
+ G_STMT_START { _GAMES_DEBUG_IF(flags) g_printerr(fmt, ##__VA_ARGS__); } G_STMT_END
+#else
+#include <stdarg.h>
+#include <glib/gstdio.h>
+static void _games_debug_print (guint flags, const char *fmt, ...)
+{
+ if (_games_debug_on (flags)) {
+ va_list ap;
+ va_start (ap, fmt);
+ g_vfprintf (stderr, fmt, ap);
+ va_end (ap);
+ }
+}
+#endif
+
+G_END_DECLS
+
+#endif /* !GNOME_ENABLE_DEBUG_H */
Modified: trunk/libgames-support/games-runtime.c
==============================================================================
--- trunk/libgames-support/games-runtime.c (original)
+++ trunk/libgames-support/games-runtime.c Tue Jan 6 18:19:03 2009
@@ -26,6 +26,7 @@
#define HELP_EXT "xhtml"
#endif /* G_OS_WIN32 */
+#include "games-debug.h"
#include "games-runtime.h"
static char *app_name;
@@ -78,7 +79,16 @@
app_name = g_strdup (name);
#ifdef G_OS_WIN32
- return games_runtime_get_directory (GAMES_RUNTIME_MODULE_DIRECTORY) != NULL;
+{
+ const char *path;
+
+ path = games_runtime_get_directory (GAMES_RUNTIME_MODULE_DIRECTORY);
+
+ _games_debug_print (GAMES_DEBUG_RUNTIME,
+ "Relocation path: %s\n", path ? path : "(null)");
+
+ return path != NULL;
+}
#else
return TRUE;
#endif
Modified: trunk/libgames-support/games-sound.c
==============================================================================
--- trunk/libgames-support/games-sound.c (original)
+++ trunk/libgames-support/games-sound.c Tue Jan 6 18:19:03 2009
@@ -31,6 +31,7 @@
#include "SDL_mixer.h"
#endif
+#include "games-debug.h"
#include "games-runtime.h"
#include "games-sound.h"
@@ -78,7 +79,9 @@
gchar *debug;
gst_message_parse_error (message, &err, &debug);
- g_print (_("Error playing sound: %s\n"), err->message);
+ _games_debug_print (GAMES_DEBUG_SOUND,
+ "Error playing sound: %s\n", err->message);
+
g_error_free (err);
g_free (debug);
@@ -111,7 +114,8 @@
wave = Mix_LoadWAV (path);
if (wave == NULL) {
- g_print (_("Error playing sound %s: %s\n"), path, Mix_GetError ());
+ _games_debug_print (GAMES_DEBUG_SOUND,
+ "Error playing sound %s: %s\n", path, Mix_GetError ());
}
Mix_PlayChannel (-1, wave, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]