changeset 11:b9d162d77d00

Added more toplevel classes and added functionality
author unexist
date Mon, 14 Dec 2009 00:35:14 +0100
parents c28e7dc088fd
children 3754aca8433a
files subtly/gtk.rb
diffstat 1 files changed, 515 insertions(+), 456 deletions(-) [+]
line wrap: on
line diff
--- a/subtly/gtk.rb	Mon Dec 14 00:34:53 2009 +0100
+++ b/subtly/gtk.rb	Mon Dec 14 00:35:14 2009 +0100
@@ -9,469 +9,528 @@
 ##
 
 require "ffi"
-require "subtly/glib"
+require "subtly/gthread"
+require "subtly/gobject"
 
 module Subtly
-  class Runner # {{{
-    extend FFI::Library
-
-    ffi_lib("libgtk-x11-2.0")    
-
-    def initialize
-      Subtly::GThread.ffi_init(nil)
-      Subtly::Runner.ffi_init(nil, nil)
-    end
-
-    def run
-      Subtly::Runner.ffi_run
-    end
-
-    ## init
-    # Init Gtk system
-    #
-    # @param  [Pointer, #read]  Parent widget
-    ##
-
-    attach_function(:ffi_init,                   
-      :gtk_init, [ :pointer, :pointer ], :void
-    )
-
-    ## run
-    # Run Gtk main loop
-    ##
-
-    attach_function(:ffi_run,
-      :gtk_main, [ ], :void
-    )
-
-    ## quit
-    # Quit Gtk main loop
-    ##
-
-    attach_function(:ffi_quit,
-      :gtk_main_quit, [ ], :void
-    )
-  end # }}}
-
-  class Widget # {{{
-    attr_accessor :widget
-
-    extend FFI::Library
-
-    ffi_lib("libgtk-x11-2.0")
-
-    # States
-    enum(:state,
-    [
-      :normal, 0,
-      :active,
-      :prelight,
-      :selected,
-      :insensitive
-    ])
-
-    def foreground=(color)
-      col = Subtly::GdkColor.new
-
-      Subtly::Gdk.ffi_parse_color(color, col.pointer)
-      Subtly::Widget.ffi_set_fg(@widget, :normal, col.pointer)
-    end
-
-    def background=(color)
-      col = Subtly::GdkColor.new
-
-      Subtly::Gdk.ffi_parse_color(color, col.pointer)
-      Subtly::Widget.ffi_set_bg(@widget, :normal, col.pointer)      
-    end
-
-    def connect(signal, callback, data)
-      case callback.arity
-        when 2 then
-          Subtly::GObject.ffi_signal_connect2(@widget, signal, callback, data, nil, 0)
-        when 3 then
-          Subtly::GObject.ffi_signal_connect3(@widget, signal, callback, data, nil, 0)
-        when 4 then
-          Subtly::GObject.ffi_signal_connect4(@widget, signal, callback, data, nil, 0)
-      end
-    end
-
-    def alignment(xalign, yalign)
-      Subtly::Widget.ffi_set_alignment(@widget, xalign, yalign)
-    end
-
-    def to_wid
-      @widget
-    end
-    
-    ## ffi_set_fg
-    # Set foreground color of widget
-    #
-    # @param  [Pointer, #read]  Widget to set color
-    # @param  [State,   #read]  Widget state
-    # @param  [Pointer, #read]  Color to set
-    ##
-
-    attach_function(:ffi_set_fg,
-      :gtk_widget_modify_fg, [ :pointer, :state, :pointer ], :void
-    )
-
-    ## ffi_set_fg
-    # Set background color of widget
-    #
-    # @param  [Pointer, #read]  Widget to set color
-    # @param  [State,   #read]  Widget state
-    # @param  [Pointer, #read]  Color to set
-    ##
-
-    attach_function(:ffi_set_bg,
-      :gtk_widget_modify_bg, [ :pointer, :state, :pointer ], :void
-    )
-
-    ## ffi_set_alignment
-    # Set background color of widget
-    #
-    # @param  [Pointer, #read]  Widget to set alignment
-    # @param  [Float,   #read]  X alignment
-    # @param  [Float,   #read]  Y alignment
-    ##
-
-    attach_function(:ffi_set_alignment,
-      :gtk_misc_set_alignment, [ :pointer, :float, :float ], :void
-    )
-  end # }}}
-
-  class Window < Subtly::Widget # {{{
-    extend FFI::Library
-
-    ffi_lib("libgtk-x11-2.0")
-
-    def initialize
-      @widget = Subtly::Window.ffi_new(0)
-    end
-
-    def title=(str)
-      Subtly::Window.ffi_set_title(@widget, str)
-    end
-
-    def klass=(klass)
-      Subtly::Window.ffi_set_klass(@widget, klass[0], klass[1])
-    end
-
-    def size=(array)
-      Subtly::Window.ffi_set_size(@widget, array[0], array[1])
-    end
-
-    def show_all
-      Subtly::Window.ffi_show_all(@widget)
-    end
-
-    def add(widget)
-      Subtly::Window.ffi_add(@widget, widget.to_wid)
-    end
-
-    ## ffi_new
-    # Create window
-    #
-    # @param  [Fixnum, #read]  Window type, #GtkWindowType
-    # @return [Pointer] Return the new widget
-    ##
-   
-    attach_function(:ffi_new,
-      :gtk_window_new, [ :int ], :pointer
-    )
-
-    ## ffi_set_title
-    # Set window title
-    #
-    # @param  [Pointer, #read]  Window to set title
-    # @param  [String,  #read]  Window title
-    ##
-
-    attach_function(:ffi_set_title,
-      :gtk_window_set_title, [:pointer, :string], :void
-    )
-    
-    ## ffi_set_klass
-    # Set window title
-    #
-    # @param  [Pointer, #read]  Window to set class
-    # @param  [String,  #read]  Instance name
-    # @param  [String,  #read]  Class name
-    ##
-
-    attach_function(:ffi_set_klass,
-      :gtk_window_set_wmclass, [:pointer, :string, :string], :void
-    )
-
-    ## ffi_set_size
-    # Set default size of widget
-    #
-    # @param  [Pointer, #read]  Widget to set size
-    # @param  [Fixnum,  #read]  Width of the widget
-    # @param  [Fixnum,  #read]  Height of the widget
-    ##
-
-    attach_function(:ffi_set_size,
-      :gtk_window_set_default_size, [ :pointer, :int, :int ], :void
-    )      
-
-    ## ffi_show_all
-    # Show all child widgets
-    #
-    # @param  [Pointer, #read]  Parent widget
-    ##
-
-    attach_function(:ffi_show_all,
-      :gtk_widget_show_all, [ :pointer ], :void
-    )
-
-    ## ffi_add
-    # Add widget to container
-    #
-    # @param  [Pointer, #read]  Container widget
-    # @param  [Pointer, #read]  Widget to add
-    ##
-
-    attach_function(:ffi_add,
-      :gtk_container_add, [ :pointer, :pointer ], :void
-    )
-  end # }}}
-
-  class Box < Subtly::Widget # {{{
-    extend FFI::Library
-
-    ffi_lib("libgtk-x11-2.0")
+  module Gtk
+    class Runner # {{{
+      extend FFI::Library
 
-    def initialize(type, homogenous, spacing)
-      if(:vbox == type)
-        @widget = Subtly::Box.ffi_vbox_new(homogenous, spacing)
-      else
-        @widget = Subtly::Box.ffi_hbox_new(homogenous, spacing)
-      end
-    end
-
-    def add(widget, expand, fill, padding)
-      Subtly::Box.ffi_add(@widget, widget.to_wid, expand, fill, padding)
-    end
-
-    ## ffi_vbox_new
-    # Create vbox widget
-    #
-    # @param  [Bool,   #read]  Homogeneous or not
-    # @param  [Fixnum, #read]  Default space between children
-    # @return [Pointer] Return the new widget
-    ##
-
-    attach_function(:ffi_vbox_new,
-      :gtk_vbox_new, [ :bool, :int ], :pointer
-    )
-    
-    ## ffi_hbox_new
-    # Create hbox widget
-    #
-    # @param  [Bool,   #read]  Homogeneous or not
-    # @param  [Fixnum, #read]  Default space between children
-    # @return [Pointer] Return the new widget
-    ##
-
-    attach_function(:ffi_hbox_new,
-      :gtk_hbox_new, [ :bool, :int ], :pointer
-    )
-
-    ## ffi_add
-    # Add widget to box
-    #
-    # @param  [Pointer, #read]  Box widget
-    # @param  [Pointer, #read]  Widget to add
-    # @param  [Bool,    #read]  Expand widget
-    # @param  [Bool,    #read]  Fill widget
-    # @param  [Fixnum,  #read]  Padding of children
-    ##
-
-    attach_function(:ffi_add,
-      :gtk_box_pack_start, [:pointer, :pointer, :bool, :bool, :int], :void
-    )      
-  end # }}}
-
-  class Label < Subtly::Widget# {{{
-    def initialize(single, selectable)
-      @widget = Subtly::Label.ffi_new("Subtly")
-
-      Subtly::Label.ffi_single_line(@widget, single)
-      Subtly::Label.ffi_selectable(@widget,  selectable)
-    end
-
-    def text=(str)
-      Subtly::Label.ffi_set_text(@widget, str)
-    end
-
-    def markup=(str)
-      Subtly::Label.ffi_set_markup(@widget, str)
-    end
-
-    ## ffi_new
-    # Create label widget
-    # 
-    # @param  [String, #read]  String to display
-    # @return [Pointer] Return the new widget
-    ##
-
-    attach_function(:ffi_new,
-      :gtk_label_new, [ :string ], :pointer
-    )
-
-    ## ffi_set_text
-    # Set widget label text
-    # @param  [Pointer, #read]  Widget to set text
-    # @param  [String,  #read]  String to set
-    ##
-
-    attach_function(:ffi_set_text,
-      :gtk_label_set_text, [ :pointer, :string ], :void
-    )
-
-    ## ffi_set_markup
-    # Set widget label markup
-    # @param  [Pointer, #read]  Widget to set text
-    # @param  [String,  #read]  String to set
-    ##
-
-    attach_function(:ffi_set_markup,
-      :gtk_label_set_markup, [ :pointer, :string ], :void
-    )
-
-    ## ffi_single_line
-    # Set single line mode
-    # @param  [Pointer, #read]  Widget to set text
-    # @param  [Bool,    #read]  Set single line mode
-    ##
-
-    attach_function(:ffi_single_line,
-      :gtk_label_set_single_line_mode, [ :pointer, :bool ], :void
-    )
-
-    ## ffi_selectable
-    # Set selected
-    # @param  [Pointer, #read]  Widget to set text
-    # @param  [Bool,    #read]  Set selectable
-    ##
+      ffi_lib("libgtk-x11-2.0")    
 
-    attach_function(:ffi_selectable,
-      :gtk_label_set_selectable , [ :pointer, :bool ], :void
-    )
-  end # }}}
-
-  class Entry < Subtly::Widget# {{{
-    def initialize(frame)
-      @widget = Subtly::Entry.ffi_new
-
-      Subtly::Entry.ffi_set_frame(@widget, frame)
-    end
-
-    def text=(str)
-      Subtly::Label.ffi_set_text(@widget, str)
-    end
-
-    ## ffi_new
-    # Create entry widget
-    # 
-    # @return [Pointer] Return the new widget
-    ##
-
-    attach_function(:ffi_new,
-      :gtk_entry_new, [ ], :pointer
-    )
-
-    ## ffi_set_frame
-    # Set widget frame
-    # @param  [Pointer, #read]  Widget to set text
-    # @param  [Bool,  #read]    Set frame
-    ##
-
-    attach_function(:ffi_set_frame,
-      :gtk_entry_set_has_frame, [ :pointer, :bool ], :void
-    )
-
-    ## ffi_set_text
-    # Set widget entry text
-    # @param  [Pointer, #read]  Widget to set text
-    # @param  [String,  #read]  String to set
-    ##
-
-    attach_function(:ffi_set_text,
-      :gtk_entry_set_text, [ :pointer, :string ], :void
-    )
-  end # }}}
-
-  class Scrolled < Subtly::Widget # {{{
-    extend FFI::Library
-
-    ffi_lib("libgtk-x11-2.0")
-
-    def initialize
-      @widget = Subtly::Scrolled.ffi_new(nil, nil)
-    end
+      def initialize
+        Subtly::GThread.ffi_init(nil)
+        Subtly::Gtk::Runner.ffi_init(nil, nil)
+      end
 
-    def add(widget)
-      Subtly::Window.ffi_add(@widget, widget.to_wid)
-    end
-
-    ## ffi_new
-    # Create scrolled window
-    #
-    # @param  [Pointer, #read]  Horizontal adjustment, #GtkAdjustment
-    # @param  [Pointer, #read]  Vertical adjustment, #GtkAdjustment
-    # @return [Pointer] Return the new widget
-    ##
-    
-    attach_function(:ffi_new,
-      :gtk_scrolled_window_new, [ :pointer, :pointer ], :pointer
-    )
-
-    ## ffi_add
-    # Add widget to container
-    #
-    # @param  [Pointer, #read]  Container widget
-    # @param  [Pointer, #read]  Widget to add
-    ##
-
-    attach_function(:ffi_add,
-      :gtk_container_add, [ :pointer, :pointer ], :void
-    )      
-  end # }}}
-
-  class Webkit < Subtly::Widget # {{{
-    extend FFI::Library
+      def run
+        Subtly::Gtk::Runner.ffi_run
+      end
 
-    ffi_lib("libwebkit-1.0")
-
-    def initialize
-      @widget = Subtly::Webkit.ffi_new
-    end
-
-    def uri=(uri)
-      Subtly::Webkit.ffi_load_uri(@widget, uri)
-    end
-
-    ## ffi_new
-    # Create webkit view
-    #
-    # @return [Pointer] Return the new view
-    ##
+      ## init
+      # Init Gtk system
+      #
+      # @param  [Pointer, #read]  Parent widget
+      ##
 
-    attach_function(:ffi_new,
-      :webkit_web_view_new, [ ], :pointer
-    )
+      attach_function(:ffi_init,                   
+        :gtk_init, [ :pointer, :pointer ], :void
+      )
 
-    ## ffi_load_uri
-    # Load given uri in view
-    #
-    # @param  [Pointer, #read]  Webkit view, #GtkWidget
-    # @param  [String, #read]   Uri to load
-    ##
+      ## run
+      # Run Gtk main loop
+      ##
 
-    attach_function(:ffi_load_uri,
-      :webkit_web_view_load_uri, [ :pointer, :string ], :void
-    )
-  end # }}}
+      attach_function(:ffi_run,
+        :gtk_main, [ ], :void
+      )
+
+      ## quit
+      # Quit Gtk main loop
+      ##
+
+      attach_function(:ffi_quit,
+        :gtk_main_quit, [ ], :void
+      )
+    end # }}}
+
+    class Widget # {{{
+      attr_accessor :widget
+
+      extend FFI::Library
+
+      ffi_lib("libgtk-x11-2.0")
+
+      # States
+      enum(:state,
+      [
+        :normal, 0,
+        :active,
+        :prelight,
+        :selected,
+        :insensitive
+      ])
+
+      def foreground=(color)
+        col = Subtly::Gdk::Color.new
+
+        Subtly::Gdk.ffi_parse_color(color, col.pointer)
+        Subtly::Gtk::Widget.ffi_set_fg(@widget, :normal, col.pointer)
+      end
+
+      def background=(color)
+        col = Subtly::Gdk::Color.new
+
+        Subtly::Gdk.ffi_parse_color(color, col.pointer)
+        Subtly::Gtk::Widget.ffi_set_bg(@widget, :normal, col.pointer)      
+      end
+
+      def connect(signal, callback, data)
+        case callback.arity
+          when 2 then
+            Subtly::GObject.ffi_signal_connect2(@widget, signal, callback, data, nil, 0)
+          when 3 then
+            Subtly::GObject.ffi_signal_connect3(@widget, signal, callback, data, nil, 0)
+          when 4 then
+            Subtly::GObject.ffi_signal_connect4(@widget, signal, callback, data, nil, 0)
+        end
+      end
+
+      def alignment(xalign, yalign)
+        Subtly::Gtk::Widget.ffi_set_alignment(@widget, xalign, yalign)
+      end
+
+      def focusable=(value)
+        Subtly::Gtk::Widget.ffi_set_can_focus(@widget, value)
+      end
+
+      def editable=(value)
+        Subtly::Gtk::Widget.ffi_set_can_edit(@widget, value)
+      end
+
+      def to_wid
+        @widget
+      end
+      
+      ## ffi_set_fg
+      # Set foreground color of widget
+      #
+      # @param  [Pointer, #read]  Widget to set color
+      # @param  [State,   #read]  Widget state
+      # @param  [Pointer, #read]  Color to set
+      ##
+
+      attach_function(:ffi_set_fg,
+        :gtk_widget_modify_fg, [ :pointer, :state, :pointer ], :void
+      )
+
+      ## ffi_set_fg
+      # Set background color of widget
+      #
+      # @param  [Pointer, #read]  Widget to set color
+      # @param  [State,   #read]  Widget state
+      # @param  [Pointer, #read]  Color to set
+      ##
+
+      attach_function(:ffi_set_bg,
+        :gtk_widget_modify_bg, [ :pointer, :state, :pointer ], :void
+      )
+
+      ## ffi_set_alignment
+      # Set background color of widget
+      #
+      # @param  [Pointer, #read]  Widget to set alignment
+      # @param  [Float,   #read]  X alignment
+      # @param  [Float,   #read]  Y alignment
+      ##
+
+      attach_function(:ffi_set_alignment,
+        :gtk_misc_set_alignment, [ :pointer, :float, :float ], :void
+      )
+
+      ## ffi_set_can_focus
+      # Get title or uri loaded
+      #
+      # @param  [Pointer, #read]  Webkit view, #GtkWidget
+      # @param  [Book,    #read]  Set focusable
+      ##
+
+      attach_function(:ffi_set_can_focus,
+        :gtk_widget_set_can_focus, [ :pointer, :bool ], :void
+       )
+
+      ## ffi_set_can_edit
+      # Get title or uri loaded
+      #
+      # @param  [Pointer, #read]  Webkit view, #GtkWidget
+      # @param  [Book,    #read]  Set editable
+      ##
+
+      attach_function(:ffi_set_can_edit,
+        :gtk_editable_set_editable, [ :pointer, :bool ], :void
+       )
+    end # }}}
+
+    class Container < Subtly::Gtk::Widget # {{{
+      extend FFI::Library
+
+      ffi_lib("libgtk-x11-2.0")
+
+      def show_all
+        Subtly::Gtk::Container.ffi_show_all(@widget)
+      end
+
+      def add(widget)
+        Subtly::Gtk::Container.ffi_add(@widget, widget.to_wid)
+      end
+
+      ## ffi_show_all
+      # Show all child widgets
+      #
+      # @param  [Pointer, #read]  Parent widget
+      ##
+
+      attach_function(:ffi_show_all,
+        :gtk_widget_show_all, [ :pointer ], :void
+      )
+
+      ## ffi_add
+      # Add widget to container
+      #
+      # @param  [Pointer, #read]  Container widget
+      # @param  [Pointer, #read]  Widget to add
+      ##
+
+      attach_function(:ffi_add,
+        :gtk_container_add, [ :pointer, :pointer ], :void
+      )
+    end # }}}
+
+    class Window < Subtly::Gtk::Container # {{{
+      extend FFI::Library
+
+      ffi_lib("libgtk-x11-2.0")
+
+      def initialize
+        @widget = Subtly::Gtk::Window.ffi_new(0)
+      end
+
+      def title=(str)
+        Subtly::Gtk::Window.ffi_set_title(@widget, str)
+      end
+
+      def klass=(klass)
+        Subtly::Gtk::Window.ffi_set_klass(@widget, klass[0], klass[1])
+      end
+
+      def size=(array)
+        Subtly::Gtk::Window.ffi_set_size(@widget, array[0], array[1])
+      end
+
+      ## ffi_new
+      # Create window
+      #
+      # @param  [Fixnum, #read]  Window type, #GtkWindowType
+      # @return [Pointer] Return the new widget
+      ##
+     
+      attach_function(:ffi_new,
+        :gtk_window_new, [ :int ], :pointer
+      )
+
+      ## ffi_set_title
+      # Set window title
+      #
+      # @param  [Pointer, #read]  Window to set title
+      # @param  [String,  #read]  Window title
+      ##
+
+      attach_function(:ffi_set_title,
+        :gtk_window_set_title, [:pointer, :string], :void
+      )
+      
+      ## ffi_set_klass
+      # Set window title
+      #
+      # @param  [Pointer, #read]  Window to set class
+      # @param  [String,  #read]  Instance name
+      # @param  [String,  #read]  Class name
+      ##
+
+      attach_function(:ffi_set_klass,
+        :gtk_window_set_wmclass, [:pointer, :string, :string], :void
+      )
+
+      ## ffi_set_size
+      # Set default size of widget
+      #
+      # @param  [Pointer, #read]  Widget to set size
+      # @param  [Fixnum,  #read]  Width of the widget
+      # @param  [Fixnum,  #read]  Height of the widget
+      ##
+
+      attach_function(:ffi_set_size,
+        :gtk_window_set_default_size, [ :pointer, :int, :int ], :void
+      )      
+    end # }}}
+
+    class Scrolled < Subtly::Gtk::Container # {{{
+      extend FFI::Library
+
+      ffi_lib("libgtk-x11-2.0")
+
+      def initialize
+        @widget = Subtly::Gtk::Scrolled.ffi_new(nil, nil)
+      end
+
+      def vadjustment
+        vadjustment = Subtly::Gtk::Scrolled.ffi_get_vadjustment(@widget)
+        
+        Subtly::Gtk::Adjustment.new(vadjustment)
+      end
+
+      ## ffi_new
+      # Create scrolled window
+      #
+      # @param  [Pointer, #read]  Horizontal adjustment, #GtkAdjustment
+      # @param  [Pointer, #read]  Vertical adjustment, #GtkAdjustment
+      # @return [Pointer] Return the new widget
+      ##
+      
+      attach_function(:ffi_new,
+        :gtk_scrolled_window_new, [ :pointer, :pointer ], :pointer
+      )
+
+      ## ffi_get_vadjustment
+      # Get vertical adjustment
+      #
+      # @param  [Pointer, #read]  Scrolled widget
+      # @return [Pointer] Return the vertical adjustment, #GtkAdjustment
+      ##
+
+      attach_function(:ffi_get_vadjustment,
+        :gtk_scrolled_window_get_vadjustment, [ :pointer ], :pointer
+      )
+    end # }}}
+
+    class Box < Subtly::Gtk::Widget # {{{
+      extend FFI::Library
+
+      ffi_lib("libgtk-x11-2.0")
+
+      def initialize(type, homogenous, spacing)
+        if(:vbox == type)
+          @widget = Subtly::Gtk::Box.ffi_vbox_new(homogenous, spacing)
+        else
+          @widget = Subtly::Gtk::Box.ffi_hbox_new(homogenous, spacing)
+        end
+      end
+
+      def add(widget, expand, fill, padding)
+        Subtly::Gtk::Box.ffi_add(@widget, widget.to_wid, expand, fill, padding)
+      end
+
+      ## ffi_vbox_new
+      # Create vbox widget
+      #
+      # @param  [Bool,   #read]  Homogeneous or not
+      # @param  [Fixnum, #read]  Default space between children
+      # @return [Pointer] Return the new widget
+      ##
+
+      attach_function(:ffi_vbox_new,
+        :gtk_vbox_new, [ :bool, :int ], :pointer
+      )
+      
+      ## ffi_hbox_new
+      # Create hbox widget
+      #
+      # @param  [Bool,   #read]  Homogeneous or not
+      # @param  [Fixnum, #read]  Default space between children
+      # @return [Pointer] Return the new widget
+      ##
+
+      attach_function(:ffi_hbox_new,
+        :gtk_hbox_new, [ :bool, :int ], :pointer
+      )
+
+      ## ffi_add
+      # Add widget to box
+      #
+      # @param  [Pointer, #read]  Box widget
+      # @param  [Pointer, #read]  Widget to add
+      # @param  [Bool,    #read]  Expand widget
+      # @param  [Bool,    #read]  Fill widget
+      # @param  [Fixnum,  #read]  Padding of children
+      ##
+
+      attach_function(:ffi_add,
+        :gtk_box_pack_start, [:pointer, :pointer, :bool, :bool, :int], :void
+      )      
+    end # }}}
+
+    class Label < Subtly::Gtk::Widget# {{{
+      def initialize(single, selectable)
+        @widget = Subtly::Gtk::Label.ffi_new("Subtly")
+
+        Subtly::Gtk::Label.ffi_single_line(@widget, single)
+        Subtly::Gtk::Label.ffi_selectable(@widget,  selectable)
+      end
+
+      def text=(str)
+        Subtly::Gtk::Label.ffi_set_text(@widget, str)
+      end
+
+      def markup=(str)
+        Subtly::Gtk::Label.ffi_set_markup(@widget, str)
+      end
+
+      ## ffi_new
+      # Create label widget
+      # 
+      # @param  [String, #read]  String to display
+      # @return [Pointer] Return the new widget
+      ##
+
+      attach_function(:ffi_new,
+        :gtk_label_new, [ :string ], :pointer
+      )
+
+      ## ffi_set_text
+      # Set widget label text
+      # @param  [Pointer, #read]  Widget to set text
+      # @param  [String,  #read]  String to set
+      ##
+
+      attach_function(:ffi_set_text,
+        :gtk_label_set_text, [ :pointer, :string ], :void
+      )
+
+      ## ffi_set_markup
+      # Set widget label markup
+      # @param  [Pointer, #read]  Widget to set text
+      # @param  [String,  #read]  String to set
+      ##
+
+      attach_function(:ffi_set_markup,
+        :gtk_label_set_markup, [ :pointer, :string ], :void
+      )
+
+      ## ffi_single_line
+      # Set single line mode
+      # @param  [Pointer, #read]  Widget to set text
+      # @param  [Bool,    #read]  Set single line mode
+      ##
+
+      attach_function(:ffi_single_line,
+        :gtk_label_set_single_line_mode, [ :pointer, :bool ], :void
+      )
+
+      ## ffi_selectable
+      # Set selected
+      # @param  [Pointer, #read]  Widget to set text
+      # @param  [Bool,    #read]  Set selectable
+      ##
+
+      attach_function(:ffi_selectable,
+        :gtk_label_set_selectable , [ :pointer, :bool ], :void
+      )
+    end # }}}
+
+    class Entry < Subtly::Gtk::Widget# {{{
+      def initialize(frame)
+        @widget = Subtly::Gtk::Entry.ffi_new
+
+        Subtly::Gtk::Entry.ffi_set_frame(@widget, frame)
+      end
+
+      def text
+        Subtly::Gtk::Entry.ffi_get_text(@widget)
+      end
+
+      def text=(str)
+        Subtly::Gtk::Entry.ffi_set_text(@widget, str)
+      end
+
+      def empty?
+        0 < Subtly::Gtk::Entry.ffi_get_length(@widget) ? false : true
+      end
+
+      def <<(str)
+        Subtly::Gtk::Entry.ffi_append_text(@widget, str)
+      end
+
+      ## ffi_new
+      # Create entry widget
+      # 
+      # @return [Pointer] Return the new widget
+      ##
+
+      attach_function(:ffi_new,
+        :gtk_entry_new, [ ], :pointer
+      )
+
+      ## ffi_set_frame
+      # Set widget frame
+      # @param  [Pointer, #read]  Widget to set text
+      # @param  [Bool,  #read]    Set frame
+      ##
+
+      attach_function(:ffi_set_frame,
+        :gtk_entry_set_has_frame, [ :pointer, :bool ], :void
+      )
+
+      ## ffi_get_text
+      # Set widget entry text
+      # @param  [Pointer, #read]  Widget to get text
+      # @return [String] Entry text
+      ##
+
+      attach_function(:ffi_get_text,
+        :gtk_entry_get_text, [ :pointer ], :string
+      )
+
+      ## ffi_set_text
+      # Set widget entry text
+      # @param  [Pointer, #read]  Widget to set text
+      # @param  [String,  #read]  String to set
+      ##
+
+      attach_function(:ffi_set_text,
+        :gtk_entry_set_text, [ :pointer, :string ], :void
+      )
+
+      ## ffi_get_length
+      # Get entry text length
+      # @param  [Pointer, #read]  Widget to get length
+      # @return [Uin16] Length of text
+      ##
+
+      attach_function(:ffi_get_length,
+        :gtk_entry_get_text_length, [ :pointer ], :uint16
+      )
+
+      ## ffi_append_text
+      # Append text to entry
+      # @param  [Pointer, #read]  Widget to get length
+      # @param  [String, #read]   Text to append
+      ##
+
+      attach_function(:ffi_append_text,
+        :gtk_entry_append_text, [ :pointer, :string ], :void
+      )
+    end # }}}
+
+    class Adjustment < FFI::Struct # {{{
+      layout(
+        :parent_instance, :pointer,
+        :lower,           :double,
+        :upper,           :double,
+        :step_increment,  :double,
+        :page_increment,  :double,
+        :page_size,       :double
+      )
+    end # }}}
+  end
 end