Sha256: ba09658726e2de79751500a1e9742b7922e39e88e0b889da0dd59806f842bf74

Contents?: true

Size: 981 Bytes

Versions: 3

Compression:

Stored size: 981 Bytes

Contents

# frozen_string_literal: true

Gtk.load_class :FileChooserDialog

module Gtk
  # Add non-introspected function to Gtk::Lib
  module Lib
    attach_function :gtk_file_chooser_dialog_new, [:string,
                                                   :pointer,
                                                   Gtk::FileChooserAction,
                                                   :varargs], :pointer
  end

  # Overrides for GtkFileChooserDialog
  class FileChooserDialog
    def self.new(*args)
      obj = allocate
      obj.send :initialize, *args
      obj
    end

    def initialize(title, parent, action, buttons)
      button_params = buttons.flat_map do |button_text, button_response|
        [:string, button_text, :int, Gtk::ResponseType.to_int(button_response)]
      end
      ptr = Gtk::Lib.gtk_file_chooser_dialog_new(title, parent, action,
                                                 *button_params, :string, nil)
      store_pointer(ptr)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-gtk-0.15.0 lib/gir_ffi-gtk/file_chooser_dialog.rb
gir_ffi-gtk-0.14.1 lib/gir_ffi-gtk/file_chooser_dialog.rb
gir_ffi-gtk-0.14.0 lib/gir_ffi-gtk/file_chooser_dialog.rb