コード例 #1
0
        public SdiWorkspaceWindow(IViewContent content, Notebook tabControl, TabLabel tabLabel)
            : base()
        {
            this.tabControl = tabControl;
            this.content = content;
            this.tabLabel = tabLabel;
            this.tabPage = content.Control;

            content.WorkbenchWindow = this;

            content.ContentNameChanged += new EventHandler(SetTitleEvent);
            content.DirtyChanged       += new EventHandler(SetTitleEvent);
            content.BeforeSave         += new EventHandler(BeforeSave);
            content.ContentChanged     += new EventHandler (OnContentChanged);

            ShadowType = ShadowType.None;
            Add (content.Control);
            content.Control.Show ();
            Show ();
            SetTitleEvent(null, null);

            commandHandler = new ViewCommandHandlers (this);
        }
コード例 #2
0
        public IWorkbenchWindow ShowView(IViewContent content)
        {
            Gtk.Image mimeimage = null;
            if (content.IsUntitled) {
                mimeimage = new Gtk.Image (FileIconLoader.GetPixbufForType ("gnome-fs-regular", 16));
            } else {
                mimeimage = new Gtk.Image (FileIconLoader.GetPixbufForFile (content.ContentName, 16));
            }

            TabLabel tabLabel = new TabLabel (new Label (), mimeimage != null ? mimeimage : new Gtk.Image (""));
            tabLabel.Button.Clicked += new EventHandler (closeClicked);
            tabLabel.Button.StateChanged += new StateChangedHandler (stateChanged);
            tabLabel.ClearFlag (WidgetFlags.CanFocus);
            SdiWorkspaceWindow sdiWorkspaceWindow = new SdiWorkspaceWindow(content, tabControl, tabLabel);

            sdiWorkspaceWindow.CloseEvent += new EventHandler(CloseWindowEvent);
            tabControl.InsertPage (sdiWorkspaceWindow, tabLabel, -1);

            tabLabel.Show();
            return sdiWorkspaceWindow;
        }
コード例 #3
0
        public void CloseWindow(bool force, bool fromMenu, int pageNum)
        {
            if (!force && ViewContent != null && ViewContent.IsDirty) {

                QuestionResponse response = Runtime.MessageService.AskQuestionWithCancel (GettextCatalog.GetString ("Do you want to save the current changes"));

                if (response == QuestionResponse.Cancel) {
                    return;
                }

                if (response == QuestionResponse.Yes) {
                    if (content.ContentName == null) {
                        while (true) {
                            Runtime.FileService.SaveFileAs (this);
                            if (ViewContent.IsDirty) {
                                if (Runtime.MessageService.AskQuestion(GettextCatalog.GetString ("Do you really want to discard your changes ?"))) {
                                    break;
                                }
                            } else {
                                break;
                            }
                        }

                    } else {
                        Runtime.FileUtilityService.ObservedSave(new FileOperationDelegate(ViewContent.Save), ViewContent.ContentName , FileErrorPolicy.ProvideAlternative);
                    }
                }
            }
            if (fromMenu == true) {
                WorkbenchSingleton.Workbench.WorkbenchLayout.RemoveTab (tabControl.CurrentPage);
            } else {
                WorkbenchSingleton.Workbench.WorkbenchLayout.RemoveTab (pageNum);
            }
            OnWindowDeselected(EventArgs.Empty);

            content.ContentNameChanged -= new EventHandler(SetTitleEvent);
            content.DirtyChanged       -= new EventHandler(SetTitleEvent);
            content.BeforeSave         -= new EventHandler(BeforeSave);
            content.ContentChanged     -= new EventHandler (OnContentChanged);
            content.WorkbenchWindow = null;

            Remove (content.Control);
            content.Dispose ();
            OnCloseEvent(null);

            this.content = null;
            this.tabControl = null;
            this.tabLabel = null;
            this.tabPage = null;
        }