[gedit-plugins/gnome-2-32] Adapted commander and terminal for API changes



commit c2f1a7e6d70c00781221e63df44ec4369531e7bb
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date:   Thu Apr 29 14:59:24 2010 +0200

    Adapted commander and terminal for API changes

 plugins/commander/commander/commands/completion.py |    2 +-
 plugins/commander/modules/edit.py                  |   20 ++++++++++----------
 plugins/commander/modules/shell.py                 |    2 +-
 plugins/terminal/terminal.py                       |    7 +++----
 4 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/plugins/commander/commander/commands/completion.py b/plugins/commander/commander/commands/completion.py
index 0109bf3..1ec9244 100644
--- a/plugins/commander/commander/commands/completion.py
+++ b/plugins/commander/commander/commands/completion.py
@@ -156,7 +156,7 @@ def filename(words, idx, view):
 	doc = view.get_buffer()
 	
 	if not doc.is_untitled():
-		root = os.path.dirname(gio.File(doc.get_uri()).get_path())
+		root = os.path.dirname(doc.get_location().get_path())
 	else:
 		root = os.path.expanduser('~/')
 		
diff --git a/plugins/commander/modules/edit.py b/plugins/commander/modules/edit.py
index c8aed3e..43ec235 100644
--- a/plugins/commander/modules/edit.py
+++ b/plugins/commander/modules/edit.py
@@ -23,7 +23,7 @@ def __default__(filename, view):
 	cwd = os.getcwd()
 	
 	if not doc.is_untitled():
-		cwd = os.path.dirname(doc.get_uri())
+		cwd = doc.get_location().get_parent().get_path()
 	else:
 		cwd = os.path.expanduser('~/')
 	
@@ -35,13 +35,13 @@ def __default__(filename, view):
 	
 	if matches:
 		for match in matches:
-			files.append(gio.File(match).get_uri())
+			files.append(gio.File(match))
 	else:
-		files.append(gio.File(filename).get_uri())
+		files.append(gio.File(filename))
 	
 	if files:
 		window = view.get_toplevel()
-		gedit.commands.load_uris(window, files)
+		gedit.commands.load_locations(window, files)
 		
 	return commander.commands.result.HIDE
 
@@ -66,8 +66,8 @@ def rename(view, newfile):
 	if not doc.is_local():
 		raise commander.commands.exceptions.Execute('You can only rename local files')
 	
-	f = gio.File(doc.get_uri())
-	
+	f = doc.get_location()
+
 	if not f.query_exists():
 		raise commander.commands.exceptions.Execute('Current document file does not exist')
 	
@@ -101,7 +101,7 @@ def rename(view, newfile):
 	try:
 		f.move(dest, _dummy_cb, flags=gio.FILE_COPY_OVERWRITE)
 		
-		doc.set_uri(dest.get_uri())
+		doc.set_location(dest)
 		yield commander.commands.result.HIDE
 	except Exception, e:
 		raise commander.commands.exceptions.Execute('Could not move file: %s' % (e,))
@@ -114,12 +114,12 @@ def _mod_has_alias(mod, alias):
 
 def _edit_command(view, mod, func=None):
 	try:
-		uri = gio.File(inspect.getsourcefile(mod)).get_uri()
+		location = gio.File(inspect.getsourcefile(mod))
 	except:
 		return False
 
 	if not func:
-		gedit.commands.load_uri(view.get_toplevel(), uri)
+		gedit.commands.load_location(view.get_toplevel(), location)
 	else:
 		try:
 			lines = inspect.getsourcelines(func)
@@ -127,7 +127,7 @@ def _edit_command(view, mod, func=None):
 		except:
 			line = 0
 
-		gedit.commands.load_uri(view.get_toplevel(), uri, None, line)
+		gedit.commands.load_location(view.get_toplevel(), location, None, line)
 	
 	return True
 
diff --git a/plugins/commander/modules/shell.py b/plugins/commander/modules/shell.py
index 32d3d19..42e582b 100644
--- a/plugins/commander/modules/shell.py
+++ b/plugins/commander/modules/shell.py
@@ -105,7 +105,7 @@ def _run_command(entry, replace, background, argstr):
 	doc = entry.view().get_buffer()
 	
 	if not doc.is_untitled() and doc.is_local():
-		gfile = gio.File(doc.get_uri())
+		gfile = doc.get_location()
 		cwd = os.path.dirname(gfile.get_path())
 	
 	if '<!' in argstr:
diff --git a/plugins/terminal/terminal.py b/plugins/terminal/terminal.py
index 28ee996..229a766 100644
--- a/plugins/terminal/terminal.py
+++ b/plugins/terminal/terminal.py
@@ -296,10 +296,9 @@ class TerminalWindowHelper(object):
         doc = self._window.get_active_document()
         if doc is None:
             return None
-        uri = doc.get_uri()
-        if uri is not None and gedit.utils.uri_has_file_scheme(uri):
-            gfile = gio.File(uri)
-            directory = gfile.get_parent()
+        location = doc.get_location()
+        if location is not None and gedit.utils.location_has_file_scheme(location):
+            directory = location.get_parent()
             return directory.get_path()
         return None
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]