gtk3 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/ext/gtk3/extconf.rb +1 -1
  3. data/ext/gtk3/rbgtk-color-button.c +7 -1
  4. data/ext/gtk3/rbgtk-dialog.c +26 -6
  5. data/ext/gtk3/rbgtk-image.c +1 -0
  6. data/ext/gtk3/rbgtk-selection-data.c +4 -5
  7. data/ext/gtk3/rbgtk-stack-switcher.c +41 -0
  8. data/ext/gtk3/rbgtk-window.c +8 -0
  9. data/ext/gtk3/rbgtk.c +158 -0
  10. data/ext/gtk3/rbgtk3.h +33 -0
  11. data/ext/gtk3/rbgtk3conversions.h +60 -1
  12. data/ext/gtk3/rbgtk3private.h +1 -1
  13. data/lib/gtk3.rb +1 -0
  14. data/sample/gtk-demo/cairo-arc-negative.rb +1 -1
  15. data/sample/gtk-demo/cairo-arc.rb +1 -1
  16. data/sample/gtk-demo/cairo-clip-image.rb +6 -6
  17. data/sample/gtk-demo/cairo-clip-rectangle.rb +2 -2
  18. data/sample/gtk-demo/cairo-curve-rectangle.rb +2 -2
  19. data/sample/gtk-demo/cairo-curve-to.rb +2 -2
  20. data/sample/gtk-demo/cairo-dash.rb +1 -1
  21. data/sample/gtk-demo/cairo-fill-and-stroke.rb +1 -1
  22. data/sample/gtk-demo/cairo-fill-and-stroke2.rb +2 -2
  23. data/sample/gtk-demo/cairo-gradient.rb +1 -1
  24. data/sample/gtk-demo/cairo-image-pattern.rb +5 -5
  25. data/sample/gtk-demo/cairo-image.rb +4 -4
  26. data/sample/gtk-demo/cairo-line-cap.rb +8 -8
  27. data/sample/gtk-demo/cairo-line-join.rb +3 -3
  28. data/sample/gtk-demo/cairo-long-lines.rb +3 -3
  29. data/sample/gtk-demo/cairo-pattern-fill.rb +11 -11
  30. data/sample/gtk-demo/cairo-self-intersect.rb +2 -2
  31. data/sample/gtk-demo/cairo-text-align-center.rb +4 -4
  32. data/sample/gtk-demo/cairo-text-extents.rb +5 -5
  33. data/sample/gtk-demo/cairo-text.rb +3 -3
  34. data/sample/gtk-demo/common.rb +0 -1
  35. data/sample/gtk-demo/dialog.rb +23 -23
  36. data/sample/gtk-demo/drawingarea.rb +5 -1
  37. data/sample/gtk-demo/editable_cells.rb +28 -28
  38. data/sample/gtk-demo/entry_completion.rb +3 -3
  39. data/sample/gtk-demo/images.rb +75 -75
  40. data/sample/gtk-demo/item_factory.rb +40 -40
  41. data/sample/gtk-demo/list_store.rb +13 -13
  42. data/sample/gtk-demo/menus.rb +34 -34
  43. data/sample/gtk-demo/panes.rb +28 -28
  44. data/sample/gtk-demo/rotated_text.rb +41 -53
  45. data/sample/gtk-demo/sizegroup.rb +17 -17
  46. data/sample/gtk-demo/spinner.rb +1 -1
  47. data/sample/gtk-demo/textview.rb +137 -137
  48. data/sample/gtk-demo/theming.ui +319 -0
  49. data/sample/gtk-demo/theming_style_classes.rb +48 -0
  50. data/sample/gtk-demo/tree_store.rb +127 -127
  51. data/sample/misc/assistant.rb +6 -66
  52. data/sample/misc/bindings.rb +22 -32
  53. data/sample/misc/button.rb +8 -5
  54. data/sample/misc/buttonbox.rb +2 -2
  55. data/sample/misc/checkbutton.rb +4 -1
  56. data/sample/misc/colorselection.rb +7 -10
  57. data/sample/misc/combo_check.rb +34 -26
  58. data/sample/misc/combobox.rb +10 -11
  59. data/sample/misc/cursor.rb +3 -1
  60. data/sample/misc/dialog.rb +12 -12
  61. data/sample/misc/dialog2.rb +13 -16
  62. data/sample/misc/drawing.rb +40 -21
  63. data/sample/misc/statusicon.rb +28 -45
  64. data/sample/misc/threads.rb +16 -18
  65. data/sample/misc/tree_progress.rb +10 -12
  66. data/test/run-test.rb +17 -9
  67. data/test/test_gtk_search_bar.rb +1 -1
  68. data/test/test_gtk_stack_switcher.rb +30 -0
  69. metadata +25 -21
@@ -21,10 +21,10 @@ module Demo
21
21
  Cairo::FONT_SLANT_NORMAL,
22
22
  Cairo::FONT_WEIGHT_BOLD)
23
23
  cr.set_font_size(0.35)
24
-
24
+
25
25
  cr.move_to(0.04, 0.53)
26
26
  cr.show_text("Hello")
27
-
27
+
28
28
  cr.move_to(0.27, 0.65)
29
29
  cr.text_path("void")
30
30
  cr.set_source_rgba(0.5, 0.5, 1)
@@ -32,7 +32,7 @@ module Demo
32
32
  cr.set_source_rgba(0, 0, 0)
33
33
  cr.set_line_width(0.01)
34
34
  cr.stroke
35
-
35
+
36
36
  # draw helping lines
37
37
  cr.set_source_rgba(1,0.2,0.2, 0.6)
38
38
  cr.arc(0.04, 0.53, 0.02, 0, 2 * Math::PI)
@@ -49,7 +49,6 @@ module Demo
49
49
  end
50
50
 
51
51
  class CairoWindow < BasicWindow
52
-
53
52
  def initialize(title=nil)
54
53
  super
55
54
 
@@ -14,23 +14,23 @@ module Demo
14
14
  class Dialog < Demo::BasicWindow
15
15
  def initialize
16
16
  @count = 1
17
-
17
+
18
18
  super('Dialogs')
19
19
  set_border_width(8)
20
-
20
+
21
21
  frame = Gtk::Frame.new('Dialogs')
22
22
  add(frame)
23
-
23
+
24
24
  vbox = Gtk::VBox.new(false, 8)
25
25
  vbox.set_border_width(8)
26
26
  frame.add(vbox)
27
-
27
+
28
28
  # Standard message dialog
29
29
  hbox = Gtk::Box.new(:horizontal, 0)
30
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
- message_dialog_clicked
33
+ message_dialog_clicked
34
34
  end
35
35
  hbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
36
36
 
@@ -43,7 +43,7 @@ module Demo
43
43
 
44
44
  button = Gtk::Button.new('_Interactive Dialog')
45
45
  button.signal_connect('clicked') do
46
- interactive_dialog_clicked
46
+ interactive_dialog_clicked
47
47
  end
48
48
  hbox.pack_start(vbox2, :expand => false, :fill => false, :padding => 0)
49
49
  vbox2.pack_start(button, :expand => false, :fill => false, :padding => 0)
@@ -71,11 +71,11 @@ module Demo
71
71
 
72
72
  def message_dialog_clicked
73
73
  dialog = Gtk::MessageDialog.new(self,
74
- Gtk::Dialog::MODAL |
75
- Gtk::Dialog::DESTROY_WITH_PARENT,
76
- Gtk::MessageDialog::INFO,
77
- Gtk::MessageDialog::BUTTONS_OK,
78
- <<EOS)
74
+ Gtk::Dialog::MODAL |
75
+ Gtk::Dialog::DESTROY_WITH_PARENT,
76
+ Gtk::MessageDialog::INFO,
77
+ Gtk::MessageDialog::BUTTONS_OK,
78
+ <<EOS)
79
79
  This message box has been popped up the following
80
80
  number of times:
81
81
 
@@ -88,12 +88,12 @@ EOS
88
88
 
89
89
  def interactive_dialog_clicked
90
90
  dialog = Gtk::Dialog.new('Interactive Dialog',
91
- self,
92
- Gtk::Dialog::MODAL |
93
- Gtk::Dialog::DESTROY_WITH_PARENT,
94
- [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK],
95
- ["_Non-stock Button", Gtk::Dialog::RESPONSE_CANCEL]
96
- )
91
+ self,
92
+ Gtk::Dialog::MODAL |
93
+ Gtk::Dialog::DESTROY_WITH_PARENT,
94
+ [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK],
95
+ ["_Non-stock Button", Gtk::Dialog::RESPONSE_CANCEL]
96
+ )
97
97
 
98
98
  hbox = Gtk::Box.new(:horizontal, 0)
99
99
  hbox.set_border_width(8)
@@ -108,7 +108,7 @@ EOS
108
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
- 0, 1, 0, 1)
111
+ 0, 1, 0, 1)
112
112
  local_entry1 = Gtk::Entry.new
113
113
  local_entry1.text = @entry1.text
114
114
  table.attach_defaults(local_entry1, 1, 2, 0, 1)
@@ -116,7 +116,7 @@ EOS
116
116
 
117
117
  label = Gtk::Label.new('E_ntry 2', true)
118
118
  table.attach_defaults(label,
119
- 0, 1, 1, 2)
119
+ 0, 1, 1, 2)
120
120
 
121
121
  local_entry2 = Gtk::Entry.new
122
122
  local_entry2.text = @entry2.text
@@ -125,10 +125,10 @@ EOS
125
125
 
126
126
  hbox.show_all
127
127
  response = dialog.run
128
-
129
- if response == Gtk::Dialog::RESPONSE_OK
130
- @entry1.text = local_entry1.text
131
- @entry2.text = local_entry2.text
128
+
129
+ if response == Gtk::Dialog::RESPONSE_OK
130
+ @entry1.text = local_entry1.text
131
+ @entry2.text = local_entry2.text
132
132
  end
133
133
  dialog.destroy
134
134
  end
@@ -93,7 +93,11 @@ module Demo
93
93
 
94
94
  # Create a new surface of the appropriate size to store our scribbles
95
95
  def scribble_configure_event(widget)
96
- @cairo_context = widget.window.create_cairo_context
96
+ allocation = widget.allocation
97
+ surface = widget.window.create_similar_surface(:color,
98
+ allocation.width,
99
+ allocation.height)
100
+ @cairo_context = Cairo::Context.new(surface)
97
101
  @cairo_context.set_source_rgb(1, 1, 1)
98
102
  @cairo_context.paint
99
103
 
@@ -24,7 +24,7 @@ module Demo
24
24
  add(vbox)
25
25
 
26
26
  vbox.pack_start(Gtk::Label.new('Shopping list (you can edit the cells!)'),
27
- :expand => false, :fill => false, :padding => 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
@@ -50,13 +50,13 @@ module Demo
50
50
 
51
51
  button = Gtk::Button.new('Add item')
52
52
  button.signal_connect('clicked') do
53
- add_item(model)
53
+ add_item(model)
54
54
  end
55
55
  hbox.pack_start(button, :expand => true, :fill => true, :padding => 0)
56
56
 
57
57
  button = Gtk::Button.new('Remove item')
58
58
  button.signal_connect('clicked') do
59
- remove_item(treeview)
59
+ remove_item(treeview)
60
60
  end
61
61
  hbox.pack_start(button, :expand => true, :fill => true, :padding => 0)
62
62
 
@@ -74,11 +74,11 @@ module Demo
74
74
 
75
75
  # add items
76
76
  @articles.each do |article|
77
- iter = model.append
77
+ iter = model.append
78
78
 
79
- article.each_with_index do |value, index|
80
- iter.set_value(index, value)
81
- end
79
+ article.each_with_index do |value, index|
80
+ iter.set_value(index, value)
81
+ end
82
82
  end
83
83
  return model
84
84
  end
@@ -106,30 +106,30 @@ module Demo
106
106
  # number column
107
107
  renderer = Gtk::CellRendererText.new
108
108
  renderer.signal_connect('edited') do |*args|
109
- cell_edited(*args.push(model))
109
+ cell_edited(*args.push(model))
110
110
  end
111
111
  treeview.insert_column(-1, 'Number', renderer,
112
- {
113
- :text => COLUMN_NUMBER,
114
- :editable => COLUMN_EDITABLE,
115
- })
112
+ {
113
+ :text => COLUMN_NUMBER,
114
+ :editable => COLUMN_EDITABLE,
115
+ })
116
116
  def renderer.column
117
- COLUMN_NUMBER
117
+ COLUMN_NUMBER
118
118
  end
119
119
 
120
120
  # product column
121
121
  renderer = Gtk::CellRendererText.new
122
122
  renderer.signal_connect('edited') do |*args|
123
- cell_edited(*args.push(model))
123
+ cell_edited(*args.push(model))
124
124
  end
125
125
  def renderer.column
126
- COLUMN_PRODUCT
126
+ COLUMN_PRODUCT
127
127
  end
128
128
  treeview.insert_column(-1, 'Product', renderer,
129
- {
130
- :text => COLUMN_PRODUCT,
131
- :editable => COLUMN_EDITABLE,
132
- })
129
+ {
130
+ :text => COLUMN_PRODUCT,
131
+ :editable => COLUMN_EDITABLE,
132
+ })
133
133
  end
134
134
 
135
135
  def cell_edited(cell, path_string, new_text, model)
@@ -140,13 +140,13 @@ module Demo
140
140
  iter = model.get_iter(path)
141
141
  case column
142
142
  when COLUMN_NUMBER
143
- i = iter.path.indices[0]
144
- @articles[i].number = new_text.to_i
145
- iter.set_value(column, @articles[i].number)
143
+ i = iter.path.indices[0]
144
+ @articles[i].number = new_text.to_i
145
+ iter.set_value(column, @articles[i].number)
146
146
  when COLUMN_PRODUCT
147
- i = iter.path.indices[0]
148
- @articles[i].product = new_text
149
- iter.set_value(column, @articles[i].product)
147
+ i = iter.path.indices[0]
148
+ @articles[i].product = new_text
149
+ iter.set_value(column, @articles[i].product)
150
150
  end
151
151
  end
152
152
 
@@ -156,7 +156,7 @@ module Demo
156
156
 
157
157
  iter = model.append
158
158
  foo.each_with_index do |value, index|
159
- iter.set_value(index, value)
159
+ iter.set_value(index, value)
160
160
  end
161
161
  end
162
162
 
@@ -165,8 +165,8 @@ module Demo
165
165
  selection = treeview.selection
166
166
 
167
167
  if iter = selection.selected
168
- @articles.delete_at(iter.path.indices[0])
169
- model.remove(iter)
168
+ @articles.delete_at(iter.path.indices[0])
169
+ model.remove(iter)
170
170
  end
171
171
  end
172
172
  end
@@ -14,9 +14,9 @@ module Demo
14
14
  class EntryCompletion < Gtk::Dialog
15
15
  def initialize
16
16
  super('GtkEntryCompletion',
17
- nil, # parent
18
- 0,
19
- [Gtk::Stock::CLOSE, Gtk::Dialog::RESPONSE_NONE])
17
+ nil, # parent
18
+ 0,
19
+ [Gtk::Stock::CLOSE, Gtk::Dialog::RESPONSE_NONE])
20
20
 
21
21
  self.resizable = false
22
22
 
@@ -27,9 +27,9 @@ module Demo
27
27
 
28
28
  super('Images')
29
29
  signal_connect('destroy') do
30
- cleanup_callback
30
+ cleanup_callback
31
31
  end
32
-
32
+
33
33
  self.border_width = 8
34
34
 
35
35
  vbox = Gtk::VBox.new(false, 8)
@@ -39,10 +39,10 @@ module Demo
39
39
  label = Gtk::Label.new
40
40
  label.set_markup('<u>Image loaded from a file</u>')
41
41
  vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
42
-
42
+
43
43
  frame = Gtk::Frame.new
44
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)
@@ -54,26 +54,26 @@ module Demo
54
54
  # in the location where the file is installed.
55
55
  pixbuf = nil
56
56
  begin
57
- filename = Demo.find_file('gtk-logo-rgb.gif')
58
- pixbuf = Gdk::Pixbuf.new(filename)
57
+ filename = Demo.find_file('gtk-logo-rgb.gif')
58
+ pixbuf = Gdk::Pixbuf.new(filename)
59
59
  rescue
60
- # This code shows off error handling. You can just use
61
- # Gtk::Image.new instead if you don't want to report
62
- # errors to the user. If the file doesn't load when using
63
- # Gtk::Image.new, a 'missing image' icon will
64
- # be displayed instead.
65
- dialog = Gtk::MessageDialog.new(self,
66
- Gtk::Dialog::DESTROY_WITH_PARENT,
67
- Gtk::MessageDialog::ERROR,
68
- Gtk::MessageDialog::BUTTONS_CLOSE,
69
- "Unable to open image file 'gtk-logo-rgb.gif': #{$1}")
70
-
71
- dialog.signal_connect('response') do |widget, data|
72
- widget.destroy
73
- end
74
- dialog.show
60
+ # This code shows off error handling. You can just use
61
+ # Gtk::Image.new instead if you don't want to report
62
+ # errors to the user. If the file doesn't load when using
63
+ # Gtk::Image.new, a 'missing image' icon will
64
+ # be displayed instead.
65
+ dialog = Gtk::MessageDialog.new(self,
66
+ Gtk::Dialog::DESTROY_WITH_PARENT,
67
+ Gtk::MessageDialog::ERROR,
68
+ Gtk::MessageDialog::BUTTONS_CLOSE,
69
+ "Unable to open image file 'gtk-logo-rgb.gif': #{$1}")
70
+
71
+ dialog.signal_connect('response') do |widget, data|
72
+ widget.destroy
73
+ end
74
+ dialog.show
75
75
  end
76
-
76
+
77
77
  image = Gtk::Image.new(pixbuf)
78
78
  frame.add(image)
79
79
 
@@ -82,10 +82,10 @@ module Demo
82
82
  label = Gtk::Label.new
83
83
  label.set_markup('<u>Animation loaded from a file</u>')
84
84
  vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
85
-
85
+
86
86
  frame = Gtk::Frame.new
87
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)
@@ -95,16 +95,16 @@ module Demo
95
95
  filename = Demo.find_file('floppybuddy.gif')
96
96
  image = Gtk::Image.new(filename)
97
97
  frame.add(image)
98
-
98
+
99
99
 
100
100
  # Progressive
101
101
  label = Gtk::Label.new
102
102
  label.set_markup('<u>Progressive image loading</u>')
103
103
  vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
104
-
104
+
105
105
  frame = Gtk::Frame.new(nil)
106
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)
@@ -123,65 +123,65 @@ module Demo
123
123
  vbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
124
124
 
125
125
  button.signal_connect('toggled') do |widget|
126
- vbox.children.each do |widget|
127
- if widget != button
128
- widget.sensitive = ! button.active?
129
- end
130
- end
126
+ vbox.children.each do |widget|
127
+ if widget != button
128
+ widget.sensitive = ! button.active?
129
+ end
130
+ end
131
131
  end
132
132
  end
133
133
 
134
134
  def start_progressive_loading(image)
135
135
  @load_timeout = Gtk.timeout_add(150) do
136
- progressive_timeout(image)
136
+ progressive_timeout(image)
137
137
  end
138
138
  end
139
139
 
140
140
  def progressive_timeout(image)
141
141
  if @image_stream
142
- buf = @image_stream.read(256)
143
-
144
- @pixbuf_loader.write(buf)
145
-
146
- if @image_stream.eof?
147
- @image_stream.close
148
- @image_stream = nil
149
-
150
- @pixbuf_loader.close
151
- @pixbuf_loader = nil
152
- end
142
+ buf = @image_stream.read(256)
143
+
144
+ @pixbuf_loader.write(buf)
145
+
146
+ if @image_stream.eof?
147
+ @image_stream.close
148
+ @image_stream = nil
149
+
150
+ @pixbuf_loader.close
151
+ @pixbuf_loader = nil
152
+ end
153
153
  else
154
- filename = Demo.find_file('alphatest.png')
155
- @image_stream = File.open(filename, 'rb')
156
-
157
- if @pixbuf_loader != nil
158
- @pixbuf_loader.close
159
- @pixbuf_loader = nil
160
- end
161
-
162
- @pixbuf_loader = Gdk::PixbufLoader.new
163
-
164
- @pixbuf_loader.signal_connect('area_prepared') do |loader|
165
- pixbuf = loader.pixbuf
166
-
167
- # Avoid displaying random memory contents, since the pixbuf
168
- # isn't filled in yet.
169
- pixbuf.fill!(0xaaaaaaff)
170
-
171
- image.pixbuf = pixbuf
172
- end
173
-
174
- @pixbuf_loader.signal_connect('area_updated') do
175
- # We know the pixbuf inside the Gtk::Image has changed, but the image
176
- # itself doesn't know this; so queue a redraw. If we wanted to be
177
- # really efficient, we could use a drawing area or something
178
- # instead of a Gtk::Image, so we could control the exact position of
179
- # the pixbuf on the display, then we could queue a draw for only
180
- # the updated area of the image.
181
- image.queue_draw
182
- end
154
+ filename = Demo.find_file('alphatest.png')
155
+ @image_stream = File.open(filename, 'rb')
156
+
157
+ if @pixbuf_loader != nil
158
+ @pixbuf_loader.close
159
+ @pixbuf_loader = nil
160
+ end
161
+
162
+ @pixbuf_loader = Gdk::PixbufLoader.new
163
+
164
+ @pixbuf_loader.signal_connect('area_prepared') do |loader|
165
+ pixbuf = loader.pixbuf
166
+
167
+ # Avoid displaying random memory contents, since the pixbuf
168
+ # isn't filled in yet.
169
+ pixbuf.fill!(0xaaaaaaff)
170
+
171
+ image.pixbuf = pixbuf
172
+ end
173
+
174
+ @pixbuf_loader.signal_connect('area_updated') do
175
+ # We know the pixbuf inside the Gtk::Image has changed, but the image
176
+ # itself doesn't know this; so queue a redraw. If we wanted to be
177
+ # really efficient, we could use a drawing area or something
178
+ # instead of a Gtk::Image, so we could control the exact position of
179
+ # the pixbuf on the display, then we could queue a draw for only
180
+ # the updated area of the image.
181
+ image.queue_draw
182
+ end
183
183
  end
184
-
184
+
185
185
  # leave timeout installed
186
186
  return true
187
187
  end
@@ -190,7 +190,7 @@ module Demo
190
190
  @pixbuf_loader.close if @pixbuf_loader
191
191
  @pixbuf_loader = nil
192
192
  if @load_timeout != 0
193
- Gtk.timeout_remove(@load_timeout)
193
+ Gtk.timeout_remove(@load_timeout)
194
194
  end
195
195
  end
196
196
  end