@@ -21,13 +21,15 @@ static bool no_footer;
2121static bool no_header ;
2222static bool pipemenu ;
2323static bool show_desktop_filename ;
24+ static bool show_icons ;
2425static char * terminal_prefix ;
2526
2627static const struct option long_options [] = {
2728 {"bare" , no_argument , NULL , 'b' },
2829 {"desktop" , no_argument , NULL , 'd' },
2930 {"help" , no_argument , NULL , 'h' },
3031 {"ignore" , required_argument , NULL , 'i' },
32+ {"icons" , no_argument , NULL , 'I' },
3133 {"no-duplicates" , no_argument , NULL , 'n' },
3234 {"pipemenu" , no_argument , NULL , 'p' },
3335 {"terminal-prefix" , required_argument , NULL , 't' },
@@ -40,6 +42,7 @@ static const char labwc_menu_generator_usage[] =
4042" -d, --desktop Add .desktop filename as a comment in the XML output\n"
4143" -h, --help Show help message and quit\n"
4244" -i, --ignore <file> Specify file listing .desktop files to ignore\n"
45+ " -I, --icons Add icon=\"\" attribute\n"
4346" -n, --no-duplicates Limit desktop entries to one directory only\n"
4447" -p, --pipemenu Output in pipemenu format\n"
4548" -t, --terminal-prefix Specify prefix for Terminal=true entries\n" ;
@@ -86,9 +89,14 @@ print_app_to_buffer(struct app *app, GString *submenu)
8689 exit (EXIT_FAILURE );
8790 }
8891
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+
92100 g_string_append_printf (submenu ,
93101 " <action name=\"Execute\"><command>%s</command></action>\n" ,
94102 command );
@@ -197,8 +205,13 @@ print_menu(GList *dirs, GList *apps)
197205 if (!submenu -> len ) {
198206 continue ;
199207 }
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+
202215 printf ("%s" , submenu -> str );
203216 printf (" </menu> <!-- %s -->\n" , dir -> name );
204217 }
@@ -312,7 +325,7 @@ main(int argc, char **argv)
312325 int c ;
313326 while (1 ) {
314327 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 );
316329 if (c == -1 ) {
317330 break ;
318331 }
@@ -327,6 +340,9 @@ main(int argc, char **argv)
327340 case 'i' :
328341 ignore_init (optarg );
329342 break ;
343+ case 'I' :
344+ show_icons = true;
345+ break ;
330346 case 'n' :
331347 no_duplicates = true;
332348 break ;
0 commit comments