Skip to content

Commit

Permalink
Support multiple icon themes
Browse files Browse the repository at this point in the history
You can supply multiple icon themes by setting
freedesktop.util.icon_theme to a table that contains icon themes to
search for the requested icon. Example:

freedesktop.utils.icon_theme = { 'Mist', 'gnome' }

This would first try to find the icon in Mist theme and if not found,
in gnome theme.

The change is backwards-compatible. If freedesktop.util.icon_theme
is a string, this icon theme will be used like before this change.

Signed-off-by: Tuomas Jormola <tj@solitudo.net>
  • Loading branch information
tjormola authored and terceiro committed Apr 19, 2011
1 parent d648e49 commit af278f7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions freedesktop/utils.lua
Expand Up @@ -2,6 +2,7 @@

local io = io
local table = table
local type = type
local ipairs = ipairs
local pairs = pairs

Expand Down Expand Up @@ -53,10 +54,16 @@ function lookup_icon(arg)
return arg.icon
else
local icon_path = {}
local icon_themes = {}
local icon_theme_paths = {}
if icon_theme then
for i, path in ipairs(all_icon_paths) do
table.insert(icon_theme_paths, path .. icon_theme .. '/')
if icon_theme and type(icon_theme) == 'table' then
icon_themes = icon_theme
elseif icon_theme then
icon_themes = { icon_theme }
end
for i, theme in ipairs(icon_themes) do
for j, path in ipairs(all_icon_paths) do
table.insert(icon_theme_paths, path .. theme .. '/')
end
-- TODO also look in parent icon themes, as in freedesktop.org specification
end
Expand Down

0 comments on commit af278f7

Please sign in to comment.