/*! * \brief File->Save menu item * * Implement the File->Save menu */ static void menu_file_save() { s_toplevel_gtksheet_to_toplevel(pr_current); /* Dumps sheet data into TOPLEVEL */ s_page_save_all(pr_current); /* saves all pages in design */ sheet_head->CHANGED = FALSE; }
/*! \brief Unsaved data dialog * * This is the "Unsaved data -- are you sure you want to quit?" dialog * box which is thrown up before the user quits. */ void x_dialog_unsaved_data() { GtkWidget *dialog; gchar *tmp; gchar *str; tmp = _("Save the changes before closing?"); str = g_strconcat (N_("<big><b>"), tmp, N_("</b></big>"), NULL); tmp = _("If you don't save, all your changes will be permanently lost."); str = g_strconcat (str, "\n\n", tmp, NULL); dialog = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE, NULL); gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), str); gtk_dialog_add_buttons (GTK_DIALOG (dialog), _("Close without saving"), GTK_RESPONSE_NO, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_YES, NULL); /* Set the alternative button order (ok, cancel, help) for other systems */ gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_YES, GTK_RESPONSE_NO, GTK_RESPONSE_CANCEL, -1); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES); switch (gtk_dialog_run (GTK_DIALOG (dialog))) { case GTK_RESPONSE_NO: { gattrib_quit(0); break; } case GTK_RESPONSE_YES: { s_toplevel_gtksheet_to_toplevel(pr_current); /* Dumps sheet data into TOPLEVEL */ s_page_save_all(pr_current); /* saves all pages in design */ sheet_head->CHANGED = FALSE; gattrib_quit(0); break; } case GTK_RESPONSE_CANCEL: default: { break; } } gtk_widget_destroy (dialog); return; }
void main_prog(void *closure, int argc, char *argv[]) { int i; int argv_index; char *cwd; char *logfile; TOPLEVEL *pr_current; argv_index = parse_commandline(argc, argv); cwd = g_get_current_dir(); libgeda_init(); /* Ensure object->sel_func can be used to correctly determine object * locking when the project is saved out */ select_func = o_select_dummy; /* create log file right away */ /* even if logging is enabled */ logfile = g_build_filename (cwd, "gschlas.log", NULL); s_log_init (logfile); g_free (logfile); logging_dest=STDOUT_TTY; if (!quiet_mode) { s_log_message( "gEDA/gschlas version %s%s.%s\n", PREPEND_VERSION_STRING, DOTTED_VERSION, DATE_VERSION); s_log_message( "gEDA/gschlas 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, "gschlasrc", 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"); if (embed_mode) { s_util_embed(pr_current, TRUE); } if (unembed_mode) { s_util_embed(pr_current, FALSE); } /* save all the opened files */ s_page_save_all(pr_current); s_page_delete_list (pr_current); gschlas_quit(); exit(0); }
void main_prog(void *closure, int argc, char *argv[]) { int i; int argv_index; 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 */ s_log_init ("gschlas"); 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], "gschlasrc", 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, 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"); if (embed_mode) { s_util_embed(pr_current, TRUE); } if (unembed_mode) { s_util_embed(pr_current, FALSE); } /* save all the opened files */ s_page_save_all(pr_current); s_page_delete_list (pr_current); gschlas_quit(); exit(0); }