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
This commit is contained in:
Bastien Nocera
2011-03-22 16:46:55 +00:00
parent e1bebc6bf2
commit d7e4369d40
7 changed files with 111 additions and 8 deletions

View File

@@ -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)

View File

@@ -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");

View File

@@ -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);
}
}

View File

@@ -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 \

63
shell/cc-shell-log.c Normal file
View File

@@ -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);
}
}

33
shell/cc-shell-log.h Normal file
View File

@@ -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 */

View File

@@ -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 ();