mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-23 06:02:48 +02:00
eeshow/gui.c: get only list of file names from main, parse on its own
This commit is contained in:
parent
ba95c01249
commit
5f0678097f
26
eeshow/gui.c
26
eeshow/gui.c
@ -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;
|
GtkWidget *window;
|
||||||
struct gui_ctx ctx = {
|
struct gui_ctx ctx = {
|
||||||
@ -612,8 +632,8 @@ int gui(const struct sheet *sheets, const char *sch_name)
|
|||||||
.aois = NULL,
|
.aois = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
get_sheets(&ctx, sheets);
|
get_sheets(&ctx, parse_sheets(n_args, args, recurse));
|
||||||
get_git(&ctx, sch_name);
|
get_git(&ctx, args[n_args - 1]);
|
||||||
|
|
||||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
|
|
||||||
|
@ -13,9 +13,13 @@
|
|||||||
#ifndef GUI_H
|
#ifndef GUI_H
|
||||||
#define 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 */
|
#endif /* !GUI_H */
|
||||||
|
@ -146,6 +146,17 @@ int main(int argc, char **argv)
|
|||||||
if (dashdash - optind < 1)
|
if (dashdash - optind < 1)
|
||||||
usage(*argv);
|
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);
|
sch_init(&sch_ctx, recurse);
|
||||||
file_open(&sch_file, argv[dashdash - 1], NULL);
|
file_open(&sch_file, argv[dashdash - 1], NULL);
|
||||||
|
|
||||||
@ -181,9 +192,6 @@ found:
|
|||||||
sch_parse(&sch_ctx, &sch_file, &lib);
|
sch_parse(&sch_ctx, &sch_file, &lib);
|
||||||
file_close(&sch_file);
|
file_close(&sch_file);
|
||||||
|
|
||||||
if (!have_dashdash)
|
|
||||||
return gui(sch_ctx.sheets, argv[dashdash - 1]);
|
|
||||||
|
|
||||||
gfx_init(*ops, gfx_argc, gfx_argv);
|
gfx_init(*ops, gfx_argc, gfx_argv);
|
||||||
if (recurse) {
|
if (recurse) {
|
||||||
const struct sheet *sheet;
|
const struct sheet *sheet;
|
||||||
|
Loading…
Reference in New Issue
Block a user