示例#1
0
文件: viewpage.py 项目: worron/ACYLS
class ViewerPage:
	"""Icon view GUI"""
	def __init__(self, config):
		self.bhandlers = dict()
		self.mhandlers = dict()

		# Create object for iconview
		self.iconview = Prospector(config.get("Directories", "real"))

		# Read icon size settins from config
		self.VIEW_ICON_SIZE = int(config.get("PreviewSize", "group"))

		# Load GUI
		self.builder = Gtk.Builder()
		self.builder.add_from_file(os.path.join(acyls.dirs['gui'], "viewer.glade"))

		gui_elements = (
			'iconview_grid', 'iconview_combo', 'icons_view',
		)
		self.gui = {element: self.builder.get_object(element) for element in gui_elements}

		# Build store
		self.store = Gtk.ListStore(Pixbuf)
		self.gui['icons_view'].set_model(self.store)
		self.gui['icons_view'].set_pixbuf_column(0)
		self.iconview_lock = TreeViewHolder(self.gui['icons_view'])

		# Fill up GUI
		for name in self.iconview.structure[0]['directories']:
			self.gui['iconview_combo'].append_text(name.capitalize())

		# connect signals
		self.gui['iconview_combo'].connect("changed", self.on_iconview_combo_changed)

		# setup
		self.gui['iconview_combo'].set_active(0)

	# GUI handlers
	@multithread
	def on_iconview_combo_changed(self, combo):
		DIG_LEVEL = 1
		text = combo.get_active_text()
		if text:
			self.iconview.dig(text.lower(), DIG_LEVEL)

			icons = self.iconview.get_icons(DIG_LEVEL)
			pixbufs = [PixbufCreator.new_single_at_size(icon, self.VIEW_ICON_SIZE) for icon in icons]

			# GUI action catched in seperate function and moved to main thread
			def update_gui_with_new_icons():
				with self.iconview_lock:
					self.store.clear()
					for pix in pixbufs:
						self.store.append([pix])

			return update_gui_with_new_icons

	def on_page_switch(self):
		self.gui['iconview_combo'].emit("changed")
示例#2
0
class AlternativesPage:
    """Alternatives GUI"""
    def __init__(self, config):
        self.config = config
        self.bhandlers = dict()

        # Create objects for alternative and prewiew
        self.alternatives = Prospector(
            config.getdir("Directories", "alternatives"))

        # Read icon size settins from config
        self.VIEW_ICON_SIZE = config.getint("PreviewSize", "group")

        # Load GUI
        self.builder = Gtk.Builder()
        self.builder.add_from_file(
            os.path.join(acyls.dirs['gui'], "alternatives.glade"))

        gui_elements = (
            'alternatives_grid',
            'alt_theme_combo',
            'alt_group_combo',
            'alt_icon_view',
        )
        self.gui = {
            element: self.builder.get_object(element)
            for element in gui_elements
        }

        # Mainpage buttnons hanlers
        self.mhandlers = dict()
        self.mhandlers['apply_button'] = self.on_apply_click

        # Build store
        self.store = Gtk.ListStore(Pixbuf)
        self.gui['alt_icon_view'].set_model(self.store)
        self.gui['alt_icon_view'].set_pixbuf_column(0)
        self.iconview_lock = TreeViewHolder(self.gui['alt_icon_view'])

        # Fill up GUI
        for name in self.alternatives.structure[0]['directories']:
            self.gui['alt_group_combo'].append_text(name.capitalize())

        # connect signals
        self.gui['alt_group_combo'].connect("changed",
                                            self.on_alt_group_combo_changed)
        self.gui['alt_theme_combo'].connect("changed",
                                            self.on_alt_theme_combo_changed)

        # setup
        self.gui['alt_group_combo'].set_active(0)

    # GUI handlers
    def on_apply_click(self, *args):
        DIG_LEVEL = 2
        self.alternatives.send_icons(DIG_LEVEL,
                                     self.config.getdir("Directories", "real"))

    def on_alt_group_combo_changed(self, combo):
        DIG_LEVEL = 1
        self.alternatives.dig(combo.get_active_text().lower(), DIG_LEVEL)

        self.gui['alt_theme_combo'].remove_all()
        for name in self.alternatives.structure[DIG_LEVEL]['directories']:
            self.gui['alt_theme_combo'].append_text(name.capitalize())

        self.gui['alt_theme_combo'].set_active(0)

    def on_alt_theme_combo_changed(self, combo):
        DIG_LEVEL = 2
        text = combo.get_active_text()
        if text:
            self.alternatives.dig(text.lower(), DIG_LEVEL)
            with self.iconview_lock:
                self.store.clear()
                for icon in self.alternatives.get_icons(DIG_LEVEL):
                    pixbuf = PixbufCreator.new_single_at_size(
                        icon, self.VIEW_ICON_SIZE)
                    self.store.append([pixbuf])

    def on_page_switch(self):
        self.gui['alt_theme_combo'].emit("changed")
示例#3
0
class ViewerPage(GObject.GObject):
    """Icon view GUI"""
    __gsignals__ = {'icons_loaded': (GObject.SIGNAL_RUN_FIRST, None, ())}

    def __init__(self, config):
        super().__init__()
        self.bhandlers = dict()
        self.mhandlers = dict()
        self.pixbufs = []

        # Create object for iconview
        self.iconview = Prospector(config.getdir("Directories", "real"))

        # Read icon size settins from config
        self.VIEW_ICON_SIZE = config.getint("PreviewSize", "group")

        # Load GUI
        self.builder = Gtk.Builder()
        self.builder.add_from_file(
            os.path.join(acyls.dirs['gui'], "viewer.glade"))

        gui_elements = (
            'iconview_grid',
            'iconview_combo',
            'icons_view',
        )
        self.gui = {
            element: self.builder.get_object(element)
            for element in gui_elements
        }

        # Build store
        self.store = Gtk.ListStore(Pixbuf)
        self.gui['icons_view'].set_model(self.store)
        self.gui['icons_view'].set_pixbuf_column(0)
        self.iconview_lock = TreeViewHolder(self.gui['icons_view'])

        # Fill up GUI
        for name in self.iconview.structure[0]['directories']:
            self.gui['iconview_combo'].append_text(name.capitalize())

        # connect signals
        self.gui['iconview_combo'].connect("changed",
                                           self.on_iconview_combo_changed)
        self.connect("icons_loaded", self.on_icons_loaded)

        # setup
        self.gui['iconview_combo'].set_active(0)

    # GUI handlers
    def on_icons_loaded(self, *args):
        with self.iconview_lock:
            self.store.clear()
            for pix in self.pixbufs:
                self.store.append([pix])

    @multithread
    def on_iconview_combo_changed(self, combo):
        DIG_LEVEL = 1
        text = combo.get_active_text()
        if text:
            self.iconview.dig(text.lower(), DIG_LEVEL)

            icons = self.iconview.get_icons(DIG_LEVEL)
            self.pixbufs = [
                PixbufCreator.new_single_at_size(icon, self.VIEW_ICON_SIZE)
                for icon in icons
            ]

            return "icons_loaded"

    def on_page_switch(self):
        self.gui['iconview_combo'].emit("changed")
示例#4
0
文件: altpage.py 项目: worron/ACYLS
class AlternativesPage:
	"""Alternatives GUI"""
	def __init__(self, config):
		self.config = config
		self.bhandlers = dict()

		# Create objects for alternative and prewiew
		self.alternatives = Prospector(config.get("Directories", "alternatives"))

		# Read icon size settins from config
		self.VIEW_ICON_SIZE = int(config.get("PreviewSize", "group"))

		# Load GUI
		self.builder = Gtk.Builder()
		self.builder.add_from_file(os.path.join(acyls.dirs['gui'], "alternatives.glade"))

		gui_elements = (
			'alternatives_grid', 'alt_theme_combo', 'alt_group_combo', 'alt_icon_view',
		)
		self.gui = {element: self.builder.get_object(element) for element in gui_elements}

		# Mainpage buttnons hanlers
		self.mhandlers = dict()
		self.mhandlers['apply_button'] = self.on_apply_click

		# Build store
		self.store = Gtk.ListStore(Pixbuf)
		self.gui['alt_icon_view'].set_model(self.store)
		self.gui['alt_icon_view'].set_pixbuf_column(0)
		self.iconview_lock = TreeViewHolder(self.gui['alt_icon_view'])

		# Fill up GUI
		for name in self.alternatives.structure[0]['directories']:
			self.gui['alt_group_combo'].append_text(name.capitalize())

		# connect signals
		self.gui['alt_group_combo'].connect("changed", self.on_alt_group_combo_changed)
		self.gui['alt_theme_combo'].connect("changed", self.on_alt_theme_combo_changed)

		# setup
		self.gui['alt_group_combo'].set_active(0)

	# GUI handlers
	def on_apply_click(self, *args):
		DIG_LEVEL = 2
		self.alternatives.send_icons(DIG_LEVEL, self.config.get("Directories", "real"))

	def on_alt_group_combo_changed(self, combo):
		DIG_LEVEL = 1
		self.alternatives.dig(combo.get_active_text().lower(), DIG_LEVEL)

		self.gui['alt_theme_combo'].remove_all()
		for name in self.alternatives.structure[DIG_LEVEL]['directories']:
			self.gui['alt_theme_combo'].append_text(name.capitalize())

		self.gui['alt_theme_combo'].set_active(0)

	def on_alt_theme_combo_changed(self, combo):
		DIG_LEVEL = 2
		text = combo.get_active_text()
		if text:
			self.alternatives.dig(text.lower(), DIG_LEVEL)
			with self.iconview_lock:
				self.store.clear()
				for icon in self.alternatives.get_icons(DIG_LEVEL):
					pixbuf = PixbufCreator.new_single_at_size(icon, self.VIEW_ICON_SIZE)
					self.store.append([pixbuf])

	def on_page_switch(self):
		self.gui['alt_theme_combo'].emit("changed")