gnome-media r4257 - in trunk/gnome-volume-control: . src



Author: matthiasc
Date: Fri Mar  6 20:02:06 2009
New Revision: 4257
URL: http://svn.gnome.org/viewvc/gnome-media?rev=4257&view=rev

Log:
Wire up --debug and turn off debug spew initially


Added:
   trunk/gnome-volume-control/src/gvc-log.c
   trunk/gnome-volume-control/src/gvc-log.h
Modified:
   trunk/gnome-volume-control/ChangeLog
   trunk/gnome-volume-control/src/Makefile.am
   trunk/gnome-volume-control/src/applet-main.c
   trunk/gnome-volume-control/src/dialog-main.c

Modified: trunk/gnome-volume-control/src/Makefile.am
==============================================================================
--- trunk/gnome-volume-control/src/Makefile.am	(original)
+++ trunk/gnome-volume-control/src/Makefile.am	Fri Mar  6 20:02:06 2009
@@ -44,6 +44,7 @@
 	gvc-stream-status-icon.c		\
 	gvc-applet.h				\
 	gvc-applet.c				\
+	gvc-log.c				\
 	applet-main.c				\
 	$(NULL)
 
@@ -78,6 +79,7 @@
 	gvc-mixer-dialog.c			\
 	gvc-level-bar.h				\
 	gvc-level-bar.c				\
+	gvc-log.c				\
 	dialog-main.c				\
 	$(NULL)
 

Modified: trunk/gnome-volume-control/src/applet-main.c
==============================================================================
--- trunk/gnome-volume-control/src/applet-main.c	(original)
+++ trunk/gnome-volume-control/src/applet-main.c	Fri Mar  6 20:02:06 2009
@@ -32,6 +32,7 @@
 #include <unique/uniqueapp.h>
 
 #include "gvc-applet.h"
+#include "gvc-log.h"
 
 #define GVCA_DBUS_NAME "org.gnome.VolumeControlApplet"
 
@@ -54,11 +55,14 @@
         bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
         textdomain (GETTEXT_PACKAGE);
 
+	gvc_log_init ();
+
         error = NULL;
         gtk_init_with_args (&argc, &argv,
                             (char *) _(" - GNOME Volume Control Applet"),
                             entries, GETTEXT_PACKAGE,
                             &error);
+
         if (error != NULL) {
                 g_warning ("%s", error->message);
                 exit (1);
@@ -69,6 +73,8 @@
                 exit (1);
         }
 
+	gvc_log_set_debug (debug);
+
         app = unique_app_new (GVCA_DBUS_NAME, NULL);
         if (unique_app_is_running (app)) {
                 g_warning ("Applet is already running, exiting");

Modified: trunk/gnome-volume-control/src/dialog-main.c
==============================================================================
--- trunk/gnome-volume-control/src/dialog-main.c	(original)
+++ trunk/gnome-volume-control/src/dialog-main.c	Fri Mar  6 20:02:06 2009
@@ -32,6 +32,7 @@
 #include <unique/uniqueapp.h>
 
 #include "gvc-mixer-dialog.h"
+#include "gvc-log.h"
 
 #define GVCA_DBUS_NAME "org.gnome.VolumeControl"
 #define DIALOG_POPUP_TIMEOUT 3
@@ -146,6 +147,8 @@
         bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
         textdomain (GETTEXT_PACKAGE);
 
+	gvc_log_init ();
+
         error = NULL;
         gtk_init_with_args (&argc, &argv,
                             (char *) _(" - GNOME Volume Control"),
@@ -161,6 +164,8 @@
                 exit (1);
         }
 
+	gvc_log_set_debug (debug);
+
         app = unique_app_new (GVCA_DBUS_NAME, NULL);
         if (unique_app_is_running (app)) {
                 unique_app_send_message (app, UNIQUE_ACTIVATE, NULL);

Added: trunk/gnome-volume-control/src/gvc-log.c
==============================================================================
--- (empty file)
+++ trunk/gnome-volume-control/src/gvc-log.c	Fri Mar  6 20:02:06 2009
@@ -0,0 +1,63 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#include "gvc-log.h"
+
+
+static int log_levels = G_LOG_LEVEL_CRITICAL |
+                        G_LOG_LEVEL_ERROR    |
+                        G_LOG_LEVEL_WARNING  |
+                        G_LOG_LEVEL_DEBUG;
+
+static void
+gvc_log_default_handler (const gchar    *log_domain,
+                         GLogLevelFlags  log_level,
+                         const gchar    *message,
+                         gpointer        unused_data)
+{
+        if ((log_level & log_levels) == 0)
+                return;
+
+        g_log_default_handler (log_domain, log_level, message, unused_data);
+}
+
+void
+gvc_log_init (void)
+{
+        g_log_set_default_handler (gvc_log_default_handler, NULL);
+}
+
+void
+gvc_log_set_debug (gboolean debug)
+{
+        if (debug) {
+                log_levels |= G_LOG_LEVEL_DEBUG;
+                g_debug ("Enabling debugging");
+        } else {
+                g_debug ("Disabling debugging");
+                log_levels &= ~G_LOG_LEVEL_DEBUG;
+        }
+}

Added: trunk/gnome-volume-control/src/gvc-log.h
==============================================================================
--- (empty file)
+++ trunk/gnome-volume-control/src/gvc-log.h	Fri Mar  6 20:02:06 2009
@@ -0,0 +1,35 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GVC_LOG_H
+#define __GVC_LOG_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+
+void gvc_log_init      (void);
+void gvc_log_set_debug (gboolean debug);
+
+
+G_END_DECLS
+
+#endif /* __GVC_LOG_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]