diff --git a/OpenSQLManager.php b/OpenSQLManager.php index 92e5a08..261c491 100644 --- a/OpenSQLManager.php +++ b/OpenSQLManager.php @@ -1,4 +1,3 @@ -#!/usr/bin/env php GetOperatingSystemId()); + // Start the wx event loop \wxApp::SetInstance($app); \wxEntry(); diff --git a/sys/LICENSE b/resources/LICENSE similarity index 100% rename from sys/LICENSE rename to resources/LICENSE diff --git a/sys/images/firebird-logo-32.png b/resources/images/firebird-logo-32.png similarity index 100% rename from sys/images/firebird-logo-32.png rename to resources/images/firebird-logo-32.png diff --git a/sys/images/firebirdlogo32.xpm b/resources/images/firebirdlogo32.xpm similarity index 100% rename from sys/images/firebirdlogo32.xpm rename to resources/images/firebirdlogo32.xpm diff --git a/sys/images/mysql-logo-32.png b/resources/images/mysql-logo-32.png similarity index 100% rename from sys/images/mysql-logo-32.png rename to resources/images/mysql-logo-32.png diff --git a/sys/images/mysqllogo32.xpm b/resources/images/mysqllogo32.xpm similarity index 100% rename from sys/images/mysqllogo32.xpm rename to resources/images/mysqllogo32.xpm diff --git a/sys/images/postgresql-logo-32.png b/resources/images/postgresql-logo-32.png similarity index 100% rename from sys/images/postgresql-logo-32.png rename to resources/images/postgresql-logo-32.png diff --git a/sys/images/postgresqllogo32.xpm b/resources/images/postgresqllogo32.xpm similarity index 100% rename from sys/images/postgresqllogo32.xpm rename to resources/images/postgresqllogo32.xpm diff --git a/sys/images/sqlite-logo-32.png b/resources/images/sqlite-logo-32.png similarity index 100% rename from sys/images/sqlite-logo-32.png rename to resources/images/sqlite-logo-32.png diff --git a/sys/images/sqlitelogo32.xpm b/resources/images/sqlitelogo32.xpm similarity index 100% rename from sys/images/sqlitelogo32.xpm rename to resources/images/sqlitelogo32.xpm diff --git a/sys/widgets/connection_sidebar.php b/sys/widgets/connection_sidebar.php index 886ceeb..44d9a01 100644 --- a/sys/widgets/connection_sidebar.php +++ b/sys/widgets/connection_sidebar.php @@ -124,7 +124,7 @@ class Connection_Sidebar extends \wxPanel { */ public function menu($event) { - if ($this->list->GetSelectedItemCount() === 1) + if ($this->list->GetSelectedItemCount() > 0) { // Create the menu items $menu = new \wxMenu(); diff --git a/sys/windows/connection_manager.php b/sys/windows/connection_manager.php index 5e975f9..5421bc6 100644 --- a/sys/windows/connection_manager.php +++ b/sys/windows/connection_manager.php @@ -39,13 +39,13 @@ class Connection_Manager extends \wxFrame { * * @var array */ - protected $fields = array(); - - /** - * Array of labels for Connection Information manipulation - * - * @var array - */ + protected $fields = array(); + + /** + * Array of labels for Connection Information manipulation + * + * @var array + */ protected $labels = array(); /** @@ -56,7 +56,7 @@ class Connection_Manager extends \wxFrame { */ public function __construct($parent, $params = array()) { - parent::__construct($parent, 32, "Connection Manager", wxDefaultPosition); + parent::__construct($parent, 32, "Connection Manager", wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxSTAY_ON_TOP | wxRESIZE_BORDER); // Save a reference to the settings class $this->settings =& Settings::get_instance(); @@ -105,16 +105,16 @@ class Connection_Manager extends \wxFrame { 'Password' => new \wxTextCtrl($this, self::TXT_DB_PASS) ); - $choice->Create($this, self::COMBO_DB_TYPE, wxDefaultPosition, wxDefaultSize, $db_types); - - // Enable hiding/showing of controls based on choice + $choice->Create($this, self::COMBO_DB_TYPE, wxDefaultPosition, wxDefaultSize, $db_types); + + // Enable hiding/showing of controls based on choice $choice->Connect(wxEVT_COMMAND_CHOICE_SELECTED, array($this, 'change_db')); // Add the controls to the sizer $i = 1; foreach ($this->fields as $lbl => $ctrl) - { - // Add the label to the labels array for later manipulation + { + // Add the label to the labels array for later manipulation $this->labels[$lbl] = new \wxStaticText($this, $i, $lbl); $sizer->Add($this->labels[$lbl], 0, wxALIGN_LEFT); @@ -168,7 +168,7 @@ class Connection_Manager extends \wxFrame { continue; } - // Use the ibase_functions over PDO::Firebird, at least for now + // Use the ibase_functions over PDO::Firebird if ($d === 'firebird') { continue; @@ -198,7 +198,7 @@ class Connection_Manager extends \wxFrame { /** * Adds a connection to the connection manager - * + * * @param wxCommandEvent * @return void */ @@ -219,66 +219,71 @@ class Connection_Manager extends \wxFrame { /** * Set defaults for new database type - * + * * @param wxCommandEvent * @return void */ public function change_db($event) { - $db = strtolower($event->GetString()); - $sizer = $this->GetSizer(); - - $fields =& $this->fields; - - // Set defaults - $this->_show(array( - 'Host', - 'Database Name', - 'Port', - 'User', - 'Password' - )); - $this->_hide(array('Database File')); - - $fields['Password']->SetValue(''); - $fields['Database Name']->SetValue(''); - $fields['Host']->SetValue('127.0.0.1'); - - // Set db-specific defaults - switch($db) - { - case "mysql": - $fields['User']->SetValue('root'); - $fields['Port']->SetValue('3306'); - break; - - case "postgresql": - $fields['User']->SetValue('postgres'); - $fields['Port']->SetValue('5432'); - break; - - case "firebird": - $fields['User']->SetValue('sysdba'); - $fields['Password']->SetValue('masterkey'); - $fields['Port']->SetValue(''); - $this->_show(array('Database File')); - $this->_hide(array('Database Name')); - break; - - case "sqlite": - $this->_show(array('Database File')); - - $this->_hide(array( - 'Database Name', - 'Port', - 'Host', - 'User', - 'Password' - )); - break; - } - - // Resize the window to fit the controls + $db = strtolower($event->GetString()); + $sizer = $this->GetSizer(); + + $fields =& $this->fields; + + // Set defaults + $this->_show(array( + 'Host', + 'Database Name', + 'Port', + 'User', + 'Password' + )); + $this->_hide(array('Database File')); + + $fields['User']->SetValue(''); + $fields['Port']->SetValue(''); + $fields['Password']->SetValue(''); + $fields['Database Name']->SetValue(''); + $fields['Host']->SetValue('127.0.0.1'); + + // Set db-specific defaults + switch($db) + { + case "mysql": + $fields['User']->SetValue('root'); + $fields['Port']->SetValue('3306'); + break; + + case "postgresql": + $fields['User']->SetValue('postgres'); + $fields['Port']->SetValue('5432'); + break; + + case "firebird": + $fields['User']->SetValue('sysdba'); + $fields['Password']->SetValue('masterkey'); + $fields['Port']->SetValue(''); + $this->_show(array('Database File')); + $this->_hide(array( + 'Database Name', + 'Port' + )); + break; + + case "sqlite": + $this->_show(array('Database File')); + + $this->_hide(array( + 'Database Name', + 'Port', + 'Host', + 'User', + 'Password' + )); + break; + } + + // Resize the window to fit the controls $sizer->Fit($this); } @@ -294,7 +299,7 @@ class Connection_Manager extends \wxFrame { // Get the connection parameters $params = $this->_get_vals(); - // Smart alek error for smart alek behavior + // Smart aleck error for smart aleck behavior if (empty($params->type)) { error("You need to select the correct database type"); @@ -348,44 +353,44 @@ class Connection_Manager extends \wxFrame { $params->pass = $fields['Password']->GetValue(); return $params; - } - - // -------------------------------------------------------------------------- - - /** - * Hides a list of elements - * - * @param array - */ - private function _hide($ctrls) - { - $f =& $this->fields; - $l =& $this->labels; - - foreach($ctrls as $c) - { - $f[$c]->Hide(); - $l[$c]->Hide(); - } - } - - // -------------------------------------------------------------------------- - - /** - * Shows a list of elements - * - * @param array - */ - private function _show($ctrls) - { - $f =& $this->fields; - $l =& $this->labels; - - foreach($ctrls as $c) - { - $f[$c]->Show(); - $l[$c]->Show(); - } + } + + // -------------------------------------------------------------------------- + + /** + * Hides a list of elements + * + * @param array + */ + private function _hide($ctrls) + { + $f =& $this->fields; + $l =& $this->labels; + + foreach($ctrls as $c) + { + $f[$c]->Hide(); + $l[$c]->Hide(); + } + } + + // -------------------------------------------------------------------------- + + /** + * Shows a list of elements + * + * @param array + */ + private function _show($ctrls) + { + $f =& $this->fields; + $l =& $this->labels; + + foreach($ctrls as $c) + { + $f[$c]->Show(); + $l[$c]->Show(); + } } } diff --git a/sys/windows/main.php b/sys/windows/main.php index 1a428b0..b5cbae3 100644 --- a/sys/windows/main.php +++ b/sys/windows/main.php @@ -106,7 +106,7 @@ class Main extends \wxFrame { $dlg->SetWebSite('https://github.com/aviat4ion/OpenSQLManager','Fork on Github'); - $dlg->SetLicense(file_get_contents(BASE_DIR . "/LICENSE")); + $dlg->SetLicense(file_get_contents(RESOURCE_DIR . "/LICENSE")); $dlg->SetDevelopers(array( 'Timothy J. Warren', @@ -163,8 +163,8 @@ class Main extends \wxFrame { // File Menu { // Set up the quit item - $top_file_menu->Append(2, "&Quit", "Exit the program"); - $this->Connect(2, wxEVT_COMMAND_MENU_SELECTED, array($this, "quit")); + $top_file_menu->Append(wxID_EXIT, "&Quit\tCtrl+Q", "Exit the program"); + $this->Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, array($this, "quit")); // Add the top level menu to the menubar $menu_bar->Append($top_file_menu, "&File"); @@ -173,11 +173,12 @@ class Main extends \wxFrame { // Help Menu { // Set up the about item - $top_help_menu->Append(4, "&About", "About this program"); - $this->Connect(4, wxEVT_COMMAND_MENU_SELECTED, array($this, "about")); - + $top_help_menu->Append(wxID_ABOUT, "&About", "About this program"); + $this->Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, array($this, "about")); + // Add the top level menu to the menubar $menu_bar->Append($top_help_menu, "&Help"); + }