configurable thumbnails height
authorgc <gc>
Tue, 1 Apr 2008 21:46:04 +0000 (21:46 +0000)
committergc <gc>
Tue, 1 Apr 2008 21:46:04 +0000 (21:46 +0000)
bin/booh-classifier

index 456becf..840e5be 100644 (file)
@@ -130,6 +130,7 @@ def read_config
     $config['preload-distance'] ||= '5'
     $config['cache-memory-use'] ||= 'memfree_80%'
     $config['rotate-set-exif'] ||= 'true'
+    $config['thumbnails-height'] ||= '64'
     set_cache_memory_use_figure
 end
 
@@ -234,10 +235,9 @@ class Label
 end
 
 class Entry
-    @@thumbnails_height = 64
     @@max_width = nil
     def Entry.thumbnails_height
-        return @@thumbnails_height
+        return $config['thumbnails-height'].to_i
     end
 
     attr_accessor :path, :guipath, :type, :angle, :button, :image, :alignment, :removed, :labeled
@@ -310,19 +310,19 @@ class Entry
         if @pixbuf_thumbnail.nil?
             if @pixbuf_main
                 msg 3, ">>> pixbuf_thumbnail from main #{path}"
-                @pixbuf_thumbnail = @pixbuf_main.scale(@pixbuf_main.width * (@@thumbnails_height.to_f/@pixbuf_main.height), @@thumbnails_height, Gdk::Pixbuf::INTERP_BILINEAR)
+                @pixbuf_thumbnail = @pixbuf_main.scale(@pixbuf_main.width * (Entry.thumbnails_height.to_f/@pixbuf_main.height), Entry.thumbnails_height, Gdk::Pixbuf::INTERP_BILINEAR)
             else
                 msg 3, ">>> pixbuf_thumbnail from file #{path}"
                 @pixbuf_thumbnail = load_into_pixbuf_at_size(false) { |w, h|
                     if @angle == 0
-                        if h > @@thumbnails_height
-                            [ w * @@thumbnails_height.to_f/h, @@thumbnails_height ]
+                        if h > Entry.thumbnails_height
+                            [ w * Entry.thumbnails_height.to_f/h, Entry.thumbnails_height ]
                         else
                             [ w, h ]
                         end
                     else
-                        if w > @@thumbnails_height
-                            [ @@thumbnails_height, h * @@thumbnails_height.to_f/w ]
+                        if w > Entry.thumbnails_height
+                            [ Entry.thumbnails_height, h * Entry.thumbnails_height.to_f/w ]
                         else
                             [ w, h ]
                         end
@@ -1450,30 +1450,42 @@ def preferences
                              [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL])
 
     tooltips = Gtk::Tooltips.new
-    
+
+    table_y = 0
+
     dialog.vbox.add(tbl = Gtk::Table.new(0, 0, false))
     tbl.attach(Gtk::Alignment.new(1, 0.5, 0, 0).add(Gtk::Label.new.set_markup(utf8(_("Command for watching videos: ")))),
-               0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
+               0, 1, table_y, table_y + 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tbl.attach(Gtk::Alignment.new(0, 0.5, 1, 0).add(video_viewer_entry = Gtk::Entry.new.set_text($config['video-viewer']).set_size_request(250, -1)),
-               1, 2, 0, 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
+               1, 2, table_y, table_y + 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tooltips.set_tip(video_viewer_entry, utf8(_("Use %f to specify the filename;\nfor example: /usr/bin/mplayer %f")), nil)
 
+    table_y += 1
     tbl.attach(Gtk::Alignment.new(1, 0.5, 0, 0).add(Gtk::Label.new.set_markup(utf8(_("Browser's command: ")))),
-               0, 1, 1, 2, Gtk::FILL, Gtk::SHRINK, 2, 2)
+               0, 1, table_y, table_y + 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tbl.attach(Gtk::Alignment.new(0, 0.5, 1, 0).add(browser_entry = Gtk::Entry.new.set_text($config['browser'])),
-               1, 2, 1, 2, Gtk::FILL, Gtk::SHRINK, 2, 2)
+               1, 2, table_y, table_y + 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tooltips.set_tip(browser_entry, utf8(_("Use %f to specify the filename;\nfor example: /usr/bin/mozilla-firefox -remote 'openURL(%f,new-window)' || /usr/bin/mozilla-firefox %f")), nil)
 
+    table_y += 1
+    tbl.attach(Gtk::Alignment.new(1, 0.5, 0, 0).add(Gtk::Label.new.set_markup(utf8(_("Thumbnails height: ")))),
+               0, 1, table_y, table_y + 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
+    tbl.attach(Gtk::Alignment.new(0, 0.5, 1, 0).add(thumbnails_height = Gtk::SpinButton.new(32, 256, 16).set_value($config['thumbnails-height'].to_i)),
+               1, 2, table_y, table_y + 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
+    tooltips.set_tip(thumbnails_height, utf8(_("The desired height for the thumbnails line on the bottom")), nil)
+
+    table_y += 1
     tbl.attach(Gtk::Alignment.new(1, 0.5, 0, 0).add(Gtk::Label.new.set_markup(utf8(_("Preloading distance: ")))),
-               0, 1, 2, 3, Gtk::FILL, Gtk::SHRINK, 2, 2)
+               0, 1, table_y, table_y + 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tbl.attach(Gtk::Alignment.new(0, 0.5, 1, 0).add(preload_distance = Gtk::SpinButton.new(0, 50, 1).set_value($config['preload-distance'].to_i)),
-               1, 2, 2, 3, Gtk::FILL, Gtk::SHRINK, 2, 2)
+               1, 2, table_y, table_y + 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tooltips.set_tip(preload_distance, utf8(_("Amount of pictures preloaded left and right to the currently shown")), nil)
 
+    table_y += 1
     tbl.attach(Gtk::Alignment.new(1, 0.5, 0, 0).add(Gtk::Label.new.set_markup(utf8(_("Cache memory use: ")))),
-               0, 1, 3, 4, Gtk::FILL, Gtk::SHRINK, 2, 2)
+               0, 1, table_y, table_y + 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tbl.attach(Gtk::Alignment.new(0, 0.5, 1, 0).add(cache_vbox = Gtk::VBox.new(false, 0)),
-               1, 2, 3, 4, Gtk::FILL, Gtk::SHRINK, 2, 2)
+               1, 2, table_y, table_y + 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
     cache_vbox.pack_start(Gtk::HBox.new(false, 0).pack_start(cache_memfree_radio = Gtk::RadioButton.new(''), false, false).
                                                   pack_start(cache_memfree_spin = Gtk::SpinButton.new(0, 100, 10), false, false).
                                                   pack_start(cache_memfree_label = Gtk::Label.new(utf8(_("% of free memory"))), false, false), false, false)
@@ -1499,8 +1511,9 @@ def preferences
         cache_specify_spin.value = $config['cache-memory-use'].to_i
     end
 
+    table_y += 1
     tbl.attach(update_exif_orientation_check = Gtk::CheckButton.new(utf8(_("Update file's EXIF orientation when rotating a picture"))),
-               0, 2, 4, 5, Gtk::FILL, Gtk::SHRINK, 2, 2)
+               0, 2, table_y, table_y + 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tooltips.set_tip(update_exif_orientation_check, utf8(_("When rotating a picture (Alt-Right/Left), also update EXIF orientation in the file itself")), nil)
     update_exif_orientation_check.active = $config['rotate-set-exif'] == 'true'
 
@@ -1509,6 +1522,7 @@ def preferences
         if response == Gtk::Dialog::RESPONSE_OK
             $config['video-viewer'] = from_utf8(video_viewer_entry.text)
             $config['browser'] = from_utf8(browser_entry.text)
+            $config['thumbnails-height'] = thumbnails_height.value
             $config['preload-distance'] = preload_distance.value
             $config['rotate-set-exif'] = update_exif_orientation_check.active?.to_s
             if cache_memfree_radio.active?