void OnNotebooksTreeButtonPressed (object sender, Gtk.ButtonPressEventArgs args)
{
switch (args.Event.Button) {
case 3: // third mouse button (right-click)
Notebooks.Notebook notebook = GetSelectedNotebook ();
if (notebook == null)
return; // Don't pop open a submenu
Gtk.TreePath path = null;
Gtk.TreeViewColumn column = null;
bool rowClicked = true;
if (notebooksTree.GetPathAtPos ((int) args.Event.X,
(int) args.Event.Y, out path, out column) == false)
rowClicked = false;
Gtk.TreeSelection selection = notebooksTree.Selection;
if (selection.CountSelectedRows () == 0)
rowClicked = false;
Gtk.Menu menu = null;
if (rowClicked)
menu = Tomboy.ActionManager.GetWidget (
"/NotebooksTreeContextMenu") as Gtk.Menu;
else
menu = Tomboy.ActionManager.GetWidget (
"/NotebooksTreeNoRowContextMenu") as Gtk.Menu;
PopupContextMenuAtLocation (menu,
(int) args.Event.X,
(int) args.Event.Y);
break;
}
}