There's an issue in eve: if a page can't be loaded (due to network or
other instability issues), a message error page is displayed, but if you
try to reload that page to recover that, you still get the error because
the reload button just calls the ewk_view_reload() function, and that's
not enough. Actually you always need to focus on the url-entry and then
to activate it by pressing enter; this is so annoying on mobile devices
(I'm testing it in Openmoko).

These patches changes this behaviour by changing the reload-button
callback on error.

The code is quite tricky due to the fact that when loading the static
error page, newer "load,*" and "uri,changed" signals are emitted (is
this right?!? Should be "uri,changed" be emitted also when we're
visiting the same uri?).

I've made two versions of the patch, take the one you prefer (ooops, I
just noticed that the v1 doesn't free the load_error variable, please
include that fix in the case :) ).

Bye.
From 39bf453d524977e54d5d059e5eed48b24e4e7557 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20(Trevi=C3=B1o)?= <m...@3v1n0.net>
Date: Wed, 1 Dec 2010 10:13:30 +0100
Subject: [PATCH] eve: use full reload when a view returned a loading error v2

This has a tricky implementation due to the fact that Webkit reloads
a new page also when an error has occurred, not keeping the previous
error signal.
This version just alwyas changes the reload button callbacks on each
load, switching between the full and standard reload functions
---
 src/bin/chrome.c |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/src/bin/chrome.c b/src/bin/chrome.c
index f7e0c9d..412e51c 100644
--- a/src/bin/chrome.c
+++ b/src/bin/chrome.c
@@ -39,6 +39,10 @@ static More_Menu_Item *more_menu_home_page_default_set(Browser_Window *, More_Me
 
 static void on_more_item_click(void *data, Evas_Object *obj, void *event_info __UNUSED__);
 static void on_more_item_back_click(void *data, Evas_Object *edje, const char *emission __UNUSED__, const char *source __UNUSED__);
+static void on_action_reload(void *data, Evas_Object *o __UNUSED__,
+                 const char *emission __UNUSED__, const char *source __UNUSED__);
+static void on_action_reload_full(void *data, Evas_Object *o __UNUSED__,
+                 const char *emission __UNUSED__, const char *source __UNUSED__);
 
 static char *tab_grid_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__);
 static Evas_Object *tab_grid_icon_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__);
@@ -996,8 +1000,16 @@ static void
 on_view_uri_changed(void *data, Evas_Object *view, void *event_info __UNUSED__)
 {
    Evas_Object *chrome = data;
+   Evas_Object *ed = elm_layout_edje_get(chrome);
 
    _chrome_state_apply(chrome, view);
+
+   edje_object_signal_callback_del(ed, "action,reload", "reload",
+                                   on_action_reload);
+   edje_object_signal_callback_del(ed, "action,reload", "reload",
+                                   on_action_reload_full);
+   edje_object_signal_callback_add(ed, "action,reload", "reload",
+                                   on_action_reload, view);
 }
 
 static void
@@ -2096,6 +2108,15 @@ on_action_reload(void *data, Evas_Object *o __UNUSED__,
 }
 
 static void
+on_action_reload_full(void *data, Evas_Object *o __UNUSED__,
+                 const char *emission __UNUSED__, const char *source __UNUSED__)
+{
+   Evas_Object *view = data;
+
+   ewk_view_reload_full(view);
+}
+
+static void
 on_action_home(void *data, Evas_Object *o __UNUSED__,
                const char *emission __UNUSED__, const char *source __UNUSED__)
 {
@@ -2126,6 +2147,8 @@ on_view_load_error(void *data __UNUSED__, Evas_Object *view __UNUSED__,
 {
    const Ewk_Frame_Load_Error *error = event_info;
    Evas_Object *frame = error->frame;
+   Evas_Object *chrome = evas_object_data_get(view, "chrome");
+   Evas_Object *ed = elm_layout_edje_get(chrome);
    char *msg;
    int len;
    const char template[] = ""
@@ -2137,7 +2160,9 @@ on_view_load_error(void *data __UNUSED__, Evas_Object *view __UNUSED__,
                            "    <h1>Error loading page</h1>\n"
                            "    <p>Error description: <strong>%s</strong></p>\n"
                            "    <p>Failing address: <strong>%s</strong></p>\n"
-                           "    <p>Go <a href=\"javascript:history.go(-1);\">back</a></p>"
+                           "    <p>Go <a href=\"javascript:history.go(-1);\">back</a>\n"
+                           "    or <a href=\"javascript:history.go(0);\">retry</a>\n"
+                           "    </p>"
                            "  </body>\n" "</html>\n";
 
    if (error->is_cancellation)
@@ -2159,6 +2184,13 @@ on_view_load_error(void *data __UNUSED__, Evas_Object *view __UNUSED__,
    ewk_frame_contents_alternate_set
       (frame, msg, len, "text/html", NULL, NULL, error->failing_url);
    free(msg);
+
+   edje_object_signal_callback_del(ed, "action,reload", "reload",
+                                   on_action_reload);
+   edje_object_signal_callback_del(ed, "action,reload", "reload",
+                                   on_action_reload_full);
+   edje_object_signal_callback_add(ed, "action,reload", "reload",
+                                   on_action_reload_full, view);
 }
 
 static void
-- 
1.7.1

From dde33819decbe9c45bd5b34932bf891ae9903214 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20(Trevi=C3=B1o)?= <m...@3v1n0.net>
Date: Wed, 1 Dec 2010 09:37:14 +0100
Subject: [PATCH 1/3] eve: use full reload when a view returned a loading error v1

This has a tricky implementation due to the fact that Webkit reloads
a new page also when an error has occurred, not keeping the previous
error signal.
---
 src/bin/chrome.c |   62 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 61 insertions(+), 1 deletions(-)

diff --git a/src/bin/chrome.c b/src/bin/chrome.c
index f7e0c9d..61d8325 100644
--- a/src/bin/chrome.c
+++ b/src/bin/chrome.c
@@ -39,6 +39,10 @@ static More_Menu_Item *more_menu_home_page_default_set(Browser_Window *, More_Me
 
 static void on_more_item_click(void *data, Evas_Object *obj, void *event_info __UNUSED__);
 static void on_more_item_back_click(void *data, Evas_Object *edje, const char *emission __UNUSED__, const char *source __UNUSED__);
+static void on_action_reload(void *data, Evas_Object *o __UNUSED__,
+                 const char *emission __UNUSED__, const char *source __UNUSED__);
+static void on_action_reload_full(void *data, Evas_Object *o __UNUSED__,
+                 const char *emission __UNUSED__, const char *source __UNUSED__);
 
 static char *tab_grid_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__);
 static Evas_Object *tab_grid_icon_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__);
@@ -984,6 +988,13 @@ on_view_load_progress(void *data, Evas_Object *view, void *event_info)
 }
 
 static void
+on_view_load_finished(void *data, Evas_Object *view, void *event_info)
+{
+   Eina_Bool *load_error = evas_object_data_get(view, "load_error");
+   if (load_error) *load_error = EINA_FALSE;
+}
+
+static void
 on_view_title_changed(void *data, Evas_Object *view,
                       void *event_info __UNUSED__)
 {
@@ -996,8 +1007,27 @@ static void
 on_view_uri_changed(void *data, Evas_Object *view, void *event_info __UNUSED__)
 {
    Evas_Object *chrome = data;
+   Evas_Object *ed = elm_layout_edje_get(chrome);
+   Eina_Bool *load_error = evas_object_data_get(view, "load_error");
 
    _chrome_state_apply(chrome, view);
+
+   if (load_error && *load_error)
+     {
+        edje_object_signal_callback_del(ed, "action,reload", "reload",
+                                        on_action_reload);
+        edje_object_signal_callback_del(ed, "action,reload", "reload",
+                                        on_action_reload_full);
+        edje_object_signal_callback_add(ed, "action,reload", "reload",
+                                        on_action_reload_full, view);
+     } else {
+        edje_object_signal_callback_del(ed, "action,reload", "reload",
+                                        on_action_reload);
+        edje_object_signal_callback_del(ed, "action,reload", "reload",
+                                        on_action_reload_full);
+        edje_object_signal_callback_add(ed, "action,reload", "reload",
+                                        on_action_reload, view);
+     }
 }
 
 static void
@@ -2082,8 +2112,10 @@ on_action_pause(void *data, Evas_Object *o __UNUSED__,
                 const char *emission __UNUSED__, const char *source __UNUSED__)
 {
    Evas_Object *view = data;
+   Eina_Bool *load_error = evas_object_data_get(view, "load_error");
 
    ewk_view_stop(view);
+   if (load_error) *load_error = EINA_FALSE;
 }
 
 static void
@@ -2096,22 +2128,37 @@ on_action_reload(void *data, Evas_Object *o __UNUSED__,
 }
 
 static void
+on_action_reload_full(void *data, Evas_Object *o __UNUSED__,
+                 const char *emission __UNUSED__, const char *source __UNUSED__)
+{
+   Evas_Object *view = data;
+
+   ewk_view_reload_full(view);
+}
+
+static void
 on_action_home(void *data, Evas_Object *o __UNUSED__,
                const char *emission __UNUSED__, const char *source __UNUSED__)
 {
    Evas_Object *view = data;
+   Eina_Bool *load_error = evas_object_data_get(view, "load_error");
 
    ewk_view_uri_set(view, config_home_page_get(config));
+   if (load_error) *load_error = EINA_FALSE;
 }
 
 static void
 on_action_load_page(void *data, Evas_Object *view, void *event_info __UNUSED__)
 {
    Evas_Object *ewk_view = data;
+   Eina_Bool *load_error = evas_object_data_get(ewk_view, "load_error");
 
    const char *entry_data = elm_scrolled_entry_entry_get(view);
    char *uri;
 
+   if (load_error)
+      *load_error = EINA_FALSE;
+
    if ((uri = uri_sanitize(entry_data)))
      {
         ewk_view_uri_set(ewk_view, uri);
@@ -2126,6 +2173,7 @@ on_view_load_error(void *data __UNUSED__, Evas_Object *view __UNUSED__,
 {
    const Ewk_Frame_Load_Error *error = event_info;
    Evas_Object *frame = error->frame;
+   Eina_Bool *load_error;
    char *msg;
    int len;
    const char template[] = ""
@@ -2137,9 +2185,14 @@ on_view_load_error(void *data __UNUSED__, Evas_Object *view __UNUSED__,
                            "    <h1>Error loading page</h1>\n"
                            "    <p>Error description: <strong>%s</strong></p>\n"
                            "    <p>Failing address: <strong>%s</strong></p>\n"
-                           "    <p>Go <a href=\"javascript:history.go(-1);\">back</a></p>"
+                           "    <p>Go <a href=\"javascript:history.go(-1);\">back</a>\n"
+                           "    or <a href=\"javascript:history.go(0);\">retry</a>\n"
+                           "    </p>"
                            "  </body>\n" "</html>\n";
 
+   load_error = evas_object_data_get(view, "load_error");
+   if (load_error) *load_error = EINA_TRUE;
+
    if (error->is_cancellation)
       return;
 
@@ -2476,6 +2529,7 @@ chrome_add(Browser_Window *win, const char *url, Session_Item *session_item)
    Evas_Object *chrome = elm_layout_add(win->win);
    Evas_Object *ed = elm_layout_edje_get(chrome);
    Evas_Object *view;
+   Eina_Bool *load_error;
 
    if (!elm_layout_file_set(chrome, PACKAGE_DATA_DIR "/default.edj", "chrome"))
      {
@@ -2508,9 +2562,13 @@ chrome_add(Browser_Window *win, const char *url, Session_Item *session_item)
    evas_object_focus_set(view, 1);
    elm_layout_content_set(chrome, "view", view);
 
+   load_error = malloc(1);
+   *load_error = EINA_FALSE;
+
    evas_object_data_set(chrome, "view", view);
    evas_object_data_set(chrome, "win", win);
    evas_object_data_set(view, "chrome", chrome);
+   evas_object_data_set(view, "load_error", load_error);
    evas_object_data_set(ed, "win", win);
 
    evas_object_event_callback_add(view, EVAS_CALLBACK_KEY_DOWN, on_key_down,
@@ -2589,6 +2647,8 @@ chrome_add(Browser_Window *win, const char *url, Session_Item *session_item)
                                    on_action_tab_hide, chrome);
    evas_object_smart_callback_add(view, "load,progress", on_view_load_progress,
                                   chrome);
+   evas_object_smart_callback_add(view, "load,finished", on_view_load_finished,
+                                  chrome);
    evas_object_smart_callback_add(view, "title,changed", on_view_title_changed,
                                   chrome);
    evas_object_smart_callback_add(view, "uri,changed", on_view_uri_changed,
-- 
1.7.1

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to