HScale stops changing when running code in on_change_value

Hello

While trying to write a test application for the pixels= method I
found that when doing too much work in on_change_value the value stops
changing.

The update method is called from the on_change_value. When everything
in that method is commented out it is possible to change the scale
value but since the update method is where this value is used it makes
the application somewhat pointless.

Any ideas how to do a “preview” that updates along with the changing
value as the user drags the scale?

Thanks

Michal

Anybody has advice on this issue?

I simplified the application so that it has only two hscales and a
toggle which breaks sliding of the scales. It is written in ruby +
gtk2 + glade.

Thanks

Michal

Le mardi 22 septembre 2009 à 15:49 +0200, Michal S. a écrit :

Anybody has advice on this issue?

I simplified the application so that it has only two hscales and a
toggle which breaks sliding of the scales. It is written in ruby +
gtk2 + glade.

Why do you call glade[‘update’].queue_draw ?

2009/9/22 Pascal T. [email protected]:

Le mardi 22 septembre 2009 à 15:49 +0200, Michal S. a écrit :

Anybody has advice on this issue?

I simplified the application so that it has only two hscales and a
toggle which breaks sliding of the scales. It is written in ruby +
gtk2 + glade.

Why do you call glade[‘update’].queue_draw ?

Because in my original application I changed the pixes of an image and
it won’t update unless I tell it to (or hide the window and show it
again or something like that).

Calling queue_draw on anything seems to break ruby-gtk2 so I do not
need to ship a picture with the sample code.

Thanks

Michal

Michal S. wrote:

Anybody has advice on this issue?

I simplified the application so that it has only two hscales and a
toggle which breaks sliding of the scales. It is written in ruby +
gtk2 + glade.

Thanks

Michal

I tried your example, but I don’t see what’s wrong.

Is it supposed to demonstrate the problem ?

Simon

2009/9/23 Simon A. [email protected]:

I tried your example, but I don’t see what’s wrong.

Is it supposed to demonstrate the problem ?

Yes, when you check the update checkbox the hscales are no longer
movable.

Perhaps I should have make it checked it to start with.

Thanks

Michal

Michal S. wrote:

2009/9/23 Simon A. [email protected]:

I tried your example, but I don’t see what’s wrong.

Is it supposed to demonstrate the problem ?

Yes, when you check the update checkbox the hscales are no longer
movable.

Perhaps I should have make it checked it to start with.

I think ‘on_xxxx_change_value’ should return false/nil if you want the
scale to update, or true otherwise.

change ‘update min, max’ to :

def update min,max
if @update then
STDERR.puts “returning false, scale will move”
return false
else
STDERR.puts “returning true, scale will NOT move”
return true
end
end

Since ruby returns your last statement, it returns max for you, which is
always true. However, when you call queue_draw, it returns false, so,
you on_xxx_change_value returns false.

Hope it helps

Simon

2009/9/23 Simon A. [email protected]:

Perhaps I should have make it checked it to start with.
  else
   STDERR.puts “returning true, scale will NOT move”
   return true
  end
 end

Since ruby returns your last statement, it returns max for you, which is
always true. However, when you call queue_draw, it returns false, so,
you on_xxx_change_value returns false.

Indeed, moving the handler to value_changed handler resolves the
problem.

Unfortunately, this is not documented for ruby-gnome2.

Thanks

Michal