当前位置: 首页>>代码示例>>Python>>正文


Python File.cancel方法代码示例

本文整理汇总了Python中gio.File.cancel方法的典型用法代码示例。如果您正苦于以下问题:Python File.cancel方法的具体用法?Python File.cancel怎么用?Python File.cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gio.File的用法示例。


在下文中一共展示了File.cancel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ColorButton

# 需要导入模块: from gio import File [as 别名]
# 或者: from gio.File import cancel [as 别名]
class ColorButton(object):

	def __init__(self, editor, manager):
		self.__init_attributes(editor, manager)
		self.__set_properties()
		self.__sigid1 = self.__button.connect("color-set", self.__color_set_cb)
		self.__sigid2 = manager.connect("destroy", self.__destroy_cb)
		self.__monitor.connect("changed", self.__changed_cb)
		self.__button.set_property("sensitive", True)

	def __init_attributes(self, editor, manager):
		self.__editor = editor
		self.__manager = manager
		self.__button = manager.gui.get_widget("BracketSelectionColorButton")
		from os.path import join
		preference_folder = join(editor.metadata_folder, "PluginPreferences")
		_path = join(preference_folder, "LexicalScopeHighlight.gdb")
		from gio import File, FILE_MONITOR_NONE
		self.__monitor = File(_path).monitor_file(FILE_MONITOR_NONE, None)
		return

	def __set_properties(self):
		from LexicalScopeHighlightMetadata import get_value
		from gtk.gdk import color_parse
		color = color_parse(get_value())
		self.__button.set_color(color)
		return

	def __destroy(self):
		self.__monitor.cancel()
		self.__editor.disconnect_signal(self.__sigid1, self.__button)
		self.__editor.disconnect_signal(self.__sigid2, self.__manager)
		self.__button.destroy()
		del self
		self = None
		return

	def __color_set_cb(self, *args):
		from LexicalScopeHighlightMetadata import set_value
		color = self.__button.get_color().to_string()
		set_value(color)
		return True

	def __destroy_cb(self, *args):
		self.__destroy()
		return True

	def __changed_cb(self, *args):
		monitor, gfile, otherfile, event = args
		if not (event in (0,2,3)): return False
		self.__button.handler_block(self.__sigid1)
		from LexicalScopeHighlightMetadata import get_value
		from gtk.gdk import color_parse
		color = color_parse(get_value())
		self.__button.set_color(color)
		self.__button.handler_unblock(self.__sigid1)
		return True
开发者ID:mystilleef,项目名称:scribes,代码行数:59,代码来源:BracketSelectionColorButton.py

示例2: Updater

# 需要导入模块: from gio import File [as 别名]
# 或者: from gio.File import cancel [as 别名]
class Updater(object):

	def __init__(self, editor):
		self.__init_attributes(editor)
		self.__sigid1 = editor.connect("quit", self.__quit_cb)
		self.__monitor.connect("changed", self.__changed_cb)
		self.__update()
		editor.register_object(self)

	def __init_attributes(self, editor):
		self.__editor = editor
		self.__buffer = editor.textbuffer
		from gio import File, FILE_MONITOR_NONE
		self.__monitor = File(self.__get_path()).monitor_file(FILE_MONITOR_NONE, None)
		return

	def __destroy(self):
		self.__editor.disconnect_signal(self.__sigid1, self.__editor)
		self.__monitor.cancel()
		self.__editor.unregister_object(self)
		del self
		return False

	def __update(self):
		from SCRIBES.ColorThemeMetadata import get_value
		scheme_id = get_value()
		style_scheme = self.__editor.style_scheme_manager.get_scheme(scheme_id)
		if style_scheme: self.__buffer.set_style_scheme(style_scheme)
		self.__editor.emit("syntax-color-theme-changed")
		return False

	def __get_path(self):
		from os.path import join
		folder = join(self.__editor.metadata_folder, "Preferences")
		return join(folder, "ColorTheme.gdb")

	def __quit_cb(self, *args):
		self.__destroy()
		return False

	def __changed_cb(self, *args):
		monitor, gfile, otherfile, event = args
		if not (event in (0, 2, 3)): return False
		from gobject import idle_add
		idle_add(self.__update)
		return False
开发者ID:mystilleef,项目名称:scribes,代码行数:48,代码来源:StyleSchemeUpdater.py

示例3: Listener

# 需要导入模块: from gio import File [as 别名]
# 或者: from gio.File import cancel [as 别名]
class Listener(object):

	def __init__(self, manager, editor):
		self.__init_attributes(manager, editor)
		self.__sigid1 = manager.connect("destroy", self.__destroy_cb)
		self.__monitor.connect("changed", self.__update_cb)
		self.__update()

	def __init_attributes(self, manager, editor):
		self.__editor = editor
		self.__manager = manager
		from gio import File, FILE_MONITOR_NONE
		self.__monitor = File(self.__get_path()).monitor_file(FILE_MONITOR_NONE, None)
		return

	def __destroy(self):
		self.__monitor.cancel()
		self.__editor.disconnect_signal(self.__sigid1, self.__manager)
		del self
		self = None
		return False

	def __get_path(self):
		from os.path import join
		folder = join(self.__editor.metadata_folder, "PluginPreferences")
		return join(folder, "TemplateIndentation.gdb")

	def __update(self):
		from Metadata import get_value
		self.__manager.emit("get-data", get_value())
		return False

	def __destroy_cb(self, *args):
		self.__destroy()
		return False

	def __update_cb(self, *args):
		monitor, gfile, otherfile, event = args
		if not (event in (0,2,3)): return False
		from gobject import idle_add
		idle_add(self.__update, priority=9999)
		return False
开发者ID:mystilleef,项目名称:scribes,代码行数:44,代码来源:DatabaseListener.py

示例4: Listener

# 需要导入模块: from gio import File [as 别名]
# 或者: from gio.File import cancel [as 别名]
class Listener(object):

	def __init__(self, manager, editor):
		self.__init_attributes(manager, editor)
		self.__sigid1 = editor.connect("quit", self.__quit_cb)
		self.__monitor.connect("changed", self.__changed_cb)
		editor.register_object(self)

	def __init_attributes(self, manager, editor):
		self.__editor = editor
		self.__view = editor.textview
		from gio import File, FILE_MONITOR_NONE
		self.__monitor = File(manager.get_path("Font.gdb")).monitor_file(FILE_MONITOR_NONE, None)
		self.__manager = manager
		return

	def __destroy(self):
		self.__monitor.cancel()
		self.__editor.disconnect_signal(self.__sigid1, self.__editor)
		self.__editor.unregister_object(self)
		del self
		self = None
		return False

	def __update(self):
		from pango import FontDescription
		from SCRIBES.FontMetadata import get_value
		new_font = FontDescription(get_value(self.__manager.get_language()))
		self.__view.modify_font(new_font)
		return False

	def __quit_cb(self, *args):
		self.__destroy()
		return False

	def __changed_cb(self, *args):
		monitor, gfile, otherfile, event = args
		if not (event in (0,2,3)): return False
		from gobject import idle_add
		idle_add(self.__update)
		return False
开发者ID:mystilleef,项目名称:scribes,代码行数:43,代码来源:FontListener.py

示例5: Listener

# 需要导入模块: from gio import File [as 别名]
# 或者: from gio.File import cancel [as 别名]
class Listener(object):

	def __init__(self, manager, editor):
		self.__init_attributes(manager, editor)
		self.__sigid1 = editor.connect("quit", self.__quit_cb)
		self.__monitor.connect("changed", self.__changed_cb)
		editor.register_object(self)

	def __init_attributes(self, manager, editor):
		self.__editor = editor
		self.__manager = manager
		self.__view = editor.textview
		from gio import File, FILE_MONITOR_NONE
		self.__monitor = File(manager.get_path("TextWrapping.gdb")).monitor_file(FILE_MONITOR_NONE, None)
		return

	def __destroy(self):
		self.__monitor.cancel()
		self.__editor.disconnect_signal(self.__sigid1, self.__editor)
		self.__editor.unregister_object(self)
		del self
		return False

	def __update(self):
		from gtk import WRAP_NONE, WRAP_WORD_CHAR
		from SCRIBES.TextWrappingMetadata import get_value
		wrap_mode = self.__view.set_wrap_mode
		wrap_mode(WRAP_WORD_CHAR) if get_value(self.__manager.get_language()) else wrap_mode(WRAP_NONE)
		return False

	def __quit_cb(self, *args):
		self.__destroy()
		return False

	def __changed_cb(self, *args):
		monitor, gfile, otherfile, event = args
		if not (event in (0,2,3)): return False
		from gobject import idle_add
		idle_add(self.__update)
		return False
开发者ID:mystilleef,项目名称:scribes,代码行数:42,代码来源:TextWrappingListener.py

示例6: Listener

# 需要导入模块: from gio import File [as 别名]
# 或者: from gio.File import cancel [as 别名]
class Listener(object):

	def __init__(self, manager, editor):
		self.__init_attributes(manager, editor)
		self.__sigid1 = editor.connect("quit", self.__quit_cb)
		self.__monitor.connect("changed", self.__changed_cb)
		editor.register_object(self)

	def __init_attributes(self, manager, editor):
		self.__manager = manager
		self.__editor = editor
		self.__view = editor.textview
		from gio import File, FILE_MONITOR_NONE
		self.__monitor = File(manager.get_path("MarginPosition.gdb")).monitor_file(FILE_MONITOR_NONE, None)
		return

	def __destroy(self):
		self.__monitor.cancel()
		self.__editor.disconnect_signal(self.__sigid1, self.__editor)
		self.__editor.unregister_object(self)
		del self
		self = None
		return False

	def __update(self):
		from SCRIBES.MarginPositionMetadata import get_value
		self.__view.set_property("right-margin-position", get_value(self.__manager.get_language()))
		return False

	def __quit_cb(self, *args):
		self.__destroy()
		return False

	def __changed_cb(self, *args):
		monitor, gfile, otherfile, event = args
		if not (event in (0,2,3)): return False
		from gobject import idle_add
		idle_add(self.__update)
		return False
开发者ID:mystilleef,项目名称:scribes,代码行数:41,代码来源:RightMarginPositionListener.py

示例7: Monitor

# 需要导入模块: from gio import File [as 别名]
# 或者: from gio.File import cancel [as 别名]
class Monitor(object):

	def __init__(self, manager, editor):
		self.__init_attributes(manager, editor)
		self.__sigid1 = manager.connect("destroy", self.__destroy_cb)
		self.__monitor.connect("changed", self.__update_cb)

	def __init_attributes(self, manager, editor):
		self.__manager = manager
		self.__editor = editor
		from os.path import join
		path_ = join(editor.metadata_folder, "abbreviations.gdb")
		from gio import File, FILE_MONITOR_NONE
		self.__monitor = File(path_).monitor_file(FILE_MONITOR_NONE, None)
		return

	def __destroy(self):
		self.__monitor.cancel()
		self.__editor.disconnect_signal(self.__sigid1, self.__manager)
		del self
		self = None
		return

	def __update(self, *args):
		self.__manager.emit("database-update")
		return False

	def __destroy_cb(self, *args):
		self.__destroy()
		return False

	def __update_cb(self, *args):
		monitor, gfile, otherfile, event = args
		if not (event in (0,2,3)): return False
		self.__update()
		return False
开发者ID:mystilleef,项目名称:scribes,代码行数:38,代码来源:DatabaseMonitor.py

示例8: Monitor

# 需要导入模块: from gio import File [as 别名]
# 或者: from gio.File import cancel [as 别名]
class Monitor(SignalManager):

	def __init__(self, editor):
		SignalManager.__init__(self)
		self.__init_attributes(editor)
		self.connect(editor, "close", self.__close_cb)
		self.connect(editor, "quit", self.__quit_cb)
		self.connect(editor, "saved-file", self.__saved_file_cb)
		self.connect(editor, "save-file", self.__busy_cb)
		self.connect(editor, "save-error", self.__nobusy_cb, True)
		self.connect(editor, "saved-file", self.__nobusy_cb, True)
		self.connect(editor, "loaded-file", self.__monitor_cb, True)
		editor.register_object(self)

	def __init_attributes(self, editor):
		self.__editor = editor
		self.__uri = ""
		from SCRIBES.GObjectTimerManager import Manager
		self.__timer_manager = Manager()
		from gio import File, FILE_MONITOR_NONE, Cancellable
		self.__cancellable = Cancellable()
		self.__file_monitor = File("").monitor_file(FILE_MONITOR_NONE, self.__cancellable)
		self.__can_reload = True
		return

	def __monitor(self, uri):
		self.__uri = uri
		from gio import File, FILE_MONITOR_NONE
		self.__unmonitor()
		self.__file_monitor = File(uri).monitor_file(FILE_MONITOR_NONE, self.__cancellable)
		self.__file_monitor.connect("changed", self.__changed_cb)
		self.__file_monitor.set_rate_limit(RATE_LIMIT)
		return False

	def __unmonitor(self):
		self.__file_monitor.cancel()
		self.__cancellable.cancel()
		self.__cancellable.reset()
		return False

	def __remove_monitor(self):
		self.__timer_manager.remove_all()
		self.__unmonitor()
		return False

	def __set_can_reload(self, can_reload):
		self.__can_reload = can_reload
		return False

	def __reload(self):
		if self.__file_exists() is False: return False
		if self.__file_is_remote(): return False
		from URILoader.Manager import Manager
		Manager(self.__editor, self.__uri, self.__editor.encoding)
		from gobject import timeout_add, PRIORITY_LOW
		timeout_add(1000, self.__reload_feedback_message, priority=PRIORITY_LOW)
		return False

	def __reload_feedback_message(self):
		from gettext import gettext as _
		message = _("File modification detected. Reloaded file")
		self.__editor.update_message(message, "info", 10)
		return False

	def __file_exists(self):
		from gio import File
		return File(self.__uri).query_exists()

	def __file_is_remote(self):
		if not self.__uri: return False
		from Utils import uri_is_remote
		return uri_is_remote(self.__uri)

	def __change_handler(self, event):
		if self.__can_reload is False or event not in (1, 2, 3, 4): return False
		from gobject import idle_add, PRIORITY_LOW
		idle_add(self.__reload, priority=PRIORITY_LOW)
		return False

	def __destroy(self):
		self.__timer_manager.destroy()
		self.disconnect()
		self.__editor.unregister_object(self)
		del self
		return False

	def __quit_cb(self, *args):
		self.__destroy()
		return False

	def __monitor_cb(self, editor, uri, *args):
		self.__timer_manager.remove_all()
		from gobject import idle_add, PRIORITY_LOW
		idle_add(self.__monitor, uri, priority=PRIORITY_LOW)
		return False

	def __changed_cb(self, monitor, child, other_child, event):
		self.__timer_manager.remove_all()
		from gobject import timeout_add
		self.__timer1 = timeout_add(WAIT_INTERVAL, self.__change_handler, event)
#.........这里部分代码省略.........
开发者ID:mystilleef,项目名称:scribes,代码行数:103,代码来源:FileChangeMonitor.py

示例9: Monitor

# 需要导入模块: from gio import File [as 别名]
# 或者: from gio.File import cancel [as 别名]
class Monitor(SignalManager):

	def __init__(self, manager, editor):
		SignalManager.__init__(self, editor)
		self.__init_attributes(manager, editor)
		self.connect(manager, "destroy", self.__destroy_cb)
		self.connect(manager, "generate-uris", self.__generate_uris_cb)
		self.connect(manager, "generate-data-for-treeview", self.__uris_cb)
		self.connect(manager, "finished-enumerating-children", self.__enumerated_children_cb)

	def __init_attributes(self, manager, editor):
		self.__manager = manager
		self.__editor = editor
		self.__folder_uri = ""
		self.__folder_monitor = None
		self.__uris = []
		self.__unique_id = ""
		return

	def __monitor(self, folder_uri):
		if self.__folder_uri == folder_uri: return False
		self.__disconnect()
		self.__connect(folder_uri)
		return False

	def __connect(self, folder_uri):
		self.__folder_uri = folder_uri
		from gio import File, FILE_MONITOR_WATCH_MOUNTS
		self.__folder_monitor = File(folder_uri).monitor_directory(FILE_MONITOR_WATCH_MOUNTS)
		self.__sigid1 = self.__folder_monitor.connect("changed", self.__changed_cb)
		return False

	def __disconnect(self):
		if not self.__folder_uri: return False
		self.__folder_monitor.disconnect(self.__sigid1)
		self.__folder_monitor.cancel()
		self.__folder_monitor = None
		return False

	def __check(self):
		from uuid import uuid1
		self.__unique_id = str(uuid1())
		from gobject import idle_add
		idle_add(self.__manager.emit, "enumerate-children", (self.__folder_uri, self.__unique_id))
		return False

	def __compare(self, user_data):
		fileinfos, folder_uri, unique_id = user_data
		if unique_id != self.__unique_id: return False
		if folder_uri != self.__folder_uri: return False
		from gio import File
		uris = sorted((File(folder_uri).resolve_relative_path(fileinfo.get_name()).get_uri()
			for fileinfo in fileinfos))
		if uris == self.__uris: return False
		from gobject import idle_add
		idle_add(self.__manager.emit, "generate-uris", folder_uri)
		return False

	def __remove_timer(self, _timer=1):
		try:
			timers = {
				1: self.__timer1,
			}
			from gobject import source_remove
			source_remove(timers[_timer])
		except AttributeError:
			pass
		return False

	def __changed_cb(self, folder_monitor, gfile, other_gfile, event_type):
		from gio import FILE_MONITOR_EVENT_CREATED, FILE_MONITOR_EVENT_DELETED
		if event_type not in (FILE_MONITOR_EVENT_CREATED, FILE_MONITOR_EVENT_DELETED): return False
		self.__remove_timer(1)
		from gobject import timeout_add, PRIORITY_LOW
		self.__timer1 = timeout_add(2000, self.__check, priority=PRIORITY_LOW)
		return False

	def __generate_uris_cb(self, manager, folder_uri):
		from gobject import idle_add
		idle_add(self.__monitor, folder_uri)
		return False

	def __enumerated_children_cb(self, manager, user_data):
		from gobject import idle_add, PRIORITY_LOW
		idle_add(self.__compare, user_data, priority=PRIORITY_LOW)
		return False

	def __uris_cb(self, manager, user_data):
		folder_uri, fileinfos, treeview_reference = user_data
		from gio import File
		self.__uris = sorted((File(folder_uri).resolve_relative_path(fileinfo.get_name()).get_uri()
			for fileinfo in fileinfos))
		return False

	def __destroy_cb(self, *args):
		self.__disconnect()
		self.disconnect()
		del self
		return False
开发者ID:mystilleef,项目名称:scribes,代码行数:101,代码来源:FolderMonitor.py


注:本文中的gio.File.cancel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。