lib/gtk2passwordapp.rb in gtk2passwordapp-0.0.7 vs lib/gtk2passwordapp.rb in gtk2passwordapp-0.0.8
- old
+ new
@@ -1,6 +1,6 @@
-# $Date: 2009/02/26 01:03:00 $
+# $Date: 2009/02/28 00:30:16 $
require 'lib/passwords_data'
require 'find'
class Gtk2PasswordApp
include Configuration
@@ -10,11 +10,11 @@
'comments' => "Ruby-Gtk2 Password Manager.",
'version' => $version,
'website' => 'http://ruby-gnome-apps.blogspot.com/search/label/Passwords',
'website-label' => 'Ruby Gnome Password Manager',
'license' => 'GPL',
- 'copyright' => '$Date: 2009/02/26 01:03:00 $'.gsub(/\s*\$\s*/,''),
+ 'copyright' => '$Date: 2009/02/28 00:30:16 $'.gsub(/\s*\$\s*/,''),
'logo' => Gdk::Pixbuf.new(GEM_ROOT_DIR+'/gifs/logo.gif'),
}
BUTTONS = [[ :username, :current, :url, ],[ :note, :edit, :quit, ],]
@@ -425,25 +425,34 @@
i = old_list.index(account)
old_list.delete_at(i)
combo_box.remove_text(i)
end
}
+ if i = new_list.index( widget[:account].active_text ) then
+ combo_box.active = i
+ end
else
quit_windows
end
end
window.destroy
@editing = nil
}
# Delete
widget[:delete].signal_connect('clicked'){
- account = (widget[:account].active_text)? widget[:account].active_text.strip: ''
- i = @passwords.accounts.index(account)
- @passwords.delete(account)
- widget[:account].remove_text(i)
- @updated = true
+ account = (widget[:account].active_text)? widget[:account].active_text.strip: nil
+ if account then
+ i = @passwords.accounts.index(account)
+ if i then
+ @passwords.delete(account)
+ widget[:account].remove_text(i)
+ widget[:account].active = (i > 0)? i - 1: 0
+ @updated = true
+ quick_message("#{account} deleted.", window)
+ end
+ end
}
# Cancel
widget[:cancel].signal_connect('clicked'){
window.hide
@@ -493,10 +502,11 @@
combo_box.active = 0
if !@passwords.online? then
button[:edit].child.modify_fg(Gtk::STATE_NORMAL, (@passwords.expired?(combo_box.active_text.strip))? RED: BLACK) if combo_box.active_text
combo_box.signal_connect('changed'){
- button[:edit].child.modify_fg(Gtk::STATE_NORMAL, (@passwords.expired?(combo_box.active_text.strip))? RED: BLACK)
+ txt = combo_box.active_text
+ button[:edit].child.modify_fg(Gtk::STATE_NORMAL, (@passwords.expired?(txt.strip))? RED: BLACK) if txt
}
end
button[:username].signal_connect('clicked'){
primary = Gtk::Clipboard.get(Gdk::Selection::PRIMARY)