static void preview_init (GschemPreview *preview) { struct event_reg_t { gchar *detailed_signal; GCallback c_handler; } drawing_area_events[] = { { "realize", G_CALLBACK (preview_callback_realize) }, { "expose_event", G_CALLBACK (x_event_expose) }, { "button_press_event", G_CALLBACK (preview_callback_button_press) }, { "configure_event", G_CALLBACK (x_event_configure) }, { "scroll_event", G_CALLBACK (preview_event_scroll) }, { NULL, NULL } }, *tmp; GschemToplevel *preview_w_current; preview_w_current = gschem_toplevel_new (); gschem_toplevel_set_toplevel (preview_w_current, s_toplevel_new ()); preview_w_current->toplevel->load_newer_backup_func = x_fileselect_load_backup; preview_w_current->toplevel->load_newer_backup_data = preview_w_current; o_text_set_rendered_bounds_func (preview_w_current->toplevel, o_text_get_rendered_bounds, preview_w_current); i_vars_set (preview_w_current); /* be sure to turn off scrollbars */ preview_w_current->scrollbars_flag = FALSE; /* be sure to turn off the grid */ gschem_options_set_grid_mode (preview_w_current->options, GRID_MODE_NONE); /* preview_w_current windows don't have toolbars */ preview_w_current->handleboxes = FALSE; preview_w_current->toolbars = FALSE; preview_w_current->drawing_area = GTK_WIDGET (preview); preview->preview_w_current = preview_w_current; preview->active = FALSE; preview->filename = NULL; preview->buffer = NULL; GSCHEM_PAGE_VIEW (preview)->page = s_page_new (preview->preview_w_current->toplevel, "preview"); gtk_widget_set_events (GTK_WIDGET (preview), GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK); for (tmp = drawing_area_events; tmp->detailed_signal != NULL; tmp++) { g_signal_connect (GTK_WIDGET (preview), tmp->detailed_signal, tmp->c_handler, preview_w_current); } }
void ruby_toplevel_init(void) { VALUE argv0; argv0 = rb_gv_get("$0"); toplevel = s_toplevel_new(); g_rc_parse(toplevel, StringValueCStr(argv0), "grubyrc", NULL); i_vars_libgeda_set(toplevel); }
/*! \brief Creates a new X window. * * \par Function description * * Creates and initializes new GschemToplevel object and then sets * and setups its libgeda \a toplevel. * * \param toplevel The libgeda TOPLEVEL object. * \return Pointer to the new GschemToplevel object. */ GschemToplevel* x_window_new (TOPLEVEL *toplevel) { GschemToplevel *w_current; w_current = gschem_toplevel_new (); gschem_toplevel_set_toplevel (w_current, (toplevel != NULL) ? toplevel : s_toplevel_new ()); gschem_toplevel_get_toplevel (w_current)->load_newer_backup_func = x_fileselect_load_backup; gschem_toplevel_get_toplevel (w_current)->load_newer_backup_data = w_current; o_text_set_rendered_bounds_func (gschem_toplevel_get_toplevel (w_current), o_text_get_rendered_bounds, w_current); /* Damage notifications should invalidate the object on screen */ o_add_change_notify (gschem_toplevel_get_toplevel (w_current), (ChangeNotifyFunc) o_invalidate, (ChangeNotifyFunc) o_invalidate, w_current); x_window_setup (w_current); return w_current; }
static void cmd_export_impl (void *data, int argc, char **argv) { int i; GError *err = NULL; gchar *tmp; const gchar *out_suffix; struct ExportFormat *exporter = NULL; GArray *render_color_map = NULL; gchar *original_cwd = g_get_current_dir (); gtk_init_check (&argc, &argv); scm_init_guile (); libgeda_init (); scm_dynwind_begin (0); toplevel = s_toplevel_new (); edascm_dynwind_toplevel (toplevel); /* Now load rc files, if necessary */ if (getenv ("GAF_INHIBIT_RCFILES") == NULL) { g_rc_parse (toplevel, "gaf export", NULL, NULL); } i_vars_libgeda_set (toplevel); /* Ugh */ /* Parse configuration files */ export_config (); /* Parse command-line arguments */ export_command_line (argc, argv); /* If no format was specified, try and guess from output * filename. */ if (settings.format == NULL) { out_suffix = strrchr (settings.outfile, '.'); if (out_suffix != NULL) { out_suffix++; /* Skip '.' */ } else { fprintf (stderr, _("ERROR: Cannot infer output format from filename '%s'.\n"), settings.outfile); exit (1); } } /* Try and find an exporter function */ tmp = g_utf8_strdown ((settings.format == NULL) ? out_suffix : settings.format, -1); for (i = 0; formats[i].name != NULL; i++) { if (strcmp (tmp, formats[i].alias) == 0) { exporter = &formats[i]; break; } } if (exporter == NULL) { if (settings.format == NULL) { fprintf (stderr, _("ERROR: Cannot find supported format for filename '%s'.\n"), settings.outfile); exit (1); } else { fprintf (stderr, _("ERROR: Unsupported output format '%s'.\n"), settings.format); fprintf (stderr, see_help_msg); exit (1); } } g_free (tmp); /* If more than one schematic/symbol file was specified, check that * exporter supports multipage output. */ if ((settings.infilec > 1) && !(exporter->flags & OUTPUT_MULTIPAGE)) { fprintf (stderr, _("ERROR: Selected output format does not support multipage output\n")); exit (1); } /* Load schematic files */ while (optind < argc) { PAGE *page; tmp = argv[optind++]; page = s_page_new (toplevel, tmp); if (!f_open (toplevel, page, tmp, &err)) { fprintf (stderr, _("ERROR: Failed to load '%s': %s\n"), tmp, err->message); exit (1); } if (g_chdir (original_cwd) != 0) { fprintf (stderr, _("ERROR: Failed to change directory to '%s': %s\n"), original_cwd, g_strerror (errno)); exit (1); } } /* Create renderer */ renderer = eda_renderer_new (NULL, NULL); if (settings.font != NULL) { g_object_set (renderer, "font-name", settings.font, NULL); } /* Make sure libgeda knows how to calculate the bounds of text * taking into account font etc. */ o_text_set_rendered_bounds_func (toplevel, export_text_rendered_bounds, renderer); /* Create color map */ render_color_map = g_array_sized_new (FALSE, FALSE, sizeof(GedaColor), MAX_COLORS); render_color_map = g_array_append_vals (render_color_map, print_colors, MAX_COLORS); if (!settings.color) { /* Create a black and white color map. All non-background colors * are black. */ GedaColor white = {~0, ~0, ~0, ~0, TRUE}; GedaColor black = {0, 0, 0, ~0, TRUE}; for (i = 0; i < MAX_COLORS; i++) { GedaColor *c = &g_array_index (render_color_map, GedaColor, i); if (!c->enabled) continue; if (c->a == 0) { c->enabled = FALSE; continue; } if (i == OUTPUT_BACKGROUND_COLOR) { *c = white; } else { *c = black; } } } eda_renderer_set_color_map (renderer, render_color_map); /* Render */ exporter->func (); scm_dynwind_end (); exit (0); }
static void shell_main (void *data, int argc, char **argv) { SCM setup_lst = SCM_EOL; /* We reverse! this before using it. */ SCM run_lst = SCM_EOL; /* We reverse! this before using it. */ int c; int interactive = 1; int inhibit_rc = 0; int status; TOPLEVEL *toplevel; #include "shell.x" /* Parse command-line arguments */ opterr = 0; while ((c = getopt (argc, argv, GETOPT_OPTIONS)) != -1) { switch (c) { case 's': /* Construct an application of LOAD to the script name */ run_lst = scm_cons (scm_list_2 (sym_load, scm_from_locale_string (optarg)), run_lst); interactive = 0; goto endoptloop; case 'c': /* We need to evaluate an expression */ run_lst = scm_cons (scm_list_2 (sym_eval_string, scm_from_locale_string (optarg)), run_lst); interactive = 0; goto endoptloop; case 'L': /* Add argument to %load-path */ setup_lst = scm_cons (scm_list_3 (sym_set_x, sym_load_path, scm_list_3 (sym_cons, scm_from_locale_string (optarg), sym_load_path)), setup_lst); break; case 'l': /* Same as -s, pretty much */ run_lst = scm_cons (scm_list_2 (sym_load, scm_from_locale_string (optarg)), run_lst); break; case 'q': inhibit_rc = 1; break; case 'h': usage (0); case 'V': version(); case '?': if ((optopt != ':') && (strchr (GETOPT_OPTIONS, optopt) != NULL)) { fprintf (stderr, "ERROR: -%c option requires an argument.\n\n", optopt); usage (1); } else if (isprint (optopt)) { fprintf (stderr, "ERROR: Unknown option -%c\n\n", optopt); usage (1); } else { fprintf (stderr, "ERROR: Unknown option character `\\x%x'.\n\n", optopt); usage (1); } default: g_assert_not_reached (); } } endoptloop: /* Set program arguments visible from Guile */ scm_set_program_arguments (argc - optind, argv + optind, "geda-shell"); /* If interactive mode, load readline and run top REPL. */ if (interactive) { run_lst = scm_cons (scm_list_2 (sym_use_modules, scm_list_2 (sym_ice_9, sym_readline)), run_lst); run_lst = scm_cons (scm_list_1 (sym_activate_readline), run_lst); run_lst = scm_cons (scm_list_1 (sym_top_repl), run_lst); /* Print GPL bumf if necessary */ if (isatty (1) && isatty (0)) { printf ( "gEDA " PACKAGE_GIT_VERSION "\n" "Copyright (C) 1998-2010 gEDA developers\n" "This is free software, and you are welcome to redistribute it under\n" "certain conditions. For details, see the file `COPYING', which is\n" "included in the gEDA distribution.\n" "There is NO WARRANTY, to the extent permitted by law.\n" ); } } else { run_lst = scm_cons (scm_list_1 (sym_quit), run_lst); } /* Reverse lists */ setup_lst = scm_reverse_x (setup_lst, SCM_UNDEFINED); run_lst = scm_reverse_x (run_lst, SCM_UNDEFINED); /* Initialise libgeda */ libgeda_init (); scm_dynwind_begin (0); toplevel = s_toplevel_new (); edascm_dynwind_toplevel (toplevel); /* First run the setup list */ if (setup_lst != SCM_EOL) { setup_lst = scm_cons (sym_begin, setup_lst); scm_eval_x (setup_lst, scm_current_module ()); } /* Now load rc files, if necessary */ if (!inhibit_rc) g_rc_parse (toplevel, argv[0], NULL, NULL); i_vars_libgeda_set (toplevel); /* Ugh */ /* Finally evaluate run list */ run_lst = scm_cons (sym_begin, run_lst); status = scm_exit_status (scm_eval_x (run_lst, scm_current_module ())); exit (status); scm_dynwind_end (); scm_remember_upto_here_2 (setup_lst, run_lst); }
void main_prog(void *closure, int argc, char *argv[]) { int i; int argv_index; int exit_status; char *cwd; char *logfile; TOPLEVEL *pr_current; argv_index = parse_commandline(argc, argv); cwd = g_get_current_dir(); libgeda_init(); /* create log file right away */ /* even if logging is enabled */ logfile = g_build_filename (cwd, "gsymcheck.log", NULL); x_log_update_func = s_log_update; s_log_init (logfile); g_free (logfile); logging_dest=STDOUT_TTY; if (!quiet_mode) { s_log_message( "gEDA/gsymcheck version %s%s.%s\n", PREPEND_VERSION_STRING, DOTTED_VERSION, DATE_VERSION); s_log_message( "gEDA/symcheck comes with ABSOLUTELY NO WARRANTY; see COPYING for more details.\n"); s_log_message( "This is free software, and you are welcome to redistribute it under certain\n"); s_log_message( "conditions; please see the COPYING file for more details.\n\n"); } #ifdef __MINGW32__ fprintf(stderr, "This is the MINGW32 port.\n"); #endif logging_dest=-1; /* don't output to the screen for now */ /* register guile (scheme) functions */ g_register_funcs(); pr_current = s_toplevel_new (); g_rc_parse(pr_current, "gsymcheckrc", rc_filename); i_vars_set(pr_current); i = argv_index; while (argv[i] != NULL) { gchar *filename; GError *err = NULL; if (g_path_is_absolute(argv[i])) { /* Path is already absolute so no need to do any concat of cwd */ filename = g_strdup (argv[i]); } else { filename = g_build_filename (cwd, argv[i], NULL); } s_page_goto (pr_current, s_page_new (pr_current, filename)); if (!f_open (pr_current, pr_current->page_current->page_filename, &err)) { /* Not being able to load a file is apparently a fatal error */ logging_dest = STDOUT_TTY; g_warning ("%s\n", err->message); g_error_free (err); exit(2); } else { g_message ("Loaded file [%s]\n", filename); } i++; g_free (filename); } if (argv[argv_index] == NULL) { fprintf(stderr, "\nERROR! You must specify at least one filename\n\n"); usage(argv[0]); } g_free(cwd); logging_dest=STDOUT_TTY; #if DEBUG s_page_print_all(pr_current); #endif if (!quiet_mode) s_log_message("\n"); exit_status = s_check_all(pr_current); s_page_delete_list(pr_current); gsymcheck_quit(); exit(exit_status); }
/*! \brief Main Scheme(GUILE) program function. * \par Function Description * This function is the main program called from scm_boot_guile. * It handles initializing all libraries and gSchem variables * and passes control to the gtk main loop. */ void main_prog(void *closure, int argc, char *argv[]) { int i; char *cwd = NULL; GSCHEM_TOPLEVEL *w_current = NULL; char *input_str = NULL; int argv_index; int first_page = 1; char *filename; SCM scm_tmp; #ifdef HAVE_GTHREAD /* Gschem isn't threaded, but some of GTK's file chooser * backends uses threading so we need to call g_thread_init(). * GLib requires threading be initialised before any other GLib * functions are called. Do it now if its not already setup. */ if (!g_thread_supported ()) g_thread_init (NULL); #endif #if ENABLE_NLS /* this should be equivalent to setlocale (LC_ALL, "") */ gtk_set_locale(); /* This must be the same for all locales */ setlocale(LC_NUMERIC, "C"); /* Disable gtk's ability to set the locale. */ /* If gtk is allowed to set the locale, then it will override the */ /* setlocale for LC_NUMERIC (which is important for proper PS output. */ /* This may look funny here, given we make a call to gtk_set_locale() */ /* above. I don't know yet, if this is really the right thing to do. */ gtk_disable_setlocale(); #endif gtk_init(&argc, &argv); argv_index = parse_commandline(argc, argv); cwd = g_get_current_dir(); libgeda_init(); /* create log file right away even if logging is enabled */ s_log_init ("gschem"); s_log_message( _("gEDA/gschem version %s%s.%s\n"), PREPEND_VERSION_STRING, PACKAGE_DOTTED_VERSION, PACKAGE_DATE_VERSION); s_log_message( _("gEDA/gschem comes with ABSOLUTELY NO WARRANTY; see COPYING for more details.\n")); s_log_message( _("This is free software, and you are welcome to redistribute it under certain\n")); s_log_message( _("conditions; please see the COPYING file for more details.\n\n")); #if defined(__MINGW32__) && defined(DEBUG) fprintf(stderr, _("This is the MINGW32 port.\n")); #endif #if DEBUG fprintf(stderr, _("Current locale settings: %s\n"), setlocale(LC_ALL, NULL)); #endif /* init global buffers */ o_buffer_init(); /* register guile (scheme) functions */ g_register_funcs(); g_init_window (); g_init_select (); g_init_hook (); g_init_attrib (); g_init_keys (); g_init_util (); /* initialise color map (need to do this before reading rc files */ x_color_init (); o_undo_init(); if (s_path_sys_data () == NULL) { const gchar *message = _("You must set the GEDADATA environment variable!\n\n" "gschem cannot locate its data files. You must set the GEDADATA\n" "environment variable to point to the correct location.\n"); GtkWidget* error_diag = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", message); gtk_dialog_run (GTK_DIALOG (error_diag)); g_error ("%s", message); } /* Allocate w_current */ w_current = gschem_toplevel_new (); /* Connect hooks that run for each s_toplevel_new() first */ s_toplevel_append_new_hook ((NewToplevelFunc) add_libgeda_toplevel_hooks, w_current); w_current->toplevel = s_toplevel_new (); w_current->toplevel->load_newer_backup_func = x_fileselect_load_backup; w_current->toplevel->load_newer_backup_data = w_current; o_text_set_rendered_bounds_func (w_current->toplevel, o_text_get_rendered_bounds, w_current); /* Damage notifications should invalidate the object on screen */ o_add_change_notify (w_current->toplevel, (ChangeNotifyFunc) o_invalidate, (ChangeNotifyFunc) o_invalidate, w_current); scm_dynwind_begin (0); g_dynwind_window (w_current); /* Run pre-load Scheme expressions */ g_scm_eval_protected (s_pre_load_expr, scm_current_module ()); /* By this point, libgeda should have setup the Guile load path, so * we can take advantage of that. */ scm_tmp = scm_sys_search_load_path (scm_from_utf8_string ("gschem.scm")); if (scm_is_false (scm_tmp)) { s_log_message (_("Couldn't find init scm file [%s]\n"), "gschem.scm"); } input_str = scm_to_utf8_string (scm_tmp); if (g_read_file(w_current->toplevel, input_str, NULL)) { s_log_message(_("Read init scm file [%s]\n"), input_str); } else { /*! \todo These two messages are the same. Should be * integrated. */ s_log_message(_("Failed to read init scm file [%s]\n"), input_str); } free (input_str); /* M'allocated by scm_to_utf8_string() */ scm_remember_upto_here_1 (scm_tmp); /* Now read in RC files. */ g_rc_parse_gtkrc(); x_rc_parse_gschem (w_current, rc_filename); /* Set default icon */ x_window_set_default_icon(); /* At end, complete set up of window. */ x_color_allocate(); x_window_setup (w_current); #ifdef HAVE_LIBSTROKE x_stroke_init (); #endif /* HAVE_LIBSTROKE */ for (i = argv_index; i < argc; i++) { if (g_path_is_absolute(argv[i])) { /* Path is already absolute so no need to do any concat of cwd */ filename = g_strdup (argv[i]); } else { filename = g_build_filename (cwd, argv[i], NULL); } if ( first_page ) first_page = 0; /* * SDB notes: at this point the filename might be unnormalized, like * /path/to/foo/../bar/baz.sch. Bad filenames will be normalized in * f_open (called by x_window_open_page). This works for Linux and MINGW32. */ x_window_open_page(w_current, filename); g_free (filename); } g_free(cwd); /* If no page has been loaded (wasn't specified in the command line.) */ /* Then create an untitled page */ if ( first_page ) { x_window_open_page( w_current, NULL ); } /* Update the window to show the current page */ x_window_set_current_page( w_current, w_current->toplevel->page_current ); #if DEBUG scm_c_eval_string ("(display \"hello guile\n\")"); #endif /* Run post-load expressions */ g_scm_eval_protected (s_post_load_expr, scm_current_module ()); /* open up log window on startup */ if (w_current->log_window == MAP_ON_STARTUP) { x_log_open (); } /* if there were any symbols which had major changes, put up an error */ /* dialog box */ major_changed_dialog(w_current); scm_dynwind_end (); /* enter main loop */ gtk_main(); }
void main_prog(void *closure, int argc, char *argv[]) { int i; int argv_index; int exit_status; char *cwd; TOPLEVEL *pr_current; argv_index = parse_commandline(argc, argv); cwd = g_get_current_dir(); libgeda_init(); /* create log file right away */ /* even if logging is enabled */ x_log_update_func = s_log_update; s_log_init ("symcheck"); logging_dest=STDOUT_TTY; #if defined(__MINGW32__) && defined(DEBUG) fprintf(stderr, "This is the MINGW32 port.\n"); #endif logging_dest=-1; /* don't output to the screen for now */ /* register guile (scheme) functions */ g_register_funcs(); pr_current = s_toplevel_new (); g_rc_parse (pr_current, argv[0], "gsymcheckrc", rc_filename); i_vars_set(pr_current); i = argv_index; while (argv[i] != NULL) { gchar *filename; GError *err = NULL; if (g_path_is_absolute(argv[i])) { /* Path is already absolute so no need to do any concat of cwd */ filename = g_strdup (argv[i]); } else { filename = g_build_filename (cwd, argv[i], NULL); } s_page_goto (pr_current, s_page_new (pr_current, filename)); if (!f_open (pr_current, pr_current->page_current, s_page_get_filename (pr_current->page_current), &err)) { /* Not being able to load a file is apparently a fatal error */ logging_dest = STDOUT_TTY; g_warning ("%s\n", err->message); g_error_free (err); exit(2); } else { g_message (_("Loaded file [%1$s]\n"), filename); } i++; g_free (filename); } if (argv[argv_index] == NULL) { fprintf(stderr, _("\nERROR! You must specify at least one filename\n\n")); usage(argv[0]); } g_free(cwd); logging_dest=STDOUT_TTY; #if DEBUG s_page_print_all(pr_current); #endif if (!quiet_mode) s_log_message("\n"); exit_status = s_check_all(pr_current); s_page_delete_list(pr_current); gsymcheck_quit(); exit(exit_status); }
void main_prog(void *closure, int argc, char *argv[]) { int i; int argv_index; char *cwd; gchar *str; gchar *filename; TOPLEVEL *pr_current; /* set default output filename */ output_filename = g_strdup("output.net"); argv_index = parse_commandline(argc, argv); cwd = g_get_current_dir(); scm_set_program_arguments (argc, argv, NULL); /* this is a kludge to make sure that spice mode gets set */ /* Hacked by SDB to allow spice netlisters of arbitrary name * as long as they begin with "spice". For example, this spice * netlister is valid: "spice-sdb". */ if (guile_proc) { if (strncmp(guile_proc, "spice", 5) == 0) { netlist_mode = SPICE; } } libgeda_init(); /* create log file right away */ /* even if logging is enabled */ s_log_init ("gnetlist"); s_log_message("gEDA/gnetlist version %s%s.%s\n", PREPEND_VERSION_STRING, PACKAGE_DOTTED_VERSION, PACKAGE_DATE_VERSION); s_log_message ("gEDA/gnetlist comes with ABSOLUTELY NO WARRANTY; see COPYING for more details.\n"); s_log_message ("This is free software, and you are welcome to redistribute it under certain\n"); s_log_message ("conditions; please see the COPYING file for more details.\n\n"); #if defined(__MINGW32__) && defined(DEBUG) fprintf(stderr, "This is the MINGW32 port.\n\n"); #endif /* register guile (scheme) functions */ g_register_funcs(); pr_current = s_toplevel_new (); /* Evaluate Scheme expressions that need to be run before rc files * are loaded. */ scm_eval (pre_rc_list, scm_current_module ()); g_rc_parse (pr_current, argv[0], "gnetlistrc", rc_filename); /* immediately setup user params */ i_vars_set (pr_current); s_rename_init(); if(list_backends) { gnetlist_backends(pr_current); exit (0); } /* Evaluate the first set of Scheme expressions before we load any * schematic files */ scm_eval (pre_backend_list, scm_current_module ()); i = argv_index; while (argv[i] != NULL) { GError *err = NULL; if (g_path_is_absolute(argv[i])) { /* Path is already absolute so no need to do any concat of cwd */ filename = g_strdup (argv[i]); } else { filename = g_build_filename (cwd, argv[i], NULL); } if (!quiet_mode) { s_log_message ("Loading schematic [%s]\n", filename); printf ("Loading schematic [%s]\n", filename); } s_page_goto (pr_current, s_page_new (pr_current, filename)); if (!f_open (pr_current, pr_current->page_current, filename, &err)) { g_warning ("%s\n", err->message); fprintf (stderr, "%s\n", err->message); g_error_free (err); } /* collect input filenames for backend use */ input_files = g_slist_append(input_files, argv[i]); i++; g_free (filename); } /* Change back to the directory where we started. This is done */ /* since gnetlist is a command line utility and will deposit its output */ /* in the current directory. Having the output go to a different */ /* directory will confuse the user (confused me, at first). */ if (chdir (cwd)) { /* Error occured with chdir */ #warning FIME: What do we do? } /* free(cwd); - Defered; see below */ if (argv[argv_index] == NULL) { fprintf (stderr, "ERROR: No schematics files specified for processing.\n"); fprintf (stderr, "\nRun `%s --help' for more information.\n", argv[0]); exit (1); } g_set_project_current(pr_current); #if DEBUG s_page_print_all(pr_current); #endif /* Load basic gnetlist functions */ scm_primitive_load_path (scm_from_utf8_string ("gnetlist.scm")); if (guile_proc) { SCM s_backend_path; /* Search for backend scm file in load path */ str = g_strdup_printf("gnet-%s.scm", guile_proc); s_backend_path = scm_sys_search_load_path (scm_from_locale_string (str)); g_free (str); /* If it couldn't be found, fail. */ if (scm_is_false (s_backend_path)) { fprintf (stderr, "ERROR: Could not find backend `%s' in load path.\n", guile_proc); fprintf (stderr, "\nRun `%s --list-backends' for a full list of available backends.\n", argv[0]); exit (1); } /* Load backend code. */ scm_primitive_load (s_backend_path); /* Evaluate second set of Scheme expressions. */ scm_eval (post_backend_list, scm_current_module ()); } s_traverse_init(); s_traverse_start(pr_current); /* Change back to the directory where we started AGAIN. This is done */ /* because the s_traverse functions can change the Current Working Directory. */ if (chdir (cwd)) { /* Error occured with chdir */ #warning FIXME: What do we do? } g_free(cwd); /* Run post-traverse code. */ scm_primitive_load_path (scm_from_utf8_string ("gnetlist-post.scm")); if (guile_proc) { /* check size here hack */ str = g_strdup_printf ("(%s \"%s\")", guile_proc, output_filename); scm_c_eval_string (str); g_free (str); /* gh_eval_str_with_stack_saving_handler (input_str); */ } else if (interactive_mode) { scm_c_eval_string ("(set-repl-prompt! \"gnetlist> \")"); scm_shell (0, NULL); } else { fprintf(stderr, "You gave neither backend to execute nor interactive mode!\n"); } gnetlist_quit(); }
static void preview_init (Preview *preview) { struct event_reg_t { gchar *detailed_signal; GCallback c_handler; } drawing_area_events[] = { { "realize", G_CALLBACK (preview_callback_realize) }, { "expose_event", G_CALLBACK (preview_callback_expose) }, { "button_press_event", G_CALLBACK (preview_callback_button_press) }, { "configure_event", G_CALLBACK (preview_event_configure) }, { "scroll_event", G_CALLBACK (preview_event_scroll) }, { NULL, NULL } }, *tmp; GSCHEM_TOPLEVEL *preview_w_current; preview_w_current = gschem_toplevel_new (); preview_w_current->toplevel = s_toplevel_new (); preview_w_current->toplevel->load_newer_backup_func = x_fileselect_load_backup; preview_w_current->toplevel->load_newer_backup_data = preview_w_current; o_text_set_rendered_bounds_func (preview_w_current->toplevel, o_text_get_rendered_bounds, preview_w_current); o_add_change_notify (preview_w_current->toplevel, (ChangeNotifyFunc) o_invalidate, (ChangeNotifyFunc) o_invalidate, preview_w_current); i_vars_set (preview_w_current); /* be sure to turn off scrollbars */ preview_w_current->scrollbars_flag = FALSE; /* be sure to turn off the grid */ preview_w_current->grid = FALSE; /* preview_w_current windows don't have toolbars */ preview_w_current->handleboxes = FALSE; preview_w_current->toolbars = FALSE; preview_w_current->toplevel->width = 160; preview_w_current->toplevel->height = 120; preview_w_current->win_width = preview_w_current->toplevel->width; preview_w_current->win_height = preview_w_current->toplevel->height; preview_w_current->drawing_area = GTK_WIDGET (preview); preview->preview_w_current = preview_w_current; g_object_set (GTK_WIDGET (preview), "width-request", preview_w_current->toplevel->width, "height-request", preview_w_current->toplevel->height, NULL); preview->active = FALSE; preview->filename = NULL; preview->buffer = NULL; gtk_widget_set_events (GTK_WIDGET (preview), GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK); for (tmp = drawing_area_events; tmp->detailed_signal != NULL; tmp++) { g_signal_connect (preview, tmp->detailed_signal, tmp->c_handler, NULL); } }
/*! \brief gattrib_main -- main gattrib fcn. * * \par * *------------------------------------------------------------------*/ void gattrib_main(void *closure, int argc, char *argv[]) { /* TOPLEVEL *pr_current is a global */ /* SHEET_DATA *sheet_head is a global */ /* GtkWidget *main_window is a global */ int argv_index; gchar *cwd; gchar *logfile; #ifdef HAVE_GTHREAD /* Gattrib isn't threaded, but some of GTK's file chooser * backends uses threading so we need to call g_thread_init(). * GLib requires threading be initialised before any other GLib * functions are called. Do it now if its not already setup. */ if (!g_thread_supported ()) g_thread_init (NULL); #endif /* Initialize gEDA stuff */ libgeda_init(); /* Ensure object->sel_func can be used to correctly determine object * locking when the project is saved out */ select_func = s_toplevel_select_object; /* Note that argv_index holds index to first non-flag command line option * (that is, to the first file name) */ argv_index = parse_commandline(argc, argv); /* ---------- create log file right away ---------- */ /* ---------- even if logging is enabled ---------- */ cwd = g_get_current_dir(); logfile = g_build_filename (cwd, "gattrib.log", NULL); s_log_init (logfile); g_free (logfile); g_free (cwd); s_log_message ("gEDA/gattrib version %s%s.%s\n", PREPEND_VERSION_STRING, DOTTED_VERSION, DATE_VERSION); s_log_message ("gEDA/gattrib comes with ABSOLUTELY NO WARRANTY; see COPYING for more details.\n"); s_log_message ("This is free software, and you are welcome to redistribute it under certain\n"); s_log_message ("conditions; please see the COPYING file for more details.\n\n"); if (!quiet_mode) { fflush(stderr); fflush(stdout); fprintf(stderr, "gEDA/gattrib version %s%s.%s\n", PREPEND_VERSION_STRING, DOTTED_VERSION, DATE_VERSION); fprintf(stderr, "gEDA/gattrib comes with ABSOLUTELY NO WARRANTY; see COPYING for more details.\n"); fprintf(stderr, "This is free software, and you are welcome to redistribute it under certain\n"); fprintf(stderr, "conditions; please see the COPYING file for more details.\n\n"); } /* ------ register guile (scheme) functions. Necessary to parse RC file. ------ */ g_register_funcs(); /* ---------- Start creation of new project: (TOPLEVEL *pr_current) ---------- */ pr_current = s_toplevel_new(); /* ----- Read in RC files. ----- */ g_rc_parse(pr_current, "gattribrc", NULL); i_vars_set(pr_current); gtk_init(&argc, &argv); x_window_init(); /* ---------- Initialize SHEET_DATA data structure ---------- */ sheet_head = s_sheet_data_new(); /* sheet_head was declared in globals.h */ GSList *file_list = NULL; if (argv_index >= argc) { /* No files specified on the command line, pop up the File open dialog. */ file_list = x_fileselect_open(); if(file_list == NULL) exit(0); } else { /* Construct the list of filenames from the command line. * argv_index holds the position of the first filename */ while (argv_index < argc) { gchar *filename = f_normalize_filename(argv[argv_index], NULL); if (filename != NULL) { file_list = g_slist_append(file_list, filename); } else { fprintf(stderr, "Couldn't find file [%s]\n", argv[argv_index]); exit(1); } argv_index++; } } /* Load the files */ if(x_fileselect_load_files(file_list) == FALSE) { /* just exit the program */ exit(1); } g_slist_foreach(file_list, (GFunc)g_free, NULL); g_slist_free(file_list); gtk_main(); exit(0); }