diff options
author | Dmitry Baryshkov <dbaryshkov@gmail.com> | 2020-12-28 05:34:07 +0300 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2020-12-29 15:50:45 -0800 |
commit | 9d50716cf4dc898dc491d624152634f02dec8acb (patch) | |
tree | 09cae7dd6ae6f5d5dee60dc08e889804b1122396 | |
parent | 2e23b42c65549fea323e37863d354420e27fba42 (diff) | |
download | meta-openembedded-9d50716cf4dc898dc491d624152634f02dec8acb.tar.gz |
openbox-xdgmenu: Openbox menu generator
Openbox has an ability to use external programs to generate menu.
Revive and forward port one of the simplest menu generators using XDG
desktop files.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
5 files changed, 263 insertions, 0 deletions
diff --git a/meta-oe/dynamic-layers/gnome-layer/recipes-core/packagegroups/packagegroup-meta-oe.bbappend b/meta-oe/dynamic-layers/gnome-layer/recipes-core/packagegroups/packagegroup-meta-oe.bbappend new file mode 100644 index 000000000..dcd88841f --- /dev/null +++ b/meta-oe/dynamic-layers/gnome-layer/recipes-core/packagegroups/packagegroup-meta-oe.bbappend | |||
@@ -0,0 +1,3 @@ | |||
1 | RDEPENDS_packagegroup-meta-oe-graphics +="\ | ||
2 | openbox-xdgmenu \ | ||
3 | " | ||
diff --git a/meta-oe/dynamic-layers/gnome-layer/recipes-graphics/openbox/openbox-xdgmenu/7_6.diff b/meta-oe/dynamic-layers/gnome-layer/recipes-graphics/openbox/openbox-xdgmenu/7_6.diff new file mode 100644 index 000000000..8ab5386dc --- /dev/null +++ b/meta-oe/dynamic-layers/gnome-layer/recipes-graphics/openbox/openbox-xdgmenu/7_6.diff | |||
@@ -0,0 +1,13 @@ | |||
1 | === modified file 'openbox-xdgmenu.c' | ||
2 | --- openbox-xdgmenu.c 2011-09-03 20:13:39 +0000 | ||
3 | +++ openbox-xdgmenu.c 2013-12-28 17:41:04 +0000 | ||
4 | @@ -235,7 +235,7 @@ | ||
5 | } | ||
6 | |||
7 | g_printf("<item label=\"%s\">\n", g_strjoinv("&", g_strsplit(name,"&",0))), | ||
8 | - g_printf("<action name=\"Execute\"><execute>%s</execute></action>\n", exec), | ||
9 | + g_printf("<action name=\"Execute\"><command>%s</command></action>\n", exec), | ||
10 | g_printf("</item>\n"); | ||
11 | |||
12 | g_free(name); | ||
13 | |||
diff --git a/meta-oe/dynamic-layers/gnome-layer/recipes-graphics/openbox/openbox-xdgmenu/fix-menu-generation.patch b/meta-oe/dynamic-layers/gnome-layer/recipes-graphics/openbox/openbox-xdgmenu/fix-menu-generation.patch new file mode 100644 index 000000000..03b357263 --- /dev/null +++ b/meta-oe/dynamic-layers/gnome-layer/recipes-graphics/openbox/openbox-xdgmenu/fix-menu-generation.patch | |||
@@ -0,0 +1,27 @@ | |||
1 | Index: openbox-xdgmenu-0.3/openbox-xdgmenu.c | ||
2 | =================================================================== | ||
3 | --- openbox-xdgmenu-0.3.orig/openbox-xdgmenu.c | ||
4 | +++ openbox-xdgmenu-0.3/openbox-xdgmenu.c | ||
5 | @@ -197,7 +197,7 @@ void process_entry(GMenuTreeEntry *entry | ||
6 | { | ||
7 | GDesktopAppInfo *appinfo = gmenu_tree_entry_get_app_info (entry); | ||
8 | char *name = g_strdup (g_app_info_get_name(G_APP_INFO(appinfo))); | ||
9 | - char *exec = g_strdup (g_app_info_get_executable(G_APP_INFO(appinfo))); | ||
10 | + char *exec = g_strdup (g_app_info_get_commandline(G_APP_INFO(appinfo))); | ||
11 | int i; | ||
12 | |||
13 | for (i = 0; i < strlen(exec) - 1; i++) { | ||
14 | @@ -217,8 +217,11 @@ void process_entry(GMenuTreeEntry *entry | ||
15 | } | ||
16 | } | ||
17 | |||
18 | - g_printf("<item label=\"%s\">\n", g_strjoinv("&", g_strsplit(name,"&",0))), | ||
19 | - g_printf("<action name=\"Execute\"><command>%s</command></action>\n", exec), | ||
20 | + g_printf("<item label=\"%s\">\n", g_strjoinv("&", g_strsplit(name,"&",0))); | ||
21 | + g_printf("<action name=\"Execute\"><command>%s%s</command></action>\n", | ||
22 | + g_desktop_app_info_get_boolean(appinfo, G_KEY_FILE_DESKTOP_KEY_TERMINAL) ? | ||
23 | + "x-terminal-emulator -e " : "", | ||
24 | + exec); | ||
25 | g_printf("</item>\n"); | ||
26 | |||
27 | g_free(name); | ||
diff --git a/meta-oe/dynamic-layers/gnome-layer/recipes-graphics/openbox/openbox-xdgmenu/port-gnome-menus3.patch b/meta-oe/dynamic-layers/gnome-layer/recipes-graphics/openbox/openbox-xdgmenu/port-gnome-menus3.patch new file mode 100644 index 000000000..3fcc31916 --- /dev/null +++ b/meta-oe/dynamic-layers/gnome-layer/recipes-graphics/openbox/openbox-xdgmenu/port-gnome-menus3.patch | |||
@@ -0,0 +1,184 @@ | |||
1 | Index: openbox-xdgmenu-0.3/openbox-xdgmenu.c | ||
2 | =================================================================== | ||
3 | --- openbox-xdgmenu-0.3.orig/openbox-xdgmenu.c | ||
4 | +++ openbox-xdgmenu-0.3/openbox-xdgmenu.c | ||
5 | @@ -32,7 +32,7 @@ | ||
6 | #include <string.h> | ||
7 | #include <glib.h> | ||
8 | #include <glib/gprintf.h> | ||
9 | -#include <gnome-menus/gmenu-tree.h> | ||
10 | +#include <gnome-menus-3.0/gmenu-tree.h> | ||
11 | |||
12 | /*============================================================================= | ||
13 | * Declarations | ||
14 | @@ -42,7 +42,6 @@ static void process_directory(GMenuTreeD | ||
15 | static void process_entry(GMenuTreeEntry *entry); | ||
16 | static void process_separator(GMenuTreeSeparator *entry); | ||
17 | |||
18 | -gboolean option_show_amount_of_entries = 0; | ||
19 | gboolean option_do_not_use_categories = 0; | ||
20 | |||
21 | /*============================================================================= | ||
22 | @@ -61,11 +60,6 @@ int main (int argc, char **argv) | ||
23 | g_free (xdgfile); | ||
24 | return 0; | ||
25 | } | ||
26 | - else if ((strcmp (argv[i], "--show-amount") == 0) || | ||
27 | - (strcmp (argv[i], "-a") == 0)) | ||
28 | - { | ||
29 | - option_show_amount_of_entries = 1; | ||
30 | - } | ||
31 | else if ((strcmp (argv[i], "--plain") == 0) || | ||
32 | (strcmp (argv[i], "-p") == 0)) | ||
33 | { | ||
34 | @@ -93,16 +87,15 @@ int main (int argc, char **argv) | ||
35 | return 1; | ||
36 | } | ||
37 | |||
38 | - FILE * file; | ||
39 | - if (!(file = fopen(xdgfile, "r"))) | ||
40 | + GMenuTree *menuTree = gmenu_tree_new (xdgfile, GMENU_TREE_FLAGS_NONE ); | ||
41 | + | ||
42 | + GError *error = NULL; | ||
43 | + if (!gmenu_tree_load_sync(menuTree, &error)) | ||
44 | { | ||
45 | - g_printf ("Could not read file \"%s\".\n", xdgfile); | ||
46 | - g_free (xdgfile); | ||
47 | - return 2; | ||
48 | + g_printerr ("Failed to load tree: %s\n", error->message); | ||
49 | + g_clear_error (&error); | ||
50 | + return 3; | ||
51 | } | ||
52 | - fclose(file); | ||
53 | - | ||
54 | - GMenuTree *menuTree = gmenu_tree_lookup (xdgfile, GMENU_TREE_FLAGS_NONE ); | ||
55 | |||
56 | GMenuTreeDirectory *rootDirectory = gmenu_tree_get_root_directory(menuTree); | ||
57 | |||
58 | @@ -129,11 +122,10 @@ void show_help() | ||
59 | g_printf (" openbox-xdgmenu [options] <Xdg menu file>\n"); | ||
60 | g_printf ("\n"); | ||
61 | g_printf ("Options:\n"); | ||
62 | - g_printf (" -a: Show the amount of items in each category next to its name.\n"); | ||
63 | g_printf (" -p: Do not use categories.\n"); | ||
64 | g_printf ("\n"); | ||
65 | g_printf ("For example:\n"); | ||
66 | - g_printf (" openbox-xdgmenu \"/etc/xdg/menus/applications.menu\"\n\n"); | ||
67 | + g_printf (" openbox-xdgmenu \"gnome-applications.menu\"\n\n"); | ||
68 | } | ||
69 | |||
70 | /*============================================================================= | ||
71 | @@ -141,72 +133,61 @@ void show_help() | ||
72 | */ | ||
73 | void process_directory(GMenuTreeDirectory *directory, gboolean isRoot) | ||
74 | { | ||
75 | - int hasSeparator = 0; | ||
76 | + GMenuTreeSeparator *separator = NULL; | ||
77 | int hasMenu = 0; | ||
78 | GMenuTreeItemType entryType; | ||
79 | - GSList *entryList = gmenu_tree_directory_get_contents (directory); | ||
80 | - GSList *l; | ||
81 | - | ||
82 | - if (option_do_not_use_categories == 00 && isRoot == 0 && | ||
83 | - g_slist_length(entryList) > 0) | ||
84 | + GMenuTreeIter *iter = gmenu_tree_directory_iter (directory); | ||
85 | + GMenuTreeItemType next_type; | ||
86 | + | ||
87 | + while ((next_type = gmenu_tree_iter_next (iter)) != GMENU_TREE_ITEM_INVALID) | ||
88 | { | ||
89 | - hasMenu = 1; | ||
90 | - | ||
91 | - if (option_show_amount_of_entries == 1) | ||
92 | + if (option_do_not_use_categories == 00 && isRoot == 0 && hasMenu == 0) | ||
93 | { | ||
94 | + hasMenu = 1; | ||
95 | + | ||
96 | g_printf( | ||
97 | - "<menu id=\"xdg-menu-%s\" label=\"%s (%d)\">\n", | ||
98 | - g_strjoinv("&", g_strsplit(gmenu_tree_directory_get_name(directory),"&",0)), | ||
99 | - g_strjoinv("&", g_strsplit(gmenu_tree_directory_get_name(directory),"&",0)), | ||
100 | - g_slist_length(entryList)); | ||
101 | + "<menu id=\"xdg-menu-%s\" label=\"%s\">\n", | ||
102 | + g_strjoinv("&", g_strsplit(gmenu_tree_directory_get_name(directory),"&",0)), | ||
103 | + g_strjoinv("&", g_strsplit(gmenu_tree_directory_get_name(directory),"&",0))); | ||
104 | } | ||
105 | - else | ||
106 | - { | ||
107 | - g_printf( | ||
108 | - "<menu id=\"xdg-menu-%s\" label=\"%s\">\n", | ||
109 | - g_strjoinv("&", g_strsplit(gmenu_tree_directory_get_name(directory),"&",0)), | ||
110 | - g_strjoinv("&", g_strsplit(gmenu_tree_directory_get_name(directory),"&",0))); | ||
111 | - } | ||
112 | - } | ||
113 | |||
114 | - for (l = entryList; l; l = l->next) | ||
115 | - { | ||
116 | - GMenuTreeItem *item = l->data; | ||
117 | - | ||
118 | - entryType = gmenu_tree_item_get_type (GMENU_TREE_ITEM(item)); | ||
119 | - | ||
120 | - switch (entryType) | ||
121 | + switch (next_type) | ||
122 | { | ||
123 | + case GMENU_TREE_ITEM_INVALID: | ||
124 | + break; | ||
125 | case GMENU_TREE_ITEM_DIRECTORY: | ||
126 | - if (hasSeparator) | ||
127 | + if (separator != NULL) | ||
128 | { | ||
129 | - process_separator(GMENU_TREE_SEPARATOR(item)); | ||
130 | - hasSeparator = 0; | ||
131 | + process_separator(separator); | ||
132 | + gmenu_tree_item_unref (separator); | ||
133 | + separator = NULL; | ||
134 | } | ||
135 | - process_directory(GMENU_TREE_DIRECTORY(item), 0); | ||
136 | + process_directory(gmenu_tree_iter_get_directory(iter), 0); | ||
137 | break; | ||
138 | case GMENU_TREE_ITEM_ENTRY: | ||
139 | - if (hasSeparator) | ||
140 | + if (separator != NULL) | ||
141 | { | ||
142 | - process_separator(GMENU_TREE_SEPARATOR(item)); | ||
143 | - hasSeparator = 0; | ||
144 | + process_separator(separator); | ||
145 | + gmenu_tree_item_unref (separator); | ||
146 | + separator = NULL; | ||
147 | } | ||
148 | - process_entry(GMENU_TREE_ENTRY(item)); | ||
149 | + process_entry(gmenu_tree_iter_get_entry(iter)); | ||
150 | break; | ||
151 | case GMENU_TREE_ITEM_SEPARATOR: | ||
152 | - hasSeparator = 1; | ||
153 | + separator = gmenu_tree_iter_get_separator(iter); | ||
154 | break; | ||
155 | } | ||
156 | - | ||
157 | - gmenu_tree_item_unref (item); | ||
158 | } | ||
159 | |||
160 | if (hasMenu == 1) | ||
161 | { | ||
162 | g_printf("</menu>\n"); | ||
163 | } | ||
164 | + | ||
165 | + if (separator != NULL) | ||
166 | + gmenu_tree_item_unref (separator); | ||
167 | |||
168 | - g_slist_free (entryList); | ||
169 | + gmenu_tree_iter_unref (iter); | ||
170 | } | ||
171 | |||
172 | /*============================================================================= | ||
173 | @@ -214,8 +195,9 @@ void process_directory(GMenuTreeDirector | ||
174 | */ | ||
175 | void process_entry(GMenuTreeEntry *entry) | ||
176 | { | ||
177 | - char *name = g_strdup (gmenu_tree_entry_get_name(entry)); | ||
178 | - char *exec = g_strdup (gmenu_tree_entry_get_exec(entry)); | ||
179 | + GDesktopAppInfo *appinfo = gmenu_tree_entry_get_app_info (entry); | ||
180 | + char *name = g_strdup (g_app_info_get_name(G_APP_INFO(appinfo))); | ||
181 | + char *exec = g_strdup (g_app_info_get_executable(G_APP_INFO(appinfo))); | ||
182 | int i; | ||
183 | |||
184 | for (i = 0; i < strlen(exec) - 1; i++) { | ||
diff --git a/meta-oe/dynamic-layers/gnome-layer/recipes-graphics/openbox/openbox-xdgmenu_0.3.bb b/meta-oe/dynamic-layers/gnome-layer/recipes-graphics/openbox/openbox-xdgmenu_0.3.bb new file mode 100644 index 000000000..237154e29 --- /dev/null +++ b/meta-oe/dynamic-layers/gnome-layer/recipes-graphics/openbox/openbox-xdgmenu_0.3.bb | |||
@@ -0,0 +1,36 @@ | |||
1 | SUMMARY = "Openbox configuration tool" | ||
2 | AUTHOR = "Siegfried Gevatter" | ||
3 | HOMEPAGE = "https://launchpad.net/openbox-xdgmenu/" | ||
4 | SECTION = "x11/wm" | ||
5 | LICENSE = "GPLv3+" | ||
6 | LIC_FILES_CHKSUM = "file://COPYING;md5=f27defe1e96c2e1ecd4e0c9be8967949" | ||
7 | DEPENDS = " \ | ||
8 | gnome-menus3 \ | ||
9 | glib-2.0 \ | ||
10 | " | ||
11 | PV = "0.3" | ||
12 | |||
13 | SRC_URI = " \ | ||
14 | http://launchpad.net/openbox-xdgmenu/trunk/0.3/+download/openbox-xdgmenu-0.3.tar.gz \ | ||
15 | file://7_6.diff;striplevel=0 \ | ||
16 | file://port-gnome-menus3.patch \ | ||
17 | file://fix-menu-generation.patch \ | ||
18 | " | ||
19 | SRC_URI[sha256sum] = "824e099928aab2fb628f0fa4870ef7bba10b95581e47c2d8fa216709a0f399b3" | ||
20 | |||
21 | inherit pkgconfig features_check | ||
22 | # depends on openbox, which is X11-only | ||
23 | REQUIRED_DISTRO_FEATURES = "x11" | ||
24 | |||
25 | EXTRA_OEMAKE = " \ | ||
26 | CC='${CC}' \ | ||
27 | CFLAGS='${CPPFLAGS} ${CFLAGS} `pkg-config --cflags glib-2.0 libgnome-menu-3.0` -DGMENU_I_KNOW_THIS_IS_UNSTABLE' \ | ||
28 | LDFLAGS='${LDFLAGS} `pkg-config --libs glib-2.0 libgnome-menu-3.0`' \ | ||
29 | " | ||
30 | |||
31 | do_install() { | ||
32 | install -d ${D}${bindir} | ||
33 | install -m 0755 openbox-xdgmenu ${D}${bindir} | ||
34 | } | ||
35 | |||
36 | RDEPENDS_${PN} += "virtual/x-terminal-emulator" | ||