Elv13 / radical

An extensible menu subsystem for Awesome WM
222 stars 16 forks source link

Change arrow image for sub menus #50

Open deb75 opened 5 years ago

deb75 commented 5 years ago

Hi,

I would like to change the arrow image which appears when a sub_menu is defined within one item.

It appears that radical uses menu_submenu_icon property of beautiful.

Currently the only way I found to customize the arrow image is to replace :

sub_arrow:set_image( beautiful.menu_submenu_icon   )

by

sub_arrow:set_image( "/home/edouard/.config/awesome/browser/submenu2.png"  )

in item/layout/horizontal.lua radical file.

Would there be an easier way ? How could I add this property to the item ? (like the icon one)

Regards

deb75 commented 5 years ago

Answeering to my own post, I suggest this modification :

diff --git a/item/init.lua b/item/init.lua
index 6767c71..3f01611 100644
--- a/item/init.lua
+++ b/item/init.lua
@@ -114,6 +114,7 @@ local function new_item(data,args)
       bg_prefix   = args.bg_prefix   or data.bg_prefix                                                  
       sub_menu_m  = (args.sub_menu   and type(args.sub_menu) == "table" and args.sub_menu.is_menu) and a
       sub_menu_f  = (args.sub_menu   and type(args.sub_menu) == "function") and args.sub_menu or nil    
+      submenu_icon  = args.submenu_icon or nil                                                          
       checkable   = args.checkable   or (args.checked ~= nil) or false                                  

and

diff --git a/item/layout/horizontal.lua b/item/layout/horizontal.lua
index 2102985..7003bed 100644
--- a/item/layout/horizontal.lua
+++ b/item/layout/horizontal.lua
@@ -21,8 +21,10 @@ function module:setup_sub_menu_arrow(item,data)
         return (sub_arrow._private.image and sub_arrow._private.image:get_width() or 0),item.height
       end

-      if beautiful.menu_submenu_icon then
-        sub_arrow:set_image( beautiful.menu_submenu_icon   )
+      if item._private_data.submenu_icon then
+         sub_arrow:set_image( item._private_data.submenu_icon   )
+      elseif beautiful.menu_submenu_icon then
+         sub_arrow:set_image( beautiful.menu_submenu_icon   )
       else
         local h = data.item_height

which lets the user customize the image for the sub arrow of sub menus.

Elv13 commented 5 years ago

can you submit a pull request for this?