Skip to content

Commit

Permalink
feat(launcher): option to reverse order
Browse files Browse the repository at this point in the history
* Add reverse order for launcher items/favorites

* Add lanucher reverse order to docs

* Add example configs for json,toml,yaml,corn

---------

Co-authored-by: SerraPi <[email protected]>
  • Loading branch information
SerraPi and serrapm authored Apr 28, 2024
1 parent 782b955 commit d03c752
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 6 additions & 3 deletions docs/modules/Launcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Optionally displays a launchable set of favourites.
| `show_names` | `boolean` | `false` | Whether to show app names on the button label. Names will still show on tooltips when set to false. |
| `show_icons` | `boolean` | `true` | Whether to show app icons on the button. |
| `icon_size` | `integer` | `32` | Size to render icon at (image icons only). |

| `reversed` | `boolean` | `false` | Whether to reverse the order of favorites/items |
<details>
<summary>JSON</summary>

Expand All @@ -32,7 +32,8 @@ Optionally displays a launchable set of favourites.
"discord"
],
"show_names": false,
"show_icons": true
"show_icons": true,
"reversed": false
}
]
}
Expand All @@ -51,6 +52,7 @@ type = "launcher"
favorites = ["firefox", "discord"]
show_names = false
show_icons = true
reversed = false
```

</details>
Expand All @@ -66,6 +68,7 @@ start:
- discord
show_names: false
show_icons: true
reversed: false
```
</details>
Expand All @@ -81,7 +84,7 @@ start:
favorites = [ "firefox" "discord" ]
show_names = false
show_icons = true

reversed = false
}
]
}
Expand Down
10 changes: 9 additions & 1 deletion src/modules/launcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ pub struct LauncherModule {
#[serde(default = "default_icon_size")]
icon_size: i32,

#[serde(default = "crate::config::default_false")]
reversed: bool,

#[serde(flatten)]
pub common: Option<CommonConfig>,
}
Expand Down Expand Up @@ -338,7 +341,12 @@ impl Module<gtk::Box> for LauncherModule {
&controller_tx,
);

container.add(&button.button);
if self.reversed {
container.pack_end(&button.button, false, false, 0);
} else {
container.add(&button.button);
}

buttons.insert(item.app_id, button);
}
}
Expand Down

0 comments on commit d03c752

Please sign in to comment.