changeset 27:bb259a0825a1

Added SubtlyBrowserZoomIn and SubtlyBrowserZoomOut
author unexist
date Fri, 22 Jan 2010 14:57:49 +0100
parents b8a8e3c5b6c6
children 304f8997c7d2
files subtly.rb subtly/browser.rb subtly/webkit.rb
diffstat 3 files changed, 65 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/subtly.rb	Fri Jan 22 14:38:33 2010 +0100
+++ b/subtly.rb	Fri Jan 22 14:57:49 2010 +0100
@@ -25,6 +25,8 @@
   "m"   => :SubtlyBrowserForward,
   "r"   => :SubtlyBrowerReloadCache,
   "R"   => :SubtlyBrowerReload,
+  "+"   => :SubtlyBrowserZoomIn,
+  "-"   => :SubtlyBrowserZoomOut,
   "gg"  => :SubtlyScrollTop,
   "G"   => :SubtlyScrollBottom,
   "ZZ"  => :SubtlyQuit,
--- a/subtly/browser.rb	Fri Jan 22 14:38:33 2010 +0100
+++ b/subtly/browser.rb	Fri Jan 22 14:57:49 2010 +0100
@@ -198,6 +198,12 @@
           @webkit.reload(true)
         when :SubtlyBrowerReload then
           @webkit.reload(false)
+        when :SubtlyBrowserZoomIn then
+          @webkit.zoom = 1
+          @info.text   = "Zoom: %d%%" % [ (@webkit.zoom * 100).to_i ]
+        when :SubtlyBrowserZoomOut then
+          @webkit.zoom = -1
+          @info.text   = "Zoom: %d%%" % [ (@webkit.zoom * 100).to_i ]
         when :SubtlyScrollTop
           @scrolled.vadjust = 0.0
           @page.text        = format_page(0)
--- a/subtly/webkit.rb	Fri Jan 22 14:38:33 2010 +0100
+++ b/subtly/webkit.rb	Fri Jan 22 14:57:49 2010 +0100
@@ -68,7 +68,8 @@
     ##
 
     def back(steps = 1)
-      Subtly::Webkit.ffi_go_steps(@widget, steps * -1)
+      steps *= -1 unless(0 > steps)
+      Subtly::Webkit.ffi_go_steps(@widget, steps)
     end
 
     ## forward
@@ -103,6 +104,30 @@
       end
     end
 
+    ## zoom
+    # Set zoom level
+    #
+    # @param [Fixnum, #read] level Level step
+    ##
+
+    def zoom=(level)
+      if(0 < level)
+        Subtly::Webkit.ffi_zoom_in(@widget)
+      else
+        Subtly::Webkit.ffi_zoom_out(@widget)
+      end
+    end
+
+    ## zoom
+    # Get zoom level
+    #
+    # @return [Float] Zoom level
+    ##
+
+    def zoom
+      Subtly::Webkit.ffi_zoom_level(@widget)
+    end
+
     private
 
     ## ffi_new
@@ -175,7 +200,7 @@
     ## ffi_reload_cache
     # Reload view from cache
     #
-    # @param  [Pointer, #read]  web_view  A #WebKitWebView
+    # @param [Pointer, #read]  web_view  A #WebKitWebView
     ##
 
     attach_function(:ffi_reload_cache,
@@ -190,6 +215,35 @@
 
     attach_function(:ffi_reload,
       :webkit_web_view_reload_bypass_cache, [ :pointer ], :void
-    )    
+    )
+
+    ## ffi_zoom_level
+    # Get zoom level
+    #
+    # @param  [Pointer, #read]  web_view  A #WebKitWebView
+
+    attach_function(:ffi_zoom_level,
+      :webkit_web_view_get_zoom_level, [ :pointer ], :float
+    )
+
+    ## ffi_zoom_in
+    # Reload view bypassing cache
+    #
+    # @param  [Pointer, #read]  web_view  A #WebKitWebView
+    ##
+
+    attach_function(:ffi_zoom_in,
+      :webkit_web_view_zoom_in, [ :pointer ], :void
+    )
+
+    ## ffi_zoom_out
+    # Reload view bypassing cache
+    #
+    # @param  [Pointer, #read]  web_view  A #WebKitWebView
+    ##
+
+    attach_function(:ffi_zoom_out,
+      :webkit_web_view_zoom_out, [ :pointer ], :void
+    )
   end # }}}
 end