Beispiel #1
0
class Radar_Plugin(Plugin):
    def __init__(self, main_gui):
        self.register_plugin(PLUGIN_TYPE_RADAR)
        self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)
        self.myself = self.community.get_myself()
        self.main_gui = main_gui

        self.page = GUI_Page('Radar')
        self.user_radar = UserRadar(main_gui)
        self.page.pack_start(self.user_radar)
        self.action_list = User_Action_List(self.community.community_gui,
            self.user_radar.get_selected)
        self.page.pack_start(self.action_list.get_widget(), False, True)
        self.page.show_all()
        self.main_gui.add_page(self.page)
    
        # Press 'r' to switch to radar view
        self.main_gui.add_key_binding(gtk.gdk.CONTROL_MASK, gtk.keysyms.r, self.key_pressed_r)

        self.radar_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR),
            'radar.png'))
        self.main_gui.add_statusbar_icon(self.radar_icon, 'Open radar',
            self.statusbar_icon_clicked)

    def key_pressed_r(self, target, ctx):
        self.run()

    def statusbar_icon_clicked(self):
        if self.page.is_visible:
            self.main_gui.hide_page(self.page)
        else:
            self.run()

    def run(self):
        # get the last opened community from the main gui
        open_community = self.community.get_default_community()
        for page in reversed(self.main_gui.page_history):
            com = page.get_community()
            if com != None:
                open_community = com
                break
        cname = open_community.get('name')
        debug('radar: Opening radar view for community %s\n' % cname)
        self.page.set_page_title(cname, sub=True)
        self.user_radar.set_community(open_community)
        self.main_gui.show_page(self.page)

    def user_appears(self, user):
        if user != self.myself and self.main_gui:
            self.user_radar.new_user(user)

    def user_changes(self, user, what=None):
        if user != self.myself and self.main_gui:
            self.user_radar.update_user(user, what)

    def user_disappears(self, user):
        if user != self.myself and self.main_gui:
            self.user_radar.remove_user(user)
Beispiel #2
0
    def __init__(self, main_gui):
        self.register_plugin(PLUGIN_TYPE_RADAR)
        self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)
        self.myself = self.community.get_myself()
        self.main_gui = main_gui

        self.page = GUI_Page('Radar')
        self.user_radar = UserRadar(main_gui)
        self.page.pack_start(self.user_radar)
        self.action_list = User_Action_List(self.community.community_gui,
            self.user_radar.get_selected)
        self.page.pack_start(self.action_list.get_widget(), False, True)
        self.page.show_all()
        self.main_gui.add_page(self.page)
    
        # Press 'r' to switch to radar view
        self.main_gui.add_key_binding(gtk.gdk.CONTROL_MASK, gtk.keysyms.r, self.key_pressed_r)

        self.radar_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR),
            'radar.png'))
        self.main_gui.add_statusbar_icon(self.radar_icon, 'Open radar',
            self.statusbar_icon_clicked)