*
* 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
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
#ifdef HAVE_CONFIG_H
#include "base64.h"
#include "inputdialog.h"
#include "timing.h"
-
-gint previousquotelevel = -1;
+#include "tags.h"
static GdkColor quote_colors[3] = {
{(gulong)0, (gushort)0, (gushort)0, (gushort)0},
{
GtkTextBuffer *buffer;
GtkTextTag *tag, *qtag;
+ static GdkColor yellow, black;
+ static gboolean color_init = FALSE;
static PangoFontDescription *font_desc, *bold_font_desc;
+ if (!color_init) {
+ gdk_color_parse("#f5f6be", &yellow);
+ gdk_color_parse("#000000", &black);
+ color_init = gdk_colormap_alloc_color(
+ gdk_colormap_get_system(), &yellow, FALSE, TRUE);
+ color_init &= gdk_colormap_alloc_color(
+ gdk_colormap_get_system(), &black, FALSE, TRUE);
+ }
+
if (!font_desc)
font_desc = pango_font_description_from_string
(NORMAL_FONT);
"foreground-gdk", "e_colors[2],
NULL);
}
+#if GTK_CHECK_VERSION(2, 8, 0)
+ gtk_text_buffer_create_tag(buffer, "tags",
+ "foreground-gdk", &black,
+ "paragraph-background-gdk", &yellow,
+ NULL);
+#else
+ gtk_text_buffer_create_tag(buffer, "tags",
+ "foreground-gdk", &emphasis_color,
+ NULL);
+#endif
gtk_text_buffer_create_tag(buffer, "emphasis",
"foreground-gdk", &emphasis_color,
NULL);
return;
}
- previousquotelevel = -1;
+ textview->prev_quote_level = -1;
if ((mimeinfo->type == MIMETYPE_MESSAGE) && !g_ascii_strcasecmp(mimeinfo->subtype, "rfc822")) {
FILE *fp;
GtkTextView *text;
GtkTextBuffer *buffer;
GtkTextIter iter;
+ const gchar *name;
+ gchar *content_type;
if (!partinfo) return;
gtk_text_buffer_get_start_iter(buffer, &iter);
TEXTVIEW_INSERT("\n");
- TEXTVIEW_INSERT(_(" The following can be performed on this part by\n"));
- TEXTVIEW_INSERT(_(" right-clicking the icon or list item:\n"));
+
+ name = procmime_mimeinfo_get_parameter(partinfo, "filename");
+ if (name == NULL)
+ name = procmime_mimeinfo_get_parameter(partinfo, "name");
+ if (name != NULL) {
+ content_type = procmime_get_content_type_str(partinfo->type,
+ partinfo->subtype);
+ TEXTVIEW_INSERT(" ");
+ TEXTVIEW_INSERT_BOLD(name);
+ TEXTVIEW_INSERT(" (");
+ TEXTVIEW_INSERT(content_type);
+ TEXTVIEW_INSERT(", ");
+ TEXTVIEW_INSERT(to_human_readable(partinfo->length));
+ TEXTVIEW_INSERT("):\n\n");
+
+ g_free(content_type);
+ }
+ TEXTVIEW_INSERT(_(" The following can be performed on this part\n"));
+#ifndef MAEMO
+ TEXTVIEW_INSERT(_(" by right-clicking the icon or list item:\n"));
+#endif
TEXTVIEW_INSERT(_(" - To save, select "));
TEXTVIEW_INSERT_LINK(_("'Save as...'"), "sc://save_as", NULL);
+#ifndef MAEMO
TEXTVIEW_INSERT(_(" (Shortcut key: 'y')\n"));
+#endif
TEXTVIEW_INSERT(_(" - To display as text, select "));
TEXTVIEW_INSERT_LINK(_("'Display as text'"), "sc://display_as_text", NULL);
+#ifndef MAEMO
TEXTVIEW_INSERT(_(" (Shortcut key: 't')\n"));
+#endif
TEXTVIEW_INSERT(_(" - To open with an external program, select "));
TEXTVIEW_INSERT_LINK(_("'Open'"), "sc://open", NULL);
+#ifndef MAEMO
TEXTVIEW_INSERT(_(" (Shortcut key: 'l')\n"));
TEXTVIEW_INSERT(_(" (alternately double-click, or click the middle "));
TEXTVIEW_INSERT(_("mouse button)\n"));
TEXTVIEW_INSERT(_(" - Or use "));
TEXTVIEW_INSERT_LINK(_("'Open with...'"), "sc://open_with", NULL);
TEXTVIEW_INSERT(_(" (Shortcut key: 'o')\n"));
+#endif
textview_show_icon(textview, GTK_STOCK_DIALOG_INFO);
}
fg_color = quote_tag_str;
}
- if (prefs_common.enable_color && (strcmp(buf,"-- \n") == 0 || textview->is_in_signature)) {
+ if (prefs_common.enable_color &&
+ (strcmp(buf,"-- \n") == 0 || strcmp(buf, "- -- \n") == 0 || textview->is_in_signature)) {
fg_color = "signature";
textview->is_in_signature = TRUE;
}
g_free(utf8buf);
}
do_quote:
- if ( previousquotelevel != real_quotelevel ) {
+ if ( textview->prev_quote_level != real_quotelevel ) {
ClickableText *uri;
uri = g_new0(ClickableText, 1);
uri->uri = g_strdup("");
textview->uri_list =
g_slist_prepend(textview->uri_list, uri);
- previousquotelevel = real_quotelevel;
+ textview->prev_quote_level = real_quotelevel;
} else {
GSList *last = textview->uri_list;
- ClickableText *lasturi = (ClickableText *)last->data;
+ ClickableText *lasturi = NULL;
gint e_len = 0, n_len = 0;
+ if (textview->uri_list) {
+ lasturi = (ClickableText *)last->data;
+ } else {
+ printf("oops (%d %d)\n",
+ real_quotelevel, textview->prev_quote_level);
+ }
if (lasturi->is_quote == FALSE) {
- previousquotelevel = -1;
+ textview->prev_quote_level = -1;
goto do_quote;
}
e_len = lasturi->data ? strlen(lasturi->data):0;
}
} else {
textview_make_clickable_parts(textview, fg_color, "link", buf, FALSE);
- previousquotelevel = -1;
+ textview->prev_quote_level = -1;
}
}
textview_uri_list_remove_all(textview->uri_list);
textview->uri_list = NULL;
textview->uri_hover = NULL;
+ textview->prev_quote_level = -1;
textview->body_pos = 0;
if (textview->image)
textview_uri_list_remove_all(textview->uri_list);
textview->uri_list = NULL;
+ textview->prev_quote_level = -1;
g_free(textview);
}
}
#endif
+static void textview_show_tags(TextView *textview)
+{
+ MsgInfo *msginfo = textview->messageview->msginfo;
+ GtkTextView *text = GTK_TEXT_VIEW(textview->text);
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer(text);
+ GtkTextIter iter;
+ ClickableText *uri;
+ GSList *cur;
+ gboolean found_tag = FALSE;
+
+ if (!msginfo->tags)
+ return;
+
+ for (cur = msginfo->tags; cur; cur = cur->next) {
+ if (tags_get_tag(GPOINTER_TO_INT(cur->data)) != NULL) {
+ found_tag = TRUE;
+ break;
+ }
+ }
+ if (!found_tag)
+ return;
+
+ gtk_text_buffer_get_end_iter (buffer, &iter);
+ gtk_text_buffer_insert_with_tags_by_name(buffer,
+ &iter, _("Tags: "), -1,
+ "header_title", "header", "tags", NULL);
+
+ for (cur = msginfo->tags; cur; cur = cur->next) {
+ uri = g_new0(ClickableText, 1);
+ uri->uri = g_strdup("");
+ uri->start = gtk_text_iter_get_offset(&iter);
+ gtk_text_buffer_insert_with_tags_by_name(buffer, &iter,
+ tags_get_tag(GPOINTER_TO_INT(cur->data)), -1,
+ "link", "header", "tags", NULL);
+ uri->end = gtk_text_iter_get_offset(&iter);
+ uri->filename = g_strdup_printf("sc://search_tags:%s", tags_get_tag(GPOINTER_TO_INT(cur->data)));
+ uri->data = NULL;
+ textview->uri_list =
+ g_slist_prepend(textview->uri_list, uri);
+ if (cur->next)
+ gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, ", ", 2,
+ "header", "tags", NULL);
+ else
+ gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, " ", 1,
+ "header", "tags", NULL);
+ }
+
+ gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "\n", 1,
+ "header", "tags", NULL);
+}
+
static void textview_show_header(TextView *textview, GPtrArray *headers)
{
GtkTextView *text = GTK_TEXT_VIEW(textview->text);
g_return_if_fail(headers != NULL);
+ textview_show_tags(textview);
+
for (i = 0; i < headers->len; i++) {
header = g_ptr_array_index(headers, i);
g_return_if_fail(header->name != NULL);
mimeview_scroll_page(messageview->mimeview, TRUE);
break;
case GDK_Return:
+ case GDK_KP_Enter:
mimeview_scroll_one_line
(messageview->mimeview, (event->state &
(GDK_SHIFT_MASK|GDK_MOD1_MASK)) != 0);
case GDK_y:
case GDK_t:
case GDK_l:
+ case GDK_o:
case GDK_c:
+ case GDK_a:
if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) == 0) {
KEY_PRESS_EVENT_STOP();
mimeview_pass_key_press_event(messageview->mimeview,
folder_item = textview->messageview->msginfo->folder;
if (folder_item->prefs && folder_item->prefs->enable_default_account)
account = account_find_from_id(folder_item->prefs->default_account);
+ if (!account)
+ account = account_find_from_item(folder_item);
}
compose_new_with_folderitem(account, folder_item, uri->uri + 7);
}