/*
* 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-prefer-plain.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
#define d(x)
typedef struct _EMailDisplayPopupPreferPlain {
EExtension parent;
WebKitDOMDocument *document;
gchar *text_plain_id;
gchar *text_html_id;
GtkActionGroup *action_group;
} EMailDisplayPopupPreferPlain;
typedef struct _EMailDisplayPopupPreferPlainClass {
EExtensionClass parent_class;
} EMailDisplayPopupPreferPlainClass;
#define E_MAIL_DISPLAY_POPUP_PREFER_PLAIN(obj) \
(G_TYPE_CHECK_INSTANCE_CAST \
((obj), e_mail_display_popup_prefer_plain_get_type(), EMailDisplayPopupPreferPlain))
GType e_mail_display_popup_prefer_plain_get_type (void);
static void e_mail_display_popup_extension_interface_init (EMailDisplayPopupExtensionInterface *iface);
G_DEFINE_DYNAMIC_TYPE_EXTENDED (
EMailDisplayPopupPreferPlain,
e_mail_display_popup_prefer_plain,
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_webview =
""
" "
" "
" "
" "
" "
" "
" "
" "
"";
static const gchar *ui_reader =
""
" "
" "
" "
" "
" "
" "
" "
" "
"";
static void
toggle_part (GtkAction *action,
EMailDisplayPopupExtension *extension)
{
EMailDisplayPopupPreferPlain *pp_extension = (EMailDisplayPopupPreferPlain *) extension;
WebKitDOMDocument *doc = pp_extension->document;
WebKitDOMDOMWindow *window;
WebKitDOMElement *frame_element;
SoupURI *soup_uri;
GHashTable *query;
gchar *uri;
uri = webkit_dom_document_get_document_uri (doc);
soup_uri = soup_uri_new (uri);
g_free (uri);
query = soup_form_decode (soup_uri->query);
g_hash_table_replace (query, g_strdup ("part_id"),
pp_extension->text_html_id ?
pp_extension->text_html_id :
pp_extension->text_plain_id);
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