示例#1
0
	def get_items(self):
		try:
			dbfile = config.get_data_file("rhythmdb.xml", "rhythmbox")
			songs = rhythmbox_support.get_rhythmbox_songs(dbfile=dbfile)
		except StandardError, e:
			self.output_error(e)
			songs = []
示例#2
0
	def __init__(self, check_callback=None, previous_key=None, screen=None):
		'''@check_callback - optional function to check is entered key is valid.
		@previous_key - optional previous keybinding, press equal act like cancel'''
		builder = gtk.Builder()
		builder.set_translation_domain(version.PACKAGE_NAME)

		ui_file = config.get_data_file("getkey_dialog.ui")
		builder.add_from_file(ui_file)
		builder.connect_signals(self)
		self.window = builder.get_object("dialoggetkey")
		self.labelkey = builder.get_object('labelkey')
		self.imagekeybindingaux = builder.get_object('imagekeybindingaux')
		self.labelkeybindingaux = builder.get_object('labelkeybindingaux')
		self.labelaccelerator = builder.get_object('labelaccelerator')

		self.imagekeybindingaux.hide()
		self.labelkeybindingaux.hide()

		self._key = None
		self._check_callback = check_callback
		self._previous_key = previous_key
		self._press_time = None

		if screen:
			self.window.set_screen(screen)
		self.window.connect("focus-in-event", self.on_window_focus_in)
		self.window.connect("focus-out-event", self.on_window_focus_out)
示例#3
0
文件: uiutils.py 项目: guns/kupfer
def builder_get_objects_from_file(fname, attrs, autoconnect_to=None):
    """
    Open @fname with Gtk.Builder and yield objects named @attrs

    @fname is sought in the data directories.
    If @autoconnect_to is not None, signals are autoconnected to this object,
    and a user_data object is passed as a namespace containing all @attrs
    """
    builder = Gtk.Builder()
    builder.set_translation_domain(version.PACKAGE_NAME)

    ui_file = config.get_data_file(fname)
    builder.add_from_file(ui_file)

    class Namespace(object):
        pass

    names = Namespace()
    for attr in attrs:
        obj = builder.get_object(attr)
        setattr(names, attr, obj)
        yield obj
    if autoconnect_to:
        autoconnect_to.names = names
        builder.connect_signals(autoconnect_to)
示例#4
0
 def get_items(self):
     try:
         dbfile = config.get_data_file("rhythmdb.xml", "rhythmbox")
         songs = rhythmbox_support.get_rhythmbox_songs(dbfile=dbfile)
     except StandardError, e:
         self.output_error(e)
         songs = []
示例#5
0
	def _read_config(self, read_config=True):
		"""
		Read cascading config files
		default -> then config
		(in all XDG_CONFIG_DIRS)
		"""
		parser = ConfigParser.SafeConfigParser()

		def fill_parser(parser, defaults):
			for secname, section in defaults.iteritems():
				if not parser.has_section(secname):
					parser.add_section(secname)
				for key, default in section.iteritems():
					if isinstance(default, (tuple, list)):
						default = self.sep.join(default)
					elif isinstance(default, int):
						default = str(default)
					parser.set(secname, key, default)

		# Set up defaults
		confmap = copy.deepcopy(self.defaults)
		fill_parser(parser, confmap)

		# Read all config files
		config_files = []
		try:
			defaults_path = config.get_data_file(self.defaults_filename)
		except config.ResourceLookupError, exc:
			print "Error: no default config file %s found!" % self.defaults_filename
示例#6
0
文件: main.py 项目: chmouel/kupfer
	def make_help_text():
		from kupfer import config

		config_filename = "kupfer.cfg"
		defaults_filename = "defaults.cfg"
		conf_path = config.save_config_file(config_filename)
		defaults_path = config.get_data_file(defaults_filename)
		usage_string = _("Usage: kupfer [OPTIONS | QUERY]")
		def format_options(opts):
			return "\n".join("  --%-15s  %s" % (o,h) for o,h in opts)

		options_string = u"%s\n\n%s\n\n%s" % (usage_string,
				format_options(program_options), format_options(misc_options))

		configure_help1 = _("To configure kupfer, edit:")
		configure_help2 = _("The default config for reference is at:")
		help_text = "\n".join((
			options_string,
			"\n",
			configure_help1,
			"\t%s" % conf_path,
			configure_help2,
			"\t%s" % defaults_path,
			"\n",
		))
		return help_text
示例#7
0
	def __init__(self, check_callback=None, previous_key=None):
		'''@check_callback - optional function to check is entered key is valid.
		@previous_key - optional previous keybinding, press equal act like cancel'''
		builder = gtk.Builder()
		builder.set_translation_domain(version.PACKAGE_NAME)

		ui_file = config.get_data_file("getkey_dialog.ui")
		builder.add_from_file(ui_file)
		builder.connect_signals(self)
		self.window = builder.get_object("dialoggetkey")
		self.labelkey = builder.get_object('labelkey')
		self.imagekeybindingaux = builder.get_object('imagekeybindingaux')
		self.labelkeybindingaux = builder.get_object('labelkeybindingaux')
		self.labelaccelerator = builder.get_object('labelaccelerator')

		self.imagekeybindingaux.hide()
		self.labelkeybindingaux.hide()

		self._key = None
		self._check_callback = check_callback
		self._previous_key = previous_key
		self._press_time = None

		self.window.connect("focus-in-event", self.on_window_focus_in)
		self.window.connect("focus-out-event", self.on_window_focus_out)
示例#8
0
def load_kupfer_icons(scheduler):
    """Load in kupfer icons from installed files"""
    ilist = "art/icon-list"
    ilist_file_path = config.get_data_file(ilist)
    # parse icon list file
    ifile = open(ilist_file_path, "r")
    for line in ifile:
        # ignore '#'-comments
        if line.startswith("#"):
            continue
        icon_name, basename, size = (i.strip() for i in line.split("\t", 2))
        size = int(size)
        icon_path = config.get_data_file(os.path.join("art", basename))
        if not icon_path:
            pretty.print_info(__name__, "Icon", basename, icon_path, "not found")
            continue
        pixbuf = pixbuf_new_from_file_at_size(icon_path, size, size)
        gtk.icon_theme_add_builtin_icon(icon_name, size, pixbuf)
        pretty.print_debug(__name__, "Loading icon", icon_name, "at", size, "from", icon_path)
示例#9
0
文件: rhythmbox.py 项目: pbx/kupfer
 def get_items(self):
     # first try to load songs via dbus
     songs = list(_get_all_songs_via_dbus())
     if not songs:
         try:
             dbfile = config.get_data_file("rhythmdb.xml", "rhythmbox")
             songs = rhythmbox_support.get_rhythmbox_songs(dbfile=dbfile)
         except StandardError, e:
             self.output_error(e)
             songs = []
示例#10
0
 def get_items(self):
     # first try to load songs via dbus
     songs = list(_get_all_songs_via_dbus())
     if not songs:
         try:
             dbfile = config.get_data_file("rhythmdb.xml", "rhythmbox")
             songs = rhythmbox_support.get_rhythmbox_songs(dbfile=dbfile)
         except StandardError, e:
             self.output_error(e)
             songs = []
示例#11
0
    def __init__(self, title, header=None, max_value=100):
        """Create a new progress dialog

        @header: first line of dialog

        The methods show, hide and update are all wrapped to be
        safe to call from any thread.
        """
        self.aborted = False
        self.max_value = float(max_value)
        ui_file = config.get_data_file("progress_dialog.ui")
        self._construct_dialog(ui_file, title, header)
示例#12
0
    def __init__(self, title, header=None, max_value=100):
        """Create a new progress dialog

		@header: first line of dialog

		The methods show, hide and update are all wrapped to be
		safe to call from any thread.
		"""
        self.aborted = False
        self.max_value = float(max_value)
        ui_file = config.get_data_file("progress_dialog.ui")
        self._construct_dialog(ui_file, title, header)
示例#13
0
	def __init__(self, username, password):
		"""Load ui from data file"""
		builder = gtk.Builder()
		builder.set_translation_domain(version.PACKAGE_NAME)
		ui_file = config.get_data_file("credentials_dialog.ui")
		builder.add_from_file(ui_file)
		builder.connect_signals(self)

		self.window = builder.get_object("credentials_dialog")
		self.entry_user = builder.get_object('entry_username')
		self.entry_pass = builder.get_object('entry_password')

		self.entry_user.set_text(username or '')
		self.entry_pass.set_text(password or '')
示例#14
0
	def _read_config(self, read_config=True):
		"""
		Read cascading config files
		default -> then config
		(in all XDG_CONFIG_DIRS)
		"""
		parser = ConfigParser.SafeConfigParser()

		def fill_parser(parser, defaults):
			for secname, section in defaults.iteritems():
				if not parser.has_section(secname):
					parser.add_section(secname)
				for key, default in section.iteritems():
					if isinstance(default, (tuple, list)):
						default = self.sep.join(default)
					elif isinstance(default, int):
						default = str(default)
					parser.set(secname, key, default)

		# Set up defaults
		confmap = copy.deepcopy(self.defaults)
		fill_parser(parser, confmap)

		# Read all config files
		config_files = []
		try:
			defaults_path = config.get_data_file(self.defaults_filename)
		except config.ResourceLookupError:
			print "Error: no default config file %s found!" % self.defaults_filename
		else:
			self._defaults_path = defaults_path
			config_files += (defaults_path, )

		if read_config:
			config_path = config.get_config_file(self.config_filename)
			if config_path:
				config_files += (config_path, )

		for config_file in config_files:
			try:
				with open(config_file, "r") as fil:
					parser.readfp(fil)
			except IOError, e:
				print "Error reading configuration file %s: %s", (config_file, e)
示例#15
0
	def _read_config(self, read_config=True):
		"""
		Read cascading config files
		default -> then config
		(in all XDG_CONFIG_DIRS)
		"""
		parser = ConfigParser.SafeConfigParser()

		def fill_parser(parser, defaults):
			for secname, section in defaults.iteritems():
				if not parser.has_section(secname):
					parser.add_section(secname)
				for key, default in section.iteritems():
					if isinstance(default, (tuple, list)):
						default = self.sep.join(default)
					elif isinstance(default, int):
						default = str(default)
					parser.set(secname, key, default)

		# Set up defaults
		confmap = copy.deepcopy(self.defaults)
		fill_parser(parser, confmap)

		# Read all config files
		config_files = []
		try:
			defaults_path = config.get_data_file(self.defaults_filename)
		except config.ResourceLookupError:
			print "Error: no default config file %s found!" % self.defaults_filename
		else:
			self._defaults_path = defaults_path
			config_files += (defaults_path, )

		if read_config:
			config_path = config.get_config_file(self.config_filename)
			if config_path:
				config_files += (config_path, )

		for config_file in config_files:
			try:
				with open(config_file, "r") as fil:
					parser.readfp(fil)
			except IOError, e:
				print "Error reading configuration file %s: %s", (config_file, e)
示例#16
0
    def __init__(self, username, password, infotext=None):
        """Load ui from data file"""
        builder = Gtk.Builder()
        builder.set_translation_domain(version.PACKAGE_NAME)
        ui_file = config.get_data_file("credentials_dialog.ui")
        builder.add_from_file(ui_file)
        builder.connect_signals(self)

        self.window = builder.get_object("credentials_dialog")
        self.entry_user = builder.get_object('entry_username')
        self.entry_pass = builder.get_object('entry_password')
        if infotext:
            hbox_information = builder.get_object('hbox_information')
            label_information = builder.get_object('label_information')
            hbox_information.show()
            label_information.set_text(infotext)

        self.entry_user.set_text(username or '')
        self.entry_pass.set_text(password or '')
示例#17
0
    def __init__(self, check_callback=None, previous_key=None,
                 screen=None, parent=None,
                 show_clear=True):
        '''
        check_callback: optional function to check is entered key is valid.
        previous_key - optional previous keybinding, press equal act like cancel
        screen: Screen to use
        parent: Parent toplevel window
        show_clear: Show the “clear” button
        '''
        builder = Gtk.Builder()
        builder.set_translation_domain(version.PACKAGE_NAME)

        ui_file = config.get_data_file("getkey_dialog.ui")
        builder.add_from_file(ui_file)
        builder.connect_signals(self)
        self.window = builder.get_object("dialoggetkey")
        self.labelkey = builder.get_object('labelkey')
        self.imagekeybindingaux = builder.get_object('imagekeybindingaux')
        self.labelkeybindingaux = builder.get_object('labelkeybindingaux')
        self.labelaccelerator = builder.get_object('labelaccelerator')
        buttonclear = builder.get_object('buttonclear')
        if not show_clear:
            buttonclear.hide()

        self.imagekeybindingaux.hide()
        self.labelkeybindingaux.hide()

        self._key = None
        self._check_callback = check_callback
        self._previous_key = previous_key
        self._press_time = None

        if screen:
            self.window.set_screen(screen)
        if parent:
            self.window.set_transient_for(parent)
        self.window.connect("focus-in-event", self.on_window_focus_in)
        self.window.connect("focus-out-event", self.on_window_focus_out)
示例#18
0
def builder_get_objects_from_file(fname, attrs, autoconnect_to=None):
	"""
	Open @fname with gtk.Builder and yield objects named @attrs

	@fname is sought in the data directories.
	If @autoconnect_to is not None, signals are autoconnected to this object,
	and a user_data object is passed as a namespace containing all @attrs
	"""
	builder = gtk.Builder()
	builder.set_translation_domain(version.PACKAGE_NAME)

	ui_file = config.get_data_file(fname)
	builder.add_from_file(ui_file)
	class Namespace (object):
		pass
	names = Namespace()
	for attr in attrs:
		obj = builder.get_object(attr)
		setattr(names, attr, obj)
		yield obj
	if autoconnect_to:
		builder.connect_signals(autoconnect_to, user_data=names)
示例#19
0
	def __init__(self):
		"""Load ui from data file"""
		builder = gtk.Builder()
		builder.set_translation_domain(version.PACKAGE_NAME)
		ui_file = config.get_data_file("preferences.ui")

		if ui_file:
			builder.add_from_file(ui_file)
		else:
			self.window = None
			return
		builder.connect_signals(self)
		self.window = builder.get_object("preferenceswindow")
		self.window.set_position(gtk.WIN_POS_CENTER)
		self.window.connect("delete-event", self._close_window)
		self.pluglist_parent = builder.get_object("plugin_list_parent")
		self.dirlist_parent = builder.get_object("directory_list_parent")
		self.plugin_about_parent = builder.get_object("plugin_about_parent")
		self.preferences_notebook = builder.get_object("preferences_notebook")

		self.buttonremovedirectory = builder.get_object("buttonremovedirectory")
		checkautostart = builder.get_object("checkautostart")
		checkstatusicon = builder.get_object("checkstatusicon")
		checkcloseonunfocus = builder.get_object("checkcloseonunfocus")
		checkusecommandkeys = builder.get_object("checkusecommandkeys")
		self.entry_plugins_filter = builder.get_object('entry_plugins_filter')
		self.keybindings_list_parent = builder.get_object('keybindings_list_parent')
		self.gkeybindings_list_parent = builder.get_object('gkeybindings_list_parent')
		source_list_parent = builder.get_object("source_list_parent")
		self.sources_list_ctrl = SourceListController(source_list_parent)

		setctl = settings.GetSettingsController()
		checkautostart.set_active(self._get_should_autostart())
		checkstatusicon.set_active(setctl.get_show_status_icon())
		checkusecommandkeys.set_active(setctl.get_use_command_keys())
		checkcloseonunfocus.set_active(setctl.get_close_on_unfocus())

		# Plugin List
		columns = [
			{"key": "plugin_id", "type": str },
			{"key": "enabled", "type": bool },
			{"key": "icon-name", "type": str },
			{"key": "markup", "type": str },
		]
		# setup plugin list table
		column_types = [c["type"] for c in columns]
		self.columns = [c["key"] for c in columns]
		self.store = gtk.ListStore(*column_types)
		self.table = gtk.TreeView(self.store)
		self.table.set_headers_visible(False)
		self.table.set_property("enable-search", False)
		self.table.set_rules_hint(True)
		self.table.connect("cursor-changed", self.plugin_table_cursor_changed)
		self.table.get_selection().set_mode(gtk.SELECTION_BROWSE)

		checkcell = gtk.CellRendererToggle()
		checkcol = gtk.TreeViewColumn("item", checkcell)
		checkcol.add_attribute(checkcell, "active",
				self.columns.index("enabled"))
		checkcell.connect("toggled", self.on_checkplugin_toggled)

		icon_cell = gtk.CellRendererPixbuf()
		icon_cell.set_property("height", LIST_ICON_SIZE)
		icon_cell.set_property("width", LIST_ICON_SIZE)

		icon_col = gtk.TreeViewColumn("icon", icon_cell)
		icon_col.add_attribute(icon_cell, "icon-name",
				self.columns.index("icon-name"))

		cell = gtk.CellRendererText()
		col = gtk.TreeViewColumn("item", cell)
		col.add_attribute(cell, "markup", self.columns.index("markup"))

		self.table.append_column(checkcol)
		# hide icon for now
		#self.table.append_column(icon_col)
		self.table.append_column(col)

		self.plugin_list_timer = scheduler.Timer()
		self.plugin_info = utils.locale_sort(plugins.get_plugin_info(),
				key= lambda rec: rec["localized_name"])
		self._refresh_plugin_list()
		self.output_debug("Standard Plugins: %d" % len(self.store))
		self.table.show()
		self.pluglist_parent.add(self.table)

		# Directory List
		self.dir_store = gtk.ListStore(str, gio.Icon, str)
		self.dir_table = gtk.TreeView(self.dir_store)
		self.dir_table.set_headers_visible(False)
		self.dir_table.set_property("enable-search", False)
		self.dir_table.connect("cursor-changed", self.dir_table_cursor_changed)
		self.dir_table.get_selection().set_mode(gtk.SELECTION_BROWSE)

		icon_cell = gtk.CellRendererPixbuf()

		icon_col = gtk.TreeViewColumn("icon", icon_cell)
		icon_col.add_attribute(icon_cell, "gicon", 1)

		cell = gtk.CellRendererText()
		col = gtk.TreeViewColumn("name", cell)
		col.add_attribute(cell, "text", 2)
		cell.set_property("ellipsize", pango.ELLIPSIZE_END)
		self.dir_table.append_column(icon_col)
		self.dir_table.append_column(col)
		self.dir_table.show()
		self.dirlist_parent.add(self.dir_table)
		self.read_directory_settings()

		# keybindings list
		self.keybind_table, self.keybind_store = _create_conf_keys_list()
		self.keybindings_list_parent.add(self.keybind_table)
		self.keybind_table.connect("row-activated", self.on_keybindings_row_activate)
		# global keybindings list
		self.gkeybind_table, self.gkeybind_store = _create_conf_keys_list()
		self.gkeybindings_list_parent.add(self.gkeybind_table)
		self.gkeybind_table.connect("row-activated",
				self.on_gkeybindings_row_activate)

		self._show_keybindings(setctl)
		self._show_gkeybindings(setctl)
示例#20
0
    def _read_config(self, read_config=True):
        """
        Read cascading config files
        default -> then config
        (in all XDG_CONFIG_DIRS)
        """
        parser = configparser.RawConfigParser()

        def fill_parser(parser, defaults):
            for secname, section in defaults.items():
                if not parser.has_section(secname):
                    parser.add_section(secname)
                for key, default in section.items():
                    if isinstance(default, (tuple, list)):
                        default = self.sep.join(default)
                    elif isinstance(default, int):
                        default = str(default)
                    parser.set(secname, key, default)

        # Set up defaults
        confmap = copy.deepcopy(self.defaults)
        fill_parser(parser, confmap)

        # Read all config files
        config_files = []
        try:
            defaults_path = config.get_data_file(self.defaults_filename)
        except config.ResourceLookupError:
            self.output_error(("Error: no default config file %s found!" %
                               self.defaults_filename))
        else:
            self._defaults_path = defaults_path
            config_files += (defaults_path, )

        if read_config:
            config_path = config.get_config_file(self.config_filename)
            if config_path:
                config_files += (config_path, )

        for config_file in config_files:
            try:
                parser.read(config_file, encoding=self.encoding)
            except IOError as e:
                self.output_error(("Error reading configuration file %s: %s" %
                                   (config_file, e)))
            except UnicodeDecodeError as e:
                self.output_error(("Error reading configuration file %s: %s" %
                                   (config_file, e)))

        # Read parsed file into the dictionary again
        for secname in parser.sections():
            if secname not in confmap: confmap[secname] = {}
            for key in parser.options(secname):
                value = parser.get(secname, key)
                retval = value
                if secname in self.defaults and key in self.defaults[secname]:
                    defval = self.defaults[secname][key]
                    if isinstance(defval, (tuple, list)):
                        if not value:
                            retval = ()
                        else:
                            retval = [
                                p.strip() for p in value.split(self.sep) if p
                            ]
                    elif isinstance(defval, bool):
                        retval = strbool(value)
                    elif isinstance(defval, int):
                        retval = type(defval)(value)
                    else:
                        retval = str(value)
                confmap[secname][key] = retval

        return confmap
示例#21
0
	def __init__(self):
		"""Load ui from data file"""
		builder = gtk.Builder()
		builder.set_translation_domain(version.PACKAGE_NAME)
		ui_file = config.get_data_file("preferences.ui")

		if ui_file:
			builder.add_from_file(ui_file)
		else:
			self.window = None
			return
		builder.connect_signals(self)
		self.window = builder.get_object("preferenceswindow")
		self.window.set_position(gtk.WIN_POS_CENTER)
		self.window.connect("delete-event", self._close_window)
		self.pluglist_parent = builder.get_object("plugin_list_parent")
		self.dirlist_parent = builder.get_object("directory_list_parent")
		self.plugin_about_parent = builder.get_object("plugin_about_parent")
		self.preferences_notebook = builder.get_object("preferences_notebook")

		self.entrykeybinding = builder.get_object("entrykeybinding")
		self.buttonkeybinding = builder.get_object("buttonkeybinding")
		self.imagekeybindingaux = builder.get_object("imagekeybindingaux")
		self.labelkeybindingaux = builder.get_object("labelkeybindingaux")
		self.buttonremovedirectory = builder.get_object("buttonremovedirectory")
		checkautostart = builder.get_object("checkautostart")
		checkstatusicon = builder.get_object("checkstatusicon")

		setctl = settings.GetSettingsController()
		self.entrykeybinding.set_text(setctl.get_keybinding())
		checkautostart.set_active(self._get_should_autostart())
		checkstatusicon.set_active(setctl.get_show_status_icon())

		# Plugin List
		columns = [
			{"key": "plugin_id", "type": str },
			{"key": "enabled", "type": bool },
			{"key": "icon-name", "type": str },
			{"key": "markup", "type": str },
		]
		# setup plugin list table
		column_types = [c["type"] for c in columns]
		self.columns = [c["key"] for c in columns]
		self.store = gtk.ListStore(*column_types)
		self.table = gtk.TreeView(self.store)
		self.table.set_headers_visible(False)
		self.table.set_property("enable-search", False)
		self.table.set_rules_hint(True)
		self.table.connect("cursor-changed", self.plugin_table_cursor_changed)
		self.table.get_selection().set_mode(gtk.SELECTION_BROWSE)

		checkcell = gtk.CellRendererToggle()
		checkcol = gtk.TreeViewColumn("item", checkcell)
		checkcol.add_attribute(checkcell, "active",
				self.columns.index("enabled"))
		checkcell.connect("toggled", self.on_checkplugin_toggled)

		icon_cell = gtk.CellRendererPixbuf()
		icon_cell.set_property("height", 18)
		icon_cell.set_property("width", 18)

		icon_col = gtk.TreeViewColumn("icon", icon_cell)
		icon_col.add_attribute(icon_cell, "icon-name",
				self.columns.index("icon-name"))

		cell = gtk.CellRendererText()
		col = gtk.TreeViewColumn("item", cell)
		col.add_attribute(cell, "markup", self.columns.index("markup"))

		self.table.append_column(checkcol)
		# hide icon for now
		#self.table.append_column(icon_col)
		self.table.append_column(col)

		self.plugin_info = utils.locale_sort(plugins.get_plugin_info(),
				key= lambda rec: rec["localized_name"])
		for info in self.plugin_info:
			plugin_id = info["name"]
			if setctl.get_plugin_is_hidden(plugin_id):
				continue
			enabled = setctl.get_plugin_enabled(plugin_id)
			name = info["localized_name"]
			desc = info["description"]
			text = u"%s" % name
			self.store.append((plugin_id, enabled, "kupfer-object", text))
		self.output_debug("Standard Plugins: %d" % len(self.store))
		self.table.show()
		self.pluglist_parent.add(self.table)

		# Directory List
		self.dir_store = gtk.ListStore(str, gio.Icon, str)
		self.dir_table = gtk.TreeView(self.dir_store)
		self.dir_table.set_headers_visible(False)
		self.dir_table.set_property("enable-search", False)
		self.dir_table.connect("cursor-changed", self.dir_table_cursor_changed)
		self.dir_table.get_selection().set_mode(gtk.SELECTION_BROWSE)

		icon_cell = gtk.CellRendererPixbuf()
			
		icon_col = gtk.TreeViewColumn("icon", icon_cell)
		icon_col.add_attribute(icon_cell, "gicon", 1)

		cell = gtk.CellRendererText()
		col = gtk.TreeViewColumn("name", cell)
		col.add_attribute(cell, "text", 2)
		cell.set_property("ellipsize", pango.ELLIPSIZE_END)
		self.dir_table.append_column(icon_col)
		self.dir_table.append_column(col)
		self.dir_table.show()
		self.dirlist_parent.add(self.dir_table)
		self.read_directory_settings()
示例#22
0
    def __init__(self):
        """Load ui from data file"""
        builder = Gtk.Builder()
        builder.set_translation_domain(version.PACKAGE_NAME)
        ui_file = config.get_data_file("preferences.ui")

        if ui_file:
            builder.add_from_file(ui_file)
        else:
            self.window = None
            return
        self.window = builder.get_object("preferenceswindow")
        self.window.set_position(Gtk.WindowPosition.CENTER)
        self.window.connect("delete-event", self._close_window)
        self.pluglist_parent = builder.get_object("plugin_list_parent")
        self.dirlist_parent = builder.get_object("directory_list_parent")
        self.plugin_about_parent = builder.get_object("plugin_about_parent")
        self.preferences_notebook = builder.get_object("preferences_notebook")

        self.buttonremovedirectory = builder.get_object(
            "buttonremovedirectory")
        checkautostart = builder.get_object("checkautostart")
        checkstatusicon_gtk = builder.get_object("checkstatusicon_gtk")
        checkstatusicon_ai = builder.get_object("checkstatusicon_ai")
        combo_icons_large_size = builder.get_object("icons_large_size")
        combo_icons_small_size = builder.get_object("icons_small_size")
        checkusecommandkeys = builder.get_object("checkusecommandkeys")
        radio_actionaccelalt = builder.get_object("radio_actionaccelalt")
        radio_actionaccelctrl = builder.get_object("radio_actionaccelctrl")
        self.entry_plugins_filter = builder.get_object('entry_plugins_filter')
        self.keybindings_list_parent = builder.get_object(
            'keybindings_list_parent')
        self.gkeybindings_list_parent = builder.get_object(
            'gkeybindings_list_parent')
        source_list_parent = builder.get_object("source_list_parent")
        button_reset_keys = builder.get_object("button_reset_keys")
        self.sources_list_ctrl = SourceListController(source_list_parent)

        setctl = settings.GetSettingsController()
        checkautostart.set_active(self._get_should_autostart())
        checkstatusicon_gtk.set_active(setctl.get_show_status_icon())

        large_icon_size = setctl.get_config_int("Appearance",
                                                "icon_large_size")
        small_icon_size = setctl.get_config_int("Appearance",
                                                "icon_small_size")

        set_combobox(large_icon_size, combo_icons_large_size)
        set_combobox(small_icon_size, combo_icons_small_size)

        if supports_app_indicator():
            checkstatusicon_ai.set_active(setctl.get_show_status_icon_ai())
        else:
            checkstatusicon_ai.set_sensitive(False)

        label = checkstatusicon_gtk.get_label()
        checkstatusicon_gtk.set_label(label + " (GtkStatusIcon)")
        label = checkstatusicon_ai.get_label()
        checkstatusicon_ai.set_label(label + " (AppIndicator)")

        checkusecommandkeys.set_active(setctl.get_use_command_keys())
        radio_actionaccelalt.set_active(
            setctl.get_action_accelerator_modifer() != 'ctrl')
        radio_actionaccelctrl.set_active(
            setctl.get_action_accelerator_modifer() == 'ctrl')

        # List store with columns (Name, ID)
        # Make alternative comboboxes
        terminal_combobox = builder.get_object("terminal_combobox")
        icons_combobox = builder.get_object("icons_combobox")

        def make_combobox_model(combobox):
            combobox_store = Gtk.ListStore(GObject.TYPE_STRING,
                                           GObject.TYPE_STRING)
            combobox.set_model(combobox_store)
            combobox_cell = Gtk.CellRendererText()
            combobox.pack_start(combobox_cell, True)
            combobox.add_attribute(combobox_cell, 'text', 0)

        make_combobox_model(terminal_combobox)
        make_combobox_model(icons_combobox)

        self._update_alternative_combobox('terminal', terminal_combobox)
        self._update_alternative_combobox('icon_renderer', icons_combobox)
        self.terminal_combobox = terminal_combobox
        self.icons_combobox = icons_combobox
        setctl.connect("alternatives-changed", self._on_alternatives_changed)

        # Plugin List
        columns = [
            {
                "key": "plugin_id",
                "type": str
            },
            {
                "key": "enabled",
                "type": bool
            },
            {
                "key": "icon-name",
                "type": str
            },
            {
                "key": "text",
                "type": str
            },
        ]
        # setup plugin list table
        column_types = [c["type"] for c in columns]
        self.columns = [c["key"] for c in columns]
        self.store = Gtk.ListStore.new(column_types)
        self.table = Gtk.TreeView.new_with_model(self.store)
        self.table.set_headers_visible(False)
        self.table.set_property("enable-search", False)
        self.table.connect("cursor-changed", self.plugin_table_cursor_changed)
        self.table.get_selection().set_mode(Gtk.SelectionMode.BROWSE)

        checkcell = Gtk.CellRendererToggle()
        checkcol = Gtk.TreeViewColumn("item", checkcell)
        checkcol.add_attribute(checkcell, "active",
                               self.columns.index("enabled"))
        checkcell.connect("toggled", self.on_checkplugin_toggled)

        icon_cell = Gtk.CellRendererPixbuf()
        icon_cell.set_property("height", LIST_ICON_SIZE)
        icon_cell.set_property("width", LIST_ICON_SIZE)

        icon_col = Gtk.TreeViewColumn("icon", icon_cell)
        icon_col.add_attribute(icon_cell, "icon-name",
                               self.columns.index("icon-name"))

        cell = Gtk.CellRendererText()
        col = Gtk.TreeViewColumn("item", cell)
        col.add_attribute(cell, "text", self.columns.index("text"))

        self.table.append_column(checkcol)
        # hide icon for now
        #self.table.append_column(icon_col)
        self.table.append_column(col)

        self.plugin_list_timer = scheduler.Timer()
        self.plugin_info = utils.locale_sort(
            plugins.get_plugin_info(), key=lambda rec: rec["localized_name"])
        self._refresh_plugin_list()
        self.output_debug("Standard Plugins: %d" % len(self.store))
        self.table.show()
        self.pluglist_parent.add(self.table)

        # Directory List
        self.dir_store = Gtk.ListStore.new([str, Gio.Icon, str])
        self.dir_table = Gtk.TreeView.new_with_model(self.dir_store)
        self.dir_table.set_headers_visible(False)
        self.dir_table.set_property("enable-search", False)
        self.dir_table.connect("cursor-changed", self.dir_table_cursor_changed)
        self.dir_table.get_selection().set_mode(Gtk.SelectionMode.BROWSE)

        icon_cell = Gtk.CellRendererPixbuf()

        icon_col = Gtk.TreeViewColumn("icon", icon_cell)
        icon_col.add_attribute(icon_cell, "gicon", 1)

        cell = Gtk.CellRendererText()
        col = Gtk.TreeViewColumn("name", cell)
        col.add_attribute(cell, "text", 2)
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
        self.dir_table.append_column(icon_col)
        self.dir_table.append_column(col)
        self.dir_table.show()
        self.dirlist_parent.add(self.dir_table)
        self.read_directory_settings()

        # global keybindings list
        self.keybind_table, self.keybind_store = _create_conf_keys_list()
        self.keybindings_list_parent.add(self.keybind_table)
        self.keybind_table.connect("row-activated",
                                   self.on_keybindings_row_activate)
        button_reset_keys.set_sensitive(keybindings.is_available())
        self.keybind_table.set_sensitive(keybindings.is_available())

        # kupfer interface (accelerators) keybindings list
        self.gkeybind_table, self.gkeybind_store = _create_conf_keys_list()
        self.gkeybindings_list_parent.add(self.gkeybind_table)
        self.gkeybind_table.connect("row-activated",
                                    self.on_gkeybindings_row_activate)

        # Requires GTK 3.22
        try:
            self.gkeybindings_list_parent.set_propagate_natural_height(True)
        except AttributeError:
            pass

        self._show_keybindings(setctl)
        self._show_gkeybindings(setctl)

        # Connect to signals at the last point
        builder.connect_signals(self)
示例#23
0
    def __init__(self):
        """Load ui from data file"""
        builder = gtk.Builder()
        builder.set_translation_domain(version.PACKAGE_NAME)
        ui_file = config.get_data_file("preferences.ui")

        if ui_file:
            builder.add_from_file(ui_file)
        else:
            self.window = None
            return
        builder.connect_signals(self)
        self.window = builder.get_object("preferenceswindow")
        self.window.set_position(gtk.WIN_POS_CENTER)
        self.window.connect("delete-event", self._close_window)
        self.pluglist_parent = builder.get_object("plugin_list_parent")
        self.dirlist_parent = builder.get_object("directory_list_parent")
        self.plugin_about_parent = builder.get_object("plugin_about_parent")
        self.preferences_notebook = builder.get_object("preferences_notebook")

        self.buttonremovedirectory = builder.get_object(
            "buttonremovedirectory")
        checkautostart = builder.get_object("checkautostart")
        checkstatusicon = builder.get_object("checkstatusicon")
        checkusecommandkeys = builder.get_object("checkusecommandkeys")
        self.entry_plugins_filter = builder.get_object('entry_plugins_filter')
        self.keybindings_list_parent = builder.get_object(
            'keybindings_list_parent')
        self.gkeybindings_list_parent = builder.get_object(
            'gkeybindings_list_parent')
        source_list_parent = builder.get_object("source_list_parent")
        self.sources_list_ctrl = SourceListController(source_list_parent)

        setctl = settings.GetSettingsController()
        checkautostart.set_active(self._get_should_autostart())
        checkstatusicon.set_active(setctl.get_show_status_icon())
        checkusecommandkeys.set_active(setctl.get_use_command_keys())

        # List store with columns (Name, ID)
        # Make alternative comboboxes
        terminal_combobox = builder.get_object("terminal_combobox")
        icons_combobox = builder.get_object("icons_combobox")

        def make_combobox_model(combobox):
            combobox_store = gtk.ListStore(gobject.TYPE_STRING,
                                           gobject.TYPE_STRING)
            combobox.set_model(combobox_store)
            combobox_cell = gtk.CellRendererText()
            combobox.pack_start(combobox_cell, True)
            combobox.add_attribute(combobox_cell, 'text', 0)

        make_combobox_model(terminal_combobox)
        make_combobox_model(icons_combobox)

        self._update_alternative_combobox('terminal', terminal_combobox)
        self._update_alternative_combobox('icon_renderer', icons_combobox)
        self.terminal_combobox = terminal_combobox
        self.icons_combobox = icons_combobox
        setctl.connect("alternatives-changed", self._on_alternatives_changed)

        # Plugin List
        columns = [
            {
                "key": "plugin_id",
                "type": str
            },
            {
                "key": "enabled",
                "type": bool
            },
            {
                "key": "icon-name",
                "type": str
            },
            {
                "key": "text",
                "type": str
            },
        ]
        # setup plugin list table
        column_types = [c["type"] for c in columns]
        self.columns = [c["key"] for c in columns]
        self.store = gtk.ListStore(*column_types)
        self.table = gtk.TreeView(self.store)
        self.table.set_headers_visible(False)
        self.table.set_property("enable-search", False)
        self.table.set_rules_hint(True)
        self.table.connect("cursor-changed", self.plugin_table_cursor_changed)
        self.table.get_selection().set_mode(gtk.SELECTION_BROWSE)

        checkcell = gtk.CellRendererToggle()
        checkcol = gtk.TreeViewColumn("item", checkcell)
        checkcol.add_attribute(checkcell, "active",
                               self.columns.index("enabled"))
        checkcell.connect("toggled", self.on_checkplugin_toggled)

        icon_cell = gtk.CellRendererPixbuf()
        icon_cell.set_property("height", LIST_ICON_SIZE)
        icon_cell.set_property("width", LIST_ICON_SIZE)

        icon_col = gtk.TreeViewColumn("icon", icon_cell)
        icon_col.add_attribute(icon_cell, "icon-name",
                               self.columns.index("icon-name"))

        cell = gtk.CellRendererText()
        col = gtk.TreeViewColumn("item", cell)
        col.add_attribute(cell, "text", self.columns.index("text"))

        self.table.append_column(checkcol)
        # hide icon for now
        #self.table.append_column(icon_col)
        self.table.append_column(col)

        self.plugin_list_timer = scheduler.Timer()
        self.plugin_info = utils.locale_sort(
            plugins.get_plugin_info(), key=lambda rec: rec["localized_name"])
        self._refresh_plugin_list()
        self.output_debug("Standard Plugins: %d" % len(self.store))
        self.table.show()
        self.pluglist_parent.add(self.table)

        # Directory List
        self.dir_store = gtk.ListStore(str, gio.Icon, str)
        self.dir_table = gtk.TreeView(self.dir_store)
        self.dir_table.set_headers_visible(False)
        self.dir_table.set_property("enable-search", False)
        self.dir_table.connect("cursor-changed", self.dir_table_cursor_changed)
        self.dir_table.get_selection().set_mode(gtk.SELECTION_BROWSE)

        icon_cell = gtk.CellRendererPixbuf()

        icon_col = gtk.TreeViewColumn("icon", icon_cell)
        icon_col.add_attribute(icon_cell, "gicon", 1)

        cell = gtk.CellRendererText()
        col = gtk.TreeViewColumn("name", cell)
        col.add_attribute(cell, "text", 2)
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
        self.dir_table.append_column(icon_col)
        self.dir_table.append_column(col)
        self.dir_table.show()
        self.dirlist_parent.add(self.dir_table)
        self.read_directory_settings()

        # keybindings list
        self.keybind_table, self.keybind_store = _create_conf_keys_list()
        self.keybindings_list_parent.add(self.keybind_table)
        self.keybind_table.connect("row-activated",
                                   self.on_keybindings_row_activate)
        # global keybindings list
        self.gkeybind_table, self.gkeybind_store = _create_conf_keys_list()
        self.gkeybindings_list_parent.add(self.gkeybind_table)
        self.gkeybind_table.connect("row-activated",
                                    self.on_gkeybindings_row_activate)

        self._show_keybindings(setctl)
        self._show_gkeybindings(setctl)