aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadek Doulik <rodo@ximian.com>2001-03-23 01:00:42 +0800
committerRadek Doulik <rodo@src.gnome.org>2001-03-23 01:00:42 +0800
commitec189bd8f46c84af0323df0fbd08ebf11a2db413 (patch)
tree3809d6ce8827fcde36fc2226f534f9ac1e45f1cb
parenta2ae2d718be2cf4803ae0564c0cc539ecdaa4f6b (diff)
downloadgsoc2013-evolution-ec189bd8f46c84af0323df0fbd08ebf11a2db413.tar.gz
gsoc2013-evolution-ec189bd8f46c84af0323df0fbd08ebf11a2db413.tar.zst
gsoc2013-evolution-ec189bd8f46c84af0323df0fbd08ebf11a2db413.zip
connect to button_press_event and iframe_created events of GtkHTML widget
2001-03-22 Radek Doulik <rodo@ximian.com> * mail-display.c (mail_display_new): connect to button_press_event and iframe_created events of GtkHTML widget (html_button_press_event): new signal handler, runs popup on address fields and on links, later we should add popups for images and maybe some more? any ideas? (html_iframe_created): new signal handler, takes care of connecting to button_press_event of all iframes : plus bunch of empty methods for popup menu items - to be implemented * mail-format.c (write_address): revert back to raw HTML text, store name and email to Text objects, workaround gtkhtml tables bug (to be fixed soon ;-) svn path=/trunk/; revision=8896
-rw-r--r--mail/ChangeLog16
-rw-r--r--mail/mail-display.c98
-rw-r--r--mail/mail-format.c40
3 files changed, 145 insertions, 9 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 51526591bd..2bf7e4ea50 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,19 @@
+2001-03-22 Radek Doulik <rodo@ximian.com>
+
+ * mail-display.c (mail_display_new): connect to button_press_event
+ and iframe_created events of GtkHTML widget
+ (html_button_press_event): new signal handler, runs popup on
+ address fields and on links, later we should add popups for images
+ and maybe some more? any ideas?
+ (html_iframe_created): new signal handler, takes care of
+ connecting to button_press_event of all iframes
+ : plus bunch of empty methods for popup menu items - to be
+ implemented
+
+ * mail-format.c (write_address): revert back to raw HTML text,
+ store name and email to Text objects, workaround gtkhtml tables
+ bug (to be fixed soon ;-)
+
2001-03-21 Ettore Perazzoli <ettore@ximian.com>
* folder-browser-factory.c (update_pixmaps): Don't return if
diff --git a/mail/mail-display.c b/mail/mail-display.c
index fa755c15d8..2b8659cfa4 100644
--- a/mail/mail-display.c
+++ b/mail/mail-display.c
@@ -36,6 +36,8 @@
#include <gdk-pixbuf/gdk-pixbuf-loader.h>
#include <gtkhtml/gtkhtml-embedded.h>
#include <gtkhtml/htmlengine.h> /* XXX */
+#include <gtkhtml/htmlobject.h> /* XXX */
+#include <gtkhtml/htmlinterval.h> /* XXX */
#define PARENT_TYPE (gtk_vbox_get_type ())
@@ -1034,6 +1036,98 @@ mail_display_class_init (GtkObjectClass *object_class)
mail_display_parent_class = gtk_type_class (PARENT_TYPE);
}
+static void
+add_to_addressbook (GtkWidget *w, MailDisplay *mail_display)
+{
+ g_print ("FIXME\n");
+}
+
+static void
+open_in_addressbook (GtkWidget *w, MailDisplay *mail_display)
+{
+ g_print ("FIXME\n");
+}
+
+static void
+link_open_in_browser (GtkWidget *w, MailDisplay *mail_display)
+{
+ g_print ("FIXME\n");
+}
+
+static void
+link_save_as (GtkWidget *w, MailDisplay *mail_display)
+{
+ g_print ("FIXME\n");
+}
+
+static void
+link_copy_location (GtkWidget *w, MailDisplay *mail_display)
+{
+ g_print ("FIXME\n");
+}
+
+#define SEPARATOR { "", NULL, (NULL), NULL, 0 }
+#define TERMINATOR { NULL, NULL, (NULL), NULL, 0 }
+
+static EPopupMenu address_menu [] = {
+ { N_("Add to addressbook (FIXME)"), NULL,
+ GTK_SIGNAL_FUNC (add_to_addressbook), NULL, 0 },
+ { N_("Open in addressbook (FIXME)"), NULL,
+ GTK_SIGNAL_FUNC (open_in_addressbook), NULL, 0 },
+
+ TERMINATOR
+};
+
+static EPopupMenu link_menu [] = {
+ { N_("Open link in browser (FIXME)"), NULL,
+ GTK_SIGNAL_FUNC (link_open_in_browser), NULL, 0 },
+ { N_("Save as (FIXME)"), NULL,
+ GTK_SIGNAL_FUNC (link_save_as), NULL, 0 },
+ { N_("Copy location (FIXME)"), NULL,
+ GTK_SIGNAL_FUNC (link_copy_location), NULL, 0 },
+
+ TERMINATOR
+};
+
+static int
+html_button_press_event (GtkWidget *widget, GdkEventButton *event, MailDisplay *mail_display)
+{
+ g_return_val_if_fail (widget != NULL, FALSE);
+ g_return_val_if_fail (event != NULL, FALSE);
+
+ if (event->type == GDK_BUTTON_PRESS) {
+ if (event->button == 3) {
+ HTMLPoint *point;
+ const gchar *email;
+ const gchar *name;
+ const gchar *link;
+
+ point = html_engine_get_point_at (GTK_HTML (widget)->engine, event->x, event->y, FALSE);
+ if (point) {
+ email = (const gchar *) html_object_get_data (point->object, "email");
+ if (email) {
+ name = (const gchar *) html_object_get_data (point->object, "name");
+ e_popup_menu_run (address_menu, (GdkEvent *) event, 0, 0, mail_display);
+ } else if ((link = html_engine_get_link_at (GTK_HTML (widget)->engine,
+ event->x, event->y))) {
+ e_popup_menu_run (link_menu, (GdkEvent *) event, 0, 0, mail_display);
+ }
+ html_point_destroy (point);
+ }
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static void
+html_iframe_created (GtkWidget *w, GtkHTML *iframe, MailDisplay *mail_display)
+{
+ gtk_signal_connect (GTK_OBJECT (iframe), "button_press_event",
+ GTK_SIGNAL_FUNC (html_button_press_event), mail_display);
+}
+
GtkWidget *
mail_display_new (void)
{
@@ -1064,6 +1158,10 @@ mail_display_new (void)
gtk_signal_connect (GTK_OBJECT (html), "link_clicked",
GTK_SIGNAL_FUNC (on_link_clicked),
mail_display);
+ gtk_signal_connect (GTK_OBJECT (html), "button_press_event",
+ GTK_SIGNAL_FUNC (html_button_press_event), mail_display);
+ gtk_signal_connect (GTK_OBJECT (html), "iframe_created",
+ GTK_SIGNAL_FUNC (html_iframe_created), mail_display);
gtk_container_add (GTK_CONTAINER (scroll), html);
gtk_widget_show (GTK_WIDGET (html));
diff --git a/mail/mail-format.c b/mail/mail-format.c
index 2668208bc9..fc46526b9c 100644
--- a/mail/mail-format.c
+++ b/mail/mail-format.c
@@ -582,7 +582,7 @@ write_field_row_begin (const char *description, gint flags, GtkHTML *html, GtkHT
encoded_desc = e_utf8_from_gtk_string (GTK_WIDGET (html), description);
- mail_html_write (html, stream, "<tr><%s align=right> %s </%s>",
+ mail_html_write (html, stream, "<tr><%s align=\"right\" valign=\"top\">%s</%s>",
bold ? "th" : "td", encoded_desc, bold ? "th" : "td");
g_free (encoded_desc);
@@ -600,7 +600,7 @@ write_date (CamelMimeMessage *message, int flags, GtkHTML *html, GtkHTMLStream *
date = camel_mime_message_get_date (message, &offset);
datestr = header_format_date (date, offset);
- mail_html_write (html, stream, "<td> %s </td> </tr>", datestr);
+ mail_html_write (html, stream, "<td>%s</td> </tr>", datestr);
g_free (datestr);
}
@@ -617,7 +617,7 @@ write_subject (const char *subject, int flags, GtkHTML *html, GtkHTMLStream *str
write_field_row_begin (_("Subject:"), flags, html, stream);
- mail_html_write (html, stream, "<td> %s </td> </tr>", encoded_subj);
+ mail_html_write (html, stream, "<td>%s</td> </tr>", encoded_subj);
if (subject)
g_free (encoded_subj);
@@ -653,6 +653,7 @@ static void
write_address(MailDisplay *md, const CamelInternetAddress *addr, const char *field_name, int flags)
{
const char *name, *email;
+ gboolean name_set = FALSE, mail_set = FALSE;
gint i;
if (addr == NULL || !camel_internet_address_get (addr, 0, NULL, NULL))
@@ -664,19 +665,40 @@ write_address(MailDisplay *md, const CamelInternetAddress *addr, const char *fie
while (camel_internet_address_get (addr, i, &name, &email)) {
if ((name && *name) || (email && *email)) {
-
- mail_html_write (md->html, md->stream, i ? ", " : "<td>");
+ /* we need these <B> </B> to separate HTMLText objects */
+ mail_html_write (md->html, md->stream, i ? ",<B> </B> " : "<td>");
+ mail_html_write (md->html, md->stream, " ");
- mail_html_write (md->html, md->stream, "<object classid=\"address\">");
+ if (name && *name) {
+ mail_html_write (md->html, md->stream,
+ "<!--+GtkHTML:<DATA class=\"Text\" key=\"name\" value=\"%s\">-->",
+ name);
+ name_set = TRUE;
+ }
+
+ if (email && *email) {
+ mail_html_write (md->html, md->stream,
+ "<!--+GtkHTML:<DATA class=\"Text\" key=\"email\" value=\"%s\">-->",
+ email);
+ mail_set = TRUE;
+ }
if (name && *name)
- mail_html_write (md->html, md->stream, "<param name=\"name\" value=\"%s\"/>", name);
+ mail_html_write (md->html, md->stream, "%s ", name);
if (email && *email)
- mail_html_write (md->html, md->stream, "<param name=\"email\" value=\"%s\"/>", email);
- mail_html_write (md->html, md->stream, "</object>");
+ mail_html_write (md->html, md->stream, "%s%s%s",
+ name && *name ? "&lt;" : "",
+ email,
+ name && *name ? "&gt;" : "");
}
++i;
}
+ if (name_set)
+ mail_html_write (md->html, md->stream,
+ "<!--+GtkHTML:<DATA class=\"Text\" clear=\"name\">-->");
+ if (mail_set)
+ mail_html_write (md->html, md->stream,
+ "<!--+GtkHTML:<DATA class=\"Text\" clear=\"email\">-->");
mail_html_write (md->html, md->stream, "</td></tr>"); /* Finish up the table row */
}