diff options
author | Milan Crha <mcrha@redhat.com> | 2008-01-02 20:35:38 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2008-01-02 20:35:38 +0800 |
commit | dbe798bd9a4f54b76968d16931178ab1c683e90d (patch) | |
tree | e2aad3d75d92b4a959e46564084f82d5e5aa75bd | |
parent | 89908f675cfc9a7c83d69f729bf4d4e57cd5a41a (diff) | |
download | gsoc2013-evolution-dbe798bd9a4f54b76968d16931178ab1c683e90d.tar gsoc2013-evolution-dbe798bd9a4f54b76968d16931178ab1c683e90d.tar.gz gsoc2013-evolution-dbe798bd9a4f54b76968d16931178ab1c683e90d.tar.bz2 gsoc2013-evolution-dbe798bd9a4f54b76968d16931178ab1c683e90d.tar.lz gsoc2013-evolution-dbe798bd9a4f54b76968d16931178ab1c683e90d.tar.xz gsoc2013-evolution-dbe798bd9a4f54b76968d16931178ab1c683e90d.tar.zst gsoc2013-evolution-dbe798bd9a4f54b76968d16931178ab1c683e90d.zip |
** Fix for bug #317823
2008-01-02 Milan Crha <mcrha@redhat.com>
** Fix for bug #317823
* em-format-html-display.c: (efhd_get_uri_puri):
New helper function to dig up uri or puri from the GtkHtml.
If the object is an image, then pass it as puri or uri, depends
on the source of the image.
* em-format-html-display.c: (efhd_html_button_press_event),
(em_format_html_display_popup_menu): Using new helper function.
Note: New API functions in gtkhtml are required.
svn path=/trunk/; revision=34750
-rw-r--r-- | mail/ChangeLog | 11 | ||||
-rw-r--r-- | mail/em-format-html-display.c | 64 |
2 files changed, 57 insertions, 18 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 904c9edead..f78fcdc96c 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,16 @@ 2008-01-02 Milan Crha <mcrha@redhat.com> + ** Fix for bug #317823 + + * em-format-html-display.c: (efhd_get_uri_puri): + New helper function to dig up uri or puri from the GtkHtml. + If the object is an image, then pass it as puri or uri, depends + on the source of the image. + * em-format-html-display.c: (efhd_html_button_press_event), + (em_format_html_display_popup_menu): Using new helper function. + +2008-01-02 Milan Crha <mcrha@redhat.com> + ** Fix for bug #364642 * em-composer-prefs.h: (struct _EMComposerPrefs): diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index eb06d8a095..8589564bd6 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -837,31 +837,62 @@ efhd_iframe_created(GtkHTML *html, GtkHTML *iframe, EMFormatHTMLDisplay *efh) return; } +static void +efhd_get_uri_puri (GtkWidget *html, GdkEventButton *event, EMFormatHTMLDisplay *efhd, char **uri, EMFormatPURI **puri) +{ + char *url, *img_url; + + g_return_if_fail (html != NULL); + g_return_if_fail (GTK_IS_HTML (html)); + g_return_if_fail (efhd != NULL); + + if (event) { + url = gtk_html_get_url_at (GTK_HTML (html), event->x, event->y); + img_url = gtk_html_get_image_src_at (GTK_HTML (html), event->x, event->y); + } else { + url = gtk_html_get_cursor_url (GTK_HTML (html)); + img_url = gtk_html_get_cursor_image_src (GTK_HTML (html)); + } + + if (!url && img_url) { + if (strstr (img_url, "://") || g_ascii_strncasecmp (img_url, "cid:", 4) == 0) { + url = img_url; + img_url = NULL; + } else + url = g_strconcat ("file://", img_url, NULL); + } + + if (url && puri) + *puri = em_format_find_puri((EMFormat *)efhd, url); + + if (uri) { + *uri = url; + url = NULL; + } +} + static int efhd_html_button_press_event (GtkWidget *widget, GdkEventButton *event, EMFormatHTMLDisplay *efhd) { - char *uri; - gboolean res = FALSE; + char *uri = NULL; EMFormatPURI *puri = NULL; + gboolean res = FALSE; if (event->button != 3) return FALSE; - uri = gtk_html_get_url_at (GTK_HTML (widget), event->x, event->y); - d(printf("popup button pressed\n")); - if (uri && !strncmp (uri, "##", 2)) - return TRUE; + efhd_get_uri_puri (widget, event, efhd, &uri, &puri); - if (uri) { - puri = em_format_find_puri((EMFormat *)efhd, uri); - d(printf("poup event, uri = '%s' part = '%p'\n", uri, puri?puri->part:NULL)); + if (uri && !strncmp (uri, "##", 2)) { + g_free (uri); + return TRUE; } g_signal_emit((GtkObject *)efhd, efhd_signals[EFHD_POPUP_EVENT], 0, event, uri, puri?puri->part:NULL, &res); - g_free(uri); + g_free (uri); return res; } @@ -870,20 +901,17 @@ gboolean em_format_html_display_popup_menu (EMFormatHTMLDisplay *efhd) { GtkHTML *html; - char *url; - gboolean res = FALSE; + char *uri = NULL; EMFormatPURI *puri = NULL; + gboolean res = FALSE; html = efhd->formathtml.html; - url = gtk_html_get_cursor_url (html); - - if (url) - puri = em_format_find_puri((EMFormat *)efhd, url); + efhd_get_uri_puri (GTK_WIDGET (html), NULL, efhd, &uri, &puri); - g_signal_emit((GtkObject *)efhd, efhd_signals[EFHD_POPUP_EVENT], 0, NULL, url, puri?puri->part:NULL, &res); + g_signal_emit ((GtkObject *)efhd, efhd_signals[EFHD_POPUP_EVENT], 0, NULL, uri, puri?puri->part:NULL, &res); - g_free(url); + g_free (uri); return res; } |