From a1f93fa8bd836f106acb3decbd1d21a9877e08f9 Mon Sep 17 00:00:00 2001 From: Pavel Makhov Date: Tue, 17 Dec 2019 16:27:30 -0500 Subject: tiny refactoring --- calendar-widget/calendar.lua | 1 - gerrit-widget/gerrit.lua | 4 +--- jira-widget/jira.lua | 28 ++++++++++++---------------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/calendar-widget/calendar.lua b/calendar-widget/calendar.lua index b98b3a4..c54fb5c 100644 --- a/calendar-widget/calendar.lua +++ b/calendar-widget/calendar.lua @@ -137,7 +137,6 @@ local function worker(args) ontop = true, visible = false, shape = gears.shape.rounded_rect, - preferred_positions = top, offset = { y = 5 }, border_width = 1, border_color = calendar_themes[theme].border, diff --git a/gerrit-widget/gerrit.lua b/gerrit-widget/gerrit.lua index af3879b..890371f 100644 --- a/gerrit-widget/gerrit.lua +++ b/gerrit-widget/gerrit.lua @@ -45,14 +45,12 @@ local function worker(args) } local popup = awful.popup{ - visible = true, ontop = true, visible = false, shape = gears.shape.rounded_rect, border_width = 1, border_color = beautiful.bg_focus, maximum_width = 400, - preferred_positions = top, offset = { y = 5 }, widget = {} } @@ -84,7 +82,7 @@ local function worker(args) } local function get_name_by_user_id(user_id) - if name_dict[user_id] == null then + if name_dict[user_id] == nil then name_dict[user_id] = {} end diff --git a/jira-widget/jira.lua b/jira-widget/jira.lua index 158db7c..d0b364b 100644 --- a/jira-widget/jira.lua +++ b/jira-widget/jira.lua @@ -43,14 +43,12 @@ local function worker(args) } local popup = awful.popup{ - visible = true, ontop = true, visible = false, shape = gears.shape.rounded_rect, border_width = 1, border_color = beautiful.bg_focus, maximum_width = 400, - preferred_positions = top, offset = { y = 5 }, widget = {} } @@ -86,6 +84,12 @@ local function worker(args) current_number_of_reviews = rawlen(result.issues) + if current_number_of_reviews == 0 then + widget:set_visible(false) + return + end + + widget:set_visible(true) widget:set_text(current_number_of_reviews) for i = 0, #rows do rows[i]=nil end @@ -149,11 +153,7 @@ local function worker(args) row:buttons( awful.util.table.join( awful.button({}, 1, function() - spawn.with_shell("google-chrome " .. host .. '/browse/' .. issue.key) - popup.visible = false - end), - awful.button({}, 3, function() - spawn.with_shell("echo 'git-review -d " .. issue._number .."' | xclip -selection clipboard") + spawn.with_shell("xdg-open " .. host .. '/browse/' .. issue.key) popup.visible = false end) ) @@ -171,15 +171,11 @@ local function worker(args) if popup.visible then popup.visible = not popup.visible else - --local geo = mouse.current_widget_geometry - --if theme.calendar_placement == 'center' then - -- local x = geo.x + (geo.width / 2) - (popup:geometry().width / 2) -- align two widgets - -- popup:move_next_to({x = x, y = geo.y + 22, width = 0, height = geo.height}) - --else - -- popup:move_next_to(geo) - --end - - popup:move_next_to(mouse.current_widget_geometry) + local geo = mouse.current_widget_geometry + local x = geo.x + (geo.width / 2) - (popup:geometry().width / 2) + popup:move_next_to({x = x, y = geo.y + 22, width = 0, height = geo.height}) + + -- popup:move_next_to(mouse.current_widget_geometry) end end) ) -- cgit v1.2.3