diff --git a/main.c b/main.c index 4821794..c1785da 100644 --- a/main.c +++ b/main.c @@ -21,6 +21,7 @@ static bool no_footer; static bool no_header; static bool pipemenu; static bool show_desktop_filename; +static bool show_icons; static char *terminal_prefix; static const struct option long_options[] = { @@ -28,6 +29,7 @@ static const struct option long_options[] = { {"desktop", no_argument, NULL, 'd'}, {"help", no_argument, NULL, 'h'}, {"ignore", required_argument, NULL, 'i'}, + {"icons", no_argument, NULL, 'I'}, {"no-duplicates", no_argument, NULL, 'n'}, {"pipemenu", no_argument, NULL, 'p'}, {"terminal-prefix", required_argument, NULL, 't'}, @@ -40,6 +42,7 @@ static const char labwc_menu_generator_usage[] = " -d, --desktop Add .desktop filename as a comment in the XML output\n" " -h, --help Show help message and quit\n" " -i, --ignore Specify file listing .desktop files to ignore\n" +" -I, --icons Add icon=\"\" attribute\n" " -n, --no-duplicates Limit desktop entries to one directory only\n" " -p, --pipemenu Output in pipemenu format\n" " -t, --terminal-prefix Specify prefix for Terminal=true entries\n"; @@ -86,9 +89,14 @@ print_app_to_buffer(struct app *app, GString *submenu) exit(EXIT_FAILURE); } - g_string_append_printf(submenu, - " \n", - app->name_localized ? app->name_localized : app->name, app->icon); + g_string_append_printf(submenu, " name_localized ? app->name_localized : app->name); + if (show_icons) { + g_string_append_printf(submenu, " icon=\"%s\"", app->icon); + } + g_string_append_printf(submenu, ">\n"); + + g_string_append_printf(submenu, " %s\n", command); @@ -197,8 +205,13 @@ print_menu(GList *dirs, GList *apps) if (!submenu->len) { continue; } - printf(" \n", - dir->name, dir->name_localized ? : dir->name, dir->icon); + + printf(" name, dir->name_localized ? : dir->name); + if (show_icons) { + printf(" icon=\"%s\"", dir->icon); + } + printf(">\n"); + printf("%s", submenu->str); printf(" \n", dir->name); } @@ -312,7 +325,7 @@ main(int argc, char **argv) int c; while (1) { int index = 0; - c = getopt_long(argc, argv, "bdhi:npt:", long_options, &index); + c = getopt_long(argc, argv, "bdhi:Inpt:", long_options, &index); if (c == -1) { break; } @@ -327,6 +340,9 @@ main(int argc, char **argv) case 'i': ignore_init(optarg); break; + case 'I': + show_icons = true; + break; case 'n': no_duplicates = true; break; diff --git a/t/t1000.t.c b/t/t1000.t.c index a4dd818..be63e7e 100644 --- a/t/t1000.t.c +++ b/t/t1000.t.c @@ -20,7 +20,7 @@ int main(void) setenv("LABWC_MENU_GENERATOR_DEBUG_FIRST_DIR_ONLY", "1", 1); setenv("LANG", "C", 1); char command[1000]; - snprintf(command, sizeof(command), "./labwc-menu-generator >%s", actual); + snprintf(command, sizeof(command), "./labwc-menu-generator -I >%s", actual); system(command); bool pass = test_cmp_files(actual, expect); if (pass) { diff --git a/t/t1001.t.c b/t/t1001.t.c index 1beee28..a2dcbf2 100644 --- a/t/t1001.t.c +++ b/t/t1001.t.c @@ -20,7 +20,7 @@ int main(void) setenv("LABWC_MENU_GENERATOR_DEBUG_FIRST_DIR_ONLY", "1", 1); setenv("LANG", "sv_SE.utf8", 1); char command[1000]; - snprintf(command, sizeof(command), "./labwc-menu-generator >%s", actual); + snprintf(command, sizeof(command), "./labwc-menu-generator -I >%s", actual); system(command); bool pass = test_cmp_files(actual, expect); if (pass) {