2006-12-14 [colin] 2.6.1cvs35
[claws.git] / src / main.c
index c30e681c1210da41c291558b84757ed892fb2010..14202eaba97084e79aa5265ec20b4af54ac46c21 100644 (file)
@@ -51,7 +51,7 @@
 # include <gdk/gdkx.h>
 #endif
 
-#include "sylpheed.h"
+#include "claws.h"
 #include "main.h"
 #include "mainwindow.h"
 #include "folderview.h"
@@ -170,7 +170,7 @@ static void send_queue                      (void);
 static void initial_processing         (FolderItem *item, gpointer data);
 static void quit_signal_handler         (int sig);
 static void install_basic_sighandlers   (void);
-static void exit_sylpheed              (MainWindow *mainwin);
+static void exit_claws                 (MainWindow *mainwin);
 
 #define MAKE_DIR_IF_NOT_EXIST(dir) \
 { \
@@ -234,7 +234,7 @@ static void startup_notification_complete(gboolean with_window)
 }
 #endif /* HAVE_STARTUP_NOTIFICATION */
 
-void sylpheed_gtk_idle(void) 
+void claws_gtk_idle(void) 
 {
        while(gtk_events_pending()) {
                gtk_main_iteration();
@@ -273,7 +273,7 @@ static gboolean migrate_old_config(const gchar *old_cfg_dir, const gchar *new_cf
        GtkWidget *window = NULL;
        if (alertpanel(_("Migration of configuration"),
                       message,
-                      GTK_STOCK_NO, GTK_STOCK_YES, NULL) != G_ALERTALTERNATE) {
+                      GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL) != G_ALERTALTERNATE) {
                return FALSE;
        }
        
@@ -501,6 +501,9 @@ static void sc_session_manager_connect(MainWindow *mainwin)
 }
 #endif
 
+static gboolean sc_exiting = FALSE;
+static gboolean sc_starting = FALSE;
+
 int main(int argc, char *argv[])
 {
        gchar *userrc;
@@ -511,7 +514,9 @@ int main(int argc, char *argv[])
        gint num_folder_class = 0;
        START_TIMING("startup");
        
-       if (!sylpheed_init(&argc, &argv)) {
+       sc_starting = TRUE;
+
+       if (!claws_init(&argc, &argv)) {
                return 0;
        }
 
@@ -602,11 +607,11 @@ int main(int argc, char *argv[])
                prefs_destroy_cache();
                gboolean r = FALSE;
                if (is_dir_exist(OLD_GTK2_RC_DIR))
-                       r = migrate_old_config(OLD_GTK2_RC_DIR, RC_DIR, _("Sylpheed-Claws 2.6.0"));
+                       r = migrate_old_config(OLD_GTK2_RC_DIR, RC_DIR, "Sylpheed-Claws 2.6.0");
                else if (is_dir_exist(OLDER_GTK2_RC_DIR))
-                       r = migrate_old_config(OLDER_GTK2_RC_DIR, RC_DIR, _("Sylpheed-Claws 1.9.15"));
+                       r = migrate_old_config(OLDER_GTK2_RC_DIR, RC_DIR, "Sylpheed-Claws 1.9.15");
                else if (is_dir_exist(OLD_GTK1_RC_DIR))
-                       r = migrate_old_config(OLD_GTK1_RC_DIR, RC_DIR, _("Sylpheed-Claws 1.0.5"));
+                       r = migrate_old_config(OLD_GTK1_RC_DIR, RC_DIR, "Sylpheed-Claws 1.0.5");
                if (r == FALSE && !is_dir_exist(RC_DIR) && make_dir(RC_DIR) < 0)
                        exit(1);
        }
@@ -728,8 +733,10 @@ int main(int argc, char *argv[])
                if (!run_wizard(mainwin, FALSE))
                        exit(1);
                account_read_config_all();
-               if(!account_get_list())
-                       exit_sylpheed(mainwin);
+               if(!account_get_list()) {
+                       exit_claws(mainwin);
+                       exit(1);
+               }
        }
 
        
@@ -747,11 +754,11 @@ int main(int argc, char *argv[])
 
        prefs_matcher_read_config();
 
-       /* make one all-folder processing before using sylpheed */
+       /* make one all-folder processing before using claws */
        main_window_cursor_wait(mainwin);
        folder_func_to_all_folders(initial_processing, (gpointer *)mainwin);
 
-       /* if Sylpheed crashed, rebuild caches */
+       /* if claws crashed, rebuild caches */
        if (!cmd.crash && crash_file_present) {
                GTK_EVENTS_FLUSH();
                debug_print("Claws Mail crashed, checking for new messages in local folders\n");
@@ -785,7 +792,7 @@ int main(int argc, char *argv[])
                cmd.status_full_folders = NULL;
        }
 
-       sylpheed_register_idle_function(sylpheed_gtk_idle);
+       claws_register_idle_function(claws_gtk_idle);
 
        prefs_toolbar_init();
 
@@ -811,12 +818,21 @@ int main(int argc, char *argv[])
        if (!folder_have_mailbox()) {
                prefs_destroy_cache();
                main_window_cursor_normal(mainwin);
-               alertpanel_error(_("Claws Mail has detected a configured "
+               if (folder_get_list() != NULL) {
+                       alertpanel_error(_("Claws Mail has detected a configured "
+                                  "mailbox, but is it incomplete. It is "
+                                  "possibly due to a failing IMAP account. Use "
+                                  "\"Rebuild folder tree\" on the mailbox's folder "
+                                  "to try to fix it."));
+               } else {
+                       alertpanel_error(_("Claws Mail has detected a configured "
                                   "mailbox, but could not load it. It is "
                                   "probably provided by an out-of-date "
                                   "external plugin. Please reinstall the "
                                   "plugin and try again."));
-               exit(1);
+                       exit_claws(mainwin);
+                       exit(1);
+               }
        }
        
        static_mainwindow = mainwin;
@@ -862,10 +878,13 @@ int main(int argc, char *argv[])
        }
 
        prefs_destroy_cache();
+       
+       sc_starting = FALSE;
        END_TIMING();
+       
        gtk_main();
 
-       exit_sylpheed(mainwin);
+       exit_claws(mainwin);
 
        return 0;
 }
@@ -882,9 +901,7 @@ static void save_all_caches(FolderItem *item, gpointer data)
        folder_item_free_cache(item, TRUE);
 }
 
-static gboolean sc_exiting = FALSE;
-
-static void exit_sylpheed(MainWindow *mainwin)
+static void exit_claws(MainWindow *mainwin)
 {
        gchar *filename;
 
@@ -967,7 +984,7 @@ static void exit_sylpheed(MainWindow *mainwin)
        gtkaspell_checkers_quit();
 #endif
        plugin_unload_all("Common");
-       sylpheed_done();
+       claws_done();
 }
 
 static void parse_cmd_opt(int argc, char *argv[])
@@ -1007,7 +1024,7 @@ static void parse_cmd_opt(int argc, char *argv[])
                                        cmd.attach_files = g_ptr_array_new();
                                }
                                if (*p != G_DIR_SEPARATOR) {
-                                       file = g_strconcat(sylpheed_get_startup_dir(),
+                                       file = g_strconcat(claws_get_startup_dir(),
                                                           G_DIR_SEPARATOR_S,
                                                           p, NULL);
                                } else {
@@ -1190,7 +1207,7 @@ gboolean clean_quit(gpointer data)
                
        draft_all_messages();
        emergency_exit = TRUE;
-       exit_sylpheed(static_mainwindow);
+       exit_claws(static_mainwindow);
        exit(0);
 
        return FALSE;
@@ -1240,11 +1257,16 @@ void app_will_exit(GtkWidget *widget, gpointer data)
        gtk_main_quit();
 }
 
-gboolean sylpheed_is_exiting(void)
+gboolean claws_is_exiting(void)
 {
        return sc_exiting;
 }
 
+gboolean claws_is_starting(void)
+{
+       return sc_starting;
+}
+
 /*
  * CLAWS: want this public so crash dialog can delete the
  * lock file too