view subtly/webkit.rb @ 6:c86846c6b2da

Moved lib magic into separated files
author unexist
date Mon, 14 Dec 2009 00:33:30 +0100
parents
children 3754aca8433a
line wrap: on
line source
##
# @package subtly
#
# @file Webkit bindings
# @author Christoph Kappel <unexist@dorfelite.net>
# @version $Id: subtly/webkit.rb,v 6 1260747210.0-3600 unexist $
#
# This program can be distributed under the terms of the GNU GPL.
##

require "ffi"
require "subtly/gtk"

module Subtly
  class Webkit < Subtly::Gtk::Widget # {{{
    attr_accessor :uri

    extend FFI::Library

    ffi_lib("libwebkit-1.0")

    def initialize
      @widget = Subtly::Webkit.ffi_new
    end

    def uri
      Subtly::Webkit.ffi_get_uri(@widget)
    end

    def uri=(uri)
      Subtly::Webkit.ffi_set_uri(@widget, uri)
    end

    def title
      Subtly::Webkit.ffi_get_title(@widget)
    end


    ## ffi_new
    # Create webkit view
    #
    # @return [Pointer] Return the new view
    ##

    attach_function(:ffi_new,
      :webkit_web_view_new, [ ], :pointer
    )

    ## ffi_get_uri
    # Load given uri in view
    #
    # @param  [Pointer, #read]  Webkit view, #GtkWidget
    # @return [String] Uri in webkit view
    ##

    attach_function(:ffi_get_uri,
      :webkit_web_view_get_uri, [ :pointer ], :string
    )

    ## ffi_set_uri
    # Set given uri in view
    #
    # @param  [Pointer, #read]  Webkit view, #GtkWidget
    # @param  [String, #read]   Uri to set
    ##

    attach_function(:ffi_set_uri,
      :webkit_web_view_load_uri, [ :pointer, :string ], :void
    )

    ## ffi_get_title
    # Get title or uri loaded
    #
    # @param  [Pointer, #read]  Webkit view, #GtkWidget
    # @return [String] Title of uri
    ##

    attach_function(:ffi_get_title,
      :webkit_web_view_get_title, [ :pointer ], :string
     )
  end # }}}
end