Example #1
0
def get_gicon_for_file(uri):
	"""
	Return a GIcon representing the file at
	the @uri, which can be *either* and uri or a path

	return None if not found
	"""

	gfile = File(uri)
	if not gfile.query_exists():
		return None

	finfo = gfile.query_info(FILE_ATTRIBUTE_STANDARD_ICON)
	gicon = finfo.get_attribute_object(FILE_ATTRIBUTE_STANDARD_ICON)
	return gicon
Example #2
0
def get_thumbnail_for_file(uri, width=-1, height=-1):
	"""
	Return a Pixbuf thumbnail for the file at
	the @uri, which can be *either* and uri or a path
	size is @width x @height

	return None if not found
	"""

	gfile = File(uri)
	if not gfile.query_exists():
		return None
	finfo = gfile.query_info(FILE_ATTRIBUTE_THUMBNAIL_PATH)
	thumb_path = finfo.get_attribute_byte_string(FILE_ATTRIBUTE_THUMBNAIL_PATH)

	return get_pixbuf_from_file(thumb_path, width, height)
Example #3
0
def get_thumbnail_for_file(uri, width=-1, height=-1):
    """
	Return a Pixbuf thumbnail for the file at
	the @uri, which can be *either* and uri or a path
	size is @width x @height

	return None if not found
	"""

    gfile = File(uri)
    if not gfile.query_exists():
        return None
    finfo = gfile.query_info(FILE_ATTRIBUTE_THUMBNAIL_PATH)
    thumb_path = finfo.get_attribute_byte_string(FILE_ATTRIBUTE_THUMBNAIL_PATH)

    return get_pixbuf_from_file(thumb_path, width, height)
Example #4
0
File: icons.py Project: pbx/kupfer
def get_gicon_for_file(uri):
    """
    Return a GIcon representing the file at
    the @uri, which can be *either* and uri or a path

    return None if not found
    """

    gfile = File(uri)
    if not gfile.query_exists():
        return None

    finfo = gfile.query_info(FILE_ATTRIBUTE_STANDARD_ICON)
    gicon = finfo.get_attribute_object(FILE_ATTRIBUTE_STANDARD_ICON)
    # very manually override generic folder icon name
    if isinstance(gicon, ThemedIcon):
        if gicon.get_names()[0] == "inode-directory":
            return ThemedIcon("folder")
    return gicon
Example #5
0
def get_gicon_for_file(uri):
    """
	Return a GIcon representing the file at
	the @uri, which can be *either* and uri or a path

	return None if not found
	"""

    gfile = File(uri)
    if not gfile.query_exists():
        return None

    finfo = gfile.query_info(FILE_ATTRIBUTE_STANDARD_ICON)
    gicon = finfo.get_attribute_object(FILE_ATTRIBUTE_STANDARD_ICON)
    # very manually override generic folder icon name
    if isinstance(gicon, ThemedIcon):
        if gicon.get_names()[0] == "inode-directory":
            return ThemedIcon("folder")
    return gicon
Example #6
0
    def __init__(self, g_file):
        self._folder = None
        self._loop = MainLoop()

        # Make the archive uri
        uri = g_file.get_uri()
        uri = 'archive://' + quote(uri, '')

        # Mount the archive if needed
        g_file = File(uri)
        # Already mounted ?
        if g_file.query_exists():
            self._folder = g_file
        else:
            mount_operation = MountOperation()
            mount_operation.set_anonymous(True)
            g_file.mount_enclosing_volume(mount_operation, self._mount_end)

            # Wait
            self._loop.run()
Example #7
0
    def __init__(self, g_file):
        self._folder = None
        self._loop = MainLoop()

        # Make the archive uri
        uri = g_file.get_uri()
        uri = 'archive://' + quote(uri, '')

        # Mount the archive if needed
        g_file = File(uri)
        # Already mounted ?
        if g_file.query_exists():
            self._folder = g_file
        else:
            mount_operation = MountOperation()
            mount_operation.set_anonymous(True)
            g_file.mount_enclosing_volume(mount_operation, self._mount_end)

            # Wait
            self._loop.run()