2005-10-10 [colin] 1.9.15cvs27
[claws.git] / src / import.c
index 642594abbd9b51b7fe23e1dd3547a03e7deea45a..2e66423b97271b19b42e9c124c6ce3085f1dac53 100644 (file)
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -24,6 +24,7 @@
 #include "defs.h"
 
 #include <glib.h>
+#include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtkmain.h>
 #include <gtk/gtkwidget.h>
@@ -37,7 +38,7 @@
 #include <gtk/gtkfilesel.h>
 #include <gtk/gtksignal.h>
 
-#include "intl.h"
+#include "sylpheed.h"
 #include "main.h"
 #include "inc.h"
 #include "mbox.h"
@@ -71,20 +72,26 @@ gint import_mbox(FolderItem *default_dest)
        gint ok = 0;
        gchar *dest_id = NULL;
 
-       if (!window)
+       if (!window) {
                import_create();
-       else
+       }
+       else {
                gtk_widget_show(window);
+       }
 
-       gtk_entry_set_text(GTK_ENTRY(file_entry), "");
-       if (default_dest && default_dest->path)
+       change_dir(sylpheed_get_startup_dir());
+
+       if (default_dest && default_dest->path) {
                dest_id = folder_item_get_identifier(default_dest);
+       }
 
        if (dest_id) {
                gtk_entry_set_text(GTK_ENTRY(dest_entry), dest_id);
                g_free(dest_id);
-       } else
+       } else {
                gtk_entry_set_text(GTK_ENTRY(dest_entry), "");
+       }
+       gtk_entry_set_text(GTK_ENTRY(file_entry), "");
        gtk_widget_grab_focus(file_entry);
 
        manage_window_set_transient(GTK_WINDOW(window));
@@ -92,34 +99,34 @@ gint import_mbox(FolderItem *default_dest)
        gtk_main();
 
        if (import_ack) {
-               const gchar *utf8filename, *destdir;
+               const gchar *utf8mbox, *destdir;
                FolderItem *dest;
 
-               utf8filename = gtk_entry_get_text(GTK_ENTRY(file_entry));
+               utf8mbox = gtk_entry_get_text(GTK_ENTRY(file_entry));
                destdir = gtk_entry_get_text(GTK_ENTRY(dest_entry));
-               if (utf8filename && *utf8filename) {
-                       gchar *filename;
-
-                       filename = g_filename_from_utf8
-                               (utf8filename, -1, NULL, NULL, NULL);
-                       if (!filename) {
-                               g_warning("faild to convert character set\n");
-                               filename = g_strdup(utf8filename);
+               if (utf8mbox && *utf8mbox) {
+                       gchar *mbox;
+
+                       mbox = g_filename_from_utf8(utf8mbox, -1, NULL, NULL, NULL);
+                       if (!mbox) {
+                               g_warning("Failed to convert character set.\n");
+                               mbox = g_strdup(utf8mbox);
                        }
 
                        if (!destdir || !*destdir) {
                                dest = folder_find_item_from_path(INBOX_DIR);
-                       } else
+                       } else {
                                dest = folder_find_item_from_identifier
                                        (destdir);
+                       }
 
                        if (!dest) {
                                g_warning("Can't find the folder.\n");
                        } else {
-                               ok = proc_mbox(dest, filename, FALSE);
+                               ok = proc_mbox(dest, mbox, FALSE);
                        }
 
-                       g_free(filename);
+                       g_free(mbox);
                }
        }
 
@@ -186,14 +193,25 @@ static void import_create(void)
        gtk_table_attach(GTK_TABLE(table), dest_entry, 1, 2, 1, 2,
                         GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
 
+#if GTK_CHECK_VERSION(2, 6, 0)
+       file_button = gtk_button_new_with_mnemonic(_("_Browse"));
+       gtk_button_set_image((GtkButton*)file_button,
+               gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON));
+#else
        file_button = gtk_button_new_from_stock(GTK_STOCK_OPEN);
+#endif
        gtk_table_attach(GTK_TABLE(table), file_button, 2, 3, 0, 1,
                         0, 0, 0, 0);
        g_signal_connect(G_OBJECT(file_button), "clicked",
                         G_CALLBACK(import_filesel_cb), NULL);
 
-       /* XXX GTK 2.6: GTK_STOCK_DIRECTORY */
+#if GTK_CHECK_VERSION(2, 6, 0)
+       dest_button = gtk_button_new_with_mnemonic(_("B_rowse"));
+       gtk_button_set_image((GtkButton*)dest_button,
+               gtk_image_new_from_stock(GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_BUTTON));
+#else
        dest_button = gtk_button_new_from_stock(GTK_STOCK_OPEN);
+#endif
        gtk_table_attach(GTK_TABLE(table), dest_button, 2, 3, 1, 2,
                         0, 0, 0, 0);
        g_signal_connect(G_OBJECT(dest_button), "clicked",