本文整理汇总了Python中gi.repository.Gedit.utils_is_valid_location方法的典型用法代码示例。如果您正苦于以下问题:Python Gedit.utils_is_valid_location方法的具体用法?Python Gedit.utils_is_valid_location怎么用?Python Gedit.utils_is_valid_location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gedit
的用法示例。
在下文中一共展示了Gedit.utils_is_valid_location方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: activate_tab
# 需要导入模块: from gi.repository import Gedit [as 别名]
# 或者: from gi.repository.Gedit import utils_is_valid_location [as 别名]
def activate_tab(self, file):
"""
Activate the GeditTab containing the given File or open a new
tab for it (this is called by the WindowContext)
@param file: a File object
"""
for tab, tab_decorator in self._tab_decorators.items():
if tab_decorator.file and tab_decorator.file == file:
self.window.set_active_tab(tab)
return
# not found, open file in a new tab...
uri = file.uri
gfile = Gio.file_new_for_uri(uri)
if Gedit.utils_is_valid_location(gfile):
LOG.debug("GeditWindow.create_tab_from_uri(%s)" % uri)
try:
view = self.window.get_active_view()
encoding = view.get_buffer().get_encoding()
except AttributeError:
# No document open
encoding = None
self.window.create_tab_from_location(
gfile, encoding,
1, 1, False, True)
else:
LOG.error("Gedit.utils.uri_is_valid(%s) = False" % uri)
示例2: _direct_file
# 需要导入模块: from gi.repository import Gedit [as 别名]
# 或者: from gi.repository.Gedit import utils_is_valid_location [as 别名]
def _direct_file(self):
uri = self._entry.get_text()
gfile = Gio.file_new_for_uri(uri)
if Gedit.utils_is_valid_location(gfile) or (os.path.isabs(uri) and gfile.query_exists()):
return gfile
else:
return None
示例3: activate_tab
# 需要导入模块: from gi.repository import Gedit [as 别名]
# 或者: from gi.repository.Gedit import utils_is_valid_location [as 别名]
def activate_tab(self, file):
"""
Activate the GeditTab containing the given File or open a new
tab for it (this is called by the WindowContext)
@param file: a File object
"""
for tab, tab_decorator in self._tab_decorators.iteritems():
if tab_decorator.file and tab_decorator.file == file:
self.window.set_active_tab(tab)
return
# not found, open file in a new tab...
uri = file.uri
gfile = Gio.file_new_for_uri(uri)
if Gedit.utils_is_valid_location(gfile):
LOG.debug("GeditWindow.create_tab_from_uri(%s)" % uri)
self.window.create_tab_from_location(
gfile, Gedit.encoding_get_current(),
1, 1, False, True)
else:
LOG.error("Gedit.utils.uri_is_valid(%s) = False" % uri)