Class: Otpui::Main
- Inherits:
-
Object
- Object
- Otpui::Main
- Defined in:
- lib/otpui.rb
Instance Method Summary collapse
- #connect_signals ⇒ Object
- #on_main_window_destroy(object) ⇒ Object
- #on_menuitem_about_activate(object) ⇒ Object
- #on_menuitem_add_otp_code_activate(object) ⇒ Object
- #on_menuitem_add_otp_qrcode_activate(object) ⇒ Object
- #on_new_otp_button_activate(object) ⇒ Object
- #on_settings_menu_item_activate(object) ⇒ Object
- #start ⇒ Object
Instance Method Details
#connect_signals ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/otpui.rb', line 66 def connect_signals @builder.connect_signals do |handler| begin method(handler) rescue Log.debug "#{handler} not yet implemented!" end end end |
#on_main_window_destroy(object) ⇒ Object
20 21 22 |
# File 'lib/otpui.rb', line 20 def on_main_window_destroy(object) Gtk.main_quit() end |
#on_menuitem_about_activate(object) ⇒ Object
16 17 18 |
# File 'lib/otpui.rb', line 16 def (object) @about_window.show end |
#on_menuitem_add_otp_code_activate(object) ⇒ Object
29 30 31 |
# File 'lib/otpui.rb', line 29 def (object) @builder["otp_add_via_code_popover"].show end |
#on_menuitem_add_otp_qrcode_activate(object) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/otpui.rb', line 41 def (object) dialog = Gtk::FileChooserDialog.new( title: "Gtk::FileChooser sample", action: Gtk::FileChooserAction::OPEN, parent: @main_window, buttons: [ [Gtk::Stock::OPEN, Gtk::ResponseType::ACCEPT], [Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL] ] ) if dialog.run == Gtk::ResponseType::ACCEPT uri = URI(ZXing.decode(dialog.filename)) @settings.add_secret( uri.query_params["issuer"], uri.query_params["secret"] ) dialog.destroy elsif dialog.destroy end end |
#on_new_otp_button_activate(object) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/otpui.rb', line 33 def (object) @settings.add_secret( @builder["new_otp_name"].text, @builder["new_otp_code"].text ) @builder["otp_add_via_code_popover"].hide end |
#on_settings_menu_item_activate(object) ⇒ Object
24 25 26 27 |
# File 'lib/otpui.rb', line 24 def (object) dialog = SettingsDialog.new dialog.show end |
#start ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/otpui.rb', line 76 def start logo = GdkPixbuf::Pixbuf.new(file: Resources.get_icon("logo.png")) @settings = Settings.load Gtk::Window.set_default_icon(logo) @builder = Gtk::Builder.new @builder.add_from_file Resources.get_glade("main.glade") @about_window = @builder["about_window"] @about_window.version = Otpui::VERSION @about_window.logo = logo @main_window = @builder["main_window"] otp_list = OtpList.new(@builder) otp_list.run connect_signals @main_window.show_all Gtk.main end |