Adding DBs works

Well, adding the information. You have to close the program for the dbs
to update, and there's no way to connect yet...
This commit is contained in:
Timothy Warren 2012-02-06 12:14:39 -05:00
parent 7ec35088b1
commit b0da1994f5
3 changed files with 32 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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);
}
/**