2003-05-13 18:37:05 +00:00
|
|
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
|
|
|
|
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
|
|
|
/*
|
2003-05-13 18:37:05 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2007-02-07 17:49:09 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2005-05-22 15:46:45 +00:00
|
|
|
#include <glib/gi18n.h>
|
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
|
|
|
#include <gio/gio.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>
|
2007-02-07 17:49:09 +00:00
|
|
|
#include <libgnomeui/gnome-ui-init.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"
|
|
|
|
|
2007-02-07 17:49:09 +00:00
|
|
|
static gboolean
|
|
|
|
run_apply_font_dialog (GnomeThemeMetaInfo *theme)
|
2003-05-13 18:37:05 +00:00
|
|
|
{
|
2003-07-24 19:35:08 +00:00
|
|
|
gboolean apply_font = FALSE;
|
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
if (theme->application_font) {
|
2007-02-07 17:49:09 +00:00
|
|
|
GladeXML *font_xml;
|
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
font_xml = glade_xml_new (GNOMECC_GLADE_DIR "/apply-font.glade",
|
|
|
|
NULL, NULL);
|
|
|
|
if (font_xml) {
|
2007-02-07 17:49:09 +00:00
|
|
|
GtkWidget *font_dialog;
|
|
|
|
GtkWidget *font_sample;
|
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
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));
|
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
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
if (gtk_dialog_run (GTK_DIALOG(font_dialog)) == GTK_RESPONSE_OK)
|
|
|
|
apply_font = TRUE;
|
2007-02-07 17:49:09 +00:00
|
|
|
|
|
|
|
g_object_unref (font_xml);
|
2004-11-27 15:22:44 +00:00
|
|
|
} 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
|
|
|
}
|
2007-02-07 17:49:09 +00:00
|
|
|
return apply_font;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
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
|
|
|
GFile *file;
|
2007-02-07 17:49:09 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
file = g_file_new_for_path (arguments[0]);
|
2007-02-07 17:49:09 +00:00
|
|
|
g_strfreev (arguments);
|
|
|
|
|
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
|
|
|
gnome_theme_init ();
|
2007-02-07 17:49:09 +00:00
|
|
|
|
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
|
|
|
theme = gnome_theme_read_meta_theme (file);
|
|
|
|
g_object_unref (file);
|
2007-02-07 17:49:09 +00:00
|
|
|
|
|
|
|
if (!theme)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
apply_font = run_apply_font_dialog (theme);
|
2003-07-24 19:35:08 +00:00
|
|
|
|
2004-11-27 15:22:44 +00:00
|
|
|
gnome_meta_theme_set (theme);
|
2007-02-07 17:49:09 +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
|
|
|
}
|
2007-01-07 15:47:51 +00:00
|
|
|
|
2007-01-07 16:41:03 +00:00
|
|
|
g_object_unref (program);
|
2004-11-27 15:22:44 +00:00
|
|
|
return 0;
|
2007-02-07 17:49:09 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
g_object_unref (program);
|
|
|
|
return 1;
|
2003-05-13 18:37:05 +00:00
|
|
|
}
|