Beispiel #1
0
	def __select(self):
		try:
			if not self.__editor.uri: raise ValueError
			from gio import File 
			gfile = File(self.__editor.uri)
			folder_uri = gfile.get_parent().get_uri()
			if folder_uri != self.__chooser.get_current_folder_uri():
				self.__chooser.set_current_folder_uri(folder_uri)
			fileinfo = gfile.query_info("standard::display-name")
			self.__chooser.set_current_name(fileinfo.get_display_name())
		except ValueError:
			self.__chooser.set_current_name(_("Unsaved Document"))
			self.__chooser.set_current_folder(self.__editor.desktop_folder)
		return False
Beispiel #2
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
Beispiel #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)
Beispiel #4
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)
Beispiel #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
Beispiel #6
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