Hi,
Sorry, I’m just a newbie in programming.
I have a problem with the transfer of array from the treeview to the labels.
I got three separate files, the gl_main.php (extends GtkWindow), the gl_listview.php (extends GtkTreeView) and the gl_details.php (extends GtkTable).
The two files (gl_listview.php and gl_details.php) are just called to gl_main.php using “require_once ‘name_of_file.php’”.
Now, I made a callback to a function from gl_listview.php to gl_main.php. I got this code:
| Code: |
//Get selection
$selectData = $this->get_selection();
$selectData->set_mode(Gtk::SELECTION_SINGLE);
$selectData->connect('changed', array('gl_MainWindow', 'on_selection')); |
This lines are perfectly running. No problem about that.
The on_selection function called from gl_listview.php is made inside the gl_main.php:
| Code: |
function on_selection($selectData){
list ($listStore, $iter) = $selectData->get_selected();
if($iter){
$selTransIdno = $listStore->get_value($iter, 0);
$selFname = $listStore->get_value($iter, 1);
$selLname = $listStore->get_value($iter, 2);
$selAddress = $listStore->get_value($iter, 3);
$selContact = $listStore->get_value($iter, 4);
$selCompany = $listStore->get_value($iter, 5);
$selCompanyId = $listStore->get_value($iter, 6);
//I made this array so that it would be easy for me to populate the data.
$dataSelection = array($selTransIdno, $selFname, $selLname, $selAddress, $selContact, $selCompany, $selCompanyId);
//This is the other callback to show the data to the labels using the array $dataSelection.
//But still doesn’t help me out. :D
//Is the script for connection right? coz I’m not sure about it. ^_^
$dataSelection->connect('changed', array(‘gl_Details,'disp_selected'));
}
} |
Now, the problem is how will I made the function to show the data inside the array ($dataSelection)??? :(
I got this code from gl_details.php:
| Code: |
class gl_Details extends GtkTable{
public function __construct(){
//the construction of the table
//the array for labels
$labels = array('Transaction No.', 'First Name', 'Last Name', 'Address', 'Contact No.', 'Company', 'Company ID No.');
//NOW I WANT TO BRING THE ARRAY ($dataSelection) HERE.
//BECAUSE I MADE A LOOP FOR IT.
//THE ARRAY $dataSelection SHOULD BE HERE. HOW???PLS HELP
$disp = $dataSelection; //??????
$this->_layoutContent($labels, $disp);
}
function _layoutContent($labels, $disp){
foreach ($labels as $label){
//THE LOOP FOR LABELS
}
$cnt = 0;
foreach ($disp as $display){
//THE LOOP FOR THE SELECTED FROM AN ARRAY ($dataSelection).
$desc = new GtkLabel($display);
$desc->set_alignment(1,0);
$this->attach($desc, 1, 2, $cnt, $cnt + 1, $expFill, 0);
++$cnt;
}
}
function disp_selected($dataSelection){
//HOW WILL I MADE THIS FUNCTION TO BRING THE ARRAY UP (LITTERALLY) SO THAT IT WOULD BE USE AS THE $disp VARIABLE??PLS HELP..
}
} |
I already tried to “echo” the selected row from the tree view to the console, it runs perfectly. I already made lots of functions, but still doesn’t work. The root problem is to display the selected row to the labels.
Sorry, if I made it long..maybe you need the codes from other files. Tnx a lot.. :D
PHP-GTK rocks!!!.. \m/