Class: DragonsKeep::AccountDialog
- Inherits:
-
Wx::Dialog
- Object
- Wx::Dialog
- DragonsKeep::AccountDialog
- Defined in:
- lib/dragons_keep/account_dialog.rb
Constant Summary collapse
- ID_USER_NAME =
103
- ID_ACCOUNT_NAME =
101
- ID_URL =
102
- ID_PASSWORD =
104
- ID_GENERATE_PASSWORD =
105
- ID_SAVE =
106
- ID_COPY_CLIP =
107
- ID_CANCEL =
108
Instance Method Summary collapse
- #account ⇒ Object
- #account=(account) ⇒ Object
- #gen_pass_click(event) ⇒ Object
-
#initialize(parent, id, title) ⇒ AccountDialog
constructor
A new instance of AccountDialog.
Constructor Details
#initialize(parent, id, title) ⇒ AccountDialog
Returns a new instance of AccountDialog.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dragons_keep/account_dialog.rb', line 17 def initialize parent, id, title super parent, id, title self.set_size(Wx::Size.new(400, 300)) main_sizer = Wx::BoxSizer.new(Wx::VERTICAL) grid_sizer = Wx::FlexGridSizer.new(4,2,5,5) # Create name entry label = Wx::StaticText.new(self, :label=>"Name:") grid_sizer.add label, 0, Wx::ALL |Wx::ALIGN_RIGHT @name = Wx::TextCtrl.new self, ID_ACCOUNT_NAME grid_sizer.add @name, 1, Wx::EXPAND # Create url entry label = Wx::StaticText.new(self, :label=>"URL:") grid_sizer.add label, 0,Wx::ALL |Wx::ALIGN_RIGHT @url = Wx::TextCtrl.new self, ID_URL grid_sizer.add @url, 1, Wx::EXPAND # Create User_name entry label = Wx::StaticText.new(self, :label=>"User Name:") grid_sizer.add label, 0, Wx::ALL |Wx::ALIGN_RIGHT @user = Wx::TextCtrl.new self, ID_USER_NAME grid_sizer.add @user, 1, Wx::EXPAND # Create password entry label = Wx::StaticText.new(self, :label=>"Password:") grid_sizer.add label, 0, Wx::ALL |Wx::ALIGN_RIGHT @pass = Wx::TextCtrl.new self, ID_PASSWORD, :style=> Wx::TE_PASSWORD grid_sizer.add @pass, 1, Wx::EXPAND main_sizer.add grid_sizer, 0, Wx::GROW|Wx::ALIGN_CENTER_VERTICAL|Wx::ALL, 5 grid_sizer.add_growable_col(1) # add spacer to grid grid_sizer.add(25, 25) # Add generate password button @gen_button = Wx::Button.new self, ID_GENERATE_PASSWORD, "Generate Password..." grid_sizer.add @gen_button, 1, Wx::EXPAND (ID_GENERATE_PASSWORD){|evt| self.gen_pass_click(evt)} main_sizer.add self.(Wx::OK|Wx::CANCEL), 1, Wx::ALIGN_RIGHT self.set_sizer main_sizer end |
Instance Method Details
#account ⇒ Object
68 69 70 71 |
# File 'lib/dragons_keep/account_dialog.rb', line 68 def account save_account @account end |
#account=(account) ⇒ Object
73 74 75 76 |
# File 'lib/dragons_keep/account_dialog.rb', line 73 def account=(account) @account = account load_account end |
#gen_pass_click(event) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/dragons_keep/account_dialog.rb', line 59 def gen_pass_click(event) # display generate pass dialog gen_dialog = GeneratePasswordDialog.new self, -1, "Generate Password" if gen_dialog.show_modal() == Wx::ID_OK @account.generate_password gen_dialog.password_length, gen_dialog.use_special_chars? @pass.value = @account.unencrypted_password end end |