[gnome-control-center] shell: Add "-v" for verbose option to the shell



commit d7e4369d40827b6792e26206bd0dad775efcdf9e
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Mar 22 16:46:55 2011 +0000

    shell: Add "-v" for verbose option to the shell
    
    And remove it in the sound panel, so that all the panels
    use the same verbose settings.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=645435

 panels/sound/Makefile.am      |    4 +-
 panels/sound/cc-sound-panel.c |    4 --
 panels/sound/gvc-log.c        |    6 ++-
 shell/Makefile.am             |    2 +
 shell/cc-shell-log.c          |   63 +++++++++++++++++++++++++++++++++++++++++
 shell/cc-shell-log.h          |   33 +++++++++++++++++++++
 shell/control-center.c        |    7 ++++
 7 files changed, 111 insertions(+), 8 deletions(-)
---
diff --git a/panels/sound/Makefile.am b/panels/sound/Makefile.am
index 6d9938b..23ef9fd 100644
--- a/panels/sound/Makefile.am
+++ b/panels/sound/Makefile.am
@@ -48,8 +48,6 @@ libgnomevolumecontrol_la_SOURCES =		\
 	gvc-mixer-control-private.h		\
 	gvc-channel-bar.h			\
 	gvc-channel-bar.c			\
-	gvc-log.h				\
-	gvc-log.c				\
 	gvc-pulseaudio-fake.h			\
 	$(NULL)
 
@@ -64,6 +62,8 @@ gnome_sound_applet_SOURCES =			\
 	gvc-stream-status-icon.c		\
 	gvc-applet.h				\
 	gvc-applet.c				\
+	gvc-log.h				\
+	gvc-log.c				\
 	applet-main.c				\
 	$(NULL)
 
diff --git a/panels/sound/cc-sound-panel.c b/panels/sound/cc-sound-panel.c
index 316c3b3..e3f0b1d 100644
--- a/panels/sound/cc-sound-panel.c
+++ b/panels/sound/cc-sound-panel.c
@@ -33,7 +33,6 @@
 
 #include "cc-sound-panel.h"
 #include "gvc-mixer-dialog.h"
-#include "gvc-log.h"
 
 G_DEFINE_DYNAMIC_TYPE (CcSoundPanel, cc_sound_panel, CC_TYPE_PANEL)
 
@@ -72,9 +71,6 @@ cc_sound_panel_finalize (GObject *object)
 static void
 cc_sound_panel_init (CcSoundPanel *self)
 {
-        gvc_log_init ();
-        gvc_log_set_debug (TRUE);
-
         gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
                                            ICON_DATA_DIR);
         gtk_window_set_default_icon_name ("multimedia-volume-control");
diff --git a/panels/sound/gvc-log.c b/panels/sound/gvc-log.c
index 03a9486..3e78e79 100644
--- a/panels/sound/gvc-log.c
+++ b/panels/sound/gvc-log.c
@@ -30,6 +30,8 @@
 static int log_levels = G_LOG_LEVEL_CRITICAL |
                         G_LOG_LEVEL_ERROR    |
                         G_LOG_LEVEL_WARNING  |
+                        G_LOG_LEVEL_MESSAGE  |
+                        G_LOG_LEVEL_INFO     |
                         G_LOG_LEVEL_DEBUG;
 
 static void
@@ -54,9 +56,9 @@ void
 gvc_log_set_debug (gboolean debug)
 {
         if (debug) {
-                log_levels |= G_LOG_LEVEL_DEBUG;
+                log_levels |= (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO);
                 g_debug ("Enabling debugging");
         } else {
-                log_levels &= ~G_LOG_LEVEL_DEBUG;
+                log_levels &= ~ (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO);
         }
 }
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 521486d..d6a4f71 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -16,6 +16,8 @@ cc-shell-marshal.c: cc-shell-marshal.list
 
 gnome_control_center_SOURCES =			\
 	control-center.c			\
+	cc-shell-log.c				\
+	cc-shell-log.h				\
 	gnome-control-center.c			\
 	gnome-control-center.h			\
 	shell-search-renderer.c			\
diff --git a/shell/cc-shell-log.c b/shell/cc-shell-log.c
new file mode 100644
index 0000000..6301772
--- /dev/null
+++ b/shell/cc-shell-log.c
@@ -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 "cc-shell-log.h"
+
+static int log_levels = G_LOG_LEVEL_CRITICAL |
+                        G_LOG_LEVEL_ERROR    |
+                        G_LOG_LEVEL_WARNING  |
+                        G_LOG_LEVEL_MESSAGE  |
+                        G_LOG_LEVEL_INFO     |
+                        G_LOG_LEVEL_DEBUG;
+
+static void
+cc_shell_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
+cc_shell_log_init (void)
+{
+        g_log_set_default_handler (cc_shell_log_default_handler, NULL);
+}
+
+void
+cc_shell_log_set_debug (gboolean debug)
+{
+        if (debug) {
+                log_levels |= (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO);
+                g_debug ("Enabling debugging");
+        } else {
+                log_levels &= ~ (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO);
+        }
+}
diff --git a/shell/cc-shell-log.h b/shell/cc-shell-log.h
new file mode 100644
index 0000000..6ea1174
--- /dev/null
+++ b/shell/cc-shell-log.h
@@ -0,0 +1,33 @@
+/* -*- 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 __CC_SHELL_LOG_H
+#define __CC_SHELL_LOG_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+void cc_shell_log_init      (void);
+void cc_shell_log_set_debug (gboolean debug);
+
+G_END_DECLS
+
+#endif /* __CC_SHELL_LOG_H */
diff --git a/shell/control-center.c b/shell/control-center.c
index 1a589a7..7d017b1 100644
--- a/shell/control-center.c
+++ b/shell/control-center.c
@@ -29,6 +29,8 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
+#include "cc-shell-log.h"
+
 G_GNUC_NORETURN static gboolean
 option_version_cb (const gchar *option_name,
                    const gchar *value,
@@ -41,9 +43,11 @@ option_version_cb (const gchar *option_name,
 
 static char **start_panels = NULL;
 static gboolean show_overview = FALSE;
+static gboolean verbose = FALSE;
 
 const GOptionEntry all_options[] = {
   { "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_version_cb, NULL, NULL },
+  { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, N_("Enable verbose mode"), NULL },
   { "overview", 'o', 0, G_OPTION_ARG_NONE, &show_overview, N_("Show the overview"), NULL },
   { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &start_panels, N_("Panel to display"), NULL },
   { NULL } /* end the list */
@@ -77,6 +81,8 @@ application_command_line_cb (GApplication  *application,
     }
   g_option_context_free (context);
 
+  cc_shell_log_set_debug (verbose);
+
   gnome_control_center_show (shell, GTK_APPLICATION (application));
 
   if (show_overview)
@@ -139,6 +145,7 @@ main (int argc, char **argv)
 
   g_thread_init (NULL);
   gtk_init (&argc, &argv);
+  cc_shell_log_init ();
 
   shell = gnome_control_center_new ();
 



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