diff --git a/src/common/settings.php b/src/common/settings.php index fabd93b..8fa2455 100644 --- a/src/common/settings.php +++ b/src/common/settings.php @@ -99,8 +99,9 @@ class Settings { */ function add_db($name, $params) { - if(empty($this->current->dbs->{$name})) + if(! isset($this->current->dbs->{$name})) { + $this->current->dbs->{$name} = array(); $this->current->dbs->{$name} = $params; } else diff --git a/src/windows/add_db.php b/src/windows/add_db.php index 80d7153..6d04cac 100644 --- a/src/windows/add_db.php +++ b/src/windows/add_db.php @@ -17,7 +17,7 @@ */ class Add_DB extends GtkWindow { - var $conn, $dbtype, $host, $user, $password, $database, $settings; + var $conn, $dbtype, $host, $user, $pass, $database, $settings; function __construct() { @@ -89,6 +89,15 @@ class Add_DB extends GtkWindow { $this->_add_row($table, "DB Password", $this->pass, $y1, $y2); } + // Add connection button + { + $add_button = new GtkButton(); + $add_button->set_label("Add Connnection"); + $add_button->set_image(GTKImage::new_from_stock(GTK::STOCK_ADD, Gtk::ICON_SIZE_SMALL_TOOLBAR)); + $table->attach($add_button, 0, 3, ++$y1, ++$y2); + $add_button->connect_simple("clicked", array($this, 'db_add')); + } + return $table; } @@ -156,6 +165,24 @@ class Add_DB extends GtkWindow { $table->attach($lblalign, 0, 1, ++$y1, ++$y2); $table->attach($vname, 1, 2, $y1, $y2); } + + /** + * Adds the database to the settings file + */ + function db_add() + { + $data = array( + 'type' => $this->dbtype->get_active_text(), + 'host' => $this->host->get_text(), + 'user' => $this->user->get_text(), + 'pass' => $this->pass->get_text(), + ); + + $this->settings->add_db($this->conn->get_text(), $data); + + // Destroy this window + $this->destroy(); + } } // End of add_db.php \ No newline at end of file diff --git a/src/windows/main.php b/src/windows/main.php index 3d434b0..55e0b6f 100644 --- a/src/windows/main.php +++ b/src/windows/main.php @@ -202,7 +202,7 @@ class Main extends GtkWindow { foreach($db_conns as $name => $props) { $db = $props; - $db['name'] = $name; + $db->name = $name; $iter = $model->append(); $model->set($iter, 0, $db); @@ -237,7 +237,7 @@ class Main extends GtkWindow { function set_label($col, $cell, $model, $iter) { $info = $model->get_value($iter, 0); - $cell->set_property('text', $info['name']); + $cell->set_property('text', $info->name); } /**