public VMView(MainController controller) : base() { this.controller = controller; HeadersVisible = false; cellTextLayoutFunc = new CellLayoutDataFunc (OnCellTextLayout); cellPixbufLayoutFunc = new CellLayoutDataFunc (OnCellPixbufLayout); AppendColumn ("icon", new CellRendererPixbuf (), cellPixbufLayoutFunc); AppendColumn ("machines", new CellRendererText (), cellTextLayoutFunc); EnableModelDragDest (new TargetEntry[] { new TargetEntry ("text/uri-list", 0, 0) }, Gdk.DragAction.Copy | Gdk.DragAction.Default); EnableModelDragSource (Gdk.ModifierType.Button1Mask, new TargetEntry[] { new TargetEntry ("text/uri-list", 0, 0) }, Gdk.DragAction.Copy | Gdk.DragAction.Default); this.DragDataGet += OnDragDataGet; this.DragDataReceived += OnDragDataReceived; }
public MainWindow() : base("Virtual Machine Manager") { IconThemeUtils.SetWindowIcon (this); manager = new VirtualMachineManager (); controller = new MainController (); controller.MainWindow = this; controller.Manager = manager; Glade.XML xml = new Glade.XML ("vmx-manager.glade", "mainContent"); xml.Autoconnect (this); noMachinesWidget = new Viewport (); noMachinesWidget.ShadowType = ShadowType.None; MessagePane pane = new MessagePane (); pane.HeaderIcon = IconThemeUtils.LoadIcon (48, "face-surprise", Stock.DialogInfo); pane.HeaderMarkup = Catalog.GetString ("<b>There are currently no virtual machines.</b>"); pane.Append (Catalog.GetString ("You can add or create a new virtual machine using the buttons on the left"), false); pane.Show (); noMachinesWidget.Add (pane); vmview = new VMView (controller); controller.VMView = vmview; vmmodel = new VMModel (manager); vmview.Model = vmmodel; treeContent.Add (vmview); Add (mainContent); ActionEntry[] actionList = { new ActionEntry ("Start", Stock.Execute, Catalog.GetString ("Start Machine"), "<control>r", Catalog.GetString ("Start the virtual machine"), controller.OnStart), new ActionEntry ("Configure", Stock.Properties, Catalog.GetString ("Configure Machine"), "<control>p", Catalog.GetString ("Configure the connected devices"), controller.OnConfigure), new ActionEntry ("Remove", Stock.Remove, Catalog.GetString ("Remove Machine"), "<control>d", Catalog.GetString ("Remove the virtual machine"), controller.OnRemove), new ActionEntry ("CreateBlank", Stock.New, Catalog.GetString ("Create Blank Machine"), null, Catalog.GetString ("Create a new empty virtual machine"), controller.OnCreateBlank), new ActionEntry ("CreateFromIso", Stock.New, Catalog.GetString ("Create Machine From ISO"), null, Catalog.GetString ("Create a new machine which boots from a ISO"), controller.OnCreateFromIso), new ActionEntry ("AddMachine", Stock.Add, Catalog.GetString ("Add Existing Machine"), null, Catalog.GetString ("Add an existing virtual machine"), controller.OnAddExisting) }; actions = new ActionGroup ("VmxManager Actions"); actions.Add (actionList); ui = new UIManager (); ui.InsertActionGroup (actions, 0); ui.AddUiFromResource ("vmx-manager.xml"); havePlayer = Utility.CheckForPlayer (); if (!havePlayer) { HigMessageDialog dialog = new HigMessageDialog (this, DialogFlags.Modal, MessageType.Warning, ButtonsType.Close, Catalog.GetString ("VMware Player not found"), Catalog.GetString ("It will not be possible to run virtual machines.")); dialog.Run (); dialog.Destroy (); } SetActionsSensitive (); DefaultWidth = 600; DefaultHeight = 400; vmview.ButtonPressEvent += OnTreeButtonPress; startButton.Clicked += controller.OnStart; configureButton.Clicked += controller.OnConfigure; removeButton.Clicked += controller.OnRemove; createBlankButton.Clicked += controller.OnCreateBlank; createFromIsoButton.Clicked += controller.OnCreateFromIso; addExistingButton.Clicked += controller.OnAddExisting; vmview.Selection.Changed += delegate { SetActionsSensitive (); }; vmview.Model.RowInserted += delegate { SetActionsSensitive (); }; vmview.Model.RowDeleted += delegate { SetActionsSensitive (); }; foreach (VirtualMachine machine in manager.Machines) { machine.Started += OnMachineChanged; machine.Stopped += OnMachineChanged; } manager.Added += delegate (object o, VirtualMachineArgs args) { args.Machine.Started += OnMachineChanged; args.Machine.Stopped += OnMachineChanged; }; }