Dynamically add connections

This commit is contained in:
Timothy Warren 2012-03-30 09:58:41 -04:00
parent 84fcc1c8d2
commit 634a5b92a2
3 changed files with 40 additions and 3 deletions

View File

@ -122,6 +122,31 @@ if(function_exists('fbird_connect'))
// ! Global Functions // ! Global Functions
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/**
* Convert an array to an object
*
* @param array $array
* @return object
*/
function array_to_object($array)
{
if (is_object($array))
{
return $array;
}
$obj = new StdClass();
foreach($array as $k => $v)
{
$obj->$k = $v;
}
return $obj;
}
// --------------------------------------------------------------------------
/** /**
* Create info dialog to retun an informational message * Create info dialog to retun an informational message
* *

View File

@ -96,6 +96,11 @@ class Connection_Sidebar extends GtkVBox {
{ {
foreach($db_conns as $name => $props) foreach($db_conns as $name => $props)
{ {
if (is_array($props))
{
$props = array_to_object($props);
}
$db = $props; $db = $props;
$db->name = $name; $db->name = $name;
@ -247,6 +252,13 @@ class Connection_Sidebar extends GtkVBox {
*/ */
public function refresh() public function refresh()
{ {
$cols = $this->treeview->get_columns();
foreach($cols as $c)
{
$this->treeview->remove_column($c);
}
$this->_render(); $this->_render();
} }

View File

@ -39,7 +39,7 @@ class DB_Info_Widget extends GtkTable {
$db->port = ''; $db->port = '';
$db->conn_db = ''; $db->conn_db = '';
$db->dbtype = ''; $db->dbtype = '';
$db->db_file = NULL; $db->file = NULL;
} }
// Set up the form elements, with default values // Set up the form elements, with default values