Remove edit main menu item, and implement functionality in the context menu
This commit is contained in:
@@ -32,6 +32,111 @@ namespace GridProxyGUI
|
||||
ShowAll();
|
||||
}
|
||||
|
||||
protected void ShowContext()
|
||||
{
|
||||
var selected = Selection.GetSelectedRows();
|
||||
if (selected.Length < 1) return;
|
||||
|
||||
Menu context = new Menu();
|
||||
|
||||
MenuItem item = new MenuItem("Remove");
|
||||
item.Activated += (sender, e) =>
|
||||
{
|
||||
foreach (var p in selected)
|
||||
{
|
||||
TreeIter iter;
|
||||
if (Messages.GetIter(out iter, p))
|
||||
{
|
||||
Messages.Remove(ref iter);
|
||||
}
|
||||
}
|
||||
Selection.UnselectAll();
|
||||
};
|
||||
context.Add(item);
|
||||
|
||||
item = new MenuItem("Remove All");
|
||||
item.Activated += (sender, e) =>
|
||||
{
|
||||
Selection.UnselectAll();
|
||||
Messages.Clear();
|
||||
};
|
||||
context.Add(item);
|
||||
|
||||
context.Add(new SeparatorMenuItem());
|
||||
|
||||
item = new MenuItem("Select All");
|
||||
item.Activated += (sender, e) =>
|
||||
{
|
||||
Selection.SelectAll();
|
||||
};
|
||||
context.Add(item);
|
||||
|
||||
item = new MenuItem("Deselect");
|
||||
item.Activated += (sender, e) =>
|
||||
{
|
||||
Selection.UnselectAll();
|
||||
};
|
||||
context.Add(item);
|
||||
|
||||
context.Add(new SeparatorMenuItem());
|
||||
|
||||
item = new MenuItem("Copy");
|
||||
item.Activated += (sender, e) =>
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
foreach (var p in selected)
|
||||
{
|
||||
TreeIter iter;
|
||||
if (Messages.GetIter(out iter, p))
|
||||
{
|
||||
var session = Messages.GetValue(iter, 0) as Session;
|
||||
if (session != null)
|
||||
{
|
||||
sb.AppendLine(string.Join(" | ", session.Columns));
|
||||
}
|
||||
}
|
||||
|
||||
Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false)).Text = sb.ToString().TrimEnd();
|
||||
}
|
||||
};
|
||||
context.Add(item);
|
||||
|
||||
context.ShowAll();
|
||||
context.Popup();
|
||||
}
|
||||
|
||||
protected override bool OnButtonPressEvent(Gdk.EventButton evnt)
|
||||
{
|
||||
if (evnt.Type == Gdk.EventType.ButtonPress && evnt.Button == 3) // right click press
|
||||
{
|
||||
TreePath path;
|
||||
if (GetPathAtPos((int)evnt.X, (int)evnt.Y, out path))
|
||||
{
|
||||
bool amISelected = false;
|
||||
foreach (var p in Selection.GetSelectedRows())
|
||||
{
|
||||
if (p.Compare(path) == 0)
|
||||
{
|
||||
amISelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!amISelected)
|
||||
{
|
||||
Selection.UnselectAll();
|
||||
Selection.SelectPath(path);
|
||||
}
|
||||
}
|
||||
|
||||
ShowContext();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnButtonPressEvent(evnt);
|
||||
}
|
||||
|
||||
void CellDataFunc(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
|
||||
{
|
||||
var item = model.GetValue(iter, 0) as Session;
|
||||
|
||||
Reference in New Issue
Block a user