2
* Copyright (c) 2009, 2010 Intel, Inc.
3
* Copyright (c) 2010 Red Hat, Inc.
5
* The Control Center is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by the
7
* Free Software Foundation; either version 2 of the License, or (at your
8
* option) any later version.
10
* The Control Center is distributed in the hope that it will be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15
* You should have received a copy of the GNU General Public License along
16
* with the Control Center; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
* Author: Thomas Wood <thos@gnome.org>
24
#include <glib/gi18n.h>
27
#include "gnome-control-center.h"
32
#include "cc-shell-log.h"
34
G_GNUC_NORETURN static gboolean
35
option_version_cb (const gchar *option_name,
40
g_print ("%s %s\n", PACKAGE, VERSION);
44
static char **start_panels = NULL;
45
static gboolean show_overview = FALSE;
46
static gboolean verbose = FALSE;
47
static gboolean show_help = FALSE;
49
const GOptionEntry all_options[] = {
50
{ "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_version_cb, NULL, NULL },
51
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, N_("Enable verbose mode"), NULL },
52
{ "overview", 'o', 0, G_OPTION_ARG_NONE, &show_overview, N_("Show the overview"), NULL },
53
{ "help", '?', 0, G_OPTION_ARG_NONE, &show_help, N_("Show help options"), NULL },
54
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &start_panels, N_("Panel to display"), NULL },
55
{ NULL } /* end the list */
59
application_command_line_cb (GApplication *application,
60
GApplicationCommandLine *command_line,
61
GnomeControlCenter *shell)
66
GOptionContext *context;
70
show_overview = FALSE;
74
argv = g_application_command_line_get_arguments (command_line, &argc);
76
context = g_option_context_new (N_("- System Settings"));
77
g_option_context_add_main_entries (context, all_options, GETTEXT_PACKAGE);
78
g_option_context_set_translation_domain(context, GETTEXT_PACKAGE);
79
g_option_context_add_group (context, gtk_get_option_group (TRUE));
80
g_option_context_set_help_enabled (context, FALSE);
82
if (g_option_context_parse (context, &argc, &argv, &error) == FALSE)
84
g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
85
error->message, argv[0]);
87
g_option_context_free (context);
95
help = g_option_context_get_help (context, FALSE, NULL);
98
g_option_context_free (context);
102
g_option_context_free (context);
104
cc_shell_log_set_debug (verbose);
106
gnome_control_center_show (shell, GTK_APPLICATION (application));
110
gnome_control_center_set_overview_page (shell);
112
else if (start_panels != NULL && start_panels[0] != NULL)
114
const char *start_id;
117
start_id = start_panels[0];
119
if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), start_id, &err))
121
g_warning ("Could not load setting panel \"%s\": %s", start_id,
122
(err) ? err->message : "Unknown error");
132
gnome_control_center_present (shell);
133
gdk_notify_startup_complete ();
136
if (start_panels != NULL)
138
g_strfreev (start_panels);
141
show_overview = FALSE;
147
application_startup_cb (GApplication *application,
148
GnomeControlCenter *shell)
150
/* nothing to do here, we don't want to show a window before
151
* we've looked at the commandline
156
main (int argc, char **argv)
158
GnomeControlCenter *shell;
159
GtkApplication *application;
162
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
163
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
164
textdomain (GETTEXT_PACKAGE);
167
g_thread_init (NULL);
168
gtk_init (&argc, &argv);
169
cc_shell_log_init ();
171
shell = gnome_control_center_new ();
173
/* enforce single instance of this application */
174
application = gtk_application_new ("org.gnome.ControlCenter", G_APPLICATION_HANDLES_COMMAND_LINE);
175
g_signal_connect (application, "startup",
176
G_CALLBACK (application_startup_cb), shell);
177
g_signal_connect (application, "command-line",
178
G_CALLBACK (application_command_line_cb), shell);
180
status = g_application_run (G_APPLICATION (application), argc, argv);
182
g_object_unref (application);