def new_combo_session(self, session_combo, on_session_changed): account = self.config.get_or_set('last_logged_account', '') default_session=extension.get_default('session') count=0 name_to_ext={} if account in self.accounts: service = self.config.d_user_service.get(account, 'msn') else: service='msn' for ext_id, ext in extension.get_extensions('session').iteritems(): if default_session.NAME == ext.NAME: default_session_index = count for service_name, service_data in ext.SERVICES.iteritems(): if service == service_name: index = count session_found = True session_combo.append_text(service_name) name_to_ext[service_name] = (ext_id, ext) count += 1 if session_found: session_combo.set_active(index) else: session_combo.set_active(default_session_index) session_combo.connect('changed', on_session_changed,name_to_ext) self.__combo_session_list.append(session_combo) return name_to_ext
def do_x(self): for extra in extension.get_extensions('bar'): try: print 'bar', extra extra.bar() except: print 'NW', extra
def _get_categories(self): ''' get available categories''' categories = [ ctg for ctg in extension.get_categories().keys() if len(extension.get_extensions(ctg)) > 1 ] categories.sort() return categories
def bar(self): print 'bar will bar' print ' # extension can be extended! ;)' for extra in extension.get_extensions('foo'): try: print 'foo', extra extra.do_foo() except Exception, reason: print 'NW', extra, reason
def _add_extensions_combo(self): """add the widgets to display the extensions """ categories = [ctg for ctg in extension.get_categories().keys() if len(extension.get_extensions(ctg)) > 1] categories.sort() for item in categories: self.categories.append_text(item) self.categories.connect('changed', self._on_category_changed) self.extensions.connect('changed', self._on_extension_changed) self.attach(self.categories, 1, 2, 0, 1, yoptions=gtk.EXPAND) self.attach(self.extensions, 1, 2, 1, 2, yoptions=gtk.EXPAND) self.categories.set_active(0)
def _setup_services(self, session_id): if session_id is not None: for ext_id, ext in extension.get_extensions('session').iteritems(): for service_name, service_data in ext.SERVICES.iteritems(): self.services[service_name] = service_data self.service2id[service_name] = (ext_id, ext) if session_id == ext_id and self.config.service in ext.SERVICES: self.server_host = ext.SERVICES[self.config.service]['host'] self.server_port = ext.SERVICES[self.config.service]['port'] else: self.config.service = 'msn' self.server_host = 'messenger.hotmail.com' self.server_port = '1863' else: self.config.service = 'msn' self.server_host = 'messenger.hotmail.com' self.server_port = '1863'
def _setup_config(self): '''Adds missing options to config file''' print " *** _setup_config" default_session = extension.get_default('session') service = default_session.SERVICES.keys()[0] self._host = default_session.SERVICES[service]['host'] self._port = default_session.SERVICES[service]['port'] self._config.get_or_set('last_logged_account', '') self._config.get_or_set('d_remembers', {}) self._config.get_or_set('d_user_service', {}) self._config.get_or_set('d_status', {}) self._config.get_or_set('service', service) # obtaining host and port info for each service for ext_id, ext_class in extension.get_extensions('session').\ iteritems(): for service_name, service_data in ext_class.SERVICES.iteritems(): self._service2data[service_name] = service_data self._service2id[service_name] = ext_id
def new_combo_session(self): account = self.config.get_or_set('last_logged_account', '') default_session = extension.get_default('session') count = 0 session_found = False self.session_name_to_index = {} if account in self.accounts: service = self.config.d_user_service.get( account.rpartition('|')[0], 'msn') else: service = self.config.service for ext_id, ext in extension.get_extensions('session').iteritems(): if default_session.NAME == ext.NAME: default_session_index = count for service_name, service_data in ext.SERVICES.iteritems(): if service == service_name: index = count session_found = True try: s_name = getattr(gui.theme.image_theme, "service_" + service_name) image = utils.safe_gtk_pixbuf_load(s_name) except: image = None self.session_combo.get_model().append([image, service_name]) self.session_name_to_index[service_name] = count count += 1 if session_found: self.session_combo.set_active(index) else: self.session_combo.set_active(default_session_index) self.session_combo.connect('changed', self._on_session_changed) self._combo_session_list.append(self.session_combo)
def new_combo_session(self, session_combo, on_session_changed): account = self.config.get_or_set('last_logged_account', '') default_session = extension.get_default('session') count=0 session_found = False name_to_ext = {} if account in self.accounts: service = self.config.d_user_service.get(account, 'msn') else: service = 'msn' for ext_id, ext in extension.get_extensions('session').iteritems(): if default_session.NAME == ext.NAME: default_session_index = count for service_name, service_data in ext.SERVICES.iteritems(): if service == service_name: index = count session_found = True try: # ugly eval here, is there another way? s_name = getattr(gui.theme, "service_" + service_name) image = utils.safe_gtk_pixbuf_load(s_name) except: image = None session_combo.get_model().append([image, service_name]) name_to_ext[service_name] = (ext_id, ext) count += 1 if session_found: session_combo.set_active(index) else: session_combo.set_active(default_session_index) session_combo.connect('changed', on_session_changed, name_to_ext) self.__combo_session_list.append(session_combo) return name_to_ext
def _on_category_changed(self, combo): """callback called when the category on the combo changes""" self.extensions.get_model().clear() self.extension_list = [] category = combo.get_active_text() default = extension.get_default(category) extensions = extension.get_extensions(category) count = 0 selected = 0 for identifier, ext in extensions.iteritems(): if default is ext: selected = count self.extensions.append_text(self.get_attr_or_default(ext, "NAME", ext.__name__)) self.extension_list.append((ext, identifier)) count += 1 self.extensions.set_active(selected)
def _setup_services(self, session_id): if session_id is not None: for ext_id, ext in extension.get_extensions('session').iteritems(): for service_name, service_data in ext.SERVICES.iteritems(): self.services[service_name] = service_data self.service2id[service_name] = (ext_id, ext) if session_id == ext_id and self.config.service in ext.SERVICES: self.server_host = ext.SERVICES[ self.config.service]['host'] self.server_port = ext.SERVICES[ self.config.service]['port'] else: self.config.service = 'msn' self.server_host = 'messenger.hotmail.com' self.server_port = '1863' else: self.config.service = 'msn' self.server_host = 'messenger.hotmail.com' self.server_port = '1863'
def _on_category_changed(self, combo): """callback called when the category on the combo changes""" self.extensions.get_model().clear() self.extension_list = [] category = combo.get_active_text() default = extension.get_default(category) extensions = extension.get_extensions(category) count = 0 selected = 0 for identifier, ext in extensions.iteritems(): if default is ext: selected = count self.extensions.append_text( self.get_attr_or_default(ext, 'NAME', ext.__name__)) self.extension_list.append((ext, identifier)) count += 1 self.extensions.set_active(selected)
def _on_category_changed(self, combo): """callback called when the category on the combo changes""" self.extensions_cmb.model().clear() self.extension_list = [] category = str(combo.currentText()) default = extension.get_default(category) extensions = extension.get_extensions(category) count = 0 selected = 0 for identifier, ext in extensions.iteritems(): if default is ext: selected = count self.extension_list.append((ext, identifier)) self.extensions_cmb.addItem(self.get_attr_or_default(ext, "NAME", ext.__name__)) count += 1 self.extensions_cmb.setCurrentIndex(selected) self._on_extension_changed(self.extensions_cmb)
def new_combo_session(self, add_cb): '''Fill the service combo with the avariable services. For each service we call the add_cb function with it's image path and service description. This function return the index of the current service. ''' account = self.config.get_or_set('last_logged_account', '') default_session = extension.get_default('session') count = 0 session_found = False self.session_name_to_index = {} if account in self.accounts: service = self.config.d_user_service.get( account.rpartition('|')[0], 'whatsapp') else: service = self.config.service for ext_id, ext in extension.get_extensions('session').iteritems(): if default_session.NAME == ext.NAME: default_session_index = count for service_name, service_data in ext.SERVICES.iteritems(): if service == service_name: index = count session_found = True try: s_name = getattr(gui.theme.image_theme, "service_" + service_name) except: s_name = None add_cb(s_name, service_name) self.session_name_to_index[service_name] = count count += 1 if session_found: return index return default_session_index
def new_combo_session(self, add_cb): '''Fill the service combo with the avariable services. For each service we call the add_cb function with it's image path and service description. This function return the index of the current service. ''' account = self.config.get_or_set('last_logged_account', '') default_session = extension.get_default('session') count = 0 session_found = False self.session_name_to_index = {} if account in self.accounts: service = self.config.d_user_service.get( account.rpartition('|')[0], 'msn') else: service = self.config.service for ext_id, ext in extension.get_extensions('session').iteritems(): if default_session.NAME == ext.NAME: default_session_index = count for service_name, service_data in ext.SERVICES.iteritems(): if service == service_name: index = count session_found = True try: s_name = getattr(gui.theme.image_theme, "service_" + service_name) except: s_name = None add_cb(s_name, service_name) self.session_name_to_index[service_name] = count count += 1 if session_found: return index return default_session_index
def _on_category_changed(self, combo): '''callback called when the category on the combo changes''' self.extensions_cmb.model().clear() self.extension_list = [] category = str(combo.currentText()) default = extension.get_default(category) extensions = extension.get_extensions(category) count = 0 selected = 0 for identifier, ext in extensions.iteritems(): if default is ext: selected = count self.extension_list.append((ext, identifier)) self.extensions_cmb.addItem( self.get_attr_or_default(ext, 'NAME', ext.__name__)) count += 1 self.extensions_cmb.setCurrentIndex(selected) self._on_extension_changed(self.extensions_cmb)
def run(self): for extra in extension.get_extensions('foo_category'): extra.do_it()
def login_preferences(cls, session, callback, use_http, proxy): """ display the preferences dialog for the login window cls -- the dialog class session -- the session string identifier callback -- callback to call if the user press accept, call with the new values use_http -- boolean that indicates if the e3 should use http method proxy -- a e3.Proxy object """ content = gtk.VBox(spacing=4) advanced = gtk.Expander("Advanced") box = gtk.Table(10, 2) box.set_property('row-spacing', 4) box.set_property('column-spacing', 4) combo = gtk.combo_box_new_text() t_proxy_host = gtk.Entry() t_proxy_port = gtk.Entry() t_user = gtk.Entry() t_passwd = gtk.Entry() t_server_host = gtk.Entry() t_server_port = gtk.Entry() def on_toggled(check_button, *entries): '''called when a check button is toggled, receive a set of entries, enable or disable them deppending on the state of the check button''' for entry in entries: entry.set_sensitive(check_button.get_active()) c_use_http = gtk.CheckButton('Use HTTP method') c_use_proxy = gtk.CheckButton('Use proxy') c_use_proxy.connect('toggled', on_toggled, t_proxy_host, t_proxy_port) c_use_auth = gtk.CheckButton('Use authentication') c_use_auth.connect('toggled', on_toggled, t_user, t_passwd) t_proxy_host.set_text(proxy.host or '') t_proxy_port.set_text(proxy.port or '') t_user.set_text(proxy.user or '') t_passwd.set_text(proxy.passwd or '') t_passwd.set_visibility(False) c_use_http.set_active(use_http) c_use_proxy.set_active(proxy.use_proxy) c_use_proxy.toggled() c_use_proxy.toggled() c_use_auth.set_active(proxy.use_auth) c_use_auth.toggled() c_use_auth.toggled() l_session = gtk.Label('Session') l_session.set_alignment(0.0, 0.5) l_server_host = gtk.Label('Server') l_server_host.set_alignment(0.0, 0.5) l_server_port = gtk.Label('Port') l_server_port.set_alignment(0.0, 0.5) l_host = gtk.Label('Host') l_host.set_alignment(0.0, 0.5) l_port = gtk.Label('Port') l_port.set_alignment(0.0, 0.5) l_user = gtk.Label('User') l_user.set_alignment(0.0, 0.5) l_passwd = gtk.Label('Password') l_passwd.set_alignment(0.0, 0.5) proxy_settings = (l_host, l_port, l_user, l_passwd, t_proxy_host, t_proxy_port, t_user, t_passwd, c_use_auth) def on_use_proxy_toggled(*args): for widget in proxy_settings: if c_use_proxy.get_active(): widget.show() else: widget.hide() c_use_proxy.connect('toggled', on_use_proxy_toggled) box.attach(l_server_host, 0, 1, 0, 1) box.attach(t_server_host, 1, 2, 0, 1) box.attach(l_server_port, 0, 1, 1, 2) box.attach(t_server_port, 1, 2, 1, 2) box.attach(c_use_http, 0, 2, 2, 3) box.attach(c_use_proxy, 0, 2, 3, 4) box.attach(l_host, 0, 1, 4, 5) box.attach(t_proxy_host, 1, 2, 4, 5) box.attach(l_port, 0, 1, 5, 6) box.attach(t_proxy_port, 1, 2, 5, 6) box.attach(c_use_auth, 0, 2, 6, 7) box.attach(l_user, 0, 1, 7, 8) box.attach(t_user, 1, 2, 7, 8) box.attach(l_passwd, 0, 1, 8, 9) box.attach(t_passwd, 1, 2, 8, 9) index = 0 count = 0 name_to_ext = {} session_found = False default_session_index = 0 default_session = extension.get_default('session') for ext_id, ext in extension.get_extensions('session').iteritems(): if session == ext_id: index = count t_server_host.set_text(ext.DEFAULT_HOST) t_server_port.set_text(ext.DEFAULT_PORT) session_found = True print session if default_session.NAME == ext.NAME: default_session_index = count combo.append_text(ext.NAME) name_to_ext[ext.NAME] = (ext_id, ext) count += 1 if session_found: combo.set_active(index) else: combo.set_active(default_session_index) def on_session_changed(*args): session_id, ext = name_to_ext[combo.get_active_text()] t_server_host.set_text(ext.DEFAULT_HOST) t_server_port.set_text(ext.DEFAULT_PORT) combo.connect('changed', on_session_changed) def response_cb(response): '''called on any response (close, accept, cancel) if accept get the new values and call callback with those values''' if response == stock.ACCEPT: use_http = c_use_http.get_active() use_proxy = c_use_proxy.get_active() use_auth = c_use_auth.get_active() proxy_host = t_proxy_host.get_text() proxy_port = t_proxy_port.get_text() server_host = t_server_host.get_text() server_port = t_server_port.get_text() user = t_user.get_text() passwd = t_passwd.get_text() session_id, ext = name_to_ext[combo.get_active_text()] callback(use_http, use_proxy, proxy_host, proxy_port, use_auth, user, passwd, session_id, server_host, server_port) window.hide() def button_cb(button, window, response_cb, response): '''called when a button is pressedm get the response id and call the response_cb that will handle the event according to the response''' response_cb(response) window = cls.new_window('Preferences', response_cb) window.set_modal(True) window.hbox.pack_start(content, True, True) session_box = gtk.HBox(spacing=4) session_box.pack_start(l_session, True, True) session_box.pack_start(combo, True, True) advanced.add(box) content.pack_start(session_box, False) content.pack_start(advanced, True, True) cls.add_button(window, gtk.STOCK_CANCEL, stock.CANCEL, response_cb, button_cb) cls.add_button(window, gtk.STOCK_OK, stock.ACCEPT, response_cb, button_cb) window.show_all() for widget in proxy_settings: widget.hide()
def __init__(self, callback, on_preferences_changed, config, config_dir, config_path, proxy=None, use_http=None, session_id=None): gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=1.0, yscale=1.0) self.config = config self.config_dir = config_dir self.config_path = config_path self.callback = callback self.on_preferences_changed = on_preferences_changed # the id of the default extension that handles the session # used to select the default session on the preference dialog self.use_http = use_http self.session_id = session_id account = self.config.get_or_set('last_logged_account', '') self.remembers = self.config.get_or_set('d_remembers', {}) self.status = self.config.get_or_set('d_status',{}) self.accounts = self.config.d_accounts if proxy is None: self.proxy = e3.Proxy() else: self.proxy = proxy self.dialog = extension.get_default('dialog') if session_id is not None: for ext_id, ext in extension.get_extensions('session').iteritems(): if session_id == ext_id: self.server_host = ext.DEFAULT_HOST self.server_port = ext.DEFAULT_PORT else: self.server_host = extension.get_default('session').DEFAULT_HOST self.server_port = extension.get_default('session').DEFAULT_PORT self.liststore = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf) completion = gtk.EntryCompletion() completion.set_model(self.liststore) pixbufcell = gtk.CellRendererPixbuf() completion.pack_start(pixbufcell) completion.add_attribute(pixbufcell, 'pixbuf', 1) completion.set_text_column(0) completion.set_inline_selection(True) self.pixbuf = utils.safe_gtk_pixbuf_load(gui.theme.user) self._reload_account_list() self.cmb_account = gtk.ComboBoxEntry(self.liststore, 0) self.cmb_account.get_children()[0].set_completion(completion) self.cmb_account.get_children()[0].connect('key-press-event', self._on_account_key_press) self.cmb_account.connect('changed', self._on_account_changed) self.btn_status = StatusButton.StatusButton() self.btn_status.set_status(e3.status.ONLINE) status_padding = gtk.Label() status_padding.set_size_request(*self.btn_status.size_request()) self.txt_password = gtk.Entry() self.txt_password.set_visibility(False) self.txt_password.connect('key-press-event', self._on_password_key_press) self.txt_password.connect('changed', self._on_password_changed) pix_account = utils.safe_gtk_pixbuf_load(gui.theme.user) pix_password = utils.safe_gtk_pixbuf_load(gui.theme.password) self.img_account = gtk.Image() path = self.config_dir.join(account.replace('@','-at-'), \ 'avatars', 'last') if self.config_dir.file_readable(path): pix = utils.safe_gtk_pixbuf_load(path, (96,96)) else: pix = utils.safe_gtk_pixbuf_load(gui.theme.logo) self.img_account.set_from_pixbuf(pix) self.remember_account = gtk.CheckButton(_('Remember me')) self.remember_password = gtk.CheckButton(_('Remember password')) self.auto_login = gtk.CheckButton(_('Auto-login')) self.remember_account.connect('toggled', self._on_remember_account_toggled) self.remember_password.connect('toggled', self._on_remember_password_toggled) self.auto_login.connect('toggled', self._on_auto_login_toggled) self.forget_me = gtk.EventBox() self.forget_me.set_events(gtk.gdk.BUTTON_PRESS_MASK) self.forget_me_label = gtk.Label('<span foreground="#0000AA">(' + \ _('Forget me') + ')</span>') self.forget_me_label.set_use_markup(True) self.forget_me.add(self.forget_me_label) self.forget_me.connect('button_press_event', self._on_forget_me_clicked) self.forget_me.set_child_visible(False) hboxremember = gtk.HBox(spacing=2) hboxremember.pack_start(self.remember_account, False, False) hboxremember.pack_start(self.forget_me, False, False) vbox_remember = gtk.VBox(spacing=4) vbox_remember.set_border_width(8) vbox_remember.pack_start(hboxremember) vbox_remember.pack_start(self.remember_password) vbox_remember.pack_start(self.auto_login) self.b_connect = gtk.Button(stock=gtk.STOCK_CONNECT) self.b_connect.connect('clicked', self._on_connect_clicked) self.b_connect.set_border_width(8) vbox = gtk.VBox() hbox_account = gtk.HBox(spacing=6) img_accountpix = gtk.Image() img_accountpix.set_from_pixbuf(utils.scale_nicely(pix_account)) hbox_account.pack_start(img_accountpix, False) hbox_account.pack_start(self.cmb_account, True, True) hbox_account.pack_start(status_padding, False) hbox_password = gtk.HBox(spacing=6) img_password = gtk.Image() img_password.set_from_pixbuf(utils.scale_nicely(pix_password)) hbox_password.pack_start(img_password, False) hbox_password.pack_start(self.txt_password, True, True) hbox_password.pack_start(self.btn_status, False) vbox_entries = gtk.VBox(spacing=12) vbox_entries.set_border_width(8) vbox_entries.pack_start(hbox_account) vbox_entries.pack_start(hbox_password) self.b_preferences = gtk.Button() self.img_preferences = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU) self.img_preferences.set_sensitive(False) self.b_preferences.set_image(self.img_preferences) self.b_preferences.set_relief(gtk.RELIEF_NONE) self.b_preferences.connect('enter-notify-event', self._on_preferences_enter) self.b_preferences.connect('leave-notify-event', self._on_preferences_leave) self.b_preferences.connect('clicked', self._on_preferences_selected) self.nicebar = NiceBar.NiceBar(default_background= \ NiceBar.ALERTBACKGROUND) al_logo = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.0) al_vbox_entries = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2, yscale=0.0) al_vbox_remember = gtk.Alignment(xalign=0.55, yalign=0.5, xscale=0.05, yscale=0.2) al_button = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.15) al_account = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.0) al_preferences = gtk.Alignment(xalign=1.0, yalign=0.5) al_vbox_entries.add(vbox_entries) al_vbox_remember.add(vbox_remember) al_button.add(self.b_connect) al_account.add(self.img_account) al_preferences.add(self.b_preferences) vbox.pack_start(self.nicebar, False) vbox.pack_start(al_account, True, False) vbox.pack_start(al_vbox_entries, True, True) vbox.pack_start(al_vbox_remember, True, False) vbox.pack_start(al_button, True, True) vbox.pack_start(al_preferences, False) self.add(vbox) vbox.show_all() self.nicebar.hide() if account != '': self.cmb_account.get_children()[0].set_text(account)
def __init__(self, callback, on_preferences_changed, config, config_dir, config_path, proxy=None, use_http=None, session_id=None, cancel_clicked=False, no_autologin=False): LoginBase.__init__(self, callback) self.config = config self.config_dir = config_dir self.config_path = config_path self.callback = callback self.cancel_clicked = cancel_clicked self.on_preferences_changed = on_preferences_changed self.no_autologin = no_autologin # the id of the default extension that handles the session # used to select the default session on the preference dialog self.use_http = use_http self.session_id = session_id account = self.config.get_or_set('last_logged_account', '') self.config.get_or_set('service', 'msn') self.remembers = self.config.get_or_set('d_remembers', {}) self.config.get_or_set('d_user_service', {}) self.status = self.config.get_or_set('d_status', {}) #convert old configs to the new format if len(account.split('|')) == 1: config_keys = self.config.d_remembers.keys() for _account in config_keys: account_and_service = \ _account + '|' + \ self.config.d_user_service.get(_account, 'msn') if _account == account: self.config.last_logged_account = account_and_service account = account_and_service self.config.d_remembers[account_and_service] = \ self.config.d_remembers.get(_account) self.config.d_remembers.pop(_account, None) self.config.d_status[account_and_service] = \ self.config.d_status.get(_account) self.config.d_status.pop(_account, None) _value = self.config.d_accounts.get(_account) if _value: self.config.d_accounts[account_and_service] = _value self.config.d_accounts.pop(_account, None) self.remembers = self.config.d_remembers self.status = self.config.d_status self.accounts = self.config.d_accounts self.b_connect.connect('clicked', self._on_connect_clicked) self._combo_session_list = [] self.new_combo_session() self._reload_account_list() if proxy is None: self.proxy = e3.Proxy() else: self.proxy = proxy self.services = {} if session_id is not None: for ext_id, ext in extension.get_extensions('session').iteritems(): for service_name, service_data in ext.SERVICES.iteritems(): self.services[service_name] = service_data if session_id == ext_id and self.config.service in ext.SERVICES: self.server_host = ext.SERVICES[self.config.service]['host'] self.server_port = ext.SERVICES[self.config.service]['port'] break else: self.config.service = 'msn' self.server_host = 'messenger.hotmail.com' self.server_port = '1863' else: self.config.service = 'msn' self.server_host = 'messenger.hotmail.com' self.server_port = '1863' avatar_path = self.config_dir.join( self.server_host, account.rpartition('|')[0], 'avatars', 'last') self.avatar.set_from_file(avatar_path) self.nicebar.hide() self.throbber.hide() self.label_timer.hide() self.b_cancel.hide() if account != '': self.cmb_account.get_children()[0].set_text( account.rpartition('|')[0]) if not self.cancel_clicked: self._check_autologin()
def __init__(self, callback, on_preferences_changed, config, config_dir, config_path, proxy=None, use_http=None, session_id=None, cancel_clicked=False, no_autologin=False): LoginBase.__init__(self, callback) self.config = config self.config_dir = config_dir self.config_path = config_path self.callback = callback self.cancel_clicked = cancel_clicked self.on_preferences_changed = on_preferences_changed self.no_autologin = no_autologin # the id of the default extension that handles the session # used to select the default session on the preference dialog self.use_http = use_http self.session_id = session_id account = self.config.get_or_set('last_logged_account', '') self.config.get_or_set('service', 'msn') self.remembers = self.config.get_or_set('d_remembers', {}) self.config.get_or_set('d_user_service', {}) self.status = self.config.get_or_set('d_status', {}) self.accounts = self.config.d_accounts self.b_connect.connect('clicked', self._on_connect_clicked) self._reload_account_list() self.__combo_session_list = [] if proxy is None: self.proxy = e3.Proxy() else: self.proxy = proxy self.services = {} if session_id is not None: for ext_id, ext in extension.get_extensions('session').iteritems(): for service_name, service_data in ext.SERVICES.iteritems(): self.services[service_name] = service_data if session_id == ext_id and self.config.service in ext.SERVICES: self.server_host = ext.SERVICES[ self.config.service]['host'] self.server_port = ext.SERVICES[ self.config.service]['port'] break else: self.config.service = 'msn' self.server_host = 'messenger.hotmail.com' self.server_port = '1863' else: self.config.service = 'msn' self.server_host = 'messenger.hotmail.com' self.server_port = '1863' avatar_path = self.config_dir.join(self.server_host, account, 'avatars', 'last') self.avatar.set_from_file(avatar_path) self.nicebar.hide() self.throbber.hide() self.label_timer.hide() self.b_cancel.hide() if account != '': self.cmb_account.get_children()[0].set_text(account) if not self.cancel_clicked: self._check_autologin() self._show_sessions()
def __init__( self, callback, on_preferences_changed, config, config_dir, config_path, proxy=None, use_http=None, session_id=None, cancel_clicked=False, no_autologin=False, ): LoginBase.__init__(self, callback) self.config = config self.config_dir = config_dir self.config_path = config_path self.callback = callback self.cancel_clicked = cancel_clicked self.on_preferences_changed = on_preferences_changed self.no_autologin = no_autologin # the id of the default extension that handles the session # used to select the default session on the preference dialog self.use_http = use_http self.session_id = session_id account = self.config.get_or_set("last_logged_account", "") self.config.get_or_set("service", "msn") self.remembers = self.config.get_or_set("d_remembers", {}) self.config.get_or_set("d_user_service", {}) self.status = self.config.get_or_set("d_status", {}) self.accounts = self.config.d_accounts self.b_connect.connect("clicked", self._on_connect_clicked) self._reload_account_list() self.__combo_session_list = [] if proxy is None: self.proxy = e3.Proxy() else: self.proxy = proxy self.services = {} if session_id is not None: for ext_id, ext in extension.get_extensions("session").iteritems(): for service_name, service_data in ext.SERVICES.iteritems(): self.services[service_name] = service_data if session_id == ext_id and self.config.service in ext.SERVICES: self.server_host = ext.SERVICES[self.config.service]["host"] self.server_port = ext.SERVICES[self.config.service]["port"] break else: self.config.service = "msn" self.server_host = "messenger.hotmail.com" self.server_port = "1863" else: self.config.service = "msn" self.server_host = "messenger.hotmail.com" self.server_port = "1863" avatar_path = self.config_dir.join(self.server_host, account, "avatars", "last") self.avatar.set_from_file(avatar_path) self.nicebar.hide() self.throbber.hide() self.label_timer.hide() self.b_cancel.hide() if account != "": self.cmb_account.get_children()[0].set_text(account) if not self.cancel_clicked: self._check_autologin() self._show_sessions()
def login_preferences(cls, service, service_host, service_port, callback, use_http, proxy): """ display the preferences dialog for the login window cls -- the dialog class service -- the service string identifier (for example 'gtalk') callback -- callback to call if the user press accept, call with the new values use_http -- boolean that indicates if the e3 should use http method proxy -- a e3.Proxy object """ def on_session_changed(*args): '''Callback called when the session type in the combo is called''' service = str(session_cmb.currentText()) session_id, ext = name_to_ext[service] server_host_edit.setText(ext.SERVICES[service]['host']) server_port_edit.setText(ext.SERVICES[service]['port']) def on_use_auth_toggled(is_enabled, is_checked): '''called when the auth check button is toggled, receive a set of entries, enable or disable auth related widgets deppending on the state of the check button''' auth_settings = (user_lbl, user_edit, pwd_lbl, pwd_edit) state = (is_enabled and is_checked) for widget in auth_settings: widget.setEnabled(state) def on_use_proxy_toggled(is_checked, *args): '''Callback invoked when the 'use proxy' checkbox is toggled. enables or disables widgets to insert proxy settings accordingly''' proxy_settings = (host_lbl, proxy_host_edit, port_lbl, proxy_port_edit, auth_chk) print 'upt' for widget in proxy_settings: widget.setEnabled(is_checked) on_use_auth_toggled(is_checked, auth_chk.isChecked()) def response_cb(response): '''called on any response (close, accept, cancel) if accept get the new values and call callback with those values''' if response == gui.stock.ACCEPT: use_http = http_chk.isChecked() use_proxy = proxy_chk.isChecked() use_auth = auth_chk.isChecked() proxy_host = str(proxy_host_edit.text()) proxy_port = str(proxy_port_edit.text()) server_host = str(server_host_edit.text()) server_port = str(server_port_edit.text()) user = str(user_edit.text()) passwd = str(pwd_edit.text()) service = str(session_cmb.currentText()) session_id, ext = name_to_ext[service] print session_id callback(use_http, use_proxy, proxy_host, proxy_port, use_auth, user, passwd, session_id, service, server_host, server_port) dialog.hide() dialog = OkCancelDialog() session_lbl = QtGui.QLabel(_('Session')) session_cmb = QtGui.QComboBox() server_host_lbl = QtGui.QLabel(_('Server')) server_host_edit = QtGui.QLineEdit() server_port_lbl = QtGui.QLabel(_('Port')) server_port_edit = QtGui.QLineEdit() http_chk = QtGui.QCheckBox(_('Use HTTP method')) proxy_chk = QtGui.QCheckBox(_('Use proxy')) host_lbl = QtGui.QLabel(_('Host')) proxy_host_edit = QtGui.QLineEdit() port_lbl = QtGui.QLabel(_('Port')) proxy_port_edit = QtGui.QLineEdit() auth_chk = QtGui.QCheckBox(_('Use authentication')) user_lbl = QtGui.QLabel(_('User')) user_edit = QtGui.QLineEdit() pwd_lbl = QtGui.QLabel(_('Password')) pwd_edit = QtGui.QLineEdit() grid_lay = QtGui.QGridLayout() grid_lay.setHorizontalSpacing(20) grid_lay.setVerticalSpacing(4) grid_lay.addWidget(session_lbl, 0, 0) grid_lay.addWidget(session_cmb, 0, 2) grid_lay.addWidget(server_host_lbl, 1, 0) grid_lay.addWidget(server_host_edit, 1, 2) grid_lay.addWidget(server_port_lbl, 2, 0) grid_lay.addWidget(server_port_edit, 2, 2) grid_lay.addWidget(http_chk, 3, 0, 1, -1) grid_lay.addWidget(proxy_chk, 4, 0, 1, -1) grid_lay.addWidget(host_lbl, 5, 0) grid_lay.addWidget(proxy_host_edit, 5, 2) grid_lay.addWidget(port_lbl, 6, 0) grid_lay.addWidget(proxy_port_edit, 6, 2) grid_lay.addWidget(auth_chk, 7, 0, 1, -1) grid_lay.addWidget(user_lbl, 8, 0) grid_lay.addWidget(user_edit, 8, 2) grid_lay.addWidget(pwd_lbl, 9, 0) grid_lay.addWidget(pwd_edit, 9, 2) dialog.setLayout(grid_lay) dialog.setWindowTitle('Preferences') server_host_edit.setText(service_host) server_port_edit.setText(service_port) proxy_host_edit.setText(proxy.host or '') proxy_port_edit.setText(proxy.port or '') user_edit.setText(proxy.user or '') pwd_edit.setText(proxy.passwd or '') #pwd_edit.setVisible(False) http_chk.setChecked(use_http) index = 0 count = 0 name_to_ext = {} session_found = False default_session_index = 0 default_session = extension.get_default('session') for ext_id, ext in extension.get_extensions('session').iteritems(): if default_session.NAME == ext.NAME: default_session_index = count for service_name, service_data in ext.SERVICES.iteritems(): if service == service_name: index = count server_host_edit.setText(service_data['host']) server_port_edit.setText(service_data['port']) session_found = True session_cmb.addItem(service_name) name_to_ext[service_name] = (ext_id, ext) count += 1 if session_found: session_cmb.setCurrentIndex(index) else: session_cmb.setCurrentIndex(default_session_index) session_cmb.currentIndexChanged.connect(on_session_changed) proxy_chk.toggled.connect(on_use_proxy_toggled) auth_chk.toggled.connect(lambda checked: on_use_auth_toggled(auth_chk.isEnabled(), checked)) # putting these there to trigger the slots: proxy_chk.setChecked(not proxy.use_proxy) proxy_chk.setChecked(proxy.use_proxy) auth_chk.setChecked(not proxy.use_auth) auth_chk.setChecked(proxy.use_auth) dialog.resize(300, 300) dialog.show() #for widget in proxy_settings: #widget.hide() response = dialog.exec_() if response == QtGui.QDialog.Accepted: response = gui.stock.ACCEPT elif response == QtGui.QDialog.Rejected: response = gui.stock.CANCEL print response response_cb(response)
def login_preferences(cls, service, service_host, service_port, callback, use_http, proxy): """ display the preferences dialog for the login window cls -- the dialog class service -- the service string identifier (for example 'gtalk') callback -- callback to call if the user press accept, call with the new values use_http -- boolean that indicates if the e3 should use http method proxy -- a e3.Proxy object """ def on_session_changed(*args): '''Callback called when the session type in the combo is called''' service = str(session_cmb.currentText()) session_id, ext = name_to_ext[service] server_host_edit.setText(ext.SERVICES[service]['host']) server_port_edit.setText(ext.SERVICES[service]['port']) def on_use_auth_toggled(is_enabled, is_checked): '''called when the auth check button is toggled, receive a set of entries, enable or disable auth related widgets deppending on the state of the check button''' auth_settings = (user_lbl, user_edit, pwd_lbl, pwd_edit) state = (is_enabled and is_checked) for widget in auth_settings: widget.setEnabled(state) def on_use_proxy_toggled(is_checked, *args): '''Callback invoked when the 'use proxy' checkbox is toggled. enables or disables widgets to insert proxy settings accordingly''' proxy_settings = (host_lbl, proxy_host_edit, port_lbl, proxy_port_edit, auth_chk) log.info('upt') for widget in proxy_settings: widget.setEnabled(is_checked) on_use_auth_toggled(is_checked, auth_chk.isChecked()) def response_cb(response): '''called on any response (close, accept, cancel) if accept get the new values and call callback with those values''' if response == gui.stock.ACCEPT: use_http = http_chk.isChecked() use_proxy = proxy_chk.isChecked() use_auth = auth_chk.isChecked() proxy_host = str(proxy_host_edit.text()) proxy_port = str(proxy_port_edit.text()) server_host = str(server_host_edit.text()) server_port = str(server_port_edit.text()) user = str(user_edit.text()) passwd = str(pwd_edit.text()) service = str(session_cmb.currentText()) session_id, ext = name_to_ext[service] log.debug(str(session_id)) callback(use_http, use_proxy, proxy_host, proxy_port, use_auth, user, passwd, session_id, service, server_host, server_port) dialog.hide() dialog = OkCancelDialog(unicode(tr('Connection preferences'))) session_lbl = QtGui.QLabel(unicode(tr('Session:'))) session_cmb = QtGui.QComboBox() server_host_lbl = QtGui.QLabel(unicode(tr('Server'))) server_host_edit = QtGui.QLineEdit() server_port_lbl = QtGui.QLabel(unicode(tr('Port'))) server_port_edit = QtGui.QLineEdit() http_chk = QtGui.QCheckBox(unicode(tr('Use HTTP method'))) proxy_chk = QtGui.QCheckBox(unicode(tr('Use proxy'))) host_lbl = QtGui.QLabel(unicode(tr('Host'))) proxy_host_edit = QtGui.QLineEdit() port_lbl = QtGui.QLabel(unicode(tr('Port'))) proxy_port_edit = QtGui.QLineEdit() auth_chk = QtGui.QCheckBox(unicode(tr('Use authentication'))) user_lbl = QtGui.QLabel(unicode(tr('User'))) user_edit = QtGui.QLineEdit() pwd_lbl = QtGui.QLabel(unicode(tr('Password'))) pwd_edit = QtGui.QLineEdit() grid_lay = QtGui.QGridLayout() grid_lay.setHorizontalSpacing(20) grid_lay.setVerticalSpacing(4) grid_lay.addWidget(session_lbl, 0, 0) grid_lay.addWidget(session_cmb, 0, 2) grid_lay.addWidget(server_host_lbl, 1, 0) grid_lay.addWidget(server_host_edit, 1, 2) grid_lay.addWidget(server_port_lbl, 2, 0) grid_lay.addWidget(server_port_edit, 2, 2) grid_lay.addWidget(http_chk, 3, 0, 1, -1) grid_lay.addWidget(proxy_chk, 4, 0, 1, -1) grid_lay.addWidget(host_lbl, 5, 0) grid_lay.addWidget(proxy_host_edit, 5, 2) grid_lay.addWidget(port_lbl, 6, 0) grid_lay.addWidget(proxy_port_edit, 6, 2) grid_lay.addWidget(auth_chk, 7, 0, 1, -1) grid_lay.addWidget(user_lbl, 8, 0) grid_lay.addWidget(user_edit, 8, 2) grid_lay.addWidget(pwd_lbl, 9, 0) grid_lay.addWidget(pwd_edit, 9, 2) dialog.setLayout(grid_lay) dialog.setWindowTitle(tr('Preferences')) server_host_edit.setText(service_host) server_port_edit.setText(service_port) proxy_host_edit.setText(proxy.host or '') proxy_port_edit.setText(proxy.port or '') user_edit.setText(proxy.user or '') pwd_edit.setText(proxy.passwd or '') #pwd_edit.setVisible(False) http_chk.setChecked(use_http) index = 0 count = 0 name_to_ext = {} session_found = False default_session_index = 0 default_session = extension.get_default('session') for ext_id, ext in extension.get_extensions('session').iteritems(): if default_session.NAME == ext.NAME: default_session_index = count for service_name, service_data in ext.SERVICES.iteritems(): if service == service_name: index = count server_host_edit.setText(service_data['host']) server_port_edit.setText(service_data['port']) session_found = True session_cmb.addItem(service_name) name_to_ext[service_name] = (ext_id, ext) count += 1 if session_found: session_cmb.setCurrentIndex(index) else: session_cmb.setCurrentIndex(default_session_index) session_cmb.currentIndexChanged.connect(on_session_changed) proxy_chk.toggled.connect(on_use_proxy_toggled) auth_chk.toggled.connect( lambda checked: on_use_auth_toggled(auth_chk.isEnabled(), checked)) # putting these there to trigger the slots: proxy_chk.setChecked(not proxy.use_proxy) proxy_chk.setChecked(proxy.use_proxy) auth_chk.setChecked(not proxy.use_auth) auth_chk.setChecked(proxy.use_auth) dialog.resize(300, 300) dialog.show() #for widget in proxy_settings: #widget.hide() response = dialog.exec_() if response == QtGui.QDialog.Accepted: response = gui.stock.ACCEPT elif response == QtGui.QDialog.Rejected: response = gui.stock.CANCEL log.debug(str(response)) response_cb(response)
def __init__(self, callback, on_preferences_changed, config, config_dir, config_path, proxy=None, use_http=None, session_id=None, cancel_clicked=False, no_autologin=False): LoginBase.__init__(self, callback) self.config = config self.config_dir = config_dir self.config_path = config_path self.callback = callback self.on_preferences_changed = on_preferences_changed self.no_autologin = no_autologin # the id of the default extension that handles the session # used to select the default session on the preference dialog self.use_http = use_http self.session_id = session_id account = self.config.get_or_set('last_logged_account', '') self.config.get_or_set('service', 'msn') self.remembers = self.config.get_or_set('d_remembers', {}) self.config.get_or_set('d_user_service', {}) self.status = self.config.get_or_set('d_status',{}) self.accounts = self.config.d_accounts self._reload_account_list() if proxy is None: self.proxy = e3.Proxy() else: self.proxy = proxy self.services = {} if session_id is not None: for ext_id, ext in extension.get_extensions('session').iteritems(): for service_name, service_data in ext.SERVICES.iteritems(): self.services[service_name] = service_data if session_id == ext_id and self.config.service in ext.SERVICES: self.server_host = ext.SERVICES[self.config.service]['host'] self.server_port = ext.SERVICES[self.config.service]['port'] break else: self.config.service = 'msn' self.server_host = 'messenger.hotmail.com' self.server_port = '1863' else: self.config.service = 'msn' self.server_host = 'messenger.hotmail.com' self.server_port = '1863' avatar_path = self.config_dir.join(self.server_host, account, 'avatars', 'last') self.avatar.set_from_file(avatar_path) self.nicebar.hide() self.throbber.hide() self.label_timer.hide() self.b_cancel.hide() if account != '': self.cmb_account.get_children()[0].set_text(account) if not cancel_clicked: self._check_autologin()
def login_preferences(cls, session, callback, use_http, proxy): """ display the preferences dialog for the login window cls -- the dialog class session -- the session string identifier callback -- callback to call if the user press accept, call with the new values use_http -- boolean that indicates if the e3 should use http method proxy -- a e3.Proxy object """ content = gtk.VBox() box = gtk.Table(9, 2) combo = gtk.combo_box_new_text() t_host = gtk.Entry() t_port = gtk.Entry() t_user = gtk.Entry() t_passwd = gtk.Entry() def on_toggled(check_button, *entries): """called when a check button is toggled, receive a set of entries, enable or disable them deppending on the state of the check button""" for entry in entries: entry.set_sensitive(check_button.get_active()) c_use_http = gtk.CheckButton("Use HTTP method") c_use_proxy = gtk.CheckButton("Use proxy") c_use_proxy.connect("toggled", on_toggled, t_host, t_port) c_use_auth = gtk.CheckButton("Use authentication") c_use_auth.connect("toggled", on_toggled, t_user, t_passwd) t_host.set_text(proxy.host or "") t_port.set_text(proxy.port or "") t_user.set_text(proxy.user or "") t_passwd.set_text(proxy.passwd or "") t_passwd.set_visibility(False) c_use_http.set_active(use_http) c_use_proxy.set_active(proxy.use_proxy) c_use_proxy.toggled() c_use_proxy.toggled() c_use_auth.set_active(proxy.use_auth) c_use_auth.toggled() c_use_auth.toggled() l_session = gtk.Label("Session") l_session.set_alignment(0.0, 0.5) l_host = gtk.Label("Host") l_host.set_alignment(0.0, 0.5) l_port = gtk.Label("Port") l_port.set_alignment(0.0, 0.5) l_user = gtk.Label("User") l_user.set_alignment(0.0, 0.5) l_passwd = gtk.Label("Password") l_passwd.set_alignment(0.0, 0.5) box.attach(l_session, 0, 1, 0, 1) box.attach(combo, 1, 2, 0, 1) box.attach(c_use_http, 0, 2, 1, 2) box.attach(c_use_proxy, 0, 2, 2, 3) box.attach(l_host, 0, 1, 3, 4) box.attach(t_host, 1, 2, 3, 4) box.attach(l_port, 0, 1, 4, 5) box.attach(t_port, 1, 2, 4, 5) box.attach(c_use_auth, 0, 2, 5, 6) box.attach(l_user, 0, 1, 6, 7) box.attach(t_user, 1, 2, 6, 7) box.attach(l_passwd, 0, 1, 7, 8) box.attach(t_passwd, 1, 2, 7, 8) index = 0 count = 0 name_to_id = {} for ext_id, ext in extension.get_extensions("session").iteritems(): if session == ext_id: index = count combo.append_text(ext.NAME) name_to_id[ext.NAME] = ext_id count += 1 combo.set_active(index) def response_cb(response): """called on any response (close, accept, cancel) if accept get the new values and call callback with those values""" if response == stock.ACCEPT: use_http = c_use_http.get_active() use_proxy = c_use_proxy.get_active() use_auth = c_use_auth.get_active() host = t_host.get_text() port = t_port.get_text() user = t_user.get_text() passwd = t_passwd.get_text() session_id = name_to_id[combo.get_active_text()] callback(use_http, use_proxy, host, port, use_auth, user, passwd, session_id) window.hide() def button_cb(button, window, response_cb, response): """called when a button is pressedm get the response id and call the response_cb that will handle the event according to the response""" response_cb(response) window = cls.new_window("Preferences", response_cb) window.set_modal(True) window.hbox.pack_start(content, True, True) content.pack_start(box, True, True) cls.add_button(window, gtk.STOCK_CANCEL, stock.CANCEL, response_cb, button_cb) cls.add_button(window, gtk.STOCK_OK, stock.ACCEPT, response_cb, button_cb) window.show_all()
def _get_categories(self): ''' get available categories''' categories = [ctg for ctg in extension.get_categories().keys() \ if len(extension.get_extensions(ctg)) > 1] categories.sort() return categories
def __init__(self, callback, on_preferences_changed, config, config_dir, config_path, proxy=None, use_http=None, session_id=None): gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=0.0, yscale=1.0) self.config = config self.config_dir = config_dir self.config_path = config_path self.callback = callback self.on_preferences_changed = on_preferences_changed # the id of the default extension that handles the session # used to select the default session on the preference dialog self.use_http = use_http self.session_id = session_id account = self.config.get_or_set('last_logged_account', '') self.remembers = self.config.get_or_set('d_remembers', {}) self.status = self.config.get_or_set('d_status',{}) self.accounts = self.config.d_accounts if proxy is None: self.proxy = e3.Proxy() else: self.proxy = proxy self.dialog = extension.get_default('dialog') Avatar = extension.get_default('avatar') NiceBar = extension.get_default('nice bar') if session_id is not None: for ext_id, ext in extension.get_extensions('session').iteritems(): if session_id == ext_id: self.server_host = ext.DEFAULT_HOST self.server_port = ext.DEFAULT_PORT else: self.server_host = extension.get_default('session').DEFAULT_HOST self.server_port = extension.get_default('session').DEFAULT_PORT else: self.server_host = extension.get_default('session').DEFAULT_HOST self.server_port = extension.get_default('session').DEFAULT_PORT self.liststore = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf) completion = gtk.EntryCompletion() completion.set_model(self.liststore) pixbufcell = gtk.CellRendererPixbuf() completion.pack_start(pixbufcell) completion.add_attribute(pixbufcell, 'pixbuf', 1) completion.set_text_column(0) completion.set_inline_selection(True) self.pixbuf = utils.safe_gtk_pixbuf_load(gui.theme.user) self._reload_account_list() self.cmb_account = gtk.ComboBoxEntry(self.liststore, 0) self.cmb_account.get_children()[0].set_completion(completion) self.cmb_account.get_children()[0].connect('key-press-event', self._on_account_key_press) self.cmb_account.connect('changed', self._on_account_changed) self.btn_status = StatusButton.StatusButton() self.btn_status.set_status(e3.status.ONLINE) self.txt_password = gtk.Entry() self.txt_password.set_visibility(False) self.txt_password.connect('key-press-event', self._on_password_key_press) self.txt_password.connect('changed', self._on_password_changed) self.txt_password.set_sensitive(False) pix_account = utils.safe_gtk_pixbuf_load(gui.theme.user) pix_password = utils.safe_gtk_pixbuf_load(gui.theme.password) self.avatar = Avatar() avatar_path = self.config_dir.join(self.server_host, account, 'avatars', 'last') self.avatar.set_from_file(avatar_path) self.remember_account = gtk.CheckButton(_('Remember me')) self.remember_password = gtk.CheckButton(_('Remember password')) self.auto_login = gtk.CheckButton(_('Auto-login')) self.remember_account.connect('toggled', self._on_remember_account_toggled) self.remember_password.connect('toggled', self._on_remember_password_toggled) self.auto_login.connect('toggled', self._on_auto_login_toggled) self.remember_account.set_sensitive(False) self.remember_password.set_sensitive(False) self.auto_login.set_sensitive(False) self.forget_me = gtk.Button() self.forget_me.set_tooltip_text(_('Delete user')) forget_img = gtk.image_new_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_MENU) self.forget_me.set_image(forget_img) self.forget_me.set_relief(gtk.RELIEF_NONE) self.forget_me.set_border_width(0) self.forget_me.connect('clicked', self._on_forget_me_clicked) self.forget_me.set_sensitive(False) hboxremember = gtk.HBox(spacing=2) hboxremember.pack_start(self.remember_account, False, False) vbox_remember = gtk.VBox(spacing=4) vbox_remember.set_border_width(8) vbox_remember.pack_start(hboxremember) vbox_remember.pack_start(self.remember_password) vbox_remember.pack_start(self.auto_login) self.b_connect = gtk.Button(stock=gtk.STOCK_CONNECT) self.b_connect.connect('clicked', self._on_connect_clicked) self.b_connect.set_border_width(8) self.b_connect.set_sensitive(False) vbox = gtk.VBox() hbox_account = gtk.HBox(spacing=6) img_accountpix = gtk.Image() img_accountpix.set_from_pixbuf(utils.scale_nicely(pix_account)) hbox_account.pack_start(img_accountpix, False) hbox_account.pack_start(self.cmb_account, True, True) hbox_account.pack_start(self.forget_me, False) hbox_password = gtk.HBox(spacing=6) img_password = gtk.Image() img_password.set_from_pixbuf(utils.scale_nicely(pix_password)) hbox_password.pack_start(img_password, False) hbox_password.pack_start(self.txt_password, True, True) hbox_password.pack_start(self.btn_status, False) vbox_entries = gtk.VBox(spacing=12) vbox_entries.set_border_width(8) vbox_entries.pack_start(hbox_account) vbox_entries.pack_start(hbox_password) self.b_preferences = gtk.Button() self.img_preferences = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU) self.img_preferences.set_sensitive(False) self.b_preferences.set_image(self.img_preferences) self.b_preferences.set_relief(gtk.RELIEF_NONE) self.b_preferences.connect('enter-notify-event', self._on_preferences_enter) self.b_preferences.connect('leave-notify-event', self._on_preferences_leave) self.b_preferences.connect('clicked', self._on_preferences_selected) self.nicebar = NiceBar() al_vbox_entries = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2, yscale=0.0) al_vbox_remember = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.2) al_button = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.20) al_account = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.0) al_preferences = gtk.Alignment(xalign=1.0, yalign=0.5) al_vbox_entries.add(vbox_entries) al_vbox_remember.add(vbox_remember) al_button.add(self.b_connect) al_account.add(self.avatar) al_preferences.add(self.b_preferences) vbox.pack_start(self.nicebar, False) vbox.pack_start(al_account, True, False) vbox.pack_start(al_vbox_entries, True, True) vbox.pack_start(al_vbox_remember, True, False) vbox.pack_start(al_button, True, True) vbox.pack_start(al_preferences, False) self.add(vbox) vbox.show_all() self.nicebar.hide() if account != '': self.cmb_account.get_children()[0].set_text(account)