Remove DB works

This commit is contained in:
Timothy Warren 2012-03-30 13:09:38 -04:00
parent 53652d62b4
commit 069837ae35
3 changed files with 28 additions and 9 deletions

View File

@ -36,14 +36,21 @@ class Data_Grid extends GtkTreeView {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Get the value of the cell at the provided coordinate array * Get the value of the model for the current selection
* *
* @param array $coord * @param int pos
* @return mixed * @return mixed
*/ */
public function get(array $coord) public function get($pos = 0)
{ {
// @todo implement // Get the selection object of the row
$sel = $this->get_selection();
// Get the model and iterator for the selected row
list($model, $iter) = $sel->get_selected();
// Get the data from the model
return $model->get_value($iter, $pos);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -64,7 +71,7 @@ class Data_Grid extends GtkTreeView {
/** /**
* Empty the model * Empty the model
*/ */
public function reset($model = null) public function reset()
{ {
$this->model->clear(); $this->model->clear();

View File

@ -72,7 +72,11 @@ class Settings {
*/ */
public function __destruct() public function __destruct()
{ {
file_put_contents(SETTINGS_DIR . '/settings.json', json_encode($this->current)); $file_string = (defined('JSON_PRETTY_PRINT'))
? json_encode($this->current, JSON_PRETTY_PRINT)
: json_encode($this->current);
file_put_contents(SETTINGS_DIR . '/settings.json', $file_string);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------

View File

@ -219,6 +219,8 @@ class Connection_Sidebar extends GtkVBox {
* *
* @param array $pos * @param array $pos
* @param object $event * @param object $event
* @param object $col
* @param array $all
* @return void * @return void
*/ */
public function conn_popup_menu($pos, $event, $col, $all) public function conn_popup_menu($pos, $event, $col, $all)
@ -273,15 +275,21 @@ class Connection_Sidebar extends GtkVBox {
* *
* @return void * @return void
*/ */
public function remove_connection($col) public function remove_connection()
{ {
if ( ! confirm("Are you sure you want to remove this database connection?")) if ( ! confirm("Are you sure you want to remove this database connection?"))
{ {
return; return;
} }
//@todo implement // Get the data from the model for the current selection
$model = $this->treeview->get_model(); $data = $this->treeview->get(0);
// Remove the connection from the settings
$this->settings->remove_db($data->name);
// Refresh the sidebar
$this->refresh();
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------