def init_interface_state(self):
        self.widget("interface-pages").set_show_tabs(False)

        # [ unique, label, icon name, icon size, is_active ]
        interfaceListModel = gtk.ListStore(str, str, str, int, bool)
        self.widget("interface-list").set_model(interfaceListModel)

        interfaceCol = gtk.TreeViewColumn("Interfaces")
        interfaceCol.set_spacing(6)
        interface_txt = gtk.CellRendererText()
        interface_img = gtk.CellRendererPixbuf()
        interfaceCol.pack_start(interface_img, False)
        interfaceCol.pack_start(interface_txt, True)
        interfaceCol.add_attribute(interface_txt, 'text', 1)
        interfaceCol.add_attribute(interface_txt, 'sensitive', 4)
        interfaceCol.add_attribute(interface_img, 'icon-name', 2)
        interfaceCol.add_attribute(interface_img, 'stock-size', 3)
        self.widget("interface-list").append_column(interfaceCol)
        interfaceListModel.set_sort_column_id(1, gtk.SORT_ASCENDING)

        # Starmode combo
        uihelpers.build_startmode_combo(self.widget("interface-startmode"))

        # [ name, type ]
        childListModel = gtk.ListStore(str, str)
        childList = self.widget("interface-child-list")
        childList.set_model(childListModel)

        childNameCol = gtk.TreeViewColumn("Name")
        child_txt1 = gtk.CellRendererText()
        childNameCol.pack_start(child_txt1, True)
        childNameCol.add_attribute(child_txt1, 'text', 0)
        childNameCol.set_sort_column_id(0)
        childList.append_column(childNameCol)

        childTypeCol = gtk.TreeViewColumn("Interface Type")
        child_txt2 = gtk.CellRendererText()
        childTypeCol.pack_start(child_txt2, True)
        childTypeCol.add_attribute(child_txt2, 'text', 1)
        childTypeCol.set_sort_column_id(1)
        childList.append_column(childTypeCol)
        childListModel.set_sort_column_id(0, gtk.SORT_ASCENDING)

        self.populate_interfaces(interfaceListModel)
Beispiel #2
0
    def init_interface_state(self):
        self.widget("interface-pages").set_show_tabs(False)

        # [ unique, label, icon name, icon size, is_active ]
        interfaceListModel = gtk.ListStore(str, str, str, int, bool)
        self.widget("interface-list").set_model(interfaceListModel)

        interfaceCol = gtk.TreeViewColumn("Interfaces")
        interfaceCol.set_spacing(6)
        interface_txt = gtk.CellRendererText()
        interface_img = gtk.CellRendererPixbuf()
        interfaceCol.pack_start(interface_img, False)
        interfaceCol.pack_start(interface_txt, True)
        interfaceCol.add_attribute(interface_txt, 'text', 1)
        interfaceCol.add_attribute(interface_txt, 'sensitive', 4)
        interfaceCol.add_attribute(interface_img, 'icon-name', 2)
        interfaceCol.add_attribute(interface_img, 'stock-size', 3)
        self.widget("interface-list").append_column(interfaceCol)
        interfaceListModel.set_sort_column_id(1, gtk.SORT_ASCENDING)

        # Starmode combo
        uihelpers.build_startmode_combo(self.widget("interface-startmode"))

        # [ name, type ]
        childListModel = gtk.ListStore(str, str)
        childList = self.widget("interface-child-list")
        childList.set_model(childListModel)

        childNameCol = gtk.TreeViewColumn("Name")
        child_txt1 = gtk.CellRendererText()
        childNameCol.pack_start(child_txt1, True)
        childNameCol.add_attribute(child_txt1, 'text', 0)
        childNameCol.set_sort_column_id(0)
        childList.append_column(childNameCol)

        childTypeCol = gtk.TreeViewColumn("Interface Type")
        child_txt2 = gtk.CellRendererText()
        childTypeCol.pack_start(child_txt2, True)
        childTypeCol.add_attribute(child_txt2, 'text', 1)
        childTypeCol.set_sort_column_id(1)
        childList.append_column(childTypeCol)
        childListModel.set_sort_column_id(0, gtk.SORT_ASCENDING)

        self.populate_interfaces(interfaceListModel)
    def set_initial_state(self):
        self.widget("pages").set_show_tabs(False)
        self.widget("bond-pages").set_show_tabs(False)

        finish_img = Gtk.Image.new_from_stock(Gtk.STOCK_QUIT,
                                              Gtk.IconSize.BUTTON)
        self.widget("finish").set_image(finish_img)

        blue = Gdk.Color.parse("#0072A8")[1]
        self.widget("header").modify_bg(Gtk.StateType.NORMAL, blue)

        box = self.widget("header-icon-box")
        image = Gtk.Image.new_from_icon_name("network-idle",
                                             Gtk.IconSize.DIALOG)
        image.show()
        box.pack_end(image, False, False, False)

        # Interface type
        type_list = self.widget("interface-type")
        type_model = Gtk.ListStore(str, str)
        type_list.set_model(type_model)
        text = Gtk.CellRendererText()
        type_list.pack_start(text, True)
        type_list.add_attribute(text, 'text', 1)
        type_model.append([Interface.Interface.INTERFACE_TYPE_BRIDGE,
                           _("Bridge")])
        type_model.append([Interface.Interface.INTERFACE_TYPE_BOND,
                           _("Bond")])
        type_model.append([Interface.Interface.INTERFACE_TYPE_ETHERNET,
                           _("Ethernet")])
        type_model.append([Interface.Interface.INTERFACE_TYPE_VLAN,
                          _("VLAN")])

        # Start mode
        uihelpers.build_startmode_combo(
            self.widget("interface-startmode"))

        # Parent/slave Interface list
        slave_list = self.widget("interface-list")
        # [ vmmInterface, selected, selectabel, name, type, is defined,
        #   is active, in use by str, mac]
        slave_model = Gtk.ListStore(object, bool, bool, str, str, bool, bool,
                                    str, str)
        slave_list.set_model(slave_model)

        selectCol = Gtk.TreeViewColumn()
        nameCol = Gtk.TreeViewColumn(_("Name"))
        typeCol = Gtk.TreeViewColumn(_("Type"))
        useCol = Gtk.TreeViewColumn(_("In use by"))

        slave_list.append_column(selectCol)
        slave_list.append_column(nameCol)
        slave_list.append_column(typeCol)
        slave_list.append_column(useCol)

        chk = Gtk.CellRendererToggle()
        chk.connect("toggled", self.interface_item_toggled, slave_list)
        selectCol.pack_start(chk, False)
        selectCol.add_attribute(chk, "active", INTERFACE_ROW_SELECT)
        selectCol.add_attribute(chk, "inconsistent", INTERFACE_ROW_CANT_SELECT)
        selectCol.set_sort_column_id(INTERFACE_ROW_CANT_SELECT)

        txt = Gtk.CellRendererText()
        nameCol.pack_start(txt, True)
        nameCol.add_attribute(txt, "text", INTERFACE_ROW_NAME)
        nameCol.set_sort_column_id(INTERFACE_ROW_NAME)

        txt = Gtk.CellRendererText()
        typeCol.pack_start(txt, True)
        typeCol.add_attribute(txt, "text", INTERFACE_ROW_TYPE)
        typeCol.set_sort_column_id(INTERFACE_ROW_TYPE)
        slave_model.set_sort_column_id(INTERFACE_ROW_CANT_SELECT,
                                       Gtk.SortType.ASCENDING)

        txt = Gtk.CellRendererText()
        useCol.pack_start(txt, True)
        useCol.add_attribute(txt, "text", INTERFACE_ROW_IN_USE_BY)
        useCol.set_sort_column_id(INTERFACE_ROW_IN_USE_BY)

        # Bond config
        mode_list = self.widget("bond-mode")
        mode_model = Gtk.ListStore(str, str)
        mode_list.set_model(mode_model)
        txt = Gtk.CellRendererText()
        mode_list.pack_start(txt, True)
        mode_list.add_attribute(txt, "text", 0)
        mode_model.append([_("System default"), None])
        for m in Interface.InterfaceBond.INTERFACE_BOND_MODES:
            mode_model.append([m, m])

        mon_list = self.widget("bond-monitor-mode")
        mon_model = Gtk.ListStore(str, str)
        mon_list.set_model(mon_model)
        txt = Gtk.CellRendererText()
        mon_list.pack_start(txt, True)
        mon_list.add_attribute(txt, "text", 0)
        mon_model.append([_("System default"), None])
        for m in Interface.InterfaceBond.INTERFACE_BOND_MONITOR_MODES:
            mon_model.append([m, m])

        validate_list = self.widget("arp-validate")
        validate_model = Gtk.ListStore(str)
        validate_list.set_model(validate_model)
        txt = Gtk.CellRendererText()
        validate_list.pack_start(txt, True)
        validate_list.add_attribute(txt, "text", 0)
        for m in Interface.InterfaceBond.INTERFACE_BOND_MONITOR_MODE_ARP_VALIDATE_MODES:
            validate_model.append([m])

        carrier_list = self.widget("mii-carrier")
        carrier_model = Gtk.ListStore(str)
        carrier_list.set_model(carrier_model)
        txt = Gtk.CellRendererText()
        carrier_list.pack_start(txt, True)
        carrier_list.add_attribute(txt, "text", 0)
        for m in Interface.InterfaceBond.INTERFACE_BOND_MONITOR_MODE_MII_CARRIER_TYPES:
            carrier_model.append([m])

        # IP config
        copy_iface = self.widget("ip-copy-interface-combo")
        copy_model = Gtk.ListStore(str, object, bool)
        copy_iface.set_model(copy_model)
        txt = Gtk.CellRendererText()
        copy_iface.pack_start(txt, True)
        copy_iface.add_attribute(txt, "text", 0)
        copy_iface.add_attribute(txt, "sensitive", 2)

        ip_mode = self.widget("ipv4-mode")
        ip_model = Gtk.ListStore(str)
        ip_mode.set_model(ip_model)
        txt = Gtk.CellRendererText()
        ip_mode.pack_start(txt, True)
        ip_mode.add_attribute(txt, "text", 0)
        ip_model.insert(IP_DHCP, ["DHCP"])
        ip_model.insert(IP_STATIC, ["Static"])
        ip_model.insert(IP_NONE, ["No configuration"])

        ip_mode = self.widget("ipv6-mode")
        ip_model = Gtk.ListStore(str)
        ip_mode.set_model(ip_model)
        txt = Gtk.CellRendererText()
        ip_mode.pack_start(txt, True)
        ip_mode.add_attribute(txt, "text", 0)
        ip_model.insert(IP_DHCP, ["DHCP"])
        ip_model.insert(IP_STATIC, ["Static"])
        ip_model.insert(IP_NONE, ["No configuration"])

        v6_addr = self.widget("ipv6-address-list")
        addr_model = Gtk.ListStore(str)
        v6_addr.set_model(addr_model)
        txt_col = Gtk.TreeViewColumn("")
        v6_addr.append_column(txt_col)
        txt = Gtk.CellRendererText()
        txt.set_property("editable", True)
        txt.connect("edited", self.ipv6_address_edited)
        txt_col.pack_start(txt, True)
        txt_col.add_attribute(txt, "text", 0)
        v6_addr.get_selection().connect("changed", self.ipv6_address_selected)
Beispiel #4
0
    def set_initial_state(self):
        self.widget("pages").set_show_tabs(False)
        self.widget("bond-pages").set_show_tabs(False)

        finish_img = Gtk.Image.new_from_stock(Gtk.STOCK_QUIT,
                                              Gtk.IconSize.BUTTON)
        self.widget("finish").set_image(finish_img)

        blue = Gdk.Color.parse("#0072A8")[1]
        self.widget("header").modify_bg(Gtk.StateType.NORMAL, blue)

        box = self.widget("header-icon-box")
        image = Gtk.Image.new_from_icon_name("network-idle",
                                             Gtk.IconSize.DIALOG)
        image.show()
        box.pack_end(image, False, False, False)

        # Interface type
        type_list = self.widget("interface-type")
        type_model = Gtk.ListStore(str, str)
        type_list.set_model(type_model)
        text = Gtk.CellRendererText()
        type_list.pack_start(text, True)
        type_list.add_attribute(text, 'text', 1)
        type_model.append([Interface.Interface.INTERFACE_TYPE_BRIDGE,
                           _("Bridge")])
        type_model.append([Interface.Interface.INTERFACE_TYPE_BOND,
                           _("Bond")])
        type_model.append([Interface.Interface.INTERFACE_TYPE_ETHERNET,
                           _("Ethernet")])
        type_model.append([Interface.Interface.INTERFACE_TYPE_VLAN,
                          _("VLAN")])

        # Start mode
        uihelpers.build_startmode_combo(
            self.widget("interface-startmode"))

        # Parent/slave Interface list
        slave_list = self.widget("interface-list")
        # [ vmmInterface, selected, selectabel, name, type, is defined,
        #   is active, in use by str, mac]
        slave_model = Gtk.ListStore(object, bool, bool, str, str, bool, bool,
                                    str, str)
        slave_list.set_model(slave_model)

        selectCol = Gtk.TreeViewColumn()
        nameCol = Gtk.TreeViewColumn(_("Name"))
        typeCol = Gtk.TreeViewColumn(_("Type"))
        useCol = Gtk.TreeViewColumn(_("In use by"))

        slave_list.append_column(selectCol)
        slave_list.append_column(nameCol)
        slave_list.append_column(typeCol)
        slave_list.append_column(useCol)

        chk = Gtk.CellRendererToggle()
        chk.connect("toggled", self.interface_item_toggled, slave_list)
        selectCol.pack_start(chk, False)
        selectCol.add_attribute(chk, "active", INTERFACE_ROW_SELECT)
        selectCol.add_attribute(chk, "inconsistent", INTERFACE_ROW_CANT_SELECT)
        selectCol.set_sort_column_id(INTERFACE_ROW_CANT_SELECT)

        txt = Gtk.CellRendererText()
        nameCol.pack_start(txt, True)
        nameCol.add_attribute(txt, "text", INTERFACE_ROW_NAME)
        nameCol.set_sort_column_id(INTERFACE_ROW_NAME)

        txt = Gtk.CellRendererText()
        typeCol.pack_start(txt, True)
        typeCol.add_attribute(txt, "text", INTERFACE_ROW_TYPE)
        typeCol.set_sort_column_id(INTERFACE_ROW_TYPE)
        slave_model.set_sort_column_id(INTERFACE_ROW_CANT_SELECT,
                                       Gtk.SortType.ASCENDING)

        txt = Gtk.CellRendererText()
        useCol.pack_start(txt, True)
        useCol.add_attribute(txt, "text", INTERFACE_ROW_IN_USE_BY)
        useCol.set_sort_column_id(INTERFACE_ROW_IN_USE_BY)

        # Bond config
        mode_list = self.widget("bond-mode")
        mode_model = Gtk.ListStore(str, str)
        mode_list.set_model(mode_model)
        txt = Gtk.CellRendererText()
        mode_list.pack_start(txt, True)
        mode_list.add_attribute(txt, "text", 0)
        mode_model.append([_("System default"), None])
        for m in Interface.InterfaceBond.INTERFACE_BOND_MODES:
            mode_model.append([m, m])

        mon_list = self.widget("bond-monitor-mode")
        mon_model = Gtk.ListStore(str, str)
        mon_list.set_model(mon_model)
        txt = Gtk.CellRendererText()
        mon_list.pack_start(txt, True)
        mon_list.add_attribute(txt, "text", 0)
        mon_model.append([_("System default"), None])
        for m in Interface.InterfaceBond.INTERFACE_BOND_MONITOR_MODES:
            mon_model.append([m, m])

        validate_list = self.widget("arp-validate")
        validate_model = Gtk.ListStore(str)
        validate_list.set_model(validate_model)
        txt = Gtk.CellRendererText()
        validate_list.pack_start(txt, True)
        validate_list.add_attribute(txt, "text", 0)
        for m in Interface.InterfaceBond.INTERFACE_BOND_MONITOR_MODE_ARP_VALIDATE_MODES:
            validate_model.append([m])

        carrier_list = self.widget("mii-carrier")
        carrier_model = Gtk.ListStore(str)
        carrier_list.set_model(carrier_model)
        txt = Gtk.CellRendererText()
        carrier_list.pack_start(txt, True)
        carrier_list.add_attribute(txt, "text", 0)
        for m in Interface.InterfaceBond.INTERFACE_BOND_MONITOR_MODE_MII_CARRIER_TYPES:
            carrier_model.append([m])

        # IP config
        copy_iface = self.widget("ip-copy-interface-combo")
        copy_model = Gtk.ListStore(str, object, bool)
        copy_iface.set_model(copy_model)
        txt = Gtk.CellRendererText()
        copy_iface.pack_start(txt, True)
        copy_iface.add_attribute(txt, "text", 0)
        copy_iface.add_attribute(txt, "sensitive", 2)

        ip_mode = self.widget("ipv4-mode")
        ip_model = Gtk.ListStore(str)
        ip_mode.set_model(ip_model)
        txt = Gtk.CellRendererText()
        ip_mode.pack_start(txt, True)
        ip_mode.add_attribute(txt, "text", 0)
        ip_model.insert(IP_DHCP, ["DHCP"])
        ip_model.insert(IP_STATIC, ["Static"])
        ip_model.insert(IP_NONE, ["No configuration"])

        ip_mode = self.widget("ipv6-mode")
        ip_model = Gtk.ListStore(str)
        ip_mode.set_model(ip_model)
        txt = Gtk.CellRendererText()
        ip_mode.pack_start(txt, True)
        ip_mode.add_attribute(txt, "text", 0)
        ip_model.insert(IP_DHCP, ["DHCP"])
        ip_model.insert(IP_STATIC, ["Static"])
        ip_model.insert(IP_NONE, ["No configuration"])

        v6_addr = self.widget("ipv6-address-list")
        addr_model = Gtk.ListStore(str)
        v6_addr.set_model(addr_model)
        txt_col = Gtk.TreeViewColumn("")
        v6_addr.append_column(txt_col)
        txt = Gtk.CellRendererText()
        txt.set_property("editable", True)
        txt.connect("edited", self.ipv6_address_editted)
        txt_col.pack_start(txt, True)
        txt_col.add_attribute(txt, "text", 0)
        v6_addr.get_selection().connect("changed", self.ipv6_address_selected)