2
* Copyright (C) 2007 The GNOME Foundation
3
* Written by Thomas Wood <thos@gnome.org>
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.
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.
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.
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"
32
static AppearanceData *
33
init_appearance_data (int *argc, char ***argv, GOptionContext *context)
35
AppearanceData *data = NULL;
43
theme_thumbnail_factory_init (*argc, *argv);
44
capplet_init (context, argc, argv);
45
activate_settings_daemon ();
48
uifile = g_build_filename (GNOMECC_GTKBUILDER_DIR, "appearance.ui",
50
ui = gtk_builder_new ();
51
gtk_builder_add_from_file (ui, uifile, &err);
56
g_warning (_("Could not load user interface file: %s"), err->message);
62
data = g_new (AppearanceData, 1);
63
data->client = gconf_client_get_default ();
65
data->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);
72
main_window_response (GtkWidget *widget,
76
if (response_id == GTK_RESPONSE_CLOSE ||
77
response_id == GTK_RESPONSE_DELETE_EVENT)
81
themes_shutdown (data);
82
style_shutdown (data);
83
desktop_shutdown (data);
86
g_object_unref (data->thumb_factory);
87
g_object_unref (data->client);
88
g_object_unref (data->ui);
90
else if (response_id == GTK_RESPONSE_HELP)
95
nb = GTK_NOTEBOOK (appearance_capplet_get_widget (data, "main_notebook"));
96
pindex = gtk_notebook_get_current_page (nb);
101
capplet_help (GTK_WINDOW (widget), "goscustdesk-12");
103
case 1: /* background */
104
capplet_help (GTK_WINDOW (widget), "goscustdesk-7");
107
capplet_help (GTK_WINDOW (widget), "goscustdesk-38");
109
case 3: /* interface */
110
capplet_help (GTK_WINDOW (widget), "goscustuserinter-2");
113
capplet_help (GTK_WINDOW (widget), "prefs-look-and-feel");
120
main (int argc, char **argv)
122
AppearanceData *data;
125
gchar *install_filename = NULL;
126
gchar *start_page = NULL;
127
gchar **wallpaper_files = NULL;
128
GOptionContext *option_context;
129
GOptionEntry option_entries[] = {
132
G_OPTION_FLAG_IN_MAIN,
133
G_OPTION_ARG_FILENAME,
135
N_("Specify the filename of a theme to install"),
139
G_OPTION_FLAG_IN_MAIN,
142
/* TRANSLATORS: don't translate the terms in brackets */
143
N_("Specify the name of the page to show (theme|background|fonts|interface)"),
145
{ G_OPTION_REMAINING,
147
G_OPTION_FLAG_IN_MAIN,
148
G_OPTION_ARG_FILENAME_ARRAY,
151
N_("[WALLPAPER...]") },
155
option_context = g_option_context_new (NULL);
156
g_option_context_add_main_entries (option_context, option_entries, GETTEXT_PACKAGE);
159
data = init_appearance_data (&argc, &argv, option_context);
166
desktop_init (data, (const gchar **) wallpaper_files);
167
g_strfreev (wallpaper_files);
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);
175
g_signal_connect_after (w, "response",
176
(GCallback) main_window_response, data);
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");
182
if (start_page != NULL) {
185
page_name = g_strconcat (start_page, "_vbox", NULL);
188
w = appearance_capplet_get_widget (data, page_name);
193
nb = GTK_NOTEBOOK (appearance_capplet_get_widget (data, "main_notebook"));
194
pindex = gtk_notebook_page_num (nb, w);
196
gtk_notebook_set_current_page (nb, pindex);
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);
208
g_option_context_free (option_context);
210
/* start the mainloop */
212
gdk_threads_leave ();