[mathieu blondel feat] add a clickable URL to view the webalbum
authorgc <gc>
Sun, 18 Sep 2005 21:45:37 +0000 (21:45 +0000)
committergc <gc>
Sun, 18 Sep 2005 21:45:37 +0000 (21:45 +0000)
in the dialog for successful webalbum generation

bin/booh

index 1e437980313c83fa5892ab4685cefb4401040673..9769d1cfecc419e86f001b479738d5841f5209ef 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -174,11 +174,12 @@ def write_config
 end
 
 def set_mousecursor(what, *widget)
+    cursor = what.nil? ? nil : Gdk::Cursor.new(what)
     if widget[0] && widget[0].window
-        widget[0].window.set_cursor(Gdk::Cursor.new(what))
+        widget[0].window.cursor = cursor
     end
     if $main_window.window
-        $main_window.window.set_cursor(Gdk::Cursor.new(what))
+        $main_window.window.cursor = cursor
     end
     $current_cursor = what
 end
@@ -189,7 +190,7 @@ def set_mousecursor_wait(*widget)
     end
 end
 def set_mousecursor_normal(*widget)
-    gtk_thread_protect { set_mousecursor($save_cursor = Gdk::Cursor::LEFT_PTR, *widget) }
+    gtk_thread_protect { set_mousecursor($save_cursor = nil, *widget) }
 end
 def push_mousecursor_wait(*widget)
     if $current_cursor != Gdk::Cursor::WATCH
@@ -198,7 +199,7 @@ def push_mousecursor_wait(*widget)
     end
 end
 def pop_mousecursor(*widget)
-    gtk_thread_protect { set_mousecursor($save_cursor || Gdk::Cursor::LEFT_PTR, *widget) }
+    gtk_thread_protect { set_mousecursor($save_cursor || nil, *widget) }
 end
 
 def current_dest_dir
@@ -1468,6 +1469,17 @@ def show_popup(parent, msg, *options)
     else
         dialog.window_position = Gtk::Window::POS_MOUSE
     end
+
+    if options[0] && options[0][:linkurl]
+        linkbut = Gtk::Button.new('')
+        linkbut.child.markup = "<span foreground=\"#00000000FFFF\" underline=\"single\">#{options[0][:linkurl]}</span>"
+        linkbut.signal_connect('clicked') { open_url(options[0][:linkurl] + '/index.html' ) }
+        linkbut.relief = Gtk::RELIEF_NONE
+        linkbut.signal_connect('enter-notify-event') { set_mousecursor(Gdk::Cursor::HAND2, linkbut); false }
+        linkbut.signal_connect('leave-notify-event') { set_mousecursor(nil, linkbut); false }
+        dialog.vbox.add(Gtk::Alignment.new(0.5, 0.5, 0, 0).add(linkbut))
+    end
+
     dialog.show_all
 
     if !options[0] || !options[0][:not_transient]
@@ -1579,7 +1591,7 @@ def call_backend(cmd, waitmsg, mode, params)
             gtk_thread_protect { w8.destroy }
             if exitstatus == 0
                 if params[:successmsg]
-                    gtk_thread_protect { show_popup($main_window, params[:successmsg]) }
+                    gtk_thread_protect { show_popup($main_window, params[:successmsg], { :linkurl => params[:successmsg_linkurl] }) }
                 end
                 if params[:closure_after]
                     gtk_thread_protect(&params[:closure_after])
@@ -2238,6 +2250,12 @@ def open_file_popup
     fc.destroy
 end
 
+def open_url(url)
+    cmd = $config['browser'].gsub('%f', "'#{url}'") + ' &'
+    msg 2, cmd
+    system(cmd)
+end
+
 def additional_booh_options
     options = ''
     if $config['mproc']
@@ -3186,7 +3204,9 @@ def create_menu_and_toolbar
         call_backend("booh-backend --config '#{$filename}' --verbose-level #{$verbose_level} #{additional_booh_options}",
                      utf8(_("Please wait while generating web-album...\nThis may take a while, please be patient.")),
                      'web-album',
-                     { :successmsg => utf8(_("Your web-album is now ready in directory `%s'.") % $xmldoc.root.attributes['destination']),
+                     { :successmsg => utf8(_("Your web-album is now ready in directory `%s'.
+Click to view it in your browser:") % $xmldoc.root.attributes['destination']),
+                       :successmsg_linkurl => $xmldoc.root.attributes['destination'],
                        :failuremsg => utf8(_("There was something wrong when generating the web-album, sorry.")),
                        :closure_after => proc {
                              $xmldoc.elements.each('//dir') { |elem|
@@ -3263,11 +3283,7 @@ for speeding up your editions. If bothered, you can disable them from Edit/Prefe
 
 
     about.signal_connect('activate') {
-        Gtk::AboutDialog.set_url_hook { |dialog, url|
-            cmd = $config['browser'].gsub('%f', "'#{url}'") + ' &'
-            msg 2, cmd
-            system(cmd)
-        }
+        Gtk::AboutDialog.set_url_hook { |dialog, url| open_url(url) }
         Gtk::AboutDialog.show($main_window, { :name => 'booh',
                                               :version => $VERSION,
                                               :copyright => 'Copyright (c) 2005 Guillaume Cottenceau',