 |
| View previous topic :: View next topic |
| Author |
Message |
syn
Joined: 12 May 2006 Posts: 46 Location: Hamburg
|
Posted: Tue May 16, 2006 9:21 am Post subject: GtkCellRenderer - Widged in a cell |
|
|
Is it possible to add e.g. a textarea and two buttons to a cell , or is it only possible to add plain or styled text (i know, there is no GtkCellRendererObj).
I want build a row with 2 cells. First cell hosts an image, the second a description and buttons to bookmark and remove this row. Is that possible?
Regards,
andreas |
|
| Back to top |
|
 |
squirrel
Joined: 02 May 2006 Posts: 10 Location: Switzerland
|
Posted: Tue May 16, 2006 10:31 am Post subject: |
|
|
Hi andreas,
You may use 'GtkCellRendererToggle' instead of 'GtkCellRendererText'.
| Quote: | | GtkCellRendererToggle renders a toggle button in a cell. The button is drawn as a radio- or checkbutton, depending on the radio property. When activated, it emits the toggled signal. |
Have a look at the following properties:
active : boolean => set the value: $col->set_attributes($renderer, 'active', 0);
radio : boolean => radio or checkbox
Regards,
Gerry |
|
| Back to top |
|
 |
syn
Joined: 12 May 2006 Posts: 46 Location: Hamburg
|
Posted: Tue May 16, 2006 3:54 pm Post subject: |
|
|
I would build a cell like a table in html where you can add an <html> into a <td> A toogle-button per cell is very simple, i think.
| Code: |
<table border=1>
<tr>
<td>Image</td>
<td>
<table border=1>
<tr>
<td colspan="2">This ist the infoblock</td>
</tr>
<tr>
<td>BOOKMARK</td>
<td>REMOVE</td>
</tr>
</table>
</td>
</tr>
</table>
|
|
|
| Back to top |
|
 |
squirrel
Joined: 02 May 2006 Posts: 10 Location: Switzerland
|
Posted: Tue May 16, 2006 10:16 pm Post subject: |
|
|
Hi andreas,
I thought you were programming a GUI-application not an HTML page? - I think it's not possible to have a layout like this with a GtkTreeView. To have such a layout, I would build up this with the help of different widgets contained in a GtkVBox and all that on a GtkScrolledWindow.
Another way is to have your buttons at the bottom of the list and you 'bookmark' or 'remove' the selected item in the list.
To show you my idea about GtkCellRendererToggle check out the following example (you still need some activation with the help of a button, but you could bookmark or remove over a more visible multi-selection):
| Code: | <?php
// set values on toggle
function onToggle($objRenderer, $strPath, $model, $intCol) {
$iter = $model->get_iter_from_string($strPath);
$value = $model->get_value($iter, $intCol);
if ($value == true) {
$model->set($iter, $intCol, false);
} else {
$model->set($iter, $intCol, true);
}
}
$window = new GtkWindow();
$icon_table = $window->render_icon(Gtk::STOCK_NO, Gtk::ICON_SIZE_SMALL_TOOLBAR);
$icon_column = $window->render_icon(Gtk::STOCK_YES, Gtk::ICON_SIZE_SMALL_TOOLBAR);
// create model
$model = new GtkListStore(GdkPixbuf::gtype, Gtk::TYPE_STRING, Gtk::TYPE_BOOLEAN, Gtk::TYPE_BOOLEAN);
$model->append(array($icon_table, 'info1', true, false));
$model->append(array($icon_column, 'info2', false, false));
// treeview with 2 columns
$treeview = new GtkTreeView($model);
$col1 = new GtkTreeViewColumn('picture');
$col2 = new GtkTreeViewColumn('info');
$col3 = new GtkTreeViewColumn('bookmark');
$col4 = new GtkTreeViewColumn('remove');
$treeview->append_column($col1);
$treeview->append_column($col2);
$treeview->append_column($col3);
$treeview->append_column($col4);
$cell_renderer1 = new GtkCellRendererPixBuf();
$cell_renderer2 = new GtkCellRendererText();
$cell_renderer3 = new GtkCellRendererToggle();
$cell_renderer3->set_property('activatable', true);
$cell_renderer3->set_property('xalign', 0);
$cell_renderer3->connect('toggled', 'onToggle', $model, 2);
$cell_renderer4 = new GtkCellRendererToggle();
$cell_renderer4->set_property('activatable', true);
$cell_renderer4->set_property('xalign', 0);
$cell_renderer4->connect('toggled', 'onToggle', $model, 3);
$col1->pack_start($cell_renderer1, true);
$col2->pack_start($cell_renderer2, true);
$col3->pack_start($cell_renderer3, false);
$col4->pack_start($cell_renderer4, false);
$col1->set_attributes($cell_renderer1, 'pixbuf', 0);
$col2->set_attributes($cell_renderer2, 'text', 1);
$col3->set_attributes($cell_renderer3, 'active', 2);
$col4->set_attributes($cell_renderer4, 'active', 3);
// build dialog
$vBox = new GtkVBox();
$window->add($vBox);
$vBox->pack_start($treeview);
$window->show_all();
$window->connect_simple('destroy', array('Gtk', 'main_quit'));
gtk::main();
?>
|
|
|
| Back to top |
|
 |
syn
Joined: 12 May 2006 Posts: 46 Location: Hamburg
|
Posted: Wed May 17, 2006 9:34 am Post subject: |
|
|
I know, that we dont want to build html-pages... its only an exsample what i need. In dont want to build an Tool like Excel, but sometimes i think, the lists can only do this for me. I want build a tool like a forum. But i dont see, how to create this in a single line
Yes, your excample works.. but is that the stateofart of usability? I dont think so. |
|
| Back to top |
|
 |
cweiske
Joined: 08 Dec 2005 Posts: 454 Location: Leipzig/Germany
|
Posted: Wed May 17, 2006 9:50 am Post subject: |
|
|
You could do the following:
Pack a GtkTable in a GtkScrolledWindow and add a row with normal image, label and buttons for each row you want to have. |
|
| Back to top |
|
 |
syn
Joined: 12 May 2006 Posts: 46 Location: Hamburg
|
Posted: Wed May 17, 2006 10:06 am Post subject: |
|
|
Ok, i think that will work too. But then, i miss some implemented features of gtkTreeView  |
|
| Back to top |
|
 |
cweiske
Joined: 08 Dec 2005 Posts: 454 Location: Leipzig/Germany
|
Posted: Wed May 17, 2006 10:11 am Post subject: |
|
|
| Currently it is not possible to implement your own cell renderer because of some features missing in php-gtk2. So you have to wait until you can, and then use a normal button in a cell. |
|
| Back to top |
|
 |
syn
Joined: 12 May 2006 Posts: 46 Location: Hamburg
|
Posted: Wed May 17, 2006 12:56 pm Post subject: |
|
|
| cweiske wrote: | | Currently it is not possible |
I like the word currently  |
|
| Back to top |
|
 |
cweiske
Joined: 08 Dec 2005 Posts: 454 Location: Leipzig/Germany
|
Posted: Thu May 18, 2006 6:10 pm Post subject: |
|
|
| I implemented the marshaller and the set_sort_func/set_default_sort_func methods today. The patch can be found there: http://bugs.php.net/bug.php?id=37504 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
 |