Exemplo n.º 1
0
static HRESULT WINAPI PersistStreamInit_IsDirty(IPersistStreamInit *iface)
{
    HTMLDocument *This = impl_from_IPersistStreamInit(iface);

    TRACE("(%p)\n", This);

    if(This->doc_obj->usermode == EDITMODE)
        return editor_is_dirty(This);

    return S_FALSE;
}
Exemplo n.º 2
0
void
editor_load_note(EDITOR *e, const gchar *module_name, const gchar *key)
{
	gchar *title;
	gchar *text;

	if (editor_is_dirty(e))
		_save_note(e);

	if (module_name) {
		if (e->module)
			g_free(e->module);
		e->module = g_strdup(module_name);
	}
	if (key) {
		if (e->key)
			g_free(e->key);
		e->key = g_strdup(key);
	}

	title = g_strdup_printf("%s - %s", e->module, e->key);
	text = main_get_raw_text((gchar *)e->module, (gchar *)e->key);
	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 (e->type == NOTE_EDITOR)
		main_navbar_versekey_set(e->navbar, e->key);

	if (text)
		g_free(text);
	if (title)
		g_free(title);
}
Exemplo n.º 3
0
static int
app_delete_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
{
	if (editor_is_dirty((EDITOR *)data)) {
		switch (ask_about_saving((EDITOR *)data)) {
		case GS_YES: /* exit saving */

			break;
		case GS_NO: /* exit without saving */

			break;
		case GS_CANCEL:
			return TRUE;
			break;
		}
	}
	editors_all = g_list_remove(editors_all, (EDITOR *)data);
	do_exit((EDITOR *)data);
	return FALSE;
}
Exemplo n.º 4
0
static void action_new_cb(GtkAction *action, EDITOR *e)
{ /* for studypad only */

	if (editor_is_dirty(e))
		_save_file(e);

	_load_file(e,
		   g_strdup_printf("%s/%s", settings.gSwordDir,
				   "template.pad"));

	if (e->filename)
		g_free(e->filename);
	e->filename = g_strdup(_("Untitled document"));

	xml_set_value("Xiphos", "studypad", "lastfile", e->filename);
	settings.studypadfilename = xml_get_value("studypad", "lastfile");
	change_window_title(e->window, e->filename);

	gtkhtml_editor_set_filename(GTKHTML_EDITOR(e->window), NULL);
	gtkhtml_editor_set_changed(GTKHTML_EDITOR(e->window), TRUE);
}
Exemplo n.º 5
0
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);
}
Exemplo n.º 6
0
void editor_save_book(EDITOR *e)
{
	if (editor_is_dirty(e)) {
		_save_book(e);
	}
}