summaryrefslogtreecommitdiff
path: root/capplets
diff options
context:
space:
mode:
Diffstat (limited to 'capplets')
-rw-r--r--capplets/appearance/Makefile.am2
-rw-r--r--capplets/appearance/appearance-main.c5
-rw-r--r--capplets/appearance/appearance-support.c106
-rw-r--r--capplets/appearance/appearance-support.h22
-rw-r--r--capplets/common/wm-common.c6
-rw-r--r--capplets/common/wm-common.h5
6 files changed, 144 insertions, 2 deletions
diff --git a/capplets/appearance/Makefile.am b/capplets/appearance/Makefile.am
index 5c5dc2ca..293c01ea 100644
--- a/capplets/appearance/Makefile.am
+++ b/capplets/appearance/Makefile.am
@@ -16,6 +16,8 @@ mate_appearance_properties_SOURCES = \
appearance-themes.h \
appearance-style.c \
appearance-style.h \
+ appearance-support.c \
+ appearance-support.h \
mate-wp-info.c \
mate-wp-info.h \
mate-wp-item.c \
diff --git a/capplets/appearance/appearance-main.c b/capplets/appearance/appearance-main.c
index 6ff41249..65e703ad 100644
--- a/capplets/appearance/appearance-main.c
+++ b/capplets/appearance/appearance-main.c
@@ -24,6 +24,7 @@
#include "appearance-font.h"
#include "appearance-themes.h"
#include "appearance-style.h"
+#include "appearance-support.h"
#include "theme-installer.h"
#include "theme-thumbnail.h"
#include "activate-settings-daemon.h"
@@ -90,6 +91,7 @@ main_window_response (GtkWidget *widget,
style_shutdown (data);
desktop_shutdown (data);
font_shutdown (data);
+ support_shutdown (data);
g_object_unref (data->thumb_factory);
g_object_unref (data->settings);
@@ -183,6 +185,9 @@ main (int argc, char **argv)
g_strfreev (wallpaper_files);
font_init (data);
+ /* init support for other window managers */
+ support_init (data);
+
/* prepare the main window */
w = appearance_capplet_get_widget (data, "appearance_window");
capplet_set_icon (w, "preferences-desktop-theme");
diff --git a/capplets/appearance/appearance-support.c b/capplets/appearance/appearance-support.c
new file mode 100644
index 00000000..220e8cfa
--- /dev/null
+++ b/capplets/appearance/appearance-support.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2012 Stefano Karapetsas
+ * Authors: Stefano Karapetsas <[email protected]>
+ * All Rights Reserved
+ *
+ * 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 details.
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "appearance.h"
+#include "wm-common.h"
+
+#include <glib.h>
+#include <gio/gio.h>
+
+static gboolean
+is_program_in_path (const char *program)
+{
+ char *tmp = g_find_program_in_path (program);
+ if (tmp != NULL)
+ {
+ g_free (tmp);
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+static gboolean
+metacity_is_running()
+{
+ gboolean is_running = FALSE;
+ gchar *current_wm = NULL;
+
+ current_wm = wm_common_get_current_window_manager ();
+
+ is_running = (g_strcmp0(current_wm, WM_COMMON_METACITY) == 0) ||
+ (g_strcmp0(current_wm, WM_COMMON_COMPIZ) == 0);
+
+ g_free (current_wm);
+
+ return is_running;
+}
+
+static void
+metacity_theme_apply(const gchar *theme)
+{
+ /* set theme, we use gconf and gsettings binaries to avoid schemas and versions issues */
+ if (is_program_in_path ("gconftool-2"))
+ {
+ gchar *gconf_cmd = g_strdup_printf("gconftool-2 --set --type string /apps/metacity/general/theme '%s'", theme);
+ g_spawn_command_line_async (gconf_cmd, NULL);
+ g_free (gconf_cmd);
+ }
+
+ if (is_program_in_path ("gsettings"))
+ {
+ gchar *gsettings_cmd = g_strdup_printf("gsettings set org.gnome.desktop.wm.preferences theme '%s'", theme);
+ g_spawn_command_line_async (gsettings_cmd, NULL);
+ g_free (gsettings_cmd);
+ }
+}
+
+static void
+marco_theme_changed(GSettings *settings, gchar *key, AppearanceData* data)
+{
+ gchar *theme = NULL;
+ if (metacity_is_running ())
+ {
+ theme = g_settings_get_string (settings, key);
+ metacity_theme_apply (theme);
+ g_free (theme);
+ }
+}
+
+void
+support_init(AppearanceData* data)
+{
+ /* needed for wm_common_get_current_window_manager() */
+ wm_common_update_window ();
+ /* GSettings signal */
+ g_signal_connect (data->marco_settings, "changed::" MARCO_THEME_KEY,
+ G_CALLBACK (marco_theme_changed), data);
+ /* apply theme at start */
+ if (metacity_is_running ())
+ marco_theme_changed (data->marco_settings, MARCO_THEME_KEY, data);
+}
+
+void
+support_shutdown(AppearanceData* data)
+{
+ /* nothing to do */
+}
diff --git a/capplets/appearance/appearance-support.h b/capplets/appearance/appearance-support.h
new file mode 100644
index 00000000..71f6f2a8
--- /dev/null
+++ b/capplets/appearance/appearance-support.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2012 Stefano Karapetsas
+ * Authors: Stefano Karapetsas <[email protected]>
+ * All Rights Reserved
+ *
+ * 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 details.
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+void support_init(AppearanceData* data);
+void support_shutdown(AppearanceData* data);
diff --git a/capplets/common/wm-common.c b/capplets/common/wm-common.c
index acf9e431..325a58d2 100644
--- a/capplets/common/wm-common.c
+++ b/capplets/common/wm-common.c
@@ -181,4 +181,8 @@ wm_common_register_window_manager_change (GFunc func,
XSync (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), False);
}
-
+void
+wm_common_update_window ()
+{
+ update_wm_window();
+}
diff --git a/capplets/common/wm-common.h b/capplets/common/wm-common.h
index 564c6b9e..baa51d3e 100644
--- a/capplets/common/wm-common.h
+++ b/capplets/common/wm-common.h
@@ -1,8 +1,10 @@
#ifndef WM_COMMON_H
#define WM_COMMON_H
-#define WM_COMMON_MARCO "Marco"
+#define WM_COMMON_MARCO "Marco"
#define WM_COMMON_SAWFISH "Sawfish"
+#define WM_COMMON_METACITY "Metacity"
+#define WM_COMMON_COMPIZ "compiz"
#define WM_COMMON_UNKNOWN "Unknown"
gchar *wm_common_get_current_window_manager (void);
@@ -12,6 +14,7 @@ char **wm_common_get_current_keybindings (void);
void wm_common_register_window_manager_change (GFunc func,
gpointer data);
+void wm_common_update_window (void);
#endif /* WM_COMMON_H */