display progression in application title
authorgc <gc>
Mon, 24 Mar 2008 16:03:23 +0000 (16:03 +0000)
committergc <gc>
Mon, 24 Mar 2008 16:03:23 +0000 (16:03 +0000)
bin/booh

index 83e0378..7f8f2e0 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -1948,6 +1948,23 @@ def show_popup(parent, msg, *options)
     end
 end
 
+def set_mainwindow_title(progress)
+    filename = $orig_filename || $filename
+    if progress
+        if filename
+            $main_window.title = 'booh [' + (progress * 100).to_i.to_s + '%] - ' + File.basename(filename)
+        else
+            $main_window.title = 'booh [' + (progress * 100).to_i.to_s + '%] '
+        end
+    else
+        if filename
+            $main_window.title = 'booh - ' + File.basename(filename)
+        else
+            $main_window.title = 'booh'
+        end
+    end
+end
+
 def backend_wait_message(parent, msg, infopipe_path, mode)
     w = create_window
     w.set_transient_for(parent)
@@ -1971,6 +1988,15 @@ def backend_wait_message(parent, msg, infopipe_path, mode)
     b.image = Gtk::Image.new("#{$FPATH}/images/stock-close-24.png")
     vb.pack_end(bottom, false, false)
 
+    directories = nil
+    update_progression_title_pb1 = proc {
+        if mode != 'web-album'
+            set_mainwindow_title(pb1_2.fraction + pb1_1.fraction / directories)
+        else
+            set_mainwindow_title((pb1_2.fraction + pb1_1.fraction / directories) * 9 / 10)
+        end
+    }
+
     infopipe = File.open(infopipe_path, File::RDONLY | File::NONBLOCK)
     refresh_thread = Thread.new {
         directories_counter = 0
@@ -1990,14 +2016,23 @@ def backend_wait_message(parent, msg, infopipe_path, mode)
                     newtext = '/' if newtext == ''
                     gtk_thread_protect { pb1_2.text = newtext }
                     directories_counter += 1
-                    gtk_thread_protect { pb1_2.fraction = directories_counter / directories }
+                    gtk_thread_protect {
+                        pb1_2.fraction = directories_counter / directories
+                        update_progression_title_pb1.call
+                    }
                 end
             elsif line =~ /^processing element$/
                 element_counter += 1
-                gtk_thread_protect { pb1_1.fraction = element_counter / elements }
+                gtk_thread_protect {
+                    pb1_1.fraction = element_counter / elements
+                    update_progression_title_pb1.call
+                }
             elsif line =~ /^processing size$/
                 element_counter += 1
-                gtk_thread_protect { pb1_1.fraction = element_counter / elements }
+                gtk_thread_protect {
+                    pb1_1.fraction = element_counter / elements
+                    update_progression_title_pb1.call
+                }
             elsif line =~ /^finished processing sizes$/
                 gtk_thread_protect { pb1_1.fraction = 1 }
             elsif line =~ /^creating index.html$/
@@ -2009,7 +2044,10 @@ def backend_wait_message(parent, msg, infopipe_path, mode)
                 newtext = '/' if newtext == ''
                 gtk_thread_protect { pb2.text = newtext }
                 directories_counter += 1
-                gtk_thread_protect { pb2.fraction = directories_counter / directories }
+                gtk_thread_protect {
+                    pb2.fraction = directories_counter / directories
+                    set_mainwindow_title(0.9 + pb2.fraction / 10)
+                }
             elsif line =~ /^die: (.*)$/
                 $diemsg = $1
             end
@@ -2025,6 +2063,7 @@ def backend_wait_message(parent, msg, infopipe_path, mode)
             infopipe.close
             File.delete(infopipe_path)
         end
+        set_mainwindow_title(nil)
     }
     w.window_position = Gtk::Window::POS_CENTER
     w.show_all
@@ -2839,6 +2878,7 @@ def open_file(filename)
     select_current_theme
 
     $filename = filename
+    set_mainwindow_title(nil)
     $default_size['thumbnails'] =~ /(.*)x(.*)/
     $default_thumbnails = { :x => $1.to_i, :y => $2.to_i }
     $albums_thumbnail_size =~ /(.*)x(.*)/