changeset 3777:cbfc986d17d6

implement returning to the original GTK+ style after deselecting an Audacious skin with custom GTK+ style
author mf0102 <0102@gmx.at>
date Wed, 17 Oct 2007 19:55:28 +0200
parents 462f391ee02b
children 7f42752acf4d
files src/audacious/skin.c
diffstat 1 files changed, 22 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/skin.c	Wed Oct 17 18:28:17 2007 +0200
+++ b/src/audacious/skin.c	Wed Oct 17 19:55:28 2007 +0200
@@ -127,6 +127,8 @@
     {200, 200, 200}
 };
 
+static gchar *original_gtk_theme = NULL;
+
 static GdkBitmap *skin_create_transparent_mask(const gchar *,
                                                const gchar *,
                                                const gchar *,
@@ -1462,9 +1464,11 @@
 }
 
 static void
-skin_set_gtk_theme(Skin * skin, gboolean tmp_clean)
+skin_set_gtk_theme(GtkSettings * settings, Skin * skin, gboolean tmp_clean)
 {
-    GtkSettings *settings = gtk_settings_get_default();
+    if (original_gtk_theme == NULL)
+         g_object_get(settings, "gtk-theme-name", &original_gtk_theme, NULL);
+
     gchar *tmp = g_strdup_printf("%s/.themes/aud-%s", g_get_home_dir(),
                                  basename(skin->path));
 
@@ -1486,6 +1490,7 @@
 static gboolean
 skin_load_nolock(Skin * skin, const gchar * path, gboolean force)
 {
+    GtkSettings *settings;
     gchar *cpath, *gtkrcpath;
 
     g_return_val_if_fail(skin != NULL, FALSE);
@@ -1496,12 +1501,24 @@
         return FALSE;
    
     if (!force && skin->path && !strcmp(skin->path, path))
-	return FALSE;
+    return FALSE;
       
     skin_current_num++;
 
     skin->path = g_strdup(path);
 
+
+    settings = gtk_settings_get_default();
+    
+    if (original_gtk_theme != NULL)
+    {
+        gtk_settings_set_string_property(settings, "gtk-theme-name",
+                                         original_gtk_theme, "audacious");
+        g_free(original_gtk_theme);
+        original_gtk_theme = NULL;
+    }
+
+
     if (!file_is_archive(path)) {
         /* Parse the hints for this skin. */
         skin_parse_hints(skin, NULL);
@@ -1516,7 +1533,7 @@
 #ifndef _WIN32
         /* the way GTK does things can be very broken. --nenolod */
         if (gtkrcpath != NULL) {
-            skin_set_gtk_theme(skin, FALSE);
+            skin_set_gtk_theme(settings, skin, FALSE);
         }
 #endif
 
@@ -1545,7 +1562,7 @@
 #ifndef _WIN32
     /* the way GTK does things can be very broken. --nenolod */
     if (gtkrcpath != NULL) {
-        skin_set_gtk_theme(skin, TRUE);
+        skin_set_gtk_theme(settings, skin, TRUE);
     }
 #endif