mirror of
https://github.com/ErikReider/SwayNotificationCenter.git
synced 2024-09-11 15:56:04 +03:00
Fix togglebutton in menu dropdown (#339)
* Fix togglebutton in menu dropdown * Minor bugfixes and fix typo in readme
This commit is contained in:
parent
2f5253b72b
commit
ab46163f1e
@ -247,8 +247,8 @@ window that'll allow you to see all of the CSS classes + other information.
|
||||
|
||||
To add toggle buttons to your control center you can set the "type" in any acton to "toggle".
|
||||
The toggle button supports different commands depending on the state of the button and
|
||||
an "update_command" to update the state in case of changes from outside swaync. The update_command
|
||||
is called every time the control center is opened/closed.
|
||||
an "update-command" to update the state in case of changes from outside swaync. The update-command
|
||||
is called every time the control center is opened.
|
||||
The active toggle button also gains the css-class ".toggle:checked"
|
||||
|
||||
`config.json` example:
|
||||
@ -262,7 +262,7 @@ The active toggle button also gains the css-class ".toggle:checked"
|
||||
"type": "toggle",
|
||||
"active": true,
|
||||
"command": "sh -c '[[ $SWAYNC_TOGGLE_STATE == true ]] && nmcli radio wifi on || nmcli radio wifi off'",
|
||||
"update_command": "sh -c '[[ $(nmcli radio wifi) == \"enabled\" ]] && echo true || echo false'"
|
||||
"update-command": "sh -c '[[ $(nmcli radio wifi) == \"enabled\" ]] && echo true || echo false'"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ namespace SwayNotificationCenter.Widgets {
|
||||
}
|
||||
|
||||
public override void on_cc_visibility_change (bool value) {
|
||||
if (!value) {
|
||||
if (value) {
|
||||
foreach (var tb in toggle_buttons) {
|
||||
tb.on_update.begin ();
|
||||
}
|
||||
|
@ -121,9 +121,18 @@ namespace SwayNotificationCenter.Widgets {
|
||||
});
|
||||
|
||||
foreach (var a in obj.actions) {
|
||||
Gtk.Button b = new Gtk.Button.with_label (a.label);
|
||||
b.clicked.connect (() => execute_command.begin (a.command));
|
||||
menu.pack_start (b, true, true, 0);
|
||||
switch (a.type) {
|
||||
case ButtonType.TOGGLE:
|
||||
ToggleButton tb = new ToggleButton (a.label, a.command, a.update_command, a.active);
|
||||
menu.pack_start (tb, true, true, 0);
|
||||
toggle_buttons.append (tb);
|
||||
break;
|
||||
default:
|
||||
Gtk.Button b = new Gtk.Button.with_label (a.label);
|
||||
b.clicked.connect (() => execute_command.begin (a.command));
|
||||
menu.pack_start (b, true, true, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (obj.position) {
|
||||
@ -221,6 +230,7 @@ namespace SwayNotificationCenter.Widgets {
|
||||
foreach (var obj in menu_objects) {
|
||||
obj.revealer ?.set_reveal_child (false);
|
||||
}
|
||||
} else {
|
||||
foreach (var tb in toggle_buttons) {
|
||||
tb.on_update.begin ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user