Various improvements
This commit is contained in:
parent
b241819799
commit
19c709fc93
@ -21,10 +21,15 @@ class Data_Grid extends GtkTreeView {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the object
|
* Create the object
|
||||||
|
*
|
||||||
|
* @param object $model
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct($model = null)
|
||||||
{
|
{
|
||||||
$this->model = new GtkTreeStore(Gobject::TYPE_PHP_VALUE, Gobject::TYPE_PHP_VALUE);
|
$this->model = ( ! is_null($model))
|
||||||
|
? $model
|
||||||
|
: new GtkTreeStore(Gobject::TYPE_PHP_VALUE, Gobject::TYPE_PHP_VALUE);
|
||||||
|
|
||||||
parent::__construct($this->model);
|
parent::__construct($this->model);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,4 +45,30 @@ class Data_Grid extends GtkTreeView {
|
|||||||
{
|
{
|
||||||
// @todo implement
|
// @todo implement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value of the cell at the provided coordinate array
|
||||||
|
*
|
||||||
|
* @param array $coord
|
||||||
|
* @param mixed $val
|
||||||
|
*/
|
||||||
|
public function set(array $coord, $val)
|
||||||
|
{
|
||||||
|
// @todo implement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a new Data_grid object
|
||||||
|
*
|
||||||
|
* @param object $model
|
||||||
|
*/
|
||||||
|
public function reset($model = null)
|
||||||
|
{
|
||||||
|
return new Data_Grid($model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// End of data_grid.php
|
@ -21,8 +21,6 @@ class Query_Builder {
|
|||||||
// Compiled query component strings
|
// Compiled query component strings
|
||||||
private $select_string,
|
private $select_string,
|
||||||
$from_string,
|
$from_string,
|
||||||
$insert_string,
|
|
||||||
$update_string,
|
|
||||||
$set_string,
|
$set_string,
|
||||||
$order_string,
|
$order_string,
|
||||||
$group_string;
|
$group_string;
|
||||||
|
@ -32,5 +32,4 @@ class Add_DB extends GtkWindow {
|
|||||||
$this->show_all();
|
$this->show_all();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// End of add_db.php
|
// End of add_db.php
|
@ -17,7 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
class Edit_DB extends GtkWindow {
|
class Edit_DB extends GtkWindow {
|
||||||
|
|
||||||
public function __construct()
|
/**
|
||||||
|
* Connection editing window
|
||||||
|
*
|
||||||
|
* @param string $db
|
||||||
|
*/
|
||||||
|
public function __construct($db)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
@ -25,12 +30,11 @@ class Edit_DB extends GtkWindow {
|
|||||||
$this->set_title("Edit Database Connection");
|
$this->set_title("Edit Database Connection");
|
||||||
|
|
||||||
// Create the layout table
|
// Create the layout table
|
||||||
$connection_form = new DB_Info_Widget();
|
$connection_form = new DB_Info_Widget(Settings::get_instance()->get_db($db));
|
||||||
|
|
||||||
// Add the Vbox, and show the window
|
// Add the Vbox, and show the window
|
||||||
$this->add($connection_form);
|
$this->add($connection_form);
|
||||||
$this->show_all();
|
$this->show_all();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// End of edit_db.php
|
// End of edit_db.php
|
@ -150,7 +150,7 @@ class Main extends GtkWindow {
|
|||||||
|
|
||||||
$scrolled_win = new GtkScrolledWindow();
|
$scrolled_win = new GtkScrolledWindow();
|
||||||
$scrolled_win->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
$scrolled_win->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
||||||
$scrolled_win->add_with_viewport(new DB_tabs());
|
$scrolled_win->add_with_viewport(DB_tabs::get_instance());
|
||||||
|
|
||||||
// Add the connection sidebar
|
// Add the connection sidebar
|
||||||
$this->connection_sidebar =& Connection_Sidebar::get_instance();
|
$this->connection_sidebar =& Connection_Sidebar::get_instance();
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
class Connection_Sidebar extends GtkVBox {
|
class Connection_Sidebar extends GtkVBox {
|
||||||
|
|
||||||
protected $settings, $menu, $treeview, $model;
|
protected $settings, $menu, $treeview;
|
||||||
private static $instance;
|
private static $instance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,9 +60,6 @@ class Connection_Sidebar extends GtkVBox {
|
|||||||
|
|
||||||
// Treeview to show database connections
|
// Treeview to show database connections
|
||||||
{
|
{
|
||||||
// Create a Storage object for connection list
|
|
||||||
$this->model = new GtkListStore(GObject::TYPE_PHP_VALUE, GObject::TYPE_STRING);
|
|
||||||
|
|
||||||
// Render the treeview
|
// Render the treeview
|
||||||
$this->_render();
|
$this->_render();
|
||||||
|
|
||||||
@ -86,6 +83,11 @@ class Connection_Sidebar extends GtkVBox {
|
|||||||
*/
|
*/
|
||||||
protected function _render()
|
protected function _render()
|
||||||
{
|
{
|
||||||
|
// Initialize the treeview
|
||||||
|
$this->treeview = new Data_Grid();
|
||||||
|
|
||||||
|
$model = $this->treeview->get_model();
|
||||||
|
|
||||||
// Add the existing connections to the model
|
// Add the existing connections to the model
|
||||||
$db_conns = $this->settings->get_dbs();
|
$db_conns = $this->settings->get_dbs();
|
||||||
if( ! empty($db_conns))
|
if( ! empty($db_conns))
|
||||||
@ -95,14 +97,11 @@ class Connection_Sidebar extends GtkVBox {
|
|||||||
$db = $props;
|
$db = $props;
|
||||||
$db->name = $name;
|
$db->name = $name;
|
||||||
|
|
||||||
$iter = $this->model->append();
|
$iter = $model->append();
|
||||||
$this->model->set($iter, 0, $db);
|
$model->set($iter, 0, $db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the treeview with the data
|
|
||||||
$this->treeview = new GtkTreeView($this->model);
|
|
||||||
|
|
||||||
// Icon column
|
// Icon column
|
||||||
$cell_renderer = new GtkCellRendererPixbuf();
|
$cell_renderer = new GtkCellRendererPixbuf();
|
||||||
$this->treeview->insert_column_with_data_func(0, 'Type', $cell_renderer, array($this, 'set_icon'));
|
$this->treeview->insert_column_with_data_func(0, 'Type', $cell_renderer, array($this, 'set_icon'));
|
||||||
@ -125,7 +124,7 @@ class Connection_Sidebar extends GtkVBox {
|
|||||||
public function set_icon($col, $cell, $model, $iter)
|
public function set_icon($col, $cell, $model, $iter)
|
||||||
{
|
{
|
||||||
$col->set_reorderable(TRUE);
|
$col->set_reorderable(TRUE);
|
||||||
$info = $this->model->get_value($iter, 0);
|
$info = $model->get_value($iter, 0);
|
||||||
$db_type = strtolower($info->type);
|
$db_type = strtolower($info->type);
|
||||||
$img_file = BASE_DIR."/images/{$db_type}-logo-32.png";
|
$img_file = BASE_DIR."/images/{$db_type}-logo-32.png";
|
||||||
|
|
||||||
@ -154,7 +153,7 @@ class Connection_Sidebar extends GtkVBox {
|
|||||||
public function set_label($col, $cell, $model, $iter)
|
public function set_label($col, $cell, $model, $iter)
|
||||||
{
|
{
|
||||||
$col->set_reorderable(TRUE);
|
$col->set_reorderable(TRUE);
|
||||||
$info = $this->model->get_value($iter, 0);
|
$info = $model->get_value($iter, 0);
|
||||||
$cell->set_property('text', $info->name);
|
$cell->set_property('text', $info->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,25 @@
|
|||||||
*/
|
*/
|
||||||
class DB_tabs extends GTKNotebook {
|
class DB_tabs extends GTKNotebook {
|
||||||
|
|
||||||
|
private static $instance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the db tabs object if it exists, or create and return
|
||||||
|
*
|
||||||
|
* @return DB_tabs
|
||||||
|
*/
|
||||||
|
public static function &get_instance()
|
||||||
|
{
|
||||||
|
if (empty(self::$instance))
|
||||||
|
{
|
||||||
|
self::$instance = new DB_tabs();
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the object
|
* Create the object
|
||||||
*/
|
*/
|
||||||
@ -49,5 +68,19 @@ class DB_tabs extends GTKNotebook {
|
|||||||
$this->append_page($widget, new GtkLabel($label));
|
$this->append_page($widget, new GtkLabel($label));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance of this class, and destroys the existing
|
||||||
|
* instance
|
||||||
|
*
|
||||||
|
* @return DB_tabs
|
||||||
|
*/
|
||||||
|
public function reset()
|
||||||
|
{
|
||||||
|
unset(self::$instance);
|
||||||
|
return self::get_instance();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// End of db_tabs.php
|
// End of db_tabs.php
|
||||||
|
Loading…
Reference in New Issue
Block a user