Example #1
0
	def set_uri(self, uri):
		"""Data is safely saved somewhere. Update the document's URI and save_last_stat (for local saves).
		URI is not escaped. Internal."""
		path = get_local_path(escape(uri))
		if path is not None:
			self.document.save_last_stat = os.stat(path)	# Record for next time
		self.document.set_uri(path or uri)
Example #2
0
    def set_uri(self, uri):
        """Data is safely saved somewhere. Update the document's URI and save_last_stat (for local saves).
		URI is not escaped. Internal."""
        path = get_local_path(escape(uri))
        if path is not None:
            self.document.save_last_stat = os.stat(
                path)  # Record for next time
        self.document.set_uri(path or uri)
Example #3
0
    def xds_load_uris(self, uris):
        """Try to load each URI in the list. Override this if you can handle URIs
		directly. The default method passes each local path to xds_load_from_file()
		and displays an error for anything else.
		The uris are escaped, so a space will appear as '%20'"""
        paths = []
        for uri in uris:
            path = get_local_path(uri)
            if path:
                paths.append(path)
        if len(paths) < len(uris):
            raise RemoteFiles
        for path in paths:
            self.xds_load_from_file(path)
Example #4
0
	def xds_load_uris(self, uris):
		"""Try to load each URI in the list. Override this if you can handle URIs
		directly. The default method passes each local path to xds_load_from_file()
		and displays an error for anything else.
		The uris are escaped, so a space will appear as '%20'"""
		paths = []
		for uri in uris:
			path = get_local_path(uri)
			if path:
				paths.append(path)
		if len(paths) < len(uris):
			raise RemoteFiles
		for path in paths:
			self.xds_load_from_file(path)
Example #5
0
	def save_to_file_in_entry(self):
		"""Call this when the user clicks on an OK button you provide."""
		uri = self.entry.get_text()
		path = get_local_path(escape(uri))

		if path:
			if not self.confirm_new_path(path):
				return
			try:
				self.set_sensitive(False)
				try:
					self.document.save_to_file(path)
				finally:
					self.set_sensitive(True)
				self.set_uri(uri)
				self.save_done()
			except:
				_report_save_error()
		else:
			rox.info(_("Drag the icon to a directory viewer\n"
				   "(or enter a full pathname)"))
Example #6
0
    def save_to_file_in_entry(self):
        """Call this when the user clicks on an OK button you provide."""
        uri = self.entry.get_text()
        path = get_local_path(escape(uri))

        if path:
            if not self.confirm_new_path(path):
                return
            try:
                self.set_sensitive(False)
                try:
                    self.document.save_to_file(path)
                finally:
                    self.set_sensitive(True)
                self.set_uri(uri)
                self.save_done()
            except:
                _report_save_error()
        else:
            rox.info(
                _("Drag the icon to a directory viewer\n"
                  "(or enter a full pathname)"))
Example #7
0
    def drag_data_get(self, widget, context, selection_data, info, time):
        if info == TARGET_RAW:
            try:
                self.set_sensitive(False)
                try:
                    self.document.save_to_selection(selection_data)
                finally:
                    self.set_sensitive(True)
            except:
                _report_save_error()
                _write_xds_property(context, None)
                return

            self.data_sent = 1
            _write_xds_property(context, None)

            if self.drag_in_progress:
                self.destroy_on_drag_end = 1
            else:
                self.save_done()
            return
        elif info != TARGET_XDS:
            _write_xds_property(context, None)
            alert("Bad target requested!")
            return

        # Using XDS:
        #
        # Get the path that the destination app wants us to save to.
        # If it's local, save and return Success
        #			  (or Error if save fails)
        # If it's remote, return Failure (remote may try another method)
        # If no URI is given, return Error
        to_send = 'E'
        uri = _read_xds_property(context, False)
        if uri:
            path = get_local_path(escape(uri))
            if path:
                if not self.confirm_new_path(path):
                    to_send = 'E'
                else:
                    try:
                        self.set_sensitive(False)
                        try:
                            self.document.save_to_file(path)
                        finally:
                            self.set_sensitive(True)
                        self.data_sent = True
                    except:
                        _report_save_error()
                        self.data_sent = False
                    if self.data_sent:
                        to_send = 'S'
                # (else Error)
            else:
                to_send = 'F'  # Non-local transfer
        else:
            alert("Remote application wants to use " +
                  "Direct Save, but I can't read the " +
                  "XdndDirectSave0 (type text/plain) " + "property.")

        selection_data.set(selection_data.target, 8, to_send)

        if to_send != 'E':
            _write_xds_property(context, None)
            self.set_uri(uri)
        if self.data_sent:
            self.save_done()
Example #8
0
	def drag_data_get(self, widget, context, selection_data, info, time):
		if info == TARGET_RAW:
			try:
				self.set_sensitive(False)
				try:
					self.document.save_to_selection(selection_data)
				finally:
					self.set_sensitive(True)
			except:
				_report_save_error()
				_write_xds_property(context, None)
				return

			self.data_sent = 1
			_write_xds_property(context, None)
			
			if self.drag_in_progress:
				self.destroy_on_drag_end = 1
			else:
				self.save_done()
			return
		elif info != TARGET_XDS:
			_write_xds_property(context, None)
			alert("Bad target requested!")
			return

		# Using XDS:
		#
		# Get the path that the destination app wants us to save to.
		# If it's local, save and return Success
		#			  (or Error if save fails)
		# If it's remote, return Failure (remote may try another method)
		# If no URI is given, return Error
		to_send = 'E'
		uri = _read_xds_property(context, False)
		if uri:
			path = get_local_path(escape(uri))
			if path:
				if not self.confirm_new_path(path):
					to_send = 'E'
				else:
					try:
						self.set_sensitive(False)
						try:
							self.document.save_to_file(path)
						finally:
							self.set_sensitive(True)
						self.data_sent = True
					except:
						_report_save_error()
						self.data_sent = False
					if self.data_sent:
						to_send = 'S'
				# (else Error)
			else:
				to_send = 'F'	# Non-local transfer
		else:
			alert("Remote application wants to use " +
				  "Direct Save, but I can't read the " +
				  "XdndDirectSave0 (type text/plain) " +
				  "property.")

		selection_data.set(selection_data.target, 8, to_send)
	
		if to_send != 'E':
			_write_xds_property(context, None)
			self.set_uri(uri)
		if self.data_sent:
			self.save_done()