Sha256: 5582e122caaf874564d6ea360773ad4778d0a791137b4a76d3acced59831428d

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

module Gtk3App
module Widget

  class MenuItem < Such::MenuItem
    attr_accessor :key
  end

  class Menu < Such::Menu
    def add_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 add_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

1 entries across 1 versions & 1 rubygems

Version Path
gtk3app-3.0.0 lib/gtk3app/widget/widgets.rb