gtk3 1.2.6 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,50 +15,45 @@ module Demo
15
15
  def initialize
16
16
  super('Clipboard')
17
17
 
18
- unless Gtk.check_version?(2, 2, 0)
19
- add(Gtk::Label.new("This sample requires GTK+ 2.2.0 or later"))
20
- return
21
- end
22
-
23
- vbox = Gtk::VBox.new(false, 0)
18
+ vbox = Gtk::Box.new(:vertical)
24
19
  vbox.border_width = 8
25
20
 
26
21
  add(vbox)
27
22
 
28
23
  label = Gtk::Label.new(%Q["Copy" will copy the text\nin the entry to the clipboard])
29
24
 
30
- vbox.pack_start(label, false, false, 0)
25
+ vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
31
26
 
32
- hbox = Gtk::HBox.new(false, 0)
27
+ hbox = Gtk::Box.new(:horizontal, 0)
33
28
  hbox.border_width = 8
34
- vbox.pack_start(hbox, false, false, 0)
29
+ vbox.pack_start(hbox, :expand => false, :fill => false, :padding => 0)
35
30
 
36
31
  # Create the first entry
37
32
  entry = Gtk::Entry.new
38
- hbox.pack_start(entry, true, true, 0)
33
+ hbox.pack_start(entry, :expand => true, :fill => true, :padding => 0)
39
34
 
40
35
  # Create the button
41
- button = Gtk::Button.new(Gtk::Stock::COPY)
42
- hbox.pack_start(button, false, false, 0)
36
+ button = Gtk::Button.new(:stock_id => :copy)
37
+ hbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
43
38
  button.signal_connect('clicked', entry) do |w, e|
44
39
  clipboard = e.get_clipboard(Gdk::Selection::CLIPBOARD)
45
40
  clipboard.text = e.text
46
41
  end
47
42
 
48
43
  label = Gtk::Label.new(%Q["Paste" will paste the text from the clipboard to the entry])
49
- vbox.pack_start(label, false, false, 0)
44
+ vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
50
45
 
51
- hbox = Gtk::HBox.new(false, 4)
46
+ hbox = Gtk::Box.new(:horizontal, 4)
52
47
  hbox.border_width = 8
53
- vbox.pack_start(hbox, false, false, 0)
48
+ vbox.pack_start(hbox, :expand => false, :fill => false, :padding => 0)
54
49
 
55
50
  # Create the second entry
56
51
  entry = Gtk::Entry.new
57
- hbox.pack_start(entry, true, true, 0)
52
+ hbox.pack_start(entry, :expand => true, :fill => true, :padding => 0)
58
53
 
59
54
  # Create the button
60
- button = Gtk::Button.new(Gtk::Stock::PASTE)
61
- hbox.pack_start(button, false, false, 0)
55
+ button = Gtk::Button.new(:stock_id => :paste)
56
+ hbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
62
57
  button.signal_connect('clicked', entry) do |w, e|
63
58
  clipboard = e.get_clipboard(Gdk::Selection::CLIPBOARD)
64
59
  clipboard.request_text do |board, text, data|
@@ -25,8 +25,8 @@ module Demo
25
25
 
26
26
  ## Create the color swatch area
27
27
  @frame = Gtk::Frame.new
28
- @frame.set_shadow_type(Gtk::SHADOW_IN)
29
- vbox.pack_start(@frame, true, true, 0)
28
+ @frame.set_shadow_type(:in)
29
+ vbox.pack_start(@frame, :expand => true, :fill => true, :padding => 0)
30
30
 
31
31
  @da = Gtk::DrawingArea.new
32
32
 
@@ -53,7 +53,7 @@ module Demo
53
53
  button = Gtk::Button.new('_Change the above color', true)
54
54
  alignment.add(button)
55
55
 
56
- vbox.pack_start(alignment, false, false, 0)
56
+ vbox.pack_start(alignment, :expand => false, :fill => false, :padding => 0)
57
57
 
58
58
  button.signal_connect('clicked') do
59
59
  change_color_callback
@@ -23,7 +23,7 @@ module Demo
23
23
 
24
24
  class BasicWindow < Gtk::Window
25
25
  def initialize(title = nil)
26
- super(Gtk::Window::TOPLEVEL)
26
+ super(:toplevel)
27
27
  if title
28
28
  set_title("#{title} in Ruby/GTK")
29
29
  end
@@ -26,32 +26,32 @@ module Demo
26
26
  frame.add(vbox)
27
27
 
28
28
  # Standard message dialog
29
- hbox = Gtk::HBox.new(false, 0)
30
- vbox.pack_start(hbox, false, false, 0)
29
+ hbox = Gtk::Box.new(:horizontal, 0)
30
+ vbox.pack_start(hbox, :expand => false, :fill => false, :padding => 0)
31
31
  button = Gtk::Button.new('_Message Dialog', true)
32
32
  button.signal_connect('clicked') do
33
33
  message_dialog_clicked
34
34
  end
35
- hbox.pack_start(button, false, false, 0)
35
+ hbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
36
36
 
37
- vbox.pack_start(Gtk::HSeparator.new, false, false, 0)
37
+ vbox.pack_start(Gtk::HSeparator.new, :expand => false, :fill => false, :padding => 0)
38
38
 
39
39
  # Interactive dialog
40
- hbox = Gtk::HBox.new(false, 8)
41
- vbox.pack_start(hbox, false, false, 0)
40
+ hbox = Gtk::Box.new(:horizontal, 8)
41
+ vbox.pack_start(hbox, :expand => false, :fill => false, :padding => 0)
42
42
  vbox2 = Gtk::VBox.new(false, 0)
43
43
 
44
44
  button = Gtk::Button.new('_Interactive Dialog')
45
45
  button.signal_connect('clicked') do
46
46
  interactive_dialog_clicked
47
47
  end
48
- hbox.pack_start(vbox2, false, false, 0)
49
- vbox2.pack_start(button, false, false, 0)
48
+ hbox.pack_start(vbox2, :expand => false, :fill => false, :padding => 0)
49
+ vbox2.pack_start(button, :expand => false, :fill => false, :padding => 0)
50
50
 
51
51
  table = Gtk::Table.new(2, 2, false)
52
52
  table.set_row_spacings(4)
53
53
  table.set_column_spacings(4)
54
- hbox.pack_start(table, false, false, 0)
54
+ hbox.pack_start(table, :expand => false, :fill => false, :padding => 0)
55
55
 
56
56
  label = Gtk::Label.new('_Entry 1', true)
57
57
  table.attach_defaults(label, 0, 1, 0, 1)
@@ -95,17 +95,17 @@ EOS
95
95
  ["_Non-stock Button", Gtk::Dialog::RESPONSE_CANCEL]
96
96
  )
97
97
 
98
- hbox = Gtk::HBox.new(false, 0)
98
+ hbox = Gtk::Box.new(:horizontal, 0)
99
99
  hbox.set_border_width(8)
100
- dialog.vbox.pack_start(hbox, false, false, 0)
100
+ dialog.vbox.pack_start(hbox, :expand => false, :fill => false, :padding => 0)
101
101
 
102
102
  stock = Gtk::Image.new(Gtk::Stock::DIALOG_QUESTION, Gtk::IconSize::DIALOG)
103
- hbox.pack_start(stock, false, false, 0)
103
+ hbox.pack_start(stock, :expand => false, :fill => false, :padding => 0)
104
104
 
105
105
  table = Gtk::Table.new(2, 2, false)
106
106
  table.set_row_spacings(4)
107
107
  table.set_column_spacings(4)
108
- hbox.pack_start(table, true, true, 0)
108
+ hbox.pack_start(table, :expand => true, :fill => true, :padding => 0)
109
109
  label = Gtk::Label.new('_Entry 1', true)
110
110
  table.attach_defaults(label,
111
111
  0, 1, 0, 1)
@@ -37,11 +37,11 @@ module Demo
37
37
  ## Create the checkerboard area
38
38
  label = Gtk::Label.new
39
39
  label.set_markup('<u>Checkerboard pattern</u>')
40
- vbox.pack_start(label, false, false, 0)
40
+ vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
41
41
 
42
42
  frame = Gtk::Frame.new
43
- frame.shadow_type = Gtk::SHADOW_IN
44
- vbox.pack_start(frame, true, true, 0)
43
+ frame.shadow_type = :in
44
+ vbox.pack_start(frame, :expand => true, :fill => true, :padding => 0)
45
45
 
46
46
  da = Gtk::DrawingArea.new
47
47
  # set a minimum size
@@ -56,11 +56,11 @@ module Demo
56
56
  ## Create the scribble area
57
57
  label = Gtk::Label.new
58
58
  label.set_markup('<u>Scribble area</u>')
59
- vbox.pack_start(label, false, false, 0)
59
+ vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
60
60
 
61
61
  frame = Gtk::Frame.new
62
- frame.shadow_type = Gtk::SHADOW_IN
63
- vbox.pack_start(frame, true, true, 0)
62
+ frame.shadow_type = :in
63
+ vbox.pack_start(frame, :expand => true, :fill => true, :padding => 0)
64
64
 
65
65
  da = Gtk::DrawingArea.new
66
66
  # set a minimum size
@@ -24,12 +24,12 @@ module Demo
24
24
  add(vbox)
25
25
 
26
26
  vbox.pack_start(Gtk::Label.new('Shopping list (you can edit the cells!)'),
27
- false, false, 0)
27
+ :expand => false, :fill => false, :padding => 0)
28
28
 
29
29
  sw = Gtk::ScrolledWindow.new
30
30
  sw.shadow_type = Gtk::SHADOW_ETCHED_IN
31
- sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
32
- vbox.pack_start(sw, true, true, 0)
31
+ sw.set_policy(:automatic, :automatic)
32
+ vbox.pack_start(sw, :expand => true, :fill => true, :padding => 0)
33
33
 
34
34
  # create model
35
35
  model = create_model
@@ -44,20 +44,21 @@ module Demo
44
44
  sw.add(treeview)
45
45
 
46
46
  # some buttons
47
- hbox = Gtk::HBox.new(true, 4)
48
- vbox.pack_start(hbox, false, false, 0)
47
+ hbox = Gtk::Box.new(:horizontal, 4)
48
+ hbox.homogeneous = true
49
+ vbox.pack_start(hbox, :expand => false, :fill => false, :padding => 0)
49
50
 
50
51
  button = Gtk::Button.new('Add item')
51
52
  button.signal_connect('clicked') do
52
53
  add_item(model)
53
54
  end
54
- hbox.pack_start(button, true, true, 0)
55
+ hbox.pack_start(button, :expand => true, :fill => true, :padding => 0)
55
56
 
56
57
  button = Gtk::Button.new('Remove item')
57
58
  button.signal_connect('clicked') do
58
59
  remove_item(treeview)
59
60
  end
60
- hbox.pack_start(button, true, true, 0)
61
+ hbox.pack_start(button, :expand => true, :fill => true, :padding => 0)
61
62
 
62
63
  set_default_size(320, 200)
63
64
  end
@@ -25,16 +25,16 @@ module Demo
25
25
  end
26
26
 
27
27
  vbox = Gtk::VBox.new(false, 5)
28
- self.vbox.pack_start(vbox, true, true)
28
+ self.vbox.pack_start(vbox, :expand => true, :fill => true)
29
29
  vbox.border_width = 5
30
30
 
31
31
  label = Gtk::Label.new
32
32
  label.markup = 'Completion demo, try writing <b>total</b> or <b>gnome</b> for example'
33
- vbox.pack_start(label, false, false)
33
+ vbox.pack_start(label, :expand => false, :fill => false)
34
34
 
35
35
  # Create our entry
36
36
  entry = Gtk::Entry.new
37
- vbox.pack_start(entry, false, false)
37
+ vbox.pack_start(entry, :expand => false, :fill => false)
38
38
 
39
39
  # Create the completion object
40
40
  completion = Gtk::EntryCompletion.new
@@ -13,26 +13,28 @@ require 'common'
13
13
  module Demo
14
14
  class Expander < Gtk::Dialog
15
15
  def initialize
16
- super('GtkExpander',
17
- nil, # parent
18
- 0,
19
- [Gtk::Stock::CLOSE, Gtk::Dialog::RESPONSE_NONE])
16
+ # as opposed to the GTK2 dialog, the buttons have to be enclodes by brackeds
17
+ # together with their ResponseType AND all groups have to bracketed together
18
+ super(:title => 'GtkExpander',
19
+ :parent => nil,
20
+ :flags => 0,
21
+ :buttons => [[Gtk::Stock::CLOSE, Gtk::ResponseType::NONE]])
20
22
  self.resizable = false
21
23
 
22
24
  signal_connect('response') do
23
25
  self.destroy
24
26
  end
25
27
 
26
- vbox = Gtk::VBox.new(false, 5)
27
- self.vbox.pack_start(vbox, true, true)
28
+ vbox = Gtk::Box.new(:vertical, 5)
29
+ self.child.pack_start(vbox, :expand => true, :fill => true)
28
30
  vbox.border_width = 5
29
31
 
30
32
  label = Gtk::Label.new('Expander demo. CLick on the triangle for details.')
31
- vbox.pack_start(label, false, false)
33
+ vbox.pack_start(label, :expand => false, :fill => false)
32
34
 
33
35
  # Create the expander
34
36
  expander = Gtk::Expander.new('Details')
35
- vbox.pack_start(expander, false, false)
37
+ vbox.pack_start(expander, :expand => false, :fill => false)
36
38
 
37
39
  expander.add(Gtk::Label.new('Details can be shown or hidden.'))
38
40
  end
@@ -27,7 +27,7 @@ module Demo
27
27
 
28
28
  view = Gtk::TextView.new
29
29
 
30
- view.wrap_mode = Gtk::TextTag::WRAP_WORD
30
+ view.wrap_mode = :word
31
31
 
32
32
  view.signal_connect('key-press-event') do |*args|
33
33
  key_press_event(*args)
@@ -45,8 +45,8 @@ module Demo
45
45
  buffer = view.buffer
46
46
 
47
47
  sw = Gtk::ScrolledWindow.new
48
- sw.set_policy(Gtk::POLICY_AUTOMATIC,
49
- Gtk::POLICY_AUTOMATIC)
48
+ sw.set_policy(:automatic,
49
+ :automatic)
50
50
 
51
51
  add(sw)
52
52
  sw.add(view)
@@ -77,7 +77,7 @@ module Demo
77
77
  puts
78
78
 
79
79
  buffer.text = ''
80
- iter = buffer.get_iter_at_offset(0)
80
+ iter = buffer.get_iter_at(:offset => 0)
81
81
 
82
82
  case page
83
83
  when 1
@@ -9,7 +9,8 @@ The Gtk::IconView widget is used to display and manipulate icons.
9
9
  It uses a Gtk::TreeModel for data storage, so the list store example
10
10
  might be helpful.
11
11
  =end
12
- $KCODE="u"
12
+
13
+
13
14
  require 'common'
14
15
 
15
16
  module Demo
@@ -19,19 +20,19 @@ module Demo
19
20
  def fill_store
20
21
  @store.clear
21
22
  Dir.glob(File.join(@parent, "*")).each do |path|
22
- is_dir = FileTest.directory?(path)
23
- iter = @store.append
23
+ is_dir = FileTest.directory?(path)
24
+ iter = @store.append
24
25
  # set COL_DISPLAY_NAME first because changing an iter will trigger the
25
26
  # sort function; if we set something else first, the value of
26
27
  # COL_DISPLAY_NAME for this row will be "nil" and the sort function will fail
27
- puts path
28
+ #puts path
28
29
  #puts GLib.convert(GLib.filename_to_utf8(path), "Shift_JIS", "UTF-8")
29
30
  #puts File.basename(GLib.convert(GLib.filename_to_utf8(path), "Shift_JIS", "UTF-8"))
30
31
  # iter[COL_DISPLAY_NAME] = File.basename(GLib.filename_to_utf8(path))
31
32
  iter[COL_DISPLAY_NAME] = GLib.filename_to_utf8(path)
32
- iter[COL_PATH] = path
33
- iter[COL_IS_DIR] = is_dir
34
- iter[COL_PIXBUF] = is_dir ? @folder_pixbuf : @file_pixbuf
33
+ iter[COL_PATH] = path
34
+ iter[COL_IS_DIR] = is_dir
35
+ iter[COL_PIXBUF] = is_dir ? @folder_pixbuf : @file_pixbuf
35
36
  end
36
37
  end
37
38
 
@@ -53,53 +54,53 @@ puts path
53
54
  end
54
55
  end
55
56
  @store.set_sort_column_id(Gtk::TreeSortable::DEFAULT_SORT_COLUMN_ID,
56
- Gtk::SORT_ASCENDING)
57
+ Gtk::SortType::ASCENDING)
57
58
 
58
59
  fill_store
59
60
  set_default_size(650, 400)
60
61
  set_border_width(8)
61
62
 
62
- vbox = Gtk::VBox.new(false, 0)
63
+ vbox = Gtk::Box.new(:vertical)
63
64
  add(vbox)
64
65
 
65
66
  toolbar = Gtk::Toolbar.new
66
- vbox.pack_start(toolbar, false, false, 0)
67
+ vbox.pack_start(toolbar, :expand => false, :fill => false, :padding => 0)
67
68
 
68
- up_button = Gtk::ToolButton.new(Gtk::Stock::GO_UP)
69
+ up_button = Gtk::ToolButton.new(:stock_id => :go_up)
69
70
  up_button.important = true
70
71
  up_button.sensitive = false
71
- toolbar.insert(-1, up_button)
72
+ toolbar.insert(up_button, -1)
72
73
  up_button.signal_connect("clicked") do
73
- @parent = File.dirname(@parent)
74
- fill_store
75
- up_button.sensitive = @parent != "/"
74
+ @parent = File.dirname(@parent)
75
+ fill_store
76
+ up_button.sensitive = @parent != "/"
76
77
  end
77
78
 
78
- home_button = Gtk::ToolButton.new(Gtk::Stock::HOME)
79
+ home_button = Gtk::ToolButton.new(:stock_id => :home)
79
80
  home_button.important = true
80
- toolbar.insert(-1, home_button)
81
+ toolbar.insert(home_button, -1)
81
82
  home_button.signal_connect("clicked") do
82
- @parent = GLib.home_dir
83
- fill_store
84
- up_button.sensitive = true
83
+ @parent = GLib.home_dir
84
+ fill_store
85
+ up_button.sensitive = true
85
86
  end
86
87
 
87
88
  sw = Gtk::ScrolledWindow.new
88
- sw.shadow_type = Gtk::SHADOW_ETCHED_IN
89
- sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
90
- vbox.pack_start(sw, true, true, 0)
89
+ sw.shadow_type = :etched_in
90
+ sw.set_policy(:automatic, :automatic)
91
+ vbox.pack_start(sw, :expand => true, :fill => true, :padding => 0)
91
92
 
92
93
  iconview = Gtk::IconView.new(@store)
93
- iconview.selection_mode = Gtk::SELECTION_MULTIPLE
94
+ iconview.selection_mode = :multiple
94
95
  iconview.text_column = COL_DISPLAY_NAME
95
96
  iconview.pixbuf_column = COL_PIXBUF
96
97
  iconview.signal_connect("item_activated") do |iview, path|
97
- iter = @store.get_iter(path)
98
- if iter[COL_DISPLAY_NAME]
99
- @parent = iter[COL_PATH]
100
- fill_store
101
- up_button.sensitive = true
102
- end
98
+ iter = @store.get_iter(path)
99
+ if iter[COL_DISPLAY_NAME]
100
+ @parent = iter[COL_PATH]
101
+ fill_store
102
+ up_button.sensitive = true
103
+ end
103
104
  end
104
105
  sw.add(iconview)
105
106
  iconview.grab_focus
@@ -38,16 +38,16 @@ module Demo
38
38
 
39
39
  label = Gtk::Label.new
40
40
  label.set_markup('<u>Image loaded from a file</u>')
41
- vbox.pack_start(label, false, false, 0)
41
+ vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
42
42
 
43
43
  frame = Gtk::Frame.new
44
- frame.shadow_type = Gtk::SHADOW_IN
44
+ frame.shadow_type = :in
45
45
 
46
46
  # The alignment keeps the frame from growing when users resize
47
47
  # the window
48
48
  align = Gtk::Alignment.new(0.5, 0.5, 0, 0)
49
49
  align.add(frame)
50
- vbox.pack_start(align, false, false, 0)
50
+ vbox.pack_start(align, :expand => false, :fill => false, :padding => 0)
51
51
 
52
52
  # demo_find_file looks in the the current directory first,
53
53
  # so you can run gtk-demo without installing GTK, then looks
@@ -81,16 +81,16 @@ module Demo
81
81
  # Animation
82
82
  label = Gtk::Label.new
83
83
  label.set_markup('<u>Animation loaded from a file</u>')
84
- vbox.pack_start(label, false, false, 0)
84
+ vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
85
85
 
86
86
  frame = Gtk::Frame.new
87
- frame.shadow_type = Gtk::SHADOW_IN
87
+ frame.shadow_type = :in
88
88
 
89
89
  # The alignment keeps the frame from growing when users resize
90
90
  # the window
91
91
  align = Gtk::Alignment.new(0.5, 0.5, 0, 0)
92
92
  align.add(frame)
93
- vbox.pack_start(align, false, false, 0)
93
+ vbox.pack_start(align, :expand => false, :fill => false, :padding => 0)
94
94
 
95
95
  filename = Demo.find_file('floppybuddy.gif')
96
96
  image = Gtk::Image.new(filename)
@@ -100,16 +100,16 @@ module Demo
100
100
  # Progressive
101
101
  label = Gtk::Label.new
102
102
  label.set_markup('<u>Progressive image loading</u>')
103
- vbox.pack_start(label, false, false, 0)
103
+ vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
104
104
 
105
105
  frame = Gtk::Frame.new(nil)
106
- frame.shadow_type = Gtk::SHADOW_IN
106
+ frame.shadow_type = :in
107
107
 
108
108
  # The alignment keeps the frame from growing when users resize
109
109
  # the window
110
110
  align = Gtk::Alignment.new(0.5, 0.5, 0, 0)
111
111
  align.add(frame)
112
- vbox.pack_start(align, false, false, 0)
112
+ vbox.pack_start(align, :expand => false, :fill => false, :padding => 0)
113
113
 
114
114
  # Create an empty image for now; the progressive loader
115
115
  # will create the pixbuf and fill it in.
@@ -120,7 +120,7 @@ module Demo
120
120
 
121
121
  # Sensitivity control
122
122
  button = Gtk::ToggleButton.new('_Insensitive', true)
123
- vbox.pack_start(button, false, false, 0)
123
+ vbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
124
124
 
125
125
  button.signal_connect('toggled') do |widget|
126
126
  vbox.children.each do |widget|