Re: Gtk2::CellRendererText vs TextView right alignment on hebrew text
- From: muppet <scott asofyet org>
- To: gtk2-perl List <gtk-perl-list gnome org>
- Subject: Re: Gtk2::CellRendererText vs TextView right alignment on hebrew text
- Date: Fri, 25 Jan 2008 00:19:55 -0500
On Jan 24, 2008, at 11:45 PM, Mitchell Laks wrote:
On 12:21 Thu 24 Jan , Mitchell Laks wrote:
Hi,
I have been using gtk2-perl with hebrew according to the wonderful
Dov Grobgeld tutorial.
Now, I am trying to display text with a Gtk2::CellRendererText in a
TreeViewColumn in a TreeView.
However I notice that the text is displayed 'left justified' which
is wrong since hebrew is written from right to left.
I love that I can answer my own questions,
because that means there is alot of available data to be mined with
google!
Ok the answer is
$renderer->set_property('xalign',1.0);
where $renderer is the Gtk2::CellRendererText.
I don't think this is really what you want. That will cause text to
be right-aligned even if your user is *not* using a right-to-left
locale.
I just checked gtk/gtkcellrenderertext.c, and indeed, there's this:
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
align = PANGO_ALIGN_RIGHT;
else
align = PANGO_ALIGN_LEFT;
pango_layout_set_alignment (layout, align);
and
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
*x_offset = (1.0 - cell->xalign) * (cell_area->width - (rect.x +
rect.width + (2 * cell->xpad)));
else
*x_offset = cell->xalign * (cell_area->width - (rect.x +
rect.width + (2 * cell->xpad)));
so, provided your locale is being set up properly, this should Just
Work.
You may be interested in experimenting with some combination of
Gtk2::Widget::set_direction() and Gtk2::Widget::set_default_direction().
E.g.,
if (magically_determine_if_locale_is_rtl ()) {
$toplevel->set_default_direction ('rtl');
}
My system insists that the "he" locale is not installed, so i can't
really tell if this works completely.
If nothing really does the trick, you can do
$renderer->set_property (xalign => 1.0) if $renderer->get_direction
eq 'rtl';
to avoid breaking ltr users, but, again, i really do think it should
work automatically, so there's likely a config problem.
which uses the following code, which I find puzzling:
#Attach a 'renderer_number' value to the renderer.
#This can be used to differentiate between renderers
#when we have a few renderers which can be edited
$renderer->{'renderer_number'} = RENDERER_FIRST_TEXT;
Looks like he is arbitrarily extending the renderer perl base hash
for his own nefarious purposes.
which seem cool.
Am I right?
It is intended that you can store whatever you want in the instance
hash of a Glib::Object. Now, normal rules of perl OO apply in that if
you overwrite a key you don't control, you can break stuff. But, the
blessed hash references you get back from the bindings themselves
typically will have the underlying C object attached by magic, so you
can't break them.
--
So this new album took us quite a while, to get it together, to find a
title and things like that - and we were travelling quite a bit - we
made a few sort of gestures in the East, and a few gestures in the
West, and then we got thrown out because of our gestures - this is
something that we decided was an apt title for a thing that's called
'The Song Remains The Same'.
-- Robert Plant, rambling to introduce a song
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]