~kroq-gar78/ubuntu/precise/gnome-control-center/fix-885947

« back to all changes in this revision

Viewing changes to capplets/appearance/appearance-main.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya
  • Date: 2011-05-17 10:47:27 UTC
  • mfrom: (0.1.11 experimental) (1.1.45 upstream)
  • Revision ID: james.westby@ubuntu.com-20110517104727-lqel6m8vhfw5jby1
Tags: 1:3.0.1.1-1ubuntu1
* Rebase on Debian, remaining Ubuntu changes:
* debian/control:
  - Build-Depend on hardening-wrapper, dpkg-dev and dh-autoreconf
  - Add dependency on ubuntu-system-service
  - Remove dependency on gnome-icon-theme-symbolic
  - Move dependency on apg, gnome-icon-theme-symbolic and accountsservice to
    be a Recommends: until we get them in main
* debian/rules:
  - Use autoreconf
  - Add binary-post-install rule for gnome-control-center-data
  - Run dh-autoreconf
* debian/gnome-control-center.dirs:
* debian/gnome-control-center.links:
  - Add a link to the control center shell for indicators
* debian/patches/00_disable-nm.patch:
  - Temporary patch to disable building with NetworkManager until we get
    the new one in the archive
* debian/patches/01_git_remove_gettext_calls.patch:
  - Remove calls to AM_GNU_GETTEXT, IT_PROG_INTLTOOL should be enough
* debian/patches/01_git_kill_warning.patch:
  - Kill warning
* debian/patches/50_ubuntu_systemwide_prefs.patch:
  - Ubuntu specific proxy preferences
* debian/patches/51_ubuntu_system_keyboard.patch:
  - Implement the global keyboard spec at https://wiki.ubuntu.com/DefaultKeyboardSettings

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2007 The GNOME Foundation
3
 
 * Written by Thomas Wood <thos@gnome.org>
4
 
 * All Rights Reserved
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License along
17
 
 * with this program; if not, write to the Free Software Foundation, Inc.,
18
 
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
 
 */
20
 
 
21
 
#include <glib/gi18n.h>
22
 
#include "appearance.h"
23
 
#include "appearance-desktop.h"
24
 
#include "appearance-font.h"
25
 
#include "appearance-themes.h"
26
 
#include "appearance-style.h"
27
 
#include "theme-installer.h"
28
 
#include "theme-thumbnail.h"
29
 
#include "activate-settings-daemon.h"
30
 
#include "capplet-util.h"
31
 
 
32
 
static AppearanceData *
33
 
init_appearance_data (int *argc, char ***argv, GOptionContext *context)
34
 
{
35
 
  AppearanceData *data = NULL;
36
 
  gchar *uifile;
37
 
  GtkBuilder *ui;
38
 
  GError *err = NULL;
39
 
 
40
 
  g_thread_init (NULL);
41
 
  gdk_threads_init ();
42
 
  gdk_threads_enter ();
43
 
  theme_thumbnail_factory_init (*argc, *argv);
44
 
  capplet_init (context, argc, argv);
45
 
  activate_settings_daemon ();
46
 
 
47
 
  /* set up the data */
48
 
  uifile = g_build_filename (GNOMECC_GTKBUILDER_DIR, "appearance.ui",
49
 
                             NULL);
50
 
  ui = gtk_builder_new ();
51
 
  gtk_builder_add_from_file (ui, uifile, &err);
52
 
  g_free (uifile);
53
 
 
54
 
  if (err)
55
 
    {
56
 
      g_warning (_("Could not load user interface file: %s"), err->message);
57
 
      g_error_free (err);
58
 
      g_object_unref (ui);
59
 
    }
60
 
  else
61
 
    {
62
 
      data = g_new (AppearanceData, 1);
63
 
      data->client = gconf_client_get_default ();
64
 
      data->ui = ui;
65
 
      data->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);
66
 
    }
67
 
 
68
 
  return data;
69
 
}
70
 
 
71
 
static void
72
 
main_window_response (GtkWidget *widget,
73
 
                      gint response_id,
74
 
                      AppearanceData *data)
75
 
{
76
 
  if (response_id == GTK_RESPONSE_CLOSE ||
77
 
      response_id == GTK_RESPONSE_DELETE_EVENT)
78
 
  {
79
 
    gtk_main_quit ();
80
 
 
81
 
    themes_shutdown (data);
82
 
    style_shutdown (data);
83
 
    desktop_shutdown (data);
84
 
    font_shutdown (data);
85
 
 
86
 
    g_object_unref (data->thumb_factory);
87
 
    g_object_unref (data->client);
88
 
    g_object_unref (data->ui);
89
 
  }
90
 
  else if (response_id == GTK_RESPONSE_HELP)
91
 
  {
92
 
      GtkNotebook *nb;
93
 
      gint pindex;
94
 
 
95
 
      nb = GTK_NOTEBOOK (appearance_capplet_get_widget (data, "main_notebook"));
96
 
      pindex = gtk_notebook_get_current_page (nb);
97
 
 
98
 
      switch (pindex)
99
 
      {
100
 
        case 0: /* theme */
101
 
          capplet_help (GTK_WINDOW (widget), "goscustdesk-12");
102
 
          break;
103
 
        case 1: /* background */
104
 
          capplet_help (GTK_WINDOW (widget), "goscustdesk-7");
105
 
          break;
106
 
        case 2: /* fonts */
107
 
          capplet_help (GTK_WINDOW (widget), "goscustdesk-38");
108
 
          break;
109
 
        case 3: /* interface */
110
 
          capplet_help (GTK_WINDOW (widget), "goscustuserinter-2");
111
 
          break;
112
 
        default:
113
 
          capplet_help (GTK_WINDOW (widget), "prefs-look-and-feel");
114
 
          break;
115
 
       }
116
 
  }
117
 
}
118
 
 
119
 
int
120
 
main (int argc, char **argv)
121
 
{
122
 
  AppearanceData *data;
123
 
  GtkWidget *w;
124
 
 
125
 
  gchar *install_filename = NULL;
126
 
  gchar *start_page = NULL;
127
 
  gchar **wallpaper_files = NULL;
128
 
  GOptionContext *option_context;
129
 
  GOptionEntry option_entries[] = {
130
 
      { "install-theme",
131
 
        'i',
132
 
        G_OPTION_FLAG_IN_MAIN,
133
 
        G_OPTION_ARG_FILENAME,
134
 
        &install_filename,
135
 
        N_("Specify the filename of a theme to install"),
136
 
        N_("filename") },
137
 
      { "show-page",
138
 
        'p',
139
 
        G_OPTION_FLAG_IN_MAIN,
140
 
        G_OPTION_ARG_STRING,
141
 
        &start_page,
142
 
        /* TRANSLATORS: don't translate the terms in brackets */
143
 
        N_("Specify the name of the page to show (theme|background|fonts|interface)"),
144
 
        N_("page") },
145
 
      { G_OPTION_REMAINING,
146
 
        0,
147
 
        G_OPTION_FLAG_IN_MAIN,
148
 
        G_OPTION_ARG_FILENAME_ARRAY,
149
 
        &wallpaper_files,
150
 
        NULL,
151
 
        N_("[WALLPAPER...]") },
152
 
      { NULL }
153
 
    };
154
 
 
155
 
  option_context = g_option_context_new (NULL);
156
 
  g_option_context_add_main_entries (option_context, option_entries, GETTEXT_PACKAGE);
157
 
 
158
 
  /* init */
159
 
  data = init_appearance_data (&argc, &argv, option_context);
160
 
  if (!data)
161
 
    return 1;
162
 
 
163
 
  /* init tabs */
164
 
  themes_init (data);
165
 
  style_init (data);
166
 
  desktop_init (data, (const gchar **) wallpaper_files);
167
 
  g_strfreev (wallpaper_files);
168
 
  font_init (data);
169
 
 
170
 
  /* prepare the main window */
171
 
  w = appearance_capplet_get_widget (data, "appearance_window");
172
 
  capplet_set_icon (w, "preferences-desktop-theme");
173
 
  gtk_widget_show_all (w);
174
 
 
175
 
  g_signal_connect_after (w, "response",
176
 
                          (GCallback) main_window_response, data);
177
 
 
178
 
  /* default to background page if files were given on the command line */
179
 
  if (wallpaper_files && !install_filename && !start_page)
180
 
    start_page = g_strdup ("background");
181
 
 
182
 
  if (start_page != NULL) {
183
 
    gchar *page_name;
184
 
 
185
 
    page_name = g_strconcat (start_page, "_vbox", NULL);
186
 
    g_free (start_page);
187
 
 
188
 
    w = appearance_capplet_get_widget (data, page_name);
189
 
    if (w != NULL) {
190
 
      GtkNotebook *nb;
191
 
      gint pindex;
192
 
 
193
 
      nb = GTK_NOTEBOOK (appearance_capplet_get_widget (data, "main_notebook"));
194
 
      pindex = gtk_notebook_page_num (nb, w);
195
 
      if (pindex != -1)
196
 
        gtk_notebook_set_current_page (nb, pindex);
197
 
    }
198
 
    g_free (page_name);
199
 
  }
200
 
 
201
 
  if (install_filename != NULL) {
202
 
    GFile *inst = g_file_new_for_commandline_arg (install_filename);
203
 
    g_free (install_filename);
204
 
    gnome_theme_install (inst, GTK_WINDOW (w));
205
 
    g_object_unref (inst);
206
 
  }
207
 
 
208
 
  g_option_context_free (option_context);
209
 
 
210
 
  /* start the mainloop */
211
 
  gtk_main ();
212
 
  gdk_threads_leave ();
213
 
 
214
 
  /* free stuff */
215
 
  g_free (data);
216
 
 
217
 
  return 0;
218
 
}