Example #1
0
 def clear(self, source="", target="", target_display="",
         source_img="", target_img=""):
     '''clear the content'''
     self._texts = []
     self.loaded = False
     self.view.clear(source, Renderers.msnplus_to_plain_text(target), Renderers.msnplus_to_plain_text(target_display),
         source_img, target_img)
Example #2
0
    def show_tooltip(self, view, origCoords, path_array, obj):
        ''' shows the tooltip of an e3.Contact '''
        self.tag = -1

        text = xml.sax.saxutils.escape(
            Renderers.msnplus_to_plain_text(obj.display_name))
        text += '\n<span size="small">' + xml.sax.saxutils.escape(
            Renderers.msnplus_to_plain_text(obj.message)) + '</span>'
        text += '\n' + self.data_string % (\
            obj.account, obj.status_string, self.yes_no[bool(obj.blocked)])

        self.label.set_markup(text)

        # Sets tooltip image
        if obj.picture != "":
            pixbuf = utils.gtk_pixbuf_load(obj.picture, (96, 96))
        else:
            pixbuf = utils.gtk_pixbuf_load(gui.theme.user_def_image)

        if bool(obj.blocked):
            pixbufblock = utils.gtk_pixbuf_load(gui.theme.blocked_overlay_big)
            utils.simple_images_overlap(pixbuf, pixbufblock,
                                        -pixbufblock.props.width,
                                        -pixbufblock.props.width)

        self.image.set_from_pixbuf(pixbuf)
        self.image.show()

        # set the location of the tooltip
        x, y = self.computePosition(origCoords, view.window)
        self.move(x, y)
        self.show()
        return False
Example #3
0
    def show_tooltip(self, view, origCoords, path_array, obj):
        ''' shows the tooltip of an e3.Contact '''
        self.tag = -1

        text = xml.sax.saxutils.escape(Renderers.msnplus_to_plain_text(obj.display_name)) 
        text += '\n<span size="small">' + xml.sax.saxutils.escape(Renderers.msnplus_to_plain_text(obj.message)) + '</span>'
        text += '\n' + self.data_string % (\
            obj.account, obj.status_string, self.yes_no[bool(obj.blocked)])

        self.label.set_markup(text)

        # Sets tooltip image
        if obj.picture!="":
            pixbuf = utils.gtk_pixbuf_load(obj.picture, (96,96))
        else:
            pixbuf = utils.gtk_pixbuf_load(gui.theme.image_theme.user_def_image)

        if bool(obj.blocked):
            pixbufblock=utils.gtk_pixbuf_load(gui.theme.image_theme.blocked_overlay_big)
            utils.simple_images_overlap(pixbuf,pixbufblock,-pixbufblock.props.width,-pixbufblock.props.width)

        self.image.set_from_pixbuf(pixbuf)
        self.image.show()

        # set the location of the tooltip
        x, y = self.computePosition(origCoords, view.window)
        self.move(x, y)
        self.show()
        return False
Example #4
0
    def compare_contacts(self, contact1, contact2, order1=0, order2=0):
        '''compare two contacts and return 1 if contact1 should go first, 0
        if equal and -1 if contact2 should go first, use order1 and order2 to
        override the group sorting (the user can set the values on these to
        have custom ordering)'''

        override = cmp(order2, order1)

        if override != 0:
            return override

        if self.order_by_name:
            return cmp(Renderers.msnplus_to_plain_text(contact1.display_name), \
                       Renderers.msnplus_to_plain_text(contact2.display_name))

        result = cmp(e3.status.ORDERED.index(contact1.status),
                     e3.status.ORDERED.index(contact2.status))

        if result != 0:
            return result

        if self.order_by_status:
            return cmp(contact1.display_name, contact2.display_name)

        if len(contact1.groups) == 0:
            if len(contact2.groups) == 0:
                return cmp(contact1.display_name, contact2.display_name)
            else:
                return -1
        elif len(contact2.groups) == 0:
            return 1

        return 0
Example #5
0
 def clear(self, source="", target="", target_display="",
         source_img="", target_img=""):
     '''clear the content'''
     self._texts = []
     self.loaded = False
     self.view.clear(source, Renderers.msnplus_to_plain_text(target), Renderers.msnplus_to_plain_text(target_display),
         source_img, target_img)
Example #6
0
    def compare_contacts(self, contact1, contact2, order1=0, order2=0):
        '''compare two contacts and return 1 if contact1 should go first, 0
        if equal and -1 if contact2 should go first, use order1 and order2 to
        override the group sorting (the user can set the values on these to
        have custom ordering)'''

        override = cmp(order2, order1)

        if override != 0:
            return override

        if self.order_by_name:
            return cmp(Renderers.msnplus_to_plain_text(contact1.display_name), \
                       Renderers.msnplus_to_plain_text(contact2.display_name))

        result = cmp(e3.status.ORDERED.index(contact1.status),
            e3.status.ORDERED.index(contact2.status))

        if result != 0:
            return result

        if self.order_by_status:
            return cmp(contact1.display_name, contact2.display_name)

        if len(contact1.groups) == 0:
            if len(contact2.groups) == 0:
                return cmp(contact1.display_name, contact2.display_name)
            else:
                return -1
        elif len(contact2.groups) == 0:
            return 1
Example #7
0
def ThemeNotification(title, text, picture_path=None, const=None,
                      callback=None, tooltip=None):

    def picture_factory(picture, const_value):
        ''' decides which theme picture to use '''

        if picture:
            if(picture[:7]=="file://"):
                return picture
        if const_value == 'mail-received':
            return "file://" + gui.theme.image_theme.email
        elif const_value == 'file-transf-completed':
            return "file://" + gui.theme.image_theme.transfer_success
        elif const_value == 'file-transf-canceled':
            return "file://" + gui.theme.image_theme.transfer_unsuccess
        elif const_value == 'message-im':
            return "file://" + gui.theme.image_theme.user_def_imagetool
        else:
            return "file://" + gui.theme.image_theme.user_def_imagetool

    if const == 'message-im':
        #In this case title is contact nick
        title = Renderers.msnplus_to_plain_text(title)
    notification = pynotify.Notification(title, text,
                            picture_factory(picture_path, const))
    notification.set_hint_string("append", "allowed")
    notification.show()
Example #8
0
    def _on_drag_data_get(self, widget, context, selection, target_id, etime):
        if self.is_contact_selected():
            account = self.get_contact_selected().account
            display_name = self.get_contact_selected().display_name

            if selection.target == 'text/html':
                formatter = gui.base.Plus.MsnPlusMarkupMohrtutchy()  # - colors
                formatter.isHtml = True

                display_name = formatter.replaceMarkup(display_name)
                display_name = gui.base.Plus.parse_emotes(
                    display_name)  # - emotes

                for x in range(len(display_name)):
                    if type(display_name[x]) is dict:
                        display_name[x] = '<img src="file://%s" alt="%s">' %\
                                (display_name[x]["src"], display_name[x]["alt"])

                selection.set(
                    selection.target, 8,
                    u'{0} &lt;<a href="mailto:{1}">{1}</a>&gt;'.format(
                        ''.join(display_name), account))
            elif selection.target == 'text/plain':
                selection.set(
                    selection.target, 8, u'%s <%s>' %
                    (Renderers.msnplus_to_plain_text(display_name), account))
Example #9
0
def gtkNotification(title, text, picturePath=None, const=None, callback=None):
    global actual_notification
    global queue

    # TODO: we can have an option to use a queue or show notifications
    # like the oldNotification plugin of emesene1.6 (WLM-like)

    if (const=='message-im'):
        #In this case title is contact nick
        title = Renderers.msnplus_to_plain_text(title)

    if actual_notification is None:
        actual_notification = Notification(title, text, picturePath, callback)
        actual_notification.show()
    else:
        # Append text to the actual notification
        if actual_notification._title == title:
            actual_notification.append_text(text)
        else:
            found = False
            auxqueue = list()
            for _title, _text, _picturePath, _callback in queue:
                if _title == title:
                    _text = _text + "\n" + text
                    found = True
                auxqueue.append([_title,_text,_picturePath, _callback])

            if found:
                # append text to another notification
                del queue
                queue = auxqueue
            else:
                # or queue a new notification
                queue.append([title, text, picturePath, callback])
Example #10
0
def gtkNotification(title, text, picturePath=None, const=None, callback=None):
    global actual_notification
    global queue

    # TODO: we can have an option to use a queue or show notifications
    # like the oldNotification plugin of emesene1.6 (WLM-like)

    if (const == 'message-im'):
        #In this case title is contact nick
        title = Renderers.msnplus_to_plain_text(title)

    if actual_notification is None:
        actual_notification = Notification(title, text, picturePath, callback)
        actual_notification.show()
    else:
        # Append text to the actual notification
        if actual_notification._title == title:
            actual_notification.append_text(text)
        else:
            found = False
            auxqueue = list()
            for _title, _text, _picturePath, _callback in queue:
                if _title == title:
                    _text = _text + "\n" + text
                    found = True
                auxqueue.append([_title, _text, _picturePath, _callback])

            if found:
                # append text to another notification
                del queue
                queue = auxqueue
            else:
                # or queue a new notification
                queue.append([title, text, picturePath, callback])
Example #11
0
 def update_window(self, text, icon, index):
     ''' updates the window's border and item on taskbar
         with given text and icon '''
     if self.get_current_page() == index:
         win = self.get_parent() # gtk.Window, not a nice hack.
         win.set_title(Renderers.msnplus_to_plain_text(text))
         win.set_icon(icon)
Example #12
0
def pyNotification(title, text, picturePath=None, const=None, callback=None, tootltip=None):
    if (const=='message-im'):
        #In this case title is contact nick
        title = Renderers.msnplus_to_plain_text(title)
    n = pynotify.Notification(title, text, picturePath)
    n.set_hint_string("append", "allowed")
    n.show()
Example #13
0
    def _on_drag_data_get(self, widget, context, selection, target_id, etime):
        if self.is_contact_selected():
            account = self.get_contact_selected().account
            display_name = self.get_contact_selected().display_name

            if selection.target == "text/html":
                formatter = gui.base.Plus.MsnPlusMarkupMohrtutchy()  # - colors
                formatter.isHtml = True

                display_name = formatter.replaceMarkup(display_name)
                display_name = gui.base.Plus.parse_emotes(display_name)  # - emotes

                for x in range(len(display_name)):
                    if type(display_name[x]) is dict:
                        display_name[x] = '<img src="file://%s" alt="%s">' % (
                            display_name[x]["src"],
                            display_name[x]["alt"],
                        )

                selection.set(
                    selection.target,
                    8,
                    u'{0} &lt;<a href="mailto:{1}">{1}</a>&gt;'.format("".join(display_name), account),
                )
            elif selection.target == "text/plain":
                selection.set(
                    selection.target, 8, u"%s <%s>" % (Renderers.msnplus_to_plain_text(display_name), account)
                )
Example #14
0
def pyNotification(title, text, picturePath=None,const=None):
    if (const=='message-im'):
        #In this case title is contact nick
        title = Renderers.msnplus_to_plain_text(title)
    n = pynotify.Notification(title, text, picturePath)
    n.set_hint_string("append", "allowed")
    n.show()
Example #15
0
 def _on_switch_page(self, notebook, page, page_num):
     '''called when the user changes the tab'''
     page = self.get_nth_page(page_num)
     self.session.add_event(e3.Event.EVENT_MESSAGE_READ, page_num)
     self.set_message_waiting(page, False)
     parent = self.get_parent()
     parent.set_title(Renderers.msnplus_to_plain_text(page.text))
     parent.set_icon(page.icon)
Example #16
0
 def update_window(self, text, icon, index):
     """ updates the window's border and item on taskbar
         with given text and icon """
     if self.get_current_page() == index or index == (self.get_current_page() + self.get_n_pages()):
         win = self.get_parent()  # gtk.Window, not a nice hack.
         if win is None:
             return
         win.set_title(Renderers.msnplus_to_plain_text(text))
         win.set_icon(icon)
Example #17
0
    def add_message(self, msg, style=None, cedict={}, cedir=None):
        '''add a message to the conversation'''

        msg.alias = Renderers.msnplus_to_plain_text(msg.alias)
        msg.display_name = Renderers.msnplus_to_plain_text(msg.display_name)
        b_nick_check = bool(self.last_incoming_nickname != msg.display_name)
        if b_nick_check:
            self.last_incoming_nickname = msg.display_name
        if(len(msg.alias) > DISPLAY_NAME_LIMIT):
            msg.alias = msg.alias[0:DISPLAY_NAME_LIMIT] + "..."
        if(len(msg.display_name) > DISPLAY_NAME_LIMIT):
            msg.display_name = msg.display_name[0:DISPLAY_NAME_LIMIT] + "..."

        if msg.incoming:
            if self.last_incoming is None:
                self.last_incoming = False

            msg.first = not self.last_incoming

            if self.last_incoming_account != msg.sender or b_nick_check:
                msg.first = True

            html = self.theme.format_incoming(msg, style, cedict, cedir)
            self.last_incoming = True
            self.last_incoming_account = msg.sender
        else:
            if self.last_incoming is None:
                self.last_incoming = True

            msg.first = self.last_incoming

            html = self.theme.format_outgoing(msg, style, cedict, cedir)
            self.last_incoming = False

        if msg.type == "status":
            self.last_incoming = None
            msg.first = True

        if msg.first:
            function = "appendMessage('" + html + "')"
        else:
            function = "appendNextMessage('" + html + "')"

        self.append(function)
Example #18
0
 def update_window(self, text, icon, index):
     ''' updates the window's border and item on taskbar
         with given text and icon '''
     if self.get_current_page() == index or index == (
             self.get_current_page() + self.get_n_pages()):
         win = self.get_parent()  # gtk.Window, not a nice hack.
         if win is None:
             return
         win.set_title(Renderers.msnplus_to_plain_text(text))
         win.set_icon(icon)
Example #19
0
    def show_tooltip(self, view, origCoords, path_array, obj):
        ''' shows the tooltip of an e3.Contact '''
        self.tag = -1

        text = xml.sax.saxutils.escape(Renderers.msnplus_to_plain_text(obj.nick)) 
        text += '\n' + xml.sax.saxutils.escape(Renderers.msnplus_to_plain_text(obj.message))
        text += '\n' + self.data_string % (\
            obj.account, self.yes_no[bool(obj.blocked)])

        self.label.set_markup(text)

        # Sets tooltip image
        pixbuf = utils.safe_gtk_pixbuf_load(obj.picture, (96,96))
        self.image.set_from_pixbuf(pixbuf)
        self.image.show()

        # set the location of the tooltip
        x, y = self.computePosition(origCoords, view.window)
        self.move(x, y)
        self.show()
        return False
Example #20
0
    def add_message(self, msg, style=None, cedict={}, cedir=None):
        '''add a message to the conversation'''

        msg.alias = Renderers.msnplus_to_plain_text(msg.alias)
        msg.display_name = Renderers.msnplus_to_plain_text(msg.display_name)
        if(len(msg.alias) > DISPLAY_NAME_LIMIT):
            msg.alias = msg.alias[0:DISPLAY_NAME_LIMIT] + "..."
        if(len(msg.display_name) > DISPLAY_NAME_LIMIT):
            msg.display_name = msg.display_name[0:DISPLAY_NAME_LIMIT] + "..."

        if msg.incoming:
            if self.last_incoming is None:
                self.last_incoming = False

            msg.first = not self.last_incoming

            if self.last_incoming_account != msg.sender or \
               self.last_incoming_nickname != msg.display_name: # fix for groups.im
                msg.first = True

            html = self.theme.format_incoming(msg, style, cedict, cedir)
            self.last_incoming = True
            self.last_incoming_account = msg.sender
            self.last_incoming_nickname = msg.display_name
        else:
            if self.last_incoming is None:
                self.last_incoming = True

            msg.first = self.last_incoming

            html = self.theme.format_outgoing(msg, style, cedict, cedir)
            self.last_incoming = False

        if msg.first:
            function = "appendMessage('" + html + "')"
        else:
            function = "appendNextMessage('" + html + "')"

        self.append(function)
Example #21
0
    def __append_contact(self, contact):
        """
        appends a contact to our submenu
        """
        #item = gtk.ImageMenuItem()
        item = gtk.MenuItem()
        item.set_label(Renderers.msnplus_to_plain_text(contact.nick))
        #pict = self.__get_contact_pixbuf_or_default(contact)
        #item.set_image(pict)
        item.connect('activate', self._on_contact_clicked)    
        self.item_to_contacts[item] = contact
        self.contacts_to_item[contact.account] = item

        item.show()
        self.add(item)
Example #22
0
    def __append_contact(self, contact):
        """
        appends a contact to our submenu
        """
        #item = gtk.ImageMenuItem()
        item = gtk.MenuItem()
        item.set_label(Renderers.msnplus_to_plain_text(contact.nick))
        #pict = self.__get_contact_pixbuf_or_default(contact)
        #item.set_image(pict)
        item.connect('activate', self._on_contact_clicked)    
        self.item_to_contacts[item] = contact
        self.contacts_to_item[contact.account] = item

        item.show()
        self.add(item)
Example #23
0
    def _on_message(self, cid, account, msgobj, cedict=None):
        """
        This is fired when a new message arrives to a user.
        """
        contact = self.handler.session.contacts.get(account)

        if cid not in self.indicator_dict.values():
            conv_manager = self._get_conversation_manager(cid, account)

            if conv_manager:
                conv = conv_manager.conversations[cid]

                if not (conv_manager.is_active() and conv.members == [account]):

                    self._create_indicator("im", Renderers.msnplus_to_plain_text(contact.nick), account, cid=cid)
Example #24
0
    def _on_message(self, cid, account, msgobj, cedict=None):
        """
        This is fired when a new message arrives to a user.
        """
        contact = self.handler.session.contacts.get(account)

        if cid not in self.indicator_dict.values():
            conv_manager = self._get_conversation_manager(cid, account)

            if conv_manager:
                conv = conv_manager.conversations[cid]

                if not (conv_manager.is_active() and \
                         conv.members == [account]):

                    self._create_indicator("im", Renderers.msnplus_to_plain_text(contact.nick), account, cid=cid)
Example #25
0
def themeNotification(title, text, picturePath=None,const=None):
    
    def pictureFactory(picture,constValue):

        if(picture):
            if(picture[:7]=="file://"):
                return picture
        if(constValue=='mail-received'):
            return "file://" + gui.theme.email
        elif(constValue=='file-transf-completed'):
            return "file://" + gui.theme.transfer_success
        elif(constValue=='file-transf-canceled'):
            return "file://" + gui.theme.transfer_unsuccess
        elif(constValue=='message-im'):
            return "file://" + gui.theme.user_def_imagetool
        else:
            return "file://" + gui.theme.user_def_imagetool

    if (const=='message-im'):
        #In this case title is contact nick
        title = Renderers.msnplus_to_plain_text(title)
    n = pynotify.Notification(title, text, pictureFactory(picturePath,const)) 
    n.set_hint_string("append", "allowed")
    n.show()
Example #26
0
def GrowlNotification(title, text, picture_path=None, const=None,
                   callback=None, tooltip=None):
        title = Renderers.msnplus_to_plain_text(title)
        subprocess.call(['/usr/local/bin/growlnotify', '-n', 'emesene', '-a', 'emesene', '-t', title, '-m', text])
Example #27
0
 def information(self, formatter, contact, message):
     '''add an information message to the widget'''
     msg = gui.Message.from_information(contact, message)
     msg.message = Renderers.msnplus_to_plain_text(msg.message)
     self.view.add_message(msg, None, None, None)