r21093 - in /desktop/experimental/epiphany-webkit/debian: changelog patches/16_reimplement_search_on_locationbar.patch

kov at users.alioth.debian.org kov at users.alioth.debian.org
Wed Aug 26 19:12:53 UTC 2009


Author: kov
Date: Wed Aug 26 19:12:53 2009
New Revision: 21093

URL: http://svn.debian.org/wsvn/pkg-gnome/?sc=1&rev=21093
Log:
Updated 16_reimplement_search_on_locationbar.patch from the actual commit

Modified:
    desktop/experimental/epiphany-webkit/debian/changelog
    desktop/experimental/epiphany-webkit/debian/patches/16_reimplement_search_on_locationbar.patch

Modified: desktop/experimental/epiphany-webkit/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-gnome/desktop/experimental/epiphany-webkit/debian/changelog?rev=21093&op=diff
==============================================================================
--- desktop/experimental/epiphany-webkit/debian/changelog [utf-8] (original)
+++ desktop/experimental/epiphany-webkit/debian/changelog [utf-8] Wed Aug 26 19:12:53 2009
@@ -1,3 +1,10 @@
+epiphany-webkit (2.27.91-2) experimental; urgency=low
+
+  * debian/patches/16_reimplement_search_on_locationbar.patch:
+  - updated from upstream's commit
+
+ -- Gustavo Noronha Silva <kov at debian.org>  Wed, 26 Aug 2009 16:08:44 -0300
+
 epiphany-webkit (2.27.91-1) experimental; urgency=low
 
   * New upstream release

Modified: desktop/experimental/epiphany-webkit/debian/patches/16_reimplement_search_on_locationbar.patch
URL: http://svn.debian.org/wsvn/pkg-gnome/desktop/experimental/epiphany-webkit/debian/patches/16_reimplement_search_on_locationbar.patch?rev=21093&op=diff
==============================================================================
--- desktop/experimental/epiphany-webkit/debian/patches/16_reimplement_search_on_locationbar.patch [utf-8] (original)
+++ desktop/experimental/epiphany-webkit/debian/patches/16_reimplement_search_on_locationbar.patch [utf-8] Wed Aug 26 19:12:53 2009
@@ -1,125 +1,24 @@
-From b0bea4d27140f1899e84d4cf50f47655c57f18fc Mon Sep 17 00:00:00 2001
-From: Michael Kuhn <suraia at ikkoku.de>
-Date: Thu, 20 Aug 2009 18:48:50 -0300
-Subject: [PATCH] Use regex and the load-error signal to reimplement search on the location bar
+From 90605f60507241c46a721ee8d7ace518aacb41ce Mon Sep 17 00:00:00 2001
+From: Gustavo Noronha Silva <gns at gnome.org>
+Date: Wed, 26 Aug 2009 14:30:04 -0300
+Subject: [PATCH] Reimplement search on the location bar
 
-Changes slightly modified by Gustavo Noronha Silva to apply comments
-about also checking if the error is related to DNS (and the other
-error soup uses when we try to load multiple words as an URI).
+Use a regular expression and SoupURI to figure out if we should search
+the string that was typed, or load it as an URI.
 ---
- embed/ephy-embed.c    |   53 +++++++++++++++++++++++++++++++++++++++++++++++++
- embed/ephy-embed.h    |    5 ++-
- embed/ephy-web-view.c |   39 ++++++++++++++++++++++++++++++++++++
- 3 files changed, 95 insertions(+), 2 deletions(-)
+ embed/ephy-web-view.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++++-
+ 1 files changed, 48 insertions(+), 1 deletions(-)
 
-diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
-index f9f9c53..8b4f5f6 100644
---- a/embed/ephy-embed.c
-+++ b/embed/ephy-embed.c
-@@ -61,6 +61,7 @@ struct EphyEmbedPrivate
-   EphyHistory *history;
-   GtkWidget *inspector_window;
-   guint is_setting_zoom : 1;
-+  guint search_on_load_error : 1;
- };
- 
- static void
-@@ -228,6 +229,41 @@ load_status_changed_cb (WebKitWebView *view,
-   }
- }
- 
-+static gboolean
-+load_error_cb (WebKitWebView *web_view,
-+               WebKitWebFrame *web_frame,
-+               const char *uri,
-+               GError *error,
-+               EphyEmbed *embed)
-+{
-+  if (embed->priv->search_on_load_error == TRUE &&
-+      g_str_has_prefix (uri, "http://") == TRUE &&
-+      (error->code == SOUP_STATUS_CANT_RESOLVE ||
-+       error->code == SOUP_STATUS_SWITCHING_PROTOCOLS)) {
-+    char *tmp_uri = g_strdup (uri);
-+    char *effective_uri = NULL;
-+
-+    embed->priv->search_on_load_error = FALSE;
-+
-+    /* Remove slash that is added to the URI when DNS fails.
-+     * FIXME: who is adding this slash here? */
-+    if (error->code == SOUP_STATUS_CANT_RESOLVE)
-+      tmp_uri[strlen (tmp_uri) - 1] = '\0';
-+
-+    /* Search for uri without the http:// prefix. */
-+    effective_uri = g_strdup_printf (_("http://www.google.com/search?q=%s&ie=UTF-8&oe=UTF-8"), tmp_uri + 7);
-+
-+    ephy_web_view_load_url (EPHY_WEB_VIEW (web_view), effective_uri);
-+
-+    g_free (tmp_uri);
-+    g_free (effective_uri);
-+
-+    return TRUE;
-+  } else
-+    return FALSE;
-+}
-+
-+
- static void
- hovering_over_link_cb (WebKitWebView *web_view,
-                        char *title,
-@@ -678,6 +714,7 @@ ephy_embed_constructed (GObject *object)
- 
-   g_object_connect (web_view,
-                     "signal::notify::load-status", G_CALLBACK (load_status_changed_cb), embed,
-+                    "signal::load-error", G_CALLBACK (load_error_cb), embed,
-                     "signal::hovering-over-link", G_CALLBACK (hovering_over_link_cb), embed,
-                     "signal::mime-type-policy-decision-requested", G_CALLBACK (mime_type_policy_decision_requested_cb), embed,
-                     "signal::download-requested", G_CALLBACK (download_requested_cb), embed,
-@@ -739,3 +776,19 @@ ephy_embed_get_web_view (EphyEmbed *embed)
- 
-   return EPHY_WEB_VIEW (embed->priv->web_view);
- }
-+
-+/**
-+ * _ephy_embed_search_on_load_error:
-+ * @embed: and #EphyEmbed
-+ *
-+ * Tells the @embed that it should handle the load error by searching
-+ * the string in a web search engine. This will happen when a name
-+ * fails loading because of a DNS failure.
-+ **/
-+void
-+_ephy_embed_search_on_load_error (EphyEmbed *embed)
-+{
-+  g_return_if_fail (EPHY_IS_EMBED (embed));
-+
-+  embed->priv->search_on_load_error = TRUE;
-+}
-diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h
-index 18fb6ed..04b7ba4 100644
---- a/embed/ephy-embed.h
-+++ b/embed/ephy-embed.h
-@@ -51,8 +51,9 @@ struct EphyEmbedClass {
-   GtkScrolledWindowClass parent_class;
- };
- 
--GType        ephy_embed_get_type     (void);
--EphyWebView* ephy_embed_get_web_view (EphyEmbed *embed);
-+GType        ephy_embed_get_type              (void);
-+EphyWebView* ephy_embed_get_web_view          (EphyEmbed *embed);
-+void         _ephy_embed_search_on_load_error (EphyEmbed *embed);
- 
- G_END_DECLS
- 
 diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
-index 2c8d66d..da62a9e 100644
+index 6bd0196..04ccf89 100644
 --- a/embed/ephy-web-view.c
 +++ b/embed/ephy-web-view.c
 @@ -81,6 +81,9 @@ struct _EphyWebViewPrivate {
    guint reload_scheduled_id;
    guint reload_delay_ticks;
  
-+  /* Location bar search regex */
-+  GRegex *search_regex;
++  /* Regex to figure out if we're dealing with a wanna-be URI */
++  GRegex *non_search_regex;
 +
    GSList *hidden_popups;
    GSList *shown_popups;
@@ -128,9 +27,9 @@
      priv->icon = NULL;
    }
  
-+  if (priv->search_regex != NULL) {
-+    g_regex_unref (priv->search_regex);
-+    priv->search_regex = NULL;
++  if (priv->non_search_regex != NULL) {
++    g_regex_unref (priv->non_search_regex);
++    priv->non_search_regex = NULL;
 +  }
 +
    ephy_web_view_popups_manager_reset (EPHY_WEB_VIEW (object));
@@ -144,15 +43,20 @@
  
    priv = web_view->priv = EPHY_WEB_VIEW_GET_PRIVATE (web_view);
  
-@@ -994,6 +1003,16 @@ ephy_web_view_init (EphyWebView *web_view)
+@@ -994,6 +1003,21 @@ ephy_web_view_init (EphyWebView *web_view)
    priv->security_level = EPHY_WEB_VIEW_STATE_IS_UNKNOWN;
    priv->monitor_directory = FALSE;
  
-+  priv->search_regex = g_regex_new ("(^localhost$|^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]$|"
-+                                    "^[^[\\.[:space:]]+\\.[^\\.[:space:]]+.*$|"
-+                                    "^https?://[^/\\.[:space:]]+.*$|"
-+                                    "^about:.*$)",
-+                                    G_REGEX_OPTIMIZE, G_REGEX_MATCH_NOTEMPTY, &error);
++  priv->non_search_regex = g_regex_new ("(^localhost$|"
++                                        "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]$|"
++                                        "^::[0-9a-f:]*$|" /* IPv6 literals */
++                                        "^[0-9a-f:]+:[0-9a-f:]*$|" /* IPv6 literals */
++                                        "^[^\\.[:space:]]+\\.[^\\.[:space:]]+.*$|" /* foo.bar... */
++                                        "^https?://[^/\\.[:space:]]+.*$|"
++                                        "^about:.*$|"
++                                        "^data:.*$|"
++                                        "^file:.*$)",
++                                        G_REGEX_OPTIMIZE, G_REGEX_MATCH_NOTEMPTY, &error);
 +  if (error) {
 +    g_critical ("Failure creating search regex: %s", error->message);
 +    g_error_free (error);
@@ -161,38 +65,44 @@
    g_signal_connect_object (web_view, "ge_document_type",
                             G_CALLBACK (ge_document_type_cb),
                             web_view, (GConnectFlags)0);
-@@ -1069,11 +1088,31 @@ void
+@@ -1069,13 +1093,36 @@ void
  ephy_web_view_load_url (EphyWebView *view,
                          const char *url)
  {
 +  EphyWebViewPrivate *priv;
++  SoupURI *soup_uri = NULL;
    char *effective_url;
  
    g_return_if_fail (EPHY_IS_WEB_VIEW (view));
    g_return_if_fail (url);
  
+-  effective_url = ephy_embed_utils_normalize_address (url);
 +  priv = view->priv;
 +
-+  /* If the string doesn't look like an URL, let's search it */
-+  if (priv->search_regex &&
-+      !g_regex_match (priv->search_regex, url, 0, NULL)) {
-+      effective_url = g_strdup_printf (_("http://www.google.com/search?q=%s&ie=UTF-8&oe=UTF-8"), url);
-+      webkit_web_view_open (WEBKIT_WEB_VIEW (view), effective_url);
-+      g_free (effective_url);
-+      return;
-+  }
++  /* We use SoupURI as an indication of whether the value given in url
++   * is not something we want to search; we only do that, though, if
++   * the address has a web scheme, because SoupURI will consider any
++   * string: as a valid scheme, and we will end up prepending http://
++   * to it */
++  if (ephy_embed_utils_address_has_web_scheme (url))
++    soup_uri = soup_uri_new (url);
 +
-+  if (!ephy_embed_utils_address_has_web_scheme (url)) {
-+    EphyEmbed *embed;
++  /* If the string doesn't look like an URI, let's search it; */
++  if (soup_uri == NULL &&
++      priv->non_search_regex &&
++      !g_regex_match (priv->non_search_regex, url, 0, NULL))
++    effective_url = g_strdup_printf (_("http://www.google.com/search?q=%s&ie=UTF-8&oe=UTF-8"), url);
++  else
++    effective_url = ephy_embed_utils_normalize_address (url);
 +
-+    embed = EPHY_EMBED (gtk_widget_get_parent (GTK_WIDGET(view)));
+   webkit_web_view_open (WEBKIT_WEB_VIEW (view), effective_url);
 +
-+    _ephy_embed_search_on_load_error (embed);
-+  }
++  if (soup_uri)
++    soup_uri_free (soup_uri);
 +
-   effective_url = ephy_embed_utils_normalize_address (url);
-   webkit_web_view_open (WEBKIT_WEB_VIEW (view), effective_url);
    g_free (effective_url);
+ }
+ 
 -- 
 1.6.3.3
 




More information about the pkg-gnome-commits mailing list