green_shoes 0.176.0 → 0.179.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.176.0
1
+ 0.179.0
data/lib/shoes/app.rb CHANGED
@@ -159,61 +159,68 @@ class Shoes
159
159
  Gtk::Image.new(name).size_request
160
160
  end
161
161
 
162
- def button name, args={}, &blk
162
+ def button name, args={}
163
163
  args = basic_attributes args
164
164
  b = Gtk::Button.new name
165
165
  b.set_size_request args[:width], args[:height] if args[:width] > 0 and args[:height] > 0
166
- b.signal_connect "clicked", &blk if blk
166
+ b.signal_connect "clicked" do
167
+ yield @_b
168
+ end if block_given?
167
169
  @canvas.put b, args[:left], args[:top]
168
170
  b.show_now
169
171
  args[:real], args[:text], args[:app] = b, name, self
170
- Button.new args
172
+ @_b = Button.new args
171
173
  end
172
174
 
173
- def check args={}, &blk
175
+ def check args={}
174
176
  args = basic_attributes args
175
177
  cb = Gtk::CheckButton.new
176
178
  cb.active = true if args[:checked]
177
- cb.signal_connect "clicked", &blk if blk
179
+ cb.signal_connect "clicked" do
180
+ yield @_cb
181
+ end if block_given?
178
182
  @canvas.put cb, args[:left], args[:top]
179
183
  cb.show_now
180
184
  args[:real], args[:app] = cb, self
181
- Check.new args
185
+ @_cb = Check.new args
182
186
  end
183
187
 
184
- def radio *attrs, &blk
188
+ def radio *attrs
185
189
  args = attrs.last.class == Hash ? attrs.pop : {}
186
190
  group = attrs.first unless attrs.empty?
187
191
  group = group ? (@radio_groups[group] ||= Gtk::RadioButton.new) : cslot.radio_group
188
192
  args = basic_attributes args
189
193
  rb = Gtk::RadioButton.new group
190
194
  rb.active = true if args[:checked]
191
- rb.signal_connect "clicked", &blk if blk
195
+ rb.signal_connect "clicked" do
196
+ yield @_rb
197
+ end if block_given?
192
198
  @canvas.put rb, args[:left], args[:top]
193
199
  rb.show_now
194
200
  args[:real], args[:app] = rb, self
195
- Radio.new args
201
+ @_rb = Radio.new args
196
202
  end
197
203
 
198
204
  def edit_line args={}
199
205
  args = basic_attributes args
200
206
  args[:width] = 200 if args[:width].zero?
207
+ args[:height] = 28 if args[:height].zero?
201
208
  el = Gtk::Entry.new
202
209
  el.text = args[:text].to_s
203
- el.width_chars = args[:width] / 6
210
+ el.set_size_request args[:width], args[:height]
204
211
  el.signal_connect "changed" do
205
- yield el
212
+ yield @_el
206
213
  end if block_given?
207
214
  @canvas.put el, args[:left], args[:top]
208
215
  el.show_now
209
216
  args[:real], args[:app] = el, self
210
- EditLine.new args
217
+ @_el = EditLine.new args
211
218
  end
212
219
 
213
220
  def edit_box args={}
214
221
  args = basic_attributes args
215
222
  args[:width] = 200 if args[:width].zero?
216
- args[:height] = 200 if args[:height].zero?
223
+ args[:height] = 108 if args[:height].zero?
217
224
  tv = Gtk::TextView.new
218
225
  tv.wrap_mode = Gtk::TextTag::WRAP_WORD
219
226
  tv.buffer.text = args[:text].to_s
@@ -225,29 +232,31 @@ class Shoes
225
232
  eb.add tv
226
233
 
227
234
  tv.buffer.signal_connect "changed" do
228
- yield tv.buffer
235
+ yield @_eb
229
236
  end if block_given?
230
237
 
231
238
  @canvas.put eb, args[:left], args[:top]
232
239
  eb.show_now
233
240
  args[:real], args[:app], args[:textview] = eb, self, tv
234
- EditBox.new args
241
+ @_eb = EditBox.new args
235
242
  end
236
243
 
237
- def list_box args={}, &blk
244
+ def list_box args={}
238
245
  args = basic_attributes args
239
246
  args[:width] = 200 if args[:width].zero?
247
+ args[:height] = 28 if args[:height].zero?
240
248
  cb = Gtk::ComboBox.new
241
249
  args[:items] ||= []
242
250
  args[:items].each{|item| cb.append_text item.to_s}
251
+ cb.set_size_request args[:width], args[:height]
243
252
  cb.active = args[:items].index(args[:choose]) if args[:choose]
244
253
  cb.signal_connect("changed") do
245
- blk.call args[:items][cb.active]
246
- end if blk
254
+ yield @_lb
255
+ end if block_given?
247
256
  @canvas.put cb, args[:left], args[:top]
248
257
  cb.show_now
249
258
  args[:real], args[:app] = cb, self
250
- ListBox.new args
259
+ @_lb = ListBox.new args
251
260
  end
252
261
 
253
262
  def animate n=10, repaint=true, &blk
@@ -650,5 +659,11 @@ class Shoes
650
659
  def flush
651
660
  Shoes.call_back_procs self
652
661
  end
662
+
663
+ [:append, :prepend, :after, :before].each do |m|
664
+ define_method m do |*args, &blk|
665
+ top_slot.send m, *args, &blk
666
+ end
667
+ end
653
668
  end
654
669
  end
data/lib/shoes/basic.rb CHANGED
@@ -81,6 +81,7 @@ class Shoes
81
81
  when Button, EditLine, EditBox, ListBox
82
82
  @app.cslot.contents.delete self
83
83
  remove
84
+ @real = nil
84
85
  else @real.clear
85
86
  end
86
87
  end
@@ -125,22 +126,6 @@ class Shoes
125
126
  end
126
127
 
127
128
  class Image < Basic; end
128
- class Button < Basic
129
- def click &blk
130
- real.signal_connect "clicked", &blk if blk
131
- end
132
- end
133
- class ToggleButton < Button
134
- def checked?
135
- real.active?
136
- end
137
-
138
- def checked=(tof)
139
- real.active = tof
140
- end
141
- end
142
- class Check < ToggleButton; end
143
- class Radio < ToggleButton; end
144
129
 
145
130
  class Pattern < Basic
146
131
  def move2 x, y
@@ -202,7 +187,29 @@ class Shoes
202
187
  class Para < TextBlock; end
203
188
  class Inscription < TextBlock; end
204
189
 
205
- class EditLine < Basic
190
+ class Native < Basic
191
+ def change obj, &blk
192
+ obj.signal_connect "changed", &proc{parent.append{blk[self]}} if blk
193
+ end
194
+ end
195
+ class Button < Native
196
+ def click &blk
197
+ real.signal_connect "clicked", &proc{parent.append{blk[self]}} if blk
198
+ end
199
+ end
200
+ class ToggleButton < Button
201
+ def checked?
202
+ real.active?
203
+ end
204
+
205
+ def checked=(tof)
206
+ real.active = tof
207
+ end
208
+ end
209
+ class Check < ToggleButton; end
210
+ class Radio < ToggleButton; end
211
+
212
+ class EditLine < Native
206
213
  def text
207
214
  @real.text
208
215
  end
@@ -215,9 +222,13 @@ class Shoes
215
222
  @app.canvas.move @real, x, y
216
223
  move3 x, y
217
224
  end
225
+
226
+ def change &blk
227
+ super @real, &blk
228
+ end
218
229
  end
219
230
 
220
- class EditBox < Basic
231
+ class EditBox < Native
221
232
  def text
222
233
  @textview.buffer.text
223
234
  end
@@ -230,15 +241,32 @@ class Shoes
230
241
  @app.canvas.move @real, x, y
231
242
  move3 x, y
232
243
  end
244
+
245
+ def change &blk
246
+ super @textview.buffer, &blk
247
+ end
233
248
  end
234
249
 
235
- class ListBox < Basic
250
+ class ListBox < Native
236
251
  def text
237
252
  @items[@real.active]
238
253
  end
254
+
255
+ def choose item
256
+ @real.active = @items.index item
257
+ end
258
+
259
+ def change &blk
260
+ super @real, &blk
261
+ end
262
+
263
+ def items= items
264
+ @items = items
265
+ items.each{|item| real.append_text item.to_s}
266
+ end
239
267
  end
240
268
 
241
- class Progress < Basic
269
+ class Progress < Native
242
270
  def fraction
243
271
  real.fraction
244
272
  end
data/lib/shoes/slot.rb CHANGED
@@ -67,6 +67,7 @@ class Shoes
67
67
 
68
68
  def clear &blk
69
69
  @contents.each &:clear
70
+ contents.each{|e| @app.mlcs.delete e}
70
71
  if blk
71
72
  args = {}
72
73
  initials.keys.each{|k| args[k] = instance_variable_get "@#{k}"}
data/lib/shoes/style.rb CHANGED
@@ -71,11 +71,9 @@ class Shoes
71
71
  args[:width] ||= @width
72
72
  args[:height] ||= @height
73
73
  case self
74
- when Button, EditBox, ListBox
74
+ when Button, EditBox, EditLine, ListBox
75
75
  real.set_size_request args[:width], args[:height]
76
76
  @height = args[:height]
77
- when EditLine
78
- real.width_chars = args[:width] / 6
79
77
  when Progress
80
78
  real.text = ' ' * (args[:width] / 4 - 2)
81
79
  else
data/samples/sample29.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  require '../lib/green_shoes'
2
2
 
3
3
  Shoes.app do
4
- lb = list_box items: COLORS.keys.map(&:to_s), choose: 'red' do |item|
5
- @o.style fill: eval(item)
6
- @p.text = item
4
+ lb = list_box items: COLORS.keys.map(&:to_s), choose: 'red' do |s|
5
+ @o.style fill: eval(s.text)
6
+ @p.text = s.text
7
7
  end.move(300, 0)
8
8
  @p = para
9
9
  nostroke
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/static/manual-en.txt CHANGED
@@ -2904,16 +2904,16 @@ To paint a black background across the top fifty pixels of the window:
2904
2904
  {{{
2905
2905
  #!ruby
2906
2906
  Shoes.app do
2907
- background black, :height => 50
2907
+ background black, height: 50
2908
2908
  end
2909
2909
  }}}
2910
2910
 
2911
- Or, to paint a fifty pixel column on the right-side of the window:
2911
+ Or, to paint a fifty pixel column on the left-side of the window:
2912
2912
 
2913
2913
  {{{
2914
2914
  #!ruby
2915
2915
  Shoes.app do
2916
- background black, :width => 50, :right => 50
2916
+ background black, width: 50
2917
2917
  end
2918
2918
  }}}
2919
2919
 
@@ -2926,6 +2926,8 @@ Yanks out the color, gradient or image used to paint this background and places
2926
2926
  it in a normal Shoes::Pattern object. You can then pass that object to other
2927
2927
  backgrounds and borders. Reuse it as you like.
2928
2928
 
2929
+ '''Note:''' Green Shoes doesn't support `to_pattern` method.
2930
+
2929
2931
  == Border ==
2930
2932
 
2931
2933
  A border is a color, gradient or image painted in a line around the edge of any
@@ -2946,9 +2948,9 @@ Here is just such a slot:
2946
2948
  {{{
2947
2949
  #!ruby
2948
2950
  Shoes.app do
2949
- stack :width => 50 do
2950
- border black, :strokewidth => 5
2951
- para "=^.^=", :stroke => green
2951
+ stack width: 50 do
2952
+ border black, strokewidth: 5
2953
+ para fg "=^.^=", green
2952
2954
  end
2953
2955
  end
2954
2956
  }}}
@@ -2959,17 +2961,17 @@ that slot in another slot. Then, place the border in the outside slot.
2959
2961
  {{{
2960
2962
  #!ruby
2961
2963
  Shoes.app do
2962
- stack :width => 60 do
2963
- border black, :strokewidth => 5
2964
- stack :width => 50 do
2965
- para "=^.^=", :stroke => green
2964
+ stack width: 60 do
2965
+ border black, strokewidth: 5
2966
+ stack width: 50 do
2967
+ para fg "=^.^=", green
2966
2968
  end
2967
2969
  end
2968
2970
  end
2969
2971
  }}}
2970
2972
 
2971
2973
  In HTML and many other languages, the border is painted on the outside of the
2972
- box, thus increasing the overall width of the box. Shoes was designed with
2974
+ box, thus increasing the overall width of the box. Green Shoes was designed with
2973
2975
  consistency in mind, so that if you say that a box is fifty pixels wide, it
2974
2976
  stays fifty pixels wide regardless of its borders or margins or anything else.
2975
2977
 
@@ -2981,6 +2983,8 @@ Creates a basic pattern object based on the color, gradient or image used to
2981
2983
  paint this border. The pattern may then be re-used in new borders and
2982
2984
  backgrounds.
2983
2985
 
2986
+ '''Note:''' Green Shoes doesn't support `to_pattern` method.
2987
+
2984
2988
  == Button ==
2985
2989
 
2986
2990
  Buttons are, you know, push buttons. You click them and they do something.
@@ -3000,7 +3004,6 @@ order to get them to work, you've got to hook up a block to each button.
3000
3004
 
3001
3005
  {{{
3002
3006
  #!ruby
3003
- # Not yet available
3004
3007
  Shoes.app do
3005
3008
  button "OK!" do
3006
3009
  append { para "Well okay then." }
@@ -3033,7 +3036,7 @@ difference: rather than attaching the block directly to the button, the block
3033
3036
  is attached later, through the `click` method.
3034
3037
 
3035
3038
  The second change isn't related to buttons at all. The `append` block was
3036
- dropped since Shoes allows you to add new elements directly to the slot. So we
3039
+ dropped since Green Shoes allows you to add new elements directly to the slot. So we
3037
3040
  can just call `para` directly. (This isn't the case with the `prepend`,
3038
3041
  `before` or `after` methods.)
3039
3042
 
@@ -3050,6 +3053,8 @@ When a button is clicked, its `click` block is called. The block is handed
3050
3053
  Moves focus to the button. The button will be highlighted and, if the user
3051
3054
  hits Enter, the button will be clicked.
3052
3055
 
3056
+ '''Note:''' Green Shoes doesn't support `focus` method.
3057
+
3053
3058
  == Check ==
3054
3059
 
3055
3060
  Check boxes are clickable square boxes than can be either checked or unchecked.
@@ -3122,6 +3127,8 @@ Clicks are sent for both checking and unchecking the box.
3122
3127
  Moves focus to the check. The check will be highlighted and, if the user hits
3123
3128
  Enter, the check will be toggled between its checked and unchecked states.
3124
3129
 
3130
+ '''Note:''' Green Shoes doesn't support `focus` method.
3131
+
3125
3132
  == EditBox ==
3126
3133
 
3127
3134
  Edit boxes are wide, rectangular boxes for entering text. On the web, they
@@ -3135,7 +3142,7 @@ can also use `:width` and `:height` styles to set specific sizes.
3135
3142
  #!ruby
3136
3143
  Shoes.app do
3137
3144
  edit_box
3138
- edit_box :width => 100, :height => 100
3145
+ edit_box width: 100, height: 100
3139
3146
  end
3140
3147
  }}}
3141
3148
 
@@ -3147,7 +3154,7 @@ every time someone types into or deletes from the box.
3147
3154
  #!ruby
3148
3155
  Shoes.app do
3149
3156
  edit_box do |e|
3150
- @counter.text = "#{e.text.size} characters"
3157
+ @counter.text = strong("#{e.text.size}") + " characters"
3151
3158
  end
3152
3159
  @counter = para strong("0"), " characters"
3153
3160
  end
@@ -3170,6 +3177,8 @@ has changed.
3170
3177
  Moves focus to the edit box. The edit box will be highlighted and the user will
3171
3178
  be able to type into the edit box.
3172
3179
 
3180
+ '''Note:''' Green Shoes doesn't support `focus` method.
3181
+
3173
3182
  === text() » self ===
3174
3183
 
3175
3184
  Return a string of characters which have been typed into the box.
@@ -3192,14 +3201,14 @@ height may vary on some platforms.
3192
3201
  Shoes.app do
3193
3202
  stack do
3194
3203
  edit_line
3195
- edit_line :width => 400
3204
+ edit_line width: 400
3196
3205
  end
3197
3206
  end
3198
3207
  }}}
3199
3208
 
3200
3209
  You can change the size by styling both the `:width` and the `:height`.
3201
3210
  However, you generally only want to style the `:width`, as the height will be
3202
- sized to fit the font. (And, in current versions of Shoes, the font for edit
3211
+ sized to fit the font. (And, in current versions of Green Shoes, the font for edit
3203
3212
  lines and edit boxes cannot be altered anyway.)
3204
3213
 
3205
3214
  If a block is given to an edit line, it receives `change` events. Check out the
@@ -3218,6 +3227,8 @@ has changed.
3218
3227
  Moves focus to the edit line. The edit line will be highlighted and the user
3219
3228
  will be able to type into the edit line.
3220
3229
 
3230
+ '''Note:''' Green Shoes doesn't support `focus` method.
3231
+
3221
3232
  === text() » self ===
3222
3233
 
3223
3234
  Return a string of characters which have been typed into the box.
@@ -3300,7 +3311,7 @@ passed into the `:items` style.
3300
3311
  #!ruby
3301
3312
  Shoes.app do
3302
3313
  para "Choose a fruit:"
3303
- list_box :items => ["Grapes", "Pears", "Apricots"]
3314
+ list_box items: ["Grapes", "Pears", "Apricots"]
3304
3315
  end
3305
3316
  }}}
3306
3317
 
@@ -3311,9 +3322,9 @@ You can adjust this length using the `:width` style.
3311
3322
  #!ruby
3312
3323
  Shoes.app do
3313
3324
  para "Choose a fruit:"
3314
- list_box :items => ["Grapes", "Pears", "Apricots"],
3315
- :width => 120, :choose => "Apricots" do |list|
3316
- @fruit.text = list
3325
+ list_box items: ["Grapes", "Pears", "Apricots"],
3326
+ width: 120, choose: "Apricots" do |list|
3327
+ @fruit.text = list.text
3317
3328
  end
3318
3329
 
3319
3330
  @fruit = para "No fruit selected"
@@ -3347,6 +3358,8 @@ Selects the option in the list box that matches the string given by `item`.
3347
3358
  Moves focus to the list box. The list box will be highlighted and, if the user
3348
3359
  hits the up and down arrow keys, other options in the list will be selected.
3349
3360
 
3361
+ '''Note:''' Green Shoes doesn't support `focus` method.
3362
+
3350
3363
  === items() » an array of strings ===
3351
3364
 
3352
3365
  Returns the complete list of strings that the list box presently shows as its options.
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 176
7
+ - 179
8
8
  - 0
9
- version: 0.176.0
9
+ version: 0.179.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - ashbb
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-03 00:00:00 +09:00
17
+ date: 2011-03-05 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency