Re: treeview toggle

From: Date: Tue, 05 Sep 2006 12:03:04 +0000
Subject: Re: treeview toggle
References: 1 2 3  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-7224@lists.php.net to get a copy of this message
Hello Christian Weiske, I added a public to the function, but still getting the same error. Any chance you could have a look at the code? Really sorry about bothering. I am relatively certain its some stupid newbie problem. Kind regards, Suomaf <?php class loginClass extends GtkWindow { function __construct() { parent::__construct(); $this->glade = new GladeXML(dirname(__FILE__) . '/todo.glade'); $this->glade->signal_autoconnect_instance($this); $this->glade->get_widget("priorityComboBox")->set_active(1); $this->create_tree(); } function create_tree() { //------------------load the tasks ------------------ $toDoList = simplexml_load_file('list2.xml'); //-------------------end loading tasks -------------- //-----------------TEST CODE-------------------------- //consider to move to a make tree function //the model $store = new GtkListStore(Gtk::TYPE_BOOLEAN, Gtk::TYPE_STRING, Gtk::TYPE_STRING, Gtk::TYPE_STRING); $treeview=$this->glade->get_widget("treeview1"); $treeview->set_model($store); $selection = $treeview->get_selection(); $selection->set_mode(Gtk::SELECTION_SINGLE); // $selection->connect('changed','toDoTreeView_selection_clicked'); //add some data to the data store foreach ($toDoList->task as $task) { $done = false; $intDone = (int)$task->done; if ($intDone == 1) { $done = true; } $toDo = (string)$task->toDo; $priority = (string)$task->priority; $date = (string)$task->date; $store->append(array($done,$toDo,$priority,$date)); } //$store->append(array(false , 'program the stupid gms3','Normal','22-06-2006')); //sort by year by default $store->set_sort_column_id(3, Gtk::SORT_ASCENDING); //the text renderer is used to display text $cell_renderer = new GtkCellRendererText(); //Create the first column, make it resizable and sortable $colTask= new GtkTreeViewColumn('Task', $cell_renderer, 'text', 1); //make the column resizable in width $colTask->set_resizable(true); //make it sortable and let it sort after model column 1 $colTask->set_sort_column_id(1); //add the column to the view $treeview->append_column($colTask); //second column, also sortable $colPriority = new GtkTreeViewColumn('Priority', $cell_renderer, 'text', 2); $colPriority->set_sort_column_id(2); $treeview->append_column($colPriority); //third column $colDate = new GtkTreeViewColumn('Date', $cell_renderer, 'text',3); $colDate->set_sort_column_id(3); $treeview->append_column($colDate); //we want to display a boolean value, so we can use a check box for display $bool_cell_renderer = new GtkCellRendererToggle(); $bool_cell_renderer->set_property('activatable', true); $bool_cell_renderer->connect('toggled','done_toggled',$store); $colUsed = new GtkTreeViewColumn('Done', $bool_cell_renderer, 'active', 0); $colUsed->set_sort_column_id(0); $treeview->append_column($colUsed); //-----------------END CODE--------------------------- } function toDoTreeView_selection_clicked() { echo "something is clicked"; } function on_addButton_clicked() { $date = $this->glade->get_widget("calendar1")->get_date(); $dateString = $date[1] . "-" . $date[2] . "-" . $date[0]; $errors = null; $toDo = $this->glade->get_widget('toDoEntry')->get_text(); $priority = $this->glade->get_widget('priorityComboBox')->get_active_text(); if (strlen($toDo)) { $errors .= "No task entered.\r\n"; } if ($errors == null) { $dialog = new GtkMessageDialog($wnd, Gtk::DIALOG_MODAL, GTK::MESSAGE_ERROR, GTK::BUTTONS_OK, $errors); $dialog->set_markup("Please enter a task:\r\n" . "<span foreground='red'>" .$errors . "</span>"); $dialog->run(); $dialog->destroy(); } else { //---------------------some code here --------------------------------- //$store = new GtkListStore(Gtk::TYPE_BOOLEAN, Gtk::TYPE_STRING, Gtk::TYPE_STRING, Gtk::TYPE_STRING); $treeview=$this->glade->get_widget("treeview1"); $store = $treeview->get_model(); $store->append(array(false , $toDo,$priority,$dateString)); //-------------------------end code ----------------------------------- //-------------------------add to xml file ---------------------------- $toDoList = simplexml_load_file('list2.xml'); $newTask = $toDoList->addChild('task'); $newTask->addChild('done', 0); $newTask->addChild('toDo', $toDo); $newTask->addChild('priority',$priority); $newTask->addChild('date',$dateString); file_put_contents('list2.xml',$toDoList->asXML()); //--------------------------------------------------------------------- } } function on_clearButton_clicked() { $this->glade->get_widget('toDoEntry')->set_text(''); } public function done_toggled($renderer, $row, $store) { $store ->set( $iter, 1, !$store->get_value($iter,1) ); } } $myClassInstance = new loginClass(); //Start the main loop Gtk::main() ?> -- View this message in context: http://www.nabble.com/treeview-toggle-tf2218198.html#a6150570 Sent from the Php - GTK - General forum at Nabble.com.

« previous php.gtk.general (#7224) next »