2003-05-13 18:37:05 +00:00
|
|
|
/* -*- 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.
|
|
|
|
*/
|
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2005-05-22 15:46:45 +00:00
|
|
|
#include <glib/gi18n.h>
|
2004-11-27 15:22:44 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <glade/glade.h>
|
2003-07-21 21:35:24 +00:00
|
|
|
#include <libgnome/libgnome.h>
|
2003-05-13 18:37:05 +00:00
|
|
|
#include <libgnomevfs/gnome-vfs.h>
|
2003-07-20 22:31:17 +00:00
|
|
|
#include <gconf/gconf-client.h>
|
2003-05-13 18:37:05 +00:00
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
#include <gnome-theme-info.h>
|
|
|
|
#include <gnome-theme-apply.h>
|
2003-05-13 18:37:05 +00:00
|
|
|
|
2003-07-20 22:31:17 +00:00
|
|
|
#define FONT_KEY "/desktop/gnome/interface/font_name"
|
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
int main (int argc, char **argv)
|
2003-05-13 18:37:05 +00:00
|
|
|
{
|
2003-07-20 22:31:17 +00:00
|
|
|
GnomeVFSURI *uri;
|
|
|
|
GnomeThemeMetaInfo *theme;
|
2003-07-21 21:35:24 +00:00
|
|
|
GnomeProgram *program;
|
2003-07-24 19:35:08 +00:00
|
|
|
GladeXML *font_xml;
|
|
|
|
GtkWidget *font_dialog;
|
|
|
|
GtkWidget *font_sample;
|
|
|
|
gboolean apply_font = FALSE;
|
2003-07-21 21:35:24 +00:00
|
|
|
poptContext ctx;
|
|
|
|
gchar **args;
|
2004-11-27 15:22:44 +00:00
|
|
|
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
program = gnome_program_init ("ThemeApplier", "0.3.0", LIBGNOME_MODULE,
|
|
|
|
argc, argv, GNOME_PARAM_NONE);
|
2003-07-24 19:35:08 +00:00
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
g_object_get (program, GNOME_PARAM_POPT_CONTEXT, &ctx, NULL);
|
2003-07-21 21:35:24 +00:00
|
|
|
args = (char**) poptGetArgs(ctx);
|
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
if (!args) return 1;
|
|
|
|
|
|
|
|
gnome_vfs_init ();
|
2004-12-25 14:37:57 +00:00
|
|
|
gnome_theme_init (NULL);
|
2003-07-21 21:35:24 +00:00
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
uri = gnome_vfs_uri_new (args[0]);
|
|
|
|
g_assert (uri != NULL);
|
2003-05-13 18:37:05 +00:00
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
theme = gnome_theme_read_meta_theme (uri);
|
|
|
|
gnome_vfs_uri_unref (uri);
|
2003-05-13 18:37:05 +00:00
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
g_assert (theme != NULL);
|
2003-07-24 19:35:08 +00:00
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
if (theme->application_font) {
|
|
|
|
glade_init ();
|
|
|
|
font_xml = glade_xml_new (GNOMECC_GLADE_DIR "/apply-font.glade",
|
|
|
|
NULL, NULL);
|
|
|
|
if (font_xml) {
|
|
|
|
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));
|
2003-07-24 19:35:08 +00:00
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
if (gtk_dialog_run (GTK_DIALOG(font_dialog)) == GTK_RESPONSE_OK)
|
|
|
|
apply_font = TRUE;
|
|
|
|
} else {
|
2003-07-24 19:35:08 +00:00
|
|
|
/* if installation is borked, recover and apply the font */
|
2004-11-27 15:22:44 +00:00
|
|
|
apply_font = TRUE;
|
2003-07-24 19:35:08 +00:00
|
|
|
}
|
2004-11-27 15:22:44 +00:00
|
|
|
}
|
2003-07-24 19:35:08 +00:00
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
gnome_meta_theme_set (theme);
|
2003-07-24 19:35:08 +00:00
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
if (apply_font) {
|
2005-05-22 15:46:45 +00:00
|
|
|
GConfClient *client = gconf_client_get_default ();
|
2004-11-27 15:22:44 +00:00
|
|
|
gconf_client_set_string (client, FONT_KEY, theme->application_font, NULL);
|
2005-05-22 15:46:45 +00:00
|
|
|
g_object_unref (client);
|
2003-05-13 18:37:05 +00:00
|
|
|
}
|
2004-11-27 15:22:44 +00:00
|
|
|
|
|
|
|
return 0;
|
2003-05-13 18:37:05 +00:00
|
|
|
}
|