Example #1
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(Plus.msnplus_strip(obj.display_name))
        message = Plus.msnplus_strip(obj.message) \
                    if obj.media == '' else obj.media
        text += '\n<span size="small">' \
                + xml.sax.saxutils.escape(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 and 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 #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(Plus.msnplus_strip(obj.display_name))
        message = Plus.msnplus_strip(obj.message) \
                    if obj.media == '' else obj.media
        text += '\n<span size="small">' \
                + xml.sax.saxutils.escape(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
        self.image.stop()
        self.image.set_from_file(obj.picture, bool(obj.blocked))
        self.image.show()

        # set the location of the tooltip
        if view.window is None:
            return False
        x, y = self.computePosition(origCoords, view.window)
        self.move(x, y)
        self.show()
        return False
Example #3
0
    def receive_message(self, formatter, msg):
        '''add a message to the widget'''
        msg.alias = Plus.msnplus_strip(msg.alias)
        msg.display_name = Plus.msnplus_strip(msg.display_name)

        text = formatter.format(msg)
        self.append(text, msg, self.config.b_allow_auto_scroll)
Example #4
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(Plus.msnplus_strip(obj.display_name))
        message = Plus.msnplus_strip(obj.message) \
                    if obj.media == '' else obj.media
        text += '\n<span size="small">' \
                + xml.sax.saxutils.escape(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 and 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 #5
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(Plus.msnplus_strip(obj.display_name))
        message = Plus.msnplus_strip(obj.message) \
                    if obj.media == '' else obj.media
        text += '\n<span size="small">' \
                + xml.sax.saxutils.escape(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
        self.image.set_from_file(obj.picture, bool(obj.blocked))
        self.image.show()

        # set the location of the tooltip
        if view.window is None:
            return False
        x, y = self.computePosition(origCoords, view.window)
        self.move(x, y)
        self.show()
        return False
Example #6
0
    def get_layout(self, widget):
        '''Gets the Pango layout used in the cell in a TreeView widget.'''
        layout = SmileyLayout(widget.create_pango_context(),
                self.function(unicode(self.markup,
                    'utf-8')))

        if self.markup:
            try:
                decorated_markup = self.function(unicode(self.markup,
                    'utf-8'))
            except Exception, error:
                print "this nick: '%s' made the parser go crazy, striping" % \
                        (self.markup,)
                print error

                decorated_markup = Plus.msnplus_strip(self.markup)

            try:
                pango.parse_markup(self.function(unicode(self.markup,
                    'utf-8'), False))
            except gobject.GError:
                print "invalid pango markup:", decorated_markup
                decorated_markup = Plus.msnplus_strip(self.markup)

            layout.set_text(decorated_markup)
Example #7
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(Plus.msnplus_strip(contact1.display_name),
                       Plus.msnplus_strip(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 #8
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(Plus.msnplus_strip(contact1.display_name),
                       Plus.msnplus_strip(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 #9
0
    def get_layout(self, widget):
        '''Gets the Pango layout used in the cell in a TreeView widget.'''
        '''buf = RichBuffer.RichBuffer()
        plused_markup = Plus.msnplus(self.markup)
        view = gtk.TextView()
        view.set_buffer(buf)
        buf._put_formatted(plused_markup)
        return view'''
        layout = pango.Layout(widget.get_pango_context())
        layout.set_width(-1)    # Do not wrap text.
        if self.markup:
            try:
                decorated_markup = self.function(unicode(self.markup, 'utf-8')).encode('utf-8')
            except Exception, error:
                print "this nick: '%s' made the parser go crazy, striping" % (self.markup,)
                print error

                decorated_markup = Plus.msnplus_strip(self.markup)

            try:
                pango.parse_markup(decorated_markup)
            except gobject.GError:
                print "invalid pango markup:", decorated_markup
                log_strange_nick(decorated_markup, 'pango parser')
                decorated_markup = Plus.msnplus_strip(self.markup)

            layout.set_markup(decorated_markup)
Example #10
0
    def receive_message(self, formatter, msg):
        '''add a message to the widget'''
        msg.alias = Plus.msnplus_strip(msg.alias)
        msg.display_name = Plus.msnplus_strip(msg.display_name)

        text = formatter.format(msg)
        self.append(text, msg, self.config.b_allow_auto_scroll)
Example #11
0
    def _prepare_markup(self, markup, is_plus=True):
        if is_plus:
            text = Plus.msnplus_parse(markup)
        else:
            text = Plus.msnplus_strip(markup)

        text = MarkupParser.replace_markup(text)
        text_list = MarkupParser.replace_emoticons(text)
        return text_list
Example #12
0
    def _prepare_markup(self, markup, is_plus=True):
        if is_plus:
            text = Plus.msnplus_parse(markup)
        else:
            text = Plus.msnplus_strip(markup)

        text = MarkupParser.replace_markup(text)
        text_list = MarkupParser.replace_emoticons(text)
        return text_list
Example #13
0
 def add_message(self, msg, scroll):
     if msg.type == "status":
         msg.message = Plus.msnplus_strip(msg.message)
         text = self.formatter.format_information(msg.message)
     else:
         msg.alias = Plus.msnplus_strip(msg.alias)
         msg.display_name = Plus.msnplus_strip(msg.display_name)
         text = self.formatter.format(msg)
     TextBox.append(self, text, scroll)
Example #14
0
def plus_text_parse(item, plus):
    '''parse plus in the contact list'''
    global plus_or_noplus
    # get a plain string with objects
    if plus_or_noplus and plus:
        item = Plus.msnplus_parse(item)
    else:
        item = Plus.msnplus_strip(item)
    return item
Example #15
0
 def add_message(self, msg, scroll):
     if msg.type == "status":
         msg.message = Plus.msnplus_strip(msg.message)
         text = self.formatter.format_information(msg.message)
     else:
         msg.alias = Plus.msnplus_strip(msg.alias)
         msg.display_name = Plus.msnplus_strip(msg.display_name)
         text = self.formatter.format(msg)
     self._append_to_chat(text, scroll)
Example #16
0
def plus_text_parse(item, plus):
    '''parse plus in the contact list'''
    global plus_or_noplus
    # get a plain string with objects
    if plus_or_noplus and plus:
        item = Plus.msnplus_parse(item)
    else:
        item = Plus.msnplus_strip(item)
    return item
Example #17
0
 def plus_text_parse(self, item):
     '''parse plus in the contact list'''
     try:
         item = Plus.msnplus_parse(item)
     except Exception, error: # We really want to catch all exceptions
         log.exception("Text: '%s' made the parser go crazy, stripping. Error: %s" % (
                       item, error))
         try:
             item = Plus.msnplus_strip(item)
         except Exception, error: # We really want to catch all exceptions
             log.exception("Even stripping plus markup doesn't help. Error: %s" % error)
Example #18
0
def plus_text_parse(item):
    '''parse plus in the contact list'''
    global plus_or_noplus
    # get a plain string with objects
    if plus_or_noplus:
        try:
            item = Plus.msnplus_parse(item)
        except Exception, error: # We really want to catch all exceptions
            log.exception("Text: '%s' made the parser go crazy, stripping. Error: %s" % (
                      item, error))
            try:
                item = Plus.msnplus_strip(item)
            except Exception, error: # We really want to catch all exceptions
                log.exception("Even stripping plus markup doesn't help. Error: %s" % error)
Example #19
0
def plus_text_parse(item):
    '''parse plus in the contact list'''
    global plus_or_noplus
    # get a plain string with objects
    if plus_or_noplus:
        try:
            item = Plus.msnplus_parse(item)
        except Exception, error: # We really want to catch all exceptions
            log.info("Text: '%s' made the parser go crazy, stripping. Error: %s" % (
                      item, error))
            try:
                item = Plus.msnplus_strip(item)
            except Exception, error: # We really want to catch all exceptions
                log.info("Even stripping plus markup doesn't help. Error: %s" % error)
Example #20
0
 def plus_text_parse(self, item):
     '''parse plus in the contact list'''
     try:
         item = Plus.msnplus_parse(item)
     except Exception, error:  # We really want to catch all exceptions
         log.exception(
             "Text: '%s' made the parser go crazy, stripping. Error: %s" %
             (item, error))
         try:
             item = Plus.msnplus_strip(item)
         except Exception, error:  # We really want to catch all exceptions
             log.exception(
                 "Even stripping plus markup doesn't help. Error: %s" %
                 error)
Example #21
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 = Plus.msnplus_strip(title)
    notification = pynotify.Notification(title, text,
                            picture_factory(picture_path, const))
    notification.set_hint_string("append", "allowed")
    notification.show()
Example #22
0
def gtkNotification(title, text, picturePath=None, const=None, callback=None, tooltip=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 = Plus.msnplus_strip(title)

    if actual_notification is None:
        actual_notification = Notification(title, text, picturePath, callback, tooltip)
        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, _tooltip in queue:
                if _title == title:
                    _text = _text + "\n" + text
                    found = True
                auxqueue.append([_title,_text,_picturePath, _callback, _tooltip])

            if found:
                # append text to another notification
                del queue
                queue = auxqueue
            else:
                # or queue a new notification
                queue.append([title, text, picturePath, callback, tooltip])
Example #23
0
def SnarlNotification(title,
                      text,
                      picture_path=None,
                      const=None,
                      callback=None,
                      tooltip=None):
    """emesene plugins - SnarlNotification"""
    title = Plus.msnplus_strip(title)
    if const == 'mail-received':
        app_uid = 'mail'
    elif const == 'file-transf-completed':
        app_uid = 'file'
    elif const == 'file-transf-canceled':
        app_uid = 'file'
    elif const == 'message-im':
        app_uid = title + '-message'

    if picture_path == 'notification-message-im':
        sn.notify('application/x-emesene2', title, text, uid=app_uid)
    else:
        picture_path = picture_path.replace("file://", "").replace('\\', '/')
        sn.notify('application/x-emesene2',
                  title,
                  text,
                  uid=app_uid,
                  icon=picture_path)
Example #24
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 isinstance(display_name[x], 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>" % (Plus.msnplus_strip(display_name), account))
Example #25
0
def QtNotification(title, text, picture_path=None, const=None,
                    callback=None, tooltip=None):
    global actual_notification
    global queue

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

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

            if found:
                # append text to another notification
                del queue
                queue = auxqueue
            else:
                # or queue a new notification
                queue.append([title, text, picture_path, callback, tooltip])
Example #26
0
def GNTPNotification(title,
                     text,
                     picture_path=None,
                     const=None,
                     callback=None,
                     tooltip=None):

    title = Plus.msnplus_strip(title)

    appicon = open(gui.theme.image_theme.logo).read()
    imagepath = picture_path.replace("file:///", "/")
    icon = open(imagepath).read()

    growl = gntp.notifier.GrowlNotifier(
        applicationName="emesene",
        applicationIcon=appicon,
        notifications=["Generic Notification"],
        defaultNotifications=["Generic Notification"],
        # hostname = "computer.example.com", # Defaults to localhost
        # password = "******" # Defaults to a blank password
    )

    growl.register()

    growl.notify(
        noteType="Generic Notification",
        title=title,
        description=text,
        icon=icon,
        sticky=False,
        priority=1,
    )
    def _on_contact_change_something(self, *args):
        """
        update the menu when contacts change something
        """
        if len(args) == 3:
            account, type_change, value_change = args
        elif len(args) == 4:
            account, type_change, value_change, do_notify = args

        if type_change == 'status':
            contact = self.main_window.session.contacts.get(account)
            if not contact:
                return
            time = strftime('[%H:%M:%S]', localtime())
            stat = e3.status.STATUS[contact.status]

            if hasattr(gui.theme, "image_theme"):
                status = gui.theme.image_theme.status_icons[contact.status]
            else:
                status = gui.theme.status_icons[contact.status]

            pixbuf = utils.safe_gtk_pixbuf_load(status)

            pixbuf.scale_simple(20, 20, gtk.gdk.INTERP_BILINEAR)
            display_name = Plus.msnplus_strip(contact.display_name)
            self.model.prepend([time, pixbuf, contact.status, display_name])
            self.set_active(0)
Example #28
0
def GNTPNotification(title, text, picture_path=None, const=None, 
                      callback=None, tooltip=None):

    title = Plus.msnplus_strip(title)

    appicon = open(gui.theme.image_theme.logo).read()
    imagepath = picture_path.replace( "file:///", "/" )
    icon = open(imagepath).read()

    growl = gntp.notifier.GrowlNotifier(
        applicationName = "emesene",
        applicationIcon = appicon,
        notifications = ["Generic Notification"],
        defaultNotifications = ["Generic Notification"],
        # hostname = "computer.example.com", # Defaults to localhost
        # password = "******" # Defaults to a blank password
    )

    growl.register()

    growl.notify(
        noteType = "Generic Notification",
        title = title,
        description = text,
        icon = icon,
        sticky = False,
        priority = 1,
    )
    def _on_contact_change_something(self, *args):
        """
        update the menu when contacts change something
        """
        if len(args) == 3:
            account, type_change, value_change = args
        elif len(args) == 4:
            account, type_change, value_change, do_notify = args

        if type_change == 'status':
            contact =  self.main_window.session.contacts.get(account)
            if not contact:
                return
            time = strftime('[%H:%M:%S]', localtime())
            stat = e3.status.STATUS[contact.status]

            if hasattr(gui.theme, "image_theme"):
                status = gui.theme.image_theme.status_icons[contact.status]
            else:
                status = gui.theme.status_icons[contact.status]

            pixbuf = utils.safe_gtk_pixbuf_load(status)

            pixbuf.scale_simple(20, 20, gtk.gdk.INTERP_BILINEAR)
            display_name = Plus.msnplus_strip(contact.display_name)
            self.model.prepend([time, pixbuf, contact.status, display_name])
            self.set_active(0)
Example #30
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 isinstance(display_name[x], 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>' % (Plus.msnplus_strip(display_name), account))
Example #31
0
    def __init__(self,
                 title,
                 text,
                 picture_path=None,
                 const=None,
                 callback=None,
                 tooltip=None):
        parent = QApplication.desktop()
        super(Notification, self).__init__(parent)

        self.parent = parent
        self.setWindowFlags(Qt.Tool | Qt.X11BypassWindowManagerHint
                            | Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
        self.setWindowOpacity(0.7)
        self.setStyleSheet(
            "QDialog { background-color: black;} QLabel{color: white;}")
        #self.setToolTip(tooltip)
        self.__parent = parent

        if const == 'message-im':
            #In this case title is contact nick
            if title is None:
                title = ""
            title = Plus.msnplus_strip(title)

        self._caption = unicode(title)
        self.__text = unicode(text, "utf8")
        self.__icon = QPixmap(picture_path[7:])
        self.__pos = QPoint(0, 0)
        self.connect(self, SIGNAL("clicked()"), SLOT("close()"))
        self.showPopup()
Example #32
0
def PyNotification(title, text, picture_path=None, const=None,
                   callback=None, tooltip=None):
    if const == 'message-im':
        #In this case title is contact nick
        title = Plus.msnplus_strip(title)
    notification = pynotify.Notification(title, text, picture_path)
    notification.set_hint_string("append", "allowed")
    notification.show()
Example #33
0
def GrowlNotification(title, text, picture_path=None, const=None, 
                      callback=None, tooltip=None):
    title = Plus.msnplus_strip(title)
    imagepath = picture_path.replace( "file:///", "/" )
    #BUG: In growl prefs, the emesene ticket will take on the last shown
    #contact's picture
    subprocess.call(['/usr/local/bin/growlnotify', '-n', 'emesene', '--image',
                     imagepath, '-t', title, '-m', text])
Example #34
0
    def copy_nick(self, data, widget=None):
        nick_list = []
        for member in self.members:
            contact = self.session.contacts.safe_get(member)
            nick_list.append(Plus.msnplus_strip(contact.nick))

        clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
        clipboard.set_text(', '.join(nick_list))
Example #35
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':
                display_name = Plus.msnplus_parse(display_name)

                for x in range(len(display_name)):
                    if isinstance(display_name[x], 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>' % (Plus.msnplus_strip(display_name), account))
Example #36
0
    def copy_pm(self, data, widget=None):
        pm_list = []
        for member in self.members:
            contact = self.session.contacts.safe_get(member)
            pm_list.append(Plus.msnplus_strip(contact.message))

        clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
        clipboard.set_text(", ".join(pm_list))
Example #37
0
def GrowlNotification(title, text, picture_path=None, const=None, 
                      callback=None, tooltip=None):
    title = Plus.msnplus_strip(title)
    imagepath = picture_path.replace( "file:///", "/" )
    #BUG: In growl prefs, the emesene ticket will take on the last shown
    #contact's picture
    subprocess.call(['/usr/local/bin/growlnotify', '-n', 'emesene', '--image',
                     imagepath, '-t', title, '-m', text])
Example #38
0
    def copy_pm(self, data, widget=None):
        pm_list = []
        for member in self.members:
            contact = self.session.contacts.safe_get(member)
            pm_list.append(Plus.msnplus_strip(contact.message))

        clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
        clipboard.set_text(', '.join(pm_list))
Example #39
0
def plus_text_parse(item):
    """parse plus in the contact list"""
    global plus_or_noplus
    # get a plain string with objects
    if plus_or_noplus:
        item = plus_parser.replaceMarkup(item)
    else:
        item = Plus.msnplus_strip(item)
    return item
Example #40
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 or self.session.config.b_single_window:
             return
         win.set_title(Plus.msnplus_strip(text))
         win.set_icon(icon)
 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(Plus.msnplus_strip(text))
         win.set_icon(icon)
Example #42
0
 def add_new_conversation(self, session, conv_id, members):
     '''Creates a new chat tab and returns it. This implements base's
     class abstract method.'''
     conversation_cls = extension.get_default('conversation')
     conversation = conversation_cls(session, conv_id, members)
     account = session.contacts.get(members[0])
     conversation.tab_index = self.addTab(
         conversation, Plus.msnplus_strip(account.display_name))
     conversation.conv_manager = self
     return conversation
Example #43
0
 def add_new_conversation(self, session, conv_id, members):
     '''Creates a new chat tab and returns it. This implements base's
     class abstract method.'''
     conversation_cls = extension.get_default('conversation')
     conversation = conversation_cls(session, conv_id, members)
     account = session.contacts.get(members[0])
     conversation.tab_index = self.addTab(conversation,
                 Plus.msnplus_strip(account.display_name))
     conversation.conv_manager = self
     return conversation
 def on_user_typing(self, cid, account, *args):
     """
     inform that the other user has started typing
     """
     if account in self.conversation.members:
         contact = self.session.contacts.get(account)
         if contact and not self.active:
             self.active = True #avoid many timeout
             display_name = Plus.msnplus_strip(contact.display_name)
             self.set_markup(_("%s is typing") % display_name)
             self.timeout_id = glib.timeout_add_seconds(3, self.update_label)
 def on_user_typing(self, cid, account, *args):
     """
     inform that the other user has started typing
     """
     if account in self.conversation.members:
         contact = self.session.contacts.get(account)
         if contact and not self.active:
             self.active = True  #avoid many timeout
             display_name = Plus.msnplus_strip(contact.display_name)
             self.set_markup(_("%s is typing") % display_name)
             glib.timeout_add_seconds(3, self.update_label)
Example #46
0
def PyNotification(title, text, picture_path=None, const=None,
                   callback=None, tooltip=None):
    if const == 'message-im':
        #In this case title is contact nick
        title = Plus.msnplus_strip(title)
    notification = pynotify.Notification(title, text, picture_path)
    notification.set_hint_string("append", "allowed")
    notification.set_category("presence.online")
    notification.add_action("default", "Start Conversation", notifclick)

    if not notification.show():
        print "Failed to send notification"
Example #47
0
def PyNotification(title, text, picture_path=None, const=None,
                   callback=None, tooltip=None):
    if const == 'message-im':
        #In this case title is contact nick
        if title is None:
            title = ""

        title = Plus.msnplus_strip(title)
    notification = pynotify.Notification(title, text, picture_path)
    notification.set_icon_from_pixbuf(utils.safe_gtk_pixbuf_load(picture_path, (96, 96)))
    notification.set_hint_string("append", "allowed")
    notification.show()
Example #48
0
def PyNotification(title, text, picture_path=None, const=None,
                   callback=None, tooltip=None):
    if const == 'message-im':
        #In this case title is contact nick
        if title is None:
            title = ""

        title = Plus.msnplus_strip(title)
    notification = pynotify.Notification(title, text, picture_path)
    notification.set_icon_from_pixbuf(
                utils.safe_gtk_pixbuf_load(picture_path[7:], (96, 96)))
    notification.set_hint_string("append", "allowed")
    notification.show()
Example #49
0
    def get_layout(self, widget):
        """Gets the Pango layout used in the cell in a TreeView widget."""
        layout = SmileyLayout(widget.create_pango_context())

        if self.markup:
            try:
                decorated_markup = self.function(self.markup)
            except Exception, error:
                log.error("this nick: '%s' made the parser go crazy, striping. Error: %s" % (self.markup, error))

                decorated_markup = Plus.msnplus_strip(self.markup)

            layout.set_text(decorated_markup)
            return layout
Example #50
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.get_target() == 'text/html':
                display_name = Plus.msnplus_parse(display_name)

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

                selection.set(
                    selection.get_target(), 8,
                    u'{0} &lt;<a href="mailto:{1}">{1}</a>&gt;'.format(
                        ''.join(display_name), account))
            elif selection.get_target() == 'text/plain':
                selection.set(
                    selection.get_target(), 8,
                    u'%s <%s>' % (Plus.msnplus_strip(display_name), account))
            elif selection.get_target() == 'emesene-invite':
                selection.set(selection.get_target(), 8, u'%s' % (account))
Example #51
0
    def get_layout(self, widget):
        '''Gets the Pango layout used in the cell in a TreeView widget.'''
        layout = SmileyLayout(widget.create_pango_context(),
                              self.function(unicode(self.markup, 'utf-8')))

        if self.markup:
            try:
                decorated_markup = self.function(unicode(self.markup, 'utf-8'))
            except Exception, error:
                print "this nick: '%s' made the parser go crazy, striping" % \
                        (self.markup,)
                print error

                decorated_markup = Plus.msnplus_strip(self.markup)

            try:
                pango.parse_markup(
                    self.function(unicode(self.markup, 'utf-8'), False))
            except gobject.GError:
                print "invalid pango markup:", decorated_markup
                decorated_markup = Plus.msnplus_strip(self.markup)

            layout.set_text(decorated_markup)
Example #52
0
    def get_layout(self, widget):
        '''Gets the Pango layout used in the cell in a TreeView widget.'''
        layout = SmileyLayout(widget.create_pango_context())

        if self.markup:
            try:
                decorated_markup = self.function(self.markup)
            except Exception, error:
                log.error(
                    "this nick: '%s' made the parser go crazy, striping. Error: %s"
                    % (self.markup, error))

                decorated_markup = Plus.msnplus_strip(self.markup)

            layout.set_text(decorated_markup)
            return layout
Example #53
0
def _format_contact_display_role(text):
    '''Formats correctly a string part of a display role. Parses emotes, and
    scales them.'''
    # TODO: calculate smiley size from text's size.
    smiley_size = 16
    #text = Utils.escape(text)
    #log.debug(text)
    text = replace_markup(text)
    # temporary stuff:
    text = Plus.msnplus_strip(text)
    text = text.replace('[C=c10ud]', '')
    text = Utils.parse_emotes(unicode(text))
    text = text.replace('<img src', '<img width="%d" height="%d" src' % 
                 (smiley_size, smiley_size))
    #log.debug(text)
    return text
Example #54
0
def _format_contact_display_role(text):
    '''Formats correctly a string part of a display role. Parses emotes, and
    scales them.'''
    # TODO: calculate smiley size from text's size.
    smiley_size = 16
    #text = Utils.escape(text)
    #log.debug(text)
    text = replace_markup(text)
    # temporary stuff:
    text = Plus.msnplus_strip(text)
    text = text.replace('[C=c10ud]', '')
    text = Utils.parse_emotes(unicode(text))
    text = text.replace(
        '<img src',
        '<img width="%d" height="%d" src' % (smiley_size, smiley_size))
    #log.debug(text)
    return text
Example #55
0
def GtkNotification(title,
                    text,
                    picture_path=None,
                    const=None,
                    callback=None,
                    tooltip=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 = Plus.msnplus_strip(title)

    if actual_notification is None:
        actual_notification = Notification(title, text, picture_path, callback,
                                           tooltip)
        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, _picture_path, _callback, _tooltip in queue:
                if _title == title:
                    _text = _text + "\n" + text
                    found = True
                auxqueue.append(
                    [_title, _text, _picture_path, _callback, _tooltip])

            if found:
                # append text to another notification
                del queue
                queue = auxqueue
            else:
                # or queue a new notification
                queue.append([title, text, picture_path, callback, tooltip])
Example #56
0
    def update_submenus(self):
        for i in self.move_groups_submenu.get_children():
            self.move_groups_submenu.remove(i)
        for i in self.copy_groups_submenu.get_children():
            self.copy_groups_submenu.remove(i)
        for i in self.remove_group_submenu.get_children():
            self.remove_group_submenu.remove(i)
        self.groups_to_remove = 0

        if not self.handler.is_by_group_view(): return

        all_groups = self.handler.get_all_groups()
        contact_groups = self.handler.get_contact_groups()

        if all_groups:
            all_groups = sorted(
                all_groups.items(),
                key=lambda x: Plus.msnplus_strip(x[1].name).lower())

        for key, group in all_groups:
            if key not in contact_groups:
                item = gtk.MenuItem(group.name)
                item.connect('activate', self.on_move_to_group_selected, group)
                self.move_groups_submenu.append(item)
                item_2 = gtk.MenuItem(group.name)
                item_2.connect('activate', self.on_copy_to_group_selected,
                               group)
                self.copy_groups_submenu.append(item_2)
            else:
                self.groups_to_remove = 1
                item = gtk.MenuItem(group.name)
                item.connect('activate', self.on_remove_from_group_selected,
                             group)
                self.remove_group_submenu.append(item)

        self.move_groups_submenu.show_all()
        self.copy_groups_submenu.show_all()
        self.remove_group_submenu.show_all()

        self.copy_to_group.set_sensitive(self.groups_to_remove)
        self.remove_from_group.set_sensitive(self.groups_to_remove)
Example #57
0
def PyNotification(title,
                   text,
                   picture_path=None,
                   const=None,
                   callback=None,
                   tooltip=None):
    if const == 'message-im':
        #In this case title is contact nick
        if title is None:
            title = ""

        title = Plus.msnplus_strip(title)
    notification = pynotify.Notification(title, text, picture_path)
    pix = utils.safe_gtk_pixbuf_load(picture_path[7:], (96, 96))
    if pix is not None:
        notification.set_icon_from_pixbuf(pix)
    notification.set_hint_string("append", "allowed")

    try:
        notification.show()
    except Exception, err:
        log.warning('An error occurred while showing a notification: %s' %
                    str(err))
Example #58
0
def msnplus_to_list(txt, do_parse_emotes=True):
    '''parte text to a DictObj and return a list of strings and
    gtk.gdk.Pixbufs'''
    dct = Plus.msnplus(txt, do_parse_emotes)

    if not do_parse_emotes:
        return dct.to_xml()

    items = flatten_tree(dct, [], [])

    temp = []
    accum = []
    for item in items:
        if type(item) in (str, unicode):
            temp.append(item)
        else:
            text = replace_markup("".join(temp))
            accum.append(text)
            accum.append(item)
            temp = []

    accum.append(replace_markup("".join(temp)))

    return accum
Example #59
0
 def add_message(self, msg, scroll):
     if msg.type == "status":
         msg.message = Plus.msnplus_strip(msg.message)
     self.view.add_message(msg, self.config.b_allow_auto_scroll)
Example #60
0
 def information(self, formatter, msg):
     '''add an information message to the widget'''
     msg.message = Plus.msnplus_strip(msg.message)
     self.append(msg)