2005-07-16 [colin] 1.9.12cvs65
[claws.git] / src / main.c
index 2d32ac56e0330d9eee69b2285316cb35eb983b20..43d5d10704b090ff56f771b7949134101667b5c5 100644 (file)
 #include "main.h"
 #include "mainwindow.h"
 #include "folderview.h"
+#include "image_viewer.h"
 #include "summaryview.h"
 #include "prefs_common.h"
 #include "prefs_account.h"
 #include "prefs_actions.h"
 #include "prefs_ext_prog.h"
 #include "prefs_fonts.h"
+#include "prefs_image_viewer.h"
+#include "prefs_message.h"
+#include "prefs_receive.h"
 #include "prefs_msg_colors.h"
+#include "prefs_quote.h"
 #include "prefs_spelling.h"
+#include "prefs_summaries.h"
 #include "prefs_themes.h"
+#include "prefs_other.h"
+#include "prefs_send.h"
 #include "prefs_wrapping.h"
+#include "prefs_compose_writing.h"
 #include "prefs_display_header.h"
 #include "account.h"
 #include "procmsg.h"
 #include "imap_gtk.h"
 #include "news_gtk.h"
 #include "matcher.h"
+#ifdef HAVE_LIBETPAN
+#include "imap-thread.h"
+#endif
+#include "stock_pixmap.h"
 
 #if USE_OPENSSL
 #  include "ssl.h"
@@ -148,12 +161,6 @@ static void quit_signal_handler         (int sig);
 static void install_basic_sighandlers   (void);
 static void exit_sylpheed              (MainWindow *mainwin);
 
-#if 0
-/* for gettext */
-_("File `%s' already exists.\n"
-  "Can't create folder.")
-#endif
-
 #define MAKE_DIR_IF_NOT_EXIST(dir) \
 { \
        if (!is_dir_exist(dir)) { \
@@ -193,7 +200,7 @@ static void startup_notification_complete(gboolean with_window)
                 * We have to display a window, so let it be very little */
                hack = gtk_window_new(GTK_WINDOW_POPUP);
                gtk_widget_set_uposition(hack, 0, 0);
-               gtk_widget_set_usize(hack, 1, 1);
+               gtk_widget_set_size_request(hack, 1, 1);
                gtk_widget_show(hack);
        }
 
@@ -224,6 +231,7 @@ int main(int argc, char *argv[])
        gchar *userrc;
        MainWindow *mainwin;
        FolderView *folderview;
+       GdkPixbuf *icon;
 
        if (!sylpheed_init(&argc, &argv)) {
                return 0;
@@ -263,6 +271,9 @@ int main(int argc, char *argv[])
                return 0;
        }
 
+       g_thread_init(NULL);
+       /* gdk_threads_init(); */
+
        gtk_set_locale();
        gtk_init(&argc, &argv);
 
@@ -270,11 +281,8 @@ int main(int argc, char *argv[])
        gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
        gtk_widget_set_default_visual(gdk_rgb_get_visual());
 
-#if USE_THREADS || USE_LDAP
-       g_thread_init(NULL);
        if (!g_thread_supported())
                g_error(_("g_thread is not supported by glib.\n"));
-#endif
 
        /* parse gtkrc files */
        userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtkrc-2.0",
@@ -309,21 +317,31 @@ int main(int argc, char *argv[])
        set_log_file(RC_DIR G_DIR_SEPARATOR_S "sylpheed.log");
 
        folder_system_init();
-       prefs_common_init();
        prefs_common_read_config();
 
        prefs_themes_init();
        prefs_fonts_init();
        prefs_ext_prog_init();
        prefs_wrapping_init();
+       prefs_compose_writing_init();
        prefs_msg_colors_init();
+       image_viewer_init();
+       prefs_image_viewer_init();
+       prefs_quote_init();
+       prefs_summaries_init();
+       prefs_message_init();
+       prefs_other_init();
+       prefs_receive_init();
+       prefs_send_init();
 #ifdef USE_ASPELL
        gtkaspell_checkers_init();
        prefs_spelling_init();
 #endif
        
        sock_set_io_timeout(prefs_common.io_timeout_secs);
-
+#ifdef HAVE_LIBETPAN
+       imap_main_set_timeout(prefs_common.io_timeout_secs);
+#endif
        prefs_actions_read_config();
        prefs_display_header_read_config();
        /* prefs_filtering_read_config(); */
@@ -331,6 +349,8 @@ int main(int argc, char *argv[])
        renderer_read_config();
 
        gtkut_widget_init();
+       stock_pixbuf_gdk(NULL, STOCK_PIXMAP_SYLPHEED_ICON, &icon);
+       gtk_window_set_default_icon(icon);
 
        folderview_initialize();
        mh_gtk_init();
@@ -364,6 +384,9 @@ int main(int argc, char *argv[])
                        exit_sylpheed(mainwin);
        }
 
+#ifdef HAVE_LIBETPAN
+       imap_main_init();
+#endif 
        account_set_missing_folder();
        folder_set_missing_folders();
        folderview_set(folderview);
@@ -456,7 +479,9 @@ static void exit_sylpheed(MainWindow *mainwin)
        gchar *filename;
 
        debug_print("shutting down\n");
-
+#ifdef HAVE_LIBETPAN
+       imap_main_done();
+#endif
        inc_autocheck_timer_remove();
 
        if (prefs_common.clean_on_exit)
@@ -486,6 +511,7 @@ static void exit_sylpheed(MainWindow *mainwin)
        g_free(filename);
 
        /* delete temporary files */
+       remove_all_files(get_tmp_dir());
        remove_all_files(get_mime_tmp_dir());
 
        close_log_file();
@@ -508,7 +534,16 @@ static void exit_sylpheed(MainWindow *mainwin)
        prefs_fonts_done();
        prefs_ext_prog_done();
        prefs_wrapping_done();
+       prefs_compose_writing_done();
        prefs_msg_colors_done();
+       prefs_image_viewer_done();
+       image_viewer_done();
+       prefs_quote_done();
+       prefs_summaries_done();
+       prefs_message_done();
+       prefs_other_done();
+       prefs_receive_done();
+       prefs_send_done();
 #ifdef USE_ASPELL       
        prefs_spelling_done();
        gtkaspell_checkers_quit();
@@ -593,22 +628,22 @@ static void parse_cmd_opt(int argc, char *argv[])
                        gchar *base = g_path_get_basename(argv[0]);
                        g_print(_("Usage: %s [OPTION]...\n"), base);
 
-                       g_print(_("  --compose [address]    open composition window"));
-                       g_print(_("  --attach file1 [file2]...\n"
+                       g_print("%s\n", _("  --compose [address]    open composition window"));
+                       g_print("%s\n", _("  --attach file1 [file2]...\n"
                                  "                         open composition window with specified files\n"
                                  "                         attached"));
-                       g_print(_("  --receive              receive new messages"));
-                       g_print(_("  --receive-all          receive new messages of all accounts"));
-                       g_print(_("  --send                 send all queued messages"));
-                       g_print(_("  --status [folder]...   show the total number of messages"));
-                       g_print(_("  --status-full [folder]...\n"
+                       g_print("%s\n", _("  --receive              receive new messages"));
+                       g_print("%s\n", _("  --receive-all          receive new messages of all accounts"));
+                       g_print("%s\n", _("  --send                 send all queued messages"));
+                       g_print("%s\n", _("  --status [folder]...   show the total number of messages"));
+                       g_print("%s\n", _("  --status-full [folder]...\n"
                               "                         show the status of each folder"));
-                       g_print(_("  --online               switch to online mode"));
-                       g_print(_("  --offline              switch to offline mode"));
-                       g_print(_("  --debug                debug mode"));
-                       g_print(_("  --help                 display this help and exit"));
-                       g_print(_("  --version              output version information and exit"));
-                       g_print(_("  --config-dir           output configuration directory"));
+                       g_print("%s\n", _("  --online               switch to online mode"));
+                       g_print("%s\n", _("  --offline              switch to offline mode"));
+                       g_print("%s\n", _("  --debug                debug mode"));
+                       g_print("%s\n", _("  --help                 display this help and exit"));
+                       g_print("%s\n", _("  --version              output version information and exit"));
+                       g_print("%s\n", _("  --config-dir           output configuration directory"));
 
                        g_free(base);
                        exit(1);
@@ -663,15 +698,11 @@ static void initial_processing(FolderItem *item, gpointer data)
 
 static void draft_all_messages(void)
 {
-       GList *compose_list = compose_get_compose_list();
-       GList *elem = NULL;
+       GList *compose_list = NULL;
        
-       if (compose_list) {
-               for (elem = compose_list; elem != NULL && elem->data != NULL; 
-                    elem = elem->next) {
-                       Compose *c = (Compose*)elem->data;
-                       compose_draft(c);
-               }
+       while ((compose_list = compose_get_compose_list()) != NULL) {
+               Compose *c = (Compose*)compose_list->data;
+               compose_draft(c);
        }       
 }