示例#1
0
    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)
示例#2
0
    def __init__(self, handlers, session):
        """
        constructor

        handlers is a e3common.Handler.MenuHandler
        """
        gtk.MenuBar.__init__(self)

        FileMenu = extension.get_default('menu file')
        ActionsMenu = extension.get_default('menu actions')
        OptionsMenu = extension.get_default('menu options')
        HelpMenu = extension.get_default('menu help')

        file_ = gtk.MenuItem(_('_File'))
        self.file_menu = FileMenu(handlers.file_handler, session)
        file_.set_submenu(self.file_menu)

        actions = gtk.MenuItem(_('_Actions'))
        actions_menu = ActionsMenu(handlers.actions_handler, session)
        actions.set_submenu(actions_menu)

        options = gtk.MenuItem(_('_Options'))
        options_menu = OptionsMenu(handlers.options_handler, session.config)
        options.set_submenu(options_menu)

        help = gtk.MenuItem(_('_Help'))
        help_menu = HelpMenu(handlers.help_handler)
        help.set_submenu(help_menu)

        self.append(file_)
        self.append(actions)
        self.append(options)
        self.append(help)
示例#3
0
    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)
示例#4
0
    def _setup_main_menu(self, session, contact_list):
        """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, contact_list)

        contact_hnd = gui.base.ContactHandler(session, contact_list)
        group_hnd = gui.base.GroupHandler(session, 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)
示例#5
0
    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)
示例#6
0
    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)
示例#7
0
    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)
示例#8
0
    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
示例#9
0
    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
0
    def __init__(self, handlers, config):
        """
        constructor

        handlers is a e3common.Handler.MenuHandler
        """
        gtk.MenuBar.__init__(self)

        self.handlers = handlers

        FileMenu = extension.get_default("menu file")
        ActionsMenu = extension.get_default("menu actions")
        OptionsMenu = extension.get_default("menu options")
        HelpMenu = extension.get_default("menu help")

        self.file = gtk.MenuItem(_("_File"))
        self.file_menu = FileMenu(self.handlers.file_handler)
        self.file.set_submenu(self.file_menu)

        self.actions = gtk.MenuItem(_("_Actions"))
        self.actions_menu = ActionsMenu(self.handlers.actions_handler)
        self.actions.set_submenu(self.actions_menu)

        self.options = gtk.MenuItem(_("_Options"))
        self.options_menu = OptionsMenu(self.handlers.options_handler, config)
        self.options.set_submenu(self.options_menu)

        self.help = gtk.MenuItem(_("_Help"))
        self.help_menu = HelpMenu(self.handlers.help_handler)
        self.help.set_submenu(self.help_menu)

        self.append(self.file)
        self.append(self.actions)
        self.append(self.options)
        self.append(self.help)
示例#11
0
    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)
示例#12
0
    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)
示例#13
0
    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()
示例#14
0
    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")
示例#15
0
    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.session.config.get_or_set('b_notify_typing', False)
        self.session.config.get_or_set('b_notify_when_focussed', False)
        self.session.config.get_or_set('b_notify_only_when_available', True)

        self.notifier = extension.get_default('notificationGUI')
        self.picture_factory = extension.get_default('notificationImage')
        self.sound_player = extension.get_and_instantiate('sound', session)

        if self.session:
            self.session.signals.conv_message.subscribe(
                self._on_message)
            self.session.signals.user_typing.subscribe(
                self._on_user_typing)
            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
示例#16
0
文件: emesene.py 项目: bah/emesene
    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)
示例#17
0
    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()
示例#18
0
    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)
示例#19
0
    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()
示例#20
0
文件: Handler.py 项目: JPtja/emesene
    def on_set_picture_selected(self):
        '''called when set picture is selected'''
        def set_picture_cb(response, filename):
            '''callback for the avatar chooser'''
            if response == gui.stock.ACCEPT:
                self.session.set_picture(filename)

        extension.get_default('avatar chooser')(set_picture_cb).show()
示例#21
0
        def open_file_cb(response, filepath):
            if response is not gui.stock.CANCEL and response is not gui.stock.CLOSE:

                if filepath is None:
                    extension.get_default("dialog").error(_("No file selected"))
                else:
                    filename = os.path.basename(filepath)
                    self.conversation.on_filetransfer_invite(filename, filepath)
示例#22
0
 def _on_accept(self, button):
     '''method called when the user clicks the button'''
     filename = get_filename(self)
     if os.path.isfile(filename):
         self.hide()
         self.response_cb(gui.stock.ACCEPT, filename)
     else:
         extension.get_default('dialog').error("No picture selected")
示例#23
0
    def __init__(self, session, main_window):
        QtGui.QWidget.__init__(self)
        self.session = session
        self.main_window = main_window
        self.session = session
        # a widget dic to avoid proliferation of instance variables:
        self._widget_dict = {}
        self._enabled = True

        nick_edit_cls = extension.get_default("nick edit")
        avatar_cls = extension.get_default("avatar")

        widget_dict = self._widget_dict

        nick_box = QtGui.QHBoxLayout()
        widget_dict["nick_edit"] = nick_edit_cls()
        widget_dict["mail_btn"] = QtGui.QToolButton()
        widget_dict["mail_btn"].setAutoRaise(True)
        widget_dict["mail_btn"].setIcon(QtGui.QIcon.fromTheme("mail-unread"))
        widget_dict["mail_btn"].setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        widget_dict["mail_btn"].setText("(0)")
        nick_box.addWidget(widget_dict["nick_edit"])
        nick_box.addWidget(widget_dict["mail_btn"])

        widget_dict["psm_edit"] = nick_edit_cls(
            allow_empty=True, empty_message=QtCore.QString(tr("<u>Click here to set a personal message...</u>"))
        )
        widget_dict["status_combo"] = StatusButton.StatusButton(self.session)
        psm_box = QtGui.QHBoxLayout()
        psm_box.setContentsMargins(0, 0, 0, 0)
        psm_box.addWidget(widget_dict["psm_edit"])
        psm_box.addWidget(widget_dict["status_combo"])
        widget_dict["psm_box"] = psm_box
        widget_dict["display_pic"] = avatar_cls(self.session)

        my_info_lay_left = QtGui.QVBoxLayout()
        my_info_lay_left.setContentsMargins(0, 0, 0, 0)
        my_info_lay_left.addLayout(nick_box)
        my_info_lay_left.addLayout(psm_box)

        my_info_lay = QtGui.QHBoxLayout()
        my_info_lay.addWidget(widget_dict["display_pic"])
        my_info_lay.addLayout(my_info_lay_left)
        my_info_lay.setContentsMargins(0, 0, 0, 0)
        self.setLayout(my_info_lay)
        self.session.signals.status_change_succeed.subscribe(self._widget_dict["status_combo"].set_status)
        self.session.config.subscribe(self._on_show_mail_inbox_changed, "b_show_mail_inbox")

        widget_dict["nick_edit"].nick_changed.connect(self.on_nick_changed)
        widget_dict["psm_edit"].nick_changed.connect(self.on_message_changed)
        if session.session_has_service(e3.Session.SERVICE_PROFILE_PICTURE):
            widget_dict["display_pic"].clicked.connect(self.on_avatar_click)
        widget_dict["mail_btn"].clicked.connect(self._on_mail_click)

        self.on_profile_update_succeed(self.session.contacts.me.display_name, self.session.contacts.me.message)
        self.on_picture_change_succeed(self.session.account.account, self.session.contacts.me.picture)
        self._on_show_mail_inbox_changed(self.session.config.b_show_mail_inbox)
        self._add_subscriptions()
示例#24
0
    def _on_remove_all(self, button):
        '''Removes all avatars from the cache'''
        def on_response_cb(response):
            '''response callback for the confirm dialog'''
            if response == gui.stock.YES:
                self.remove_all()

        extension.get_default('dialog').yes_no(
            "Are you sure you want to remove all items?", on_response_cb)
示例#25
0
    def _setup_ui(self):
        '''Instantiates the widgets, and sets the layout'''
        widget_dict = self._widget_dict

        nick_edit_cls = extension.get_default('nick edit')
        status_combo_cls = extension.get_default('status combo')
        avatar_cls = extension.get_default('avatar')
        contact_list_cls = extension.get_default('contact list')

        nick_box = QtGui.QHBoxLayout()
        widget_dict['nick_edit'] = nick_edit_cls()
        widget_dict['mail_btn']  = QtGui.QToolButton()
        widget_dict['mail_btn'].setAutoRaise(True)
        widget_dict['mail_btn'].setIcon(
                                    QtGui.QIcon.fromTheme('mail-unread'))
        widget_dict['mail_btn'].setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        widget_dict['mail_btn'].setText("(0)")
        nick_box.addWidget(widget_dict['nick_edit'])
        nick_box.addWidget(widget_dict['mail_btn'])

        widget_dict['psm_edit'] = nick_edit_cls(allow_empty=True,
            empty_message=QtCore.QString(
                tr('<u>Click here to set a personal message...</u>')))
        widget_dict['current_media'] = QtGui.QLabel()
        widget_dict['status_combo'] = status_combo_cls()
        widget_dict['display_pic'] = avatar_cls(self.session)
        widget_dict['contact_list'] = contact_list_cls(self.session)
        my_info_lay_left = QtGui.QVBoxLayout()
        my_info_lay_left.addLayout(nick_box)
        my_info_lay_left.addWidget(widget_dict['psm_edit'])
        my_info_lay_left.addWidget(widget_dict['current_media'])
        my_info_lay_left.addWidget(widget_dict['status_combo'])

        my_info_lay = QtGui.QHBoxLayout()
        my_info_lay.addWidget(widget_dict['display_pic'])
        my_info_lay.addLayout(my_info_lay_left)

        lay = QtGui.QVBoxLayout()
        lay.addLayout(my_info_lay)
        lay.addWidget(widget_dict['contact_list'])
        self.setLayout(lay)

        # First fill of personal Infos:
        self._on_ss_profile_get_succeed('','')

        widget_dict['nick_edit'].nick_changed.connect(
                                        self._on_set_new_nick)
        widget_dict['psm_edit'].nick_changed.connect(
                                        self._on_set_new_psm)
        widget_dict['status_combo'].status_changed.connect(
                                        self._on_set_new_status)
        widget_dict['display_pic'].clicked.connect(
                                        self._on_display_pic_clicked)
        widget_dict['contact_list'].new_conversation_requested.connect(
                                        self.on_new_conversation_requested)
        widget_dict['mail_btn'].clicked.connect(
                                    self._on_mail_click)
示例#26
0
    def _on_preferences_open(self, account, callback):
        '''called when the user clicks the preference button'''
        service = self.config.get_or_set('service', 'whatsapp')
        if account in self.accounts:
            service = self.config.d_user_service.get(account, 'whatsapp')

        ext = self.service2id[service][1]
        extension.get_default('dialog').login_preferences(service, ext,
            callback, self.use_http, self.use_ipv6, self.proxy)
示例#27
0
    def _on_remove_all(self, button):
        """Removes all avatars from the cache"""

        def on_response_cb(response):
            """response callback for the confirm dialog"""
            if response == gui.stock.YES:
                self.remove_all()

        extension.get_default("dialog").yes_no(_("Are you sure you want to remove all items?"), on_response_cb)
示例#28
0
    def _on_accept(self, button):
        """method called when the user clicks the button"""
        filename = get_filename(self)

        if filename is None or not os.path.isfile(filename):
            extension.get_default("dialog").error(_("No picture selected"))
            return

        self.hide()
        self.response_cb(gui.stock.ACCEPT, filename)
示例#29
0
文件: Handler.py 项目: tiancj/emesene
        def open_file_cb(response, filepath):
            if response is not gui.stock.CANCEL and \
                response is not gui.stock.CLOSE:

                if filepath is None:
                    extension.get_default('dialog').error(
                                                _("No file selected"))
                else:
                    filename = os.path.basename(filepath)
                    self.conversation.on_send_picture(filename, filepath)
示例#30
0
文件: emesene.py 项目: Lagg3r/emesene
    def on_contact_list_ready(self):
        '''callback called when the contact list is ready to be used'''
        self.window.content.contact_list.fill()

        self.on_pending_contacts()

        glib.timeout_add(500, self.session.logger.check)

        notificationcls = extension.get_default('notification')
        self.notification = notificationcls(self.session)
        self.soundPlayer = extension.get_default('sound')(self.session)
示例#31
0
    def _on_social_request(self, conn_url):
        def set_token_fallback(response, data, token_url):
            '''callback used as fallback when webkit isn't avariable'''
            if response == 1:
                token_url = None
            self.session.set_social_token(token_url)

        dialog = extension.get_default('dialog')

        use_fallback = (
            gui.gtkui.WEBKITERROR or sys.platform == 'darwin' or
            #FIXME: remove this check when webkit works on windows 7
            (sys.platform == 'win32' and sys.getwindowsversion()[0] > 6))

        if not use_fallback:
            dialog.web_window(_("Connect Emesene and Facebook"), conn_url,
                              self.session.set_social_token)
        else:
            #Fallback method
            #Open a browser and ask user to copy the access token
            gui.base.Desktop.open(conn_url)
            w = dialog.entry_window("Url:", "", set_token_fallback,
                                    "Facebook Integration", None)
            lbl = dialog.window_add_label_vbox(
                w,
                _("Please login into facebook and copy the url opened in your browser here"
                  ))
            lbl.set_selectable(False)
            w.vbox.reorder_child(lbl, 0)
            w.show()
示例#32
0
 def _show_dialog(self):
     '''called to show dialog'''
     if self.ENABLE == False:
         return
     dialog = extension.get_default('dialog')
     dialog.yes_no_cancel(_("Do you want to synchronize with emesene 1?"),
                          self._synch_cb)
示例#33
0
    def steal_emoticon(self, path_uri):
        '''receives the path or the uri for the emoticon to be added'''
        if path_uri.startswith("file://"):
            path_uri = path_uri[7:]
            path_uri = urllib.url2pathname(path_uri)
        directory = os.path.dirname(path_uri).lower()
        emcache = self.session.caches.get_emoticon_cache(
            self.session.account.account)
        dialog = extension.get_default('dialog')

        if directory.endswith(gui.theme.emote_theme.path.lower()):
            dialog.information(_("Can't add, default emoticon"))
        elif directory == emcache.path.lower():
            dialog.information(_("Can't add, own emoticon"))
        else:

            def on_response(response, shortcut):
                if response == stock.ACCEPT:
                    shortcut = dialog.entry.get_text()
                    if shortcut not in emcache.list():
                        self.emcache.insert((shortcut, path_uri))
                    # TODO: check if the file's hash is not already on the cache
                    else:
                        dialog.information(_("Shortcut already in use"))

            matches = re.search(r'<img src="' + path_uri + \
                '" alt="(?P<alt>\S*)" name="(?P<name>\w*)"',
                self.output.view.text)
            groupdict = {'alt': ''} if not matches else matches.groupdict()
            dialog = dialog.entry_window(
                _("Type emoticon's shortcut: "), groupdict['alt'], on_response,
                _("Choose custom emoticon's shortcut"))
            dialog.entry.set_max_length(7)
            dialog.show()
示例#34
0
    def __init__(self, handler, parent=None):
        '''Constructor'''
        QtGui.QMenu.__init__(self, 'emesene2', parent)

        self._handler = handler

        status_menu_cls = extension.get_default('menu status')

        self.hide_show_mainwindow = QtGui.QAction(tr('Hide/Show emesene'),
                                                  self)
        self.status_menu = status_menu_cls(handler.on_status_selected)
        #self.list_contacts_menu = ContactsMenu(handler, main_window)
        self.disconnect = QtGui.QAction(ICON('network-disconnect'),
                                        tr('Disconnect'), self)
        self.quit = QtGui.QAction(ICON('application-exit'), tr('Quit'), self)

        self.addAction(self.hide_show_mainwindow)
        self.addMenu(self.status_menu)
        #self.addMenu(self.list_contacts_menu)
        self.addAction(self.disconnect)
        self.addSeparator()
        self.addAction(self.quit)

        self.disconnect.triggered.connect(
            lambda *args: self._handler.on_disconnect_selected())
        self.quit.triggered.connect(
            lambda *args: self._handler.on_quit_selected())
示例#35
0
 def __init__(self, session, parent=None):
     QtGui.QTreeView.__init__(self, parent)
     dialog = extension.get_default('dialog')
     # We need a model *before* callig gui.ContactList's costructor!!
     self._model = ContactListModel.ContactListModel(session.config, self)
     self._pmodel = ContactListProxy.ContactListProxy(session.config, self)
     gui.ContactList.__init__(self, session)
     
     self._pmodel.setSourceModel(self._model)
     self.setModel(self._pmodel)
     delegate = ContactListDelegate.ContactListDelegate(session, self)
     delegate.set_nick_formatter(self.format_nick)
     self.setItemDelegate(delegate)
     self.setAnimated(True)
     self.setRootIsDecorated(False)
     self.setHeaderHidden(True)
     self.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
     self.setVerticalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel)
     self.setSortingEnabled(True)
     self.viewport().setStyleSheet( 'QWidget{                    \
         background-attachment: fixed;           \
         background-origin: content;             \
         background-position: bottom left;       \
         background-repeat: no-repeat;           \
         background-clip: content;}')
         # background-color: rgb(178, 216, 255);   \
     #self.verticalScrollBar().setStyleSheet("QScrollBar:vertical{}")
     self.setIndentation(0)
     self.doubleClicked.connect(self._on_item_double_clicked)
示例#36
0
 def go_connect(self, on_cancel_login, avatar_path, config):
     '''Adds a 'connecting' page to the top level window and shows it'''
     connecting_window_cls = extension.get_default('connecting window')
     connecting_page = connecting_window_cls(on_cancel_login, avatar_path,
                                             config)
     self.content_main = connecting_page
     self.menuBar().hide()
示例#37
0
    def _setup_ui(self):
        '''Instantiates the widgets, and sets the layout'''
        widget_d = self._widget_d
        avatar_cls = extension.get_default('avatar')

        widget_d['display_pic'] = avatar_cls(clickable=False, crossfade=False)
        widget_d['label'] = QtGui.QLabel()
        widget_d['progress_bar'] = QtGui.QProgressBar()
        widget_d['cancel_btn'] = QtGui.QPushButton(tr('Cancel'))

        lay = QtGui.QVBoxLayout()
        lay.addSpacing(40)
        lay.addWidget(widget_d['display_pic'], 0, Qt.AlignCenter)
        lay.addStretch()
        lay.addWidget(widget_d['label'], 0, Qt.AlignCenter)
        lay.addWidget(widget_d['progress_bar'], 0, Qt.AlignCenter)
        lay.addSpacing(35)
        lay.addStretch()
        lay.addWidget(widget_d['cancel_btn'], 0, Qt.AlignCenter)
        lay.addSpacing(45)

        hor_lay = QtGui.QHBoxLayout()
        hor_lay.addStretch()
        hor_lay.addSpacing(40)
        hor_lay.addLayout(lay)
        hor_lay.addSpacing(40)
        hor_lay.addStretch()
        self.setLayout(hor_lay)

        widget_d['display_pic'].set_from_file(self._avatar_path)
        widget_d['progress_bar'].setMinimum(0)
        widget_d['progress_bar'].setMaximum(0)
        widget_d['progress_bar'].setMinimumWidth(220)
示例#38
0
    def __init__(self, handler):
        """
        constructor

        handler -- a e3common.Handler.TrayIconHandler object
        """
        gtk.Menu.__init__(self)
        self.handler = handler

        StatusMenu = extension.get_default('menu status')
        self.status = gtk.ImageMenuItem('Status')
        self.status.set_image(
            gtk.image_new_from_stock(gtk.STOCK_CONVERT, gtk.ICON_SIZE_MENU))
        self.status_menu = StatusMenu(handler.on_status_selected)
        self.status.set_submenu(self.status_menu)

        self.disconnect = gtk.ImageMenuItem(gtk.STOCK_DISCONNECT)
        self.disconnect.connect(
            'activate', lambda *args: self.handler.on_disconnect_selected())
        self.quit = gtk.ImageMenuItem(gtk.STOCK_QUIT)
        self.quit.connect('activate',
                          lambda *args: self.handler.on_quit_selected())

        self.append(self.status)
        self.append(self.disconnect)
        self.append(gtk.SeparatorMenuItem())
        self.append(self.quit)
示例#39
0
    def _on_forget_me_clicked(self):
        ''''''
        def _yes_no_cb(response):
            '''callback from the confirmation dialog'''
            if (response == 36):  #Accepted
                account = str(widget_dic['account_combo'].currentText())
                service = self.config.d_user_service.get(
                    account, self.config.service)
                self.forget_user(account, service)
                #FIXME: remove fron account_list and combo
                widget_dic['account_combo'].setCurrentIndex(0)

        widget_dic = self._widget_d
        extension.get_default('dialog').yes_no(
                _('Are you sure you want to delete the account %s ?') % \
                str(widget_dic['account_combo'].currentText()), _yes_no_cb)
示例#40
0
 def _on_his_avatar_click(self, widget, data):
     '''method called when user click on the other avatar '''
     account = self.members[self.index - 1]
     contact = self.session.contacts.get(account)
     if contact:
         dialog = extension.get_default('dialog')
         dialog.contact_information_dialog(self.session, contact.account)
示例#41
0
def replace_markup(markup):
    '''replace the tags defined in gui.base.ContactList'''
    Tags = extension.get_default('toolkit tags')

    markup = markup.replace("[$nl]", Tags.NEWLINE)

    markup = markup.replace("[$small]", "<span %s>" % Tags.FONT_SIZE_SMALL)
    markup = markup.replace("[$/small]", "</span>")

    while markup.count("[$COLOR=") > 0:
        hexcolor = color = markup.split("[$COLOR=")[1].split("]")[0]
        if color.count("#") == 0:
            hexcolor = "#" + color

        markup = markup.replace("[$COLOR=%s]" % color, \
                "<span %s>" % Tags.FONT_COLOR(hexcolor))
    markup = markup.replace("[$/COLOR]", "</span>")

    markup = markup.replace("[$b]", "<span %s>" % Tags.FONT_WEIGHT_BOLD)
    markup = markup.replace("[$/b]", "</span>")

    markup = markup.replace("[$i]", "<span %s>" % Tags.FONT_STYLE_ITALIC)
    markup = markup.replace("[$/i]", "</span>")

    # Close all tags before a new line
    markup_lines = markup.split('\n')
    for i in range(len(markup_lines) - 1):
        closed_line = close_tags(markup_lines[i], markup_lines[i + 1])
        markup_lines[i] = closed_line[0]
        markup_lines[i + 1] = closed_line[1]
    markup = '\n'.join(markup_lines)

    return markup
示例#42
0
    def edit_profile(cls, handler, user_nick, user_message, last_avatar):

        dialog = OkCancelDialog(unicode(tr('Change profile')))
        dialog.setWindowTitle(tr('Change profile'))

        hbox = QtGui.QHBoxLayout()
        hbox.setContentsMargins(0, 0, 0, 0)

        Avatar = extension.get_default('avatar')
        avatar = Avatar(handler.session, size=96)
        avatar.set_from_file(last_avatar)
        if handler.session.session_has_service(
                e3.Session.SERVICE_PROFILE_PICTURE):
            avatar.clicked.connect(
                lambda *args: handler.on_set_picture_selected(handler.session))
            avatar.setToolTip(tr('Click here to set your avatar'))

            def on_picture_change_succeed(self, account, path):
                '''callback called when the picture of an account is changed'''
                # our account
                if account == handler.session.account.account:
                    avatar.set_from_file(path)

            handler.session.signals.picture_change_succeed.subscribe(
                on_picture_change_succeed)

        vbox = QtGui.QVBoxLayout()
        vbox.setContentsMargins(0, 0, 0, 0)

        hbox.addWidget(avatar)
        hbox.addLayout(vbox)
        dialog.setLayout(hbox)

        nick_label = QtGui.QLabel(unicode(tr('Nick:')))

        nick = QtGui.QLineEdit()
        nick.setText(unicode(user_nick))

        pm_label = QtGui.QLabel(unicode(tr('Message:')))

        pm = QtGui.QLineEdit()
        pm.setText(unicode(user_message))

        vbox.addWidget(nick_label)
        vbox.addWidget(nick)
        vbox.addWidget(pm_label)
        vbox.addWidget(pm)

        def save_profile():
            '''save the new profile'''
            new_nick = nick.text()
            new_pm = pm.text()
            handler.save_profile(new_nick, new_pm)

        dialog.accept_response = save_profile

        dialog.show()
        dialog.exec_()
        dialog.hide()
示例#43
0
文件: Window.py 项目: Mankeke/emesene
 def go_main(self, session, on_new_conversation, on_close, on_disconnect):
     '''change to the main window'''
     MainWindow = extension.get_default('main window')
     self.content = MainWindow(session, on_new_conversation, on_close,
                               on_disconnect)
     self.add(self.content)
     self.content.show()
     self.content_type = 'main'
示例#44
0
    def go_conversation(self, session, on_close):
        '''Adds a conversation page to the top level window and shows it'''
        conversation_window_cls = extension.get_default('conversation window')
        conversation_page = conversation_window_cls(
            session, on_last_close=self._on_last_tab_close, parent=self)

        self.content_conv = conversation_page
        self.cb_on_close_conv = on_close
示例#45
0
文件: Window.py 项目: Mankeke/emesene
    def go_connect(self, callback, avatar_path):
        '''draw the login window on the main window'''
        ConnectingWindow = extension.get_default('connecting window')

        self.content = ConnectingWindow(callback, avatar_path)
        self.add(self.content)
        self.content.show()
        self.content_type = 'connecting'
示例#46
0
        def _on_save_chats_ready(results):
            '''called when the chats requested are ready
            '''
            if not results:
                return

            exporter = extension.get_default('history exporter')
            exporter(results, open(path, "w"))
示例#47
0
    def change_profile(self):
        '''show a dialog to edit the user account information'''
        last_avatar = self.session.config.last_avatar
        nick = self.session.contacts.me.nick
        message = self.session.contacts.me.message

        dialog = extension.get_default('dialog')
        dialog.edit_profile(self, nick, message, last_avatar)
示例#48
0
    def start(self, account=None):
        '''the entry point to the class'''
        windowcls = extension.get_default('window frame')
        self.window = windowcls(self.close_session) # 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)
        self.go_login(proxy, use_http)
示例#49
0
    def _build_menus(self):
        '''buildall the menus used on the client'''

        handler = gui.base.MenuHandler(self.session, self.contact_list)

        contact_handler = gui.base.ContactHandler(self.session,
                                                  self.contact_list)

        MainMenu = extension.get_default('main menu')
        ContactMenu = extension.get_default('menu contact')

        self.menu = MainMenu(handler, self.session)
        self.contact_menu = ContactMenu(contact_handler, self.session)
        if self.session.session_has_service(e3.Session.SERVICE_GROUP_MANAGING):
            group_handler = gui.base.GroupHandler(self.session,
                                                  self.contact_list)
            GroupMenu = extension.get_default('menu group')
            self.group_menu = GroupMenu(group_handler)
示例#50
0
 def start_download(self, widget=None):
     '''start the download of an extension'''
     dialog = extension.get_default('dialog')
     self.progress = dialog.progress_window(_('Updating extensions'),
                                            self._end_progress_cb)
     self.progress.set_action(_("Updating extensions"))
     self.progress.show_all()
     gobject.timeout_add(100, self.update_download_progress)
     utils.GtkRunner(self.show_update_callback, self.download_updates)
示例#51
0
 def select_emote(cls, session, theme, callback, max_width=16):
     '''select an emoticon, receives a gui.Theme object with the theme
     settings the callback receives the response and a string representing
     the selected emoticon
     '''
     smiley_chooser_cls = extension.get_default('smiley chooser')
     smiley_chooser = smiley_chooser_cls()
     smiley_chooser.emoticon_selected.connect(callback)
     smiley_chooser.show()
示例#52
0
    def add_new_conversation(self, session, cid, members):
        """
        create and append a new conversation
        """
        Conversation = extension.get_default('conversation')
        TabWidget = extension.get_default('conversation tab')
        conversation = Conversation(self.session, cid, self.update_window,
                                    None, members)
        label = TabWidget('Connecting', self._on_tab_menu, self._on_tab_close,
                          conversation, self.mozilla_tabs)
        label.set_image(gui.theme.connect)
        conversation.tab_label = label
        conversation.tab_index = self.append_page_menu(conversation, label)
        self.set_tab_label_packing(conversation, not self.mozilla_tabs, True,
                                   gtk.PACK_START)
        self.set_tab_reorderable(conversation, True)

        return conversation
示例#53
0
文件: Window.py 项目: Mankeke/emesene
 def go_conversation(self, session):
     '''change to a conversation window'''
     ConversationManager = extension.get_default('conversation window')
     self.content = ConversationManager(session, self._on_last_tab_close)
     self.add(self.content)
     self.connect('focus-in-event', self.content._on_focus)
     self.content.show()
     self.content_type = 'conversation'
     self.content._set_accels()
示例#54
0
 def go_connect(self, on_cancel_login, avatar_path, config):
     '''Adds a 'connecting' page to the top level window and shows it'''
     log.debug('GO CONNECT! ^_^')
     connecting_window_cls = extension.get_default('connecting window')
     connecting_page = connecting_window_cls(on_cancel_login, avatar_path,
                                             config)
     self._content_type = 'connecting'
     self._switch_to_page(connecting_page)
     self.menuBar().hide()
示例#55
0
 def go_conversation(self, session):
     '''Adds a conversation page to the top level window and shows it'''
     log.debug('GO CONVERSATION! ^_^')
     conversation_window_cls = extension.get_default('conversation window')
     conversation_page = conversation_window_cls(
         session, on_last_close=self._on_last_tab_close, parent=self)
     self._content_type = 'conversation'
     self._switch_to_page(conversation_page)
     self.menuBar().hide()
示例#56
0
 def _sync_emesene1(self):
     syn = extension.get_default('synch tool')
     # Check if a synch tool is present. Synch tool is only in the gtk gui.
     # Remove the following 'if' when it will be in the qt4 gui too.
     if syn:
         user = self.session.account.account
         current_service = self.session.config.service
         syn = syn(self.session, current_service)
         syn.show()
示例#57
0
    def on_debug_selected(self):
        '''called when the preference button is selected'''
        def debug_close_cb():
            self.debug_window = None

        if not self.debug_window:
            DebugWindow = extension.get_default('debug window')
            self.debug_window = DebugWindow(debug_close_cb)
            self.debug_window.show()
示例#58
0
 def add_new_avatar_from_toolkit_pix(self, toolkit_pix):
     ''' add a new picture into the avatar cache '''
     fd, fn = tempfile.mkstemp(prefix='emsnpic')
     PictureHandler = extension.get_default('picture handler')
     pix = PictureHandler.from_toolkit(toolkit_pix)
     pix.save(fn)
     results = self.add_new_avatar(fn)
     os.remove(fn)
     return results
示例#59
0
    def close_session(self, do_exit=True, server_disconnected=False):
        '''close session'''
        # prevent preference window from staying open and breaking things
        pref = extension.get_instance('preferences')
        if pref:
            pref.hide()

        # close all dialogs that are open
        extension.get_default('dialog').close_all()

        self._remove_subscriptions()

        if server_disconnected:
            for conv_manager in self.conversations:
                conv_manager.close_session()
            self.conv_manager_available = True # update with new session
        else:
            for conv_manager in self.conversations:
                conv_manager.close_all()

        if self.session:
            self.session.stop_mail_client()
            self.session.quit()

        self.window.on_disconnect(self.close_session)

        self._save_application_language()
        if self.session is not None:
            self.session.save_extensions_config()

        self._save_login_dimensions()

        if self.session and self.logged_in:
            self.session.save_config()
            self.session = None
            self.logged_in = False

        self.config.save(self.config_path)

        if do_exit:
            if self.tray_icon is not None:
                self.tray_icon.set_visible(False)

            extension.get_and_instantiate('quit')
示例#60
0
    def _on_save_clicked(self, button):
        '''called when the save button is clicked'''
        def save_cb(response, filename=None):
            '''called when the closes the save dialog'''
            if filename is not None and response == gui.stock.SAVE:
                self.save_chats(filename)

        home = os.path.expanduser('~')
        dialog = extension.get_default('dialog')
        dialog.save_as(home, save_cb)