Re: Gtk2::CellRendererText vs TextView right alignment on hebrew text



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.


-----------------------------------

Now how did I figure this out?

I grepped through the gtkmmlist for TreeView

here is what i found on the gtkmm list

From: Matt Galloway <matt galloway me uk>
User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051029)
Date: Wed, 08 Feb 2006 23:48:11 +0000
To: gtkmm-list gnome org
Subject: TreeView Queries




I've just started gtkmm programming and I have a couple of queries
regarding Gtk::TreeView. They are as follows:

1) Is there anyway I can set the columns to have central alignment
within the columns? i.e. Like this:
  Col 1  |  Col 2
    8    |   455
  Instead of:
  Col 1  |  Col 2
  8      |  455

2) Is there anyway I can set the width of the columns at startup? I
don't want the user to be able to change them and that's fine, I've got
that bit done.

Any help would be much appreciated!

Many thanks,
Matt Galloway



From: Bob Caryl <bob fis-cal com>
Reply-to: bob fis-cal com
User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317)
Date: Mon, 13 Feb 2006 09:20:09 -0600
To: Matt Galloway <matt galloway me uk>
Cc: gtkmm-list gnome org
Subject: Re: TreeView Queries

[-- Attachment #1 --]
[-- Type: text/plain, Encoding: 7bit, Size: 1.2K --]

Hey Matt,

To set the alignment you must first get the cell renderer
(Gtk::TreeView::Column::get_first_cell_renderer) and then set
Gtk::CellRenderer::property_xalign to 0.5;

http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1CellRenderer
.html#c94be538d1c46649d7030771ef054f00


note that in gtkmm

Gtk::CellRenderer<--Gtk::CellRendererText

************************

well how to set the property in perl?
so I looked in the pygtk documentation and found this 

http://www.moeraki.com/pygtktutorial/pygtk2tutorial/examples/treeviewcolumn.py
self.cell1 = gtk.CellRendererText()
self.cell1.set_property('cell-background', 'pink')

and then i guessed what would work here.

Because perl object methods are inherited down the chain without a cast.

I guess if I would have looked in gtk2-perl-study/sample-programs_17_02_2006/sample_programs

I would have found

$renderer->set_property('editable' => TRUE);

in 

sample_programs/gtk2_treeview_edit.pl.

which is fine.

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?


Mitchell



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]