gnome-control-center/capplets/common/gnome-theme-apply.c

121 lines
4.2 KiB
C
Raw Normal View History

/* -*- mode: C; c-basic-offset: 4 -*-
* themus - utilities for GNOME themes
* Copyright (C) 2002 Jonathan Blandford <aes@gnome.org>
*
* This library 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.1 of the License, or (at your option) any later version.
*
* This library 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 details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <string.h>
#include <gconf/gconf-client.h>
#include <gnome-wm-manager.h>
#include "gnome-theme-apply.h"
#include "gtkrc-utils.h"
#define GTK_THEME_KEY "/desktop/gnome/interface/gtk_theme"
#define COLOR_SCHEME_KEY "/desktop/gnome/interface/gtk_color_scheme"
#define ICON_THEME_KEY "/desktop/gnome/interface/icon_theme"
#define FONT_KEY "/desktop/gnome/interface/font_name"
#define CURSOR_FONT_KEY "/desktop/gnome/peripherals/mouse/cursor_font"
#define CURSOR_THEME_KEY "/desktop/gnome/peripherals/mouse/cursor_theme"
#define CURSOR_SIZE_KEY "/desktop/gnome/peripherals/mouse/cursor_size"
#define compare(x,y) (!x && y) || (x && !y) || (x && y && strcmp (x, y))
void
gnome_meta_theme_set (GnomeThemeMetaInfo *meta_theme_info)
{
GConfClient *client;
gchar *old_key;
gint old_key_int;
GnomeWindowManager *window_manager;
GnomeWMSettings wm_settings;
gnome_wm_manager_init ();
window_manager = gnome_wm_manager_get_current (gdk_display_get_default_screen (gdk_display_get_default ()));
client = gconf_client_get_default ();
/* Set the gtk+ key */
old_key = gconf_client_get_string (client, GTK_THEME_KEY, NULL);
if (compare (old_key, meta_theme_info->gtk_theme_name))
{
gconf_client_set_string (client, GTK_THEME_KEY, meta_theme_info->gtk_theme_name, NULL);
}
g_free (old_key);
/* Set the color scheme key */
old_key = gconf_client_get_string (client, COLOR_SCHEME_KEY, NULL);
if (compare (old_key, meta_theme_info->gtk_color_scheme))
{
/* only save the color scheme if it differs from the default
scheme for the selected gtk theme */
gchar *newval, *gtkcols;
newval = meta_theme_info->gtk_color_scheme;
gtkcols = gtkrc_get_color_scheme_for_theme (meta_theme_info->gtk_theme_name);
if (newval == NULL || !strcmp (newval, "") ||
gnome_theme_color_scheme_equal (newval, gtkcols))
{
gconf_client_unset (client, COLOR_SCHEME_KEY, NULL);
}
else
{
gconf_client_set_string (client, COLOR_SCHEME_KEY, newval, NULL);
}
g_free (gtkcols);
}
g_free (old_key);
/* Set the wm key */
wm_settings.flags = GNOME_WM_SETTING_THEME;
wm_settings.theme = meta_theme_info->metacity_theme_name;
if (window_manager)
gnome_window_manager_change_settings (window_manager, &wm_settings);
/* set the icon theme */
old_key = gconf_client_get_string (client, ICON_THEME_KEY, NULL);
if (compare (old_key, meta_theme_info->icon_theme_name))
{
gconf_client_set_string (client, ICON_THEME_KEY, meta_theme_info->icon_theme_name, NULL);
}
g_free (old_key);
/* Set the cursor theme key */
#ifdef HAVE_XCURSOR
old_key = gconf_client_get_string (client, CURSOR_THEME_KEY, NULL);
if (compare (old_key, meta_theme_info->cursor_theme_name))
{
gconf_client_set_string (client, CURSOR_THEME_KEY, meta_theme_info->cursor_theme_name, NULL);
}
old_key_int = gconf_client_get_int (client, CURSOR_SIZE_KEY, NULL);
if (old_key_int != meta_theme_info->cursor_size)
{
gconf_client_set_int (client, CURSOR_SIZE_KEY, meta_theme_info->cursor_size, NULL);
}
#else
old_key = gconf_client_get_string (client, CURSOR_FONT_KEY, NULL);
if (compare (old_key, meta_theme_info->cursor_theme_name))
{
gconf_client_set_string (client, CURSOR_FONT_KEY, meta_theme_info->cursor_theme_name, NULL);
}
#endif
g_free (old_key);
Cleanup of gconf and a few other things, patch from Kjartan Maraas 2005-05-22 Sebastien Bacher <seb128@debian.org> * ChangeLog capplets/about-me/e-image-chooser.c capplets/accessibility/at-properties/at-startup-session.h capplets/accessibility/keyboard/accessibility-keyboard.c capplets/background/gnome-wp-info.c capplets/common/gconf-property-editor.c capplets/common/gnome-theme-apply.c capplets/default-applications/gnome-default-applications-properties.c capplets/keybindings/gnome-keybinding-properties.c capplets/keyboard/gnome-keyboard-properties.c capplets/mouse/gnome-mouse-properties.c capplets/network/gnome-network-preferences.c capplets/sound/sound-properties-capplet.c capplets/theme-switcher/gnome-theme-details.c capplets/theme-switcher/gnome-theme-manager.c capplets/ui-properties/gnome-ui-properties.c capplets/windows/gnome-window-properties.c gnome-settings-daemon/factory.c gnome-settings-daemon/gnome-settings-accessibility-keyboard.c gnome-settings-daemon/gnome-settings-background.c gnome-settings-daemon/gnome-settings-daemon.c gnome-settings-daemon/gnome-settings-daemon.h gnome-settings-daemon/gnome-settings-font.c gnome-settings-daemon/gnome-settings-keybindings.c gnome-settings-daemon/gnome-settings-keybindings.h gnome-settings-daemon/gnome-settings-keyboard-xkb.c gnome-settings-daemon/gnome-settings-keyboard.c gnome-settings-daemon/gnome-settings-locate-pointer.h gnome-settings-daemon/gnome-settings-mouse.c gnome-settings-daemon/gnome-settings-multimedia-keys.c gnome-settings-daemon/gnome-settings-screensaver.c gnome-settings-daemon/gnome-settings-sound.c gnome-settings-daemon/gnome-settings-xmodmap.c gnome-settings-daemon/gnome-settings-xrdb.c gnome-settings-daemon/gnome-settings-xsettings.c libbackground/applier.c libbackground/applier.h libbackground/preferences.c libsounds/sound-properties.c libsounds/sound-view.h libwindow-settings/gnome-wm-manager.c libwindow-settings/metacity-window-manager.c typing-break/drw-break-window.c typing-break/drw-utils.h typing-break/drwright.c vfs-methods/fontilus/font-view.c vfs-methods/themus/themus-theme-applier.c: Cleanup of gconf and a few other things, patch from Kjartan Maraas <kmaraas@gnome.org> (Closes: #301945).
2005-05-22 15:46:45 +00:00
g_object_unref (client);
}