Example #1
0
	def set_filename(self, filename):
		"Sets the filename"

		filename = io.file_normpath(filename)

		if filename != io.file_normpath(self.get_filename()):
			gtk.FileChooserButton.set_filename(self, filename)
Example #2
0
	def get_filename(self):
		"Returns the file URI"

		uri = self.get_uri()

		if uri == None:
			return None

		else:
			return io.file_normpath(urllib.unquote(uri))
Example #3
0
def config_bind(cfg, key, widget, data = None):
	"Binds a config key to a UI widget"

	if isinstance(widget, gtk.RadioButton):
		signal	= "toggled"

		def cb_get(config, value, widget):
			if value == data:
				widget.set_active(True)

		def cb_set(widget, key):
			if widget.get_active() == True:
				cfg.set(key, data)


	elif isinstance(widget, gtk.CheckMenuItem) or isinstance(widget, gtk.ToggleButton):
		signal	= "toggled"
		cb_get	= lambda c,v,w:	w.set_active(v)
		cb_set	= lambda w,k:	cfg.set(k, w.get_active())

	elif isinstance(widget, gtk.SpinButton):
		signal	= "changed"
		cb_get	= lambda c,v,w:	w.set_value(v)
		cb_set	= lambda w,k:	cfg.set(k, w.get_value())

	elif isinstance(widget, gtk.Entry) or isinstance(widget, FileEntry):
		signal	= "changed"
		cb_get	= lambda c,v,w:	w.set_text(v)
		cb_set	= lambda w,k:	cfg.set(k, w.get_text())

	elif isinstance(widget, gtk.FileChooserButton):
		signal	= "selection-changed"
		cb_get	= lambda c,v,w: w.set_filename(io.file_normpath(v))
		cb_set	= lambda w,k:	cfg.set(k, io.file_normpath(w.get_filename()))

	else:
		raise config.ConfigError

	id = cfg.monitor(key, cb_get, widget)
	widget.connect(signal, cb_set, key)
	widget.connect("destroy", lambda w,i: cfg.forget(i), id)

	return id
Example #4
0
    def get_filename(self):
        "Returns the file URI"

        uri = self.get_uri()

        if uri == None:
            return None

        else:
            return io.file_normpath(urllib.unquote(uri))
Example #5
0
	def __cb_confirm_overwrite(self, widget, data = None):
		"Handles confirm-overwrite signals"

		try:
			FileReplace(self, io.file_normpath(self.get_uri())).run()

		except CancelError:
			return gtk.FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN

		else:
			return gtk.FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME
Example #6
0
    def __cb_confirm_overwrite(self, widget, data=None):
        "Handles confirm-overwrite signals"

        try:
            FileReplace(self, io.file_normpath(self.get_uri())).run()

        except CancelError:
            return gtk.FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN

        else:
            return gtk.FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME
Example #7
0
	def set_filename(self, filename):
		"Sets the current filename"

		self.entry.set_text(io.file_normpath(filename))
		self.entry.set_position(-1)
Example #8
0
	def get_filename(self):
		"Gets the current filename"

		return io.file_normpath(self.entry.get_text())
Example #9
0
	def get_filename(self):
		"Gets the filename"

		return io.file_normpath(self.get_uri())