From 92aed20ebbbc43ad686ed0dd6a0fdd42d04e4696 Mon Sep 17 00:00:00 2001 From: Yessiest Date: Tue, 6 Sep 2022 01:54:11 +0400 Subject: [PATCH] Added widget-generic styles to AWMTK --- libs/awmtk2.lua | 13 ++++++++- libs/context_menu.lua | 3 +- themes/reno98/theme.lua | 56 +++++++++++++------------------------- widgets/base/clock.lua | 3 +- widgets/base/systray.lua | 3 +- widgets/battery.lua | 3 +- widgets/clientbuttons.lua | 3 +- widgets/clientcontrols.lua | 3 +- widgets/clientmenu.lua | 3 +- widgets/launcher.lua | 4 ++- widgets/notifications.lua | 3 +- widgets/rootbuttons.lua | 3 +- widgets/rootcontrols.lua | 3 +- widgets/rootmenu.lua | 3 +- widgets/wallpapers.lua | 3 +- widgets/xdgmenu.lua | 3 +- 16 files changed, 60 insertions(+), 52 deletions(-) diff --git a/libs/awmtk2.lua b/libs/awmtk2.lua index 6da1e49..30a913c 100644 --- a/libs/awmtk2.lua +++ b/libs/awmtk2.lua @@ -10,6 +10,8 @@ local wibox = require("wibox") local awful = require("awful") local gears = require("gears") local beautiful = require("beautiful") +beautiful.widgets = beautiful.widgets or {} +beautiful.templates = beautiful.templates or {} local awmtk = {} @@ -41,7 +43,7 @@ awmtk.create_style = function(name,parent,overrides) -- A style is essentially a layer of deltas upon the previous (parent) style local new_style = {} local odelta = (overrides and overrides[name]) or {} - local cdelta = (beautiful.widgets and beautiful.widgets[name]) or {} + local cdelta = beautiful.widgets[name] or {} for name,parent_class in pairs(parent) do new_style[name] = awmtk.create_delta( name, @@ -410,5 +412,14 @@ awmtk.proto_templates = { -- This is done in order to allow overriding default style behaviour from theme awmtk.default = awmtk.create_style("default",awmtk.proto_style,{}) awmtk.templates = awmtk.create_template_lib("templates",awmtk.proto_templates,{}) + +-- Generic styles for widgets that need them +awmtk.generic = {} +awmtk.generic.menu = awmtk.create_style("generic_menu",awmtk.default,{}) +awmtk.generic.button_list = awmtk.create_style("generic_button_list",awmtk.default,{}) +awmtk.generic.iconified_widget = awmtk.create_style("generic_iconified_widget",awmtk.default,{}) +awmtk.generic.status_widget = awmtk.create_style("generic_status_widget",awmtk.default,{}) +awmtk.generic.oneline_widget = awmtk.create_style("generic_oneline_widget",awmtk.default,{}) +awmtk.generic.composite_widget = awmtk.create_style("generic_composite_widget",awmtk.default,{}) -- }}} return awmtk diff --git a/libs/context_menu.lua b/libs/context_menu.lua index b83253d..0abd7bf 100644 --- a/libs/context_menu.lua +++ b/libs/context_menu.lua @@ -39,7 +39,8 @@ end return function(args) -- A way to communicate that all widgets in menu got closed args.on_close = args.on_close or function() end - local style = awmtk2.create_style("menu", awmtk2.default, args.style) + local style = awmtk2.create_style("menu", + awmtk2.generic.menu, args.style) local templates = awmtk2.create_template_lib("menu", awmtk2.templates, args.templates) local t = awmtk2.build_templates(templates,style) local function menu_builder(element,layer,root_layer) diff --git a/themes/reno98/theme.lua b/themes/reno98/theme.lua index 49c789a..dc69e2e 100644 --- a/themes/reno98/theme.lua +++ b/themes/reno98/theme.lua @@ -336,6 +336,7 @@ theme.notification_height = 60 theme.icon_default = gears.surface(themes_path.."reno98/icons/unknown-app.png") theme.widgets = { + -- {{{ Widget base default = { container = { bgimage = theme.bgimage_highlight, @@ -394,12 +395,25 @@ theme.widgets = { bar_height = 6 } }, - xdg_menu = { + -- }}} + -- {{{ Menus + generic_menu = { base = { - spacing = 2 - } + spacing = 2, + menu_slide = true + }, + button = { + forced_height = 20, + forced_width = 160 + }, }, - battery = { + --}}} + -- {{{ Status panel widgets + generic_status_widget = { + container = { + bgimage = function() end, + margins = 0 + }, button = { margins = 0, onpress = function() end, @@ -407,6 +421,7 @@ theme.widgets = { bgimage = function() end } }, + -- }}} soundclown = { base = { width = 140 @@ -427,22 +442,6 @@ theme.widgets = { desc_valign = "top" } }, - clock = { - container = { - bgimage = function() end, - margins = 0 - } - }, - root_menu = { - base = { - spacing = 2 - } - }, - client_menu = { - base = { - spacing = 2 - } - }, taglist = { base = { spacing = 2 @@ -481,23 +480,6 @@ theme.widgets = { bgimage_minimize = theme.bgimage_outset } }, - menu = { - base = { - -- Enables the ability to just drag the mouse on an entry to open it - menu_slide = true, - spacing = 2 - }, - button = { - forced_height = 20, - forced_width = 160 - }, - }, - systray = { - container = { - bgimage = function() end, - margins = 0 - } - }, lockscreen = { popup = { margins = 0 diff --git a/widgets/base/clock.lua b/widgets/base/clock.lua index ba11335..964dd06 100644 --- a/widgets/base/clock.lua +++ b/widgets/base/clock.lua @@ -16,7 +16,8 @@ local DateTime = glib.DateTime local TimeZone = glib.TimeZone return function(args) - local style = awmtk2.create_style("clock",awmtk2.default,args.style) + local style = awmtk2.create_style("clock", + awmtk2.generic.status_widget,args.style) local templates = awmtk2.create_template_lib("clock",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) -- Don't mind me just stealing default library code diff --git a/widgets/base/systray.lua b/widgets/base/systray.lua index 32989a9..97dbf18 100644 --- a/widgets/base/systray.lua +++ b/widgets/base/systray.lua @@ -13,7 +13,8 @@ local awful = require("awful") local beautiful = require("beautiful") return function(args) - local style = awmtk2.create_style("systray",awmtk2.default,args.style) + local style = awmtk2.create_style("systray", + awmtk2.generic.status_widget,args.style) local templates = awmtk2.create_template_lib("systray",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) local widget = wibox.widget(t.container({ diff --git a/widgets/battery.lua b/widgets/battery.lua index 68cf843..e728b63 100644 --- a/widgets/battery.lua +++ b/widgets/battery.lua @@ -41,7 +41,8 @@ local function get_virtual_icon(data) end return function(args) - local style = awmtk2.create_style("battery",awmtk2.default,args.style) + local style = awmtk2.create_style("battery", + awmtk2.generic.status_widget,args.style) local templates = awmtk2.create_template_lib("battery",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) -- set up popup layout diff --git a/widgets/clientbuttons.lua b/widgets/clientbuttons.lua index 6559a58..f311ec2 100644 --- a/widgets/clientbuttons.lua +++ b/widgets/clientbuttons.lua @@ -13,7 +13,8 @@ local awful = require("awful") local beautiful = require("beautiful") return function(args) - local style = awmtk2.create_style("client_buttons",awmtk2.default,args.style) + local style = awmtk2.create_style("client_buttons", + awmtk2.generic.button_list,args.style) local templates = awmtk2.create_template_lib("client_buttons",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) local floating_on = beautiful.titlebar_floating_button_normal_inactive diff --git a/widgets/clientcontrols.lua b/widgets/clientcontrols.lua index 6c61eb4..28fc832 100644 --- a/widgets/clientcontrols.lua +++ b/widgets/clientcontrols.lua @@ -14,7 +14,8 @@ local beautiful = require("beautiful") local menugen = require("context_menu") return function(args) - local style = awmtk2.create_style("client_controls",awmtk2.default,args.style) + local style = awmtk2.create_style("client_controls", + awmtk2.generic.menu,args.style) local templates = awmtk2.create_template_lib("client_controls",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) local move_to_tag = {} diff --git a/widgets/clientmenu.lua b/widgets/clientmenu.lua index da532c8..ed920e4 100644 --- a/widgets/clientmenu.lua +++ b/widgets/clientmenu.lua @@ -13,7 +13,8 @@ local awful = require("awful") local beautiful = require("beautiful") local menugen = require("context_menu") local builder = require("builder") -local style = awmtk2.create_style("client_menu",awmtk2.default,{}) +local style = awmtk2.create_style("client_menu", + awmtk2.generic.menu,{}) local templates = awmtk2.create_template_lib("client_menu",awmtk2.templates,{}) local t = awmtk2.build_templates(templates,style) diff --git a/widgets/launcher.lua b/widgets/launcher.lua index 056bc9f..86692f0 100644 --- a/widgets/launcher.lua +++ b/widgets/launcher.lua @@ -10,6 +10,7 @@ local awful = require("awful") local wibox = require("wibox") local gears = require("gears") local awmtk2 = require("awmtk2") +local beautiful = require("beautiful") local menubar_utils = require("menubar").utils local function synchronous_ls(dir) @@ -22,7 +23,8 @@ local function synchronous_ls(dir) end return function(args) - local style = awmtk2.create_style("launcher", awmtk2.default, args.style) + local style = awmtk2.create_style("launcher", + awmtk2.generic.button_list, args.style) local templates = awmtk2.create_template_lib("launcher", awmtk2.templates, args.templates) local t = awmtk2.build_templates(templates,style) local w = wibox.widget({ diff --git a/widgets/notifications.lua b/widgets/notifications.lua index e30a899..9af4f89 100644 --- a/widgets/notifications.lua +++ b/widgets/notifications.lua @@ -15,7 +15,8 @@ local awmtk2 = require("awmtk2") local naughty = require("naughty") return function(args) - local style = awmtk2.create_style("notifications",awmtk2.default,args.style) + local style = awmtk2.create_style("notifications", + awmtk2.generic.iconified_widget,args.style) local templates = awmtk2.create_template_lib("notifications",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) local layout = wibox.widget({ diff --git a/widgets/rootbuttons.lua b/widgets/rootbuttons.lua index 515647d..3cb9bce 100644 --- a/widgets/rootbuttons.lua +++ b/widgets/rootbuttons.lua @@ -13,7 +13,8 @@ local awful = require("awful") local beautiful = require("beautiful") return function(args) - local style = awmtk2.create_style("root_buttons",awmtk2.default,args.style) + local style = awmtk2.create_style("root_buttons", + awmtk2.generic.button_list,args.style) local templates = awmtk2.create_template_lib("root_buttons",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) local poweroff = wibox.widget(t.button({ diff --git a/widgets/rootcontrols.lua b/widgets/rootcontrols.lua index d4b1152..0bd2a88 100644 --- a/widgets/rootcontrols.lua +++ b/widgets/rootcontrols.lua @@ -14,7 +14,8 @@ local beautiful = require("beautiful") local menugen = require("context_menu") return function(args) - local style = awmtk2.create_style("root_menu",awmtk2.default,args.style) + local style = awmtk2.create_style("root_menu", + awmtk2.generic.menu,args.style) local templates = awmtk2.create_template_lib("root_menu",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) local widget = menugen({ diff --git a/widgets/rootmenu.lua b/widgets/rootmenu.lua index 800251d..6f89b6f 100644 --- a/widgets/rootmenu.lua +++ b/widgets/rootmenu.lua @@ -14,7 +14,8 @@ local beautiful = require("beautiful") local builder = require("builder") return function(args) - local style = awmtk2.create_style("root_menu",awmtk2.default,{}) + local style = awmtk2.create_style("root_menu", + awmtk2.generic.menu,{}) local templates = awmtk2.create_template_lib("root_menu",awmtk2.templates,{}) local t = awmtk2.build_templates(templates,style) local config_file = io.open(root_path.."/themes/"..global.theme.."/config/root_menu.json","r") diff --git a/widgets/wallpapers.lua b/widgets/wallpapers.lua index 07acfe5..07a8426 100644 --- a/widgets/wallpapers.lua +++ b/widgets/wallpapers.lua @@ -28,7 +28,8 @@ local function ls(path) end return function(args) - local style = awmtk2.create_style("wallpapers",awmtk2.default,args.style) + local style = awmtk2.create_style("wallpapers", + awmtk2.generic.iconified_widget,args.style) local templates = awmtk2.create_template_lib("wallpapers",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) -- set wallpaper diff --git a/widgets/xdgmenu.lua b/widgets/xdgmenu.lua index eb60139..316a730 100644 --- a/widgets/xdgmenu.lua +++ b/widgets/xdgmenu.lua @@ -15,7 +15,8 @@ local menugen = require("context_menu") local menuutils = require("menubar").utils return function(args) - local style = awmtk2.create_style("xdg_menu",awmtk2.default,args.style) + local style = awmtk2.create_style("xdg_menu", + awmtk2.generic.menu,args.style) local templates = awmtk2.create_template_lib("xdg_menu",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) -- Add a "loading" indicator while XDG is still parsing data