2006-04-05 [colin] 2.1.0cvs3
authorColin Leroy <colin@colino.net>
Wed, 5 Apr 2006 16:47:17 +0000 (16:47 +0000)
committerColin Leroy <colin@colino.net>
Wed, 5 Apr 2006 16:47:17 +0000 (16:47 +0000)
* src/textview.c
* src/mimeview.c
* src/mimeview.h
Nicer messages in mimeview

ChangeLog
PATCHSETS
configure.ac
src/mimeview.c
src/mimeview.h
src/textview.c

index bc258f1259652064e434e77925ed97f723811bd9..24d4869d70fdcad1bae2b139448c9cf5a1c7ff63 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-04-05 [colin]     2.1.0cvs3
+
+       * src/textview.c
+       * src/mimeview.c
+       * src/mimeview.h
+               Nicer messages in mimeview
+
 2006-04-05 [colin]     2.1.0cvs2
 
        * src/addressbook.c
index ce9c7fa83a48033da50e3c2c8b626e5bdd463f19..7d2cafd399c9e0d90b1fb2aefe07f10fe93496b2 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.11 -r 1.1.2.12 manual/advanced.xml;  ) > 2.0.0cvs186.patchset
 ( cvs diff -u -r 1.1.2.7 -r 1.1.2.8 src/plugins/pgpcore/plugin.c;  cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/plugins/pgpcore/select-keys.c;  cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/plugins/pgpcore/select-keys.h;  cvs diff -u -r 1.1.2.17 -r 1.1.2.18 src/plugins/pgpcore/sgpgme.c;  cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/plugins/pgpcore/sgpgme.h;  cvs diff -u -r 1.1.2.10 -r 1.1.2.11 src/plugins/pgpinline/pgpinline.c;  cvs diff -u -r 1.1.2.8 -r 1.1.2.9 src/plugins/pgpinline/plugin.c;  cvs diff -u -r 1.1.2.31 -r 1.1.2.32 src/plugins/pgpmime/pgpmime.c;  cvs diff -u -r 1.1.2.17 -r 1.1.2.18 src/plugins/pgpmime/plugin.c;  ) > 2.1.0cvs1.patchset
 ( cvs diff -u -r 1.60.2.56 -r 1.60.2.57 src/addressbook.c;  cvs diff -u -r 1.1.2.22 -r 1.1.2.23 src/prefs_summaries.c;  ) > 2.1.0cvs2.patchset
+( cvs diff -u -r 1.96.2.105 -r 1.96.2.106 src/textview.c;  cvs diff -u -r 1.83.2.65 -r 1.83.2.66 src/mimeview.c;  cvs diff -u -r 1.20.2.8 -r 1.20.2.9 src/mimeview.h;  ) > 2.1.0cvs3.patchset
index 07639d71dfc9443ceff51768ebae11c7a0cff3b5..5e6c0601f2a37d5e9130a06e5b1f5177c58fca43 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=1
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=2
+EXTRA_VERSION=3
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index d58ecb8c6cd2973c453d6dca28d31e8c19b6d952..9698157d3bd0e1dc031a76d4bd48f28a29717beb 100644 (file)
@@ -63,6 +63,7 @@
 #include "procheader.h"
 #include "stock_pixmap.h"
 #include "gtk/gtkvscrollbutton.h"
+#include "gtk/logwindow.h"
 
 
 typedef enum
@@ -1053,26 +1054,6 @@ static void mimeview_selected(GtkCTree *ctree, GtkCTreeNode *node, gint column,
                        mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
                        textview_clear(mimeview->textview);
                        textview_show_mime_part(mimeview->textview, partinfo);
-                       
-#if 0 /* this sucks. I'll do better. */
-                       val = alertpanel_full(_("Unknown part type"), 
-                                             _("The type of this part is unknown. What would you like "
-                                               "to do with it?"),
-                                             GTK_STOCK_SAVE, GTK_STOCK_OPEN, _("Display as text"),
-                                             FALSE, NULL, ALERT_WARNING, G_ALERTALTERNATE);
-                       switch (val) {
-                               case G_ALERTDEFAULT:
-                                       mimeview_save_as(mimeview);
-                                       break;
-                               case G_ALERTALTERNATE:
-                                       mimeview_open_with(mimeview);
-                                       break;
-                               case G_ALERTOTHER:
-                                       mimeview_display_as_text(mimeview);
-                                       break;
-                               default:
-                       }
-#endif
                        break;
                }
        }
@@ -2186,3 +2167,32 @@ void mimeview_update (MimeView *mimeview) {
                icon_list_create(mimeview, mimeview->mimeinfo);
        }
 }
+
+void mimeview_handle_cmd(MimeView *mimeview, const gchar *cmd)
+{
+       MessageView *msgview = NULL;
+       MainWindow *mainwin = NULL;
+       
+       if (!cmd)
+               return;
+       
+       msgview = mimeview->messageview;
+       if (!msgview)
+               return;
+               
+       mainwin = msgview->mainwin;
+       if (!mainwin)
+               return;
+               
+       else if (!strcmp(cmd, "sc://view_log"))
+               log_window_show(mainwin->logwin);
+       else if (!strcmp(cmd, "sc://save_as"))
+               mimeview_save_as(mimeview);
+       else if (!strcmp(cmd, "sc://display_as_text"))
+               mimeview_display_as_text(mimeview);
+       else if (!strcmp(cmd, "sc://open_with"))
+               mimeview_open_with(mimeview);
+       else if (!strcmp(cmd, "sc://open"))
+               mimeview_launch(mimeview);
+}
+
index 16cedb45e8c87b061c4b62ad9f4dbe39986eccdc..c88973946cc01db74282bddb25cf709dd4c513fa 100644 (file)
@@ -148,6 +148,8 @@ void mimeview_pass_key_press_event  (MimeView       *mimeview,
 
 void mimeview_register_viewer_factory  (MimeViewerFactory *factory);
 void mimeview_unregister_viewer_factory        (MimeViewerFactory *factory);
+void mimeview_handle_cmd               (MimeView       *mimeview, 
+                                        const gchar    *cmd);
 
 
 #ifdef __cplusplus
index 4c3455b8236e87f6f00d7a6c211b8408f6f0803a..0cccf7d96ec191e9668f7daf919edc7eafc3b843 100644 (file)
@@ -210,6 +210,7 @@ static void save_file_cb                    (TextView       *textview,
 static void open_image_cb                      (TextView       *textview,
                                                 guint           action,
                                                 void           *data);
+static void textview_show_icon(TextView *textview, const gchar *stock_id);
 
 static GtkItemFactoryEntry textview_link_popup_entries[] = 
 {
@@ -707,7 +708,24 @@ static void textview_add_parts(TextView *textview, MimeInfo *mimeinfo)
 }
 
 #define TEXT_INSERT(str) \
-       gtk_text_buffer_insert(buffer, &iter, str, -1)
+       gtk_text_buffer_insert_with_tags_by_name \
+                               (buffer, &iter, str, -1,\
+                                "header", NULL)
+
+#define TEXT_INSERT_LINK(str, fname) {                                         \
+       RemoteURI *uri;                                                 \
+       uri = g_new(RemoteURI, 1);                                      \
+       uri->uri = g_strdup("");                                        \
+       uri->start = gtk_text_iter_get_offset(&iter);                   \
+       gtk_text_buffer_insert_with_tags_by_name                        \
+                               (buffer, &iter, str, -1,                \
+                                "link", "header_title", "header",      \
+                                NULL);                                 \
+       uri->end = gtk_text_iter_get_offset(&iter);                     \
+       uri->filename = g_strdup(fname);                                \
+       textview->uri_list =                                            \
+               g_slist_append(textview->uri_list, uri);                \
+}
 
 void textview_show_error(TextView *textview)
 {
@@ -722,7 +740,14 @@ void textview_show_error(TextView *textview)
        buffer = gtk_text_view_get_buffer(text);
        gtk_text_buffer_get_start_iter(buffer, &iter);
 
-       TEXT_INSERT(_("This message can't be displayed.\n"));
+       TEXT_INSERT(_("\n"
+                     "  This message can't be displayed.\n"
+                     "  This is probably due to a network error.\n"
+                     "\n"
+                     "  Use "));
+       TEXT_INSERT_LINK(_("'View Log'"), "sc://view_log");
+       TEXT_INSERT(_(" in the Tools menu for more information."));
+       textview_show_icon(textview, GTK_STOCK_DIALOG_ERROR);
 
 }
 
@@ -741,20 +766,29 @@ void textview_show_mime_part(TextView *textview, MimeInfo *partinfo)
        buffer = gtk_text_view_get_buffer(text);
        gtk_text_buffer_get_start_iter(buffer, &iter);
 
-       TEXT_INSERT(_("The following can be performed on this part by "));
-       TEXT_INSERT(_("right-clicking the icon or list item:\n"));
-
-       TEXT_INSERT(_("    To save select 'Save as...' (Shortcut key: 'y')\n"));
-       TEXT_INSERT(_("    To display as text select 'Display as text' "));
-       TEXT_INSERT(_("(Shortcut key: 't')\n"));
-       TEXT_INSERT(_("    To open with an external program select 'Open' "));
-       TEXT_INSERT(_("(Shortcut key: 'l'),\n"));
-       TEXT_INSERT(_("    (alternately double-click, or click the middle "));
-       TEXT_INSERT(_("mouse button),\n"));
-       TEXT_INSERT(_("    or 'Open with...' (Shortcut key: 'o')\n"));
+       TEXT_INSERT("\n");
+       TEXT_INSERT(_("  The following can be performed on this part by\n"));
+       TEXT_INSERT(_("  right-clicking the icon or list item:\n"));
+
+       TEXT_INSERT(_("     - To save, select "));
+       TEXT_INSERT_LINK(_("'Save as...'"), "sc://save_as");
+       TEXT_INSERT(_(" (Shortcut key: 'y')\n"));
+       TEXT_INSERT(_("     - To display as text, select "));
+       TEXT_INSERT_LINK(_("'Display as text'"), "sc://display_as_text");
+       TEXT_INSERT(_(" (Shortcut key: 't')\n"));
+       TEXT_INSERT(_("     - To open with an external program, select "));
+       TEXT_INSERT_LINK(_("'Open'"), "sc://open");
+       TEXT_INSERT(_(" (Shortcut key: 'l')\n"));
+       TEXT_INSERT(_("       (alternately double-click, or click the middle "));
+       TEXT_INSERT(_("mouse button)\n"));
+       TEXT_INSERT(_("     - Or use "));
+       TEXT_INSERT_LINK(_("'Open with...'"), "sc://open_with");
+       TEXT_INSERT(_(" (Shortcut key: 'o')\n"));
+       textview_show_icon(textview, GTK_STOCK_DIALOG_INFO);
 }
 
 #undef TEXT_INSERT
+#undef TEXT_INSERT_LINK
 
 static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
 {
@@ -1117,6 +1151,8 @@ void textview_clear(TextView *textview)
 {
        GtkTextView *text = GTK_TEXT_VIEW(textview->text);
        GtkTextBuffer *buffer;
+       GdkWindow *window = gtk_text_view_get_window(text,
+                               GTK_TEXT_WINDOW_TEXT);
 
        buffer = gtk_text_view_get_buffer(text);
        gtk_text_buffer_set_text(buffer, "", -1);
@@ -1129,6 +1165,12 @@ void textview_clear(TextView *textview)
        if (textview->image) 
                gtk_widget_destroy(textview->image);
        textview->image = NULL;
+
+       if (textview->messageview->mainwin->cursor_count == 0) {
+               gdk_window_set_cursor(window, text_cursor);
+       } else {
+               gdk_window_set_cursor(window, watch_cursor);
+       }
 }
 
 void textview_destroy(TextView *textview)
@@ -1323,6 +1365,30 @@ bail:
        textview->image = NULL; 
 }
 
+static void textview_show_icon(TextView *textview, const gchar *stock_id)
+{
+       GtkTextView *text = GTK_TEXT_VIEW(textview->text);
+       int x = 0;
+       
+       if (textview->image) 
+               gtk_widget_destroy(textview->image);
+       
+       textview->image = gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_DIALOG);
+       g_return_if_fail(textview->image != NULL);
+
+       gtk_widget_show(textview->image);
+       
+       x = textview->text->allocation.width - WIDTH -5;
+
+       gtk_text_view_add_child_in_window(text, textview->image, 
+               GTK_TEXT_WINDOW_TEXT, x, 5);
+
+       gtk_widget_show_all(textview->text);
+       
+
+       return;
+}
+
 #if HAVE_LIBCOMPFACE
 static void textview_show_xface(TextView *textview)
 {
@@ -1921,7 +1987,15 @@ static gboolean textview_uri_button_pressed(GtkTextTag *tag, GObject *obj,
        /* doubleclick: open compose / add address / browser */
        if ((event->type == GDK_BUTTON_PRESS && bevent->button == 1) ||
                bevent->button == 2 || bevent->button == 3) {
-               if (!g_ascii_strncasecmp(uri->uri, "mailto:", 7)) {
+               if (uri->filename && !g_ascii_strncasecmp(uri->filename, "sc://", 5)) {
+                       if (bevent->button == 1) {
+                               MimeView *mimeview = 
+                                       (textview->messageview)?
+                                               textview->messageview->mimeview:NULL;
+                               mimeview_handle_cmd(mimeview, uri->filename);
+                       }
+                       return TRUE;
+               } else if (!g_ascii_strncasecmp(uri->uri, "mailto:", 7)) {
                        if (bevent->button == 3) {
                                g_object_set_data(
                                        G_OBJECT(textview->mail_popup_menu),