changeset 20:dafbdaa3a699

Added Webkit#reload and added more comments
author unexist
date Fri, 22 Jan 2010 13:32:08 +0100
parents f1a454f3411d
children c083232ced42
files subtly/webkit.rb
diffstat 1 files changed, 79 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/subtly/webkit.rb	Fri Jan 22 13:09:32 2010 +0100
+++ b/subtly/webkit.rb	Fri Jan 22 13:32:08 2010 +0100
@@ -19,34 +19,84 @@
 
     ffi_lib("libwebkit-1.0")
 
+    ## initialize
+    # Create webkit view
+    #
+    # @return [Oject] New view
+    ##
+
     def initialize
       @widget = Subtly::Webkit.ffi_new
     end
 
+    ## uri
+    # Load given uri in view
+    #
+    # @param  [Pointer, #read]  Webkit view, #GtkWidget
+    #
+    # @return [String] Uri in webkit view
+    ##
+
     def uri
       Subtly::Webkit.ffi_get_uri(@widget)
     end
 
+    ## uri=
+    # Set given uri
+    #
+    # @param  [String, #read] uri  Uri to set
+    ##
+    #
     def uri=(uri)
       Subtly::Webkit.ffi_set_uri(@widget, uri)
     end
 
+    ## title
+    # Get title or uri loaded
+    #
+    # @return [String] Title of uri
+    ##
+
     def title
       Subtly::Webkit.ffi_get_title(@widget)
     end
+ 
+    ## back
+    # Step back in browser history
+    ##
 
     def back
       Subtly::Webkit.ffi_go_steps(@widget, -1)
     end
 
+    ## forward
+    # Step forward in history
+    ##
+
     def forward
       Subtly::Webkit.ffi_go_steps(@widget, 1)
     end
 
+    ## reload
+    # Reload page from source or cache
+    #
+    # @param [Bool, #read]  use_cache  Use cache or not
+    ##
+
+    def reload(use_cache)
+      if(use_cache)
+        Subtly::Webkit.ffi_reload_cache(@widget)
+      else
+        Subtly::Webkit.ffi_reload(@widget)
+      end
+    end
+
+    private
+
     ## ffi_new
     # Create webkit view
     #
-    # @return [Pointer] Return the new view
+    # @return [Pointer] New view
     ##
 
     attach_function(:ffi_new,
@@ -56,7 +106,8 @@
     ## ffi_get_uri
     # Load given uri in view
     #
-    # @param  [Pointer, #read]  Webkit view, #GtkWidget
+    # @param  [Pointer, #read] web_view  A #WebKitWebView
+    #
     # @return [String] Uri in webkit view
     ##
 
@@ -67,8 +118,8 @@
     ## ffi_set_uri
     # Set given uri in view
     #
-    # @param  [Pointer, #read]  Webkit view, #GtkWidget
-    # @param  [String, #read]   Uri to set
+    # @param  [Pointer, #read]  web_view  A #WebKitWebView
+    # @param  [String,  #read] uri        Uri to set
     ##
 
     attach_function(:ffi_set_uri,
@@ -78,7 +129,8 @@
     ## ffi_get_title
     # Get title or uri loaded
     #
-    # @param  [Pointer, #read]  Webkit view, #GtkWidget
+    # @param  [Pointer, #read]  web_view  A #WebKitWebView
+    #
     # @return [String] Title of uri
     ##
 
@@ -89,12 +141,32 @@
     ## ffi_go_steps
     # Go back or forward in history
     #
-    # @param  [Pointer, #read]  Webkit view, #GtkWidget
-    # @param  [Int,     #read]  Steps to go
+    # @param  [Pointer, #read]  web_view  A #WebKitWebView
+    # @param  [Int,     #read]  steps     Steps to go
     ##
 
     attach_function(:ffi_go_steps,
       :webkit_web_view_go_back_or_forward, [ :pointer, :int ], :void
     )
+
+    ## ffi_reload_cache
+    # Reload view from cache
+    #
+    # @param  [Pointer, #read]  web_view  A #WebKitWebView
+    ##
+
+    attach_function(:ffi_reload_cache,
+      :webkit_web_view_reload, [ :pointer ], :void
+    )
+
+    ## ffi_reload
+    # Reload view bypassing cache
+    #
+    # @param  [Pointer, #read]  web_view  A #WebKitWebView
+    ##
+
+    attach_function(:ffi_reload,
+      :webkit_web_view_reload_bypass_cache, [ :pointer ], :void
+    )    
   end # }}}
 end