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:
Uli Schlachter 2016-02-21 16:53:46 +01:00
parent a6dd6b4a20
commit 3db87c693a
2 changed files with 10 additions and 33 deletions

View File

@ -12,7 +12,7 @@
-- http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-0.12.html
local beautiful = require("beautiful")
local awful = require("awful")
local awful_util = require("awful.util")
local GLib = require("lgi").GLib
local index_theme = require("menubar.index_theme")
@ -26,18 +26,18 @@ local get_pragmatic_base_directories = function()
local dirs = {}
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)
end
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)
end
for _, v in ipairs(GLib.get_system_data_dirs()) do
dir = GLib.build_filenamev({v, "icons"})
if awful.util.dir_readable(dir) then
if awful_util.dir_readable(dir) then
table.insert(dirs, dir)
end
end
@ -45,7 +45,7 @@ local get_pragmatic_base_directories = function()
local need_usr_share_pixmaps = true
for _, v in ipairs(GLib.get_system_data_dirs()) do
dir = GLib.build_filenamev({v, "pixmaps"})
if awful.util.dir_readable(dir) then
if awful_util.dir_readable(dir) then
table.insert(dirs, dir)
end
if dir == "/usr/share/pixmaps" then
@ -54,7 +54,7 @@ local get_pragmatic_base_directories = function()
end
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)
end
@ -66,7 +66,7 @@ local get_default_icon_theme_name = function()
for _, dir in ipairs(get_pragmatic_base_directories()) do
for _, icon_theme_name in ipairs(icon_theme_names) do
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
end
end
@ -153,7 +153,7 @@ local lookup_icon = function(self, icon_name, icon_size)
local filename = string.format("%s/%s/%s/%s.%s",
basedir, self.icon_theme_name, subdir,
icon_name, ext)
if awful.util.file_readable(filename) then
if awful_util.file_readable(filename) then
return filename
else
checked_already[filename] = true
@ -174,7 +174,7 @@ local lookup_icon = function(self, icon_name, icon_size)
basedir, self.icon_theme_name, subdir,
icon_name, ext)
if not checked_already[filename] then
if awful.util.file_readable(filename) then
if awful_util.file_readable(filename) then
closest_filename = filename
minimal_size = dist
end
@ -210,7 +210,7 @@ local lookup_fallback_icon = function(self, icon_name)
local filename = string.format("%s/%s.%s",
dir,
icon_name, ext)
if awful.util.file_readable(filename) then
if awful_util.file_readable(filename) then
return filename
end
end

View File

@ -3,29 +3,6 @@
-- @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 string = string
local icon_theme = require("menubar.icon_theme")