/// <summary> /// Detach the specified widget to an external window or re-attach it again to its previous container. /// </summary> /// <param name="widgetToDetach">Widget to detach.</param> /// <param name="windowTitle">Window title.</param> /// <param name="widgetWhereReattach">Widget where reattach.</param> /// <param name="func">Function executed detaching and attaching by the view in order to do specific work as /// hiding widgets</param> public void Detach(Widget widgetToDetach, string windowTitle, Widget widgetWhereReattach, Function func) { if (externalWindow == null) { Log.Debug("Detaching widget"); externalWindow = new ExternalWindow(); externalWindow.Title = windowTitle; int window_width = widgetToDetach.Allocation.Width; int window_height = widgetToDetach.Allocation.Height; externalWindow.SetDefaultSize(window_width, window_height); externalWindow.DeleteEvent += (o, args) => Detach(widgetToDetach, windowTitle, widgetWhereReattach, func); externalWindow.Show(); widgetToDetach.Reparent(externalWindow.Box); // Hack to reposition widget window in widget for OSX externalWindow.Resize(window_width + 10, window_height); } else { Log.Debug("Attaching widget again"); widgetToDetach.Reparent(widgetWhereReattach); externalWindow.Destroy(); externalWindow = null; } func.Invoke(); }
Notebook CreateNewWindow(Notebook source, Widget page, int x, int y) { ExternalWindow window; EventBox box; Notebook notebook; window = new ExternalWindow(); if (page == timeline) { window.Title = Catalog.GetString("Timeline"); } else if (page == dashboardhpaned) { window.Title = Catalog.GetString("Analysis dashboard"); } else if (page == playspositionviewer1) { window.Title = Catalog.GetString("Zonal tags viewer"); } notebook = new Notebook(); notebook.ShowTabs = false; notebook.CanFocus = false; //notebook.Group = source.Group; window.Add(notebook); window.SetDefaultSize(page.Allocation.Width, page.Allocation.Height); window.Move(x, y); window.ShowAll(); activeWindows.Add(window); window.DeleteEvent += (o, args) => { Widget pa = notebook.CurrentPageWidget; activeWindows.Remove(window); notebook.Remove(pa); source.AppendPage(pa, null); SetTabProps(pa, source.NPages == 0); notebook.Destroy(); }; return(notebook); }