allow local themes in ~/.booh-themes
authorGuillaume Cottenceau <gcottenc@gmail.com>
Fri, 11 Jul 2008 15:54:07 +0000 (17:54 +0200)
committerGuillaume Cottenceau <gcottenc@gmail.com>
Fri, 11 Jul 2008 15:54:07 +0000 (17:54 +0200)
THEMES
bin/booh
bin/booh-backend
lib/booh/booh-lib.rb

diff --git a/THEMES b/THEMES
index bf463fb..c7917b5 100644 (file)
--- a/THEMES
+++ b/THEMES
@@ -24,6 +24,16 @@ Each theme is made of:
 - three metadata/screenshot-?.png files used to select theme in
   the GUI
 
+If you want to create a new theme, or make local modifications to a
+theme, just have them in your ~/.booh-themes directory. For example,
+to hack off "dark":
+
+# mkdir ~/.booh-themes
+# cp -a /usr/share/booh/themes/dark ~/.booh-themes/mine
+
+Use a different name than original theme names (here I picked the
+dummy name "mine", choose a better one).
+
 
                   [[ Skeleton files ]]
 
index 783e6a4..02512af 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -2721,7 +2721,7 @@ def theme_choose(current)
 
     dialog.vbox.add(sw = Gtk::ScrolledWindow.new(nil, nil).add(treeview).set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC))
 
-    ([ $FPATH + '/themes/simple' ] + (`find '#{$FPATH}/themes' -mindepth 1 -maxdepth 1 -type d`.find_all { |e| e !~ /simple$/ }.sort)).each { |dir|
+    ([ $FPATH + '/themes/simple' ] + (`find '#{$FPATH}/themes' ~/.booh-themes -mindepth 1 -maxdepth 1 -type d 2>/dev/null`.find_all { |e| e !~ /simple$/ }.sort)).each { |dir|
         dir.chomp!
         iter = model.append
         iter[0] = File.basename(dir)
index 2911fca..61bb820 100755 (executable)
@@ -427,9 +427,9 @@ def replace_line(surround, keyword, line)
 end
 
 def build_html_skeletons
-    $html_images     = File.open("#{$FPATH}/themes/#{$theme}/skeleton_image.html").readlines
-    $html_thumbnails = File.open("#{$FPATH}/themes/#{$theme}/skeleton_thumbnails.html").readlines
-    $html_index      = File.open("#{$FPATH}/themes/#{$theme}/skeleton_index.html").readlines
+    $html_images     = File.open("#{$themedir}/skeleton_image.html").readlines
+    $html_thumbnails = File.open("#{$themedir}/skeleton_thumbnails.html").readlines
+    $html_index      = File.open("#{$themedir}/skeleton_index.html").readlines
     for line in $html_images + $html_thumbnails + $html_index
         while line =~ /~~~(\w+)~~~/
             replace_line('~~~', $1, line)
@@ -895,21 +895,21 @@ def walk_source_dir
                 end
                 
                 #- copy any resource file that goes with the theme (css, images..)
-                themestuff = Dir.entries("#{$FPATH}/themes/#{$theme}").
+                themestuff = Dir.entries("#{$themedir}").
                                  find_all { |e| !%w(. .. skeleton_image.html skeleton_thumbnails.html skeleton_index.html metadata root CVS).include?(e) }
                 themestuff.each { |entry|
                     if !File.exists?(File.join(dest_dir, entry))
-                        psys("cp '#{$FPATH}/themes/#{$theme}/#{entry}' '#{dest_dir}'")
+                        psys("cp '#{$themedir}/#{entry}' '#{dest_dir}'")
                     end
                 }
 
                 #- copy any root-only resource file that goes with the theme (css, images..)
                 if xmldir.parent.name != 'dir'
-                    themestuff_root = Dir.entries("#{$FPATH}/themes/#{$theme}/root").
+                    themestuff_root = Dir.entries("#{$themedir}/root").
                                           find_all { |e| !%w(. .. CVS).include?(e) }
                     themestuff_root.each { |entry|
                         if !File.exists?(File.join(dest_dir, entry))
-                            psys("cp '#{$FPATH}/themes/#{$theme}/root/#{entry}' '#{dest_dir}'")
+                            psys("cp '#{$themedir}/root/#{entry}' '#{dest_dir}'")
                         end
                     }
                 end
@@ -1035,21 +1035,21 @@ def walk_source_dir
             end
 
             #- copy any resource file that goes with the theme (css, images..)
-            themestuff = Dir.entries("#{$FPATH}/themes/#{$theme}").
+            themestuff = Dir.entries("#{$themedir}").
                              find_all { |e| !%w(. .. skeleton_image.html skeleton_thumbnails.html skeleton_index.html metadata root CVS).include?(e) }
             themestuff.each { |entry|
                 if !File.exists?(File.join(dest_dir, entry))
-                    psys("cp '#{$FPATH}/themes/#{$theme}/#{entry}' '#{dest_dir}'")
+                    psys("cp '#{$themedir}/#{entry}' '#{dest_dir}'")
                 end
             }
             
             #- copy any root-only resource file that goes with the theme (css, images..)
             if xmldir.parent.name != 'dir'
-                themestuff_root = Dir.entries("#{$FPATH}/themes/#{$theme}/root").
+                themestuff_root = Dir.entries("#{$themedir}/root").
                                       find_all { |e| !%w(. .. CVS).include?(e) }
                 themestuff_root.each { |entry|
                     if !File.exists?(File.join(dest_dir, entry))
-                        psys("cp '#{$FPATH}/themes/#{$theme}/root/#{entry}' '#{dest_dir}'")
+                        psys("cp '#{$themedir}/root/#{entry}' '#{dest_dir}'")
                     end
                 }
             end
index 1678481..0235647 100644 (file)
@@ -142,11 +142,15 @@ module Booh
     def select_theme(name, limit_sizes, optimizefor32, nperrow)
         $theme = name
         msg 3, _("Selecting theme '%s'") % $theme
-        themedir = "#{$FPATH}/themes/#{$theme}"
-        if !File.directory?(themedir)
-            die_ _("Theme was not found (tried %s directory).") % themedir
+        $themedir = "#{$FPATH}/themes/#{$theme}"
+        if !File.directory?($themedir)
+            themedir2 = File.expand_path("~/.booh-themes/#{$theme}")
+            if !File.directory?(themedir2)
+                die_ _("Theme was not found (tried %s and %s directories).") % [ $themedir, themedir2 ]
+            end
+            $themedir = themedir2
         end
-        eval File.open("#{themedir}/metadata/parameters.rb").readlines.join
+        eval File.open("#{$themedir}/metadata/parameters.rb").readlines.join
 
         if limit_sizes
             if limit_sizes != 'all'