-- flaw, a Lua OO management framework for Awesome WM widgets. -- Copyright (C) 2010,2011 David Soulayrol -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -- Grab environment. local capi = { client = client, } local awful = { util = require("awful.util"), } local flaw = { gadget = require('flaw.gadget'), provider = require('flaw.provider'), helper = require('flaw.helper'), } --- Clients title display. -- --

This module contains a simple text gadget which displays the -- title of the active client, and its provider. This is a convenient -- way to see the window title displayed, even if the window bar is -- not displayed.

-- --

Gadget

-- --

The title gadget can be instantiated by indexing the gadget -- module with text.title. The ID parameter has no -- meaning for the calendar gadget, and it takes no particular -- parameters. See the gadget module -- documentation to learn about standard gadgets parameters.

-- --
-- g = flaw.gadget.text.title('') --
-- --

Provider

-- --

The provider makes no hardware or software access whatsoever. It -- simply plugs its update method on the -- focus, unfocus and -- property::name signals. This also means the -- delay parameter has no meaning for it.

-- -- -- @author David Soulayrol <david.soulayrol AT gmail DOT com> -- @copyright 2010,2011 David Soulayrol module('flaw.title') --- The client events provider prototype. -- --

The client title provider type is set to -- title._NAME.

-- -- @class table -- @name ClientProvider ClientProvider = flaw.provider.Provider:new{ type = _NAME } --- Display the new client title. function ClientProvider:update(c) if c and c.name and capi.client.focus == c then self.data.title = awful.util.escape(c.name) self:refresh_gadgets() end end --- Erase the client title. function ClientProvider:reset(c) if c then self.data.title = '' self:refresh_gadgets() end end --- A factory for client providers. -- -- @return a brand new client provider. function provider_factory() local p = flaw.provider.get(_NAME, '') -- Create the provider if necessary. if p == nil then p = ClientProvider:new{ id = '', data = { title = '' } } flaw.provider.add(p) -- Init signals once for the provider. capi.client.add_signal( 'manage', function (c, startup) c:add_signal('property::name', function(c) p:update(c) end) end) capi.client.add_signal('focus', function(c) p:update(c) end) capi.client.add_signal('unfocus', function(c) p:reset(c) end) end return p end -- A Text gadget prototype for clients title display. flaw.gadget.register.text(_M, { pattern = '$title' })