Move resources into their own folder, mac menu improvements

This commit is contained in:
Timothy Warren 2012-06-06 16:26:06 -04:00
parent 19e02e1349
commit 152a10d6b3
13 changed files with 126 additions and 117 deletions

View File

@ -1,4 +1,3 @@
#!/usr/bin/env php
<?php <?php
/** /**
* OpenSQLManager * OpenSQLManager
@ -33,6 +32,7 @@ ini_set('memory_limit', -1);
// Set the current directory as the base for included files // Set the current directory as the base for included files
define('BASE_DIR', __DIR__.'/sys'); define('BASE_DIR', __DIR__.'/sys');
define('RESOURCE_DIR', __DIR__.'/resources');
define('SETTINGS_DIR', __DIR__); define('SETTINGS_DIR', __DIR__);
define('PROGRAM_NAME', 'OpenSQLManager'); define('PROGRAM_NAME', 'OpenSQLManager');
define('VERSION', '0.2.0pre'); define('VERSION', '0.2.0pre');
@ -190,6 +190,9 @@ $app = new OpenSQLManager();
// Create platform information object // Create platform information object
$platform = new \wxPlatformInfo(); $platform = new \wxPlatformInfo();
// Define the platform for later use
define('PLATFORM', $platform->GetOperatingSystemId());
// Start the wx event loop // Start the wx event loop
\wxApp::SetInstance($app); \wxApp::SetInstance($app);
\wxEntry(); \wxEntry();

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 946 B

After

Width:  |  Height:  |  Size: 946 B

View File

@ -124,7 +124,7 @@ class Connection_Sidebar extends \wxPanel {
*/ */
public function menu($event) public function menu($event)
{ {
if ($this->list->GetSelectedItemCount() === 1) if ($this->list->GetSelectedItemCount() > 0)
{ {
// Create the menu items // Create the menu items
$menu = new \wxMenu(); $menu = new \wxMenu();

View File

@ -39,13 +39,13 @@ class Connection_Manager extends \wxFrame {
* *
* @var array * @var array
*/ */
protected $fields = array(); protected $fields = array();
/** /**
* Array of labels for Connection Information manipulation * Array of labels for Connection Information manipulation
* *
* @var array * @var array
*/ */
protected $labels = array(); protected $labels = array();
/** /**
@ -56,7 +56,7 @@ class Connection_Manager extends \wxFrame {
*/ */
public function __construct($parent, $params = array()) 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 // Save a reference to the settings class
$this->settings =& Settings::get_instance(); $this->settings =& Settings::get_instance();
@ -105,16 +105,16 @@ class Connection_Manager extends \wxFrame {
'Password' => new \wxTextCtrl($this, self::TXT_DB_PASS) 'Password' => new \wxTextCtrl($this, self::TXT_DB_PASS)
); );
$choice->Create($this, self::COMBO_DB_TYPE, wxDefaultPosition, wxDefaultSize, $db_types); $choice->Create($this, self::COMBO_DB_TYPE, wxDefaultPosition, wxDefaultSize, $db_types);
// Enable hiding/showing of controls based on choice // Enable hiding/showing of controls based on choice
$choice->Connect(wxEVT_COMMAND_CHOICE_SELECTED, array($this, 'change_db')); $choice->Connect(wxEVT_COMMAND_CHOICE_SELECTED, array($this, 'change_db'));
// Add the controls to the sizer // Add the controls to the sizer
$i = 1; $i = 1;
foreach ($this->fields as $lbl => $ctrl) 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); $this->labels[$lbl] = new \wxStaticText($this, $i, $lbl);
$sizer->Add($this->labels[$lbl], 0, wxALIGN_LEFT); $sizer->Add($this->labels[$lbl], 0, wxALIGN_LEFT);
@ -168,7 +168,7 @@ class Connection_Manager extends \wxFrame {
continue; continue;
} }
// Use the ibase_functions over PDO::Firebird, at least for now // Use the ibase_functions over PDO::Firebird
if ($d === 'firebird') if ($d === 'firebird')
{ {
continue; continue;
@ -198,7 +198,7 @@ class Connection_Manager extends \wxFrame {
/** /**
* Adds a connection to the connection manager * Adds a connection to the connection manager
* *
* @param wxCommandEvent * @param wxCommandEvent
* @return void * @return void
*/ */
@ -219,66 +219,71 @@ class Connection_Manager extends \wxFrame {
/** /**
* Set defaults for new database type * Set defaults for new database type
* *
* @param wxCommandEvent * @param wxCommandEvent
* @return void * @return void
*/ */
public function change_db($event) public function change_db($event)
{ {
$db = strtolower($event->GetString()); $db = strtolower($event->GetString());
$sizer = $this->GetSizer(); $sizer = $this->GetSizer();
$fields =& $this->fields; $fields =& $this->fields;
// Set defaults // Set defaults
$this->_show(array( $this->_show(array(
'Host', 'Host',
'Database Name', 'Database Name',
'Port', 'Port',
'User', 'User',
'Password' 'Password'
)); ));
$this->_hide(array('Database File')); $this->_hide(array('Database File'));
$fields['Password']->SetValue(''); $fields['User']->SetValue('');
$fields['Database Name']->SetValue(''); $fields['Port']->SetValue('');
$fields['Host']->SetValue('127.0.0.1'); $fields['Password']->SetValue('');
$fields['Database Name']->SetValue('');
// Set db-specific defaults $fields['Host']->SetValue('127.0.0.1');
switch($db)
{ // Set db-specific defaults
case "mysql": switch($db)
$fields['User']->SetValue('root'); {
$fields['Port']->SetValue('3306'); case "mysql":
break; $fields['User']->SetValue('root');
$fields['Port']->SetValue('3306');
case "postgresql": break;
$fields['User']->SetValue('postgres');
$fields['Port']->SetValue('5432'); case "postgresql":
break; $fields['User']->SetValue('postgres');
$fields['Port']->SetValue('5432');
case "firebird": break;
$fields['User']->SetValue('sysdba');
$fields['Password']->SetValue('masterkey'); case "firebird":
$fields['Port']->SetValue(''); $fields['User']->SetValue('sysdba');
$this->_show(array('Database File')); $fields['Password']->SetValue('masterkey');
$this->_hide(array('Database Name')); $fields['Port']->SetValue('');
break; $this->_show(array('Database File'));
$this->_hide(array(
case "sqlite": 'Database Name',
$this->_show(array('Database File')); 'Port'
));
$this->_hide(array( break;
'Database Name',
'Port', case "sqlite":
'Host', $this->_show(array('Database File'));
'User',
'Password' $this->_hide(array(
)); 'Database Name',
break; 'Port',
} 'Host',
'User',
// Resize the window to fit the controls 'Password'
));
break;
}
// Resize the window to fit the controls
$sizer->Fit($this); $sizer->Fit($this);
} }
@ -294,7 +299,7 @@ class Connection_Manager extends \wxFrame {
// Get the connection parameters // Get the connection parameters
$params = $this->_get_vals(); $params = $this->_get_vals();
// Smart alek error for smart alek behavior // Smart aleck error for smart aleck behavior
if (empty($params->type)) if (empty($params->type))
{ {
error("You need to select the correct database type"); error("You need to select the correct database type");
@ -348,44 +353,44 @@ class Connection_Manager extends \wxFrame {
$params->pass = $fields['Password']->GetValue(); $params->pass = $fields['Password']->GetValue();
return $params; return $params;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Hides a list of elements * Hides a list of elements
* *
* @param array * @param array
*/ */
private function _hide($ctrls) private function _hide($ctrls)
{ {
$f =& $this->fields; $f =& $this->fields;
$l =& $this->labels; $l =& $this->labels;
foreach($ctrls as $c) foreach($ctrls as $c)
{ {
$f[$c]->Hide(); $f[$c]->Hide();
$l[$c]->Hide(); $l[$c]->Hide();
} }
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Shows a list of elements * Shows a list of elements
* *
* @param array * @param array
*/ */
private function _show($ctrls) private function _show($ctrls)
{ {
$f =& $this->fields; $f =& $this->fields;
$l =& $this->labels; $l =& $this->labels;
foreach($ctrls as $c) foreach($ctrls as $c)
{ {
$f[$c]->Show(); $f[$c]->Show();
$l[$c]->Show(); $l[$c]->Show();
} }
} }
} }

View File

@ -106,7 +106,7 @@ class Main extends \wxFrame {
$dlg->SetWebSite('https://github.com/aviat4ion/OpenSQLManager','Fork on Github'); $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( $dlg->SetDevelopers(array(
'Timothy J. Warren', 'Timothy J. Warren',
@ -163,8 +163,8 @@ class Main extends \wxFrame {
// File Menu // File Menu
{ {
// Set up the quit item // Set up the quit item
$top_file_menu->Append(2, "&Quit", "Exit the program"); $top_file_menu->Append(wxID_EXIT, "&Quit\tCtrl+Q", "Exit the program");
$this->Connect(2, wxEVT_COMMAND_MENU_SELECTED, array($this, "quit")); $this->Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, array($this, "quit"));
// Add the top level menu to the menubar // Add the top level menu to the menubar
$menu_bar->Append($top_file_menu, "&File"); $menu_bar->Append($top_file_menu, "&File");
@ -173,11 +173,12 @@ class Main extends \wxFrame {
// Help Menu // Help Menu
{ {
// Set up the about item // Set up the about item
$top_help_menu->Append(4, "&About", "About this program"); $top_help_menu->Append(wxID_ABOUT, "&About", "About this program");
$this->Connect(4, wxEVT_COMMAND_MENU_SELECTED, array($this, "about")); $this->Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, array($this, "about"));
// Add the top level menu to the menubar // Add the top level menu to the menubar
$menu_bar->Append($top_help_menu, "&Help"); $menu_bar->Append($top_help_menu, "&Help");
} }