Remove edit main menu item, and implement functionality in the context menu

This commit is contained in:
Latif Khalifa
2013-12-04 19:34:20 +01:00
parent 26d3d2b07a
commit ec79b8d069
5 changed files with 111 additions and 131 deletions

View File

@@ -87,6 +87,8 @@ public partial class MainWindow
messages.Messages.AppendValues(session);
}
}
SessionFileName = fileName;
}
}
catch { }

View File

@@ -442,6 +442,8 @@ public partial class MainWindow : Gtk.Window
void SetVisibility()
{
tabsMain.Page = 2;
var w1 = vboxInspector.Children.GetValue(0) as Widget;
var w2 = vboxInspector.Children.GetValue(1) as Widget;

View File

@@ -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;

View File

@@ -6,22 +6,11 @@ public partial class MainWindow
private global::Gtk.UIManager UIManager;
private global::Gtk.Action FileAction;
private global::Gtk.Action ExitAction;
private global::Gtk.Action EditAction;
private global::Gtk.Action HelpAction;
private global::Gtk.Action AboutAction;
private global::Gtk.Action RemoveAction;
private global::Gtk.Action SelectAction;
private global::Gtk.Action AllAction;
private global::Gtk.Action AllAction1;
private global::Gtk.Action SelectedAction;
private global::Gtk.Action FindAction;
private global::Gtk.Action OpenAction;
private global::Gtk.Action SaveAction;
private global::Gtk.Action SaveAsAction;
private global::Gtk.Action InvertAction;
private global::Gtk.Action NoneAction;
private global::Gtk.Action CopyAction;
private global::Gtk.Action UnselectedAction;
private global::Gtk.VBox vboxMenuMain;
private global::Gtk.HBox hboxMenu;
private global::Gtk.Alignment alignment2;
@@ -109,33 +98,12 @@ public partial class MainWindow
this.ExitAction = new global::Gtk.Action ("ExitAction", global::Mono.Unix.Catalog.GetString ("Exit"), null, null);
this.ExitAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Exit");
w1.Add (this.ExitAction, "<Control>q");
this.EditAction = new global::Gtk.Action ("EditAction", global::Mono.Unix.Catalog.GetString ("Edit"), null, null);
this.EditAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Edit");
w1.Add (this.EditAction, null);
this.HelpAction = new global::Gtk.Action ("HelpAction", global::Mono.Unix.Catalog.GetString ("Help"), null, null);
this.HelpAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Help");
w1.Add (this.HelpAction, null);
this.AboutAction = new global::Gtk.Action ("AboutAction", global::Mono.Unix.Catalog.GetString ("About"), global::Mono.Unix.Catalog.GetString ("Shows the wonderful creator info"), null);
this.AboutAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("About");
w1.Add (this.AboutAction, null);
this.RemoveAction = new global::Gtk.Action ("RemoveAction", global::Mono.Unix.Catalog.GetString ("Remove"), null, null);
this.RemoveAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Remove");
w1.Add (this.RemoveAction, null);
this.SelectAction = new global::Gtk.Action ("SelectAction", global::Mono.Unix.Catalog.GetString ("Select"), null, null);
this.SelectAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Select");
w1.Add (this.SelectAction, null);
this.AllAction = new global::Gtk.Action ("AllAction", global::Mono.Unix.Catalog.GetString ("All"), null, null);
this.AllAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("All");
w1.Add (this.AllAction, null);
this.AllAction1 = new global::Gtk.Action ("AllAction1", global::Mono.Unix.Catalog.GetString ("All"), null, null);
this.AllAction1.ShortLabel = global::Mono.Unix.Catalog.GetString ("All");
w1.Add (this.AllAction1, null);
this.SelectedAction = new global::Gtk.Action ("SelectedAction", global::Mono.Unix.Catalog.GetString ("Selected"), null, null);
this.SelectedAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Selected");
w1.Add (this.SelectedAction, null);
this.FindAction = new global::Gtk.Action ("FindAction", global::Mono.Unix.Catalog.GetString ("Find"), null, null);
this.FindAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Find (Ctrl-F)");
w1.Add (this.FindAction, "<Control>f");
this.OpenAction = new global::Gtk.Action ("OpenAction", global::Mono.Unix.Catalog.GetString ("Open.."), null, null);
this.OpenAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Open Session...");
w1.Add (this.OpenAction, "<Control>o");
@@ -145,18 +113,6 @@ public partial class MainWindow
this.SaveAsAction = new global::Gtk.Action ("SaveAsAction", global::Mono.Unix.Catalog.GetString ("Save As..."), null, null);
this.SaveAsAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Save Session As...");
w1.Add (this.SaveAsAction, null);
this.InvertAction = new global::Gtk.Action ("InvertAction", global::Mono.Unix.Catalog.GetString ("Invert"), null, null);
this.InvertAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Invert");
w1.Add (this.InvertAction, null);
this.NoneAction = new global::Gtk.Action ("NoneAction", global::Mono.Unix.Catalog.GetString ("None"), null, null);
this.NoneAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("None");
w1.Add (this.NoneAction, null);
this.CopyAction = new global::Gtk.Action ("CopyAction", global::Mono.Unix.Catalog.GetString ("Copy"), null, null);
this.CopyAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Copy");
w1.Add (this.CopyAction, "<Primary>c");
this.UnselectedAction = new global::Gtk.Action ("UnselectedAction", global::Mono.Unix.Catalog.GetString ("Unselected"), null, null);
this.UnselectedAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Unselected");
w1.Add (this.UnselectedAction, null);
this.UIManager.InsertActionGroup (w1, 0);
this.AddAccelGroup (this.UIManager.AccelGroup);
this.Name = "MainWindow";
@@ -177,7 +133,7 @@ public partial class MainWindow
this.alignment2 = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F);
this.alignment2.Name = "alignment2";
// Container child alignment2.Gtk.Container+ContainerChild
this.UIManager.AddUiFromString (@"<ui><menubar name='menuMain'><menu name='FileAction' action='FileAction'><menuitem name='OpenAction' action='OpenAction'/><menuitem name='SaveAction' action='SaveAction'/><menuitem name='SaveAsAction' action='SaveAsAction'/><separator/><menuitem name='ExitAction' action='ExitAction'/></menu><menu name='EditAction' action='EditAction'><menu name='RemoveAction' action='RemoveAction'><menuitem name='AllAction1' action='AllAction1'/><menuitem name='SelectedAction' action='SelectedAction'/><menuitem name='UnselectedAction' action='UnselectedAction'/></menu><menu name='SelectAction' action='SelectAction'><menuitem name='AllAction' action='AllAction'/><menuitem name='InvertAction' action='InvertAction'/><menuitem name='NoneAction' action='NoneAction'/></menu><separator/><menuitem name='CopyAction' action='CopyAction'/></menu><menu name='HelpAction' action='HelpAction'><menuitem name='AboutAction' action='AboutAction'/></menu></menubar></ui>");
this.UIManager.AddUiFromString (@"<ui><menubar name='menuMain'><menu name='FileAction' action='FileAction'><menuitem name='OpenAction' action='OpenAction'/><menuitem name='SaveAction' action='SaveAction'/><menuitem name='SaveAsAction' action='SaveAsAction'/><separator/><menuitem name='ExitAction' action='ExitAction'/></menu><menu name='HelpAction' action='HelpAction'><menuitem name='AboutAction' action='AboutAction'/></menu></menubar></ui>");
this.menuMain = ((global::Gtk.MenuBar)(this.UIManager.GetWidget ("/menuMain")));
this.menuMain.Name = "menuMain";
this.alignment2.Add (this.menuMain);
@@ -279,7 +235,7 @@ public partial class MainWindow
this.mainSplit = new global::Gtk.HPaned ();
this.mainSplit.CanFocus = true;
this.mainSplit.Name = "mainSplit";
this.mainSplit.Position = 400;
this.mainSplit.Position = 1;
// Container child mainSplit.Gtk.Paned+PanedChild
this.vboxSessions = new global::Gtk.VBox ();
this.vboxSessions.Name = "vboxSessions";
@@ -725,16 +681,9 @@ public partial class MainWindow
this.DeleteEvent += new global::Gtk.DeleteEventHandler (this.OnDeleteEvent);
this.ExitAction.Activated += new global::System.EventHandler (this.OnExitActionActivated);
this.AboutAction.Activated += new global::System.EventHandler (this.OnAboutActionActivated);
this.AllAction.Activated += new global::System.EventHandler (this.OnAllActionActivated);
this.AllAction1.Activated += new global::System.EventHandler (this.OnAllAction1Activated);
this.SelectedAction.Activated += new global::System.EventHandler (this.OnSelectedActionActivated);
this.OpenAction.Activated += new global::System.EventHandler (this.OnOpenActionActivated);
this.SaveAction.Activated += new global::System.EventHandler (this.OnSaveActionActivated);
this.SaveAsAction.Activated += new global::System.EventHandler (this.OnSaveAsActionActivated);
this.InvertAction.Activated += new global::System.EventHandler (this.OnInvertActionActivated);
this.NoneAction.Activated += new global::System.EventHandler (this.OnNoneActionActivated);
this.CopyAction.Activated += new global::System.EventHandler (this.OnCopyActionActivated);
this.UnselectedAction.Activated += new global::System.EventHandler (this.OnUnselectedActionActivated);
this.btnStart.Clicked += new global::System.EventHandler (this.OnBtnStartClicked);
this.cbAutoScroll.Toggled += new global::System.EventHandler (this.OnCbAutoScrollToggled);
this.cbSelectAllUDP.Toggled += new global::System.EventHandler (this.OnCbSelectAllUDPToggled);

View File

@@ -22,11 +22,6 @@
<property name="ShortLabel" translatable="yes">Exit</property>
<signal name="Activated" handler="OnExitActionActivated" />
</action>
<action id="EditAction">
<property name="Type">Action</property>
<property name="Label" translatable="yes">Edit</property>
<property name="ShortLabel" translatable="yes">Edit</property>
</action>
<action id="HelpAction">
<property name="Type">Action</property>
<property name="Label" translatable="yes">Help</property>
@@ -39,40 +34,6 @@
<property name="Tooltip" translatable="yes">Shows the wonderful creator info</property>
<signal name="Activated" handler="OnAboutActionActivated" />
</action>
<action id="RemoveAction">
<property name="Type">Action</property>
<property name="Label" translatable="yes">Remove</property>
<property name="ShortLabel" translatable="yes">Remove</property>
</action>
<action id="SelectAction">
<property name="Type">Action</property>
<property name="Label" translatable="yes">Select</property>
<property name="ShortLabel" translatable="yes">Select</property>
</action>
<action id="AllAction">
<property name="Type">Action</property>
<property name="Label" translatable="yes">All</property>
<property name="ShortLabel" translatable="yes">All</property>
<signal name="Activated" handler="OnAllActionActivated" />
</action>
<action id="AllAction1">
<property name="Type">Action</property>
<property name="Label" translatable="yes">All</property>
<property name="ShortLabel" translatable="yes">All</property>
<signal name="Activated" handler="OnAllAction1Activated" />
</action>
<action id="SelectedAction">
<property name="Type">Action</property>
<property name="Label" translatable="yes">Selected</property>
<property name="ShortLabel" translatable="yes">Selected</property>
<signal name="Activated" handler="OnSelectedActionActivated" />
</action>
<action id="FindAction">
<property name="Type">Action</property>
<property name="Accelerator">&lt;Control&gt;f</property>
<property name="Label" translatable="yes">Find</property>
<property name="ShortLabel" translatable="yes">Find (Ctrl-F)</property>
</action>
<action id="OpenAction">
<property name="Type">Action</property>
<property name="Accelerator">&lt;Control&gt;o</property>
@@ -93,31 +54,6 @@
<property name="ShortLabel" translatable="yes">Save Session As...</property>
<signal name="Activated" handler="OnSaveAsActionActivated" />
</action>
<action id="InvertAction">
<property name="Type">Action</property>
<property name="Label" translatable="yes">Invert</property>
<property name="ShortLabel" translatable="yes">Invert</property>
<signal name="Activated" handler="OnInvertActionActivated" />
</action>
<action id="NoneAction">
<property name="Type">Action</property>
<property name="Label" translatable="yes">None</property>
<property name="ShortLabel" translatable="yes">None</property>
<signal name="Activated" handler="OnNoneActionActivated" />
</action>
<action id="CopyAction">
<property name="Type">Action</property>
<property name="Accelerator">&lt;Primary&gt;c</property>
<property name="Label" translatable="yes">Copy</property>
<property name="ShortLabel" translatable="yes">Copy</property>
<signal name="Activated" handler="OnCopyActionActivated" />
</action>
<action id="UnselectedAction">
<property name="Type">Action</property>
<property name="Label" translatable="yes">Unselected</property>
<property name="ShortLabel" translatable="yes">Unselected</property>
<signal name="Activated" handler="OnUnselectedActionActivated" />
</action>
</action-group>
<property name="MemberName" />
<property name="Title" translatable="yes">Grid Proxy</property>
@@ -148,20 +84,6 @@
<node type="Separator" />
<node type="Menuitem" action="ExitAction" />
</node>
<node type="Menu" action="EditAction">
<node type="Menu" action="RemoveAction">
<node type="Menuitem" action="AllAction1" />
<node type="Menuitem" action="SelectedAction" />
<node type="Menuitem" action="UnselectedAction" />
</node>
<node type="Menu" action="SelectAction">
<node type="Menuitem" action="AllAction" />
<node type="Menuitem" action="InvertAction" />
<node type="Menuitem" action="NoneAction" />
</node>
<node type="Separator" />
<node type="Menuitem" action="CopyAction" />
</node>
<node type="Menu" action="HelpAction">
<node type="Menuitem" action="AboutAction" />
</node>