menubar.icon_theme: Don't require("awful")
This avoids having to mock half the C API just because all of awful is loaded needlessly in this unit test and is generally a good idea. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
a6dd6b4a20
commit
3db87c693a
|
@ -12,7 +12,7 @@
|
||||||
-- http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-0.12.html
|
-- http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-0.12.html
|
||||||
|
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
local awful = require("awful")
|
local awful_util = require("awful.util")
|
||||||
local GLib = require("lgi").GLib
|
local GLib = require("lgi").GLib
|
||||||
local index_theme = require("menubar.index_theme")
|
local index_theme = require("menubar.index_theme")
|
||||||
|
|
||||||
|
@ -26,18 +26,18 @@ local get_pragmatic_base_directories = function()
|
||||||
local dirs = {}
|
local dirs = {}
|
||||||
|
|
||||||
local dir = GLib.build_filenamev({GLib.get_home_dir(), ".icons"})
|
local dir = GLib.build_filenamev({GLib.get_home_dir(), ".icons"})
|
||||||
if awful.util.dir_readable(dir) then
|
if awful_util.dir_readable(dir) then
|
||||||
table.insert(dirs, dir)
|
table.insert(dirs, dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
dir = GLib.build_filenamev({GLib.get_user_data_dir(), "icons"})
|
dir = GLib.build_filenamev({GLib.get_user_data_dir(), "icons"})
|
||||||
if awful.util.dir_readable(dir) then
|
if awful_util.dir_readable(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 = GLib.build_filenamev({v, "icons"})
|
dir = GLib.build_filenamev({v, "icons"})
|
||||||
if awful.util.dir_readable(dir) then
|
if awful_util.dir_readable(dir) then
|
||||||
table.insert(dirs, dir)
|
table.insert(dirs, dir)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -45,7 +45,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 = GLib.build_filenamev({v, "pixmaps"})
|
dir = GLib.build_filenamev({v, "pixmaps"})
|
||||||
if awful.util.dir_readable(dir) then
|
if awful_util.dir_readable(dir) then
|
||||||
table.insert(dirs, dir)
|
table.insert(dirs, dir)
|
||||||
end
|
end
|
||||||
if dir == "/usr/share/pixmaps" then
|
if dir == "/usr/share/pixmaps" then
|
||||||
|
@ -54,7 +54,7 @@ local get_pragmatic_base_directories = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
dir = "/usr/share/pixmaps"
|
dir = "/usr/share/pixmaps"
|
||||||
if need_usr_share_pixmaps and awful.util.dir_readable(dir) then
|
if need_usr_share_pixmaps and awful_util.dir_readable(dir) then
|
||||||
table.insert(dirs, dir)
|
table.insert(dirs, dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ local get_default_icon_theme_name = function()
|
||||||
for _, dir in ipairs(get_pragmatic_base_directories()) do
|
for _, dir in ipairs(get_pragmatic_base_directories()) do
|
||||||
for _, icon_theme_name in ipairs(icon_theme_names) do
|
for _, icon_theme_name in ipairs(icon_theme_names) do
|
||||||
local filename = string.format("%s/%s/index.theme", dir, icon_theme_name)
|
local filename = string.format("%s/%s/index.theme", dir, icon_theme_name)
|
||||||
if awful.util.file_readable(filename) then
|
if awful_util.file_readable(filename) then
|
||||||
return icon_theme_name
|
return icon_theme_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -153,7 +153,7 @@ local lookup_icon = function(self, icon_name, icon_size)
|
||||||
local filename = string.format("%s/%s/%s/%s.%s",
|
local filename = string.format("%s/%s/%s/%s.%s",
|
||||||
basedir, self.icon_theme_name, subdir,
|
basedir, self.icon_theme_name, subdir,
|
||||||
icon_name, ext)
|
icon_name, ext)
|
||||||
if awful.util.file_readable(filename) then
|
if awful_util.file_readable(filename) then
|
||||||
return filename
|
return filename
|
||||||
else
|
else
|
||||||
checked_already[filename] = true
|
checked_already[filename] = true
|
||||||
|
@ -174,7 +174,7 @@ local lookup_icon = function(self, icon_name, icon_size)
|
||||||
basedir, self.icon_theme_name, subdir,
|
basedir, self.icon_theme_name, subdir,
|
||||||
icon_name, ext)
|
icon_name, ext)
|
||||||
if not checked_already[filename] then
|
if not checked_already[filename] then
|
||||||
if awful.util.file_readable(filename) then
|
if awful_util.file_readable(filename) then
|
||||||
closest_filename = filename
|
closest_filename = filename
|
||||||
minimal_size = dist
|
minimal_size = dist
|
||||||
end
|
end
|
||||||
|
@ -210,7 +210,7 @@ local lookup_fallback_icon = function(self, icon_name)
|
||||||
local filename = string.format("%s/%s.%s",
|
local filename = string.format("%s/%s.%s",
|
||||||
dir,
|
dir,
|
||||||
icon_name, ext)
|
icon_name, ext)
|
||||||
if awful.util.file_readable(filename) then
|
if awful_util.file_readable(filename) then
|
||||||
return filename
|
return filename
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,29 +3,6 @@
|
||||||
-- @copyright 2015 Kazunobu Kuriyama
|
-- @copyright 2015 Kazunobu Kuriyama
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
-- Hack so that beautiful can be loaded
|
|
||||||
_G.awesome = {
|
|
||||||
xrdb_get_value = function() end,
|
|
||||||
connect_signal = function() end,
|
|
||||||
register_xproperty = function() end
|
|
||||||
}
|
|
||||||
-- Additional hacks to load menubar
|
|
||||||
_G.screen = {
|
|
||||||
add_signal = function() end,
|
|
||||||
count = function() return 0 end
|
|
||||||
}
|
|
||||||
_G.client = {
|
|
||||||
connect_signal = function() end,
|
|
||||||
add_signal = function() end
|
|
||||||
}
|
|
||||||
_G.tag = {
|
|
||||||
connect_signal = function() end,
|
|
||||||
add_signal = function() end
|
|
||||||
}
|
|
||||||
_G.root = {
|
|
||||||
cursor = function() end
|
|
||||||
}
|
|
||||||
|
|
||||||
local os = os
|
local os = os
|
||||||
local string = string
|
local string = string
|
||||||
local icon_theme = require("menubar.icon_theme")
|
local icon_theme = require("menubar.icon_theme")
|
||||||
|
|
Loading…
Reference in New Issue