Re: Dynamic Build Types for GtkListStore.
| From: | Andrei Zmievski | Date: | Sun, 09 Apr 2006 01:54:00 +0000 |
| Subject: | Re: Dynamic Build Types for GtkListStore. | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-6851@lists.php.net to get a copy of this message | ||
That's just the restriction that Gtk+ has. See this:
http://www.gtk.org/api/2.6/gtk/GtkTreeStore.html#gtk-tree-store-set-column-types
"This function is meant primarily for GObjects that inherit from GtkTreeStore, and should only be used when constructing a new GtkTreeStore. It will not function after a row has been added, or a method on the GtkTreeModel interface is called."
-Andrei
On Apr 8, 2006, at 5:19 PM, Pablo Dall'Oglio wrote:
Why I cannot call $model->set_column_types() after GtkTreeView::set_model($model) ? I mean, I cannot change the number of columns of the model, once I have already called set_model()... it tells me: Gtk-CRITICAL **: gtk_list_store_set_column_types: assertion `list_store->columns_dirty == 0' failed PS: I know it isn't trivial, but it would be usefull for me, because I'm writting a wrapper for list edition that allow to add columns dinamically. <?php$view = new GtkTreeView; $model = new GtkTreeStore; $columns = array(Gtk::TYPE_STRING, Gtk::TYPE_STRING); $model->set_column_types($columns); $view->set_model($model);$columns[] = Gtk::TYPE_STRING; echo 'before error'; $model->set_column_types($columns); echo 'after error';Gtk::Main();?> Pablo Em Sex, 2006-04-07 às 14:50 -0400, Eddie Hixson escreveu:Andrei, Here is the code to build the store. The variable $keys is the array of column names from mysql query. $ListStoreTypes = array(); $ListStoreTypes = array_fill(0,count($keys),Gtk::TYPE_STRING); $store = new GtkListStore(); $store->set_column_types($ListStoreTypes); do {--:: Pablo Dall'Oglio :: www.dalloglio.netfor($i=0; $i < count($data)/2; $i++) { $row_data[$i] = $data[$i]; } $store->append($row_data);}while ($data = mysql_fetch_array($result)); $treeview = new GtkTreeView($store); $treeview->set_model($store); //the text renderer is used to display text $cell_renderer = new GtkCellRendererText(); //Create the column list for ($i=0;$i<count($keys);$i++) {$column[$i] = new GtkTreeViewColumn($keys[$i], $cell_renderer,'text', $i);$column[$i]->set_resizable(true); $column[$i]->set_sort_column_id($i); $treeview->append_column($column[$i]);} $scrolled_win->add($treeview); Regards, Eddie On Fri, 2006-04-07 at 10:40 -0700, Andrei Zmievski wrote:Can you paste in the code you're using? -Andrei On Apr 7, 2006, at 5:47 AM, Eddie Hixson wrote:Andrei, Thank you for response and quick fix in the code. That is exactly what I was looking to do in my application. The program is working but does create this CRITICAL ERROR. (sm_MySql.php:16162): Gtk-CRITICAL **: gtk_list_store_set_n_columns: assertion `n_columns > 0' failed Is this error related to your new implementaion of the override? OR Do I have another issue I need to be looking for? "YOU ARE THE MAN" Regards, Eddie