untwist file selection logic - be explicit
authorColin Leroy <colin@colino.net>
Wed, 21 Jul 2004 09:39:52 +0000 (09:39 +0000)
committerColin Leroy <colin@colino.net>
Wed, 21 Jul 2004 09:39:52 +0000 (09:39 +0000)
15 files changed:
ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/compose.c
src/crash.c
src/export.c
src/gtk/filesel.c
src/gtk/filesel.h
src/gtk/pluginwindow.c
src/import.c
src/messageview.c
src/mimeview.c
src/prefs_spelling.c
src/prefs_themes.c
src/summaryview.c

index 63a77850be348a7fa5cd91d6efe3fd7825a10525..b8c36472259218f792123b4e256a63c2b3a40275 100644 (file)
@@ -1,3 +1,20 @@
+2004-07-21 [colin]     0.9.12cvs33.10
+
+       * src/compose.c
+       * src/crash.c
+       * src/export.c
+       * src/import.c
+       * src/messageview.c
+       * src/mimeview.c
+       * src/prefs_spelling.c
+       * src/prefs_themes.c
+       * src/summaryview.c
+       * src/gtk/filesel.c
+       * src/gtk/filesel.h
+       * src/gtk/pluginwindow.c
+               Untwist open/save mode guessing logic, make
+               it explicit
+
 2004-07-20 [colin]     0.9.12cvs33.9
 
        * src/codeconv.c
index adf19fc40be58847ca0db81087662492ab16f3a6..d8124987a319dc11c1c733f58fbc03b5d109ac1c 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
@@ -63,3 +63,4 @@
 ( cvs diff -u -r 1.274.2.10 -r 1.274.2.11 src/mainwindow.c; ) > 0.9.12cvs33.7.patchset
 ( cvs diff -u -r 1.65.2.8 -r 1.65.2.9 src/codeconv.c; ) > 0.9.12cvs33.8.patchset
 ( cvs diff -u -r 1.65.2.9 -r 1.65.2.10 src/codeconv.c; cvs diff -u -r 1.382.2.29 -r 1.382.2.30 src/compose.c; ) > 0.9.12cvs33.9.patchset
+( cvs diff -u -r 1.382.2.31 -r 1.382.2.32 src/compose.c; cvs diff -u -r 1.23.2.3 -r 1.23.2.4 src/crash.c; cvs diff -u -r 1.8.2.1 -r 1.8.2.2 src/export.c; cvs diff -u -r 1.13.2.2 -r 1.13.2.3 src/import.c; cvs diff -u -r 1.94.2.22 -r 1.94.2.23 src/messageview.c; cvs diff -u -r 1.83.2.12 -r 1.83.2.13 src/mimeview.c; cvs diff -u -r 1.5.2.1 -r 1.5.2.2 src/prefs_spelling.c; cvs diff -u -r 1.3.2.5 -r 1.3.2.6 src/prefs_themes.c; cvs diff -u -r 1.395.2.23 -r 1.395.2.24 src/summaryview.c; cvs diff -u -r 1.2.2.8 -r 1.2.2.9 src/gtk/filesel.c; cvs diff -u -r 1.1.4.1 -r 1.1.4.2 src/gtk/filesel.h; cvs diff -u -r 1.5.2.3 -r 1.5.2.4 src/gtk/pluginwindow.c; ) > 0.9.12cvs33.10.patchset
index a1248bff5c9f614225cef7ca018fbc349ac0b3c6..123936386e26e192a170ac5cc3ebb41dd025f97b 100644 (file)
@@ -13,7 +13,7 @@ INTERFACE_AGE=0
 BINARY_AGE=0
 EXTRA_VERSION=33
 EXTRA_RELEASE=
-EXTRA_GTK2_VERSION=.9
+EXTRA_GTK2_VERSION=.10
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}${EXTRA_RELEASE}${EXTRA_GTK2_VERSION}
index 6487f64005bb266bf9addfaaf02fe74929c001f3..ffb44b70cba27377f7f889af04338964ad6f82b5 100644 (file)
@@ -6670,7 +6670,7 @@ static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget)
        if (compose->redirect_filename != NULL)
                return;
 
-       file_list = filesel_select_multiple_files(_("Select file"));
+       file_list = filesel_select_multiple_files_open(_("Select file"));
 
        if (file_list) {
                GList *tmp;
@@ -6691,7 +6691,7 @@ static void compose_insert_file_cb(gpointer data, guint action,
        Compose *compose = (Compose *)data;
        GList *file_list;
 
-       file_list = filesel_select_multiple_files(_("Select file"));
+       file_list = filesel_select_multiple_files_open(_("Select file"));
 
        if (file_list) {
                GList *tmp;
index 04a1f53ce1ae48566348cec278ec695e9ea6984a..ec91e910fb80637a745787b56431d42b00204366 100644 (file)
@@ -296,7 +296,7 @@ static void crash_save_crash_log(GtkButton *button, const gchar *text)
        timer = time(NULL);
        lt = localtime(&timer);
        strftime(buf, sizeof buf, "sylpheed-crash-log-%Y-%m-%d-%H-%M-%S.txt", lt);
-       if (NULL != (filename = filesel_select_file(_("Save crash information"), buf))
+       if (NULL != (filename = filesel_select_file_save(_("Save crash information"), buf))
        &&  *filename)
                str_write_to_file(text, filename);
        g_free(filename);       
index 7859b31a3950975af603324ff5b262e82e4f8861..08c17c3c140ecd0446e4268add866a8594783031 100644 (file)
@@ -230,7 +230,7 @@ static void export_filesel_cb(GtkWidget *widget, gpointer data)
 {
        gchar *filename;
 
-       filename = filesel_select_file(_("Select exporting file"), NULL);
+       filename = filesel_select_file_save(_("Select exporting file"), NULL);
        if (!filename) return;
 
        if (g_getenv ("G_BROKEN_FILENAMES")) {
index 315e0f46cf7837620a41b48a166c3f78432bf424..b24e40fee9031abbcfc2a806cb650889538a05bc 100644 (file)
 #include "utils.h"
 
 static gchar *last_selected_dir = NULL;
-static GList *filesel_create(const gchar *title, const gchar *path, gboolean multiple_files)
+static GList *filesel_create(const gchar *title, const gchar *path, 
+                            gboolean multiple_files,
+                            gboolean open)
 {
        GSList *slist = NULL, *slist_orig = NULL;
        GList *list = NULL;
 
-       gint action = (path != NULL) ? GTK_FILE_CHOOSER_ACTION_SAVE:GTK_FILE_CHOOSER_ACTION_OPEN;
-       gchar * action_btn = (path != NULL) ? GTK_STOCK_SAVE:GTK_STOCK_OPEN;
+       gint action = (open == TRUE) ? GTK_FILE_CHOOSER_ACTION_OPEN:GTK_FILE_CHOOSER_ACTION_SAVE;
+       gchar * action_btn = (open == TRUE) ? GTK_STOCK_OPEN:GTK_STOCK_SAVE;
        GtkWidget *chooser = gtk_file_chooser_dialog_new (title, NULL, action, 
                                GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                action_btn, GTK_RESPONSE_OK, 
@@ -64,7 +66,9 @@ static GList *filesel_create(const gchar *title, const gchar *path, gboolean mul
        if (path) {
                char *filename = NULL;
                char *realpath = strdup(path);
-               if ((filename = strrchr(path, G_DIR_SEPARATOR)) != NULL) {
+               if (path[strlen(path)-1] == G_DIR_SEPARATOR) {
+                       filename = "";
+               } else if ((filename = strrchr(path, G_DIR_SEPARATOR)) != NULL) {
                        filename++;
                        *(strrchr(realpath, G_DIR_SEPARATOR)+1) = '\0';
                } else {
@@ -117,9 +121,9 @@ static GList *filesel_create(const gchar *title, const gchar *path, gboolean mul
  * This opens an Open type dialog.
  * @param title the title of the dialog
  */
-GList *filesel_select_multiple_files(const gchar *title)
+GList *filesel_select_multiple_files_open(const gchar *title)
 {
-       return filesel_create(title, NULL, TRUE);
+       return filesel_create(title, NULL, TRUE, TRUE);
 }
 
 /**
@@ -129,9 +133,10 @@ GList *filesel_select_multiple_files(const gchar *title)
  * @param title the title of the dialog
  * @param path the optional path to save to
  */
-gchar *filesel_select_file(const gchar *title, const gchar *path)
+static gchar *filesel_select_file(const gchar *title, const gchar *path,
+                                 gboolean open)
 {
-       GList * list = filesel_create(title, path, FALSE);
+       GList * list = filesel_create(title, path, FALSE, open);
        gchar * result = NULL;
        if (list) {
                result = strdup(list->data);
@@ -139,3 +144,12 @@ gchar *filesel_select_file(const gchar *title, const gchar *path)
        g_list_free(list);
        return result;
 }
+gchar *filesel_select_file_open(const gchar *title, const gchar *path)
+{
+       return filesel_select_file (title, path, TRUE);
+}
+
+gchar *filesel_select_file_save(const gchar *title, const gchar *path)
+{
+       return filesel_select_file (title, path, FALSE);
+}
index 80dcd47af8c5efbd9edfd8af078bd0995cba9194..c864b35a469fcb48624840b19f91c6610d9c94a2 100644 (file)
@@ -22,8 +22,9 @@
 
 #include <glib.h>
 
-gchar *filesel_select_file(const gchar *title, const gchar *path);
+gchar *filesel_select_file_open(const gchar *title, const gchar *path);
+gchar *filesel_select_file_save(const gchar *title, const gchar *path);
 
-GList *filesel_select_multiple_files(const gchar *title);
+GList *filesel_select_multiple_files_open(const gchar *title);
 
 #endif /* __FILESEL_H__ */
index f3ffb1a6c2eeb8af52569ff1f95244c738f38b7f..f38c05da02cfda0f5fef518a42810de44db0946c 100644 (file)
@@ -120,7 +120,7 @@ static void load_cb(GtkButton *button, PluginWindow *pluginwindow)
 {
        gchar *file, *error = NULL;
 
-       file = filesel_select_file(_("Select Plugin to load"), PLUGINDIR);
+       file = filesel_select_file_open(_("Select Plugin to load"), PLUGINDIR);
        if (file == NULL)
                return;
 
index 6f5c31576e05cf302a7627acf7bae17d42c774d3..63395b72b01f0d6f5bce96a236809a9146b25c1b 100644 (file)
@@ -235,7 +235,7 @@ static void import_filesel_cb(GtkWidget *widget, gpointer data)
 {
        gchar *filename;
 
-       filename = filesel_select_file(_("Select importing file"), NULL);
+       filename = filesel_select_file_open(_("Select importing file"), NULL);
        if (!filename) return;
 
        if (g_getenv ("G_BROKEN_FILENAMES")) {
index 3f611d7db329f4e0071d752d19c423ade3d7ade9..4f6071c8fcb96e219e778ccf0ef2487a147e65ad 100644 (file)
@@ -953,7 +953,7 @@ void messageview_save_as(MessageView *messageview)
                Xstrdup_a(filename, msginfo->subject, return);
                subst_for_filename(filename);
        }
-       dest = filesel_select_file(_("Save as"), filename);
+       dest = filesel_select_file_save(_("Save as"), filename);
        if (!dest) return;
        if (is_file_exist(dest)) {
                AlertValue aval;
index 8361bf0805151979bb7fbc3d56e01e4d79827100..2705ed8a520320dc0d250c7572e6ebf596f8903e 100644 (file)
@@ -1059,7 +1059,7 @@ static void mimeview_save_all(MimeView *mimeview)
                startdir = g_strconcat(prefs_common.attach_save_dir,
                                       G_DIR_SEPARATOR_S, NULL);
 
-       dirname = filesel_select_file(_("Select destination folder"), startdir);
+       dirname = filesel_select_file_open(_("Select destination folder"), startdir);
        if (!dirname) {
                if (startdir) g_free(startdir);
                return;
@@ -1133,7 +1133,7 @@ static void mimeview_save_as(MimeView *mimeview)
        else
                filepath = g_strdup(defname);
 
-       filename = filesel_select_file(_("Save as"), filepath);
+       filename = filesel_select_file_save(_("Save as"), filepath);
        if (!filename) {
                g_free(filepath);
                return;
index 0e3607a5f8d9c168e8fed524b52801473a6ce240..23560f9a821bb83e2d28b96b82f7020dcc6e2e38 100644 (file)
@@ -92,7 +92,7 @@ static void prefs_spelling_btn_aspell_path_clicked_cb(GtkWidget *widget,
        gchar *file_path;
        GtkWidget *new_menu;
 
-       file_path = filesel_select_file(_("Select dictionaries location"),
+       file_path = filesel_select_file_open(_("Select dictionaries location"),
                                        prefs_common.aspell_path);
        if (file_path != NULL) {
                gchar *tmp_path, *tmp;
index a816f292e3a8afd0ac50faa1166077a696545ec9..cbb43eb128499db33921ac6c6babb9414fc61dde 100644 (file)
@@ -454,7 +454,7 @@ static void prefs_themes_btn_install_clicked_cb(GtkWidget *widget, gpointer data
        AlertValue  val = 0;
        ThemesData *tdata = prefs_themes_data;
        
-       filename = filesel_select_file(_("Select theme folder"), NULL);
+       filename = filesel_select_file_open(_("Select theme folder"), NULL);
        if (filename == NULL) 
                return;
        
index 2510b919e0f21facc852015afa26db232ea83ec9..ac8fcb6f0c0c84faf78bd449587feca557c968fb 100644 (file)
@@ -3264,10 +3264,10 @@ void summary_save_as(SummaryView *summaryview)
                        g_warning("summary_save_as(): faild to convert character set.");
                        filename = g_strdup(oldstr);
                }
-               dest = filesel_select_file(_("Save as"), filename);
+               dest = filesel_select_file_save(_("Save as"), filename);
                g_free(filename);
        } else
-               dest = filesel_select_file(_("Save as"), filename);
+               dest = filesel_select_file_save(_("Save as"), filename);
        filename = NULL;
        if (!dest) return;
        if (is_file_exist(dest)) {