Example #1
0
    def __init__(self, win, prev_screen=None, first_boot=False):

        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
        self.win = win
        self.win.set_main_widget(self)
        self.win.set_decorated(True)
        self.win.set_size_request(self.width, -1)
        self.first_boot = first_boot

        self.heading = Heading(_("Login"),
                               _("Enter your username and password"))
        self.pack_start(self.heading.container, False, False, 10)

        if force_login:
            self.add_username_as_label()

        else:
            align = Gtk.Alignment(xscale=0, xalign=0.5)
            self.pack_start(align, False, False, 15)

            self.labelled_entries = LabelledEntries([{
                'heading': _("Username"),
                'subheading': ""
            }, {
                'heading': _("Password"),
                'subheading': ""
            }])
            self.labelled_entries.set_spacing(15)
            self.username_entry = self.labelled_entries.get_entry(0)
            self.password_entry = self.labelled_entries.get_entry(1)

            align.add(self.labelled_entries)

        self.password_entry.set_visibility(False)

        for entry in self.labelled_entries.get_entries():
            entry.connect('key_release_event', self.enable_kano_button)
            entry.connect('key-release-event', self.activate)

        self.button_box = KanoButtonBox(_("LOGIN"), _("Create New"),
                                        _("Forgot your password?"),
                                        _("Or your username?"))

        self.button_box.set_spacing(40)
        self.button_box.set_margin_left(70)
        self.button_box.set_margin_right(70)
        self.button_box.set_margin_bottom(30)

        self.kano_button = self.button_box.kano_button
        self.button_box.set_orange_button_cb(self.go_to_registration)
        self.button_box.set_orange_button2_cb(self.reset_password_screen)
        self.button_box.set_orange_button3_cb(self.recover_username_screen)
        self.kano_button.connect('button_release_event', self.activate)
        self.kano_button.connect('key-release-event', self.activate)
        self.pack_start(self.button_box, False, False, 20)

        self.kano_button.set_sensitive(False)

        if not force_login:
            self.username_entry.grab_focus()
        else:
            self.password_entry.grab_focus()

        self.win.show_all()