Esempio n. 1
0
    def __init__(self, add_auto=True):
        self.add_auto = add_auto
        self.store = gtk.ListStore(str, str)

        gtk.ComboBox.__init__(self, self.store)

        pix = gtk.CellRendererPixbuf()
        txt = gtk.CellRendererText()

        self.pack_start(pix, False)
        self.pack_start(txt)

        self.set_attributes(pix, stock_id=0)
        self.set_attributes(txt, markup=1)

        if self.add_auto:
            self.store.append([gtk.STOCK_CONNECT, _("<b>Auto</b>")])

        for iface in backend.find_all_devs():
            self.store.append(
                [gtk.STOCK_CONNECT, iface.name]
            )

        self.set_active(0)
        self.show()
    def __populate(self):
        # Let's repopulate the store if the capmethod changes.
        # This is usefull for WINDOWS in case of using windump/dumpcap
        # that have a different nomenclature for the interface respect
        # libdnet python binding.

        # This is useless for Linux and other OS

        self.if_list.store.clear()
        active_m = self.options.method.get_active()

        for iface in backend.find_all_devs(active_m):
            self.if_list.store.append(
                [gtk.STOCK_CONNECT, iface.name, iface.description, iface.ip])
Esempio n. 3
0
    def __populate(self):
        # Let's repopulate the store if the capmethod changes.
        # This is usefull for WINDOWS in case of using windump/dumpcap
        # that have a different nomenclature for the interface respect
        # libdnet python binding.

        # This is useless for Linux and other OS

        self.if_list.store.clear()
        active_m = self.options.method.get_active()

        for iface in backend.find_all_devs(active_m):
            self.if_list.store.append(
                [gtk.STOCK_CONNECT, iface.name, iface.description, iface.ip]
            )
Esempio n. 4
0
    def __init__(self, add_auto=True):
        self.add_auto = add_auto
        self.store = gtk.ListStore(str, str)

        gtk.ComboBox.__init__(self, self.store)

        pix = gtk.CellRendererPixbuf()
        txt = gtk.CellRendererText()

        self.pack_start(pix, False)
        self.pack_start(txt)

        self.set_attributes(pix, stock_id=0)
        self.set_attributes(txt, markup=1)

        if self.add_auto:
            self.store.append([gtk.STOCK_CONNECT, _("<b>Auto</b>")])

        for iface in backend.find_all_devs():
            self.store.append([gtk.STOCK_CONNECT, iface.name])

        self.set_active(0)
        self.show()
Esempio n. 5
0
    def __init__(self):
        super(RouteList, self).__init__(False, 2)
        self.set_border_width(4)

        self.frame = gtk.Frame()
        self.frame.set_shadow_type(gtk.SHADOW_NONE)

        lbl = gtk.Label(_('<b>Routing table:</b>'))
        lbl.set_use_markup(True)

        self.frame.set_label_widget(lbl)

        self.ifaces = []

        for iface in backend.find_all_devs():
            self.ifaces.append(iface.name)

        self.ip_regex = re.compile(
                "\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
                "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
                "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
                "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"
        )

        # A ListStore model to organize all possible interfaces
        self.iface_store = gtk.ListStore(str)

        for iface in self.ifaces:
            self.iface_store.append([iface])

        # Stock, network, netmask, gw, iface, out_ip
        self.store = gtk.ListStore(str, str, str, str, str, str)
        self.tree = gtk.TreeView(self.store)

        pix_renderer = gtk.CellRendererPixbuf()
        txt_renderer = gtk.CellRendererText()

        col = gtk.TreeViewColumn(_('Network'))
        col.pack_start(pix_renderer, False)
        col.pack_start(txt_renderer)

        col.set_attributes(pix_renderer, stock_id=0)
        col.set_attributes(txt_renderer, text=1)

        txt_renderer.set_property('editable', True)
        txt_renderer.connect('edited', self.__on_field_edited, 1)

        self.tree.append_column(col)

        idx = 2
        for name in (_('Netmask'), _('Gateway'), _('Interface'),
                     _('Output IP')):
            if idx == 4:
                renderer = gtk.CellRendererCombo()
                renderer.set_property('model', self.iface_store)
                renderer.set_property('text-column', 0)
            else:
                renderer = gtk.CellRendererText()

            renderer.set_property('editable', True)
            renderer.connect('edited', self.__on_field_edited, idx)

            col = gtk.TreeViewColumn(name, renderer, text=idx)
            self.tree.append_column(col)
            idx += 1

        self.tree.set_rules_hint(True)
        self.tree.set_reorderable(True)
        self.tree.connect('button-press-event', self.__on_context)

        sw = gtk.ScrolledWindow()

        sw.set_border_width(4)
        sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add(self.tree)

        self.frame.add(sw)
        self.pack_start(self.frame)

        self.__populate()