[Xfce4-commits] <midori:master> Show access keys distinct from numbers in link search

Christian Dywan noreply at xfce.org
Tue Apr 5 00:44:01 CEST 2011


Updating branch refs/heads/master
         to 867d8ce87e13a81f8a39df74bae165c79513f113 (commit)
       from 2460c161dda9665d02bb79909988c843289ccf15 (commit)

commit 867d8ce87e13a81f8a39df74bae165c79513f113
Author: Alexander Friesen <a_06357 at fastmail.fm>
Date:   Tue Apr 5 00:40:15 2011 +0200

    Show access keys distinct from numbers in link search
    
    Keys are invoked with Alt+key.
    
    Numeric access keys don't work and are not shown as such.

 midori/midori-view.c |   50 ++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/midori/midori-view.c b/midori/midori-view.c
index 750305f..2a58625 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -991,6 +991,14 @@ midori_view_web_view_navigation_decision_cb (WebKitWebView*             web_view
         "       parent.removeChild(links[i]); } }",
         NULL);
     g_free (result);
+    result = sokoke_js_script_eval (js_context,
+        "var links = document.getElementsByClassName ('midori_access_key_fc04de');"
+        "if (links != undefined && links.length > 0) {"
+        "   for (var i = links.length - 1; i >= 0; i--) {"
+        "       var parent = links[i].parentNode;"
+        "       parent.removeChild(links[i]); } }",
+        NULL);
+    g_free (result);
     view->find_links = -1;
 
     return FALSE;
@@ -1886,28 +1894,38 @@ gtk_widget_key_press_event_cb (WebKitWebView* web_view,
         if (view->find_links == -1)
         {
             result = sokoke_js_script_eval (js_context,
-                "(function (selector, rule) { "
+                " var style_func = (function (selector, rule) { "
                 " var style = document.createElement ('style');"
                 " style.setAttribute ('type', 'text/css');"
                 " var heads = document.getElementsByTagName ('head');"
                 " heads[0].appendChild (style);"
                 " document.styleSheets[0].insertRule (selector + ' ' + rule);"
-                " } )"
-                " ('.midoriHKD87346', '{ "
+                " } );"
+                " style_func ('.midoriHKD87346', '{ "
                 " font-size:small !important; font-weight:bold !important;"
                 " z-index:500; border-radius:0.3em; line-height:1 !important;"
                 " background: white !important; color: black !important;"
                 " border:1px solid gray; padding:0 0.1em !important;"
                 " position:absolute; display:inline !important; }');"
-                "var links = document.getElementsByTagName ('a');"
-                "var label_count = 0;"
-                "for (i in links) {"
-                "  if (links[i].insertBefore && links[i].href) { "
-                "    var child = document.createElement ('span');"
-                "    child.setAttribute ('class', 'midoriHKD87346');"
-                "    child.appendChild (document.createTextNode (label_count));"
-                "    links[i].insertBefore (child);"
-                "    label_count++; } }",
+                " style_func ('.midori_access_key_fc04de', '{ "
+                " font-size:small !important; font-weight:bold !important;"
+                " z-index:500; border-radius:0.3em; line-height:1 !important;"
+                " background: black !important; color: white !important;"
+                " border:1px solid gray; padding:0 0.1em 0.2em 0.1em !important;"
+                " position:absolute; display:inline !important; }');"
+                " var label_count = 0;"
+                " for (i in document.links) {"
+                "   if (document.links[i].href && document.links[i].insertBefore) {"
+                "       var child = document.createElement ('span');"
+                "       if (document.links[i].accessKey && isNaN (document.links[i].accessKey)) {"
+                "           child.setAttribute ('class', 'midori_access_key_fc04de');"
+                "           child.appendChild (document.createTextNode (document.links[i].accessKey));"
+                "       } else {"
+                "         child.setAttribute ('class', 'midoriHKD87346');"
+                "         child.appendChild (document.createTextNode (label_count));"
+                "         label_count++;"
+                "       }"
+                "       document.links[i].insertBefore (child); } }",
                 NULL);
             view->find_links = 0;
         }
@@ -1957,6 +1975,14 @@ gtk_widget_key_press_event_cb (WebKitWebView* web_view,
                 "   parent.removeChild(links[i]); }",
                 NULL);
             g_free (result);
+            result = sokoke_js_script_eval (js_context,
+                "var links = document.getElementsByClassName ('midori_access_key_fc04de');"
+                "if (links != undefined && links.length > 0) {"
+                "   for (var i = links.length - 1; i >= 0; i--) {"
+                "       var parent = links[i].parentNode;"
+                "       parent.removeChild(links[i]); } }",
+                NULL);
+            g_free (result);
             view->find_links = -1;
         }
         return FALSE;



More information about the Xfce4-commits mailing list