示例#1
0
 def on_query_tooltip(self, widget, x, y, kb_mode, tooltip, *args):
     status_name = ipmsg.get_status().get_name().title()
     contacts = ipmsg.get_contacts()
     engine = ipmsg.get_engine()
     desc = '<b>%s</b>\n%s@%s:%s\n%s contacts' % (status_name, engine.login, engine.host, engine.port, len(contacts))
     tooltip.set_markup(desc)
     tooltip.set_icon(icons.App.get_status_pixbuf(ipmsg.get_status().status))
     return True
示例#2
0
    def create_left_menu(self):
        menuitems = []
        menuitems.append(["Send", None, not ipmsg.get_status().is_off(), self.on_show_send_window])

        menuitems.append(None)

        for k, v in STAT_NAME.items():
            menuitems.append([v.title(), icons.Menu.get_status_image(k, cache=False), True, self.do_change_status_to, (k, '', '')])

        menuitems.append(None)

        stat_menuitems = []
        for (stat, stat_msg, autoreply_msg) in settings['status_list']:
            stat_menuitems.append([stat_msg.replace('_', '__'), icons.Menu.get_status_image(stat, cache=False), True, \
                self.do_change_status_to, (stat, stat_msg, autoreply_msg)])

        stat_menu = self.create_menu(stat_menuitems, 'More')

        menu = self.create_menu(menuitems)
        menu.append(stat_menu)
        return menu
示例#3
0
    def mainloop(self):
        try:
            messages, events = ipmsg.whatsnew()
            new_incoming = [m for m in messages if m.io == 1 and m not in self.incoming]
            paused = [m for m in messages if m.io == 0 and m.is_send_error()]
            read_notify = [m for m in messages if m.io == 0 and m.is_opened()]
            deleted_notify = [m for m in messages if m.io == 0 and m.is_ignored()]
        except ipmsg.NetworkError:
            ipmsg.put_offline()
            dlg = NetworkErrorDialog(None)
            dlg.show()
            dlg.run()
            return True

        if settings['enable_notify']:
            if settings['notify_online']:
                msg = ''.join([contact.get_desc() + ' signed online.\n' for contact in events if contact.status in (STAT_ON, STAT_AFK)])
                if len(msg) > 0:
                    notify.balloon('notify', msg, notify.EVENT)
            if settings['notify_offline']:
                msg = ''.join([contact.get_desc() + ' signed out.\n' for contact in events if contact.status == STAT_OFF])
                if len(msg) > 0:
                    notify.balloon('notify', msg, notify.EVENT)

            for msg in read_notify:
                notify.balloon('notify', '%s has opened your message.' % msg.contact.name , notify.EVENT)

            for msg in deleted_notify:
                notify.balloon('notify', '%s ignored your message.' % msg.contact.name , notify.EVENT)

        if settings['enable_notify'] and (not ipmsg.get_status().is_afk() or not settings['disable_notify_afk']):
            for msg in new_incoming:
                icon = msg.atts and notify.ATT or notify.MSG
                notify.balloon(msg.contact.get_desc(), msg.options['seal'] and '--Secret Message--' or msg.msg, icon)

        if settings['enable_popup'] and (not ipmsg.get_status().is_afk() or not settings['non_popup_when_afk']):
            for msg in new_incoming:
                recv_dlg = RecvDialog(msg)
                recv_dlg.show()
                ipmsg.read_notice(msg)
            new_incoming = []

        prev_unread = [m for m in self.incoming if not m.is_read()]
        self.incoming = [m for m in messages if m.io == 1]
        self.update_icon()

        for msg in [m for m in paused if m not in self.prev_paused]:
            if settings['notify_error']:
                notify.balloon('Error', 'Message not delivered', notify.EVENT)
            dlg = ResendConfimDialog(None, msg.msg)
            def on_resend_rsps(w, id, msg):
                if id == gtk.RESPONSE_YES:
                    ipmsg.resend(msg)
                w.destroy()
            dlg.connect('response', on_resend_rsps, msg)
            dlg.show()

        self.prev_paused = paused[:]

        for msg in new_incoming:
            label = '    %s ... (%s ago)' % (msg.contact.get_desc(), util.calc_time(msg.packet.age()))
            item = gtk.MenuItem(label, False)
            item.connect('activate', self.on_read_msg, msg)
            item.show()
            self.left_menu.insert(item, 1)
        self.left_menu.get_children()[0].set_sensitive(not ipmsg.get_status().is_off())

        return True