make return receipts work again
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Sun, 21 Jul 2002 15:47:39 +0000 (15:47 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Sun, 21 Jul 2002 15:47:39 +0000 (15:47 +0000)
(UI idea by Leandro Pereira)

ChangeLog.claws
configure.in
po/POTFILES.in
src/Makefile.am
src/mainwindow.c
src/messageview.c
src/messageview.h
src/noticeview.c [new file with mode: 0644]
src/noticeview.h [new file with mode: 0644]

index b64a9ba5a9603fb857a0dbeee325d548d93c7952..596fc569017236bc82c5f0fa6125278d105141ea 100644 (file)
@@ -1,3 +1,14 @@
+2002-07-21 [alfons]    0.7.8claws88
+
+       * po/POTFILES.in
+       * src/Makefile.am
+       * src/mainwindow.c
+       * src/messageview.[ch]
+       * src/noticeview.c      ** NEW FILE **
+       * src/noticeview.h      ** NEW FILE **
+               make return receipts work again
+               (UI idea by Leandro Pereira)
+
 2002-07-21 [paul]      0.7.8claws87
 
        * src/summaryview.c
index d6a6c6fd3f8e6016649870e42c0381db14619f12..dce706777ed0bec9c8457516caa4b62eb4d00270 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws87
+EXTRA_VERSION=claws88
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index aee4ed31511f2de27418f3a1c45a82202cc500e4..340c44d86c5abdc555ad45e9eb0f72a7b8cbbb21 100644 (file)
@@ -108,3 +108,4 @@ src/uuencode.c
 src/vcard.c
 src/xml.c
 src/xmlprops.c
+src/noticeview.c
index b723d39d103843f11c4dcaba79f2f11394a764d4..b66fb1570f20e4388b18e7ed9c61b6d61cf11fc1 100644 (file)
@@ -135,7 +135,8 @@ sylpheed_SOURCES = \
        matcher_parser_parse.y matcher_parser.h matcher_parser_parse.h \
        string_match.h string_match.c \
        selective_download.c selective_download.h \
-       msgcache.h msgcache.c 
+       msgcache.h msgcache.c \
+       noticeview.h noticeview.c
 
 BUILT_SOURCES = \
        quote_fmt_lex.c \
index 55cf7e1e55a32644ca078da73d4721359bd822f8..09cd69ce072c89d5279e794464c6aaeb44da36d2 100644 (file)
@@ -1941,6 +1941,11 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
                                     prefs_common.mainwin_height);
                gtk_widget_show_all(vpaned);
 
+               /* CLAWS: previous "gtk_widget_show_all" makes noticeview
+                * lose track of its visibility state */
+               if (!noticeview_is_visible(mainwin->messageview->noticeview)) 
+                       gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
+
                mainwin->win.sep_none.hpaned = hpaned;
                mainwin->win.sep_none.vpaned = vpaned;
                break;
@@ -2000,6 +2005,11 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
                mainwin->win.sep_message.hpaned     = hpaned;
 
                gtk_widget_show_all(messagewin);
+               
+               /* CLAWS: previous "gtk_widget_show_all" makes noticeview
+                * lose track of its visibility state */
+               if (!noticeview_is_visible(mainwin->messageview->noticeview)) 
+                       gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
                break;
        case SEPARATE_BOTH:
                gtk_box_pack_start(GTK_BOX(vbox_body),
@@ -2021,6 +2031,11 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
 
                gtk_widget_show_all(folderwin);
                gtk_widget_show_all(messagewin);
+               
+               /* CLAWS: previous "gtk_widget_show_all" makes noticeview
+                * lose track of its visibility state */
+               if (!noticeview_is_visible(mainwin->messageview->noticeview)) 
+                       gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
                break;
        }
 
index 47df1ce56a2a826f1772b9b2fee1532054758f31..9b55234ec9a658f128e155263a5f5a743127af68 100644 (file)
@@ -60,6 +60,11 @@ static void key_pressed                      (GtkWidget      *widget,
                                         GdkEventKey    *event,
                                         MessageView    *messageview);
 
+static void return_receipt_show                (NoticeView     *noticeview, 
+                                        MsgInfo        *msginfo);      
+static void return_receipt_send_clicked (NoticeView    *noticeview, 
+                                         MsgInfo        *msginfo);
+
 MessageView *messageview_create(void)
 {
        MessageView *messageview;
@@ -68,6 +73,7 @@ MessageView *messageview_create(void)
        TextView *textview;
        ImageView *imageview;
        MimeView *mimeview;
+       NoticeView *noticeview;
 
        debug_print(_("Creating message view...\n"));
        messageview = g_new0(MessageView, 1);
@@ -76,6 +82,8 @@ MessageView *messageview_create(void)
 
        headerview = headerview_create();
 
+       noticeview = noticeview_create();
+
        textview = textview_create();
        textview->messageview = messageview;
 
@@ -91,6 +99,8 @@ MessageView *messageview_create(void)
        vbox = gtk_vbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET_PTR(headerview),
                           FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET_PTR(noticeview),
+                          FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET_PTR(textview),
                           TRUE, TRUE, 0);
 
@@ -107,6 +117,7 @@ MessageView *messageview_create(void)
        messageview->textview   = textview;
        messageview->imageview  = imageview;
        messageview->mimeview   = mimeview;
+       messageview->noticeview = noticeview;
 
        return messageview;
 }
@@ -153,6 +164,8 @@ void messageview_init(MessageView *messageview)
        imageview_init(messageview->imageview);
        mimeview_init(messageview->mimeview);
        /*messageview_set_font(messageview);*/
+
+       noticeview_hide(messageview->noticeview);
 }
 
 static void notification_convert_header(gchar *dest, gint len, 
@@ -280,6 +293,8 @@ static gint disposition_notification_send(MsgInfo * msginfo)
            (!msginfo->dispositionnotificationto))
                return -1;
 
+       procmsg_msginfo_unset_flags(msginfo, MSG_RETRCPT_PENDING, 0);
+
        /* write to temporary file */
        g_snprintf(tmp, sizeof(tmp), "%s%ctmpmsg%d",
                   get_rc_dir(), G_DIR_SEPARATOR, (gint)msginfo);
@@ -319,6 +334,7 @@ static gint disposition_notification_send(MsgInfo * msginfo)
        notification_convert_header(buf, sizeof(buf), msginfo->subject,
                                    strlen("Subject: "));
        fprintf(fp, "Subject: Disposition notification: %s\n", buf);
+       debug_print("HEADER: Subject Disposition notification: %s\n", buf);
 
        if (fclose(fp) == EOF) {
                FILE_OP_ERROR(tmp, "fclose");
@@ -379,30 +395,7 @@ void messageview_show(MessageView *messageview, MsgInfo *msginfo,
                return;
        }
 
-       /* FIXME - doesn't tmpmsginfo->flags have the value
-        * of msginfo->flags after procheader_parse()???
-        * in any case, checking tmpmsginfo->flags for MSG_UNREAD
-        * fixes the return-receipt-request bug */
-
        tmpmsginfo = procheader_parse_file(file, msginfo->flags, TRUE, TRUE);
-       if (MSG_IS_MIME(tmpmsginfo->flags))
-               MSG_SET_TMP_FLAGS(msginfo->flags, MSG_MIME);
-
-       if (prefs_common.return_receipt
-           && (tmpmsginfo->dispositionnotificationto
-               || tmpmsginfo->returnreceiptto)
-           && (MSG_IS_UNREAD(tmpmsginfo->flags))
-           && (MSG_IS_RETRCPT_PENDING(tmpmsginfo->flags))) {
-               gint ok;
-               
-               if (alertpanel(_("Return Receipt"), _("Send return receipt ?"),
-                              _("Yes"), _("No"), NULL) == G_ALERTDEFAULT) {
-                       ok = disposition_notification_send(tmpmsginfo);
-                       if (ok < 0)
-                               alertpanel_error(_("Error occurred while sending notification."));
-               }
-               MSG_UNSET_PERM_FLAGS(tmpmsginfo->flags, MSG_RETRCPT_PENDING);   
-       }
 
        headerview_show(messageview->headerview, tmpmsginfo);
        procmsg_msginfo_free(tmpmsginfo);
@@ -420,6 +413,11 @@ void messageview_show(MessageView *messageview, MsgInfo *msginfo,
                procmime_mimeinfo_free(mimeinfo);
        }
 
+       if (MSG_IS_RETRCPT_PENDING(msginfo->flags))
+               return_receipt_show(messageview->noticeview, msginfo);
+       else 
+               noticeview_hide(messageview->noticeview);
+
        g_free(file);
 }
 
@@ -609,3 +607,21 @@ void messageview_toggle_view_real(MessageView *messageview)
                gtk_widget_grab_focus(GTK_WIDGET(mainwin->summaryview->ctree));
        }
 }
+
+static void return_receipt_show(NoticeView *noticeview, MsgInfo *msginfo)
+{
+       noticeview_set_text(noticeview, _("This messages asks for a return receipt."));
+       noticeview_set_button_text(noticeview, _("Send receipt"));
+       noticeview_set_button_press_callback(noticeview,
+                                            GTK_SIGNAL_FUNC(return_receipt_send_clicked),
+                                            (gpointer) msginfo);
+       noticeview_show(noticeview);
+}
+
+static void return_receipt_send_clicked(NoticeView *noticeview, MsgInfo *msginfo)
+{
+       if (disposition_notification_send(msginfo) >= 0) 
+               noticeview_hide(noticeview);
+}
+
+
index 9b89bc9be887b1d54e35fc4ac509646b8f235b78..cf9684947bd56e05cc939bb5f95c3322dc46001e 100644 (file)
@@ -30,6 +30,7 @@ typedef struct _MessageView   MessageView;
 #include "textview.h"
 #include "imageview.h"
 #include "mimeview.h"
+#include "noticeview.h"
 #include "procmsg.h"
 
 typedef enum
@@ -50,6 +51,7 @@ struct _MessageView
        TextView *textview;
        ImageView *imageview;
        MimeView *mimeview;
+       NoticeView *noticeview;
 
        MainWindow *mainwin;
 
diff --git a/src/noticeview.c b/src/noticeview.c
new file mode 100644 (file)
index 0000000..76cc6b9
--- /dev/null
@@ -0,0 +1,154 @@
+/* 
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2002 Hiroyuki Yamamoto & The Sylpheed Claws Team
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "defs.h"
+
+#include <glib.h>
+#include <gtk/gtkwidget.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtkvbox.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkpixmap.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+#if HAVE_LIBCOMPFACE
+#  include <compface.h>
+#endif
+
+#include "intl.h"
+#include "main.h"
+#include "headerview.h"
+#include "prefs_common.h"
+#include "gtkutils.h"
+#include "utils.h"
+#include "stock_pixmap.h"
+
+#include "noticeview.h"
+
+static void noticeview_button_pressed  (GtkButton *button, NoticeView *noticeview);
+
+NoticeView *noticeview_create(void)
+{
+       NoticeView *noticeview;
+       GtkWidget  *vbox;
+       GtkWidget  *hsep;
+       GtkWidget  *hbox;
+       GtkWidget  *icon;
+       GtkWidget  *text;
+       GtkWidget  *widget;
+
+       debug_print(_("Creating notice view...\n"));
+       noticeview = g_new0(NoticeView, 1);
+
+       vbox = gtk_vbox_new(FALSE, 4);
+       gtk_widget_show(vbox);
+       hsep = gtk_hseparator_new();
+       gtk_box_pack_start(GTK_BOX(vbox), hsep, FALSE, TRUE, 0);
+       
+       hbox = gtk_hbox_new(FALSE, 4);
+       gtk_widget_show(hbox);
+       gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
+
+       icon = stock_pixmap_widget(hbox, STOCK_PIXMAP_NOTICE_WARN); 
+#if 0
+       /* also possible... */
+       icon = gtk_pixmap_new(NULL, NULL);
+#endif
+       gtk_widget_show(icon);
+       
+       gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, TRUE, 0);
+       
+       text = gtk_label_new("");
+       gtk_widget_show(text);
+       gtk_box_pack_start(GTK_BOX(hbox), text, FALSE, FALSE, 0);
+
+       widget = gtk_button_new_with_label("");
+       gtk_signal_connect(GTK_OBJECT(widget), "clicked", 
+                          GTK_SIGNAL_FUNC(noticeview_button_pressed),
+                          (gpointer) noticeview);
+       gtk_widget_show(widget);
+       gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 4);
+       
+       noticeview->vbox   = vbox;
+       noticeview->hsep   = hsep;
+       noticeview->hbox   = hbox;
+       noticeview->icon   = icon;
+       noticeview->text   = text;
+       noticeview->button = widget;
+
+       noticeview->visible = TRUE;
+
+       return noticeview;
+}
+
+gboolean noticeview_is_visible(NoticeView *noticeview)
+{
+       return noticeview->visible;
+}
+
+void noticeview_show(NoticeView *noticeview)
+{
+       if (!noticeview->visible) {
+               gtk_widget_show_all(GTK_WIDGET_PTR(noticeview));
+               noticeview->visible = TRUE;
+       }       
+}
+
+void noticeview_hide(NoticeView *noticeview)
+{
+       if (noticeview->visible) {
+               gtk_widget_hide(GTK_WIDGET_PTR(noticeview));
+               noticeview->visible = FALSE;
+       }       
+}
+
+void noticeview_set_text(NoticeView *noticeview, const char *text)
+{
+       g_return_if_fail(noticeview);
+       gtk_label_set_text(GTK_LABEL(noticeview->text), text);
+}
+
+void noticeview_set_button_text(NoticeView *noticeview, const char *text)
+{
+       g_return_if_fail(noticeview);
+       gtk_label_set_text
+               (GTK_LABEL(GTK_BIN(noticeview->button)->child), text);
+}
+
+void noticeview_set_button_press_callback(NoticeView   *noticeview,
+                                         GtkSignalFunc  callback,
+                                         gpointer      *user_data)
+{
+       noticeview->press     = (void (*) (NoticeView *, gpointer)) callback;
+       noticeview->user_data = user_data;
+}
+
+static void noticeview_button_pressed(GtkButton *button, NoticeView *noticeview)
+{
+       if (noticeview->press) {
+               noticeview->press(noticeview, noticeview->user_data);
+       }
+}
+
diff --git a/src/noticeview.h b/src/noticeview.h
new file mode 100644 (file)
index 0000000..0dde294
--- /dev/null
@@ -0,0 +1,57 @@
+/* 
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2002 Hiroyuki Yamamoto & The Sylpheed Claws Team
+ *
+ * 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 NOTICEVIEW_H__
+#define NOTICEVIEW_H__
+
+typedef struct _NoticeView     NoticeView;
+
+struct _NoticeView 
+{
+       GtkWidget       *vbox;
+       GtkWidget       *hsep;
+       GtkWidget       *hbox;
+       GtkWidget       *icon;
+       GtkWidget       *text;
+       GtkWidget       *button;
+       gboolean         visible;
+       gpointer         user_data;
+       void            (*press) (NoticeView *, gpointer user_data);
+};
+
+NoticeView     *noticeview_create      (void);
+void            noticeview_init        (NoticeView     *noticeview);
+void            noticeview_set_icon    (NoticeView     *noticeview,
+                                        GtkWidget      *icon);
+void            noticeview_set_text    (NoticeView     *noticeview,
+                                        const gchar    *text);
+void            noticeview_set_button_text 
+                                       (NoticeView     *noticeview,
+                                        const gchar    *text);
+gboolean        noticeview_is_visible  (NoticeView     *noticeview);
+void            noticeview_show        (NoticeView     *noticeview);
+void            noticeview_hide        (NoticeView     *noticeview);
+
+void            noticeview_set_button_press_callback
+                                       (NoticeView     *noticeview,
+                                        GtkSignalFunc   callback,
+                                        gpointer       *user_data);
+                                       
+#endif /* NOTICEVIEW_H__ */
+