本文整理汇总了Python中gi.repository.Gedit类的典型用法代码示例。如果您正苦于以下问题:Python Gedit类的具体用法?Python Gedit怎么用?Python Gedit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Gedit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, window, panel, all_docs, node):
self._window = window
self._panel = panel
self._node = node
self._error = False
self._signal_ids = {}
self._counter = 0
if all_docs:
docs = window.get_documents()
else:
docs = [window.get_active_document()]
docs_to_save = [doc for doc in docs if doc.get_modified()]
signals = {}
for doc in docs_to_save:
signals[doc] = doc.connect('saving', self.on_document_saving)
if len(docs_to_save) == len(docs) and len(docs) != 0:
Gedit.commands_save_all_documents(window)
else:
for doc in docs_to_save:
Gedit.commands_save_document(window, doc)
for doc in docs_to_save:
doc.disconnect(signals[doc])
self.run_tool()
示例2: __default__
def __default__(filename, view):
"""Edit file: edit <filename>"""
doc = view.get_buffer()
cwd = os.getcwd()
if not doc.is_untitled():
cwd = doc.get_file().get_location().get_parent().get_path()
else:
cwd = os.path.expanduser('~/')
if not os.path.isabs(filename):
filename = os.path.join(cwd, filename)
matches = glob.glob(filename)
files = []
if matches:
for match in matches:
files.append(Gio.file_new_for_path(match))
else:
files.append(Gio.file_new_for_path(filename))
if files:
window = view.get_toplevel()
Gedit.commands_load_locations(window, files, None, 0, 0)
return commander.commands.result.HIDE
示例3: __init__
def __init__(self, plugin, window):
self.window = window
self.plugin = plugin
self.document_list = []
self.ui_id = None
self.action_toggle_orientation = Gtk.Action(name="ToggleSplitViewOrientation",
label="Toggle Split View Orientation",
tooltip="Switch between horizontal and vertical splits",
stock_id=Gtk.STOCK_REFRESH)
self.action_toggle_orientation.connect("activate", self.toggle_orientation)
self.action_toggle_orientation.set_visible(False)
# Add a "toggle split view" item to the View menu
self.insert_menu_item(window)
# We're going to keep track of each tab's split view. We'll
# index each dictionary via the tab objects.
self.split_views = {}
self.tabs_already_using_splitview = []
self.current_orientation = "horizontal"
# I hardly even know how this works, but it gets our encoding.
try: self.encoding = Gedit.encoding_get_current()
except: self.encoding = Gedit.gedit_encoding_get_current()
示例4: save_file
def save_file(self):
"""
Trigger the 'Save' action
(used by ToolAction before tool run)
"""
tab = self._active_tab_decorator.tab
Gedit.commands_save_document(tab.get_toplevel(), tab.get_document())
示例5: on_tool_manager_dialog_response
def on_tool_manager_dialog_response(self, dialog, response):
if response == Gtk.ResponseType.HELP:
Gedit.app_get_default().show_help(self.dialog, "gedit", "gedit-plugins-external-tools")
return
self.on_tool_manager_dialog_focus_out(dialog, None)
self.dialog.destroy()
self.dialog = None
self.tools = None
示例6: _load_session
def _load_session(self, session, window):
# Note: a session has to stand on its own window.
tab = window.get_active_tab()
if tab is not None and \
not (tab.get_document().is_untouched() and \
tab.get_state() == Gedit.TabState.STATE_NORMAL):
# Create a new gedit window
window = Gedit.App.get_default().create_window(None)
window.show()
Gedit.commands_load_locations(window, session.files, None, 0, 0)
示例7: save_next_document
def save_next_document(self):
if len(self._docs_to_save) == 0:
# The documents are saved, we can run the tool.
run_external_tool(self._window, self._panel, self._node)
else:
next_doc = self._docs_to_save[0]
self._docs_to_save.remove(next_doc)
Gedit.commands_save_document_async(next_doc,
self._window,
None,
self.on_document_saved,
None)
示例8: on_focus_out_event
def on_focus_out_event(self, widget, focus):
for n, doc in enumerate(self.window.get_unsaved_documents()):
if doc.is_untouched():
# nothing to do
continue
if doc.is_untitled():
# provide a default filename
now = datetime.datetime.now()
assure_path_exists(dirname)
filename = now.strftime(dirname + "%Y%m%d-%H%M%S-%%d.txt") % (n + 1)
doc.set_location(Gio.file_parse_name(filename))
# save the document
Gedit.commands_save_document(self.window, doc)
示例9: on_focus_out_event
def on_focus_out_event(self, widget, focus):
for doc in self.window.get_unsaved_documents():
if doc.is_untouched():
# nothing to do
continue
if doc.is_untitled():
# provide a default filename
now = datetime.datetime.now()
filename = now.strftime("/tmp/gedit.unsaved.%Y%m%d-%H%M%S.txt")
doc.set_location(Gio.file_parse_name(filename))
# save the document
Gedit.commands_save_document(self.window, doc)
示例10: _on_row_activated
def _on_row_activated(self, tree, path, column):
model = tree.get_model()
i = model.get_iter(path)
if model.iter_has_child(i):
if tree.row_expanded(path):
tree.collapse_row(path)
else:
tree.expand_row(path, False)
else:
info = model.get(i, 2, 3)
if info[1] != Gio.FileType.DIRECTORY:
Gedit.commands_load_location(self.window,
info[0], None, -1, -1)
示例11: on_view_button_press_event
def on_view_button_press_event(self, view, event):
if event.button != 1 or event.type != Gdk.BUTTON_PRESS or \
event.window != view.get_window(Gtk.TextWindowType.TEXT):
return False
link = self.get_link_at_location(view, int(event.x), int(event.y))
if link is None:
return False
gfile = self.file_lookup.lookup(link.path)
if gfile:
Gedit.commands_load_location(self.window, gfile, None, link.line_nr, -1)
GObject.idle_add(self.idle_grab_focus)
示例12: _setup
def _setup(self, tab):
notebooks = self._notebooks
multi = self._get_multi_notebook(tab)
if multi:
self._connect_handlers(multi, ('notebook-added', 'notebook-removed', 'tab-added', 'tab-removed'), 'multi_notebook', notebooks)
self._multi = multi
for doc in self.window.get_documents():
self.on_multi_notebook_notebook_added(multi, Gedit.Tab.get_from_document(doc).get_parent(), notebooks)
self._connect_handlers(self.window, ('tabs-reordered', 'active-tab-changed', 'key-press-event', 'key-release-event', 'focus-out-event'), 'window', notebooks)
elif hasattr(Gedit, 'debug_plugin_message'):
Gedit.debug_plugin_message("cannot find multi notebook from %s", tab)
示例13: __init__
def __init__(self, window, panel, docs, node):
self._window = window
self._panel = panel
self._node = node
self._error = False
self._counter = len(docs)
self._signal_ids = {}
self._counter = 0
signals = {}
for doc in docs:
signals[doc] = doc.connect('saving', self.on_document_saving)
Gedit.commands_save_document(window, doc)
doc.disconnect(signals[doc])
示例14: __init__
def __init__(self):
GObject.Object.__init__(self)
self.uri = ""
self.window = None
self.id_name = 'OpenURIContextMenuPluginID'
self.encoding = Gedit.encoding_get_from_charset("UTF-8")
示例15: on_open_dev_file
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)