# Path: sunflower/common.py
# class UserDirectory:
# 	DESKTOP = 'XDG_DESKTOP_DIR'
# 	DOWNLOADS = 'XDG_DOWNLOAD_DIR'
# 	TEMPLATES = 'XDG_TEMPLATES_DIR'
# 	PUBLIC = 'XDG_PUBLICSHARE_DIR'
# 	DOCUMENTS = 'XDG_DOCUMENTS_DIR'
# 	MUSIC = 'XDG_MUSIC_DIR'
# 	PICTURES = 'XDG_PICTURES_DIR'
# 	VIDEOS = 'XDG_VIDEOS_DIR'
# 
# def get_user_directory(directory):
# 	"""Get full path to current users predefined directory"""
# 	result = None
# 	config_file = os.path.join(get_config_directory(), 'user-dirs.dirs')
# 
# 	if os.path.isfile(config_file):
# 		# read configuration file
# 		with open(config_file, 'r') as raw_file:
# 			lines = raw_file.read().splitlines(False)
# 
# 		# get desired path
# 		for line in lines:
# 			data = line.split('=')
# 
# 			if data[0] == directory:
# 				result = data[1].replace('$HOME', os.path.expanduser('~'))
# 				result = result.strip('"')
# 				break
# 
# 	return result
# 
# def get_static_assets_directory():
# 	"""Return path to directory that holds static files"""
# 	script_dir = os.path.join(os.path.dirname(__file__), '..')
# 	prefix_dir = os.path.join(sys.prefix, 'share', 'sunflower')
# 	result = prefix_dir
# 
# 	if os.path.exists(os.path.join(script_dir, 'images', 'sunflower.svg')):
# 		result = script_dir
# 
# 	return result


from builtins import filter
from gi.repository import Gtk, Gio, GdkPixbuf, GLib
from sunflower.common import UserDirectory, get_user_directory, get_static_assets_directory
import os
import sys
import zipfile

class IconManager:
	"""Icon manager class provides easy and abstract way of dealing with icons"""

	def __init__(self, parent):
		self._parent = parent
		self._icon_theme = Gtk.IconTheme.get_default()
		self._user_directories = None
		self._default_file = None
		self._default_directory = None

		# preload information
		self._prepare_icons()

	def _prepare_icons(self):
		"""Load special user directories"""
		# set default icons for file and directory
		self._default_file = 'text-x-generic'
		self._default_directory = 'folder'

		# special user directories
		directories = []
		icon_names = {
				UserDirectory.DESKTOP: 'user-desktop',
				UserDirectory.DOWNLOADS: 'folder-download',
				UserDirectory.TEMPLATES: 'folder-templates',
				UserDirectory.PUBLIC: 'folder-publicshare',
				UserDirectory.DOCUMENTS: 'folder-documents',
				UserDirectory.MUSIC: 'folder-music',
				UserDirectory.PICTURES: 'folder-pictures',

# Path: sunflower/common.py
# class UserDirectory:
# 	DESKTOP = 'XDG_DESKTOP_DIR'
# 	DOWNLOADS = 'XDG_DOWNLOAD_DIR'
# 	TEMPLATES = 'XDG_TEMPLATES_DIR'
# 	PUBLIC = 'XDG_PUBLICSHARE_DIR'
# 	DOCUMENTS = 'XDG_DOCUMENTS_DIR'
# 	MUSIC = 'XDG_MUSIC_DIR'
# 	PICTURES = 'XDG_PICTURES_DIR'
# 	VIDEOS = 'XDG_VIDEOS_DIR'
# 
# def get_user_directory(directory):
# 	"""Get full path to current users predefined directory"""
# 	result = None
# 	config_file = os.path.join(get_config_directory(), 'user-dirs.dirs')
# 
# 	if os.path.isfile(config_file):
# 		# read configuration file
# 		with open(config_file, 'r') as raw_file:
# 			lines = raw_file.read().splitlines(False)
# 
# 		# get desired path
# 		for line in lines:
# 			data = line.split('=')
# 
# 			if data[0] == directory:
# 				result = data[1].replace('$HOME', os.path.expanduser('~'))
# 				result = result.strip('"')
# 				break
# 
# 	return result
# 
# def get_static_assets_directory():
# 	"""Return path to directory that holds static files"""
# 	script_dir = os.path.join(os.path.dirname(__file__), '..')
# 	prefix_dir = os.path.join(sys.prefix, 'share', 'sunflower')
# 	result = prefix_dir
# 
# 	if os.path.exists(os.path.join(script_dir, 'images', 'sunflower.svg')):
# 		result = script_dir
# 
# 	return result


# Path: sunflower/icons.py
from builtins import filter
from gi.repository import Gtk, Gio, GdkPixbuf, GLib
from sunflower.common import UserDirectory, get_user_directory, get_static_assets_directory
import os
import sys
import zipfile


class IconManager:
	"""Icon manager class provides easy and abstract way of dealing with icons"""

	def __init__(self, parent):
		self._parent = parent
		self._icon_theme = Gtk.IconTheme.get_default()
		self._user_directories = None
		self._default_file = None
		self._default_directory = None

		# preload information
		self._prepare_icons()

	def _prepare_icons(self):
		"""Load special user directories"""
		# set default icons for file and directory
		self._default_file = 'text-x-generic'
		self._default_directory = 'folder'

		# special user directories
		directories = []
		icon_names = {
				UserDirectory.DESKTOP: 'user-desktop',
				UserDirectory.DOWNLOADS: 'folder-download',
				UserDirectory.TEMPLATES: 'folder-templates',
				UserDirectory.PUBLIC: 'folder-publicshare',
				UserDirectory.DOCUMENTS: 'folder-documents',
				UserDirectory.MUSIC: 'folder-music',
				UserDirectory.PICTURES: 'folder-pictures',

				UserDirectory.VIDEOS: 'folder-videos'