Sha256: 47023eb7814dff658dbd7c55903174763f784af5c3c71336ab9531faa518df37

Contents?: true

Size: 1.37 KB

Versions: 123

Compression:

Stored size: 1.37 KB

Contents

# Copyright (c) 2008-2016 Ruby-GNOME2 Project Team
# This program is licenced under the same licence as Ruby-GNOME2.
#
=begin
= Model Button

GtkModelButton is a button widget that is designed to be used with
a GAction as model. The button will adjust its appearance according
to the kind of action it is connected to.

It is also possible to use GtkModelButton without a GAction. In this
case, you should set the "role" attribute yourself, and connect to the
"clicked" signal as you would for any other button.

A common use of GtkModelButton is to implement menu-like content
in popovers.
=end
class ModelbuttonDemo
  def initialize(main_window)
    builder = Gtk::Builder.new(:resource => "/modelbutton/modelbutton.ui")

    builder.connect_signals do |name|
      if name == "tool_clicked"
        proc do |button|
          button.active = !button.active?
        end
      end
    end
    @window = builder["window1"]
    @window.screen = main_window.screen
    actions = Gio::SimpleActionGroup.new
    actions.add_actions([
      { :name => "color", :parameter_type => "s", :state => "'red'" },
      { :name => "chocolate", :state => "true" },
      { :name => "vanilla", :state => "false" },
      { :name => "sprinkles" }
    ])

    @window.insert_action_group("win", actions)
  end

  def run
    if !@window.visible?
      @window.show_all
    else
      @window.destroy
    end
  end
end

Version data entries

123 entries across 115 versions & 2 rubygems

Version Path
gtk3-4.2.5 sample/gtk-demo/modelbutton.rb
gtk3-4.2.4 sample/gtk-demo/modelbutton.rb
gtk3-4.2.3 sample/gtk-demo/modelbutton.rb
gtk3-4.2.2 sample/gtk-demo/modelbutton.rb
gtk3-4.2.1 sample/gtk-demo/modelbutton.rb
gtk3-4.2.0 sample/gtk-demo/modelbutton.rb
gtk3-4.1.9 sample/gtk-demo/modelbutton.rb
gtk3-4.1.8 sample/gtk-demo/modelbutton.rb
gtk3-4.1.7 sample/gtk-demo/modelbutton.rb
gtk3-4.1.6 sample/gtk-demo/modelbutton.rb
gtk3-4.1.5 sample/gtk-demo/modelbutton.rb
gtk3-4.1.4 sample/gtk-demo/modelbutton.rb
gtk3-4.1.3 sample/gtk-demo/modelbutton.rb
gtk3-4.1.2 sample/gtk-demo/modelbutton.rb
gtk3-4.1.1 sample/gtk-demo/modelbutton.rb
gtk3-4.1.0 sample/gtk-demo/modelbutton.rb
gtk3-4.0.9 sample/gtk-demo/modelbutton.rb
gtk3-4.0.8 sample/gtk-demo/modelbutton.rb
gtk3-4.0.7 sample/gtk-demo/modelbutton.rb
gtk3-4.0.6 sample/gtk-demo/modelbutton.rb