gedit r6354 - in trunk: . plugins/snippets/snippets
- From: jessevdk svn gnome org
- To: svn-commits-list gnome org
- Subject: gedit r6354 - in trunk: . plugins/snippets/snippets
- Date: Wed, 6 Aug 2008 20:10:43 +0000 (UTC)
Author: jessevdk
Date: Wed Aug 6 20:10:43 2008
New Revision: 6354
URL: http://svn.gnome.org/viewvc/gedit?rev=6354&view=rev
Log:
* plugins/snippets/snippets/Manager.py:
* plugins/snippets/snippets/Snippet.py:
* plugins/snippets/snippets/Document.py:
Ported to gio
Modified:
trunk/ChangeLog
trunk/plugins/snippets/snippets/Document.py
trunk/plugins/snippets/snippets/Manager.py
trunk/plugins/snippets/snippets/Snippet.py
Modified: trunk/plugins/snippets/snippets/Document.py
==============================================================================
--- trunk/plugins/snippets/snippets/Document.py (original)
+++ trunk/plugins/snippets/snippets/Document.py Wed Aug 6 20:10:43 2008
@@ -20,7 +20,7 @@
import gtk
from gtk import gdk
-import gnomevfs
+import gio
import gedit
from Library import Library
@@ -723,7 +723,8 @@
def apply_uri_snippet(self, snippet, mime, uri):
# Remove file scheme
if gedit.utils.uri_has_file_scheme(uri):
- uri = gnomevfs.get_local_path_from_uri(uri)
+ gfile = gio.File(uri)
+ uri = gfile.get_path()
# Set environmental variables
filename = self.env_get_filename(self.view.get_buffer())
@@ -757,7 +758,7 @@
for uri in uris:
try:
- mime = gnomevfs.get_mime_type(uri)
+ mime = gio.content_type_guess(uri)
except:
mime = None
Modified: trunk/plugins/snippets/snippets/Manager.py
==============================================================================
--- trunk/plugins/snippets/snippets/Manager.py (original)
+++ trunk/plugins/snippets/snippets/Manager.py Wed Aug 6 20:10:43 2008
@@ -26,7 +26,7 @@
import gtksourceview2 as gsv
import pango
import gedit
-import gnomevfs
+import gio
from Snippet import Snippet
from Helper import *
@@ -174,7 +174,8 @@
def on_tree_view_drag_data_get(self, widget, context, selection_data, info, time):
- selection_data.set_uris(['file://' + gnomevfs.escape_path_string(self._temp_export)])
+ gfile = gio.File(self._temp_export)
+ selection_data.set_uris([gfile.get_uri()])
def on_tree_view_drag_begin(self, widget, context):
self.dragging = True
@@ -781,7 +782,9 @@
continue
# Remove file://
- filename = gnomevfs.get_local_path_from_uri(filename)
+ gfile = gio.File(filename)
+ filename = gfile.get_path()
+
importer = Importer(filename)
error = importer.run()
@@ -1152,7 +1155,7 @@
for uri in uris:
try:
- mime = gnomevfs.get_mime_type(uri)
+ mime = gio.content_type_guess(uri)
except:
mime = None
Modified: trunk/plugins/snippets/snippets/Snippet.py
==============================================================================
--- trunk/plugins/snippets/snippets/Snippet.py (original)
+++ trunk/plugins/snippets/snippets/Snippet.py Wed Aug 6 20:10:43 2008
@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import os
-import gnomevfs
+import gio
from Placeholder import *
from Parser import Parser, Token
@@ -41,19 +41,30 @@
return len(s.expandtabs(tablen))
- def _gnomevfs_filename(self, filename):
- if filename.startswith('/'):
- return 'file://' + filename
+ def _filename_to_uri(self, filename):
+ gfile = gio.File(filename)
- return filename
+ return gfile.get_uri()
def util_readfile(self, filename):
- return gnomevfs.read_entire_file(self._gnomevfs_filename(filename))
+ stream = gio.File(filename).read()
+
+ if not stream:
+ return ''
+
+ res = stream.read()
+ stream.close()
+
+ return res
def util_filesize(self, filename):
- info = gnomevfs.get_file_info(self._gnomevfs_filename(filename), gnomevfs.FILE_INFO_FIELDS_SIZE)
+ gfile = gio.File(filename)
+ info = gfile.query_info(gio.FILE_ATTRIBUTE_STANDARD_SIZE)
+
+ if not info:
+ return 0
- return info.size
+ return info.get_size()
def util_align(self, items):
maxlen = []
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]