protected override void ReplaceChild(Gtk.Widget oldChild, Gtk.Widget newChild) { int index = tabs.IndexOf(oldChild); if (index != -1) { tabs[index] = newChild; Gtk.Widget page = notebook.GetNthPage(index); notebook.SetTabLabel(page, newChild); } else { Gtk.Widget tab = notebook.GetTabLabel(oldChild); int current = notebook.CurrentPage; int oldPageNum = ((Gtk.Notebook.NotebookChild)notebook [oldChild]).Position; base.ReplaceChild(oldChild, newChild); // Get the widget again because it may have changed (for example, if it is a text view // and has the ShowScrollbars option set. newChild = notebook.GetNthPage(oldPageNum); notebook.CurrentPage = current; notebook.SetTabLabel(newChild, tab); Widget ww = Widget.Lookup(tab); if (ww != null) { ww.RequiresUndoStatusUpdate = true; } } }
public static void ReplaceChild(Gtk.Widget oldWidget, Gtk.Widget newWidget) { Gtk.Container cont = oldWidget.Parent as Gtk.Container; if (cont == null) { return; } if (cont is IGtkContainer) { ((IGtkContainer)cont).ReplaceChild(oldWidget, newWidget); } else if (cont is Gtk.Notebook) { Gtk.Notebook notebook = (Gtk.Notebook)cont; Gtk.Notebook.NotebookChild nc = (Gtk.Notebook.NotebookChild)notebook [oldWidget]; var detachable = nc.Detachable; var pos = nc.Position; var reorderable = nc.Reorderable; var tabExpand = nc.TabExpand; var tabFill = nc.TabFill; var label = notebook.GetTabLabel(oldWidget); notebook.Remove(oldWidget); notebook.InsertPage(newWidget, label, pos); nc = (Gtk.Notebook.NotebookChild)notebook [newWidget]; nc.Detachable = detachable; nc.Reorderable = reorderable; nc.TabExpand = tabExpand; nc.TabFill = tabFill; } else if (cont is Gtk.Paned) { var paned = (Gtk.Paned)cont; var pc = (Gtk.Paned.PanedChild)paned[oldWidget]; var resize = pc.Resize; var shrink = pc.Shrink; var pos = paned.Position; if (paned.Child1 == oldWidget) { paned.Remove(oldWidget); paned.Pack1(newWidget, resize, shrink); } else { paned.Remove(oldWidget); paned.Pack2(newWidget, resize, shrink); } paned.Position = pos; } else if (cont is Gtk.Bin) { ((Gtk.Bin)cont).Remove(oldWidget); ((Gtk.Bin)cont).Child = newWidget; } }
public static void ReplaceChild(Gtk.Widget oldWidget, Gtk.Widget newWidget) { Gtk.Container cont = oldWidget.Parent as Gtk.Container; if (cont == null) { return; } if (cont is IGtkContainer) { ((IGtkContainer)cont).ReplaceChild(oldWidget, newWidget); } else if (cont is Gtk.Notebook) { Gtk.Notebook notebook = (Gtk.Notebook)cont; Gtk.Notebook.NotebookChild nc = (Gtk.Notebook.NotebookChild)notebook[oldWidget]; var detachable = nc.Detachable; var pos = nc.Position; var reorderable = nc.Reorderable; var tabExpand = nc.TabExpand; var tabFill = nc.TabFill; var label = notebook.GetTabLabel(oldWidget); notebook.Remove(oldWidget); notebook.InsertPage(newWidget, label, pos); nc = (Gtk.Notebook.NotebookChild)notebook[newWidget]; nc.Detachable = detachable; nc.Reorderable = reorderable; nc.TabExpand = tabExpand; nc.TabFill = tabFill; } else if (cont is Gtk.Bin) { ((Gtk.Bin)cont).Remove(oldWidget); ((Gtk.Bin)cont).Child = newWidget; } }
protected override void ReplaceChild(Gtk.Widget oldChild, Gtk.Widget newChild) { int index = tabs.IndexOf(oldChild); if (index != -1) { tabs[index] = newChild; Gtk.Widget page = notebook.GetNthPage(index); notebook.SetTabLabel(page, newChild); } else { Gtk.Widget tab = notebook.GetTabLabel(oldChild); int current = notebook.CurrentPage; base.ReplaceChild(oldChild, newChild); notebook.CurrentPage = current; notebook.SetTabLabel(newChild, tab); Widget ww = Widget.Lookup(tab); if (ww != null) { ww.RequiresUndoStatusUpdate = true; } } }