Ejemplo n.º 1
0
    def __init__(self):
        super(PeersTab, self).__init__('Peers', 'peers_tab', 'peers_tab_label')

        self.peer_menu = self.main_builder.get_object('menu_peer_tab')
        component.get('MainWindow').connect_signals(self)

        self.listview = self.main_builder.get_object('peers_listview')
        self.listview.props.has_tooltip = True
        self.listview.connect('button-press-event',
                              self._on_button_press_event)
        self.listview.connect('query-tooltip', self._on_query_tooltip)

        # flag, ip, client, downspd, upspd, country code, int_ip, seed/peer icon, progress
        self.liststore = ListStore(Pixbuf, str, str, int, int, str, float,
                                   Pixbuf, float)
        self.cached_flag_pixbufs = {}

        self.seed_pixbuf = icon_seeding
        self.peer_pixbuf = icon_downloading

        # key is ip address, item is row iter
        self.peers = {}

        # Country column
        column = TreeViewColumn()
        render = CellRendererPixbuf()
        column.pack_start(render, False)
        column.add_attribute(render, 'pixbuf', 0)
        column.set_sort_column_id(5)
        column.set_clickable(True)
        column.set_resizable(True)
        column.set_expand(False)
        column.set_min_width(20)
        column.set_reorderable(True)
        self.listview.append_column(column)

        # Address column
        column = TreeViewColumn(_('Address'))
        render = CellRendererPixbuf()
        column.pack_start(render, False)
        column.add_attribute(render, 'pixbuf', 7)
        render = CellRendererText()
        column.pack_start(render, False)
        column.add_attribute(render, 'text', 1)
        column.set_sort_column_id(6)
        column.set_clickable(True)
        column.set_resizable(True)
        column.set_expand(False)
        column.set_min_width(100)
        column.set_reorderable(True)
        self.listview.append_column(column)

        # Client column
        column = TreeViewColumn(_('Client'))
        render = CellRendererText()
        column.pack_start(render, False)
        column.add_attribute(render, 'text', 2)
        column.set_sort_column_id(2)
        column.set_clickable(True)
        column.set_resizable(True)
        column.set_expand(False)
        column.set_min_width(100)
        column.set_reorderable(True)
        self.listview.append_column(column)

        # Progress column
        column = TreeViewColumn(_('Progress'))
        render = CellRendererProgress()
        column.pack_start(render, True)
        column.set_cell_data_func(render, cell_data_peer_progress, 8)
        column.set_sort_column_id(8)
        column.set_clickable(True)
        column.set_resizable(True)
        column.set_expand(False)
        column.set_min_width(100)
        column.set_reorderable(True)
        self.listview.append_column(column)

        # Down Speed column
        column = TreeViewColumn(_('Down Speed'))
        render = CellRendererText()
        column.pack_start(render, False)
        column.set_cell_data_func(render, cell_data_speed_down, 3)
        column.set_sort_column_id(3)
        column.set_clickable(True)
        column.set_resizable(True)
        column.set_expand(False)
        column.set_min_width(50)
        column.set_reorderable(True)
        self.listview.append_column(column)

        # Up Speed column
        column = TreeViewColumn(_('Up Speed'))
        render = CellRendererText()
        column.pack_start(render, False)
        column.set_cell_data_func(render, cell_data_speed_up, 4)
        column.set_sort_column_id(4)
        column.set_clickable(True)
        column.set_resizable(True)
        column.set_expand(False)
        column.set_min_width(50)
        # Bugfix: Last column needs max_width set to stop scrollbar appearing
        column.set_max_width(150)
        column.set_reorderable(True)
        self.listview.append_column(column)

        self.listview.set_model(self.liststore)

        self.load_state()

        self.torrent_id = None
Ejemplo n.º 2
0
    def __init__(self, emu: Optional[DeSmuME],
                 debugger_controller: DebuggerController,
                 builder: Gtk.Builder):
        self.emu = emu
        self.debugger = debugger_controller
        self.builder = builder

        self._was_running_last_sync = False

        self._files__sw: Gtk.ScrolledWindow = builder.get_object(
            'ground_state_files_tree_sw')
        self._entities__sw: Gtk.ScrolledWindow = builder.get_object(
            'ground_state_entities_tree_sw')

        self._files__not_loaded: Gtk.Viewport = builder.get_object(
            'ground_state_files_tree_engine_not_loaded')
        self._entities__not_loaded: Gtk.Viewport = builder.get_object(
            'ground_state_entities_tree_engine_not_loaded')

        self._ssb_tree_store_iters: Dict[int, Gtk.TreeIter] = {}

        self._files__tree: Gtk.TreeView = builder.get_object(
            'ground_state_files_tree')
        icon = Gtk.CellRendererPixbuf()
        path = Gtk.CellRendererText()
        column = TreeViewColumn("Path")
        column.pack_start(icon, True)
        column.pack_start(path, True)
        column.add_attribute(icon, "icon_name", 0)
        column.add_attribute(path, "text", 1)
        self._files__tree.append_column(resizable(column))
        self._files__tree.append_column(
            resizable(TreeViewColumn("Hanger", Gtk.CellRendererText(),
                                     text=3)))
        self._files__tree.append_column(
            resizable(TreeViewColumn("Type", Gtk.CellRendererText(), text=2)))

        self._entities__tree: Gtk.TreeView = builder.get_object(
            'ground_state_entities_tree')
        #self._files__tree.append_column(resizable(TreeViewColumn("Preview", Gtk.CellRendererPixbuf(), xxx=4)))
        icon = Gtk.CellRendererPixbuf()
        debug_icon = Gtk.CellRendererPixbuf()
        slot_id = Gtk.CellRendererText()
        column = TreeViewColumn("ID")
        column.pack_start(icon, True)
        column.pack_start(debug_icon, True)
        column.pack_start(slot_id, True)
        column.add_attribute(debug_icon, "icon_name", 6)
        column.add_attribute(icon, "icon_name", 7)
        column.add_attribute(slot_id, "text", 0)
        self._entities__tree.append_column(resizable(column))
        self._entities__tree.append_column(
            resizable(TreeViewColumn("Kind", Gtk.CellRendererText(), text=5)))
        self._entities__tree.append_column(
            resizable(TreeViewColumn("Hanger", Gtk.CellRendererText(),
                                     text=1)))
        self._entities__tree.append_column(
            resizable(TreeViewColumn("X", Gtk.CellRendererText(), text=8)))
        self._entities__tree.append_column(
            resizable(TreeViewColumn("Y", Gtk.CellRendererText(), text=9)))
        self._entities__tree.append_column(
            resizable(TreeViewColumn("Sector", Gtk.CellRendererText(),
                                     text=2)))
        self._entities__tree.append_column(
            resizable(TreeViewColumn("Script", Gtk.CellRendererText(),
                                     text=3)))

        self._files__tree_store: Gtk.TreeStore = builder.get_object(
            'ground_state_files_tree_store')
        self._entities__tree_store: Gtk.TreeStore = builder.get_object(
            'ground_state_entities_store')