Author: kelnos
Date: 2009-03-15 00:01:26 +0000 (Sun, 15 Mar 2009)
New Revision: 29661

Modified:
   xfce-utils/trunk/NEWS
   xfce-utils/trunk/scripts/xfconf-migration-4.6.pl.in
Log:
ensure that there's a valid icon theme set after migration

Modified: xfce-utils/trunk/NEWS
===================================================================
--- xfce-utils/trunk/NEWS       2009-03-14 14:55:12 UTC (rev 29660)
+++ xfce-utils/trunk/NEWS       2009-03-15 00:01:26 UTC (rev 29661)
@@ -1,6 +1,13 @@
-4.6.0 (Xfce 4.6.0)
-==================
+4.6.1
+=====
 
+- Reset icon theme name if the migrated icon theme name (possibly 'Rodent')
+  doesn't exist anymore.
+
+
+4.6.0
+=====
+
 - Fix sysconfdir and datadir not being expanded properly in 
   xinitrc (bug #4924).
 - Export GTK_PATH variable in xinitrc so that GTK+ has a chance to find

Modified: xfce-utils/trunk/scripts/xfconf-migration-4.6.pl.in
===================================================================
--- xfce-utils/trunk/scripts/xfconf-migration-4.6.pl.in 2009-03-14 14:55:12 UTC 
(rev 29660)
+++ xfce-utils/trunk/scripts/xfconf-migration-4.6.pl.in 2009-03-15 00:01:26 UTC 
(rev 29661)
@@ -256,6 +256,80 @@
     return $mcs.'.xml';
 }
 
+sub icon_theme_exists
+{
+    my ($dirref,$themename) = @_;
+    my @dirs = @{$dirref};
+
+    foreach my $d (@dirs) {
+        return 1 if(-f "$d/$themename/index.theme");
+    }
+
+    return 0;
+}
+
+sub migrate_icon_theme
+{
+    my ($ref,$chan) = @_;
+    my %opts = %{$ref};
+    my $opt = 'Net/IconThemeName';
+
+    # we don't ship rodent anymore, so some distros cause it to be removed
+    # when xfce gets upgraded from 4.4 to 4.6.  arguably, they should be
+    # fixing this themselves, but i'd rather just stop the complaints.
+    # if the user still has rodent installed, we won't change anything.
+
+    return if(!defined($opts{$opt}));
+    my $val = $opts{$opt}->{'value'};
+
+    my @icondirs;
+    if(defined($ENV{'XDG_DATA_HOME'})) {
+        @icondirs = ( $ENV{'XDG_DATA_HOME'} . '/icons' );
+    } else {
+        @icondirs = ( $ENV{'HOME'} . '/.local/share/icons' );
+    }
+    if(defined($ENV{'XDG_DATA_DIRS'})) {
+        push(@icondirs, split(/:/, $ENV{'XDG_DATA_DIRS'}));
+    } else {
+        push(@icondirs, ( '/usr/share/icons', '/usr/local/share/icons' ));
+    }
+
+    if(!icon_theme_exists(\...@icondirs, $val)) {
+        $val = undef;
+        foreach my $itheme (('Tango', 'gnome', 'crystalsvg')) {
+            if(icon_theme_exists(\...@icondirs, $itheme)) {
+                $val = $itheme;
+                last;
+            }
+        }
+
+        if(!defined($val)) {
+            # pick the first one that is not 'hicolor'
+            foreach my $d (@icondirs) {
+                opendir(DIR, $d) and do {
+                    my @subdirs = grep { $_ ne 'hicolor' && -d "$d/$_" } 
readdir(DIR);
+                    foreach my $sd (@subdirs) {
+                        if(-f "$d/$sd/index.theme") {
+                            $val = $sd;
+                            last;
+                        }
+                    }
+                    closedir(DIR);
+                };
+                last if(defined($val));
+            }
+
+            if(!defined($val)) {
+                # ok, their system is kinda b0rked; not much we can do
+                warn("Couldn't find a suitable icon theme to migrate to");
+                return;
+            }
+        }
+    }
+
+    xfconf_set($chan, 'string', '/Net/IconThemeName', $val);
+}
+
 sub migrate_xsettings
 {
     my $mcs = 'gtk';
@@ -283,8 +357,7 @@
                      '/Net/CursorBlinkTime', 'int');
     save_xfconf_prop($ref, $chan, 'Net/DndDragThreshold',
                      '/Net/DndDragThreshold', 'int');
-    save_xfconf_prop($ref, $chan, 'Net/IconThemeName',
-                     '/Net/IconThemeName', 'string');
+    migrate_icon_theme($ref, $chan);
     save_xfconf_prop($ref, $chan, 'Net/ThemeName',
                      '/Net/ThemeName', 'string');
 

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to