diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-11-11 01:14:07 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-11-11 07:18:11 +0800 |
commit | 3dfdf087fc7657905fc7804b59414ecd3d74028e (patch) | |
tree | 45a5bb547ca73ebaea9c3276860f93df6d417006 /e-util | |
parent | f70ecb0406903e0fdc09bbf1c9a3367c7ba55ec2 (diff) | |
download | gsoc2013-evolution-3dfdf087fc7657905fc7804b59414ecd3d74028e.tar.gz gsoc2013-evolution-3dfdf087fc7657905fc7804b59414ecd3d74028e.tar.zst gsoc2013-evolution-3dfdf087fc7657905fc7804b59414ecd3d74028e.zip |
Kill more redundant save dialogs and related utilities.
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-dialog-utils.c | 115 | ||||
-rw-r--r-- | e-util/e-dialog-utils.h | 7 | ||||
-rw-r--r-- | e-util/e-util.c | 60 | ||||
-rw-r--r-- | e-util/e-util.h | 4 |
4 files changed, 0 insertions, 186 deletions
diff --git a/e-util/e-dialog-utils.c b/e-util/e-dialog-utils.c index df0d8f5129..19d9030d30 100644 --- a/e-util/e-dialog-utils.c +++ b/e-util/e-dialog-utils.c @@ -27,17 +27,6 @@ #include "e-dialog-utils.h" -#include <errno.h> -#include <unistd.h> -#include <glib/gstdio.h> - -#include <gconf/gconf-client.h> -#include <glib/gi18n.h> - -#include "e-util/e-util.h" -#include "e-util/e-error.h" - - /** * e_notice: * @parent: the dialog's parent window, or %NULL @@ -71,107 +60,3 @@ e_notice (gpointer parent, GtkMessageType type, const gchar *format, ...) gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } - -/** - * e_file_get_save_filesel: - * @parent: parent window - * @title: dialog title - * @name: filename; already in a proper form (suitable for file system) - * @action: action for dialog - * - * Creates a save dialog, using the saved directory from gconf. The dialog has - * no signals connected and is not shown. - **/ -GtkWidget * -e_file_get_save_filesel (GtkWindow *parent, - const gchar *title, - const gchar *name, - GtkFileChooserAction action) -{ - GtkWidget *filesel; - gchar *uri; - - g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL); - - filesel = gtk_file_chooser_dialog_new ( - title, parent, action, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - (action == GTK_FILE_CHOOSER_ACTION_OPEN) ? - GTK_STOCK_OPEN : GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL); - gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_OK); - gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (filesel), FALSE); - - uri = e_file_get_save_path (); - - gtk_file_chooser_set_current_folder_uri ( - GTK_FILE_CHOOSER (filesel), uri); - - if (name && name[0]) - gtk_file_chooser_set_current_name ( - GTK_FILE_CHOOSER (filesel), name); - - g_free (uri); - - return filesel; -} - -/** - * e_file_can_save: - * - * Return TRUE if the URI can be saved to, FALSE otherwise. It checks local - * files to see if they're regular and can be accessed. If the file exists and - * is writable, it pops up a dialog asking the user if they want to overwrite - * it. Returns the users choice. - **/ -gboolean -e_file_can_save(GtkWindow *parent, const gchar *uri) -{ - struct stat st; - gchar *path; - gboolean res; - - if (!uri || uri[0] == 0) - return FALSE; - - /* Assume remote files are writable; too costly to check */ - if (!e_file_check_local(uri)) - return TRUE; - - path = g_filename_from_uri (uri, NULL, NULL); - if (!path) - return FALSE; - - /* make sure we can actually save to it... */ - if (g_stat (path, &st) != -1 && !S_ISREG (st.st_mode)) { - g_free(path); - return FALSE; - } - - res = TRUE; - if (g_access (path, F_OK) == 0) { - if (g_access (path, W_OK) != 0) { e_error_run(parent, "mail:no-save-path", path, g_strerror(errno), NULL); - g_free(path); - return FALSE; - } - - res = e_error_run(parent, E_ERROR_ASK_FILE_EXISTS_OVERWRITE, path, NULL) == GTK_RESPONSE_OK; - - } - - g_free(path); - return res; -} - -gboolean -e_file_check_local (const gchar *name) -{ - gchar *uri; - - uri = g_filename_to_uri (name, NULL, NULL); - if (uri) { - g_free(uri); - return TRUE; - } - - return FALSE; -} diff --git a/e-util/e-dialog-utils.h b/e-util/e-dialog-utils.h index 2457f1c37a..d1e8b900c0 100644 --- a/e-util/e-dialog-utils.h +++ b/e-util/e-dialog-utils.h @@ -29,12 +29,5 @@ void e_notice (gpointer parent, GtkMessageType type, const gchar *format, ...); -GtkWidget * e_file_get_save_filesel (GtkWindow *parent, - const gchar *title, - const gchar *name, - GtkFileChooserAction action); -gboolean e_file_can_save (GtkWindow *parent, - const gchar *uri); -gboolean e_file_check_local (const gchar *name); #endif /* E_DIALOG_UTILS_H */ diff --git a/e-util/e-util.c b/e-util/e-util.c index 9ad252a37d..6a9ad6d780 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -1283,66 +1283,6 @@ get_font_options (void) return font_options; } -/** - * e_file_update_save_path: - * @uri: URI to store - * @free: If TRUE, free uri - * - * Save the save_dir path for evolution. If free is TRUE, uri gets freed when - * done. Genearally, this should be called with the output of - * gtk_file_chooser_get_current_folder_uri() The URI must be a path URI, not a - * file URI. - **/ -void -e_file_update_save_path (gchar *uri, gboolean free) -{ - GConfClient *gconf = gconf_client_get_default(); - GError *error = NULL; - - gconf_client_set_string(gconf, "/apps/evolution/mail/save_dir", uri, &error); - if (error != NULL) { - g_warning("%s (%s) %s", G_STRLOC, G_STRFUNC, error->message); - g_clear_error(&error); - } - g_object_unref(gconf); - if (free) - g_free(uri); -} - -/** - * e_file_get_save_path: - * - * Return the save_dir path for evolution. If there isn't a save_dir, returns - * the users home directory. Returns an allocated URI that should be freed by - * the caller. - **/ -gchar * -e_file_get_save_path (void) -{ - GConfClient *gconf = gconf_client_get_default(); - GError *error = NULL; - gchar *uri; - - uri = gconf_client_get_string(gconf, "/apps/evolution/mail/save_dir", &error); - if (error != NULL) { - g_warning("%s (%s) %s", G_STRLOC, G_STRFUNC, error->message); - g_clear_error(&error); - } - g_object_unref(gconf); - - if (uri == NULL) { - GFile *file; - - file = g_file_new_for_path (g_get_home_dir ()); - if (file) { - uri = g_file_get_uri (file); - g_object_unref (file); - } - } - - return (uri); -} - /* Evolution Locks for crash recovery */ #define LOCK_FILE ".running" diff --git a/e-util/e-util.h b/e-util/e-util.h index 81ca05327c..d673cfe91a 100644 --- a/e-util/e-util.h +++ b/e-util/e-util.h @@ -129,10 +129,6 @@ gchar * e_ascii_dtostr (gchar *buffer, cairo_font_options_t * get_font_options (void); -void e_file_update_save_path (gchar *uri, - gboolean free); -gchar * e_file_get_save_path (void); - gboolean e_file_lock_create (void); void e_file_lock_destroy (void); gboolean e_file_lock_exists (void); |