本文整理汇总了Python中gi.repository.Gedit.utils_location_has_file_scheme方法的典型用法代码示例。如果您正苦于以下问题:Python Gedit.utils_location_has_file_scheme方法的具体用法?Python Gedit.utils_location_has_file_scheme怎么用?Python Gedit.utils_location_has_file_scheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gedit
的用法示例。
在下文中一共展示了Gedit.utils_location_has_file_scheme方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_open_dev_file
# 需要导入模块: from gi.repository import Gedit [as 别名]
# 或者: from gi.repository.Gedit import utils_location_has_file_scheme [as 别名]
def on_open_dev_file(self, action):
doc = self.window.get_active_document()
if doc is None:
return None
location = doc.get_location()
if location is not None and Gedit.utils_location_has_file_scheme(location):
self.__lang.evaluate("thisProcess.platform.devLoc(\""+location.get_path()+"\").openTextFile", silent=True)
示例2: env_get_documents_path
# 需要导入模块: from gi.repository import Gedit [as 别名]
# 或者: from gi.repository.Gedit import utils_location_has_file_scheme [as 别名]
def env_get_documents_path(self, buf):
toplevel = self.view.get_toplevel()
if isinstance(toplevel, Gedit.Window):
documents_location = [doc.get_location()
for doc in toplevel.get_documents()
if doc.get_location() is not None]
documents_path = [location.get_path()
for location in documents_location
if Gedit.utils_location_has_file_scheme(location)]
else:
documents_path = []
return ' '.join(documents_path)
示例3: import_snippets
# 需要导入模块: from gi.repository import Gedit [as 别名]
# 或者: from gi.repository.Gedit import utils_location_has_file_scheme [as 别名]
def import_snippets(self, files):
success = True
for gfile in files:
if not Gedit.utils_location_has_file_scheme(gfile):
continue
# Remove file://
filename = gfile.get_path()
importer = Importer(filename)
error = importer.run()
if error:
message = _('The following error occurred while importing: %s') % error
success = False
message_dialog(self.get_toplevel(), Gtk.MessageType.ERROR, message)
self.build_model(True)
if success:
message = _('Import successfully completed')
message_dialog(self.get_toplevel(), Gtk.MessageType.INFO, message)
示例4: apply_uri_snippet
# 需要导入模块: from gi.repository import Gedit [as 别名]
# 或者: from gi.repository.Gedit import utils_location_has_file_scheme [as 别名]
def apply_uri_snippet(self, snippet, mime, uri):
# Remove file scheme
gfile = Gio.file_new_for_uri(uri)
pathname = ''
dirname = ''
ruri = ''
if Gedit.utils_location_has_file_scheme(gfile):
pathname = gfile.get_path()
dirname = gfile.get_parent().get_path()
name = gfile.get_basename()
scheme = gfile.get_uri_scheme()
os.environ['GEDIT_DROP_DOCUMENT_URI'] = uri
os.environ['GEDIT_DROP_DOCUMENT_NAME'] = name
os.environ['GEDIT_DROP_DOCUMENT_SCHEME'] = scheme
os.environ['GEDIT_DROP_DOCUMENT_PATH'] = pathname
os.environ['GEDIT_DROP_DOCUMENT_DIR'] = dirname
os.environ['GEDIT_DROP_DOCUMENT_TYPE'] = mime
buf = self.view.get_buffer()
location = buf.get_location()
if location:
ruri = location.get_uri()
relpath = self.relative_path(ruri, uri, mime)
os.environ['GEDIT_DROP_DOCUMENT_RELATIVE_PATH'] = relpath
mark = buf.get_mark('gtk_drag_target')
if not mark:
mark = buf.get_insert()
piter = buf.get_iter_at_mark(mark)
self.apply_snippet(snippet, piter, piter)