aboutsummaryrefslogtreecommitdiffstats
path: root/embed/ephy-web-view.c
diff options
context:
space:
mode:
authorXan Lopez <xlopez@igalia.com>2011-09-06 02:35:14 +0800
committerXan Lopez <xlopez@igalia.com>2011-09-06 02:40:31 +0800
commit0c1f1ef6e14716bbfd2b64c057ab043e809b4364 (patch)
tree6f49af067eecff5bb4d060b0ea59e11eada32d03 /embed/ephy-web-view.c
parent0cff2bef71ac69095f62ace7be8443d42db34d32 (diff)
downloadgsoc2013-epiphany-0c1f1ef6e14716bbfd2b64c057ab043e809b4364.tar.gz
gsoc2013-epiphany-0c1f1ef6e14716bbfd2b64c057ab043e809b4364.tar.zst
gsoc2013-epiphany-0c1f1ef6e14716bbfd2b64c057ab043e809b4364.zip
Implement about:applications
A really simple way to list and delete the existing Web Applications. Hopefully this will go completely away in 3.4 replaced with something in the shell itself.
Diffstat (limited to 'embed/ephy-web-view.c')
-rw-r--r--embed/ephy-web-view.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 798946c3e..80f336871 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -48,6 +48,7 @@
#include "ephy-request-about.h"
#include "ephy-settings.h"
#include "ephy-string.h"
+#include "ephy-web-app-utils.h"
#include "ephy-web-view.h"
#include "ephy-zoom.h"
@@ -1787,6 +1788,22 @@ update_navigation_flags (EphyWebView *view)
}
}
+static gboolean
+delete_web_app_cb (WebKitDOMHTMLElement *button,
+ WebKitDOMEvent *dom_event,
+ EphyWebView *web_view)
+{
+ char *id = NULL;
+
+ id = webkit_dom_html_element_get_id (button);
+ if (id)
+ ephy_web_application_delete (id);
+
+ g_free (id);
+
+ return FALSE;
+}
+
static void
load_status_cb (WebKitWebView *web_view,
GParamSpec *pspec,
@@ -1885,6 +1902,29 @@ load_status_cb (WebKitWebView *web_view,
_ephy_web_view_hook_into_forms (view);
_ephy_web_view_hook_into_links (view);
+
+ /* FIXME: It sucks to do this here, but it's not really possible
+ * to hook the DOM actions nicely in the about: generator. */
+ if (g_str_equal (webkit_web_view_get_uri (web_view), "ephy-about:applications")) {
+ WebKitDOMDocument *document;
+ WebKitDOMNodeList *buttons;
+ gulong buttons_n;
+ int i;
+
+ document = webkit_web_view_get_dom_document (web_view);
+ buttons = webkit_dom_document_get_elements_by_tag_name (document, "input");
+ buttons_n = webkit_dom_node_list_get_length (buttons);
+
+ for (i = 0; i < buttons_n; i++) {
+ WebKitDOMNode *button;
+
+ button = webkit_dom_node_list_item (buttons, i);
+ webkit_dom_event_target_add_event_listener (WEBKIT_DOM_EVENT_TARGET (button), "click",
+ G_CALLBACK (delete_web_app_cb), false,
+ NULL);
+ }
+ }
+
break;
case WEBKIT_LOAD_FAILED:
ephy_web_view_set_link_message (view, NULL);