changeset 43:0d42b4c43eb7

Added #proxy=
author unexist
date Sun, 24 Jan 2010 01:56:15 +0100
parents c6f35cf6c4f6
children 1b63ba3238f3
files subtly/webkit.rb
diffstat 1 files changed, 28 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/subtly/webkit.rb	Sun Jan 24 01:55:42 2010 +0100
+++ b/subtly/webkit.rb	Sun Jan 24 01:56:15 2010 +0100
@@ -10,11 +10,16 @@
 
 require "ffi"
 require "subtly/gtk"
+require "subtly/soup"
 
 module Subtly
   class Webkit < Subtly::Gtk::Widget # {{{
+    # Current uri
     attr_accessor :uri
 
+    # Soup session
+    attr_accessor :session
+
     extend FFI::Library
 
     ffi_lib("libwebkit-1.0")
@@ -26,7 +31,8 @@
     ##
 
     def initialize
-      @widget = Subtly::Webkit.ffi_new
+      @widget  = Subtly::Webkit.ffi_new
+      @session = Subtly::Soup::Session.new(Subtly::Webkit.ffi_get_session)
     end
 
     ## uri
@@ -157,7 +163,7 @@
       Subtly::Webkit.ffi_unmark(@widget)
     end
 
-    # highlight=
+    ## highlight=
     # Enable text highlights
     #
     # @param [Bool, #read]  high  Whether to enable highlight
@@ -167,6 +173,16 @@
       Subtly::Webkit.ffi_highlight(@widget, high)
     end
 
+    ## proxy=
+    # Set proxy
+    #
+    # @param [String, #read]  uri  Uri to proxy
+    ##
+
+    def proxy=(uri)
+      @session.proxy = uri #< Delegate to session
+    end
+
     private
 
     ## ffi_new
@@ -348,5 +364,15 @@
     attach_function(:ffi_highlight,
       :webkit_web_view_set_highlight_text_matches, [ :pointer, :bool ], :void
     )
+
+    ## ffi_highlight
+    # Enable text highlights
+    #
+    # @return [Pointer] A #SoupSession
+    ##
+
+    attach_function(:ffi_get_session,
+      :webkit_get_default_session, [ ], :pointer
+    )
   end # }}}
 end