@@ -21,13 +21,15 @@ static bool no_footer;
21
21
static bool no_header ;
22
22
static bool pipemenu ;
23
23
static bool show_desktop_filename ;
24
+ static bool show_icons ;
24
25
static char * terminal_prefix ;
25
26
26
27
static const struct option long_options [] = {
27
28
{"bare" , no_argument , NULL , 'b' },
28
29
{"desktop" , no_argument , NULL , 'd' },
29
30
{"help" , no_argument , NULL , 'h' },
30
31
{"ignore" , required_argument , NULL , 'i' },
32
+ {"icons" , no_argument , NULL , 'I' },
31
33
{"no-duplicates" , no_argument , NULL , 'n' },
32
34
{"pipemenu" , no_argument , NULL , 'p' },
33
35
{"terminal-prefix" , required_argument , NULL , 't' },
@@ -40,6 +42,7 @@ static const char labwc_menu_generator_usage[] =
40
42
" -d, --desktop Add .desktop filename as a comment in the XML output\n"
41
43
" -h, --help Show help message and quit\n"
42
44
" -i, --ignore <file> Specify file listing .desktop files to ignore\n"
45
+ " -I, --icons Add icon=\"\" attribute\n"
43
46
" -n, --no-duplicates Limit desktop entries to one directory only\n"
44
47
" -p, --pipemenu Output in pipemenu format\n"
45
48
" -t, --terminal-prefix Specify prefix for Terminal=true entries\n" ;
@@ -86,9 +89,14 @@ print_app_to_buffer(struct app *app, GString *submenu)
86
89
exit (EXIT_FAILURE );
87
90
}
88
91
89
- g_string_append_printf (submenu ,
90
- " <item label=\"%s\" icon=\"%s\">\n" ,
91
- app -> name_localized ? app -> name_localized : app -> name , app -> icon );
92
+ g_string_append_printf (submenu , " <item label=\"%s\"" ,
93
+ app -> name_localized ? app -> name_localized : app -> name );
94
+ if (show_icons ) {
95
+ g_string_append_printf (submenu , " icon=\"%s\"" , app -> icon );
96
+ }
97
+ g_string_append_printf (submenu , ">\n" );
98
+
99
+
92
100
g_string_append_printf (submenu ,
93
101
" <action name=\"Execute\"><command>%s</command></action>\n" ,
94
102
command );
@@ -197,8 +205,13 @@ print_menu(GList *dirs, GList *apps)
197
205
if (!submenu -> len ) {
198
206
continue ;
199
207
}
200
- printf (" <menu id=\"%s\" label=\"%s\" icon=\"%s\">\n" ,
201
- dir -> name , dir -> name_localized ? : dir -> name , dir -> icon );
208
+
209
+ printf (" <menu id=\"%s\" label=\"%s\"" , dir -> name , dir -> name_localized ? : dir -> name );
210
+ if (show_icons ) {
211
+ printf (" icon=\"%s\"" , dir -> icon );
212
+ }
213
+ printf (">\n" );
214
+
202
215
printf ("%s" , submenu -> str );
203
216
printf (" </menu> <!-- %s -->\n" , dir -> name );
204
217
}
@@ -312,7 +325,7 @@ main(int argc, char **argv)
312
325
int c ;
313
326
while (1 ) {
314
327
int index = 0 ;
315
- c = getopt_long (argc , argv , "bdhi:npt :" , long_options , & index );
328
+ c = getopt_long (argc , argv , "bdhi:Inpt :" , long_options , & index );
316
329
if (c == -1 ) {
317
330
break ;
318
331
}
@@ -327,6 +340,9 @@ main(int argc, char **argv)
327
340
case 'i' :
328
341
ignore_init (optarg );
329
342
break ;
343
+ case 'I' :
344
+ show_icons = true;
345
+ break ;
330
346
case 'n' :
331
347
no_duplicates = true;
332
348
break ;
0 commit comments