preferences for folder items
authorChristoph Hohmann <reboot@gmx.ch>
Tue, 24 Jul 2001 20:30:26 +0000 (20:30 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Tue, 24 Jul 2001 20:30:26 +0000 (20:30 +0000)
ChangeLog.claws
src/compose.c
src/compose.h
src/folderview.c
src/mainwindow.c
src/menu.c
src/menu.h
src/prefs_folder_item.c
src/prefs_folder_item.h
src/summaryview.c

index b313b62e6cb93df7301148d7efad971b0cd47333..1c3db058078e2c8518492502e5a1b3fc951f9c64 100644 (file)
@@ -3,10 +3,24 @@
        * src/summaryview.c
                fixed segfault that happend when the selected
                message was removed while retrieving new messages.
+
        * po/es.po
                updated translation
                (submitted by Ricardo Mones Lastra <mones@trasgu.aic.uniovi.es>)
 
+       * src/folderview.c
+       * src/prefs_folder_item.[ch]
+               added folderitem preferences dialog with
+               default To: and auto request return receipt
+
+       * src/compose.[ch]
+       * src/menu.[ch]
+               changes to handle new folderitem preferences
+
+       * src/mainwindow.c
+       * src/summaryview.c
+               call compose new mail with current folderitem
+
 2001-07-22 [alfons]
 
        add English User Manual for Sylpheed by Paul Kater (paul@nlpagan.net).
index edd6164728a1bd292bb0bcab9d9b307f11e3cb33..f3afaea9fbf70ee874d86b827e33d90a26992655 100644 (file)
@@ -388,6 +388,10 @@ static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
                                  gboolean ignore_replyto,
                                  gboolean followup_and_reply_to);
 
+Compose * compose_generic_new (PrefsAccount    *account,
+                              const gchar      *to,
+                              FolderItem       *item);
+
 static GtkItemFactoryEntry compose_popup_entries[] =
 {
        {N_("/_Add..."),        NULL, compose_attach_cb, 0, NULL},
@@ -455,10 +459,20 @@ static GtkTargetEntry compose_mime_types[] =
 
 Compose * compose_new(PrefsAccount *account)
 {
-       return compose_new_with_recipient(account, NULL);
+       return compose_generic_new(account, NULL, NULL);
 }
 
 Compose * compose_new_with_recipient(PrefsAccount *account, const gchar *to)
+{
+       return compose_generic_new(account, to, NULL);
+}
+
+Compose * compose_new_with_folderitem(PrefsAccount *account, FolderItem *item)
+{
+       return compose_generic_new(account, NULL, item);
+}
+
+Compose * compose_generic_new(PrefsAccount *account, const gchar *to, FolderItem *item)
 {
        Compose *compose;
 
@@ -477,8 +491,19 @@ Compose * compose_new_with_recipient(PrefsAccount *account, const gchar *to)
                if (to) {
                        compose_entry_append(compose, to, COMPOSE_TO);
                        gtk_widget_grab_focus(compose->subject_entry);
-               } else
-                       gtk_widget_grab_focus(compose->to_entry);
+               } else {
+                       if(item && item->prefs->enable_default_to) {
+                               compose_entry_append(compose, item->prefs->default_to, COMPOSE_TO);
+                       } else {
+                               gtk_widget_grab_focus(compose->to_entry);
+                       }
+               }
+               if(item && item->prefs->request_return_receipt) {
+                       GtkItemFactory *ifactory;
+               
+                       ifactory = gtk_item_factory_from_widget(compose->menubar);
+                       menu_set_toggle(ifactory, "/Message/Request Return Receipt", TRUE);
+               }
        } else {
                if (to) {
                        compose_entry_append(compose, to, COMPOSE_NEWSGROUPS);
index e885eaddc7b6b173e69cfd6a5a814c09b1df4c86..8cc78b74661c866d34a8dbee8860f055c6da1cd0 100644 (file)
@@ -174,6 +174,9 @@ Compose * compose_new               (PrefsAccount   *account);
 Compose * compose_new_with_recipient   (PrefsAccount   *account,
                                         const gchar    *to);
 
+Compose * compose_new_with_folderitem  (PrefsAccount   *account,
+                                        FolderItem     *item);
+
 void compose_followup_and_reply_to (MsgInfo    *msginfo,
                                    gboolean     quote,
                                    gboolean     to_all,
index 3f545000649086e3b41a81094f62c838c17306f9..614838c10354895c8b3556384de5c4d16f1cc169 100644 (file)
@@ -210,6 +210,7 @@ static void folderview_drag_received_cb  (GtkWidget        *widget,
                                          FolderView       *folderview);
 static void folderview_scoring_cb(FolderView *folderview, guint action,
                                  GtkWidget *widget);
+static void folderview_property_cb(FolderView *folderview, guint action, GtkWidget *widget);
 
 static GtkItemFactoryEntry folderview_mbox_popup_entries[] =
 {
@@ -232,7 +233,7 @@ static GtkItemFactoryEntry folderview_mail_popup_entries[] =
        {N_("/_Update folder tree"),    NULL, folderview_update_tree_cb, 0, NULL},
        {N_("/Remove _mailbox"),        NULL, folderview_remove_mailbox_cb, 0, NULL},
        {N_("/---"),                    NULL, NULL, 0, "<Separator>"},
-       {N_("/_Property..."),           NULL, NULL, 0, NULL},
+       {N_("/_Property..."),           NULL, folderview_property_cb, 0, NULL},
        {N_("/_Scoring..."),            NULL, folderview_scoring_cb, 0, NULL}
 };
 
@@ -1201,6 +1202,8 @@ static void folderview_button_pressed(GtkWidget *ctree, GdkEventButton *event,
                                   "/Delete folder", TRUE);
                menu_set_sensitive(folderview->mail_factory,
                                   "/Scoring...", TRUE);
+               menu_set_sensitive(folderview->mail_factory,
+                                  "/Property...", TRUE);
        } else if (folder->type == F_IMAP && item->parent == NULL) {
                menu_set_sensitive(folderview->imap_factory,
                                   "/Create new folder...", TRUE);
@@ -2143,3 +2146,16 @@ static void folderview_scoring_cb(FolderView *folderview, guint action,
 
        prefs_scoring_open(item);
 }
+
+static void folderview_property_cb(FolderView *folderview, guint action, GtkWidget *widget) {
+       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+       FolderItem *item;
+
+       if (!folderview->selected) return;
+
+       item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
+       g_return_if_fail(item != NULL);
+       g_return_if_fail(item->folder != NULL);
+
+       prefs_folder_item_create(item);
+}
\ No newline at end of file
index 6f6487268a0f8302d27e4ebf7bd39d766ce02d2d..b7ccd1cbe659527114bd3e28a12f9903ce25085e 100644 (file)
@@ -2158,7 +2158,7 @@ static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
                    && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
                        compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
                else
-                       compose_new(mainwin->summaryview->folder_item->folder->account);
+                       compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
        }
        else
                compose_new(NULL);
@@ -2174,13 +2174,13 @@ static void compose_mail_cb(MainWindow *mainwin, guint action,
        if (mainwin->summaryview->folder_item) {
                ac = mainwin->summaryview->folder_item->folder->account;
                if (ac && ac->protocol != A_NNTP) {
-                       compose_new(ac);
+                       compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
                        return;
                }
        }
 
        if(cur_account && (cur_account->protocol != A_NNTP)) {
-               compose_new(cur_account);
+               compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
                return;
        }
 
@@ -2188,7 +2188,7 @@ static void compose_mail_cb(MainWindow *mainwin, guint action,
        for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
                ac = (PrefsAccount *) cur->data;
                if (ac->protocol != A_NNTP) {
-                       compose_new(ac);
+                       compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
                        return;
                }
        }
index c585c966a8cddaff5926ddf41ba1935638aadd60..54330e1065d340f75b88caa3ab7786b27081bd61 100644 (file)
@@ -26,6 +26,7 @@
 #include <gtk/gtkmenu.h>
 #include <gtk/gtkmenubar.h>
 #include <gtk/gtkitemfactory.h>
+#include <gtk/gtkcheckmenuitem.h>
 
 #include "intl.h"
 #include "menu.h"
@@ -87,3 +88,14 @@ void menu_set_insensitive_all(GtkMenuShell *menu_shell)
        for (cur = menu_shell->children; cur != NULL; cur = cur->next)
                gtk_widget_set_sensitive(GTK_WIDGET(cur->data), FALSE);
 }
+
+void menu_set_toggle(GtkItemFactory *ifactory, const gchar *path,
+                       gboolean active)
+{
+       GtkWidget *widget;
+
+       g_return_if_fail(ifactory != NULL);
+
+       widget = gtk_item_factory_get_item(ifactory, path);
+       gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(widget), active);
+}
\ No newline at end of file
index fc2b3f1d6faa6925dd17cc3d4945b2e9c2a1c35c..0b8ac367657012e6d53d44011fa6f6123faae7bc 100644 (file)
@@ -49,5 +49,8 @@ void menu_set_sensitive               (GtkItemFactory         *ifactory,
                                 const gchar            *path,
                                 gboolean                sensitive);
 void menu_set_insensitive_all  (GtkMenuShell           *menu_shell);
+void menu_set_toggle           (GtkItemFactory         *ifactory,
+                                const gchar            *path,
+                                gboolean                active);
 
 #endif /* __MENU_H__ */
index bbaeba880e9f6ad9f85512413fa34b2b03ed88b2..ce5741f4145700ec1bc3c2b4d9bfbdf9c1803316 100644 (file)
@@ -1,11 +1,41 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ */
+
+#include "intl.h"
 #include "defs.h"
 #include "folder.h"
 #include "prefs_folder_item.h"
 #include "summaryview.h"
 #include "prefs.h"
+#include "manage_window.h"
 
 PrefsFolderItem tmp_prefs;
 
+struct PrefsFolderItemDialog
+{
+       FolderItem *item;
+       GtkWidget *window;
+       GtkWidget *checkbtn_request_return_receipt;
+       GtkWidget *checkbtn_default_to;
+       GtkWidget *entry_default_to;
+};
+
 static PrefParam param[] = {
        {"sort_by_number", "FALSE", &tmp_prefs.sort_by_number, P_BOOL,
         NULL, NULL, NULL},
@@ -27,9 +57,20 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"important_score", "1", &tmp_prefs.important_score, P_INT,
         NULL, NULL, NULL},
+       {"request_return_receipt", "", &tmp_prefs.request_return_receipt, P_BOOL,
+        NULL, NULL, NULL},
+       {"enable_default_to", "", &tmp_prefs.enable_default_to, P_BOOL,
+        NULL, NULL, NULL},
+       {"default_to", "", &tmp_prefs.default_to, P_STRING,
+        NULL, NULL, NULL},
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
 
+void prefs_folder_item_delete_cb(GtkWidget *widget, GdkEventAny *event, struct PrefsFolderItemDialog *dialog);
+void prefs_folder_item_cancel_cb(GtkWidget *widget, struct PrefsFolderItemDialog *dialog);
+void prefs_folder_item_ok_cb(GtkWidget *widget, struct PrefsFolderItemDialog *dialog);
+void prefs_folder_item_default_to_cb(GtkWidget *widget, struct PrefsFolderItemDialog *dialog);
+
 void prefs_folder_item_read_config(FolderItem * item)
 {
        gchar * id;
@@ -107,6 +148,10 @@ PrefsFolderItem * prefs_folder_item_new(void)
        tmp_prefs.kill_score = -9999;
        tmp_prefs.important_score = 9999;
 
+       tmp_prefs.request_return_receipt = FALSE;
+       tmp_prefs.enable_default_to = FALSE;
+       tmp_prefs.default_to = NULL;
+
        * prefs = tmp_prefs;
        
        return prefs;
@@ -114,6 +159,7 @@ PrefsFolderItem * prefs_folder_item_new(void)
 
 void prefs_folder_item_free(PrefsFolderItem * prefs)
 {
+       g_free(prefs->default_to);
        if (prefs->scoring != NULL)
                prefs_scoring_free(prefs->scoring);
        g_free(prefs);
@@ -147,3 +193,112 @@ gint prefs_folder_item_get_sort_type(FolderItem * item)
        else
                return GTK_SORT_ASCENDING;
 }
+
+void prefs_folder_item_create(FolderItem *item) {
+       struct PrefsFolderItemDialog *dialog;
+       GtkWidget *window;
+       GtkWidget *vbox;
+       GtkWidget *ok_btn;
+       GtkWidget *cancel_btn;
+       GtkWidget *confirm_area;
+       GtkWidget *hbox;
+       
+       GtkWidget *checkbtn_request_return_receipt;
+       GtkWidget *checkbtn_default_to;
+       GtkWidget *entry_default_to;
+
+       dialog = g_new0(struct PrefsFolderItemDialog, 1);
+       dialog->item = item;
+
+       /* Window */
+       window = gtk_window_new (GTK_WINDOW_DIALOG);
+       gtk_window_set_title (GTK_WINDOW(window),
+                             _("Folder Property"));
+       gtk_container_set_border_width (GTK_CONTAINER (window), 8);
+       gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
+       gtk_window_set_policy (GTK_WINDOW (window), FALSE, TRUE, FALSE);
+       gtk_signal_connect (GTK_OBJECT(window), "delete_event",
+                           GTK_SIGNAL_FUNC(prefs_folder_item_delete_cb), dialog);
+       gtk_signal_connect (GTK_OBJECT(window), "focus_in_event",
+                           GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
+       gtk_signal_connect (GTK_OBJECT(window), "focus_out_event",
+                           GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
+
+       vbox = gtk_vbox_new (FALSE, 6);
+       gtk_widget_show(vbox);
+       gtk_container_add(GTK_CONTAINER (window), vbox);
+
+       /* Ok and Cancle Buttons */
+       gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
+                               &cancel_btn, _("Cancel"), NULL, NULL);
+       gtk_widget_show(confirm_area);
+       gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
+       gtk_widget_grab_default(ok_btn);
+       gtk_signal_connect (GTK_OBJECT(ok_btn), "clicked",
+                           GTK_SIGNAL_FUNC(prefs_folder_item_ok_cb), dialog);
+       gtk_signal_connect (GTK_OBJECT(cancel_btn), "clicked",
+                           GTK_SIGNAL_FUNC(prefs_folder_item_cancel_cb), dialog);
+
+       /* Request Return Receipt */
+       PACK_CHECK_BUTTON(vbox, checkbtn_request_return_receipt,
+                          _("Request Return Receipt"));
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_request_return_receipt),
+           item->prefs->request_return_receipt);
+
+       /* Default To */
+       hbox = gtk_hbox_new(FALSE, 8);
+       gtk_widget_show(hbox);
+       gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+
+       PACK_CHECK_BUTTON(hbox, checkbtn_default_to,
+                          _("Default To: "));
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_to), item->prefs->enable_default_to);
+       gtk_signal_connect(GTK_OBJECT(checkbtn_default_to), "toggled",
+                           GTK_SIGNAL_FUNC(prefs_folder_item_default_to_cb), dialog);
+
+       entry_default_to = gtk_entry_new();
+       gtk_widget_show(entry_default_to);
+       gtk_box_pack_start(GTK_BOX(hbox), entry_default_to, FALSE, FALSE, 0);
+       gtk_editable_set_editable(GTK_EDITABLE(entry_default_to), item->prefs->enable_default_to);
+       gtk_entry_set_text(GTK_ENTRY(entry_default_to), item->prefs->default_to);
+
+       dialog->window = window;
+       dialog->checkbtn_request_return_receipt = checkbtn_request_return_receipt;
+       dialog->checkbtn_default_to = checkbtn_default_to;
+       dialog->entry_default_to = entry_default_to;
+
+       gtk_widget_show(window);
+}
+
+void prefs_folder_item_destroy(struct PrefsFolderItemDialog *dialog) {
+       gtk_widget_destroy(dialog->window);
+       g_free(dialog);
+}
+
+void prefs_folder_item_cancel_cb(GtkWidget *widget, struct PrefsFolderItemDialog *dialog) {
+       prefs_folder_item_destroy(dialog);
+}
+
+void prefs_folder_item_delete_cb(GtkWidget *widget, GdkEventAny *event, struct PrefsFolderItemDialog *dialog) {
+       prefs_folder_item_destroy(dialog);
+}
+
+void prefs_folder_item_ok_cb(GtkWidget *widget, struct PrefsFolderItemDialog *dialog) {
+       PrefsFolderItem *prefs = dialog->item->prefs;
+
+       prefs->request_return_receipt = 
+           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_request_return_receipt));
+       prefs->enable_default_to = 
+           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_default_to));
+       g_free(prefs->default_to);
+       prefs->default_to = 
+           gtk_editable_get_chars(GTK_EDITABLE(dialog->entry_default_to), 0, -1);
+
+       prefs_folder_item_save_config(dialog->item);
+       prefs_folder_item_destroy(dialog);
+}
+
+void prefs_folder_item_default_to_cb(GtkWidget *widget, struct PrefsFolderItemDialog *dialog) {
+       gtk_editable_set_editable(GTK_EDITABLE(dialog->entry_default_to),
+           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_default_to)));
+}
index 8e6272946cf143537fe8607f3f68150948016b47..a74e8d3ab0755e38ade9033a05f0ad7384464fbe 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ */
+
 #ifndef PREFS_FOLDER_ITEM_H
 
 #define PREFS_FOLDER_ITEM_H
@@ -24,6 +43,10 @@ struct _PrefsFolderItem {
 
        GSList * scoring;
        GSList * processing;
+
+       gboolean request_return_receipt;
+       gboolean enable_default_to;
+       gchar *default_to;
 };
 
 typedef struct _PrefsFolderItem PrefsFolderItem;
index a43e010d869fad60565e67b65b8671d31a7f710e..460cec5f4dcb086c3a2eb2f3a393ba006d38eb8f 100644 (file)
@@ -3282,7 +3282,7 @@ static void summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
                                compose_new_with_recipient
                                        (ac, summaryview->folder_item->path);
                        else
-                               compose_new(ac);
+                               compose_new_with_folderitem(ac, summaryview->folder_item);
                } else
                        compose_new(NULL);
                return;