allow to select the theme from the GUI
authorgc <gc>
Sun, 17 Apr 2005 17:23:33 +0000 (17:23 +0000)
committergc <gc>
Sun, 17 Apr 2005 17:23:33 +0000 (17:23 +0000)
THEMES [new file with mode: 0644]
bin/booh
bin/booh-gui
data/booh/themes/simple/metadata/parameters.rb [moved from data/booh/themes/simple/parameters.rb with 100% similarity]
data/booh/themes/simple/metadata/screenshot-1.png [new file with mode: 0644]
data/booh/themes/simple/metadata/screenshot-2.png [new file with mode: 0644]
data/booh/themes/simple/metadata/screenshot-3.png [new file with mode: 0644]
lib/booh/booh-lib.rb

diff --git a/THEMES b/THEMES
new file mode 100644 (file)
index 0000000..ea88f87
--- /dev/null
+++ b/THEMES
@@ -0,0 +1,14 @@
+                Screenshots
+
+Each theme must export three screenshots, used to select theme in
+the GUI. First screenshot demonstrates the "index" page, second
+one the "thumbnails" page, and thirs one the "image" page.
+
+To keep a correct ratio between themes, to do your screenshot,
+first resize your browser so that the webpage will use a
+rectangular area of 640x480; then resize it 192x144.
+
+It would be best if the screenshots would show the same contents,
+so just send me your theme if you create a new one and I'll do
+the screenshots.
+
index 895c6e2..778bcd2 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -425,7 +425,7 @@ def walk_source_dir
         if !$forgui
             #- copy any resource file that goes with the theme (css, images..)
             for entry in Dir.entries("#{$FPATH}/themes/#{$theme}")
-                if !%w(. .. skeleton_image.html skeleton_thumbnails.html skeleton_index.html parameters.rb CVS).include?(entry)
+                if !%w(. .. skeleton_image.html skeleton_thumbnails.html skeleton_index.html metadata CVS).include?(entry)
                     if !File.exists?("#{dest_dir}/#{entry}")
                         psys("cp '#{$FPATH}/themes/#{$theme}/#{entry}' '#{dest_dir}'")
                     end
index 50d463b..b2745dc 100755 (executable)
@@ -1098,6 +1098,55 @@ def change_dir
     end
 end
 
+def pixbuf_or_nil(filename)
+    begin
+        return Gdk::Pixbuf.new(filename)
+    rescue
+        return nil
+    end
+end
+
+def theme_choose(current)
+    dialog = Gtk::Dialog.new(utf8(_("Select your preferred theme")),
+                             $main_window,
+                             Gtk::Dialog::MODAL | Gtk::Dialog::DESTROY_WITH_PARENT,
+                             [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK],
+                             [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL])
+
+    model = Gtk::ListStore.new(String, Gdk::Pixbuf, Gdk::Pixbuf, Gdk::Pixbuf)
+    treeview = Gtk::TreeView.new(model).set_rules_hint(true)
+    treeview.append_column(Gtk::TreeViewColumn.new(utf8(_("Theme name")), Gtk::CellRendererText.new, { :text => 0 }).set_alignment(0.5).set_spacing(5))
+    treeview.append_column(Gtk::TreeViewColumn.new(utf8(_("Sub-albums page look")), Gtk::CellRendererPixbuf.new, { :pixbuf => 1 }).set_alignment(0.5).set_spacing(5))
+    treeview.append_column(Gtk::TreeViewColumn.new(utf8(_("Thumbnails page look")), Gtk::CellRendererPixbuf.new, { :pixbuf => 2 }).set_alignment(0.5).set_spacing(5))
+    treeview.append_column(Gtk::TreeViewColumn.new(utf8(_("Fullscreen page look")), Gtk::CellRendererPixbuf.new, { :pixbuf => 3 }).set_alignment(0.5).set_spacing(5))
+    treeview.append_column(Gtk::TreeViewColumn.new('', Gtk::CellRendererText.new, {}))
+
+    dialog.vbox.add(sw = Gtk::ScrolledWindow.new(nil, nil).add(treeview).set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC))
+
+    `find '#{$FPATH}/themes' -mindepth 1 -maxdepth 1 -type d`.each { |dir|
+        dir.chomp!
+        iter = model.append
+        iter[0] = File.basename(dir)
+        iter[1] = pixbuf_or_nil("#{dir}/metadata/screenshot-1.png")
+        iter[2] = pixbuf_or_nil("#{dir}/metadata/screenshot-2.png")
+        iter[3] = pixbuf_or_nil("#{dir}/metadata/screenshot-3.png")
+        if File.basename(dir) == current
+            treeview.selection.select_iter(iter)
+        end
+    }
+
+    dialog.set_default_size(700, 400)
+    dialog.vbox.show_all
+    dialog.run { |response|
+        iter = treeview.selection.selected
+        dialog.destroy
+        if response == Gtk::Dialog::RESPONSE_OK && iter
+            return model.get_value(iter, 0)
+        end
+    }
+    return nil
+end
+
 def open_file(filename)
 
     $filename = nil
@@ -1225,6 +1274,12 @@ def new_album
     tbl.attach(conf_browse = Gtk::Button.new(utf8(_("browse..."))),
                2, 3, 2, 3, Gtk::SHRINK, Gtk::SHRINK, 2, 2)
 
+    frame2 = Gtk::Frame.new(utf8(_("Configuration"))).add(tbl = Gtk::Table.new(0, 0, false))
+    tbl.attach(Gtk::Label.new(utf8(_("Theme: "))),
+               0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 2, 2)
+    tbl.attach(theme_button = Gtk::Button.new($config['default-theme'] || 'simple'),
+               1, 2, 0, 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
+
     src_browse.signal_connect('clicked') {
         fc = Gtk::FileChooserDialog.new(utf8(_("Select the directory of images/videos")),
                                         nil,
@@ -1267,7 +1322,14 @@ def new_album
         fc.destroy
     }
 
+    theme_button.signal_connect('clicked') {
+        if newtheme = theme_choose(theme_button.label)
+            theme_button.label = newtheme
+        end
+    }
+
     dialog.vbox.add(frame1)
+    dialog.vbox.add(frame2)
     dialog.window_position = Gtk::Window::POS_MOUSE
     dialog.show_all
 
@@ -1307,12 +1369,13 @@ def new_album
     srcdir = from_utf8(src.text)
     destdir = from_utf8(dest.text)
     configskel = from_utf8(conf.text)
+    theme = theme_button.label
     dialog.destroy
 
     if ok
         button, w8 = wait_message($main_window, utf8(_("Please wait while scanning source directory...")))
         backend = Thread.new {
-            cmd = "booh --source #{srcdir} --destination #{destdir} --config-skel #{configskel} --for-gui --verbose-level #{$verbose_level}"
+            cmd = "booh --source #{srcdir} --destination #{destdir} --config-skel #{configskel} --for-gui --verbose-level #{$verbose_level} --theme #{theme}"
             if $config['mproc']
                 cmd += " --mproc #{$config['mproc'].to_i}"
             end
diff --git a/data/booh/themes/simple/metadata/screenshot-1.png b/data/booh/themes/simple/metadata/screenshot-1.png
new file mode 100644 (file)
index 0000000..f6ef224
Binary files /dev/null and b/data/booh/themes/simple/metadata/screenshot-1.png differ
diff --git a/data/booh/themes/simple/metadata/screenshot-2.png b/data/booh/themes/simple/metadata/screenshot-2.png
new file mode 100644 (file)
index 0000000..536e1f1
Binary files /dev/null and b/data/booh/themes/simple/metadata/screenshot-2.png differ
diff --git a/data/booh/themes/simple/metadata/screenshot-3.png b/data/booh/themes/simple/metadata/screenshot-3.png
new file mode 100644 (file)
index 0000000..1c51e36
Binary files /dev/null and b/data/booh/themes/simple/metadata/screenshot-3.png differ
index 72a4c2e..efbf1ea 100644 (file)
@@ -86,7 +86,7 @@ module Booh
         if !File.directory?(themedir)
             die _("Theme was not found (tried %s directory).") % themedir
         end
-        require "#{themedir}/parameters.rb"
+        require "#{themedir}/metadata/parameters.rb"
         $default_size = $images_size.detect { |sizeobj| sizeobj['default'] }
     end