diff --git a/sys/common/data_grid.php b/sys/common/data_grid.php index a593cc4..be51e97 100644 --- a/sys/common/data_grid.php +++ b/sys/common/data_grid.php @@ -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 */ - 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 */ - public function reset($model = null) + public function reset() { $this->model->clear(); diff --git a/sys/common/settings.php b/sys/common/settings.php index 4b2ee8b..f0d881d 100644 --- a/sys/common/settings.php +++ b/sys/common/settings.php @@ -72,7 +72,11 @@ class Settings { */ 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); } // -------------------------------------------------------------------------- diff --git a/sys/windows/widgets/connection_sidebar.php b/sys/windows/widgets/connection_sidebar.php index dec4057..16f4d20 100644 --- a/sys/windows/widgets/connection_sidebar.php +++ b/sys/windows/widgets/connection_sidebar.php @@ -219,6 +219,8 @@ class Connection_Sidebar extends GtkVBox { * * @param array $pos * @param object $event + * @param object $col + * @param array $all * @return void */ public function conn_popup_menu($pos, $event, $col, $all) @@ -273,15 +275,21 @@ class Connection_Sidebar extends GtkVBox { * * @return void */ - public function remove_connection($col) + public function remove_connection() { if ( ! confirm("Are you sure you want to remove this database connection?")) { return; } - //@todo implement - $model = $this->treeview->get_model(); + // Get the data from the model for the current selection + $data = $this->treeview->get(0); + + // Remove the connection from the settings + $this->settings->remove_db($data->name); + + // Refresh the sidebar + $this->refresh(); } // --------------------------------------------------------------------------