2
* Copyright (C) 2012 Stefano Karapetsas
3
* Authors: Stefano Karapetsas <stefano@karapetsas.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License along
17
* with this program; if not, write to the Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
#include "appearance.h"
22
#include "wm-common.h"
28
is_program_in_path (const char *program)
30
char *tmp = g_find_program_in_path (program);
45
gboolean is_running = FALSE;
46
gchar *current_wm = NULL;
48
current_wm = wm_common_get_current_window_manager ();
50
is_running = (g_strcmp0(current_wm, WM_COMMON_METACITY) == 0) ||
51
(g_strcmp0(current_wm, WM_COMMON_COMPIZ_OLD) == 0) ||
52
(g_strcmp0(current_wm, WM_COMMON_COMPIZ) == 0);
60
metacity_theme_apply(const gchar *theme, const gchar *font)
62
/* set theme, we use gconf and gsettings binaries to avoid schemas and versions issues */
63
if (is_program_in_path ("gconftool-2"))
65
gchar *gconf_cmd = NULL;
67
gconf_cmd = g_strdup_printf("gconftool-2 --set --type string /apps/metacity/general/theme '%s'", theme);
68
g_spawn_command_line_async (gconf_cmd, NULL);
71
gconf_cmd = g_strdup_printf("gconftool-2 --set --type string /apps/metacity/general/titlebar_font '%s'", font);
72
g_spawn_command_line_async (gconf_cmd, NULL);
76
if (is_program_in_path ("gsettings"))
78
gchar *gsettings_cmd = NULL;
80
gsettings_cmd = g_strdup_printf("gsettings set org.gnome.desktop.wm.preferences theme '%s'", theme);
81
g_spawn_command_line_async (gsettings_cmd, NULL);
82
g_free (gsettings_cmd);
84
gsettings_cmd = g_strdup_printf("gsettings set org.gnome.desktop.wm.preferences titlebar-font '%s'", font);
85
g_spawn_command_line_async (gsettings_cmd, NULL);
86
g_free (gsettings_cmd);
92
marco_theme_changed(GSettings *settings, gchar *key, AppearanceData* data)
96
if (metacity_is_running ())
98
theme = g_settings_get_string (settings, MARCO_THEME_KEY);
99
font = g_settings_get_string (settings, WINDOW_TITLE_FONT_KEY);
100
metacity_theme_apply (theme, font);
107
support_init(AppearanceData* data)
109
/* needed for wm_common_get_current_window_manager() */
110
wm_common_update_window ();
111
/* GSettings signals */
112
g_signal_connect (data->marco_settings, "changed::" MARCO_THEME_KEY,
113
G_CALLBACK (marco_theme_changed), data);
114
g_signal_connect (data->marco_settings, "changed::" WINDOW_TITLE_FONT_KEY,
115
G_CALLBACK (marco_theme_changed), data);
116
/* apply theme at start */
117
if (metacity_is_running ())
118
marco_theme_changed (data->marco_settings, NULL, data);
122
support_shutdown(AppearanceData* data)