Sha256: 16edbada577c72d873ae114d8d22f130ac28d6c44d3476298cd7b5a87c5b08d3

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

module Gtk3App
module Widget

  class MenuItem < Such::MenuItem
    attr_accessor :key
  end

  class Menu < Such::Menu
    def append_menu_item(key, &block)
      item = MenuItem.new(self, key, &block)
      item.key = key
      item.show
    end
  end

  class AppMenu < Menu
    def initialize(window, *par, &block)
      @block = block
      window.add_events(Gdk::EventMask::BUTTON_PRESS_MASK)
      window.signal_connect('button_press_event') do |w,e|
        if e.button == 3
          self.popup(nil, nil, 3, e.time)
        else
          block.call(w,e,'button_press_event')
        end
      end
      super(*par)
    end

    def append_menu_item(key, &block)
      super(key, &(block || @block))
    end
  end

  class MainWindow < Such::Window
    def self.set_icon(file)
      @@icon = GdkPixbuf::Pixbuf.new(file: file)
    end

    def self.icon
      @@icon
    end

    def initialize(*par, &block)
      super(*par, &block)
      self.set_icon MainWindow.icon
    end

    def minime(x=CONFIG[:SlotsScale])
      self.set_default_size(x,x)
      self.add Gtk::Image.new(pixbuf: MainWindow.icon.scale(x,x)).show
    end
  end

end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gtk3app-2.1.1 lib/gtk3app/widget/widgets.rb
gtk3app-2.1.0 lib/gtk3app/widget/widgets.rb
gtk3app-2.0.2 lib/gtk3app/widget/widgets.rb
gtk3app-2.0.1 lib/gtk3app/widget/widgets.rb
gtk3app-2.0.0 lib/gtk3app/widget/widgets.rb