[Goodies-commits] r7329 - in xfce4-power-manager/trunk: . src

Ali Abdallah aliov at xfce.org
Mon May 11 22:03:05 CEST 2009


Author: aliov
Date: 2009-05-11 20:03:05 +0000 (Mon, 11 May 2009)
New Revision: 7329

Added:
   xfce4-power-manager/trunk/src/xfpm-debug.c
Modified:
   xfce4-power-manager/trunk/ChangeLog
   xfce4-power-manager/trunk/src/Makefile.am
   xfce4-power-manager/trunk/src/xfpm-battery.c
   xfce4-power-manager/trunk/src/xfpm-button-xf86.c
   xfce4-power-manager/trunk/src/xfpm-debug.h
Log:
Added xfpm-debug.c with some code to debug GEnum values

Modified: xfce4-power-manager/trunk/ChangeLog
===================================================================
--- xfce4-power-manager/trunk/ChangeLog	2009-05-11 16:34:04 UTC (rev 7328)
+++ xfce4-power-manager/trunk/ChangeLog	2009-05-11 20:03:05 UTC (rev 7329)
@@ -1,4 +1,7 @@
 
+2009-05-11 22:02 Ali aliov at xfce.org 
+	 * : Added xfpm-debug.c with some code to debug GEnum values
+
 2009-05-11  9:31 Ali aliov at xfce.org 
 	 * : Update po Changelog for the russian translation
 

Modified: xfce4-power-manager/trunk/src/Makefile.am
===================================================================
--- xfce4-power-manager/trunk/src/Makefile.am	2009-05-11 16:34:04 UTC (rev 7328)
+++ xfce4-power-manager/trunk/src/Makefile.am	2009-05-11 20:03:05 UTC (rev 7329)
@@ -61,6 +61,7 @@
 	xfpm-errors.h				\
 	xfpm-config.h				\
 	xfpm-enum.h				\
+	xfpm-debug.c				\
 	xfpm-debug.h
 
 

Modified: xfce4-power-manager/trunk/src/xfpm-battery.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-battery.c	2009-05-11 16:34:04 UTC (rev 7328)
+++ xfce4-power-manager/trunk/src/xfpm-battery.c	2009-05-11 20:03:05 UTC (rev 7329)
@@ -157,7 +157,7 @@
 {
     gchar *icon;
 
-    XFPM_DEBUG_ENUM ("battery state", battery->priv->state, XFPM_TYPE_BATTERY_STATE)
+    XFPM_DEBUG_ENUM ("battery state", battery->priv->state, XFPM_TYPE_BATTERY_STATE);
     
     if ( state == BATTERY_NOT_PRESENT )
     {

Modified: xfce4-power-manager/trunk/src/xfpm-button-xf86.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-button-xf86.c	2009-05-11 16:34:04 UTC (rev 7328)
+++ xfce4-power-manager/trunk/src/xfpm-button-xf86.c	2009-05-11 20:03:05 UTC (rev 7329)
@@ -100,7 +100,7 @@
     
     key = GPOINTER_TO_INT (key_hash);
     
-    XFPM_DEBUG_ENUM ("Key press", key, XFPM_TYPE_BUTTON_KEY)
+    XFPM_DEBUG_ENUM ("Key press", key, XFPM_TYPE_BUTTON_KEY);
     
     g_signal_emit (G_OBJECT(button), signals[XF86_BUTTON_PRESSED], 0, key);
 
@@ -163,7 +163,7 @@
 	return FALSE;
     }
     
-    XFPM_DEBUG_ENUM_FULL (key, XFPM_TYPE_BUTTON_KEY, "Grabbed key %li ", (long int) keycode)
+    XFPM_DEBUG_ENUM_FULL (key, XFPM_TYPE_BUTTON_KEY, "Grabbed key %li ", (long int) keycode);
     
     g_hash_table_insert (button->priv->hash, GINT_TO_POINTER(keycode), GINT_TO_POINTER(key));
     

Added: xfce4-power-manager/trunk/src/xfpm-debug.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-debug.c	                        (rev 0)
+++ xfce4-power-manager/trunk/src/xfpm-debug.c	2009-05-11 20:03:05 UTC (rev 7329)
@@ -0,0 +1,82 @@
+/*
+ * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <glib/gprintf.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include <libxfce4util/libxfce4util.h>
+
+#include "xfpm-debug.h"
+
+#ifdef DEBUG
+
+void xfpm_debug_enum (const gchar *func, const gchar *file, gint line, 
+		      const gchar *text, gint v_enum, GType type)
+{
+    static gchar *content = NULL;
+    static GValue __value__ = { 0, };
+
+    g_value_init (&__value__, type);
+    g_value_set_enum (&__value__, v_enum);
+    
+    content = g_strdup_value_contents (&__value__);
+    
+    fprintf(stderr, "TRACE[%s:%d] %s(): %s : %s", file, line , func, text, content);
+    fprintf(stderr, "\n");
+    
+    g_value_unset (&__value__);						
+    g_free (content);
+}
+
+void xfpm_debug_enum_full (const gchar *func, const gchar *file, gint line,
+			   gint v_enum, GType type, const gchar *format, ...)
+{
+    va_list args;
+    gchar *buffer;
+    
+    static gchar *content = NULL;
+    static GValue __value__ = { 0, };
+    
+    g_value_init (&__value__, type);
+    g_value_set_enum (&__value__, v_enum);
+    
+    content = g_strdup_value_contents (&__value__);
+    
+    va_start (args, format);
+    g_vasprintf (&buffer, format, args);
+    va_end (args);
+	
+    fprintf(stderr, "TRACE[%s:%d] %s(): ",file,line,func);
+    fprintf(stderr, "%s: %s", buffer, content);
+    fprintf(stderr, "\n");
+    
+    g_value_unset (&__value__);	
+    g_free (content);
+    g_free (buffer);
+}
+
+#endif /*DEBUG*/

Modified: xfce4-power-manager/trunk/src/xfpm-debug.h
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-debug.h	2009-05-11 16:34:04 UTC (rev 7328)
+++ xfce4-power-manager/trunk/src/xfpm-debug.h	2009-05-11 20:03:05 UTC (rev 7329)
@@ -25,42 +25,39 @@
 #include <config.h>
 #endif
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
+#include <stdarg.h>
 #include <glib.h>
 
 G_BEGIN_DECLS
 
 #ifdef DEBUG
 
-static gchar *content = NULL;
-static GValue __value__ = { 0, };
+#define XFPM_DEBUG_ENUM(_text, _value, _type)\
+    xfpm_debug_enum (__func__, __FILE__, __LINE__, _text, _value, _type)
 
-#define XFPM_DEBUG_ENUM(_text, _value, _type) 				\
-    g_value_init (&__value__, _type);					\
-    g_value_set_enum (&__value__, _value);				\
-    content = g_strdup_value_contents (&__value__);			\
-    TRACE ("%s : %s", _text, content);					\
-    g_value_unset (&__value__);						\
-    g_free (content);
-    
-#define XFPM_DEBUG_ENUM_FULL(_value, _type, ...)			\
-    g_value_init (&__value__, _type);					\
-    g_value_set_enum (&__value__, _value);				\
-    content = g_strdup_value_contents (&__value__);			\
-    fprintf(stderr, "TRACE[%s:%d] %s(): ",__FILE__,__LINE__,__func__);  \
-    fprintf(stderr, __VA_ARGS__);					\
-    fprintf(stderr, ": %s", content);					\
-    fprintf(stderr, "\n");						\
-    g_value_unset (&__value__);						\
-    g_free (content);
-    
+#define XFPM_DEBUG_ENUM_FULL(_value, _type, ...)\
+    xfpm_debug_enum_full (__func__, __FILE__, __LINE__, _value, _type, __VA_ARGS__)
+
+
+
+void		xfpm_debug_enum 	(const gchar *func,
+					 const gchar *file,
+					 gint line,
+					 const gchar *text,
+					 gint v_enum, 
+					 GType type);
+					 
+void		xfpm_debug_enum_full    (const gchar *func,
+					 const gchar *file,
+					 gint line,
+					 gint v_enum,
+					 GType type,
+					 const gchar *format,
+					 ...);
 #else
 
 #define XFPM_DEBUG_ENUM(_text, _value, _type)
-#define XFPM_DEBUG_ENUM_FULL(_value, _type, ...)			
+#define XFPM_DEBUG_ENUM_FULL(_value, _type, ...)
 
 #endif
 




More information about the Goodies-commits mailing list