Sha256: 0a6ef567fc70e9a204876ee5265f6ac1742a84fef32ef8d19e319202518bf47c

Contents?: true

Size: 1.05 KB

Versions: 2

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

2 entries across 2 versions & 1 rubygems

Version Path
gir_ffi-gtk-0.12.1 lib/gir_ffi-gtk/tree_path.rb
gir_ffi-gtk-0.12.0 lib/gir_ffi-gtk/tree_path.rb