Unverified Commit cf7fcaee authored by Gabriele Musco's avatar Gabriele Musco Committed by GitHub

feat: new buttons-per-row property for buttons-grid widget (#576)

parent a831118a
......@@ -471,6 +471,8 @@ config file to be able to detect config errors
type: object ++
css class: widget-buttons (access buttons with >flowbox>flowboxchild>button) ++
properties: ++
buttons-per-row: ++
type: number ++
actions: ++
type: array ++
Default values: [] ++
......
......@@ -79,6 +79,7 @@
"loop-carousel": false
},
"buttons-grid": {
"buttons-per-row": 7,
"actions": [
{
"label": "直",
......
......@@ -434,6 +434,10 @@
"description": "A widget to add a grid of buttons that execute shell commands",
"additionalProperties": false,
"properties": {
"buttons-per-row": {
"type": "number",
"description": "How many buttons should be shown in a buttons-grid row"
},
"actions": {
"type": "array",
"description": "A list of actions containing a label and a command",
......
......@@ -10,6 +10,8 @@ namespace SwayNotificationCenter.Widgets {
}
Action[] actions;
// 7 is the default Gtk.FlowBox.max_children_per_line
int buttons_per_row = 7;
List<ToggleButton> toggle_buttons;
public ButtonsGrid (string suffix, SwayncDaemon swaync_daemon, NotiDaemon noti_daemon) {
......@@ -19,9 +21,14 @@ namespace SwayNotificationCenter.Widgets {
if (config != null) {
Json.Array a = get_prop_array (config, "actions");
if (a != null) actions = parse_actions (a);
bool bpr_found = false;
int bpr = get_prop<int> (config, "buttons-per-row", out bpr_found);
if (bpr_found) buttons_per_row = bpr;
}
Gtk.FlowBox container = new Gtk.FlowBox ();
container.set_max_children_per_line (buttons_per_row);
container.set_selection_mode (Gtk.SelectionMode.NONE);
container.set_hexpand (true);
append (container);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment