Skip to content

Commit 8281b6d

Browse files
committed
Add -I option to make icons optional
1 parent ee3d8d0 commit 8281b6d

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

Diff for: main.c

+15-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ static bool no_footer;
2121
static bool no_header;
2222
static bool pipemenu;
2323
static bool show_desktop_filename;
24+
static bool show_icons;
2425
static char *terminal_prefix;
2526

2627
static 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);
@@ -312,7 +320,7 @@ main(int argc, char **argv)
312320
int c;
313321
while (1) {
314322
int index = 0;
315-
c = getopt_long(argc, argv, "bdhi:npt:", long_options, &index);
323+
c = getopt_long(argc, argv, "bdhi:Inpt:", long_options, &index);
316324
if (c == -1) {
317325
break;
318326
}
@@ -327,6 +335,9 @@ main(int argc, char **argv)
327335
case 'i':
328336
ignore_init(optarg);
329337
break;
338+
case 'I':
339+
show_icons = true;
340+
break;
330341
case 'n':
331342
no_duplicates = true;
332343
break;

Diff for: t/t1000.t.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int main(void)
2020
setenv("LABWC_MENU_GENERATOR_DEBUG_FIRST_DIR_ONLY", "1", 1);
2121
setenv("LANG", "C", 1);
2222
char command[1000];
23-
snprintf(command, sizeof(command), "./labwc-menu-generator >%s", actual);
23+
snprintf(command, sizeof(command), "./labwc-menu-generator -I >%s", actual);
2424
system(command);
2525
bool pass = test_cmp_files(actual, expect);
2626
if (pass) {

Diff for: t/t1001.t.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int main(void)
2020
setenv("LABWC_MENU_GENERATOR_DEBUG_FIRST_DIR_ONLY", "1", 1);
2121
setenv("LANG", "sv_SE.utf8", 1);
2222
char command[1000];
23-
snprintf(command, sizeof(command), "./labwc-menu-generator >%s", actual);
23+
snprintf(command, sizeof(command), "./labwc-menu-generator -I >%s", actual);
2424
system(command);
2525
bool pass = test_cmp_files(actual, expect);
2626
if (pass) {

0 commit comments

Comments
 (0)