Sha256: 12f890cdd9938038f7058845539f12cebd1ec1706c73272cfc8b0720ff324e85

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

Gtk.load_class :TreePath
module Gtk
  # Add non-introspected function to Gtk::Lib
  module Lib
    if Gtk::MAJOR_VERSION == 2 || Gtk::MAJOR_VERSION == 3 && Gtk::MINOR_VERSION < 12
      attach_function :gtk_tree_path_new_from_indices, [:varargs], :pointer
    end
  end

  # Overrides for GtkTreePath
  class TreePath
    if Gtk::MAJOR_VERSION == 2 || Gtk::MAJOR_VERSION == 3 && Gtk::MINOR_VERSION < 12
      def self.new_from_indices(*args)
        obj = allocate
        obj.send :initialize_from_indices, *args
        obj
      end

      def initialize_from_indices(indices)
        args = indices.flat_map { |index| [:int, index] }
        ptr = Gtk::Lib.gtk_tree_path_new_from_indices(*args, :int, -1)
        store_pointer ptr
      end
    end

    if Gtk::MAJOR_VERSION == 2
      setup_instance_method! "get_indices"
      remove_method :get_indices

      def get_indices
        depth = get_depth
        ptr = Gtk::Lib.gtk_tree_path_get_indices self
        GirFFI::SizedArray.wrap(:gint32, depth, ptr)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-gtk-0.17.0 lib/gir_ffi-gtk/tree_path.rb
gir_ffi-gtk-0.16.0 lib/gir_ffi-gtk/tree_path.rb
gir_ffi-gtk-0.15.1 lib/gir_ffi-gtk/tree_path.rb