예제 #1
0
    def __init__(self, parent, settings, path, nm, new):

        self.nm = nm
        self.path = path
        log.debug("Network config for path %s", path)
        settings = settings.get_settings_under(NET_SETTINGS_ID, path)
        FormSettingsDialog.__init__(self, "Network Detail", parent, settings, new)
        actions = None if new else self.settings.get_unpacked("network-actions")
        self.box = ActionsBox("Actions", actions)
        self.ui.get_widget("actions-box").pack_start(self.box, True, True, 0)
예제 #2
0
 def __init__(self, title, parent, actions):
     Gtk.Dialog.__init__(
         self,
         title,
         parent,
         Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
         (Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE),
     )
     self.box = ActionsBox(title, actions)
     self.get_content_area().add(self.box)
예제 #3
0
class NetworkDetailDialog(FormSettingsDialog):
    UI_FILES = ["network-detail.ui"]
    UI_ROOT = "network-detail"

    VALUES_MAPPING = (
        ("display-name", "name", "s"),
        ("nm-name", "id", "s"),
        ("ip-address", "network-ip", "s"),
        ("subnet-mask", "network-mask", "s"),
    )

    def __init__(self, parent, settings, path, nm, new):

        self.nm = nm
        self.path = path
        log.debug("Network config for path %s", path)
        settings = settings.get_settings_under(NET_SETTINGS_ID, path)
        FormSettingsDialog.__init__(self, "Network Detail", parent, settings, new)
        actions = None if new else self.settings.get_unpacked("network-actions")
        self.box = ActionsBox("Actions", actions)
        self.ui.get_widget("actions-box").pack_start(self.box, True, True, 0)

    def init_validations(self):
        self.add_validator("display-name", min_length=3, max_length=40)
        self.add_validator("nm-name", min_length=1, max_length=40)
        self.add_validator("ip-address", allowed_chars="0123456789.", regexp=r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")
        self.add_validator("subnet-mask", allowed_chars="0123456789.", regexp=r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")

    def on_get_current_net(self, btn):
        active = self.nm.get_default_connection_info()
        if active:
            # {'name': 'Wired connection 1', 'ip': '192.168.1.24', 'net_mask': '255.255.255.0', 'mac': '5c:26:a:4:c1:d3', 'device_type': 'Wired', 'interface': 'eth0', 'vpn': False, 'type': '802-3-ethernet'}
            if not self.ui.get_widget("display-name").get_text():
                self.ui.get_widget("display-name").set_text(active.get("name"))
            self.ui.get_widget("nm-name").set_text(active.get("name"))
            if active.get("device_type") == "Wired" and not active.get("vpn"):
                self.ui.get_widget("ip-address").set_text(active.get("ip"))
                self.ui.get_widget("subnet-mask").set_text(active.get("net_mask"))

    def get_name(self):
        return self.ui.get_widget("display-name").get_text()

    def get_path(self):
        return self.path

    def save_all(self):
        super(NetworkDetailDialog, self).save_all()
        self.settings.set_formatted("network-actions", self.box.get_actions(), "as")