當前位置: 首頁>>代碼示例>>Python>>正文


Python syncthing_gtk.EditorDialog類代碼示例

本文整理匯總了Python中syncthing_gtk.EditorDialog的典型用法代碼示例。如果您正苦於以下問題:Python EditorDialog類的具體用法?Python EditorDialog怎麽用?Python EditorDialog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了EditorDialog類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __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
開發者ID:Rongya,項目名稱:syncthing-gtk,代碼行數:7,代碼來源:deviceeditor.py

示例2: 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" : False
						})
		else:
			EditorDialog.store_value(self, key, w)
開發者ID:Rongya,項目名稱:syncthing-gtk,代碼行數:31,代碼來源:deviceeditor.py

示例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)
開發者ID:LenzGr,項目名稱:syncthing-gtk,代碼行數:28,代碼來源:foldereditor.py

示例4: 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)
開發者ID:Newman101,項目名稱:syncthing-gtk,代碼行數:9,代碼來源:uisettingsdialog.py

示例5: __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 bellow or click on <b>Download</b> "
			  "button to download latest Syncthing package.") % (exe,)
		))
開發者ID:Rongya,項目名稱:syncthing-gtk,代碼行數:11,代碼來源:finddaemondialog.py

示例6: 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)
開發者ID:LenzGr,項目名稱:syncthing-gtk,代碼行數:13,代碼來源:foldereditor.py

示例7: store_value

	def store_value(self, key, w):
		if key == "vDevices":	# Still very special case
			devices = [ {
					   "Addresses" : None,
					   "DeviceID" : b.get_tooltip_text(),
					   "Name" : "",
					   "CertName" : "",
					   "Compression" : False
						}
						for b in self["vDevices"].get_children()
						if b.get_active()
					]
			self.set_value("Devices", devices)
		else:
			EditorDialog.store_value(self, key, w)
開發者ID:LenzGr,項目名稱:syncthing-gtk,代碼行數:15,代碼來源:foldereditor.py

示例8: get_value

	def get_value(self, key):
		if key == "ListenAddress":
			return ",".join([ x.strip() for x in self.values[key]])
		elif key == "MaxSendKbpsEnabled":
			return (self.values["MaxSendKbps"] != 0)
		else:
			return EditorDialog.get_value(self, key)
開發者ID:bboerner,項目名稱:syncthing-gui,代碼行數:7,代碼來源:daemonsettings.py

示例9: set_value

	def set_value(self, key, value):
		if key == "ListenAddress":
			self.values[key] = [ x.strip() for x in value.split(",") ]
		elif key == "GlobalAnnServers":
			self.values[key] = [ x.strip() for x in value.split(",") ]
			if "GlobalAnnServer" in self.values:
				# For Syncthing < 0.9.10
				if len(self.values[key]) > 0:
					self.values["GlobalAnnServer"] = self.values[key][0]
				else:
					self.values["GlobalAnnServer"] = ""
		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
				print "MaxSendKbpsEnabled : MaxSendKbps zeroed"
				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)
開發者ID:Rongya,項目名稱:syncthing-gtk,代碼行數:32,代碼來源:daemonsettings.py

示例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)
開發者ID:Newman101,項目名稱:syncthing-gtk,代碼行數:16,代碼來源:uisettingsdialog.py

示例11: 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_end(b, False, False, 0)
				b.set_active(folder["id"] in rids)
			self["vFolders"].show_all()
		else:
			EditorDialog.display_value(self, key, w)
開發者ID:Rongya,項目名稱:syncthing-gtk,代碼行數:18,代碼來源:deviceeditor.py

示例12: __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 bellow 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 bellow") % (exe,)
			))
			self.hide_download_button()
開發者ID:nagyist,項目名稱:syncthing-gtk,代碼行數:20,代碼來源:finddaemondialog.py

示例13: 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
		else:
			return EditorDialog.store_value(self, key, w)
開發者ID:bboerner,項目名稱:syncthing-gui,代碼行數:11,代碼來源:uisettings.py

示例14: get_value

	def get_value(self, key):
		if key == "KeepVersions":
			return self.get_burried_value("Versioning/Params/keep", self.values, 0, int)
		elif key == "MaxAge":
			return self.get_burried_value("Versioning/Params/maxAge", self.values, 0, int) / 86400 # seconds to days
		elif key == "VersionsPath":
			return self.get_burried_value("Versioning/Params/versionsPath", self.values, "")
		elif key == "Versioning":
			return self.get_burried_value("Versioning/Type", self.values, "")
		elif key == "INotify":
			return self.id in self.app.config["use_inotify"]
		else:
			return EditorDialog.get_value(self, key)
開發者ID:LenzGr,項目名稱:syncthing-gtk,代碼行數:13,代碼來源:foldereditor.py

示例15: display_value

	def display_value(self, key, w):
		if key == "vautostart_daemon":
			value = self.get_value(key[1:])
			if   value == 0: self["rbOnStartWait"].set_active(True)
			elif value == 1: self["rbOnStartRun"].set_active(True)
			else: self["rbOnStartAsk"].set_active(True)
		elif key == "vautokill_daemon":
			value = self.get_value(key[1:])
			if   value == 1: self["rbOnExitTerminate"].set_active(True)
			elif value == 0: self["rbOnExitLeave"].set_active(True)
			else: self["rbOnExitAsk"].set_active(True)
		else:
			return EditorDialog.display_value(self, key, w)
開發者ID:Newman101,項目名稱:syncthing-gtk,代碼行數:13,代碼來源:uisettingsdialog.py


注:本文中的syncthing_gtk.EditorDialog類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。