gnome-control-center/vfs-methods/themus/themus-theme-applier.c
Jens Granseuer d714ff7e49 port from gnome-vfs to gio (part of bug #524401)
2008-05-01  Jens Granseuer  <jensgr@gmx.net>

	* gnome-theme-apply.c:
	* gnome-theme-info.c: (get_file_type), (add_theme_to_hash_by_name),
	(get_theme_from_hash_by_name), (gnome_theme_read_meta_theme),
	(read_icon_theme), (gdk_pixbuf_from_xcursor_image),
	(read_cursor_theme), (handle_change_signal), (update_theme_index),
	(update_gtk2_index), (update_keybinding_index),
	(update_metacity_index), (update_common_theme_dir_index),
	(update_meta_theme_index), (update_icon_theme_index),
	(update_cursor_theme_index), (gtk2_dir_changed),
	(keybinding_dir_changed), (metacity_dir_changed),
	(common_theme_dir_changed), (common_icon_theme_dir_changed),
	(add_common_theme_dir_monitor),
	(add_common_icon_theme_dir_monitor),
	(remove_common_theme_dir_monitor),
	(remove_common_icon_theme_dir_monitor), (top_theme_dir_changed),
	(top_icon_theme_dir_changed), (real_add_top_theme_dir_monitor),
	(add_top_theme_dir_monitor), (add_top_icon_theme_dir_monitor),
	(gnome_theme_init):
	* gnome-theme-info.h:
	* gnome-theme-test.c: (main): port from gnome-vfs to gio (part of
	bug #524401)

2008-05-01  Jens Granseuer  <jensgr@gmx.net>

	* appearance-themes.c: (themes_init): update for changes in the
	theme-info API

2008-05-01  Jens Granseuer  <jensgr@gmx.net>

	* theme-method.c: (vfs_module_init):
	* themus-properties-view.c: (themus_properties_view_init),
	(themus_properties_view_set_location):
	* themus-theme-applier.c: (main): update users of the theme-info
	API

svn path=/trunk/; revision=8681
2008-05-01 09:08:07 +00:00

137 lines
3.6 KiB
C

/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* 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 av.
*
* 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 <stdlib.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <libgnome/libgnome.h>
#include <libgnomeui/gnome-ui-init.h>
#include <gconf/gconf-client.h>
#include <gnome-theme-info.h>
#include <gnome-theme-apply.h>
#define FONT_KEY "/desktop/gnome/interface/font_name"
static gboolean
run_apply_font_dialog (GnomeThemeMetaInfo *theme)
{
gboolean apply_font = FALSE;
if (theme->application_font) {
GladeXML *font_xml;
font_xml = glade_xml_new (GNOMECC_GLADE_DIR "/apply-font.glade",
NULL, NULL);
if (font_xml) {
GtkWidget *font_dialog;
GtkWidget *font_sample;
font_dialog = glade_xml_get_widget (font_xml, "ApplyFontAlert");
font_sample = glade_xml_get_widget (font_xml, "font_sample");
gtk_label_set_markup (GTK_LABEL (font_sample),
g_strconcat ("<span font_desc=\"",
theme->application_font,
"\">",
/* translators: you may want to include non-western chars here */
_("ABCDEFG"),
"</span>",
NULL));
if (gtk_dialog_run (GTK_DIALOG(font_dialog)) == GTK_RESPONSE_OK)
apply_font = TRUE;
g_object_unref (font_xml);
} else {
/* if installation is borked, recover and apply the font */
apply_font = TRUE;
}
}
return apply_font;
}
int
main (int argc, char **argv)
{
GFile *file;
GnomeThemeMetaInfo *theme;
GnomeProgram *program;
gboolean apply_font;
GOptionContext *context;
gchar **arguments = NULL;
const GOptionEntry options[] = {
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &arguments, NULL, N_("[FILE]") },
{NULL}
};
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
context = g_option_context_new ("- GNOME Theme Applier");
#if GLIB_CHECK_VERSION (2, 12, 0)
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
#endif
g_option_context_add_main_entries (context, options, NULL);
program = gnome_program_init ("themus-theme-applier", VERSION,
LIBGNOMEUI_MODULE,
argc, argv,
GNOME_PARAM_GOPTION_CONTEXT, context,
GNOME_PARAM_NONE);
if (!arguments || g_strv_length (arguments) != 1) {
/* FIXME: print help once bug 336089 is fixed */
g_strfreev (arguments);
goto error;
}
file = g_file_new_for_path (arguments[0]);
g_strfreev (arguments);
gnome_theme_init ();
theme = gnome_theme_read_meta_theme (file);
g_object_unref (file);
if (!theme)
goto error;
apply_font = run_apply_font_dialog (theme);
gnome_meta_theme_set (theme);
if (apply_font) {
GConfClient *client = gconf_client_get_default ();
gconf_client_set_string (client, FONT_KEY, theme->application_font, NULL);
g_object_unref (client);
}
g_object_unref (program);
return 0;
error:
g_object_unref (program);
return 1;
}