/* save if needed is done in treeky-editor.c before calling editor_load_book() */ void editor_load_book(EDITOR *e) { gchar *title = NULL, *text = NULL; if (!g_ascii_isdigit(e->key[0])) return; /* make sure is a number (offset) */ XI_message(("book: %s\noffset :%s", e->module, e->key)); if (atol(e->key) != 0) text = main_get_book_raw_text(e->module, e->key); else text = g_strdup(e->module); if ((text == NULL) || strlen(text) == 0) { if (text) g_free(text); /* new empty document from template */ gchar *fname = g_build_filename(settings.gSwordDir, "studypad.spt", NULL); XI_message(("editor load BOOK [%s]", fname)); text = inhale_text_from_file(fname); g_free(fname); } if (text && strlen(text)) { webkit_web_view_load_string((WebKitWebView *) e->html_widget, text, "text/html", "utf_8", "file://"); } if (text) g_free(text); title = g_strdup_printf("%s", e->module); change_window_title(e->window, title); g_free(title); e->is_changed = FALSE; }
/* save if needed is done in treeky-editor.c before calling editor_load_book() */ void editor_load_book(EDITOR *e) { gchar *title = NULL; gchar *text = NULL; if (!g_ascii_isdigit(e->key[0])) return; /* make sure is a number (offset) */ title = g_strdup_printf("%s", e->module); XI_message(("book: %s\noffset :%s", e->module, e->key)); if (atol(e->key) != 0) text = main_get_book_raw_text(e->module, e->key); else text = g_strdup(e->module); if (strlen(text)) { gtkhtml_editor_set_text_html(GTKHTML_EDITOR(e->window), text, strlen(text)); gtkhtml_editor_drop_undo(GTKHTML_EDITOR(e->window)); gtkhtml_editor_set_changed(GTKHTML_EDITOR(e->window), FALSE); } else { gtkhtml_editor_set_text_html(GTKHTML_EDITOR(e->window), "", strlen("")); gtkhtml_editor_drop_undo(GTKHTML_EDITOR(e->window)); gtkhtml_editor_set_changed(GTKHTML_EDITOR(e->window), FALSE); } change_window_title(e->window, title); if (text) g_free(text); if (title) g_free(title); }