Class: Grumblr::SettingsFrame

Inherits:
Gtk::HBox
  • Object
show all
Defined in:
lib/grumblr/ui.rb

Instance Method Summary collapse

Constructor Details

#initializeSettingsFrame

Returns a new instance of SettingsFrame.



456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
# File 'lib/grumblr/ui.rb', line 456

def initialize
  super false, 40
  self.set_border_width 40

  @label = Gtk::Label.new
  @label.set_markup '<b>Fill-in Tumblr credentials</b>'

  @text_e = Gtk::Entry.new
  @text_e.set_text $cfg.get(:email).to_s

  @text_p = Gtk::Entry.new
  @text_p.set_visibility false
  @text_p.set_text $cfg.get(:password).to_s

  hbox = Gtk::HBox.new

  button = Gtk::Button.new('Cancel')
  button.signal_connect(:released) { $app.quit }
  hbox.pack_start button

  button = Gtk::Button.new('Sign in')
  button.signal_connect(:released) {  }
  hbox.pack_start button

  header = Gtk::Label.new
  header.set_alignment 0.0, 0.8
  header.set_markup '<big><big><b>Grumblr 2</b></big></big>'

  vbox = Gtk::VBox.new(false, 4)
  vbox.pack_start header
  vbox.pack_with_label '_Email', @text_e
  vbox.pack_with_label '_Password', @text_p
  vbox.pack_start @label
  vbox.pack_start hbox, false

   = Gtk::Image.new($gui.)

  self.pack_start 
  self.pack_start vbox
  self.show_all
end

Instance Method Details

#loginObject



498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# File 'lib/grumblr/ui.rb', line 498

def 
  email = @text_e.text.strip
  password = @text_p.text.strip
  if $api.authenticate(email, password)
    $cfg.set :email, email
    $cfg.set :password, password
    self.destroy
    @dashboard = Dashboard.new
    $gui.add @dashboard
  else
    raise "Authentication failed"
  end
rescue Exception
  MessageDialog.new $!
end