Merge branch 'fix-icon_theme' [#515]

Closes https://github.com/awesomeWM/awesome/pull/515.
This commit is contained in:
Daniel Hahler 2015-10-11 13:10:24 +02:00
commit da92c31826
1 changed files with 10 additions and 11 deletions

View File

@ -51,18 +51,18 @@ end
local get_pragmatic_base_directories = function() local get_pragmatic_base_directories = function()
local dirs = {} local dirs = {}
local dir = GLib.get_home_dir() .. "/.icons" local dir = GLib.build_filenamev({GLib.get_home_dir(), ".icons"})
if is_readable_directory(dir) then if is_readable_directory(dir) then
table.insert(dirs, dir) table.insert(dirs, dir)
end end
dir = GLib.get_user_data_dir() .. "/icons" dir = GLib.build_filenamev({GLib.get_user_data_dir(), "icons"})
if is_readable_directory(dir) then if is_readable_directory(dir) then
table.insert(dirs, dir) table.insert(dirs, dir)
end end
for _, v in ipairs(GLib.get_system_data_dirs()) do for _, v in ipairs(GLib.get_system_data_dirs()) do
dir = v .. "/icons" dir = GLib.build_filenamev({v, "icons"})
if is_readable_directory(dir) then if is_readable_directory(dir) then
table.insert(dirs, dir) table.insert(dirs, dir)
end end
@ -70,7 +70,7 @@ local get_pragmatic_base_directories = function()
local need_usr_share_pixmaps = true local need_usr_share_pixmaps = true
for _, v in ipairs(GLib.get_system_data_dirs()) do for _, v in ipairs(GLib.get_system_data_dirs()) do
dir = v .. "/pixmaps" dir = GLib.build_filenamev({v, "pixmaps"})
if is_readable_directory(dir) then if is_readable_directory(dir) then
table.insert(dirs, dir) table.insert(dirs, dir)
end end
@ -106,7 +106,7 @@ local icon_theme = { mt = {} }
-- @tparam string icon_theme_name Internal name of icon theme -- @tparam string icon_theme_name Internal name of icon theme
-- @tparam table base_directories Paths used for lookup -- @tparam table base_directories Paths used for lookup
-- @treturn table An instance of the class `icon_theme` -- @treturn table An instance of the class `icon_theme`
icon_theme.new = function(cls, icon_theme_name, base_directories) icon_theme.new = function(icon_theme_name, base_directories)
local icon_theme_name = icon_theme_name or beautiful.icon_theme or get_default_icon_theme_name() local icon_theme_name = icon_theme_name or beautiful.icon_theme or get_default_icon_theme_name()
local base_directories = base_directories or get_pragmatic_base_directories() local base_directories = base_directories or get_pragmatic_base_directories()
@ -116,7 +116,7 @@ icon_theme.new = function(cls, icon_theme_name, base_directories)
self.extensions = { "png", "svg", "xpm" } self.extensions = { "png", "svg", "xpm" }
self.index_theme = index_theme(self.icon_theme_name, self.base_directories) self.index_theme = index_theme(self.icon_theme_name, self.base_directories)
return setmetatable(self, { __index = cls }) return setmetatable(self, { __index = icon_theme })
end end
local directory_matches_size = function(self, subdirectory, icon_size) local directory_matches_size = function(self, subdirectory, icon_size)
@ -196,8 +196,7 @@ local lookup_icon = function(self, icon_name, icon_size)
return nil return nil
end end
local find_icon_path_helper local find_icon_path_helper = function(self, icon_name, icon_size)
find_icon_path_helper = function(self, icon_name, icon_size)
local filename = lookup_icon(self, icon_name, icon_size) local filename = lookup_icon(self, icon_name, icon_size)
if filename then if filename then
return filename return filename
@ -244,7 +243,7 @@ icon_theme.find_icon_path = function(self, icon_name, icon_size)
end end
if self.icon_theme_name ~= "hicolor" then if self.icon_theme_name ~= "hicolor" then
filaname = find_icon_path_helper(icon_theme("hicolor", self.base_directories), icon_name, icon_size) filename = find_icon_path_helper(icon_theme("hicolor", self.base_directories), icon_name, icon_size)
if filename then if filename then
return filename return filename
end end
@ -253,8 +252,8 @@ icon_theme.find_icon_path = function(self, icon_name, icon_size)
return lookup_fallback_icon(self, icon_name) return lookup_fallback_icon(self, icon_name)
end end
icon_theme.mt.__call = function(cls, icon_theme_name, base_directories) icon_theme.mt.__call = function(_, ...)
return icon_theme.new(cls, icon_theme_name, base_directories) return icon_theme.new(...)
end end
return setmetatable(icon_theme, icon_theme.mt) return setmetatable(icon_theme, icon_theme.mt)