Esempio n. 1
0
    def show_login(self, global_config):

        self.mode = 1
        if self.vbox is not None: self.remove(self.vbox)

        avatar = self.load_image('logo2.png')
        self.message = LoginLabel(self)

        lbl_user = gtk.Label()
        #lbl_user.set_justify(gtk.JUSTIFY_LEFT)
        lbl_user.set_use_markup(True)
        lbl_user.set_markup(u'<span size="small">%s</span>' %
                            _('User and Password'))
        lbl_user.set_alignment(0, 0.5)

        self.username = gtk.Entry()
        self.password = gtk.Entry()
        self.password.set_visibility(False)

        self.remember = gtk.CheckButton(_('Remember my credentials'))

        self.btn_oauth = gtk.Button(_('Connect'))

        self.btn_settings = gtk.Button()
        self.btn_settings.set_relief(gtk.RELIEF_NONE)
        self.btn_settings.set_tooltip_text(_('Preferences'))
        self.btn_settings.set_image(self.load_image('settings-single.png'))
        settings_box = gtk.Alignment(xalign=1.0, yalign=0.5)
        settings_box.set_padding(70, 10, 40, 40)
        settings_box.add(self.btn_settings)

        self.waiting = CairoWaiting(self)
        align = gtk.Alignment(xalign=1, yalign=0.5)
        align.add(self.waiting)

        hbox = gtk.HBox(False)
        hbox.pack_start(lbl_user, False, False, 2)
        hbox.pack_start(align, True, True, 2)

        table = gtk.Table(10, 1, False)
        table.attach(avatar, 0, 1, 0, 1, gtk.FILL, gtk.FILL, 10, 50)
        table.attach(self.message, 0, 1, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL,
                     20, 3)
        table.attach(hbox, 0, 1, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL, 50, 0)
        table.attach(self.username, 0, 1, 3, 4, gtk.EXPAND | gtk.FILL,
                     gtk.FILL, 50, 0)
        table.attach(self.password, 0, 1, 5, 6, gtk.EXPAND | gtk.FILL,
                     gtk.FILL, 50, 0)
        table.attach(self.btn_oauth, 0, 1, 7, 8, gtk.EXPAND, gtk.FILL, 0, 10)
        table.attach(self.remember, 0, 1, 8, 9, gtk.EXPAND, gtk.FILL, 0, 10)
        table.attach(settings_box, 0, 1, 9, 10, gtk.EXPAND | gtk.FILL,
                     gtk.EXPAND | gtk.FILL, 0, 10)

        self.vbox = gtk.VBox(False, 5)
        self.vbox.pack_start(table, False, False, 2)

        self.add(self.vbox)
        self.show_all()

        self.btn_oauth.connect('clicked', self.oauth)
        self.password.connect('activate', self.oauth)
        self.remember.connect("toggled", self.__toogle_remember)
        self.btn_settings.connect('clicked', self.show_preferences, 'global')

        username = global_config.read('Login', 'username')
        password = global_config.read('Login', 'password')
        if username != '' and password != '':
            self.username.set_text(username)
            self.password.set_text(base64.b64decode(password))
            self.remember.set_active(True)
Esempio n. 2
0
    def __init__(self, mainwin):
        gtk.VBox.__init__(self, False, 5)

        self.mainwin = mainwin
        avatar = self.mainwin.load_image('logo2.png')
        self.message = LoginLabel(self)
        us, pw, rem, auto = self.mainwin.request_remembered(0)

        lbl_user = gtk.Label()
        lbl_user.set_use_markup(True)
        lbl_user.set_markup(u'<span size="small">%s</span>' %
                            _('User and Password'))
        lbl_user.set_alignment(0, 0.5)

        self.username = gtk.Entry()
        self.username.set_text(us)
        self.password = gtk.Entry()
        self.password.set_visibility(False)
        self.password.set_text(pw)

        self.remember = gtk.CheckButton(_('Remember my credentials'))
        self.autologin = gtk.CheckButton(_('Automatic login'))
        self.autologin.set_sensitive(False)

        self.btn_oauth = gtk.Button(_('Connect'))

        list = gtk.ListStore(gtk.gdk.Pixbuf, str, str)
        for p in PROTOCOLS:
            image = '%s.png' % p
            t_icon = self.mainwin.load_image(image, True)
            list.append([t_icon, p, p])

        self.combo_protocol = gtk.ComboBox(list)
        icon_cell = gtk.CellRendererPixbuf()
        txt_cell = gtk.CellRendererText()
        self.combo_protocol.pack_start(icon_cell, False)
        self.combo_protocol.pack_start(txt_cell, False)
        self.combo_protocol.add_attribute(icon_cell, 'pixbuf', 0)
        self.combo_protocol.add_attribute(txt_cell, 'markup', 1)
        self.combo_protocol.set_active(0)

        self.btn_settings = gtk.Button()
        self.btn_settings.set_relief(gtk.RELIEF_NONE)
        self.btn_settings.set_tooltip_text(_('Preferences'))
        self.btn_settings.set_image(
            self.mainwin.load_image('dock-settings.png'))
        settings_box = gtk.Alignment(xalign=1.0, yalign=0.5)
        settings_box.add(self.btn_settings)

        self.waiting = CairoWaiting(self.mainwin)
        align = gtk.Alignment(xalign=1, yalign=0.5)
        align.add(self.waiting)

        hbox = gtk.HBox(False)
        hbox.pack_start(lbl_user, False, False, 2)
        hbox.pack_start(align, True, True, 2)

        table = gtk.Table(11, 1, False)
        table.attach(settings_box, 0, 1, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL,
                     0, 3)
        table.attach(avatar, 0, 1, 1, 2, gtk.FILL, gtk.FILL, 10, 50)
        table.attach(self.message, 0, 1, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL,
                     20, 3)
        table.attach(hbox, 0, 1, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL, 50, 0)
        table.attach(self.username, 0, 1, 4, 5, gtk.EXPAND | gtk.FILL,
                     gtk.FILL, 50, 0)
        table.attach(self.password, 0, 1, 6, 7, gtk.EXPAND | gtk.FILL,
                     gtk.FILL, 50, 0)
        table.attach(self.combo_protocol, 0, 1, 8, 9, gtk.EXPAND, gtk.FILL, 0,
                     10)
        table.attach(self.btn_oauth, 0, 1, 9, 10, gtk.EXPAND, gtk.FILL, 0, 3)
        table.attach(self.remember, 0, 1, 10, 11, gtk.FILL, gtk.FILL, 60, 1)
        table.attach(self.autologin, 0, 1, 11, 12, gtk.FILL, gtk.FILL, 60, 1)

        self.pack_start(table, False, False, 2)

        self.btn_oauth.grab_focus()
        self.btn_oauth.connect('clicked', self.signin)
        self.password.connect('activate', self.signin)
        self.rhandler = self.remember.connect("toggled",
                                              self.__toogle_remember)
        self.btn_settings.connect('clicked', self.mainwin.show_preferences,
                                  'global')
        self.combo_protocol.connect('changed', self.__change_protocol)
        self.autologin.connect('toggled', self.__remember)
        self.remember.set_active(rem)
        self.autologin.set_active(auto)
        if rem:
            self.btn_oauth.grab_focus()
        else:
            self.username.grab_focus()
        if auto:
            self.signin(None)