Does any one know how to set the scrollbar position. I am able to get
the scrollbar and all it’s ancestors but I am not sure how to
programmatically change the position of the scrollbar. In my case I
would like it to be right at the bottom.
I found Gtk::Range has a signal called ‘move-slider’ but from what I
understand signals are for listening to changes in objects and make the
actual changes however I may be wrong.
On Mon, Feb 11, 2008 at 06:49:34PM +0100, Carl B. wrote:
Hi,
Does any one know how to set the scrollbar position. I am able to get
the scrollbar and all it’s ancestors but I am not sure how to
programmatically change the position of the scrollbar. In my case I
would like it to be right at the bottom.
You should be able to use Gtk::Range.value= or
Gtk::Range.adjustment.value to set it. You can see the upper and lower
limits by using Gtk::Range.adjustment.upper or .lower.
On Mon, Feb 11, 2008 at 06:49:34PM +0100, Carl B. wrote:
Hi,
Does any one know how to set the scrollbar position. I am able to get
the scrollbar and all it’s ancestors but I am not sure how to
programmatically change the position of the scrollbar. In my case I
would like it to be right at the bottom.
You should be able to use Gtk::Range.value= or
Gtk::Range.adjustment.value to set it. You can see the upper and lower
limits by using Gtk::Range.adjustment.upper or .lower.
HTH,
-pete
Thanks for the answer but that is what I tried. It only moved the
scrollbar part way as so.
Before setting the value of Gtk::Range.
Gtk::Adjustment.upper returned 255.
After calling this line of code.
Gtk::Range.value = Gtk::Adjustment.upper
Gtk::Adjustment.upper returned 15.
I just found the answer and it was pretty clear when I gave it some
thought. To move the scrollbar all the way to the other side(or bottom)
use Gtk::ScrolledWindow.hscrollbar/vscrollbar.adjustment.inverted =
true. Since the scrollbar starts at 0 and this setting will make the
oppostie end of the scrollbar 0, it will move the slider to the
end/bottom. I also noticed that anytime text is appended the scrollbar
will stay at the end/bottom.
Ruby being as powerful as it is simple to code in still isn’t 100
percent perfect. One such requirement to make life easier would be a
method to convert a byte array into a string such as Java’s String str
= new String(byte[])
and then you go a long way to come up with:
def byte_array_to_string(byte_array)
string = ‘’
byte_array.each do |byte|
string.concat(byte.chr)
end
return string
end
what is curious is that you are aware of #unpack. there is an opposite
method, #pack, which does exactly what you think is lacking (but is
not):
“byte_array_to_string(input)” yields the same results as
“input.pack(‘U*’)”
btw, avoid “new String(byte[])” in java, as it depends on platform’s
default encoding. always use the two arguments form and tell java that
the byte array is UTF-8, ISO-8859-1, or whatever it’s encoded in, it
will save you from being severely bitten someday you decide to install
your new server with other defaults.