Skip to content

Commit

Permalink
Merge pull request #3247 from benjamin-voisin/menu
Browse files Browse the repository at this point in the history
Adding the ability to have dropdown menu for modules
  • Loading branch information
Alexays authored Jul 1, 2024
2 parents 64f54e1 + 885290d commit 9c7a275
Show file tree
Hide file tree
Showing 35 changed files with 611 additions and 2 deletions.
4 changes: 4 additions & 0 deletions include/ALabel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class ALabel : public AModule {

bool handleToggle(GdkEventButton *const &e) override;
virtual std::string getState(uint8_t value, bool lesser = false);

std::map<std::string, GtkMenuItem *> submenus_;
std::map<std::string, std::string> menuActionsMap_;
static void handleGtkMenuEvent(GtkMenuItem *menuitem, gpointer data);
};

} // namespace waybar
2 changes: 2 additions & 0 deletions include/AModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <glibmm/dispatcher.h>
#include <glibmm/markup.h>
#include <gtkmm.h>
#include <gtkmm/eventbox.h>
#include <json/json.h>

Expand Down Expand Up @@ -44,6 +45,7 @@ class AModule : public IModule {
virtual bool handleMouseLeave(GdkEventCrossing *const &ev);
virtual bool handleScroll(GdkEventScroll *);
virtual bool handleRelease(GdkEventButton *const &ev);
GObject *menu_;

private:
bool handleUserEvent(GdkEventButton *const &ev);
Expand Down
13 changes: 13 additions & 0 deletions man/waybar-backlight.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ The *backlight* module displays the current backlight level.
default: 1.0 ++
The speed at which to change the brightness when scrolling.

*menu*: ++
typeof: string ++
Action that popups the menu.

*menu-file*: ++
typeof: string ++
Location of the menu descriptor file. There need to be an element of type
GtkMenu with id *menu*

*menu-actions*: ++
typeof: array ++
The actions corresponding to the buttons of the menu.

# EXAMPLE:

```
Expand Down
13 changes: 13 additions & 0 deletions man/waybar-battery.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ The *battery* module displays the current capacity and state (eg. charging) of y
default: false ++
Option to enable battery compatibility if not detected.

*menu*: ++
typeof: string ++
Action that popups the menu.

*menu-file*: ++
typeof: string ++
Location of the menu descriptor file. There need to be an element of type
GtkMenu with id *menu*

*menu-actions*: ++
typeof: array ++
The actions corresponding to the buttons of the menu.

# FORMAT REPLACEMENTS

*{capacity}*: Capacity in percentage
Expand Down
13 changes: 13 additions & 0 deletions man/waybar-bluetooth.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@ Addressed by *bluetooth*
typeof: string ++
This format is used to define how each connected device should be displayed within the *device_enumerate* format replacement in the tooltip menu.

*menu*: ++
typeof: string ++
Action that popups the menu.

*menu-file*: ++
typeof: string ++
Location of the menu descriptor file. There need to be an element of type
GtkMenu with id *menu*

*menu-actions*: ++
typeof: array ++
The actions corresponding to the buttons of the menu.

# FORMAT REPLACEMENTS

*{status}*: Status of the bluetooth device.
Expand Down
12 changes: 12 additions & 0 deletions man/waybar-cava.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ libcava lives in:
:[ string
:[ /dev/stdout
:[ It's impossible to set it. Waybar sets it to = /dev/stdout for internal needs
|[ *menu*
:[ string
:[
:[ Action that popups the menu.
|[ *menu-file*
:[ string
:[
:[ Location of the menu descriptor file. There need to be an element of type GtkMenu with id *menu*
|[ *menu-actions*
:[ array
:[
:[ The actions corresponding to the buttons of the menu.

Configuration can be provided as:
- The only cava configuration file which is provided through *cava_config*. The rest configuration can be skipped
Expand Down
12 changes: 12 additions & 0 deletions man/waybar-clock.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ $XDG_CONFIG_HOME/waybar/config ++
:[ string
:[ same as format
:[ Tooltip on hover
|[ *menu*
:[ string
:[
:[ Action that popups the menu.
|[ *menu-file*
:[ string
:[
:[ Location of the menu descriptor file. There need to be an element of type GtkMenu with id *menu*
|[ *menu-actions*
:[ array
:[
:[ The actions corresponding to the buttons of the menu.

View all valid format options in *strftime(3)* or have a look https://en.cppreference.com/w/cpp/chrono/duration/formatter

Expand Down
13 changes: 13 additions & 0 deletions man/waybar-custom.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ Addressed by *custom/<name>*
default: false ++
Option to enable escaping of script output.

*menu*: ++
typeof: string ++
Action that popups the menu.

*menu-file*: ++
typeof: string ++
Location of the menu descriptor file. There need to be an element of type
GtkMenu with id *menu*

*menu-actions*: ++
typeof: array ++
The actions corresponding to the buttons of the menu.

# RETURN-TYPE

When *return-type* is set to *json*, Waybar expects the *exec*-script to output its data in JSON format.
Expand Down
13 changes: 13 additions & 0 deletions man/waybar-disk.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ Addressed by *disk*
typeof: string ++
Use with specific_free, specific_used, and specific_total to force calculation to always be in a certain unit. Accepts kB, kiB, MB, Mib, GB, GiB, TB, TiB.

*menu*: ++
typeof: string ++
Action that popups the menu.

*menu-file*: ++
typeof: string ++
Location of the menu descriptor file. There need to be an element of type
GtkMenu with id *menu*

*menu-actions*: ++
typeof: array ++
The actions corresponding to the buttons of the menu.

# FORMAT REPLACEMENTS

*{percentage_used}*: Percentage of disk in use.
Expand Down
13 changes: 13 additions & 0 deletions man/waybar-hyprland-language.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ Addressed by *hyprland/language*
typeof: string ++
Specifies which keyboard to use from hyprctl devices output. Using the option that begins with "at-translated-set..." is recommended.

*menu*: ++
typeof: string ++
Action that popups the menu.

*menu-file*: ++
typeof: string ++
Location of the menu descriptor file. There need to be an element of type
GtkMenu with id *menu*

*menu-actions*: ++
typeof: array ++
The actions corresponding to the buttons of the menu.


# FORMAT REPLACEMENTS

Expand Down
13 changes: 13 additions & 0 deletions man/waybar-hyprland-submap.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ Addressed by *hyprland/submap*
default: Default ++
Option to set the submap name to display when not in an active submap.

*menu*: ++
typeof: string ++
Action that popups the menu.

*menu-file*: ++
typeof: string ++
Location of the menu descriptor file. There need to be an element of type
GtkMenu with id *menu*

*menu-actions*: ++
typeof: array ++
The actions corresponding to the buttons of the menu.


# EXAMPLES

Expand Down
13 changes: 13 additions & 0 deletions man/waybar-idle-inhibitor.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ screensaver, also known as "presentation mode".
typeof: string ++
This format is used when the inhibit is deactivated.

*menu*: ++
typeof: string ++
Action that popups the menu. Cannot be "on-click".

*menu-file*: ++
typeof: string ++
Location of the menu descriptor file. There need to be an element of type
GtkMenu with id *menu*

*menu-actions*: ++
typeof: array ++
The actions corresponding to the buttons of the menu.

# FORMAT REPLACEMENTS

*{status}*: status (*activated* or *deactivated*)
Expand Down
13 changes: 13 additions & 0 deletions man/waybar-inhibitor.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ See *systemd-inhibit*(1) for more information.
default: true ++
Option to disable tooltip on hover.

*menu*: ++
typeof: string ++
Action that popups the menu. Cannot be "on-click".

*menu-file*: ++
typeof: string ++
Location of the menu descriptor file. There need to be an element of type
GtkMenu with id *menu*

*menu-actions*: ++
typeof: array ++
The actions corresponding to the buttons of the menu.

# FORMAT REPLACEMENTS

*{status}*: status (*activated* or *deactivated*)
Expand Down
13 changes: 13 additions & 0 deletions man/waybar-jack.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ Addressed by *jack*
typeof: string ++
Command to execute when the module is updated.

*menu*: ++
typeof: string ++
Action that popups the menu.

*menu-file*: ++
typeof: string ++
Location of the menu descriptor file. There need to be an element of type
GtkMenu with id *menu*

*menu-actions*: ++
typeof: array ++
The actions corresponding to the buttons of the menu.

# FORMAT REPLACEMENTS

*{load}*: The current CPU load estimated by JACK.
Expand Down
13 changes: 13 additions & 0 deletions man/waybar-memory.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ Addressed by *memory*
default: true ++
Option to disable tooltip on hover.

*menu*: ++
typeof: string ++
Action that popups the menu.

*menu-file*: ++
typeof: string ++
Location of the menu descriptor file. There need to be an element of type
GtkMenu with id *menu*

*menu-actions*: ++
typeof: array ++
The actions corresponding to the buttons of the menu.

# FORMAT REPLACEMENTS

*{percentage}*: Percentage of memory in use.
Expand Down
Loading

0 comments on commit 9c7a275

Please sign in to comment.