changeset 6:c86846c6b2da

Moved lib magic into separated files
author unexist
date Mon, 14 Dec 2009 00:33:30 +0100
parents 37ddd775df8a
children 18b3fbf82cc4
files subtly/gobject.rb subtly/gthread.rb subtly/webkit.rb
diffstat 3 files changed, 154 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/subtly/gobject.rb	Mon Dec 14 00:33:30 2009 +0100
@@ -0,0 +1,43 @@
+##
+# @package subtly
+#
+# @file GObject bindings
+# @author Christoph Kappel <unexist@dorfelite.net>
+# @version $Id$
+#
+# This program can be distributed under the terms of the GNU GPL.
+##
+
+require "ffi"
+
+module Subtly
+  module GObject
+    extend FFI::Library
+
+    ffi_lib("libgobject-2.0")
+
+    # Callback type
+    callback :g_callback2, [ :pointer, :pointer ],                     :void
+    callback :g_callback3, [ :pointer, :pointer, :pointer ],           :void
+    callback :g_callback4, [ :pointer, :pointer, :pointer, :pointer ], :void
+
+    ## ffi_signal_connect
+    # Add signal callback
+    #
+    # @param  [Pointer, #read]  Widget to attach callback
+    # @param  [String,  #read]  Signal name
+    # @param  [Pointer, #read]  Callback function
+    # @param  [Pointer, #read]  Callback data
+    ##
+
+    attach_function(:ffi_signal_connect2,
+      :g_signal_connect_data, [ :pointer, :string, :g_callback2, :pointer, :pointer, :int ], :ulong
+    )
+    attach_function(:ffi_signal_connect3,
+      :g_signal_connect_data, [ :pointer, :string, :g_callback3, :pointer, :pointer, :int ], :ulong
+    )
+    attach_function(:ffi_signal_connect4,
+      :g_signal_connect_data, [ :pointer, :string, :g_callback4, :pointer, :pointer, :int ], :ulong
+    )
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/subtly/gthread.rb	Mon Dec 14 00:33:30 2009 +0100
@@ -0,0 +1,29 @@
+##
+# @package subtly
+#
+# @file GThread bindings
+# @author Christoph Kappel <unexist@dorfelite.net>
+# @version $Id$
+#
+# This program can be distributed under the terms of the GNU GPL.
+##
+
+require "ffi"
+
+module Subtly
+  module GThread
+    extend FFI::Library
+
+    ffi_lib("libgthread-2.0")
+
+    ## ffi_init
+    # Init thread system
+    #
+    # @param  [Pointer, #read]  Just don't use, #GThreadFunctions
+    ##
+
+    attach_function(:ffi_init,
+      :g_thread_init, [ :pointer ], :void
+    )
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/subtly/webkit.rb	Mon Dec 14 00:33:30 2009 +0100
@@ -0,0 +1,82 @@
+##
+# @package subtly
+#
+# @file Webkit bindings
+# @author Christoph Kappel <unexist@dorfelite.net>
+# @version $Id$
+#
+# 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