Docs: General work on gears module.
Signed-off-by: Ignas Anikevicius (gns_ank) <anikevicius@gmail.com>
This commit is contained in:
parent
de10f5e4f0
commit
00f558ff92
|
@ -2,6 +2,7 @@
|
||||||
-- @author Uli Schlachter
|
-- @author Uli Schlachter
|
||||||
-- @copyright 2010 Uli Schlachter
|
-- @copyright 2010 Uli Schlachter
|
||||||
-- @release @AWESOME_VERSION@
|
-- @release @AWESOME_VERSION@
|
||||||
|
-- @module gears.color
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
|
@ -19,11 +20,13 @@ local color = { mt = {} }
|
||||||
local pattern_cache = setmetatable({}, { __mode = 'v' })
|
local pattern_cache = setmetatable({}, { __mode = 'v' })
|
||||||
|
|
||||||
--- Parse a HTML-color.
|
--- Parse a HTML-color.
|
||||||
-- This function can parse colors like #rrggbb and #rrggbbaa.
|
-- This function can parse colors like `#rrggbb` and `#rrggbbaa`.
|
||||||
-- For example, parse_color("#00ff00ff") would return 0, 1, 0, 1.
|
|
||||||
-- Thanks to #lua for this. :)
|
-- Thanks to #lua for this. :)
|
||||||
|
--
|
||||||
-- @param col The color to parse
|
-- @param col The color to parse
|
||||||
-- @return 4 values which each are in the range [0, 1].
|
-- @return 4 values which each are in the range [0, 1].
|
||||||
|
-- @usage -- This will return 0, 1, 0, 1
|
||||||
|
-- gears.color.parse_color("#00ff00ff")
|
||||||
function color.parse_color(col)
|
function color.parse_color(col)
|
||||||
local rgb = {}
|
local rgb = {}
|
||||||
for pair in string.gmatch(col, "[^#].") do
|
for pair in string.gmatch(col, "[^#].") do
|
||||||
|
@ -39,7 +42,8 @@ function color.parse_color(col)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Find all numbers in a string
|
--- Find all numbers in a string
|
||||||
-- @param s The string to parse
|
--
|
||||||
|
-- @tparam string s The string to parse
|
||||||
-- @return Each number found as a separate value
|
-- @return Each number found as a separate value
|
||||||
local function parse_numbers(s)
|
local function parse_numbers(s)
|
||||||
local res = {}
|
local res = {}
|
||||||
|
@ -50,6 +54,7 @@ local function parse_numbers(s)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create a solid pattern
|
--- Create a solid pattern
|
||||||
|
--
|
||||||
-- @param col The color for the pattern
|
-- @param col The color for the pattern
|
||||||
-- @return A cairo pattern object
|
-- @return A cairo pattern object
|
||||||
function color.create_solid_pattern(col)
|
function color.create_solid_pattern(col)
|
||||||
|
@ -63,6 +68,7 @@ function color.create_solid_pattern(col)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create an image pattern from a png file
|
--- Create an image pattern from a png file
|
||||||
|
--
|
||||||
-- @param file The filename of the file
|
-- @param file The filename of the file
|
||||||
-- @return a cairo pattern object
|
-- @return a cairo pattern object
|
||||||
function color.create_png_pattern(file)
|
function color.create_png_pattern(file)
|
||||||
|
@ -237,7 +243,7 @@ end
|
||||||
--- Check if a pattern is opaque.
|
--- Check if a pattern is opaque.
|
||||||
-- A pattern is transparent if the background on which it gets drawn (with
|
-- A pattern is transparent if the background on which it gets drawn (with
|
||||||
-- operator OVER) doesn't influence the visual result.
|
-- operator OVER) doesn't influence the visual result.
|
||||||
-- @param col An argument that @{create_pattern} accepts
|
-- @param col An argument that `create_pattern` accepts.
|
||||||
-- @return The pattern if it is surely opaque, else nil
|
-- @return The pattern if it is surely opaque, else nil
|
||||||
function color.create_opaque_pattern(col)
|
function color.create_opaque_pattern(col)
|
||||||
local pattern = color.create_pattern(col)
|
local pattern = color.create_pattern(col)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
-- @author Uli Schlachter
|
-- @author Uli Schlachter
|
||||||
-- @copyright 2010 Uli Schlachter
|
-- @copyright 2010 Uli Schlachter
|
||||||
-- @release @AWESOME_VERSION@
|
-- @release @AWESOME_VERSION@
|
||||||
|
-- @module gears.debug
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
local error = error
|
local error = error
|
||||||
|
@ -11,12 +12,12 @@ local print = print
|
||||||
local type = type
|
local type = type
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
|
|
||||||
-- gears.debug
|
|
||||||
local debug = {}
|
local debug = {}
|
||||||
|
|
||||||
--- Check that the given condition holds true, else throw an error
|
--- Check that the given condition holds true, else throw an error
|
||||||
|
--
|
||||||
-- @param cond If this is false, throw a lua error with a backtrace.
|
-- @param cond If this is false, throw a lua error with a backtrace.
|
||||||
-- @param message Message to print in the error (optional).
|
-- @param[opt] message Message to print in the error (optional).
|
||||||
function debug.assert(cond, message)
|
function debug.assert(cond, message)
|
||||||
local message = message or cond
|
local message = message or cond
|
||||||
if not cond then
|
if not cond then
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
-- @author Uli Schlachter
|
-- @author Uli Schlachter
|
||||||
-- @copyright 2010 Uli Schlachter
|
-- @copyright 2010 Uli Schlachter
|
||||||
-- @release @AWESOME_VERSION@
|
-- @release @AWESOME_VERSION@
|
||||||
|
-- @module gears
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
--- gears
|
|
||||||
|
|
||||||
return
|
return
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
-- @author Uli Schlachter
|
-- @author Uli Schlachter
|
||||||
-- @copyright 2010 Uli Schlachter
|
-- @copyright 2010 Uli Schlachter
|
||||||
-- @release @AWESOME_VERSION@
|
-- @release @AWESOME_VERSION@
|
||||||
|
-- @classmod gears.object
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
|
@ -9,7 +10,6 @@ local pairs = pairs
|
||||||
local type = type
|
local type = type
|
||||||
local error = error
|
local error = error
|
||||||
|
|
||||||
-- gears.object
|
|
||||||
local object = { mt = {} }
|
local object = { mt = {} }
|
||||||
|
|
||||||
-- Verify that obj is indeed a valid object as returned by new()
|
-- Verify that obj is indeed a valid object as returned by new()
|
||||||
|
@ -60,10 +60,11 @@ function object:disconnect_signal(name, func)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Emit a signal
|
--- Emit a signal
|
||||||
|
--
|
||||||
-- @param name The name of the signal
|
-- @param name The name of the signal
|
||||||
-- @param ... Extra arguments for the callback functions. Each connected
|
-- @param ... Extra arguments for the callback functions. Each connected
|
||||||
-- function receives the object as first argument and then any extra
|
-- function receives the object as first argument and then any extra arguments
|
||||||
-- arguments that are given to emit_signal()
|
-- that are given to emit_signal()
|
||||||
function object:emit_signal(name, ...)
|
function object:emit_signal(name, ...)
|
||||||
local sig = find_signal(self, name, "emit")
|
local sig = find_signal(self, name, "emit")
|
||||||
for func in pairs(sig) do
|
for func in pairs(sig) do
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
-- @author Uli Schlachter
|
-- @author Uli Schlachter
|
||||||
-- @copyright 2010 Uli Schlachter
|
-- @copyright 2010 Uli Schlachter
|
||||||
-- @release @AWESOME_VERSION@
|
-- @release @AWESOME_VERSION@
|
||||||
|
-- @module gears.sort
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
|
@ -9,7 +10,6 @@ local ipairs = ipairs
|
||||||
local table = table
|
local table = table
|
||||||
local error = error
|
local error = error
|
||||||
|
|
||||||
-- gears.sort
|
|
||||||
local sort = { mt = {} }
|
local sort = { mt = {} }
|
||||||
|
|
||||||
local function less_than_comp(a, b)
|
local function less_than_comp(a, b)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
-- @author Uli Schlachter
|
-- @author Uli Schlachter
|
||||||
-- @copyright 2012 Uli Schlachter
|
-- @copyright 2012 Uli Schlachter
|
||||||
-- @release @AWESOME_VERSION@
|
-- @release @AWESOME_VERSION@
|
||||||
|
-- @module gears.surface
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
|
@ -15,7 +16,6 @@ if tonumber(ver_major) <= 0 and tonumber(ver_minor) < 7 then
|
||||||
error("lgi too old, need at least version 0.7.0")
|
error("lgi too old, need at least version 0.7.0")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- gears.surface
|
|
||||||
local surface = { mt = {} }
|
local surface = { mt = {} }
|
||||||
local surface_cache = setmetatable({}, { __mode = 'v' })
|
local surface_cache = setmetatable({}, { __mode = 'v' })
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
-- @author Uli Schlachter
|
-- @author Uli Schlachter
|
||||||
-- @copyright 2012 Uli Schlachter
|
-- @copyright 2012 Uli Schlachter
|
||||||
-- @release @AWESOME_VERSION@
|
-- @release @AWESOME_VERSION@
|
||||||
|
-- @module gears.wallpaper
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
local cairo = require("lgi").cairo
|
local cairo = require("lgi").cairo
|
||||||
local color = require("gears.color")
|
local color = require("gears.color")
|
||||||
local surface = require("gears.surface")
|
local surface = require("gears.surface")
|
||||||
|
|
||||||
-- gears.wallpaper
|
|
||||||
local wallpaper = { mt = {} }
|
local wallpaper = { mt = {} }
|
||||||
|
|
||||||
-- The size of the root window
|
-- The size of the root window
|
||||||
|
@ -30,8 +30,8 @@ end
|
||||||
--- Prepare the needed state for setting a wallpaper
|
--- Prepare the needed state for setting a wallpaper
|
||||||
-- @param s The screen to set the wallpaper on or nil for all screens
|
-- @param s The screen to set the wallpaper on or nil for all screens
|
||||||
-- @return The available geometry (table with entries width and height), a
|
-- @return The available geometry (table with entries width and height), a
|
||||||
-- that should be used for setting the wallpaper and a cairo context
|
-- that should be used for setting the wallpaper and a cairo context for
|
||||||
-- for drawing to this surface
|
-- drawing to this surface
|
||||||
local function prepare_wallpaper(s)
|
local function prepare_wallpaper(s)
|
||||||
local geom = s and screen[s].geometry or root_geom
|
local geom = s and screen[s].geometry or root_geom
|
||||||
local img = surface(root.wallpaper())
|
local img = surface(root.wallpaper())
|
||||||
|
|
Loading…
Reference in New Issue