ios.close
end
+def set_mousecursor(window, what)
+ window.set_cursor(Gdk::Cursor.new(what))
+end
def set_mousecursor_wait(window)
- window.set_cursor(Gdk::Cursor.new(Gdk::Cursor::WATCH))
+ set_mousecursor(window, Gdk::Cursor::WATCH)
Gtk.main_iteration while Gtk.events_pending?
end
def set_mousecursor_normal(window)
- window.set_cursor(Gdk::Cursor.new(Gdk::Cursor::LEFT_PTR))
+ set_mousecursor(window, Gdk::Cursor::LEFT_PTR)
end
def build_full_dest_filename(filename)
end
}
+ delete = Proc.new {
+ after = autotable.get_next_widget(vbox)
+ if !after
+ after = autotable.get_previous_widget(vbox)
+ end
+ autotable.remove(vbox)
+ if after
+ $vbox2textview[after].grab_focus
+ end
+ }
+
textview.signal_connect('key-press-event') { |w, event|
propagate = true
textview.set_editable(event.keyval != Gdk::Keyval::GDK_Tab)
end
end
if event.keyval == Gdk::Keyval::GDK_Delete && control_pressed
- after = autotable.get_next_widget(vbox)
- if !after
- after = autotable.get_previous_widget(vbox)
- end
- autotable.remove(vbox)
- if after
- $vbox2textview[after].grab_focus
- end
+ delete.call
end
if event.keyval == Gdk::Keyval::GDK_Return && control_pressed
view_element(File.basename(name))
}
evtbox.signal_connect('button-press-event') { |w, event|
+ retval = true
+ if event.event_type == Gdk::Event::BUTTON_PRESS
+ if $delete.active?
+ delete.call
+ end
+ if $r90.active?
+ rotate.call(90)
+ end
+ if $r270.active?
+ rotate.call(270)
+ end
+ end
textview.grab_focus
if event.event_type == Gdk::Event::BUTTON2_PRESS
view_element(File.basename(name))
- true
else
- false #- propagate
+ retval = false #- propagate
end
+ retval
}
vbox.signal_connect('button-press-event') { |w, event|
def show_popup(parent, msg)
dialog = Gtk::Dialog.new
dialog.title = utf8(_("Booh message"))
+ lbl = Gtk::Label.new
+ lbl.markup = msg
+ dialog.vbox.add(lbl)
+ dialog.add_button(Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK)
+
dialog.transient_for = parent
dialog.set_default_size(200, 120)
- dialog.vbox.add(Gtk::Label.new(msg))
-
- dialog.add_button(Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK)
+ dialog.window_position = Gtk::Window::POS_CENTER_ON_PARENT
dialog.show_all
+
dialog.run
dialog.destroy
end
return nil
end
+def open_file_popup
+ fc = Gtk::FileChooserDialog.new(utf8(_("Open file")),
+ nil,
+ Gtk::FileChooser::ACTION_OPEN,
+ nil,
+ [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT], [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL])
+ fc.add_shortcut_folder(File.expand_path("~/.booh-gui-files"))
+ fc.set_current_folder(File.expand_path("~/.booh-gui-files"))
+ fc.transient_for = $main_window
+ ok = false
+ while !ok
+ if fc.run == Gtk::Dialog::RESPONSE_ACCEPT
+ set_mousecursor_wait(fc.window)
+ msg = open_file(fc.filename)
+ set_mousecursor_normal(fc.window)
+ if msg
+ show_popup(fc, msg)
+ ok = false
+ else
+ ok = true
+ end
+ else
+ ok = true
+ end
+ end
+ fc.destroy
+end
+
def create_menu
mb = Gtk::MenuBar.new
filemenu.set_submenu(filesubmenu)
mb.append(filemenu)
- open.signal_connect('activate') { |w|
- fc = Gtk::FileChooserDialog.new(utf8(_("Open file")),
- nil,
- Gtk::FileChooser::ACTION_OPEN,
- nil,
- [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT], [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL])
- fc.add_shortcut_folder(File.expand_path("~/.booh-gui-files"))
- fc.set_current_folder(File.expand_path("~/.booh-gui-files"))
- fc.transient_for = $main_window
- ok = false
- while !ok
- if fc.run == Gtk::Dialog::RESPONSE_ACCEPT
- set_mousecursor_wait(fc.window)
- msg = open_file(fc.filename)
- set_mousecursor_normal(fc.window)
- if msg
- show_popup(fc, msg)
- ok = false
- else
- ok = true
- end
- else
- ok = true
- end
+ open.signal_connect('activate') { open_file_popup }
+ quit.signal_connect('activate') { try_quit }
+
+ return mb
+end
+
+def create_toolbar
+ tb = Gtk::Toolbar.new
+
+ tb.insert(-1, open = Gtk::ToolButton.new(Gtk::Stock::OPEN))
+
+ tb.insert(-1, Gtk::SeparatorToolItem.new)
+
+ tb.insert(-1, $r90 = Gtk::ToggleToolButton.new)
+ $r90.icon_widget = Gtk::Image.new("#{$FPATH}/images/stock-rotate-90-16.png")
+ $r90.label = utf8(_("Rotate"))
+ tb.insert(-1, $r270 = Gtk::ToggleToolButton.new)
+ $r270.icon_widget = Gtk::Image.new("#{$FPATH}/images/stock-rotate-270-16.png")
+ $r270.label = utf8(_("Rotate"))
+ tb.insert(-1, $delete = Gtk::ToggleToolButton.new(Gtk::Stock::DELETE))
+ tb.insert(-1, nothing = Gtk::ToolButton.new(''))
+ nothing.icon_widget = Gtk::Image.new("#{$FPATH}/images/stock-none-16.png")
+ nothing.label = utf8(_("None"))
+
+ open.signal_connect('clicked') { open_file_popup }
+
+ one_click_explain_try = Proc.new {
+ if !$config['one-click-explained']
+ show_popup($main_window, utf8(_("<b>One-Click tools.</b>
+
+You have just clicked on a One-Click tool. When such a tool is activated
+(<span foreground=\"darkblue\">Rotate clockwise</span>, <span foreground=\"darkblue\">Rotate counter-clockwise</span>, or <span foreground=\"darkblue\">Delete</span>), clicking on a
+thumbnail will immediately apply the desired action.
+
+Click the <span foreground=\"darkblue\">None</span> icon when you're finished with One-Click tools.
+")))
+ $config['one-click-explained'] = true
end
- fc.destroy
}
- quit.signal_connect('activate') { |w|
- try_quit
+ $r90.signal_connect('toggled') {
+ if $r90.active?
+ set_mousecursor($autotable.window, Gdk::Cursor::SB_RIGHT_ARROW)
+ one_click_explain_try.call
+ $r270.active = false
+ $delete.active = false
+ else
+ if !$r270.active? && !$delete.active?
+ set_mousecursor_normal($autotable.window)
+ end
+ end
+ }
+ $r270.signal_connect('toggled') {
+ if $r270.active?
+ set_mousecursor($autotable.window, Gdk::Cursor::SB_LEFT_ARROW)
+ one_click_explain_try.call
+ $r90.active = false
+ $delete.active = false
+ else
+ if !$r90.active? && !$delete.active?
+ set_mousecursor_normal($autotable.window)
+ end
+ end
+ }
+ $delete.signal_connect('toggled') {
+ if $delete.active?
+ set_mousecursor($autotable.window, Gdk::Cursor::PIRATE)
+ one_click_explain_try.call
+ $r90.active = false
+ $r270.active = false
+ else
+ if !$r90.active? && !$r270.active?
+ set_mousecursor_normal($autotable.window)
+ end
+ end
+ }
+ nothing.signal_connect('clicked') {
+ $r90.active = $r270.active = $delete.active = false
+ set_mousecursor_normal($autotable.window)
}
- return mb
+ return tb
end
def create_main_window
mb = create_menu
+ tb = create_toolbar
+
tbl = create_auto_table
# open_file('/home/gc/booh/foo')
}
$albums_ts = Gtk::TreeStore.new(String, String)
$albums_tv.set_model($albums_ts)
+ $albums_tv.signal_connect('realize') { $albums_tv.grab_focus }
paned = Gtk::HPaned.new
paned.pack1($albums_tv, false, false)
paned.pack2(tbl, true, true)
- main_vbox = Gtk::VBox.new(false, 5)
+ main_vbox = Gtk::VBox.new(false, 0)
main_vbox.pack_start(mb, false, false)
+ main_vbox.pack_start(tb, false, false)
main_vbox.pack_start(paned, true, true)
main_vbox.pack_end($statusbar = Gtk::Statusbar.new, false, false)