• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python extension.get_extensions函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中extension.get_extensions函数的典型用法代码示例。如果您正苦于以下问题:Python get_extensions函数的具体用法?Python get_extensions怎么用?Python get_extensions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_extensions函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: do_x

 def do_x(self):
     for extra in extension.get_extensions('bar'):
         try:
             print 'bar', extra
             extra.bar()
         except:
             print 'NW', extra
开发者ID:boyska,项目名称:pluginmanager,代码行数:7,代码来源:main.py


示例2: bar

 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
开发者ID:DarKprince,项目名称:emesene2,代码行数:9,代码来源:bar.py


示例3: _add_extensions_combo

    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)
开发者ID:DarKprince,项目名称:emesene2,代码行数:14,代码来源:Preferences.py


示例4: _setup_config

 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
开发者ID:felippo,项目名称:emesene,代码行数:18,代码来源:LoginPage.py


示例5: _setup_services

    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'
开发者ID:Narciso91,项目名称:emesene,代码行数:18,代码来源:LoginBase.py


示例6: _on_category_changed

    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)
开发者ID:thalesweb,项目名称:emesene,代码行数:19,代码来源:Preferences.py


示例7: new_combo_session

    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)
开发者ID:sreekumar-kr,项目名称:emesene,代码行数:43,代码来源:Login.py


示例8: new_combo_session

    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
开发者ID:canyalkin,项目名称:emesene,代码行数:43,代码来源:Login.py


示例9: _on_category_changed

    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)
开发者ID:need47-test,项目名称:emesene,代码行数:20,代码来源:Preferences.py


示例10: new_combo_session

    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
开发者ID:ahlfors,项目名称:uazapp-im,代码行数:41,代码来源:LoginBase.py


示例11: _get_categories

 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
开发者ID:19MiRkO91,项目名称:emesene,代码行数:6,代码来源:Preferences.py


示例12: __init__

    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()
开发者ID:andreskru,项目名称:emesene,代码行数:65,代码来源:Login.py


示例13: __init__

    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()
开发者ID:nenemfromhell,项目名称:emesene,代码行数:80,代码来源:Login.py


示例14: login_preferences


#.........这里部分代码省略.........
        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)
开发者ID:EchoUSB,项目名称:emesene,代码行数:101,代码来源:Dialog.py


示例15: login_preferences

    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()]
#.........这里部分代码省略.........
开发者ID:Nassty,项目名称:emesene,代码行数:101,代码来源:Dialog.py


示例16: login_preferences


#.........这里部分代码省略.........

        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()
开发者ID:JPtja,项目名称:emesene,代码行数:67,代码来源:Dialog.py


示例17: run

 def run(self):
     for extra in extension.get_extensions('foo_category'):
         extra.do_it()
开发者ID:boyska,项目名称:pluginmanager,代码行数:3,代码来源:extension_test.py


示例18: __init__

    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)
#.........这里部分代码省略.........
开发者ID:JPtja,项目名称:emesene,代码行数:101,代码来源:Login.py


示例19: __init__

    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()
开发者ID:chicky85,项目名称:emesene,代码行数:96,代码来源:Login.py



注:本文中的extension.get_extensions函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python extension.implements函数代码示例发布时间:2022-05-24
下一篇:
Python extension.get_default函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap