File: spinner.rb

package info (click to toggle)
ruby-gnome2 2.2.0-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,360 kB
  • ctags: 14,222
  • sloc: ansic: 85,875; ruby: 38,232; sh: 80; xml: 41; makefile: 22
file content (59 lines) | stat: -rw-r--r-- 1,516 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copyright (c) 2013 Ruby-GNOME2 Project Team
# This program is licenced under the same licence as Ruby-GNOME2.
#
=begin
= Spinner

GtkSpinner allows to show that background activity is on-going.
=end
require 'common'

module Demo
  class Spinner < Gtk::Dialog
    def initialize
      super(:title => 'Spinner',
            :parent => nil,
            :flags => nil,
            :buttons => [[:close, :none]])

      signal_connect(:response) {self.destroy}
      signal_connect(:destroy) {self.destroy}

      self.resizable = false
      
      vbox = Gtk::Box.new :vertical, 5

      self.content_area.pack_start vbox, :expand => true, :fill => true, :padding => 0
      vbox.border_width = 5

      # Sensitive
      hbox = Gtk::Box.new :horizontal, 5
      @spinner_sensitive = Gtk::Spinner.new
      hbox.add @spinner_sensitive
      hbox.add Gtk::Entry.new
      vbox.add hbox

      # Disabled
      hbox = Gtk::Box.new :horizontal, 5
      @spinner_insensitive = Gtk::Spinner.new
      hbox.add @spinner_insensitive
      hbox.add Gtk::Entry.new
      vbox.add hbox
      hbox.sensitive = false

      button = Gtk::Button.new :stock_id => :media_play
      button.signal_connect(:clicked) do
        @spinner_sensitive.start
        @spinner_insensitive.start
      end
      vbox.add button

      button = Gtk::Button.new :stock_id => :media_stop
      button.signal_connect(:clicked) do
        @spinner_sensitive.stop
        @spinner_insensitive.stop
      end
      vbox.add button
    end
  end
end