Example #1
0
static void action_save_as_cb(GtkAction *action, EDITOR *e)
{
	const gchar *filename;
	gboolean as_html;
	GError *error = NULL;

	if (save_dialog(GTKHTML_EDITOR(e->window), e) ==
	    GTK_RESPONSE_CANCEL)
		return;

	filename = gtkhtml_editor_get_filename(GTKHTML_EDITOR(e->window));
	as_html = gtkhtml_editor_get_html_mode(GTKHTML_EDITOR(e->window));

	gtkhtml_editor_save(GTKHTML_EDITOR(e->window), filename, as_html,
			    &error);
	handle_error(&error);
}
Example #2
0
static void _save_file(EDITOR *e)
{
	const gchar *filename;
	gboolean as_html;
	GError *error = NULL;

	if (gtkhtml_editor_get_filename(GTKHTML_EDITOR(e->window)) == NULL)
		if (save_dialog(GTKHTML_EDITOR(e->window), e) ==
		    GTK_RESPONSE_CANCEL)
			return;

	filename = gtkhtml_editor_get_filename(GTKHTML_EDITOR(e->window));
	as_html = gtkhtml_editor_get_html_mode(GTKHTML_EDITOR(e->window));

	XI_message(("\n_save_file filename: %s\n", filename));

	gtkhtml_editor_save(GTKHTML_EDITOR(e->window), filename, as_html,
			    &error);
	handle_error(&error);

	gtkhtml_editor_drop_undo(GTKHTML_EDITOR(e->window));
	gtkhtml_editor_set_changed(GTKHTML_EDITOR(e->window), FALSE);
}
Example #3
0
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;
}
static void
action_save_and_close_cb (GtkAction *action,
                          ESignatureEditor *editor)
{
	GtkWidget *entry;
	ESignatureList *signature_list;
	ESignature *signature;
	ESignature *same_name;
	const gchar *filename;
	gchar *signature_name;
	gboolean html;
	GError *error = NULL;

	entry = editor->priv->entry;
	html = gtkhtml_editor_get_html_mode (GTKHTML_EDITOR (editor));

	if (editor->priv->signature == NULL)
		signature = mail_config_signature_new (NULL, FALSE, html);
	else {
		signature = g_object_ref (editor->priv->signature);
		signature->html = html;
	}

	filename = signature->filename;
	gtkhtml_editor_save (GTKHTML_EDITOR (editor), filename, html, &error);

	if (error != NULL) {
		e_error_run (
			GTK_WINDOW (editor),
			"mail:no-save-signature",
			error->message, NULL);
		g_clear_error (&error);
		return;
	}

	signature_list = mail_config_get_signatures ();

	signature_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
	g_strstrip (signature_name);

	/* Make sure the signature name is not blank. */
	if (*signature_name == '\0') {
		e_error_run (
			GTK_WINDOW (editor),
			"mail:blank-signature", NULL);
		gtk_widget_grab_focus (entry);
		g_free (signature_name);
		return;
	}

	/* Don't overwrite an existing signature of the same name.
	 * XXX ESignatureList misuses const. */
	same_name = (ESignature *) e_signature_list_find (
		signature_list, E_SIGNATURE_FIND_NAME, signature_name);
	if (same_name != NULL && strcmp (signature->uid, same_name->uid) != 0) {
		e_error_run (
			GTK_WINDOW (editor),
			"mail:signature-already-exists",
			signature_name, NULL);
		gtk_widget_grab_focus (entry);
		g_free (signature_name);
		return;
	}

	g_free (signature->name);
	signature->name = signature_name;

	if (editor->priv->signature != NULL)
		e_signature_list_change (signature_list, signature);
	else
		mail_config_add_signature (signature);

	gtk_widget_destroy (GTK_WIDGET (editor));
}