Miscellaneous fixes

This commit is contained in:
Timothy Warren 2012-04-02 16:56:55 -04:00
parent f2191c9ae4
commit f45e66e9ee
6 changed files with 60 additions and 19 deletions

View File

@ -30,6 +30,7 @@ date_default_timezone_set('GMT');
define('BASE_DIR', dirname(__FILE__).'/sys'); define('BASE_DIR', dirname(__FILE__).'/sys');
define('SETTINGS_DIR', dirname(__FILE__)); define('SETTINGS_DIR', dirname(__FILE__));
define('PROGRAM_NAME', 'OpenSQLManager'); define('PROGRAM_NAME', 'OpenSQLManager');
define('VERSION', '0.1.0pre');
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------

View File

@ -120,7 +120,7 @@ function about()
$dlg = new GtkAboutDialog(); $dlg = new GtkAboutDialog();
$dlg->set_program_name(PROGRAM_NAME); $dlg->set_program_name(PROGRAM_NAME);
$dlg->set_version('0.1.0pre'); $dlg->set_version(VERSION);
$dlg->set_copyright("Copyright (c) ".date('Y')." Timothy J. Warren"); $dlg->set_copyright("Copyright (c) ".date('Y')." Timothy J. Warren");

View File

@ -66,5 +66,18 @@ class DB_Reg {
{ {
return array_keys(self::$instance); return array_keys(self::$instance);
} }
// --------------------------------------------------------------------------
/**
* Remove a database connection
*
* @param string $key
* @return void
*/
public static function remove_db($key)
{
unset(self::$instance[$key]);
}
} }
// End of dbreg.php // End of dbreg.php

View File

@ -47,8 +47,8 @@ class Connection_Sidebar extends GtkVBox {
$this->settings =& Settings::get_instance(); $this->settings =& Settings::get_instance();
$dblabel = new GtkLabel('Database Connections'); //$dblabel = new GtkLabel('Database Connections');
$dblabel->set_alignment(0,0); //$dblabel->set_alignment(0,0);
$add_button = new GtkButton(); $add_button = new GtkButton();
$add_button->set_label("New Connnection"); $add_button->set_label("New Connnection");
@ -56,7 +56,7 @@ class Connection_Sidebar extends GtkVBox {
$add_button->connect_simple('clicked', array($this, 'new_conn')); $add_button->connect_simple('clicked', array($this, 'new_conn'));
$this->pack_start($dblabel, FALSE, FALSE); //$this->pack_start($dblabel, FALSE, FALSE);
// Treeview to show database connections // Treeview to show database connections
{ {
@ -115,7 +115,7 @@ class Connection_Sidebar extends GtkVBox {
// Label column // Label column
$cell_renderer = new GtkCellRendererText(); $cell_renderer = new GtkCellRendererText();
$this->treeview->insert_column_with_data_func(1, 'Connection name', $cell_renderer, array($this, 'set_label')); $this->treeview->insert_column_with_data_func(1, 'Name', $cell_renderer, array($this, 'set_label'));
// Status column // Status column
$cell_renderer = new GtkCellRendererPixbuf(); $cell_renderer = new GtkCellRendererPixbuf();
@ -187,18 +187,14 @@ class Connection_Sidebar extends GtkVBox {
$conns = DB_Reg::get_connections(); $conns = DB_Reg::get_connections();
/*if(in_array($info->name, $conns)) if(in_array($info->name, $conns))
{ {
$img = new GTKImage(); $cell->set_property('stock-id', 'gtk-yes');
$img->set_from_stock(GTK::STOCK_YES, Gtk::ICON_SIZE_SMALL_TOOLBAR);
$cell->set_property('pixbuf', $img->get_pixbuf());
} }
else else
{ {
$img = new GTKImage(); $cell->set_property('stock-id', 'gtk-no');
$img->set_from_stock(GTK::STOCK_NO, Gtk::ICON_SIZE_SMALL_TOOLBAR); }
$cell->set_property('pixbuf', $img->get_pixbuf());
}*/
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -260,11 +256,24 @@ class Connection_Sidebar extends GtkVBox {
{ {
$this->menu = new GtkMenu(); $this->menu = new GtkMenu();
$data = $this->treeview->get(0);
$conns = DB_Reg::get_connections();
// Set up menu items // Set up menu items
{ {
$connect = new GtkImageMenuItem('Connect'); // Show disconnect
$connect->set_image(GtkImage::new_from_stock(GTK::STOCK_CONNECT, GTK::ICON_SIZE_MENU)); if (in_array($data->name, $conns))
$connect->connect_simple('activate', array($this, 'db_connect')); {
$connect = new GtkImageMenuItem('Disconnect');
$connect->set_image(GtkImage::new_from_stock(GTK::STOCK_DISCONNECT, GTK::ICON_SIZE_MENU));
$connect->connect_simple('activate', array($this, 'db_disconnect'));
}
else
{
$connect = new GtkImageMenuItem('Connect');
$connect->set_image(GtkImage::new_from_stock(GTK::STOCK_CONNECT, GTK::ICON_SIZE_MENU));
$connect->connect_simple('activate', array($this, 'db_connect'));
}
$this->menu->append($connect); $this->menu->append($connect);
@ -356,5 +365,19 @@ class Connection_Sidebar extends GtkVBox {
DB_Tabs::get_instance()->get_db_tabs($conn); DB_Tabs::get_instance()->get_db_tabs($conn);
} }
// --------------------------------------------------------------------------
/**
* Disconnect from a database
*/
public function db_disconnect()
{
$data = $this->treeview->get(0);
DB_Reg::remove_db($data->name);
$this->refresh();
}
} }
// End of connection_sidebar.php // End of connection_sidebar.php

View File

@ -419,7 +419,7 @@ class DB_Info_Widget extends GtkTable {
$params->pass = $this->pass->get_text(); $params->pass = $this->pass->get_text();
$params->port = $this->port->get_text(); $params->port = $this->port->get_text();
$params->file = $this->db_file->get_filename(); $params->file = $this->db_file->get_filename();
$params->database = $this->conn_db->get_text(); $params->conn_db = $this->conn_db->get_text();
// Return early if a db type isn't selected. // Return early if a db type isn't selected.
// Better to bail out then crash because of // Better to bail out then crash because of

View File

@ -17,6 +17,10 @@
*/ */
class DB_tabs extends GTKNotebook { class DB_tabs extends GTKNotebook {
/**
* Current Tab Widget object
* @var DB_Tabs
*/
private static $instance; private static $instance;
/** /**
@ -44,7 +48,7 @@ class DB_tabs extends GTKNotebook {
parent::__construct(); parent::__construct();
// Move the tab bar to the bottom // Move the tab bar to the bottom
$this->set_tab_pos(Gtk::POS_BOTTOM); //$this->set_tab_pos(Gtk::POS_BOTTOM);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -74,7 +78,7 @@ class DB_tabs extends GTKNotebook {
* *
* @return DB_tabs * @return DB_tabs
*/ */
public function reset() public static function reset()
{ {
unset(self::$instance); unset(self::$instance);
return self::get_instance(); return self::get_instance();