本文整理汇总了Python中syncthing_gtk.editordialog.EditorDialog类的典型用法代码示例。如果您正苦于以下问题:Python EditorDialog类的具体用法?Python EditorDialog怎么用?Python EditorDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EditorDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: store_value
def store_value(self, key, w):
if key == "vfolders": # And this one is special too
# Generate dict of { folder_id : bool } where bool is True if
# folder should be shared with this device
folders = {}
for b in self["vfolders"].get_children():
folders[b.get_tooltip_text()] = b.get_active()
# Go over all Folders/<folder>/Devices/<device> keys in config
# and set them as needed
nid = self.get_value("deviceID")
for r in self.config["folders"]:
rid = r["id"]
found = False
for n in r["devices"]:
if n["deviceID"] == nid:
if not rid in folders or not folders[rid]:
# Remove this /<device> key (unshare folder with device)
r["devices"].remove(n)
break
found = True
if (not found) and (rid in folders) and folders[rid]:
# Add new /<device> key (share folder with device)
r["devices"].append(
{"addresses": None, "deviceID": nid, "name": "", "certName": "", "compression": "metadata"}
)
else:
EditorDialog.store_value(self, key, w)
示例2: set_value
def set_value(self, key, value):
if key == "versioning":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "type"))
self.values["versioning"]["type"] = value
elif key == "keepVersions":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "params", "keep"))
self.values["versioning"]["params"]["keep"] = str(int(value))
elif key == "cleanoutDays":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "params", "cleanoutDays"))
self.values["versioning"]["params"]["cleanoutDays"] = str(int(value))
elif key == "maxAge":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "params", "maxAge"))
self.values["versioning"]["params"]["maxAge"] = str(int(value) * 86400) # days to seconds
elif key == "command":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "params", "command"))
self.values["versioning"]["params"]["command"] = value
elif key == "versionsPath":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "params", "versionsPath"))
self.values["versioning"]["params"]["versionsPath"] = value
elif key in ("readOnly", "receiveonly"):
if self["vreadOnly"].get_active():
self.values["type"] = "sendonly"
elif self["vreceiveOnly"].get_active():
self.values["type"] = "receiveonly"
else:
self.values["type"] = "sendreceive"
else:
EditorDialog.set_value(self, key, value)
示例3: set_value
def set_value(self, key, value):
if key == "versioning":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "type"))
self.values["versioning"]["type"] = value
elif key == "keepVersions":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "params", "keep"))
self.values["versioning"]["params"]["keep"] = str(int(value))
elif key == "maxAge":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "params", "maxAge"))
self.values["versioning"]["params"]["maxAge"] = str(int(value) * 86400) # days to seconds
elif key == "versionsPath":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "params", "versionsPath"))
self.values["versioning"]["params"]["versionsPath"] = value
elif key == "inotify":
l = self.app.config["use_inotify"]
if value:
if not self.id in l:
l.append(self.id)
else:
while self.id in l:
l.remove(self.id)
self.app.config["use_inotify"] = l
else:
EditorDialog.set_value(self, key, value)
示例4: __init__
def __init__(self, app, is_new, id=None):
EditorDialog.__init__(self, app,
"device-edit.glade",
"New Device" if is_new else "Edit Device"
)
self.id = id
self.is_new = is_new
示例5: __init__
def __init__(self, app, is_new, id=None, path=None):
EditorDialog.__init__(self, app,
"folder-edit.glade",
"New Shared Folder" if is_new else "Edit Shared Folder"
)
self.id = id
self.path = path
self.is_new = is_new
示例6: set_value
def set_value(self, key, value):
if key == "autostart":
set_run_on_startup(value, "Syncthing-GTK", get_executable(),
"/usr/share/syncthing-gtk/icons/st-logo-128.png",
"GUI for Syncthing")
elif key == "daemon_priority":
return EditorDialog.set_value(self, key, int(value))
else:
return EditorDialog.set_value(self, key, value)
示例7: store_value
def store_value(self, key, w):
if key == "vdevices": # Still very special case
devices = [ {
"deviceID" : b.get_tooltip_text(),
} for b in self["vdevices"].get_children()
if b.get_active()
]
self.set_value("devices", devices)
else:
EditorDialog.store_value(self, key, w)
示例8: display_value
def display_value(self, key, w):
if key == "vdevices":
# Very special case
nids = [ n["deviceID"] for n in self.get_value("devices") ]
for device in self.app.devices.values():
if device["id"] != self.app.daemon.get_my_id():
b = Gtk.CheckButton(device.get_title(), False)
b.set_tooltip_text(device["id"])
self["vdevices"].pack_end(b, False, False, 0)
b.set_active(device["id"] in nids)
self["vdevices"].show_all()
else:
EditorDialog.display_value(self, key, w)
示例9: get_value
def get_value(self, key):
if key == "addresses":
return ",".join([strip_v(x) for x in self.values[key]])
elif key == "compression":
val = EditorDialog.get_value(self, key)
# For syncthing <= 0.10.25
if val in (True, "true"):
return "always"
elif val in (False, "false"):
return "never"
else:
return val
else:
return EditorDialog.get_value(self, key)
示例10: store_value
def store_value(self, key, w):
if key == "vautostart_daemon":
if self["rbOnStartWait"].get_active() : self.set_value(key[1:], 0)
elif self["rbOnStartRun"].get_active() : self.set_value(key[1:], 1)
else: return self.set_value(key[1:], 2) # vOnStartAsk
elif key == "vautokill_daemon":
if self["rbOnExitTerminate"].get_active() : return self.set_value(key[1:], 1)
elif self["rbOnExitLeave"].get_active() : return self.set_value(key[1:], 0)
else: return self.set_value(key[1:], 2) # vOnExitAsk
elif key == "vst_autoupdate":
# Reset updatecheck timer when autoupdate is turned on
if self["vst_autoupdate"].get_active():
self.values["last_updatecheck"] = LONG_AGO
return EditorDialog.store_value(self, key, w)
else:
return EditorDialog.store_value(self, key, w)
示例11: set_value
def set_value(self, key, value):
if key == "listenAddresses":
self.values[key] = [ x.strip(" \t") for x in value.split(",") ]
elif key == "globalAnnounceServers":
self.values[key] = [ x.strip(" \t") for x in value.split(",") ]
elif key == "urAccepted":
self.values[key] = 1 if value else -1
elif key == "maxSendKbpsEnabled":
if value:
if self.values["maxSendKbps"] <= 0:
self.values["maxSendKbps"] = 1
self.find_widget_by_id("vmaxSendKbps").get_adjustment().set_value(self.values["maxSendKbps"])
else:
self.values["maxSendKbps"] = 0
self.find_widget_by_id("vmaxSendKbps").get_adjustment().set_value(self.values["maxSendKbps"])
elif key == "maxRecvKbpsEnabled":
if value:
if self.values["maxRecvKbps"] <= 0:
self.values["maxRecvKbps"] = 1
self.find_widget_by_id("vmaxRecvKbps").get_adjustment().set_value(self.values["maxRecvKbps"])
else:
self.values["maxRecvKbps"] = 0
self.find_widget_by_id("vmaxRecvKbps").get_adjustment().set_value(self.values["maxRecvKbps"])
else:
return EditorDialog.set_value(self, key, value)
示例12: display_value
def display_value(self, key, w):
if key == "vfolders":
# Even more special case
rids = [ ]
# Get list of folders that share this device
for r in self.config["folders"]:
for n in r["devices"]:
if n["deviceID"] == self.id:
rids.append(r["id"])
# Create CheckButtons
for folder in reversed(sorted(self.app.folders.values(), key=lambda x : x["id"])):
b = Gtk.CheckButton(folder["path"], False)
b.set_tooltip_text(folder["id"])
self["vfolders"].pack_start(b, False, False, 0)
b.set_active(folder["id"] in rids)
self["vfolders"].show_all()
else:
EditorDialog.display_value(self, key, w)
示例13: set_value
def set_value(self, key, value):
if key == "versioning":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "type"))
self.values["versioning"]["type"] = value
elif key == "keepVersions":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "params", "keep"))
self.values["versioning"]["params"]["keep"] = str(int(value))
elif key == "cleanoutDays":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "params", "cleanoutDays"))
self.values["versioning"]["params"]["cleanoutDays"] = str(int(value))
elif key == "maxAge":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "params", "maxAge"))
self.values["versioning"]["params"]["maxAge"] = str(int(value) * 86400) # days to seconds
elif key == "command":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "params", "command"))
self.values["versioning"]["params"]["command"] = value
elif key == "versionsPath":
# Create structure if needed
self.create_dicts(self.values, ("versioning", "params", "versionsPath"))
self.values["versioning"]["params"]["versionsPath"] = value
elif key == "readOnly":
self.values["type"] = "readonly" if value else "readwrite"
elif key == "inotify":
id = self.id
if id is None:
# Happens when saving new folder
id = self["vid"].get_text().strip()
l = self.app.config["use_inotify"]
if value:
if not id in l:
l.append(id)
else:
while id in l:
l.remove(id)
self.app.config["use_inotify"] = l
else:
EditorDialog.set_value(self, key, value)
示例14: __init__
def __init__(self, app):
EditorDialog.__init__(self, app, "find-daemon.glade",
_("Can't invoke the daemon"))
self.app = app
exe = "syncthing.exe" if IS_WINDOWS else _("Syncthing binary")
self["lblMessage"].set_markup("%s\n%s" % (
_("Syncthing daemon binary cannot be found."),
_("If you have Syncthing installed, please, set path to "
"%s below or click on <b>Download</b> "
"button to download latest Syncthing package.") % (exe,)
))
if IS_XP or StDownloader is None:
# Downloading is not offered on XP (github will not talk to it)
# or if StDownloader module is not packaged
self["lblMessage"].set_markup("%s\n%s" % (
_("Syncthing daemon binary cannot be found."),
_("If you have Syncthing installed, please, set path to "
"%s below") % (exe,)
))
self.hide_download_button()
示例15: store_value
def store_value(self, key, w):
if key == "vaddresses":
addresses = w.get_text().strip()
if addresses == "dynamic":
# Special case
self.set_value("addresses", "dynamic")
else:
addresses = [
x.strip() if "://" in x else "tcp://%s" % (x.strip(),)
for x in addresses.split(",") ]
self.set_value("addresses", ",".join(addresses))
elif key == "vfolders":
# Generate dict of { folder_id : bool } where bool is True if
# folder should be shared with this device
folders = {}
for b in self["vfolders"].get_children():
folders[b.get_tooltip_text()] = b.get_active()
# Go over all Folders/<folder>/Devices/<device> keys in config
# and set them as needed
nid = self.get_value("deviceID")
for r in self.config["folders"]:
rid = r["id"]
found = False
for n in r["devices"]:
if n["deviceID"] == nid:
if not rid in folders or not folders[rid]:
# Remove this /<device> key (unshare folder with device)
r["devices"].remove(n)
break
found = True
if (not found) and (rid in folders) and folders[rid]:
# Add new /<device> key (share folder with device)
r["devices"].append({
"addresses" : None,
"deviceID" : nid,
"name" : "",
"certName" : "",
"compression" : "metadata"
})
else:
EditorDialog.store_value(self, key, w)