Esempio n. 1
0
    def activate(self, item):
        """
		Activate one item
		"""
        if item.get_type() == FILE_TYPE:
            open = preferences.get_bool("open", if_none=False)
            if open:
                self._open_file(item)
                return
        self.put_on_clipboard(item)
Esempio n. 2
0
	def ready_window(self):
		"""
		Shows the controlled window
		
		sets window properties
		"""
        # show it all
		self.window.show_all()
		self.adjust_window_size()		
		# Check the sticky preference
		stick = preferences.get_bool("stick", if_none=True)
		if stick:
			self.window.stick()		
		self.full_refresh()
Esempio n. 3
0
	def cb_dragitem_dragged(self, widget, item, success):
		"""
		Callback when drags end
		"""
		if not success:	
			return
		# Successful drag
		# check if we should remove anyways
		remove = preferences.get_bool("remove", False)
		if remove:
			self.item_control.remove_item(item)
			return
		
		# Check if the item (file) is still there after move
		# We have to wait for the filesystem to react
		# Make one quick and one slow to catch it all!
		from gobject import timeout_add

		check_valid = lambda wid, item: self.item_control.check_if_valid(item)
		# Wait 0.1s and 3.0s
		timeout_add(100, check_valid, widget, item)
		timeout_add(3000, check_valid, widget, item)
Esempio n. 4
0
	def __init__(self):
		"""
		Set up the preferences window
		
		Find the glade file as it was installed, or search for custom
		DESTDIR or check if not installed at all.
		"""
		glade_filename = "preferences.glade"
		glade_file = path.normpath(path.join(glade_directory, glade_filename))

		if not path.exists(glade_file):
			# Try to find if installed with DESTDIR
			from utils import guess_destdir
			while glade_file[0] == "/":
				glade_file = glade_file[1:]
			destdir = guess_destdir()
			if destdir:
				glade_file = path.join(destdir, glade_file)
				print_debug(glade_file)
		if not path.exists(glade_file):
			# try to find if not installed
			from sys import argv
			prog_location = path.abspath(argv[0])
			(head, tail) = path.split(prog_location)
			glade_file = path.join(head, "data", glade_filename)
			print_debug(glade_file)
			
		print_debug("Loading %s" % glade_file)
		try:
			self.ui = XML(glade_file)
		except:
			from utils import print_error
			print_error("Failed to load UI file for preferences window!")
			print_error("File: %s" % glade_file)
			self.win = None
			return
			
		self.win = self.ui.get_widget("prefswindow")
		self.check_stick = self.ui.get_widget("check_stick")
		self.check_open = self.ui.get_widget("check_open")
		self.check_remove = self.ui.get_widget("check_remove")
		
		# signals from .glade file
		signals = {
			"on_check_stick_toggled" : self.cb_stick_toggled,
			"on_check_open_toggled" : self.cb_open_toggled,
			"on_close_clicked" : self.cb_close_clicked,
			"on_check_remove_toggled" : self.cb_remove_toggled,
			"on_prefswindow_delete_event" : self.cb_delete_event,
		}
		# connect signals
		self.ui.signal_autoconnect(signals)
		
		# Set check boxes to prefs values
		stick = preferences.get_bool("stick", if_none=True)
		self.check_stick.set_active(stick)
		
		open = preferences.get_bool("open", if_none=False)
		self.check_open.set_active(open)
		
		remove = preferences.get_bool("remove", if_none=False)
		self.check_remove.set_active(remove)
		
		# set window icon
		from gtk import STOCK_DND_MULTIPLE, ICON_SIZE_DIALOG 
		pixbuf = self.win.render_icon(STOCK_DND_MULTIPLE, ICON_SIZE_DIALOG)
		self.win.set_icon(pixbuf)
		
		# hide window -- only show it if asked for
		self.win.hide()