#include "procheader.h"
#include "stock_pixmap.h"
#include "gtk/gtkvscrollbutton.h"
+#include "gtk/logwindow.h"
typedef enum
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;
}
}
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);
+}
+
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[] =
{
}
#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)
{
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);
}
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)
{
{
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);
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)
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)
{
/* 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),