/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see
*/
#ifdef HAVE_CONFIG_H
#include
#endif
#include "e-mail-display-popup-text-highlight.h"
#include "mail/e-mail-display-popup-extension.h"
#include "mail/e-mail-display.h"
#include
#include
#include "mail/e-mail-browser.h"
#include
#include
#include "languages.h"
#define d(x)
typedef struct _EMailDisplayPopupTextHighlight {
EExtension parent;
GtkActionGroup *action_group;
WebKitDOMDocument *document;
} EMailDisplayPopupTextHighlight;
typedef struct _EMailDisplayPopupTextHighlightClass {
EExtensionClass parent_class;
} EMailDisplayPopupTextHighlightClass;
#define E_MAIL_DISPLAY_POPUP_TEXT_HIGHLIGHT(obj) \
(G_TYPE_CHECK_INSTANCE_CAST \
((obj), e_mail_display_popup_text_highlight_get_type (), EMailDisplayPopupTextHighlight))
GType e_mail_display_popup_text_highlight_get_type (void);
static void e_mail_display_popup_extension_interface_init (EMailDisplayPopupExtensionInterface *iface);
G_DEFINE_DYNAMIC_TYPE_EXTENDED (
EMailDisplayPopupTextHighlight,
e_mail_display_popup_text_highlight,
E_TYPE_EXTENSION,
0,
G_IMPLEMENT_INTERFACE_DYNAMIC (
E_TYPE_MAIL_DISPLAY_POPUP_EXTENSION,
e_mail_display_popup_extension_interface_init));
static const gchar *ui =
""
" "
" "
" "
" "
" "
" "
"";
static const gchar *ui_reader =
""
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
"";
static GtkActionEntry entries[] = {
{ "format-as-menu",
NULL,
N_("_Format as..."),
NULL,
NULL,
NULL
},
{ "format-as-other-menu",
NULL,
N_("_Other languages"),
NULL,
NULL,
NULL
}
};
static void
reformat (GtkAction *old,
GtkAction *action,
gpointer user_data)
{
EMailDisplayPopupTextHighlight *th_extension;
WebKitDOMDocument *doc;
WebKitDOMDOMWindow *window;
WebKitDOMElement *frame_element;
SoupURI *soup_uri;
GHashTable *query;
gchar *uri;
th_extension = E_MAIL_DISPLAY_POPUP_TEXT_HIGHLIGHT (user_data);
doc = th_extension->document;
if (!doc)
return;
uri = webkit_dom_document_get_document_uri (doc);
soup_uri = soup_uri_new (uri);
g_free (uri);
if (!soup_uri)
goto exit;
if (!soup_uri->query) {
soup_uri_free (soup_uri);
goto exit;
}
query = soup_form_decode (soup_uri->query);
g_hash_table_replace (
query, g_strdup ("__formatas"), (gpointer) gtk_action_get_name (action));
g_hash_table_replace (
query, g_strdup ("mime_type"), (gpointer) "text/plain");
soup_uri_set_query_from_form (soup_uri, query);
g_hash_table_destroy (query);
uri = soup_uri_to_string (soup_uri, FALSE);
soup_uri_free (soup_uri);
/* Get frame's window and from the window the actual