2012-01-26 16:09:05 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* OpenSQLManager
|
|
|
|
*
|
|
|
|
* Free Database manager for Open Source Databases
|
|
|
|
*
|
|
|
|
* @author Timothy J. Warren
|
|
|
|
* @copyright Copyright (c) 2012
|
|
|
|
* @link https://github.com/aviat4ion/OpenSQLManager
|
|
|
|
* @license http://philsturgeon.co.uk/code/dbad-license
|
|
|
|
*/
|
2012-01-27 16:57:59 -05:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Main Window Class
|
|
|
|
*
|
|
|
|
* Creates and displays the main interface window
|
|
|
|
*/
|
2012-01-26 16:09:05 -05:00
|
|
|
class Main extends GtkWindow {
|
|
|
|
|
2012-01-27 16:57:59 -05:00
|
|
|
private $main_vbox, $main_hbox;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and display the main window on startup
|
|
|
|
*/
|
2012-01-26 16:09:05 -05:00
|
|
|
function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
2012-01-27 11:57:13 -05:00
|
|
|
|
2012-01-27 16:57:59 -05:00
|
|
|
//Layout the interface
|
|
|
|
$this->_main_layout();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Layout the main interface
|
|
|
|
*
|
|
|
|
* Create menus, hboxes, vboxs and other widgets
|
|
|
|
*/
|
|
|
|
private function _main_layout()
|
|
|
|
{
|
2012-01-27 11:57:13 -05:00
|
|
|
$this->set_title('OpenSQLManager');
|
|
|
|
|
|
|
|
// Quit when this window is closed
|
|
|
|
$this->connect_simple('destroy', array('gtk', 'main_quit'));
|
2012-01-27 16:57:59 -05:00
|
|
|
|
|
|
|
// Main Vbox that everything is contained in
|
|
|
|
$main_vbox = new GTKVBox();
|
|
|
|
|
|
|
|
// Main Hbox for columns
|
|
|
|
$main_hbox = new GTKHBox();
|
|
|
|
|
|
|
|
// Add the menubar
|
|
|
|
$main_vbox->pack_start($this->_create_menu(), FALSE, FALSE);
|
|
|
|
|
2012-01-30 11:22:44 -05:00
|
|
|
// Add the toolbar
|
|
|
|
//$main_vbox->pack_start($this->_create_toolbar(), FALSE, FALSE);
|
|
|
|
|
|
|
|
// Add the info box
|
|
|
|
$main_vbox->pack_start($this->_create_infobox(), FALSE, FALSE);
|
|
|
|
|
2012-01-27 16:57:59 -05:00
|
|
|
// Add the main interface area hbox
|
|
|
|
$main_vbox->pack_start($main_hbox, FALSE, FALSE);
|
|
|
|
|
|
|
|
// Add the Vbox, and show the window
|
|
|
|
$this->add($main_vbox);
|
|
|
|
$this->show_all();
|
2012-01-26 16:09:05 -05:00
|
|
|
}
|
|
|
|
|
2012-01-30 11:22:44 -05:00
|
|
|
/**
|
|
|
|
* Create the main toolbar
|
|
|
|
*
|
|
|
|
* @return GtkToolBar
|
|
|
|
*/
|
|
|
|
private function _create_toolbar()
|
|
|
|
{
|
|
|
|
$tbar = new GtkToolBar();
|
|
|
|
|
|
|
|
$open = new GtkToolButton();
|
|
|
|
$open->set_stock_id(Gtk::STOCK_OPEN);
|
|
|
|
|
|
|
|
$tbar->insert($open);
|
|
|
|
|
|
|
|
return $tbar;
|
|
|
|
}
|
|
|
|
|
2012-01-27 16:57:59 -05:00
|
|
|
/**
|
|
|
|
* Create the menu for the program
|
|
|
|
*
|
|
|
|
* @return GtkMenuBar
|
|
|
|
*/
|
|
|
|
private function _create_menu()
|
|
|
|
{
|
|
|
|
//Menu Bar
|
|
|
|
$menu_bar = new GtkMenuBar();
|
|
|
|
|
|
|
|
//Menu Bar Top Items
|
|
|
|
$top_file_menu = new GtkMenuItem('_File');
|
|
|
|
$top_help_menu = new GtkMenuItem('_Help');
|
|
|
|
|
|
|
|
//Add sub Menus to top items
|
|
|
|
$file_menu = new GtkMenu();
|
|
|
|
$top_file_menu->set_submenu($file_menu);
|
|
|
|
$help_menu = new GtkMenu();
|
|
|
|
$top_help_menu->set_submenu($help_menu);
|
|
|
|
|
|
|
|
|
|
|
|
//File Menu
|
|
|
|
{
|
2012-01-30 11:22:44 -05:00
|
|
|
//Set up the open item
|
|
|
|
$open = new GtkImageMenuItem(GTK::STOCK_OPEN);
|
|
|
|
$file_menu->append($open);
|
|
|
|
|
2012-01-27 16:57:59 -05:00
|
|
|
//Set up the quit item
|
|
|
|
$quit = new GtkImageMenuItem(GTK::STOCK_QUIT);
|
|
|
|
$quit->connect_simple('activate', array($this, 'quit'));
|
2012-01-27 21:19:39 -05:00
|
|
|
$file_menu->append($quit);
|
2012-01-27 16:57:59 -05:00
|
|
|
|
|
|
|
// Add the top level menu to the menubar
|
|
|
|
$menu_bar->append($top_file_menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Help Menu
|
|
|
|
{
|
|
|
|
//Set up the about item
|
|
|
|
$about = new GtkImageMenuItem(GTK::STOCK_ABOUT);
|
|
|
|
$about->connect_simple('activate', array($this, 'about'));
|
|
|
|
$help_menu->append($about);
|
|
|
|
|
|
|
|
// Add the top level menu to the menubar
|
|
|
|
$menu_bar->append($top_help_menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $menu_bar;
|
|
|
|
}
|
|
|
|
|
2012-01-30 11:22:44 -05:00
|
|
|
/**
|
|
|
|
* Display Info box for errors/message
|
|
|
|
*/
|
|
|
|
function _create_infobox()
|
|
|
|
{
|
|
|
|
$this->infobar = new GtkInfoBar();
|
|
|
|
$this->messagelabel = new GtkLabel('Welcome to OpenSQLManager!');
|
|
|
|
$contentarea = $this->infobar->get_content_area();
|
|
|
|
$contentarea->add($this->messagelabel);
|
|
|
|
$this->infobar->add_button(GTK::STOCK_OK, GTK::RESPONSE_OK);
|
|
|
|
$this->infobar->connect_simple('response', array($this->infobar, 'hide'));
|
|
|
|
|
|
|
|
return ($this->infobar);
|
|
|
|
}
|
|
|
|
|
2012-01-27 16:57:59 -05:00
|
|
|
/**
|
|
|
|
* Display About menu with version information
|
|
|
|
*/
|
|
|
|
function about()
|
|
|
|
{
|
2012-01-27 21:19:39 -05:00
|
|
|
$dlg = new GtkAboutDialog();
|
2012-01-30 09:48:55 -05:00
|
|
|
$dlg->set_transient_for($this);
|
2012-01-27 16:57:59 -05:00
|
|
|
|
2012-01-30 09:48:55 -05:00
|
|
|
$dlg->set_program_name($this->get_title());
|
2012-01-27 21:19:39 -05:00
|
|
|
$dlg->set_version('0.0.1pre');
|
|
|
|
|
|
|
|
$dlg->set_copyright("Copyright (c) ".date('Y')." Timothy J. Warren");
|
|
|
|
|
|
|
|
$dlg->set_website('https://github.com/aviat4ion/OpenSQLManager');
|
|
|
|
|
|
|
|
$dlg->run();
|
2012-01-30 09:48:55 -05:00
|
|
|
|
|
|
|
$dlg->destroy();
|
2012-01-27 16:57:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Quits the GTK loop
|
|
|
|
*/
|
|
|
|
function quit()
|
|
|
|
{
|
|
|
|
Gtk::main_quit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// End of main.php
|