Python gtk.icon_theme_get_default() Examples

The following are 3 code examples of gtk.icon_theme_get_default(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gtk , or try the search function .
Example #1
Source File: Files.py    From launcher with GNU General Public License v2.0 5 votes vote down vote up
def iconFromName(name,size="small"):
	icon_theme = gtk.icon_theme_get_default()
	icon_=icon_theme.lookup_icon(name, 48, 0)
	is_in_theme=False
	if icon_!=None:
		sizes=icon_theme.get_icon_sizes(name)
		if len(sizes)>0:
			highest_res= sorted(icon_theme.get_icon_sizes(name))[::-1][0]
			is_in_theme=True
			icon=icon_theme.lookup_icon(name, highest_res, 0).get_filename()
		else:
			icon=icon_theme.lookup_icon(name, 48, 0).get_filename()
	if is_in_theme==True:
		return icon
	elif os.path.isfile(name):
		return name
	else:
		found=False 
		dir_list=IconTheme.icondirs
		for d in dir_list:
			if os.path.isdir(d):
				for i in os.listdir(d)[::-1]:
					if i.startswith(name):
						path=os.path.join(d,i)
						found=True
						break
		if found==True:
			return path
		else:
			return icon_theme.lookup_icon("text-plain", 48, 0).get_filename() 
Example #2
Source File: Apps.py    From launcher with GNU General Public License v2.0 5 votes vote down vote up
def ico_from_name(name,size="small"):
	icon_theme = gtk.icon_theme_get_default()
	icon_=icon_theme.lookup_icon(name, 48, 0)
	is_in_theme=False
	if icon_!=None:
		sizes=icon_theme.get_icon_sizes(name)
		if len(sizes)>0:
			highest_res= sorted(icon_theme.get_icon_sizes(name))[::-1][0]
			is_in_theme=True
			icon=icon_theme.lookup_icon(name, highest_res, 0).get_filename()
		else:
			icon=icon_theme.lookup_icon(name, 48, 0).get_filename()
	if is_in_theme==True:
		return str(icon)
	elif os.path.isfile(name):
		return str(name)
	else:
		found=False 
		dir_list=IconTheme.icondirs
		for d in dir_list:
			if os.path.isdir(d):
				for i in os.listdir(d)[::-1]:
					if i.startswith(name):
						path=os.path.join(d,i)
						found=True
						break
		if found==True:
			return str(path)
		else:
			return "/usr/share/duck-launcher/icons/apps.svg" 
Example #3
Source File: viberwrapper-indicator.py    From viberwrapper-indicator with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        if self.INSTANCE is not None:
            raise ValueError("An instantiation already exists!")

        self.git = gtk.icon_theme_get_default()

        if self.icon_exists('viber-normal') and self.icon_exists('viber-notification'):
            self.icon_type = "SYSTEM"

            self.icon_normal = "viber-normal"
            self.icon_notification = "viber-notification"
        else:
            self.icon_type = "BUILTIN"

            self.temp_icon_normal = tempfile.NamedTemporaryFile()
            self.temp_icon_notif = tempfile.NamedTemporaryFile()

            self.temp_icon_normal.write(self.ICON_NORMAL.decode('base64'))
            self.temp_icon_notif.write(self.ICON_NOTIF.decode('base64'))

            self.temp_icon_normal.flush()
            self.temp_icon_notif.flush()

            self.icon_normal = os.path.abspath(self.temp_icon_normal.name)
            self.icon_notification = os.path.abspath(self.temp_icon_notif.name)

        printf("Using %s icons\n", self.icon_type)