~ubuntu-branches/ubuntu/precise/gedit/precise

« back to all changes in this revision

Viewing changes to plugins/snippets/snippets/Document.py

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-04-14 16:41:13 UTC
  • mfrom: (1.1.78 upstream)
  • Revision ID: james.westby@ubuntu.com-20100414164113-0xgl3u73pcs0ngbc
Tags: 2.30.0git20100413-0ubuntu1
* Updating to git snaptshot since 2.30.1 will be after lucid
* debian/patches/90_autoconf.patch:
  - new version update

Show diffs side-by-side

added added

removed removed

Lines of Context:
860
860
        
861
861
        def apply_uri_snippet(self, snippet, mime, uri):
862
862
                # Remove file scheme
 
863
                gfile = gio.File(uri)
 
864
                pathname = ''
 
865
                dirname = ''
 
866
 
863
867
                if gedit.utils.uri_has_file_scheme(uri):
864
 
                        gfile = gio.File(uri)
865
 
                        uri = gfile.get_path()
866
 
                
867
 
                # Set environmental variables
868
 
                buf = self.view.get_buffer()
869
 
                filename = self.env_get_document_path(buf)
870
 
                
871
 
                variables = {
872
 
                        'GEDIT_DROP_DOCUMENT_URI': self.env_get_document_uri,
873
 
                        'GEDIT_DROP_DOCUMENT_NAME': self.env_get_document_name,
874
 
                        'GEDIT_DROP_DOCUMENT_SCHEME': self.env_get_document_scheme,
875
 
                        'GEDIT_DROP_DOCUMENT_PATH': self.env_get_document_path,
876
 
                        'GEDIT_DROP_DOCUMENT_DIR': self.env_get_document_dir,
877
 
                        'GEDIT_DROP_DOCUMENT_TYPE': self.env_get_document_type}
878
 
                
879
 
                for var in variables:
880
 
                        os.environ[var] = variables[var](buf)
881
 
 
882
 
                os.environ['GEDIT_DROP_DOCUMENT_RELATIVE_PATH'] = self.relative_path(filename, uri, mime)
883
 
 
884
 
                buf = self.view.get_buffer()
 
868
                        pathname = gfile.get_path()
 
869
                        dirname = gfile.get_parent().get_path()
 
870
 
 
871
                name = os.path.basename(uri)
 
872
                scheme = gfile.get_uri_scheme()
 
873
 
 
874
                os.environ['GEDIT_DROP_DOCUMENT_URI'] = uri
 
875
                os.environ['GEDIT_DROP_DOCUMENT_NAME'] = name
 
876
                os.environ['GEDIT_DROP_DOCUMENT_SCHEME'] = scheme
 
877
                os.environ['GEDIT_DROP_DOCUMENT_PATH'] = pathname
 
878
                os.environ['GEDIT_DROP_DOCUMENT_DIR'] = dirname
 
879
                os.environ['GEDIT_DROP_DOCUMENT_TYPE'] = mime
 
880
                
 
881
                buf = self.view.get_buffer()
 
882
                relpath = self.relative_path(buf.get_uri() or "", uri, mime)
 
883
 
 
884
                os.environ['GEDIT_DROP_DOCUMENT_RELATIVE_PATH'] = relpath
 
885
 
885
886
                mark = buf.get_mark('gtk_drag_target')
886
887
                
887
888
                if not mark:
969
970
                start = placeholder.begin_iter()
970
971
                end = placeholder.end_iter()
971
972
 
 
973
                if not start or not end:
 
974
                        return False
 
975
 
972
976
                # Test if start is before bottom, and end is after top
973
977
                start_rect = self.iter_coords(start)
974
978
                end_rect = self.iter_coords(end)