2005-10-16 [colin] 1.9.15cvs63
[claws.git] / src / wizard.c
index 8ed31f5718887d3bd223f883d7a609d6ed90ae0a..164b46a1a5340aa58a99dd39e8ca44f9f4dad8d8 100644 (file)
@@ -58,6 +58,8 @@
 #ifdef USE_OPENSSL                     
 #include "ssl.h"
 #endif
+#include "prefs_common.h"
+
 typedef enum
 {
        GO_BACK,
@@ -103,6 +105,107 @@ typedef struct
 
 } WizardWindow;
 
+static void initialize_fonts(WizardWindow *wizard)
+{
+       GtkWidget *widget = wizard->email;
+       gint size = pango_font_description_get_size(
+                       widget->style->font_desc)
+                     /PANGO_SCALE;
+       gchar *tmp, *new;
+       
+       tmp = g_strdup(prefs_common.textfont);
+       if (strrchr(tmp, ' ')) {
+               *(strrchr(tmp, ' ')) = '\0';
+               new = g_strdup_printf("%s %d", tmp, size);
+               g_free(prefs_common.textfont);
+               prefs_common.textfont = new;
+       }
+       g_free(tmp);
+       
+       tmp = g_strdup(prefs_common.smallfont);
+       if (strrchr(tmp, ' ')) {
+               *(strrchr(tmp, ' ')) = '\0';
+               new = g_strdup_printf("%s %d", tmp, size);
+               g_free(prefs_common.smallfont);
+               prefs_common.smallfont = new;
+       }
+       g_free(tmp);
+       
+       tmp = g_strdup(prefs_common.normalfont);
+       if (strrchr(tmp, ' ')) {
+               *(strrchr(tmp, ' ')) = '\0';
+               new = g_strdup_printf("%s %d", tmp, size);
+               g_free(prefs_common.normalfont);
+               prefs_common.normalfont = new;
+       }
+       g_free(tmp);
+}
+
+static void write_welcome_email(WizardWindow *wizard)
+{
+       gchar buf_date[64];
+       gchar *body=NULL;
+       const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name));
+       Folder *folder = folder_find_from_path(mailbox);
+       FolderItem *inbox = folder ? folder->inbox:NULL;
+       gchar *file = get_tmp_file();
+       
+       get_rfc822_date(buf_date, sizeof(buf_date));
+
+       body = g_strdup_printf(
+               "From: Sylpheed-Claws Team <sylpheed-claws-users@lists.sf.net>\n"
+               "To: %s <%s>\n"
+               "Date: %s\n"
+               "Subject: Welcome to Sylpheed-Claws.\n"
+               "\n"
+               "Welcome to Sylpheed-Claws\n"
+               "-------------------------\n"
+               "\n"
+               "Now that you have set up your account you can fetch your\n"
+               "mail by clicking the 'Get All' button at the left of the\n"
+               "toolbar.\n"
+               "\n"
+               "You can change your Account Preferences by using the menu\n"
+               "entry '/Configuration/Preferences for current account'\n"
+               "and change the general Preferences by using\n"
+               "'/Configuration/Preferences'.\n"
+               "\n"
+               "You can find futher information in the Sylpheed-Claws manual,\n"
+               "which can be accessed by using the menu entry '/Help/Manual'\n"
+               "or online at the URL given below.\n"
+               "\n"
+               "Useful URLs\n"
+               "-----------\n"
+               "Homepage:      <http://claws.sylpheed.org>\n"
+               "Manual:        <http://claws.sylpheed.org/manual/>\n"
+               "FAQ:          <http://claws.sylpheed.org/faq.php>\n"
+               "Themes:        <http://claws.sylpheed.org/themes.php>\n"
+               "Mailing Lists: <http://claws.sylpheed.org/MLs.php>\n"
+               "\n"
+               "LICENSE\n"
+               "-------\n"
+               "Sylpheed-Claws is free software, released under the terms\n"
+               "of the GNU General Public License, version 2 or later, as\n"
+               "published by the Free Software Foundation, 51 Franklin Street,\n"
+               "Fifth Floor, Boston, MA 02110-1301, USA. The license can be\n"
+               "found at <http://www.gnu.org/licenses/gpl.html>.\n"
+               "\n"
+               "DONATIONS\n"
+               "---------\n"
+               "If you wish to donate to the Sylpheed-Claws project you can do\n"
+               "so at <https://sourceforge.net/donate/index.php?group_id=25528>.",             
+               gtk_entry_get_text(GTK_ENTRY(wizard->full_name)),
+               gtk_entry_get_text(GTK_ENTRY(wizard->email)),
+               buf_date);
+       
+       if (inbox && inbox->total_msgs == 0
+        && str_write_to_file(body, file) >= 0) {
+               MsgFlags flags = { MSG_UNREAD|MSG_NEW, 0};
+               folder_item_add_msg(inbox, file, &flags, FALSE);
+       }
+       g_free(body);
+       g_unlink(file); 
+}
 static gboolean wizard_write_config(WizardWindow *wizard)
 {
        gboolean mailbox_ok = FALSE;
@@ -114,7 +217,7 @@ static gboolean wizard_write_config(WizardWindow *wizard)
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
        prefs_account->protocol = GPOINTER_TO_INT
                        (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
-
+       
        if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
                mailbox_ok = setup_write_mailbox_path(wizard->mainwin, 
                                gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
@@ -180,6 +283,10 @@ static gboolean wizard_write_config(WizardWindow *wizard)
        prefs_account_write_config_all(account_list);
        prefs_account_free(prefs_account);
        account_read_config_all();
+
+       initialize_fonts(wizard);
+       if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
+               write_welcome_email(wizard);
        
        return TRUE;
 }
@@ -595,6 +702,8 @@ static gint wizard_close_cb(GtkWidget *widget, GdkEventAny *event,
        WizardWindow *wizard = (WizardWindow *)data;
        wizard->result = FALSE;
        wizard->finished = TRUE;
+       
+       return FALSE;
 }
 
 gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {