1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-22 20:53:44 +02:00

eeshow/gui.c: get only list of file names from main, parse on its own

This commit is contained in:
Werner Almesberger 2016-08-05 10:24:39 -03:00
parent ba95c01249
commit 5f0678097f
3 changed files with 40 additions and 8 deletions

View File

@ -599,7 +599,27 @@ static void get_git(struct gui_ctx *ctx, const char *sch_name)
}
int gui(const struct sheet *sheets, const char *sch_name)
static struct sheet *parse_sheets(int n_args, char **args, bool recurse)
{
struct lib lib;
struct sch_ctx sch_ctx;
struct file sch_file;
int i;
sch_init(&sch_ctx, recurse);
file_open(&sch_file, args[n_args - 1], NULL);
lib_init(&lib);
for (i = 0; i != n_args - 1; i++)
lib_parse(&lib, args[i], &sch_file);
sch_parse(&sch_ctx, &sch_file, &lib);
file_close(&sch_file);
return sch_ctx.sheets;
}
int gui(unsigned n_args, char **args, bool recurse)
{
GtkWidget *window;
struct gui_ctx ctx = {
@ -612,8 +632,8 @@ int gui(const struct sheet *sheets, const char *sch_name)
.aois = NULL,
};
get_sheets(&ctx, sheets);
get_git(&ctx, sch_name);
get_sheets(&ctx, parse_sheets(n_args, args, recurse));
get_git(&ctx, args[n_args - 1]);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

View File

@ -13,9 +13,13 @@
#ifndef GUI_H
#define GUI_H
#include "sch.h"
#include <stdbool.h>
/*
* Note: this isn't (argc, argv) ! args stars right with the first file name
* and there is no NULL at the end.
*/
int gui(const struct sheet *sheets, const char *sch_name);
int gui(unsigned n_args, char **args, bool recurse);
#endif /* !GUI_H */

View File

@ -146,6 +146,17 @@ int main(int argc, char **argv)
if (dashdash - optind < 1)
usage(*argv);
if (!have_dashdash) {
unsigned n = argc - optind;
char **args;
args = alloc_size(sizeof(char *) * n);
memcpy(args, argv + optind, sizeof(const char *) * n);
optind = 0; /* reset getopt */
return gui(n, args, recurse);
}
sch_init(&sch_ctx, recurse);
file_open(&sch_file, argv[dashdash - 1], NULL);
@ -181,9 +192,6 @@ found:
sch_parse(&sch_ctx, &sch_file, &lib);
file_close(&sch_file);
if (!have_dashdash)
return gui(sch_ctx.sheets, argv[dashdash - 1]);
gfx_init(*ops, gfx_argc, gfx_argv);
if (recurse) {
const struct sheet *sheet;