Beginning of right-click context menu

This commit is contained in:
Timothy Warren 2012-02-27 12:14:49 -05:00
parent 160e76ebf8
commit 2fefe6e949
2 changed files with 48 additions and 2 deletions

View File

@ -67,7 +67,7 @@ class SQLite_manip extends db_manip {
}
// Generate the sql for the creation of the table
$sql = "CREATE TABLE {$name} (";
$sql = "CREATE TABLE \"{$name}\" (";
$sql .= implode(",", $columns);
$sql .= ")";

View File

@ -14,7 +14,7 @@
class Connection_Sidebar extends GtkVBox {
protected $settings;
protected $settings, $menu;
public function __construct()
{
@ -63,6 +63,8 @@ class Connection_Sidebar extends GtkVBox {
$cell_renderer = new GtkCellRendererText();
$treeview->insert_column_with_data_func(1, 'Connection name', $cell_renderer, array(&$this, 'set_label'));
$treeview->connect('button-press-event', array(&$this, 'on_button'));
$selection = $treeview->get_selection();
$selection->set_mode(GTK::SELECTION_SINGLE);
@ -133,6 +135,50 @@ class Connection_Sidebar extends GtkVBox {
// --------------------------------------------------------------------------
/**
* Event for mouse clicks on connection sidebar
*
* @param GtkTreeView $view
* @param $event
* @return void
*/
public function on_button($view, $event)
{
// Right click
if($event->button == 3)
{
// get the row and column
$path_array = $view->get_path_at_pos($event->x, $event->y);
$path = $path_array[0][0];
$col = $path_array[1];
$col_title = $col->get_title();
}
$this->menu = $this->conn_popup_menu($path, $col_title, $event);
}
// --------------------------------------------------------------------------
/**
* Creates a context menu for the selected connection
*
* @param [type] $pos [description]
* @param [type] $title [description]
* @param [type] $event [description]
* @return [type]
*/
public function conn_popup_menu($pos, $title, $event)
{
$this->menu = new GtkMenu();
// Set up menu items
$this->menu->show_all();
$this->menu->popup();
}
// --------------------------------------------------------------------------
/**
* Remove a connection from the connection manager
*/