summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-02-06 08:06:11 -0500
committerB Stack <bgstack15@gmail.com>2020-02-06 08:06:11 -0500
commit4e26d156b01a1054155a275c5bcb30fedfe2506b (patch)
treed1f1e90ceb7663a4b0f68fb2212c0d09e2c3a073
parentadd -h option and example doc for menu separator (diff)
downloadmktrayicon-menu_separator.tar.gz
mktrayicon-menu_separator.tar.bz2
mktrayicon-menu_separator.zip
use empty label in menu spec as a separatormenu_separator
-rw-r--r--README.md5
-rw-r--r--mktrayicon.c2
2 files changed, 4 insertions, 3 deletions
diff --git a/README.md b/README.md
index 84697fd..4af3a7c 100644
--- a/README.md
+++ b/README.md
@@ -50,7 +50,8 @@ The m(enu) command uses `,` as a delimiter between label and command and
`|` as a delimiter between entries (label+command). If you want to use
these two characters in a label or command, you have to escape them with
`\`. You can make a blank label or a label without an action by leaving
-out the `label` or `cmd` respectively. For example:
+out the `label` or `cmd` respectively. Use `-----` or an empty label to
+insert a menu separator. For example:
```console
$ echo "m Browser,firefox|Terminal,xterm|Label-only||,chromium" > /tmp/test
@@ -62,7 +63,7 @@ Would give you a menu with five entries:
- "Browser", which launches `firefox` when clicked
- "Terminal", which launches `xterm` when clicked
- "Label-only", which does nothing if clicked
- - An unlabeled, inactive entry (useful as a separator)
+ - A separator
- An unlabeled entry which launches `chromium` when clicked
## Why?
diff --git a/mktrayicon.c b/mktrayicon.c
index 518eccf..626b299 100644
--- a/mktrayicon.c
+++ b/mktrayicon.c
@@ -397,7 +397,7 @@ outer:
// Now create the menu item widgets and attach them on the menu
for (int i = 0; i < menusize; i++) {
GtkWidget *w;
- if (strncmp(onmenu[i].name, "-----", 5) == 0) {
+ if (0 == strlen(onmenu[i].name) || (!strncmp(onmenu[i].name, "-----", 5))) {
w = gtk_separator_menu_item_new() ;
} else {
w = gtk_menu_item_new_with_label(onmenu[i].name);
bgstack15