~mpt/ubuntu/oneiric/gnome-control-center/bug-844807

« back to all changes in this revision

Viewing changes to .pc/01_git_kill_warning.patch/shell/control-center.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya, Micah Gersten, Rodrigo Moya
  • Date: 2011-05-24 10:55:28 UTC
  • mfrom: (1.1.46 upstream)
  • Revision ID: james.westby@ubuntu.com-20110524105528-dlmxhkwzc0t67kzn
Tags: 1:3.0.2-1ubuntu3
[ Micah Gersten ]
* debian/control:
  - Add reaks/Replaces on g-s-d (<< 3.0~) for gnome-control-center-data (LP: #786417)

[ Rodrigo Moya ]
* New upstream release
* debian/watch:
  - Switch to .bz2, as this is what is used in ftp.gnome.org now
* debian/patches/01_git_remove_gettext_calls.patch
* debian/patches/01_git_kill_warning.patch:
  - Remove upstreamed patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (c) 2009, 2010 Intel, Inc.
3
 
 * Copyright (c) 2010 Red Hat, Inc.
4
 
 *
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.
9
 
 *
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
13
 
 * for more details.
14
 
 *
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
18
 
 *
19
 
 * Author: Thomas Wood <thos@gnome.org>
20
 
 */
21
 
 
22
 
#include "config.h"
23
 
 
24
 
#include <glib/gi18n.h>
25
 
#include <stdlib.h>
26
 
 
27
 
#include "gnome-control-center.h"
28
 
 
29
 
#include <gtk/gtk.h>
30
 
#include <string.h>
31
 
 
32
 
#include "cc-shell-log.h"
33
 
 
34
 
G_GNUC_NORETURN static gboolean
35
 
option_version_cb (const gchar *option_name,
36
 
                   const gchar *value,
37
 
                   gpointer     data,
38
 
                   GError     **error)
39
 
{
40
 
  g_print ("%s %s\n", PACKAGE, VERSION);
41
 
  exit (0);
42
 
}
43
 
 
44
 
static char **start_panels = NULL;
45
 
static gboolean show_overview = FALSE;
46
 
static gboolean verbose = FALSE;
47
 
static gboolean show_help = FALSE;
48
 
 
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 */
56
 
};
57
 
 
58
 
static int
59
 
application_command_line_cb (GApplication  *application,
60
 
                             GApplicationCommandLine  *command_line,
61
 
                             GnomeControlCenter      *shell)
62
 
{
63
 
  int argc;
64
 
  char **argv;
65
 
  int retval = 0;
66
 
  GOptionContext *context;
67
 
  GError *error = NULL;
68
 
 
69
 
  verbose = FALSE;
70
 
  show_overview = FALSE;
71
 
  show_help = FALSE;
72
 
  start_panels = NULL;
73
 
 
74
 
  argv = g_application_command_line_get_arguments (command_line, &argc);
75
 
 
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);
81
 
 
82
 
  if (g_option_context_parse (context, &argc, &argv, &error) == FALSE)
83
 
    {
84
 
      g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
85
 
               error->message, argv[0]);
86
 
      g_error_free (error);
87
 
      g_option_context_free (context);
88
 
      return 1;
89
 
    }
90
 
 
91
 
  if (show_help)
92
 
    {
93
 
      gchar *help;
94
 
 
95
 
      help = g_option_context_get_help (context, FALSE, NULL);
96
 
      g_print (help);
97
 
      g_free (help);
98
 
      g_option_context_free (context);
99
 
      return 0;
100
 
    }
101
 
 
102
 
  g_option_context_free (context);
103
 
 
104
 
  cc_shell_log_set_debug (verbose);
105
 
 
106
 
  gnome_control_center_show (shell, GTK_APPLICATION (application));
107
 
 
108
 
  if (show_overview)
109
 
    {
110
 
      gnome_control_center_set_overview_page (shell);
111
 
    }
112
 
  else if (start_panels != NULL && start_panels[0] != NULL)
113
 
    {
114
 
      const char *start_id;
115
 
      GError *err = NULL;
116
 
 
117
 
      start_id = start_panels[0];
118
 
 
119
 
      if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), start_id, &err))
120
 
        {
121
 
          g_warning ("Could not load setting panel \"%s\": %s", start_id,
122
 
                     (err) ? err->message : "Unknown error");
123
 
          retval = 1;
124
 
          if (err)
125
 
            {
126
 
              g_error_free (err);
127
 
              err = NULL;
128
 
            }
129
 
        }
130
 
    }
131
 
 
132
 
  gnome_control_center_present (shell);
133
 
  gdk_notify_startup_complete ();
134
 
 
135
 
  g_strfreev (argv);
136
 
  if (start_panels != NULL)
137
 
    {
138
 
      g_strfreev (start_panels);
139
 
      start_panels = NULL;
140
 
    }
141
 
  show_overview = FALSE;
142
 
 
143
 
  return retval;
144
 
}
145
 
 
146
 
static void
147
 
application_startup_cb (GApplication       *application,
148
 
                        GnomeControlCenter *shell)
149
 
{
150
 
  /* nothing to do here, we don't want to show a window before
151
 
   * we've looked at the commandline
152
 
   */
153
 
}
154
 
 
155
 
int
156
 
main (int argc, char **argv)
157
 
{
158
 
  GnomeControlCenter *shell;
159
 
  GtkApplication *application;
160
 
  int status;
161
 
 
162
 
  bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
163
 
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
164
 
  textdomain (GETTEXT_PACKAGE);
165
 
 
166
 
 
167
 
  g_thread_init (NULL);
168
 
  gtk_init (&argc, &argv);
169
 
  cc_shell_log_init ();
170
 
 
171
 
  shell = gnome_control_center_new ();
172
 
 
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);
179
 
 
180
 
  status = g_application_run (G_APPLICATION (application), argc, argv);
181
 
 
182
 
  g_object_unref (application);
183
 
 
184
 
  return status;
185
 
}