lib/gtk2passwordapp.rb in gtk2passwordapp-0.0.6 vs lib/gtk2passwordapp.rb in gtk2passwordapp-0.0.7

- old
+ new

@@ -1,8 +1,7 @@ -# $Date: 2009/02/22 16:20:51 $ +# $Date: 2009/02/26 01:03:00 $ require 'lib/passwords_data' -require 'gtk2' require 'find' class Gtk2PasswordApp include Configuration @@ -11,12 +10,12 @@ '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/22 16:20:51 $'.gsub(/\s*\$\s*/,''), - 'logo' => Gdk::Pixbuf.new(LOGO_IMAGE), + 'copyright' => '$Date: 2009/02/26 01:03:00 $'.gsub(/\s*\$\s*/,''), + 'logo' => Gdk::Pixbuf.new(GEM_ROOT_DIR+'/gifs/logo.gif'), } BUTTONS = [[ :username, :current, :url, ],[ :note, :edit, :quit, ],] EDITOR_LABELS = [ @@ -59,14 +58,10 @@ :cpwd => 'Data File Password', :cpph => 'Data File Passphrase', :delete => 'Delete Account', } - FONT = Pango::FontDescription.new(FONT_NAME) - RED = Gdk::Color.parse("#A00000") - BLACK = Gdk::Color.parse("#000000") - def quit_windows if @editing @editing.hide @editing.destroy @editing = nil @@ -174,11 +169,11 @@ @pwd = get_salt || exit @pph = get_passphrase @passwords = PasswordsData.new(@pwd+@pph) # Password file exist? - if @passwords.exist? # then + if @passwords.online? || @passwords.exist? # then # Yes, load passwords file. @passwords.load else # No, check if there is a file.... if has_datafile? # then @@ -402,10 +397,11 @@ # Change Passphrase widget[:cpph].signal_connect('clicked'){ if verify_user then @pph = get_passphrase(true) # mv old passphrase? true @passwords.save(@pwd+@pph) + quick_message('Passphrase Changed.', window) else quit_windows end } @@ -480,10 +476,11 @@ button = {} BUTTONS.each{ |row| hbox = Gtk::HBox.new row.each{|b| + next if b == :edit && @passwords.online? button[b] = Gtk::Button.new(TEXT[b]) button[b].modify_font(FONT) button[b].width_request = LABEL_WIDTH hbox.pack_start(button[b], false, false, PAD) } @@ -492,14 +489,18 @@ @passwords.accounts.each { |account| combo_box.append_text( account ) } combo_box.active = 0 - 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) - } + + 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) + } + end + button[:username].signal_connect('clicked'){ primary = Gtk::Clipboard.get(Gdk::Selection::PRIMARY) clipboard = Gtk::Clipboard.get(Gdk::Selection::CLIPBOARD) account = (combo_box.active_text)? combo_box.active_text.strip: '' primary.text = clipboard.text = @passwords.username_of(account) @@ -521,21 +522,25 @@ account = (combo_box.active_text)? combo_box.active_text.strip: '' note = @passwords.note_of(account).strip note = '*** empty note ***' if note.length == 0 quick_message(note,window) } - button[:edit].signal_connect('clicked'){ - if !@editing then - account = (combo_box.active_text)? combo_box.active_text.strip: '' - i = @passwords.accounts.index(account) - @editing = Gtk::Window.new - edit(combo_box,i) - end - } + + if !@passwords.online? then + button[:edit].signal_connect('clicked'){ + if !@editing then + account = (combo_box.active_text)? combo_box.active_text.strip: '' + i = @passwords.accounts.index(account) + @editing = Gtk::Window.new + edit(combo_box,i) + end + } + end + button[:quit].signal_connect('clicked'){ quit_windows } - if !@passwords.exist? then + if !@passwords.online? && !@passwords.exist? then @editing = Gtk::Window.new edit(combo_box,0) end window.show_all @@ -600,9 +605,9 @@ else main_quit(icon) end end } - run if !@passwords.exist? + run if !@passwords.online? && !@passwords.exist? Gtk.main end end