예제 #1
0
 public function click_section(GtkTreeView $view, GtkTreeIter $iter, array $path)
 {
     // Set the path to make sure the selection is selected
     $view->set_cursor($path);
     /** @var GtkTreeModel */
     $model = $view->get_model();
     $value = $model->get_value($iter, 0);
     // Do multi processing here! ~_~
     // TODO: Detect Windows verse Unix
     $proc = new Gorilla3d\Process();
     // Unix
     $proc->setCommand("php threads.php &");
     // Windows
     //$proc->setCommand("start php threads.php");
     $proc->open();
     $proc->write($value);
     // Keep checking if the process is done
     foreach (range(1, 6) as $i) {
         // Needed to not block UI
         while (Gtk::events_pending()) {
             Gtk::main_iteration();
         }
         // Sleep 0.5 seconds before checking again (locks UI for 1/2 a second
         usleep(500000);
         echo "SLEEP!" . PHP_EOL;
     }
     $proc->close();
     /*
     $sections = Fourchan\Sections::getSections();
     $url = false;
     if(isset($sections[$value])) {
         $url = $sections[$value];
     } else {
         echo "fart!\n";
     }
     
     if($url) {
         $parser = new Fourchan\Parser($url);
         $parser->getPages();
         $parser->getThreads();
         // lots of threads >.<
         var_dump($parser->threads);
     }
     */
     /** @var GtkTreeSelection */
     /* For multiple selections
        $selection = $view->get_selection();
            
        list($model, $arPaths) = $selection->get_selected_rows();
        echo "Selection is now:\r\n";
        foreach ($arPaths as $path) {
            $iter = $model->get_iter($path);
            echo '  ' . $model->get_value($iter, 0) . "\r\n";
        }
        */
     /*
      */
     echo "clicked Thread!" . PHP_EOL;
 }
예제 #2
0
	/**
	 * This returns the selected items for a GtkTreeView() (if it is possible to select more items). Saves code.
	 * @param GtkTreeView $treeview The treeview for which the function should return values.
	*/
	function treeview_getAll(GtkTreeView $treeview){
		$columns = $treeview->get_columns();
		$model = $treeview->get_model();
		
		$return = array();
		$first = true;
		while(true){
			if ($first == true){
				$iter = @$model->get_iter_first();
				$first = false;
			}else{
				$iter = $model->iter_next($iter);
			}
			
			if (!$iter){
				break;
			}
			
			foreach($columns AS $key => $column){
				$value = $model->get_value($iter, $key);
				$return_new[$key] = $value;
			}
			
			$return[] = array("values" => $return_new, "iter" => $iter);
		}
		
		return $return;
	}
 /**
  * Cria o efeito do toggle para o treeview
  * 
  * @name __onToggle
  * @access private
  * @param GtkCellRendererToggle $renderer Render a ser checkado
  * @param string $path Path que foi clicado
  * @param int $col Index da coluna clicada
  */
 public function __onToggle($renderer, $path, $col)
 {
     $model = parent::get_model();
     $iter = $model->get_iter($row);
     $model->set($iter, $col, !$model->get_value($iter, $col));
 }