[docker] add a delete button
This commit is contained in:
parent
19805d2412
commit
33339666fd
|
@ -62,7 +62,6 @@ local parse_container = function(line)
|
||||||
else actual_status = status end
|
else actual_status = status end
|
||||||
|
|
||||||
how_long = how_long:gsub('%s?%(.*%)%s?', '')
|
how_long = how_long:gsub('%s?%(.*%)%s?', '')
|
||||||
-- if how_long:find('seconds') then how_long = 'less than a minute ago' end
|
|
||||||
|
|
||||||
local container = {
|
local container = {
|
||||||
name = name,
|
name = name,
|
||||||
|
@ -122,20 +121,36 @@ local function worker(args)
|
||||||
if container.is_up() or container.is_exited() then
|
if container.is_up() or container.is_exited() then
|
||||||
start_stop_button = wibox.widget {
|
start_stop_button = wibox.widget {
|
||||||
{
|
{
|
||||||
id = 'icon',
|
{
|
||||||
image = ICONS_DIR .. (container:is_up() and 'stop-btn.svg' or 'play-btn.svg'),
|
id = 'icon',
|
||||||
opacity = 0.4,
|
image = ICONS_DIR .. (container:is_up() and 'stop-btn.svg' or 'play-btn.svg'),
|
||||||
resize = false,
|
opacity = 0.4,
|
||||||
widget = wibox.widget.imagebox
|
resize = false,
|
||||||
|
widget = wibox.widget.imagebox
|
||||||
|
},
|
||||||
|
left = 2,
|
||||||
|
right = 2,
|
||||||
|
layout = wibox.container.margin
|
||||||
},
|
},
|
||||||
left = 2,
|
shape = gears.shape.circle,
|
||||||
right = 2,
|
bg = '#00000000',
|
||||||
layout = wibox.container.margin
|
widget = wibox.container.background
|
||||||
}
|
}
|
||||||
|
local old_cursor, old_wibox
|
||||||
start_stop_button:connect_signal("mouse::enter", function(c)
|
start_stop_button:connect_signal("mouse::enter", function(c)
|
||||||
|
c:set_bg('#3B4252')
|
||||||
|
|
||||||
|
local wb = mouse.current_wibox
|
||||||
|
old_cursor, old_wibox = wb.cursor, wb
|
||||||
|
wb.cursor = "hand1"
|
||||||
c:get_children_by_id("icon")[1]:set_opacity(1)
|
c:get_children_by_id("icon")[1]:set_opacity(1)
|
||||||
c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed') end)
|
c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed') end)
|
||||||
start_stop_button:connect_signal("mouse::leave", function(c)
|
start_stop_button:connect_signal("mouse::leave", function(c)
|
||||||
|
c:set_bg('#00000000')
|
||||||
|
if old_wibox then
|
||||||
|
old_wibox.cursor = old_cursor
|
||||||
|
old_wibox = nil
|
||||||
|
end
|
||||||
c:get_children_by_id("icon")[1]:set_opacity(0.4)
|
c:get_children_by_id("icon")[1]:set_opacity(0.4)
|
||||||
c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed')
|
c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed')
|
||||||
end)
|
end)
|
||||||
|
@ -148,7 +163,7 @@ local function worker(args)
|
||||||
status_icon:set_opacity(0.2)
|
status_icon:set_opacity(0.2)
|
||||||
status_icon:emit_signal('widget::redraw_needed')
|
status_icon:emit_signal('widget::redraw_needed')
|
||||||
|
|
||||||
awful.spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function(stdout, stderr)
|
spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function(stdout, stderr)
|
||||||
if stderr ~= '' then show_warning(stderr) end
|
if stderr ~= '' then show_warning(stderr) end
|
||||||
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers), function(stdout, stderr)
|
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers), function(stdout, stderr)
|
||||||
rebuild_widget(stdout, stderr) end)
|
rebuild_widget(stdout, stderr) end)
|
||||||
|
@ -163,21 +178,36 @@ local function worker(args)
|
||||||
if container.is_up() then
|
if container.is_up() then
|
||||||
pause_unpause_button = wibox.widget {
|
pause_unpause_button = wibox.widget {
|
||||||
{
|
{
|
||||||
id = 'icon',
|
{
|
||||||
image = ICONS_DIR .. (container:is_paused() and 'unpause-btn.svg' or 'pause-btn.svg'),
|
id = 'icon',
|
||||||
opacity = 0.4,
|
image = ICONS_DIR .. (container:is_paused() and 'unpause-btn.svg' or 'pause-btn.svg'),
|
||||||
resize = false,
|
opacity = 0.4,
|
||||||
widget = wibox.widget.imagebox
|
resize = false,
|
||||||
|
widget = wibox.widget.imagebox
|
||||||
|
},
|
||||||
|
left = 2,
|
||||||
|
right = 2,
|
||||||
|
layout = wibox.container.margin
|
||||||
},
|
},
|
||||||
left = 2,
|
shape = gears.shape.circle,
|
||||||
right = 2,
|
bg = '#00000000',
|
||||||
layout = wibox.container.margin
|
widget = wibox.container.background
|
||||||
}
|
}
|
||||||
|
local old_cursor, old_wibox
|
||||||
pause_unpause_button:connect_signal("mouse::enter", function(c)
|
pause_unpause_button:connect_signal("mouse::enter", function(c)
|
||||||
|
c:set_bg('#3B4252')
|
||||||
|
local wb = mouse.current_wibox
|
||||||
|
old_cursor, old_wibox = wb.cursor, wb
|
||||||
|
wb.cursor = "hand1"
|
||||||
c:get_children_by_id("icon")[1]:set_opacity(1)
|
c:get_children_by_id("icon")[1]:set_opacity(1)
|
||||||
c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed')
|
c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed')
|
||||||
end)
|
end)
|
||||||
pause_unpause_button:connect_signal("mouse::leave", function(c)
|
pause_unpause_button:connect_signal("mouse::leave", function(c)
|
||||||
|
c:set_bg('#00000000')
|
||||||
|
if old_wibox then
|
||||||
|
old_wibox.cursor = old_cursor
|
||||||
|
old_wibox = nil
|
||||||
|
end
|
||||||
c:get_children_by_id("icon")[1]:set_opacity(0.4)
|
c:get_children_by_id("icon")[1]:set_opacity(0.4)
|
||||||
c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed')
|
c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed')
|
||||||
end)
|
end)
|
||||||
|
@ -200,6 +230,55 @@ local function worker(args)
|
||||||
pause_unpause_button = nil
|
pause_unpause_button = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local delete_button
|
||||||
|
if not container.is_up() then
|
||||||
|
delete_button = wibox.widget {
|
||||||
|
{
|
||||||
|
{
|
||||||
|
id = 'icon',
|
||||||
|
image = ICONS_DIR .. 'trash-btn.svg',
|
||||||
|
opacity = 0.4,
|
||||||
|
resize = false,
|
||||||
|
widget = wibox.widget.imagebox
|
||||||
|
},
|
||||||
|
margins = 4,
|
||||||
|
layout = wibox.container.margin
|
||||||
|
},
|
||||||
|
shape = gears.shape.circle,
|
||||||
|
bg = '#00000000',
|
||||||
|
widget = wibox.container.background
|
||||||
|
}
|
||||||
|
delete_button:buttons(
|
||||||
|
awful.util.table.join( awful.button({}, 1, function()
|
||||||
|
awful.spawn.easy_async('docker rm ' .. container['name'], function(stdout, stderr)
|
||||||
|
if stderr ~= '' then show_warning(stderr) end
|
||||||
|
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers), function(stdout, stderr)
|
||||||
|
rebuild_widget(stdout, stderr) end)
|
||||||
|
end)
|
||||||
|
end)))
|
||||||
|
|
||||||
|
local old_cursor, old_wibox
|
||||||
|
delete_button:connect_signal("mouse::enter", function(c)
|
||||||
|
c:set_bg('#3B4252')
|
||||||
|
local wb = mouse.current_wibox
|
||||||
|
old_cursor, old_wibox = wb.cursor, wb
|
||||||
|
wb.cursor = "hand1"
|
||||||
|
c:get_children_by_id("icon")[1]:set_opacity(1)
|
||||||
|
c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed')
|
||||||
|
end)
|
||||||
|
delete_button:connect_signal("mouse::leave", function(c)
|
||||||
|
c:set_bg('#00000000')
|
||||||
|
if old_wibox then
|
||||||
|
old_wibox.cursor = old_cursor
|
||||||
|
old_wibox = nil
|
||||||
|
end
|
||||||
|
c:get_children_by_id("icon")[1]:set_opacity(0.4)
|
||||||
|
c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed')
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
delete_button = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local row = wibox.widget {
|
local row = wibox.widget {
|
||||||
{
|
{
|
||||||
|
@ -237,9 +316,10 @@ local function worker(args)
|
||||||
{
|
{
|
||||||
start_stop_button,
|
start_stop_button,
|
||||||
pause_unpause_button,
|
pause_unpause_button,
|
||||||
|
delete_button,
|
||||||
layout = wibox.layout.align.horizontal
|
layout = wibox.layout.align.horizontal
|
||||||
},
|
},
|
||||||
forced_width = 60,
|
forced_width = 90,
|
||||||
valign = 'center',
|
valign = 'center',
|
||||||
haligh = 'center',
|
haligh = 'center',
|
||||||
layout = wibox.container.place,
|
layout = wibox.container.place,
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#BF616A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-trash-2"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>
|
After Width: | Height: | Size: 443 B |
Loading…
Reference in New Issue