/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2011 Hiroyuki Yamamoto and the Claws Mail 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
#include "html.h"
#include "enriched.h"
#include "compose.h"
-#include "addressbook.h"
+#ifndef USE_NEW_ADDRBOOK
+ #include "addressbook.h"
+ #include "addrindex.h"
+#else
+ #include "addressbook-dbus.h"
+ #include "addressadd.h"
+#endif
#include "displayheader.h"
#include "account.h"
#include "mimeview.h"
#include "inputdialog.h"
#include "timing.h"
#include "tags.h"
-#include "addrindex.h"
static GdkColor quote_colors[3] = {
{(gulong)0, (gushort)0, (gushort)0, (gushort)0},
TextView *textview);
static void add_uri_to_addrbook_cb (GtkAction *action,
TextView *textview);
+static void reply_to_uri_cb (GtkAction *action,
+ TextView *textview);
static void mail_to_uri_cb (GtkAction *action,
TextView *textview);
static void copy_mail_to_uri_cb (GtkAction *action,
{
{"TextviewPopupMail", NULL, "TextviewPopupMail" },
{"TextviewPopupMail/Compose", NULL, N_("Compose _new message"), NULL, NULL, G_CALLBACK(mail_to_uri_cb) },
+ {"TextviewPopupMail/ReplyTo", NULL, N_("_Reply to this address"), NULL, NULL, G_CALLBACK(reply_to_uri_cb) },
{"TextviewPopupMail/AddAB", NULL, N_("Add to _Address book"), NULL, NULL, G_CALLBACK(add_uri_to_addrbook_cb) },
{"TextviewPopupMail/Copy", NULL, N_("Copy this add_ress"), NULL, NULL, G_CALLBACK(copy_mail_to_uri_cb) },
};
# define HEIGHT 48
#endif
if (textview->image) {
+ GtkAllocation allocation;
gint x, y, x1;
- x1 = textview->text->allocation.width - WIDTH - 5;
+ gtk_widget_get_allocation(textview->text, &allocation);
+ x1 = allocation.width - WIDTH - 5;
gtk_text_view_buffer_to_window_coords(
GTK_TEXT_VIEW(textview->text),
GTK_TEXT_WINDOW_TEXT, x1, 5, &x, &y);
"/Menus/TextviewPopupLink", "Copy", "TextviewPopupLink/Copy", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(textview->ui_manager,
"/Menus/TextviewPopupMail", "Compose", "TextviewPopupMail/Compose", GTK_UI_MANAGER_MENUITEM)
+ MENUITEM_ADDUI_MANAGER(textview->ui_manager,
+ "/Menus/TextviewPopupMail", "ReplyTo", "TextviewPopupMail/ReplyTo", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(textview->ui_manager,
"/Menus/TextviewPopupMail", "AddAB", "TextviewPopupMail/AddAB", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(textview->ui_manager,
textview->text = text;
textview->uri_list = NULL;
textview->body_pos = 0;
- textview->show_all_headers = FALSE;
textview->last_buttonpress = GDK_NOTHING;
textview->image = NULL;
return textview;
{
GtkTextBuffer *buffer;
GtkTextTag *tag, *qtag;
+#if !GTK_CHECK_VERSION(3, 0, 0)
static GdkColor yellow, black;
static gboolean color_init = FALSE;
+#else
+ static GdkColor yellow = { (guint32)0, (guint16)0xf5, (guint16)0xf6, (guint16)0xbe };
+ static GdkColor black = { (guint32)0, (guint16)0x0, (guint16)0x0, (guint16)0x0 };
+#endif
static PangoFontDescription *font_desc, *bold_font_desc;
+#if !GTK_CHECK_VERSION(3, 0, 0)
if (!color_init) {
gdk_color_parse("#f5f6be", &yellow);
gdk_color_parse("#000000", &black);
color_init &= gdk_colormap_alloc_color(
gdk_colormap_get_system(), &black, FALSE, TRUE);
}
+#endif
if (!font_desc)
font_desc = pango_font_description_from_string
watch_cursor = gdk_cursor_new(GDK_WATCH);
textview_reflect_prefs(textview);
- textview_set_all_headers(textview, FALSE);
textview_set_font(textview, NULL);
textview_create_tags(GTK_TEXT_VIEW(textview->text), textview);
}
static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
{
+ GtkAllocation allocation;
GtkTextView *text;
GtkTextBuffer *buffer;
GtkTextIter iter, start_iter;
if (mimeinfo->type == MIMETYPE_IMAGE &&
prefs_common.inline_img ) {
GdkPixbuf *pixbuf;
- gint avail_width;
- gint avail_height;
GError *error = NULL;
gchar *filename;
ClickableText *uri;
return;
}
- if (!prefs_common.resize_img) {
- pixbuf = gdk_pixbuf_new_from_file(filename, &error);
- } else {
- gint w, h;
- gdk_pixbuf_get_file_info(filename, &w, &h);
- avail_width = textview->scrolledwin->allocation.width;
- avail_height = textview->scrolledwin->allocation.height;
- if (avail_width - 100 > 0 &&
- (w > avail_width || h > avail_height))
- pixbuf = gdk_pixbuf_new_from_file_at_scale(filename,
- avail_width, avail_height, TRUE, &error);
- else
- pixbuf = gdk_pixbuf_new_from_file(filename, &error);
+ pixbuf = gdk_pixbuf_new_from_file(filename, &error);
+ if (textview->stop_loading) {
+ return;
}
if (error != NULL) {
g_warning("%s\n", error->message);
return;
}
+ gtk_widget_get_allocation(textview->scrolledwin, &allocation);
+ pixbuf = claws_load_pixbuf_fitting(pixbuf,
+ allocation.width,
+ allocation.height);
+
+ if (textview->stop_loading) {
+ return;
+ }
+
uri_str = g_filename_to_uri(filename, NULL, NULL);
if (uri_str) {
uri = g_new0(ClickableText, 1);
uri->start = gtk_text_iter_get_offset(&iter);
gtk_text_buffer_insert_pixbuf(buffer, &iter, pixbuf);
-
+ if (textview->stop_loading) {
+ g_free(uri);
+ return;
+ }
uri->end = uri->start + 1;
uri->filename = procmime_get_part_file_name(mimeinfo);
textview->uri_list =
&start_iter, &iter);
} else {
gtk_text_buffer_insert_pixbuf(buffer, &iter, pixbuf);
+ if (textview->stop_loading) {
+ return;
+ }
gtk_text_buffer_insert(buffer, &iter, " ", 1);
}
" This is probably due to a network error.\n"
"\n"
" Use "));
- TEXTVIEW_INSERT_LINK(_("'View Log'"), "sc://view_log", NULL);
+ TEXTVIEW_INSERT_LINK(_("'Network Log'"), "sc://view_log", NULL);
TEXTVIEW_INSERT(_(" in the Tools menu for more information."));
textview_show_icon(textview, GTK_STOCK_DIALOG_ERROR);
}
+void textview_show_info(TextView *textview, const gchar *info_str)
+{
+ GtkTextView *text;
+ GtkTextBuffer *buffer;
+ GtkTextIter iter;
+
+ textview_set_font(textview, NULL);
+ textview_clear(textview);
+
+ text = GTK_TEXT_VIEW(textview->text);
+ buffer = gtk_text_view_get_buffer(text);
+ gtk_text_buffer_get_start_iter(buffer, &iter);
+
+ TEXTVIEW_INSERT(info_str);
+ textview_show_icon(textview, GTK_STOCK_DIALOG_INFO);
+ textview_cursor_normal(textview);
+}
+
void textview_show_mime_part(TextView *textview, MimeInfo *partinfo)
{
GtkTextView *text;
argv = strsplit_with_quote(buf, " ", 0);
close(1);
close(pfd[0]);
- dup(pfd[1]);
+ rc = dup(pfd[1]);
rc = execvp(argv[0], argv);
close(pfd[1]);
g_print(_("The command to view attachment "
g_free(textview);
}
-void textview_set_all_headers(TextView *textview, gboolean all_headers)
-{
- textview->show_all_headers = all_headers;
-}
-
#define CHANGE_TAG_FONT(tagname, font) { \
tag = gtk_text_tag_table_lookup(tags, tagname); \
if (tag) \
cm_return_val_if_fail(fp != NULL, NULL);
- if (textview->show_all_headers) {
+ if (prefs_common.show_all_headers) {
headers = procheader_get_header_array_asis(fp);
sorted_headers = g_ptr_array_new();
for (i = 0; i < headers->len; i++) {
static void textview_show_face(TextView *textview)
{
+ GtkAllocation allocation;
GtkTextView *text = GTK_TEXT_VIEW(textview->text);
MsgInfo *msginfo = textview->messageview->msginfo;
int x = 0;
gtk_widget_show(textview->image);
- x = textview->text->allocation.width - WIDTH -5;
+ gtk_widget_get_allocation(textview->text, &allocation);
+ x = allocation.width - WIDTH -5;
gtk_text_view_add_child_in_window(text, textview->image,
GTK_TEXT_WINDOW_TEXT, x, 5);
void textview_show_icon(TextView *textview, const gchar *stock_id)
{
+ GtkAllocation allocation;
GtkTextView *text = GTK_TEXT_VIEW(textview->text);
int x = 0;
gtk_widget_show(textview->image);
- x = textview->text->allocation.width - WIDTH -5;
+ gtk_widget_get_allocation(textview->text, &allocation);
+ x = allocation.width - WIDTH -5;
gtk_text_view_add_child_in_window(text, textview->image,
GTK_TEXT_WINDOW_TEXT, x, 5);
#if HAVE_LIBCOMPFACE
static void textview_show_xface(TextView *textview)
{
+ GtkAllocation allocation;
MsgInfo *msginfo = textview->messageview->msginfo;
GtkTextView *text = GTK_TEXT_VIEW(textview->text);
int x = 0;
gtk_widget_show(textview->image);
- x = textview->text->allocation.width - WIDTH -5;
+ gtk_widget_get_allocation(textview->text, &allocation);
+ x = allocation.width - WIDTH -5;
gtk_text_view_add_child_in_window(text, textview->image,
GTK_TEXT_WINDOW_TEXT, x, 5);
static void textview_save_contact_pic(TextView *textview)
{
+#ifndef USE_NEW_ADDRBOOK
MsgInfo *msginfo = textview->messageview->msginfo;
gchar *filename = NULL;
GError *error = NULL;
}
}
g_free(filename);
+#else
+ /* new address book */
+#endif
}
static void textview_show_contact_pic(TextView *textview)
{
+#ifndef USE_NEW_ADDRBOOK
MsgInfo *msginfo = textview->messageview->msginfo;
GtkTextView *text = GTK_TEXT_VIEW(textview->text);
int x = 0;
if (textview->image)
gtk_widget_destroy(textview->image);
textview->image = NULL;
-
+#else
+ /* new address book */
+#endif
}
static gint textview_tag_cmp_list(gconstpointer a, gconstpointer b)
procheader_headername_equal(header->name, "To") ||
procheader_headername_equal(header->name, "Cc"))
unfold_line(header->body);
-
- if ((procheader_headername_equal(header->name, "X-Mailer") ||
- procheader_headername_equal(header->name,
+
+ if (procheader_headername_equal(header->name, "Date") &&
+ prefs_common.msgview_date_format) {
+ gchar hbody[80];
+
+ procheader_date_parse(hbody, header->body, sizeof(hbody));
+ gtk_text_buffer_get_end_iter (buffer, &iter);
+ gtk_text_buffer_insert_with_tags_by_name
+ (buffer, &iter, hbody, -1, "header", NULL);
+ } else if ((procheader_headername_equal(header->name, "X-Mailer") ||
+ procheader_headername_equal(header->name,
"X-Newsreader")) &&
- (strstr(header->body, "Claws Mail") != NULL ||
- strstr(header->body, "Sylpheed-Claws") != NULL)) {
+ (strstr(header->body, "Claws Mail") != NULL ||
+ strstr(header->body, "Sylpheed-Claws") != NULL)) {
gtk_text_buffer_get_end_iter (buffer, &iter);
gtk_text_buffer_insert_with_tags_by_name
(buffer, &iter, header->body, -1,
void textview_scroll_one_line(TextView *textview, gboolean up)
{
GtkTextView *text = GTK_TEXT_VIEW(textview->text);
- GtkAdjustment *vadj = text->vadjustment;
+ GtkAdjustment *vadj = gtk_text_view_get_vadjustment(text);
gtkutils_scroll_one_line(GTK_WIDGET(text), vadj, up);
}
gboolean textview_scroll_page(TextView *textview, gboolean up)
{
GtkTextView *text = GTK_TEXT_VIEW(textview->text);
- GtkAdjustment *vadj = text->vadjustment;
+ GtkAdjustment *vadj = gtk_text_view_get_vadjustment(text);
return gtkutils_scroll_page(GTK_WIDGET(text), vadj, up);
}
+void textview_scroll_max(TextView *textview, gboolean up)
+{
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview->text));
+ GtkTextIter iter;
+
+ if (up) {
+ gtk_text_buffer_get_start_iter(buffer, &iter);
+ gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(textview->text),
+ &iter, 0.0, TRUE, 0.0, 1.0);
+
+ } else {
+ gtk_text_buffer_get_end_iter(buffer, &iter);
+ gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(textview->text),
+ &iter, 0.0, TRUE, 0.0, 0.0);
+ }
+}
+
#define KEY_PRESS_EVENT_STOP() \
g_signal_stop_emission_by_name(G_OBJECT(widget), \
"key_press_event");
static gint textview_key_pressed(GtkWidget *widget, GdkEventKey *event,
TextView *textview)
{
+ GdkWindow *window;
SummaryView *summaryview = NULL;
MessageView *messageview = textview->messageview;
summaryview = messageview->mainwin->summaryview;
switch (event->keyval) {
- case GDK_Tab:
- case GDK_Home:
- case GDK_Left:
- case GDK_Up:
- case GDK_Right:
- case GDK_Down:
- case GDK_Page_Up:
- case GDK_Page_Down:
- case GDK_End:
- case GDK_Control_L:
- case GDK_Control_R:
+ case GDK_KEY_Tab:
+ case GDK_KEY_Left:
+ case GDK_KEY_Up:
+ case GDK_KEY_Right:
+ case GDK_KEY_Down:
+ case GDK_KEY_Page_Up:
+ case GDK_KEY_Page_Down:
+ case GDK_KEY_Control_L:
+ case GDK_KEY_Control_R:
return FALSE;
- case GDK_space:
+ case GDK_KEY_Home:
+ case GDK_KEY_End:
+ textview_scroll_max(textview,(event->keyval == GDK_KEY_Home));
+ return TRUE;
+ case GDK_KEY_space:
if (summaryview)
summary_pass_key_press_event(summaryview, event);
else
(event->state &
(GDK_SHIFT_MASK|GDK_MOD1_MASK)) != 0);
break;
- case GDK_BackSpace:
+ case GDK_KEY_BackSpace:
mimeview_scroll_page(messageview->mimeview, TRUE);
break;
- case GDK_Return:
- case GDK_KP_Enter:
+ case GDK_KEY_Return:
+ case GDK_KEY_KP_Enter:
mimeview_scroll_one_line
(messageview->mimeview, (event->state &
(GDK_SHIFT_MASK|GDK_MOD1_MASK)) != 0);
break;
- case GDK_Delete:
+ case GDK_KEY_Delete:
if (summaryview)
summary_pass_key_press_event(summaryview, event);
break;
- case GDK_y:
- case GDK_t:
- case GDK_l:
- case GDK_o:
- case GDK_c:
- case GDK_a:
+ case GDK_KEY_y:
+ case GDK_KEY_t:
+ case GDK_KEY_l:
+ case GDK_KEY_o:
+ case GDK_KEY_c:
+ case GDK_KEY_a:
if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) == 0) {
KEY_PRESS_EVENT_STOP();
mimeview_pass_key_press_event(messageview->mimeview,
}
/* possible fall through */
default:
+ window = gtk_widget_get_window(messageview->mainwin->window);
if (summaryview &&
- event->window != messageview->mainwin->window->window) {
+ event->window != window) {
GdkEventKey tmpev = *event;
- tmpev.window = messageview->mainwin->window->window;
+ tmpev.window = window;
KEY_PRESS_EVENT_STOP();
gtk_widget_event(messageview->mainwin->window,
(GdkEvent *)&tmpev);
if (textview->loading)
return FALSE;
textview_uri_update(textview, event->x, event->y);
- gdk_window_get_pointer(widget->window, NULL, NULL, NULL);
+ gdk_window_get_pointer(gtk_widget_get_window(widget), NULL, NULL, NULL);
return FALSE;
}
if (window != event->window)
return FALSE;
- gdk_window_get_pointer(widget->window, &wx, &wy, NULL);
+ gdk_window_get_pointer(gtk_widget_get_window(widget), &wx, &wy, NULL);
textview_uri_update(textview, wx, wy);
return FALSE;
}
return TRUE;
} else if (qlink && bevent->button == 1) {
- textview_toggle_quote(textview, NULL, uri, FALSE);
+ if (prefs_common.hide_quoted)
+ textview_toggle_quote(textview, NULL, uri, FALSE);
return TRUE;
} else if (!g_ascii_strncasecmp(uri->uri, "mailto:", 7)) {
if (bevent->button == 3) {
} else {
PrefsAccount *account = NULL;
FolderItem *folder_item = NULL;
+ Compose *compose;
+
if (textview->messageview && textview->messageview->msginfo &&
textview->messageview->msginfo->folder) {
if (!account)
account = account_find_from_item(folder_item);
}
- compose_new_with_folderitem(account, folder_item, uri->uri + 7);
+ compose = compose_new_with_folderitem(account,
+ folder_item, uri->uri + 7);
+ compose_check_for_email_account(compose);
}
return TRUE;
} else if (g_ascii_strncasecmp(uri->uri, "file:", 5)) {
GtkWidget *image = NULL;
GdkPixbuf *picture = NULL;
gboolean use_picture = FALSE;
+
if (uri == NULL)
return;
if (image)
picture = gtk_image_get_pixbuf(GTK_IMAGE(image));
+#ifndef USE_NEW_ADDRBOOK
addressbook_add_contact( fromname, fromaddress, NULL, picture);
+#else
+ if (addressadd_selection(fromname, fromaddress, NULL, picture)) {
+ debug_print( "addressbook_add_contact - added\n" );
+ }
+#endif
g_free(fromaddress);
g_free(fromname);
}
+static void reply_to_uri_cb (GtkAction *action, TextView *textview)
+{
+ ClickableText *uri = g_object_get_data(G_OBJECT(textview->mail_popup_menu),
+ "menu_button");
+ if (!textview->messageview || !uri)
+ return;
+
+ compose_reply_to_address (textview->messageview,
+ textview->messageview->msginfo, uri->uri+7);
+}
+
static void mail_to_uri_cb (GtkAction *action, TextView *textview)
{
PrefsAccount *account = NULL;
+ Compose *compose;
ClickableText *uri = g_object_get_data(G_OBJECT(textview->mail_popup_menu),
"menu_button");
if (uri == NULL)
if (folder_item->prefs && folder_item->prefs->enable_default_account)
account = account_find_from_id(folder_item->prefs->default_account);
- compose_new_with_folderitem(account, folder_item, uri->uri+7);
+ compose = compose_new_with_folderitem(account, folder_item, uri->uri+7);
} else {
- compose_new(account, uri->uri + 7, NULL);
+ compose = compose_new(account, uri->uri + 7, NULL);
}
+ compose_check_for_email_account(compose);
}
static void copy_mail_to_uri_cb (GtkAction *action, TextView *textview)