Пример #1
0
 def update_indicators(self, counts):
     if indicate:
         if counts.has_key("private"):
             if not self.private_indicator:
                 self.private_indicator = indicate.Indicator() if hasattr(
                     indicate,
                     "Indicator") else indicate.IndicatorMessage()
                 self.private_indicator.connect("user-display",
                                                self.on_indicator_activate)
                 self.private_indicator.set_property("name", _("Private"))
                 self.private_indicator.set_property("stream", "private")
                 self.private_indicator.show()
             self.private_indicator.set_property("count",
                                                 str(counts["private"]))
             if counts["private"] > 0:
                 self.private_indicator.set_property_bool(
                     "draw-attention", True)
             if self.private_indicator not in self.indicator_items:
                 self.indicator_items["private"] = self.private_indicator
             log.logger.debug(
                 "Private Messages Indicator count updated to %s",
                 counts["private"])
         if counts.has_key("replies"):
             if not self.replies_indicator:
                 self.replies_indicator = indicate.Indicator() if hasattr(
                     indicate,
                     "Indicator") else indicate.IndicatorMessage()
                 self.replies_indicator.connect("user-display",
                                                self.on_indicator_activate)
                 self.replies_indicator.set_property("name", _("Replies"))
                 self.replies_indicator.set_property("stream", "replies")
                 self.replies_indicator.show()
             self.replies_indicator.set_property("count",
                                                 str(counts["replies"]))
             if self.replies_indicator not in self.indicator_items:
                 self.indicator_items["replies"] = self.replies_indicator
             log.logger.debug("Replies Indicator count updated to %s",
                              counts["replies"])
         if counts.has_key("messages"):
             if not self.messages_indicator:
                 self.messages_indicator = indicate.Indicator() if hasattr(
                     indicate,
                     "Indicator") else indicate.IndicatorMessage()
                 self.messages_indicator.connect("user-display",
                                                 self.on_indicator_activate)
                 self.messages_indicator.set_property("name", _("Messages"))
                 self.messages_indicator.set_property("stream", "messages")
                 self.messages_indicator.show()
             self.messages_indicator.set_property("count",
                                                  str(counts["messages"]))
             if self.messages_indicator not in self.indicator_items:
                 self.indicator_items["messages"] = self.messages_indicator
             log.logger.debug("Messages Indicator count updated to %s",
                              counts["messages"])
Пример #2
0
    def _create_indicator(self,
                          subtype,
                          sender,
                          body,
                          extra_text='',
                          icid=None):
        """
        This creates a new indicator item, called by on_message, online & offline.
        """
        if indicate:
            try:
                # Ubuntu 9.10+
                ind = indicate.Indicator()
            except Exception:
                # Ubuntu 9.04
                ind = indicate.IndicatorMessage()

            #Get user icon.
            contact = self.handler.session.contacts.safe_get(body)
            pixbuf = utils.safe_gtk_pixbuf_load(contact.picture or '',
                                                (48, 48))
            if pixbuf is not None:
                ind.set_property_icon("icon", pixbuf)

            ind.set_property("subtype", subtype)
            ind.set_property("sender", sender + extra_text)
            if icid is not None:
                ind.set_property("body", str(icid))
            else:
                ind.set_property("body", body)
            ind.set_property_time("time", time.time())
            ind.set_property("draw-attention", "true")
            ind.connect("user-display", self._display)
            ind.show()

            # Add indicator to the dictionary
            if subtype == "im":
                self.indicator_dict[ind] = icid
                self.r_indicator_dict[icid] = ind

            for old_icid in self.indicator_dict.values():
                if old_icid not in self.handler.session.conversations.keys():
                    # workaround: kill the orphan indicator
                    ind = self.r_indicator_dict[old_icid]
                    del self.indicator_dict[ind]
                    del self.r_indicator_dict[old_icid]
        else:
            return
Пример #3
0
 def handle_indicator_item(self, message):
     if not self.indicator_items.has_key(str(message["mid"])):
         indicator = indicate.Indicator() if hasattr(
             indicate, "Indicator") else indicate.IndicatorMessage()
         indicator.connect("user-display", self.on_indicator_reply_activate)
         indicator.set_property("subtype", "im.gwibber")
         indicator.set_property("sender", message["sender"].get("name", ""))
         indicator.set_property("body", message["text"])
         indicator.set_property_time(
             "time",
             mx.DateTime.DateTimeFromTicks(
                 message["time"]).localtime().ticks())
         indicator.show()
         self.indicator_items[message["mid"]] = indicator
         log.logger.debug("Message from %s added to indicator",
                          message["sender"].get("name", ""))
     return False
Пример #4
0
    def add_indicator(self, watch):
        icon = self.specto.notifier.get_icon(watch.icon, 0, False)
        try:
            # Ubuntu 9.10 and above
            _indicator = indicate.Indicator()
        except:
            # Ubuntu 9.04
            _indicator = indicate.IndicatorMessage()
        _indicator.set_property("subtype", "im")
        _indicator.set_property("sender", watch.name)
        _indicator.set_property("body", watch.get_balloon_text())
        _indicator.set_property_time("time", time.time())
        if icon:
            _indicator.set_property_icon("icon", icon)
        _indicator.set_property('draw-attention', 'true')
        _indicator.connect("user-display", watch.open_watch)
        _indicator.show()

        self.indicate_db.update({watch.id: _indicator})
Пример #5
0
    def manage_indicator_items(self, data, tab_num=None):
        if not self.is_gwibber_active():
            for msg in data:
                if hasattr(msg, "first_seen") and msg.first_seen and \
                    hasattr(msg, "is_unread") and msg.is_unread and \
                    hasattr(msg, "gId") and msg.gId not in self.indicator_items:
                    indicator = indicate.IndicatorMessage()
                    indicator.set_property("subtype", "im")
                    indicator.set_property("sender", msg.sender_nick)
                    indicator.set_property("body", msg.text)
                    indicator.set_property_time("time", msg.time.gmticks())
                    if hasattr(msg, "image_path"):
                        pb = gtk.gdk.pixbuf_new_from_file(msg.image_path)
                        indicator.set_property_icon("icon", pb)

                    if tab_num is not None:
                        indicator.set_property("gwibber_tab", str(tab_num))
                    indicator.connect("user-display",
                                      self.on_indicator_activate)

                    self.indicator_items[msg.gId] = indicator
                    indicator.show()