|
From: <lu...@us...> - 2003-12-20 06:38:39
|
Update of /cvsroot/neelix/neelix/view
In directory sc8-pr-cvs1:/tmp/cvs-serv27370/view
Modified Files:
fox.rb
Log Message:
"Move Up" works! We may want to find some nicer way of doing the
promote/demote, but this was the only way I could get around the notify call
halfway through the swap (which is a Bad Thing [tm], since one of the
ingredients is just plain deleted if the notification happens too soon).
Index: fox.rb
===================================================================
RCS file: /cvsroot/neelix/neelix/view/fox.rb,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** fox.rb 20 Dec 2003 03:57:44 -0000 1.10
--- fox.rb 20 Dec 2003 06:38:35 -0000 1.11
***************
*** 71,75 ****
frame = FXHorizontalFrame.new(self,LAYOUT_FILL_X, 0,0,0,0, 0,0,0,0)
ingredientFrame = FXVerticalFrame.new(frame, FRAME_NORMAL|LAYOUT_FILL_X, 0,0,0,0, 0,0,0,0)
! @ingredientList = FXList.new(ingredientFrame,5,nil,0,LAYOUT_FILL_X)
frame = FXVerticalFrame.new(frame)
--- 71,75 ----
frame = FXHorizontalFrame.new(self,LAYOUT_FILL_X, 0,0,0,0, 0,0,0,0)
ingredientFrame = FXVerticalFrame.new(frame, FRAME_NORMAL|LAYOUT_FILL_X, 0,0,0,0, 0,0,0,0)
! @ingredientList = FXList.new(ingredientFrame,5,nil,0,LAYOUT_FILL_X|LIST_SINGLESELECT)
frame = FXVerticalFrame.new(frame)
***************
*** 111,114 ****
--- 111,130 ----
end
+ @ingredientList.connect(SEL_SELECTED) do |sender,sel,data|
+ @up.enabled = (data != 0)
+ @delete.enabled = true
+ end
+
+ @up.connect(SEL_COMMAND) do |sender,sel,data|
+ selectedIndices = (0 .. @ingredientList.numItems-1).select do |i|
+ @ingredientList.itemSelected?(i)
+ end
+ if not selectedIndices.empty? then
+ index = selectedIndices.first
+ @recipe.ingredients.promote(@recipe.ingredients[index])
+ @ingredientList.selectItem(index - 1, true)
+ end
+ end
+
@directions.connect(SEL_CHANGED) do |sender,sel,data|
@recipe.directions = @directions.text
***************
*** 129,138 ****
@tottime.text = @recipe.tottime
@yields.text = @recipe.yields
@ingredientList.clearItems
@recipe.ingredients.each do |ingredient|
@ingredientList.appendItem(ingredient.to_s)
end
- @directions.text = @recipe.directions
- @notes.text = @recipe.note
end
--- 145,161 ----
@tottime.text = @recipe.tottime
@yields.text = @recipe.yields
+
+ refreshIngredients
+ @recipe.ingredients.add_observer { refreshIngredients }
+
+ @directions.text = @recipe.directions
+ @notes.text = @recipe.note
+ end
+
+ def refreshIngredients
@ingredientList.clearItems
@recipe.ingredients.each do |ingredient|
@ingredientList.appendItem(ingredient.to_s)
end
end
|