From 76623695e6c557a02061f3923da6237f697ee102 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 11 Feb 2014 21:38:05 -0500 Subject: [PATCH] Fix an issue with :remove() and fix taglist signals --- base.lua | 2 +- impl/taglist/init.lua | 50 ++++++++++++++++++++++++++++++++---------- impl/tasklist/init.lua | 3 ++- layout/vertical.lua | 3 +++ 4 files changed, 45 insertions(+), 13 deletions(-) diff --git a/base.lua b/base.lua index 2d6ae6d..739d34c 100644 --- a/base.lua +++ b/base.lua @@ -534,7 +534,7 @@ local function new(args) function data:append(item) if not item then return end - internal.items[#internal.items + 1] = item + internal.items[#internal.items + 1] = {item} data:emit_signal("item::appended",item) end diff --git a/impl/taglist/init.lua b/impl/taglist/init.lua index 1429f9b..d9ed4b4 100644 --- a/impl/taglist/init.lua +++ b/impl/taglist/init.lua @@ -51,7 +51,15 @@ local function track_used(c,t) end end -local function tag_added(t) +local function tag_activated(t) + local act = t.activated + if not act and cache[t] then + instances[cache[t]._internal.screen]:remove(cache[t]) + cache[t] = nil + end +end + +local function tag_added(t,b) if t then local s = tag.getscreen(t) if not cache[t] then @@ -64,6 +72,32 @@ local function tag_added(t) end end +local is_init = false +local function init() + if is_init then return end + + -- Global signals + capi.client.connect_signal("tagged", track_used) + capi.client.connect_signal("untagged", track_used) + capi.client.connect_signal("unmanage", track_used) + capi.tag.connect_signal("property::activated",tag_activated) + capi.tag.connect_signal("property::screen", tag_added) + + -- Property bindings + capi.tag.connect_signal("property::name", function(t) + local item = cache[t] + if item then + item.text = t.name + end + end) + capi.tag.connect_signal("property::icon", function(t) + local item = cache[t] + if item then + item.icon = tag.geticon(t) + end + end) +end + local function new(s) instances[s] = radical.bar { select_on = radical.base.event.NEVER, @@ -80,21 +114,15 @@ local function new(s) end -- Per screen signals - tag.attached_connect_signal(screen, "property::selected", tag_added) --- tag.attached_connect_signal(screen, "property::icon", ut) +-- tag.attached_connect_signal(s, "property::selected", tag_added) -- tag.attached_connect_signal(screen, "property::hide", ut) --- tag.attached_connect_signal(screen, "property::name", ut) - tag.attached_connect_signal(screen, "property::activated", tag_added) - tag.attached_connect_signal(screen, "property::screen", tag_added) - tag.attached_connect_signal(screen, "property::index", tag_added) +-- tag.attached_connect_signal(s, "property::activated", tag_added) +-- tag.attached_connect_signal(s, "property::index", tag_added) + init() return instances[s] end --- Global signals -capi.client.connect_signal("tagged", track_used) -capi.client.connect_signal("untagged", track_used) -capi.client.connect_signal("unmanage", track_used) return setmetatable(module, { __call = function(_, ...) return new(...) end }) -- kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/impl/tasklist/init.lua b/impl/tasklist/init.lua index 75615a5..80a6bb9 100644 --- a/impl/tasklist/init.lua +++ b/impl/tasklist/init.lua @@ -118,7 +118,8 @@ local function new(screen) select_on=radical.base.event.NEVER, fg = beautiful.fg_normal, bg_focus = beautiful.taglist_bg_image_selected2 or beautiful.bg_focus, - bg_hover = beautiful.menu_bg_focus + bg_hover = beautiful.menu_bg_focus, + disable_markup = true } -- Clear the menu and repopulate it diff --git a/layout/vertical.lua b/layout/vertical.lua index 1d05806..50a0539 100644 --- a/layout/vertical.lua +++ b/layout/vertical.lua @@ -119,6 +119,9 @@ function module:setup_text(item,data,text_w) end function module:setup_item(data,item,args) + if not base then + base = require( "radical.base" ) + end --Create the background local item_layout = item.item_layout or horizontal_item_layout item.widget = item_layout(item,data,args)--wibox.widget.background()