static PyObject * Dialogs_show_save_as(PyObject *self) { if (dialogs_show_save_as()) Py_RETURN_TRUE; else Py_RETURN_FALSE; }
/* Callback for sending file as attachment */ static void send_as_attachment(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer gdata) { GeanyDocument *doc; gchar *locale_filename = NULL; gchar *command = NULL; GError *error = NULL; GString *cmd_str = NULL; gchar *data; doc = document_get_current(); if (doc->file_name == NULL) { dialogs_show_save_as(); } else { document_save_file(doc, FALSE); } if (doc->file_name != NULL) { if (mailer) { locale_filename = utils_get_locale_from_utf8(doc->file_name); cmd_str = g_string_new(mailer); if ((use_address_dialog == TRUE) && (g_strrstr(mailer, "%r") != NULL)) { GKeyFile *config = NULL; gchar *config_dir = NULL; gchar *input = dialogs_show_input(_("Recipient's Address"), GTK_WINDOW(geany->main_widgets->window), _("Enter the recipient's e-mail address:"), address); if (input) { config = g_key_file_new(); g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL); g_free(address); address = input; g_key_file_set_string(config, "tools", "address", address); } else { g_string_free(cmd_str, TRUE); g_free(locale_filename); return; } config_dir = g_path_get_dirname(config_file); if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0) { dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Plugin configuration directory could not be created.")); } else { /* write config to file */ data = g_key_file_to_data(config, NULL, NULL); utils_write_file(config_file, data); g_free(data); } g_key_file_free(config); g_free(config_dir); } if (! utils_string_replace_all(cmd_str, "%f", locale_filename)) ui_set_statusbar(FALSE, _("Filename placeholder not found. The executed command might have failed.")); if (use_address_dialog == TRUE && address != NULL) { if (! utils_string_replace_all(cmd_str, "%r", address)) ui_set_statusbar(FALSE, _("Recipient address placeholder not found. The executed command might have failed.")); } else { /* Removes %r if option was not activ but was included into command */ utils_string_replace_all(cmd_str, "%r", ""); } utils_string_replace_all(cmd_str, "%b", g_path_get_basename(locale_filename)); command = g_string_free(cmd_str, FALSE); g_spawn_command_line_async(command, &error); if (error != NULL) { ui_set_statusbar(FALSE, _("Could not execute mailer. Please check your configuration.")); g_error_free(error); } g_free(locale_filename); g_free(command); } else { ui_set_statusbar(FALSE, _("Please define a mail client first.")); } } else { ui_set_statusbar(FALSE, _("File has to be saved before sending.")); } }
void on_save_as1_activate(GtkMenuItem *menuitem, gpointer user_data) { dialogs_show_save_as(); }