Getting towards dynamic sidebar updates

This commit is contained in:
Timothy Warren 2012-03-29 19:57:10 -04:00
parent 19c709fc93
commit 84fcc1c8d2
3 changed files with 18 additions and 8 deletions

View File

@ -62,13 +62,11 @@ class Data_Grid extends GtkTreeView {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Return a new Data_grid object * Empty the model
*
* @param object $model
*/ */
public function reset($model = null) public function reset($model = null)
{ {
return new Data_Grid($model); $this->model->clear();
} }
} }
// End of data_grid.php // End of data_grid.php

View File

@ -83,8 +83,10 @@ class Connection_Sidebar extends GtkVBox {
*/ */
protected function _render() protected function _render()
{ {
// Initialize the treeview // Create the treeview
$this->treeview = new Data_Grid(); $this->treeview = (isset($this->treeview))
? $this->treeview
: new Data_Grid();
$model = $this->treeview->get_model(); $model = $this->treeview->get_model();
@ -240,6 +242,16 @@ class Connection_Sidebar extends GtkVBox {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/**
* Recreate sidebar widget to update connections
*/
public function refresh()
{
$this->_render();
}
// --------------------------------------------------------------------------
/** /**
* Update the connection information for an existing connection * Update the connection information for an existing connection
*/ */

View File

@ -251,7 +251,7 @@ class DB_Info_Widget extends GtkTable {
$this->settings->add_db($data['name'], $data); $this->settings->add_db($data['name'], $data);
// Pass to connection sidebar to update // Pass to connection sidebar to update
// @todo Add new db to treeview Connection_Sidebar::get_instance()->refresh();
// Destroy the parent window // Destroy the parent window
$parent_window =& $this->get_parent_window(); $parent_window =& $this->get_parent_window();
@ -278,7 +278,7 @@ class DB_Info_Widget extends GtkTable {
$this->settings->update_db($data['name'], $data); $this->settings->update_db($data['name'], $data);
// Pass to connection sidebar to update // Pass to connection sidebar to update
// @todo Update db in treeview Connection_Sidebar::get_instance()->refresh();
// Let the user know the connection has been updated // Let the user know the connection has been updated
alert("Changes to database connection have been saved"); alert("Changes to database connection have been saved");