static void action_save_cb(GtkAction *action, EDITOR *e) { switch (e->type) { case STUDYPAD_EDITOR: _save_file(e); break; case NOTE_EDITOR: _save_note(e); break; case BOOK_EDITOR: _save_book(e); break; default: XI_message(("\naction_save_cb oops!\n")); break; } }
G_MODULE_EXPORT void action_save_activate_cb(GtkWidget *widget, EDITOR *e) { switch (e->type) { case STUDYPAD_EDITOR: _save_file(e); break; case NOTE_EDITOR: _save_note(e); break; case BOOK_EDITOR: _save_book(e); break; default: XI_message(("\naction_save_cb oops!\n")); break; } }
gint editor_create_new(const gchar *filename, const gchar *key, gint editor_type) { GList *tmp = NULL; tmp = g_list_first(editors_all); while (tmp != NULL) { EDITOR *e = (EDITOR *)tmp->data; switch (editor_type) { case STUDYPAD_EDITOR: if (e->studypad) { if (editor_is_dirty(e)) _save_file(e); if (e->filename) g_free(e->filename); e->filename = g_strdup(filename); gtk_widget_show(e->window); gdk_window_raise(gtk_widget_get_parent_window(GTK_WIDGET(e->window))); _load_file(e, g_strdup(filename)); return 1; } break; case NOTE_EDITOR: if (!e->noteeditor) break; if (editor_is_dirty(e)) _save_note(e); if (e->module) g_free(e->module); e->module = g_strdup(filename); if (e->key) g_free(e->key); e->key = g_strdup(key); gtk_widget_show(e->window); gdk_window_raise(gtk_widget_get_parent_window(GTK_WIDGET(e->window))); editor_load_note(e, NULL, NULL); return 1; break; case BOOK_EDITOR: if (!e->bookeditor) break; if (editor_is_dirty(e)) _save_book(e); if (e->module) g_free(e->module); e->module = g_strdup(filename); if (e->key) g_free(e->key); e->key = g_strdup(key); gtk_widget_show(e->window); gdk_window_raise(gtk_widget_get_parent_window(GTK_WIDGET(e->window))); main_load_book_tree_in_editor(GTK_TREE_VIEW(e->treeview), e->module); editor_load_book(e); return 1; break; } tmp = g_list_next(tmp); } XI_message(("filename %s, key %s", (filename ? filename : "-null-"), (key ? key : "-null-"))); return _create_new(filename, key, editor_type); }
static gint ask_about_saving(EDITOR *e) { gint test; GS_DIALOG *info; gchar *buf = NULL; gchar *buf1 = NULL; gchar *buf2 = NULL; gchar *buf3 = NULL; gint retval = FALSE; switch (e->type) { case BOOK_EDITOR: case NOTE_EDITOR: info = gui_new_dialog(); info->stock_icon = GTK_STOCK_DIALOG_WARNING; buf = g_strdup_printf("%s: %s", e->module, e->key); buf1 = _("Save the changes to document"); buf2 = _("before closing?"); buf3 = g_strdup_printf("<span weight=\"bold\" size=\"larger\">%s %s %s</span>", buf1, buf, buf2); info->label_top = buf3; info->label2 = _("If you don't save, changes will be permanently lost."); info->save = TRUE; info->cancel = TRUE; info->no_save = TRUE; test = gui_alert_dialog(info); retval = test; if (test == GS_YES) { if (e->type == NOTE_EDITOR) { /* save notes and prayer lists */ _save_note(e); } else { /* save notes and prayer lists */ _save_book(e); } } g_free(info); g_free(buf); g_free(buf3); break; case STUDYPAD_EDITOR: info = gui_new_dialog(); info->stock_icon = #ifdef HAVE_GTK_310 "dialog-warning"; #else GTK_STOCK_DIALOG_WARNING; #endif if (settings.studypadfilename) buf = settings.studypadfilename; else buf = N_("File"); buf1 = _("Save the changes to document"); buf2 = _("before closing?"); buf3 = g_strdup_printf("<span weight=\"bold\" size=\"larger\">%s %s %s</span>", buf1, buf, buf2); info->label_top = buf3; info->label2 = _("If you don't save, changes will be permanently lost."); info->save = TRUE; info->cancel = TRUE; info->no_save = TRUE; test = gui_alert_dialog(info); retval = test; if (test == GS_YES) { if (e->filename) gtkhtml_editor_save(GTKHTML_EDITOR(e->window), e->filename, TRUE, NULL); /*else open_or_save_as_dialog(e, OP_SAVE_THROUGH_PERSIST_FILE); */ } g_free(info); g_free(buf3); break; } sync_windows(); return retval; }
void editor_save_book(EDITOR *e) { if (editor_is_dirty(e)) { _save_book(e); } }