1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
/* -*- mode: C; c-basic-offset: 4 -*-
* themus - utilities for MATE 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
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <mateconf/mateconf-client.h>
#include <mate-wm-manager.h>
#include "mate-theme-apply.h"
#include "gtkrc-utils.h"
#define GTK_THEME_KEY "/desktop/mate/interface/gtk_theme"
#define COLOR_SCHEME_KEY "/desktop/mate/interface/gtk_color_scheme"
#define ICON_THEME_KEY "/desktop/mate/interface/icon_theme"
#define FONT_KEY "/desktop/mate/interface/font_name"
#define CURSOR_FONT_KEY "/desktop/mate/peripherals/mouse/cursor_font"
#define CURSOR_THEME_KEY "/desktop/mate/peripherals/mouse/cursor_theme"
#define CURSOR_SIZE_KEY "/desktop/mate/peripherals/mouse/cursor_size"
#define NOTIFICATION_THEME_KEY "/apps/notification-daemon/theme"
#define compare(x,y) (!x && y) || (x && !y) || (x && y && strcmp (x, y))
void
mate_meta_theme_set (MateThemeMetaInfo *meta_theme_info)
{
MateConfClient *client;
gchar *old_key;
gint old_key_int;
MateWindowManager *window_manager;
MateWMSettings wm_settings;
mate_wm_manager_init ();
window_manager = mate_wm_manager_get_current (gdk_display_get_default_screen (gdk_display_get_default ()));
client = mateconf_client_get_default ();
/* Set the gtk+ key */
old_key = mateconf_client_get_string (client, GTK_THEME_KEY, NULL);
if (compare (old_key, meta_theme_info->gtk_theme_name))
{
mateconf_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 = mateconf_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, "") ||
mate_theme_color_scheme_equal (newval, gtkcols))
{
mateconf_client_unset (client, COLOR_SCHEME_KEY, NULL);
}
else
{
mateconf_client_set_string (client, COLOR_SCHEME_KEY, newval, NULL);
}
g_free (gtkcols);
}
g_free (old_key);
/* Set the wm key */
wm_settings.flags = MATE_WM_SETTING_THEME;
wm_settings.theme = meta_theme_info->marco_theme_name;
if (window_manager)
mate_window_manager_change_settings (window_manager, &wm_settings);
/* set the icon theme */
old_key = mateconf_client_get_string (client, ICON_THEME_KEY, NULL);
if (compare (old_key, meta_theme_info->icon_theme_name))
{
mateconf_client_set_string (client, ICON_THEME_KEY, meta_theme_info->icon_theme_name, NULL);
}
g_free (old_key);
/* set the notification theme */
if (meta_theme_info->notification_theme_name != NULL)
{
old_key = mateconf_client_get_string (client, NOTIFICATION_THEME_KEY, NULL);
if (compare (old_key, meta_theme_info->notification_theme_name))
{
mateconf_client_set_string (client, NOTIFICATION_THEME_KEY, meta_theme_info->notification_theme_name, NULL);
}
g_free (old_key);
}
/* Set the cursor theme key */
#ifdef HAVE_XCURSOR
old_key = mateconf_client_get_string (client, CURSOR_THEME_KEY, NULL);
if (compare (old_key, meta_theme_info->cursor_theme_name))
{
mateconf_client_set_string (client, CURSOR_THEME_KEY, meta_theme_info->cursor_theme_name, NULL);
}
old_key_int = mateconf_client_get_int (client, CURSOR_SIZE_KEY, NULL);
if (old_key_int != meta_theme_info->cursor_size)
{
mateconf_client_set_int (client, CURSOR_SIZE_KEY, meta_theme_info->cursor_size, NULL);
}
#else
old_key = mateconf_client_get_string (client, CURSOR_FONT_KEY, NULL);
if (compare (old_key, meta_theme_info->cursor_theme_name))
{
mateconf_client_set_string (client, CURSOR_FONT_KEY, meta_theme_info->cursor_theme_name, NULL);
}
#endif
g_free (old_key);
g_object_unref (client);
}
|