}
char *pathval = g_key_file_get_string(conf, entries[i], "path", NULL);
char *nameval = g_key_file_get_string(conf, entries[i], "name", NULL);
+ int hideval = g_key_file_get_boolean(conf, entries[i], "hide", NULL);
if (pathval) next->path = pathval;
if (nameval) next->name = nameval;
if (!next->path) next->path = g_strdup(entries[i]);
if (!next->name) next->name = g_strdup(entries[i]);
+ if (hideval)
+ next->show = SHOW_HIDDEN;
+ if (!parts[0] && !strcmp(next->base, "index"))
+ next->show = SHOW_ACTIVE;
cur = cur->next = next;
}
g_strfreev(entries);
continue;
if ((next = get_menu_entry(prefix, entries[i])))
cur = cur->next = next;
+ if (!strcmp(cur->base, "index"))
+ cur->show = SHOW_HIDDEN;
}
g_strfreev(entries);
g_key_file_free(conf);
cur->kids = get_menu_rec(cur->path, parts+1);
cur->show = SHOW_ACTIVE;
}
- if (!strcmp(cur->base, "index"))
- cur->show = SHOW_HIDDEN;
}
error:
#endif
}
+int get_slashes(char *path)
+{
+ int slashes = 0;
+ for (int i = 0; path[i]; i++) {
+ if (path[i] == '/')
+ slashes += 1;
+ if (path[i] != '/' && !path[i+1])
+ slashes *= -1;
+ }
+ return slashes;
+}
+
void print_menu(menu_t *menu, int first, int last)
{
for (menu_t *cur = menu; cur; cur = cur->next) {
- if (cur->show == SHOW_HIDDEN)
- continue;
- if (first <= 0)
+ if (first <= 0 && cur->show != SHOW_HIDDEN)
print_link(cur->path, cur->name,
- cur->show == SHOW_ACTIVE);
- if (cur->kids && last != 0)
+ cur->show == SHOW_ACTIVE,
+ get_slashes(cur->path));
+ if (cur->kids && last != 0) {
+ if (first == 0)
+ print_menu_start();
print_menu(cur->kids, first-1, last-1);
+ if (first == 0)
+ print_menu_end();
+ }
}
}