コード例 #1
0
ファイル: DiskProgressPane.cs プロジェクト: snorp/vmx-manager
        public DiskProgressPane()
            : base()
        {
            this.ShadowType = ShadowType.None;

            pane = new MessagePane ();
            pane.HeaderIconStock = Stock.DialogInfo;
            pane.HeaderMarkup = Catalog.GetString ("<b>Creating Hard Disks</b>");
            pane.Append (Catalog.GetString ("Creating the hard disk(s) may take several minutes, depending on their size."), false);

            progressBar = new ProgressBar ();
            pane.Append (progressBar, AttachOptions.Expand | AttachOptions.Fill, 0, false);
            progressBar.Show ();

            Add (pane);
            pane.Show ();
        }
コード例 #2
0
ファイル: MainWindow.cs プロジェクト: snorp/vmx-manager
        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;
            };
        }