本文整理汇总了Python中extension.get_default函数的典型用法代码示例。如果您正苦于以下问题:Python get_default函数的具体用法?Python get_default怎么用?Python get_default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_default函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, handler, session):
"""
constructor
handler -- e3common.Handler.ActionsHandler
"""
gtk.Menu.__init__(self)
self.handler = handler
ContactsMenu = extension.get_default('menu contact')
GroupsMenu = extension.get_default('menu group')
AccountMenu = extension.get_default('menu account')
self.contact = gtk.ImageMenuItem(_('_Contact'))
self.contact.set_image(utils.safe_gtk_image_load(gui.theme.image_theme.chat))
self.contact_menu = ContactsMenu(self.handler.contact_handler, session)
self.contact.set_submenu(self.contact_menu)
self.group = gtk.ImageMenuItem(_('_Group'))
self.group.set_image(utils.safe_gtk_image_load(gui.theme.image_theme.group_chat))
self.group_menu = GroupsMenu(self.handler.group_handler, session)
self.group.set_submenu(self.group_menu)
self.account = gtk.ImageMenuItem(_('_Account'))
self.account.set_image(utils.safe_gtk_image_load(gui.theme.image_theme.chat))
self.account_menu = AccountMenu(self.handler.my_account_handler)
self.myaccount = gtk.ImageMenuItem(_('_Profile'))
self.myaccount.set_image(utils.safe_gtk_image_load(gui.theme.image_theme.chat))
self.myaccount.set_submenu(self.account_menu)
self.append(self.contact)
self.append(self.group)
self.append(self.myaccount)
示例2: _setup_main_menu
def _setup_main_menu(self, session, contact_list, on_close, on_disconnect):
'''build all the menus used on the client'''
# retrieving classes:
dialog_cls = extension.get_default('dialog')
avatar_manager_cls = extension.get_default('avatar manager')
# creating the avatar manager:
avatar_manager = None #avatar_manager_cls(self._session)
# create menu handlers
menu_hnd = gui.base.MenuHandler(session, dialog_cls, contact_list,
on_disconnect, on_close)
contact_hnd = gui.base.ContactHandler(session, dialog_cls,
contact_list)
group_hnd = gui.base.GroupHandler(session, dialog_cls,
contact_list)
# retrieve menu classes
main_menu_cls = extension.get_default('main menu')
contact_menu_cls = extension.get_default('menu contact')
group_menu_cls = extension.get_default('menu group')
# instantiate menu objects:
menu = main_menu_cls(menu_hnd, session.config)
# self._contact_menu = contact_menu_cls(contact_hnd)
# self._group_menu = group_menu_cls(group_hnd)
# self._contact_menu.show_all()
# self._group_menu.show_all()
self.setMenuBar(menu)
示例3: on_contact_list_ready
def on_contact_list_ready(self):
'''callback called when the contact list is ready to be used'''
self.window.content.contact_list.fill()
def on_contact_added_you(responses):
'''
callback called when the dialog is closed
'''
for account in responses['accepted']:
self.session.add_contact(account)
for account in responses['rejected']:
self.session.reject_contact(account)
if self.session.contacts.pending:
accounts = []
for contact in self.session.contacts.pending.values():
accounts.append((contact.account, contact.display_name))
dialog = extension.get_default('dialog')
dialog.contact_added_you(accounts, on_contact_added_you)
glib.timeout_add(500, self.session.logger.check)
notificationcls = extension.get_default('notification')
self.notification = notificationcls(self.session)
示例4: __init__
def __init__(self, handler, session):
"""
constructor
handler -- e3common.Handler.ActionsHandler
"""
gtk.Menu.__init__(self)
ContactsMenu = extension.get_default('menu contact')
AccountMenu = extension.get_default('menu account')
contact = gtk.ImageMenuItem(_('_Contact'))
contact.set_image(utils.safe_gtk_image_load(gui.theme.image_theme.chat))
contact_menu = ContactsMenu(handler.contact_handler, session)
contact.set_submenu(contact_menu)
account = gtk.ImageMenuItem(_('_Account'))
account.set_image(utils.safe_gtk_image_load(gui.theme.image_theme.chat))
account_menu = AccountMenu(handler.my_account_handler)
myaccount = gtk.ImageMenuItem(_('_Profile'))
myaccount.set_image(utils.safe_gtk_image_load(gui.theme.image_theme.chat))
myaccount.set_submenu(account_menu)
self.append(contact)
if session.session_has_service(e3.Session.SERVICE_GROUP_MANAGING):
GroupsMenu = extension.get_default('menu group')
group = gtk.ImageMenuItem(_('_Group'))
group.set_image(utils.safe_gtk_image_load(gui.theme.image_theme.group_chat))
group_menu = GroupsMenu(handler.group_handler)
group.set_submenu(group_menu)
self.append(group)
self.append(myaccount)
示例5: _build_menus
def _build_menus(self):
'''buildall the menus used on the client'''
dialog = extension.get_default('dialog')
avatar_manager = extension.get_default('avatar manager')
am = avatar_manager(self.session)
handler = gui.base.MenuHandler(self.session, dialog, self.contact_list,
am, self.on_disconnect, self.on_close)
contact_handler = gui.base.ContactHandler(self.session, dialog,
self.contact_list)
group_handler = gui.base.GroupHandler(self.session, dialog,
self.contact_list)
MainMenu = extension.get_default('main menu')
ContactMenu = extension.get_default('menu contact')
GroupMenu = extension.get_default('menu group')
self.menu = MainMenu(handler, self.session.config)
self.contact_menu = ContactMenu(contact_handler)
self.group_menu = GroupMenu(group_handler)
self.contact_menu.show_all()
self.group_menu.show_all()
示例6: start
def start(self, account=None):
'''the entry point to the class'''
windowcls = extension.get_default('window frame')
self.window = windowcls(None) # main window
self._set_location(self.window)
if self.tray_icon is not None:
self.tray_icon.set_visible(False)
trayiconcls = extension.get_default('tray icon')
handler = gui.base.TrayIconHandler(self.session, gui.theme,
self.on_user_disconnect, self.on_close)
self.tray_icon = trayiconcls(handler, self.window)
proxy = self._get_proxy_settings()
use_http = self.config.get_or_set('b_use_http', False)
account = self.config.get_or_set('last_logged_account', '')
#autologin
default_session = extension.get_default('session')
if account != '' and int(self.config.d_remembers[account]) == 3:
password = base64.b64decode(self.config.d_accounts[account])
user = e3.Account(account, password,
int(self.config.d_status[account]),
default_session.DEFAULT_HOST)
host = default_session.DEFAULT_HOST
port = default_session.DEFAULT_PORT
self.on_login_connect(user, self.config.session, proxy, use_http,
host, int(port))
else:
self.go_login(proxy, use_http)
示例7: start
def start(self, account=None, accounts=None, on_disconnect=False):
'''the entry point to the class'''
Window = extension.get_default('window frame')
self.window = Window(None) # main window
if self.tray_icon is not None:
self.tray_icon.set_visible(False)
TrayIcon = extension.get_default('tray icon')
handler = gui.base.TrayIconHandler(self.session, gui.theme,
self.on_disconnect, self.on_close)
self.tray_icon = TrayIcon(handler, self.window)
proxy = self._get_proxy_settings()
use_http = self.config.get_or_set('b_use_http', False)
account = self.config.get_or_set('last_logged_account', '')
#autologin
if account != '' and int(self.config.d_remembers[account]) == 3 \
and not on_disconnect:
password = base64.b64decode(self.config.d_accounts[account])
user = e3.Account(account, password,
int(self.config.d_status[account]))
self.on_login_connect(user, self.config.session, proxy, use_http)
else:
self.go_login(on_disconnect, proxy, use_http)
示例8: __init__
def __init__(self, handler, session):
"""
constructor
handler -- e3common.Handler.ActionsHandler
"""
gtk.Menu.__init__(self)
self.handler = handler
ContactsMenu = extension.get_default("menu contact")
AccountMenu = extension.get_default("menu account")
self.contact = gtk.ImageMenuItem(_("_Contact"))
self.contact.set_image(utils.safe_gtk_image_load(gui.theme.image_theme.chat))
self.contact_menu = ContactsMenu(self.handler.contact_handler, session)
self.contact.set_submenu(self.contact_menu)
self.account = gtk.ImageMenuItem(_("_Account"))
self.account.set_image(utils.safe_gtk_image_load(gui.theme.image_theme.chat))
self.account_menu = AccountMenu(self.handler.my_account_handler)
self.myaccount = gtk.ImageMenuItem(_("_Profile"))
self.myaccount.set_image(utils.safe_gtk_image_load(gui.theme.image_theme.chat))
self.myaccount.set_submenu(self.account_menu)
self.append(self.contact)
if session.session_has_service(e3.Session.SERVICE_GROUP_MANAGING):
GroupsMenu = extension.get_default("menu group")
self.group = gtk.ImageMenuItem(_("_Group"))
self.group.set_image(utils.safe_gtk_image_load(gui.theme.image_theme.group_chat))
self.group_menu = GroupsMenu(self.handler.group_handler)
self.group.set_submenu(self.group_menu)
self.append(self.group)
self.append(self.myaccount)
示例9: on_avatar_click
def on_avatar_click(self,widget,data):
'''method called when user click on his avatar
'''
def set_picture_cb(response, filename):
'''callback for the avatar chooser'''
if response == gui.stock.ACCEPT:
if self.config_dir.base_dir.replace('@', '-at-') == \
os.path.dirname(os.path.dirname(filename)):
self.session.set_picture(filename)
os.remove(self.avatar_path)
shutil.copy2(filename, self.avatar_path)
return
#i save in 128*128 for the animation on connect..if somebody like it...:)
try:
pix_128 = utils.safe_gtk_pixbuf_load(filename, (128,128))
pix_128.save(path_dir + '_temp', 'png')
self.session.set_picture(path_dir + '_temp')
if os.path.exists(self.avatar_path):
os.remove(self.avatar_path)
pix_128.save(self.avatar_path, 'png')
except OSError as e:
print e
#TODO better way to do this???
path_dir = self.config_dir.join(os.path.dirname(self.config_dir.base_dir),
self.session.contacts.me.account.replace('@','-at-'),'avatars')
extension.get_default('avatar chooser')(set_picture_cb,
self.avatar_path, path_dir).show()
示例10: start
def start(self, account=None, accounts=None):
'''the entry point to the class'''
Window = extension.get_default('window frame')
self.window = Window(None) # main window
if self.tray_icon is not None:
self.tray_icon.set_visible(False)
TrayIcon = extension.get_default('tray icon')
handler = gui.base.TrayIconHandler(self.session, gui.theme,
self.on_disconnect, self.on_close)
self.tray_icon = TrayIcon(handler, self.window)
proxy = self._get_proxy_settings()
use_http = self.config.get_or_set('b_use_http', False)
posx = self.config.get_or_set('i_login_posx', 100)
posy = self.config.get_or_set('i_login_posy', 100)
width = self.config.get_or_set('i_login_width', 250)
height = self.config.get_or_set('i_login_height', 410)
self.window.go_login(self.on_login_connect,
self.on_preferences_changed, account,
self.config.d_accounts, self.config.l_remember_account,
self.config.l_remember_password, self.config.d_status,
self.config.session, proxy, use_http, self.config.session)
self.window.set_location(width, height, posx, posy)
self.window.show()
示例11: _build_menus
def _build_menus(self):
'''buildall the menus used on the client'''
dialog = extension.get_default('dialog')
avatar_manager = extension.get_default('avatar manager')
# TODO: probably there's no need to instantiate it from here, now.
# (instantiate directly in MenuHandler)
am = gui.base.AvatarManager(self.session)
handler = gui.base.MenuHandler(self.session, dialog, self.contact_list,
am, self.on_disconnect, self.on_close)
contact_handler = gui.base.ContactHandler(self.session, dialog,
self.contact_list)
group_handler = gui.base.GroupHandler(self.session, dialog,
self.contact_list)
MainMenu = extension.get_default('main menu')
ContactMenu = extension.get_default('menu contact')
GroupMenu = extension.get_default('menu group')
self.menu = MainMenu(handler, self.session.config)
self.contact_menu = ContactMenu(contact_handler)
self.group_menu = GroupMenu(group_handler)
self.contact_menu.show_all()
self.group_menu.show_all()
示例12: __init__
def __init__(self, session, on_new_conversation, on_close, on_disconnect_cb):
"""class constructor"""
gtk.VBox.__init__(self)
self.session = session
UserPanel = extension.get_default("user panel")
ContactList = extension.get_default("contact list")
self.below_menu = extension.get_and_instantiate("below menu", self)
self.below_panel = extension.get_and_instantiate("below panel", self)
self.below_userlist = extension.get_and_instantiate("below userlist", self)
self.contact_list = ContactList(session)
scroll = gtk.ScrolledWindow()
scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
scroll.set_shadow_type(gtk.SHADOW_IN)
scroll.set_border_width(1)
self.on_new_conversation = on_new_conversation
self.on_close = on_close
self.on_disconnect_cb = on_disconnect_cb
self.session.signals.contact_attr_changed.subscribe(self._on_contact_attr_changed)
self.menu = None
self.contact_menu = None
self.contact_menu = None
self.group_menu = None
self._build_menus()
self.panel = UserPanel(session)
self.panel.nick.connect("text-changed", self._on_nick_changed)
self.panel.message.connect("text-changed", self._on_message_changed)
self.panel.search.connect("toggled", self._on_search_toggled)
self.panel.enabled = False
self.entry = gtk.Entry()
self.entry.connect("changed", self._on_entry_changed)
self.entry.connect("key-press-event", self._on_entry_key_press)
self.pack_start(self.menu, False)
self.pack_start(self.below_menu, False)
self.pack_start(self.panel, False)
self.pack_start(self.below_panel, False)
self.pack_start(scroll, True, True)
self.pack_start(self.below_userlist, False)
self.pack_start(self.entry, False)
self.contact_list.contact_selected.subscribe(self._on_contact_selected)
self.contact_list.group_selected.subscribe(self._on_group_selected)
self.contact_list.contact_menu_selected.subscribe(self._on_contact_menu_selected)
self.contact_list.group_menu_selected.subscribe(self._on_group_menu_selected)
scroll.add(self.contact_list)
scroll.show_all()
if self.session.config.b_show_userpanel:
self.panel.hide()
self.session.config.subscribe(self._on_show_userpanel_changed, "b_show_userpanel")
示例13: _setup_ui
def _setup_ui(self):
'''Instantiates the widgets, and sets the layout'''
contact_list_cls = extension.get_default('contact list')
user_panel_cls = extension.get_default('user panel')
self.panel = user_panel_cls(self.session, self)
self.panel.enabled = False
self.contact_list = contact_list_cls(self.session)
self.search_entry = widgets.SearchEntry()
self.search_entry.setVisible(False)
self.search_entry.textChanged.connect(
self._on_search_changed)
self.panel.search.clicked.connect(
self._on_search_click)
self.lay = QtGui.QGridLayout()
self.lay.setContentsMargins(0, 0, 0, 0)
self.lay.addWidget(self.below_menu, 1, 0)
self.lay.addWidget(self.panel, 2, 0)
self.lay.addWidget(self.below_panel, 3, 0)
self.lay.addWidget(self.search_entry, 4, 0)
self.lay.addWidget(self.contact_list, 5, 0)
self.lay.addWidget(self.below_userlist, 6, 0)
self.setLayout(self.lay)
self.contact_list.new_conversation_requested.connect(
self.on_new_conversation_requested)
self.contact_list.contact_menu_selected.subscribe(
self._on_contact_menu_selected)
if self.session.session_has_service(e3.Session.SERVICE_GROUP_MANAGING):
self.contact_list.group_menu_selected.subscribe(
self._on_group_menu_selected)
示例14: _on_connection_preferences_clicked
def _on_connection_preferences_clicked(self):
'''Callback invoked when the user clicks the connection preferences
button'''
def new_preferences_cb(use_http, use_proxy, proxy_host, proxy_port,
use_auth, user, passwd, session_id, service,
server_host, server_port):
'''called when the user press accept on the preferences dialog'''
self._proxy = e3.Proxy(use_proxy, proxy_host,
proxy_port, use_auth, user, passwd)
self._host = server_host
self._port = server_port
account_email = str(self._widget_d['account_combo'].currentText())
if account_email != '':
self._config.d_user_service[account_email] = service
# to trigger eventual update of dp:
self._on_account_combo_text_changed(account_email)
# TODO: investigate on what does the following do:
self._on_preferences_changed(use_http, self._proxy, session_id,
service)
service = self._config.service
account = str(self._widget_d['account_combo'].currentText())
if account in self._config.d_user_service.keys():
service = self._config.d_user_service[account]
extension.get_default('dialog').login_preferences(service, self._host,
self._port, new_preferences_cb,
self._config.b_use_http, self._proxy)
示例15: __init__
def __init__(self, session):
"""
Class Constructor
"""
self.session = session
self.session.config.get_or_set('b_notify_contact_online', True)
self.session.config.get_or_set('b_notify_contact_offline', True)
self.session.config.get_or_set('b_notify_receive_message', True)
self.notifier = extension.get_default('notificationGUI')
self.sound_player = extension.get_default('sound')(session)
if self.session:
self.session.signals.conv_message.subscribe(
self._on_message)
self.session.signals.contact_attr_changed.subscribe(
self._on_contact_attr_changed)
self.session.signals.mail_received.subscribe(
self._on_mail_received)
self.session.signals.filetransfer_completed.subscribe(
self._on_filetransfer_completed)
self.session.signals.filetransfer_canceled.subscribe(
self._on_filetransfer_canceled)
self.session.signals.filetransfer_invitation.subscribe(
self._on_filetransfer_invitation)
self.notify_online = False
self.last_online = None