[gedit] tools: check we have a view before trying to use it
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] tools: check we have a view before trying to use it
- Date: Mon, 13 Jan 2014 18:39:36 +0000 (UTC)
commit ee9912a765ac33a562ef8a90e760e8173dfde427
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Mon Jan 13 17:17:01 2014 +0100
tools: check we have a view before trying to use it
This may happen when there are no tabs and using an always
available tool.
plugins/externaltools/tools/functions.py | 40 +++++++++++++++--------------
1 files changed, 21 insertions(+), 19 deletions(-)
---
diff --git a/plugins/externaltools/tools/functions.py b/plugins/externaltools/tools/functions.py
index 301fad3..d23b0f7 100644
--- a/plugins/externaltools/tools/functions.py
+++ b/plugins/externaltools/tools/functions.py
@@ -306,7 +306,8 @@ def capture_stderr_line_panel(capture, line, panel):
panel.write(line, panel.error_tag)
def capture_begin_execute_panel(capture, panel, view, label):
- view.get_window(Gtk.TextWindowType.TEXT).set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))
+ if view:
+ view.get_window(Gtk.TextWindowType.TEXT).set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))
panel['stop'].set_sensitive(True)
panel.clear()
@@ -316,27 +317,28 @@ def capture_begin_execute_panel(capture, panel, view, label):
def capture_end_execute_panel(capture, exit_code, panel, view, output_type):
panel['stop'].set_sensitive(False)
- if output_type in ('new-document','replace-document'):
- doc = view.get_buffer()
- start = doc.get_start_iter()
- end = start.copy()
- end.forward_chars(300)
- uri = ''
+ if view:
+ if output_type in ('new-document','replace-document'):
+ doc = view.get_buffer()
+ start = doc.get_start_iter()
+ end = start.copy()
+ end.forward_chars(300)
+ uri = ''
- mtype, uncertain = Gio.content_type_guess(None, doc.get_text(start, end, False).encode('utf-8'))
- lmanager = GtkSource.LanguageManager.get_default()
+ mtype, uncertain = Gio.content_type_guess(None, doc.get_text(start, end, False).encode('utf-8'))
+ lmanager = GtkSource.LanguageManager.get_default()
- location = doc.get_location()
- if location:
- uri = location.get_uri()
- language = lmanager.guess_language(uri, mtype)
-
- if language is not None:
- doc.set_language(language)
+ location = doc.get_location()
+ if location:
+ uri = location.get_uri()
+ language = lmanager.guess_language(uri, mtype)
+
+ if language is not None:
+ doc.set_language(language)
- view.get_window(Gtk.TextWindowType.TEXT).set_cursor(Gdk.Cursor.new(Gdk.CursorType.XTERM))
- view.set_cursor_visible(True)
- view.set_editable(True)
+ view.get_window(Gtk.TextWindowType.TEXT).set_cursor(Gdk.Cursor.new(Gdk.CursorType.XTERM))
+ view.set_cursor_visible(True)
+ view.set_editable(True)
if exit_code == 0:
panel.write("\n" + _("Done.") + "\n", panel.italic_tag)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]