-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update separator functionality #2
base: master
Are you sure you want to change the base?
Conversation
Added AddSeparatorID() which returns the item id. It can be used with the new ShowSeparator() and HideSeparator() methods to manipulate the separator behavior Signed-off-by: GrumpySurfer <[email protected]>
systray_menu_unix.go
Outdated
instance.menuLock.Lock() | ||
defer instance.menuLock.Unlock() | ||
menu, _ := findLayout(int32(parent)) | ||
for _, i := range menu.V2 { | ||
item := i.Value().(*menuLayout) | ||
if item.V0 == int32(id) { | ||
item.V1["visible"] = dbus.MakeVariant(true) | ||
refresh() | ||
return | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is exactly the same as hideSeparator only with the argument to dbus.MakeVariant() differ. Could the code be reused?
systray_menu_unix.go
Outdated
func showSeparator(id uint32, parent uint32) { | ||
instance.menuLock.Lock() | ||
defer instance.menuLock.Unlock() | ||
menu, _ := findLayout(int32(parent)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for this to require menuLock
to be acquired?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lock is used to protect maps inside the menuLayout
object. It is used basically every time the menuLayout
is changed. Do you think we can remove it here?
Signed-off-by: GrumpySurfer <[email protected]>
The systray library provides a way to manage buttons. They can be shown and hidden at runtime. However, this does not apply to menu separators, which cannot be easily hidden. This leads to a situation where you can hide all buttons, but the separators are still visible, which is not a good look.
The intention of this PR is to provide a way to manage separators by returning their ID and using additional methods to show and hide them.