Author: lluis
Date: 2008-02-14 09:56:56 -0500 (Thu, 14 Feb 2008)
New Revision: 95635
Added:
trunk/monodevelop/main/src/core/MonoDevelop.Components/MonoDevelop.Components/NotebookButtonBar.cs
trunk/monodevelop/main/src/core/MonoDevelop.Components/MonoDevelop.Components/TreeViewState.cs
Modified:
trunk/monodevelop/main/src/core/MonoDevelop.Components/ChangeLog
trunk/monodevelop/main/src/core/MonoDevelop.Components/Makefile.am
trunk/monodevelop/main/src/core/MonoDevelop.Components/MonoDevelop.Components.mdp
trunk/monodevelop/main/src/core/MonoDevelop.Components/gtk-gui/gui.stetic
trunk/monodevelop/main/src/core/MonoDevelop.Components/gtk-gui/objects.xml
Log:
* gtk-gui/objects.xml, gtk-gui/gui.stetic, Makefile.am,
MonoDevelop.Components.mdp,
MonoDevelop.Components/TreeViewState.cs,
MonoDevelop.Components/NotebookButtonBar.cs: Added TreeViewState
class, which helps saving/restoring the state of a tree view. Added
NotebookButtonBar.
Modified: trunk/monodevelop/main/src/core/MonoDevelop.Components/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/core/MonoDevelop.Components/ChangeLog
2008-02-14 14:24:56 UTC (rev 95634)
+++ trunk/monodevelop/main/src/core/MonoDevelop.Components/ChangeLog
2008-02-14 14:56:56 UTC (rev 95635)
@@ -1,3 +1,11 @@
+2008-02-14 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
+ * gtk-gui/objects.xml, gtk-gui/gui.stetic, Makefile.am,
+ MonoDevelop.Components.mdp, MonoDevelop.Components/TreeViewState.cs,
+ MonoDevelop.Components/NotebookButtonBar.cs: Added TreeViewState
class,
+ which helps saving/restoring the state of a tree view. Added
+ NotebookButtonBar.
+
2008-02-05 Mike Krüger <[EMAIL PROTECTED]>
* MonoDevelop.Components.Commands.ExtensionNodes/CommandItemCodon.cs,
Modified: trunk/monodevelop/main/src/core/MonoDevelop.Components/Makefile.am
===================================================================
--- trunk/monodevelop/main/src/core/MonoDevelop.Components/Makefile.am
2008-02-14 14:24:56 UTC (rev 95634)
+++ trunk/monodevelop/main/src/core/MonoDevelop.Components/Makefile.am
2008-02-14 14:56:56 UTC (rev 95635)
@@ -92,8 +92,10 @@
MonoDevelop.Components/GladeWidgetExtract.cs \
MonoDevelop.Components/IconView.cs \
MonoDevelop.Components/Navbar.cs \
+ MonoDevelop.Components/NotebookButtonBar.cs \
MonoDevelop.Components/TabLabel.cs \
- MonoDevelop.Components/TreeViewCellContainer.cs
+ MonoDevelop.Components/TreeViewCellContainer.cs \
+ MonoDevelop.Components/TreeViewState.cs
RES = \
gtk-gui/gui.stetic \
Added:
trunk/monodevelop/main/src/core/MonoDevelop.Components/MonoDevelop.Components/NotebookButtonBar.cs
===================================================================
---
trunk/monodevelop/main/src/core/MonoDevelop.Components/MonoDevelop.Components/NotebookButtonBar.cs
2008-02-14 14:24:56 UTC (rev 95634)
+++
trunk/monodevelop/main/src/core/MonoDevelop.Components/MonoDevelop.Components/NotebookButtonBar.cs
2008-02-14 14:56:56 UTC (rev 95635)
@@ -0,0 +1,160 @@
+// NotebookButtonBar.cs
+//
+// Author:
+// Lluis Sanchez Gual <[EMAIL PROTECTED]>
+//
+// Copyright (c) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+//
+
+using System;
+using Gtk;
+
+namespace MonoDevelop.Components
+{
+ public class NotebookButtonBar: Toolbar
+ {
+ Notebook notebook;
+ bool updating;
+
+ public NotebookButtonBar()
+ {
+ IconSize = IconSize.Menu;
+ ToolbarStyle = ToolbarStyle.BothHoriz;
+ ShowArrow = false;
+ ShowAll ();
+ }
+
+ public Widget Notebook {
+ get { return notebook; }
+ set {
+ notebook = value as Notebook;
+ notebook.SwitchPage += OnPageChanged;
+ UpdateButtons ();
+ ShowPage (notebook.Page);
+ }
+ }
+
+ void OnPageChanged (object s, Gtk.SwitchPageArgs args)
+ {
+ if (updating) return;
+ updating = true;
+
+ Gtk.Widget[] buttons = Children;
+ for (int n=0; n<buttons.Length; n++) {
+ ToggleToolButton b = (ToggleToolButton) buttons
[n];
+ b.Active = (n == args.PageNum);
+ }
+
+ updating = false;
+ }
+
+ void UpdateButtons ()
+ {
+ updating = true;
+
+ foreach (Gtk.Widget c in Children)
+ Remove (c);
+ foreach (Gtk.Widget page in notebook.Children) {
+ Gtk.Widget t = notebook.GetTabLabel (page);
+ notebook.SetTabLabel (page, new Gtk.Label (""));
+ Gtk.Widget nw;
+ if (t is Gtk.Label)
+ nw = new Gtk.Label
(((Gtk.Label)t).Text);
+ else
+ nw = new Gtk.Label ("");
+ ToggleToolButton button = new ToggleToolButton
();
+ button.IsImportant = true;
+ button.LabelWidget = t;
+ button.Clicked += new EventHandler
(OnButtonToggled);
+ button.ShowAll ();
+ Insert (button, -1);
+ }
+ updating = false;
+ }
+
+ public void SetButton (int index, string label, string icon)
+ {
+ ToggleToolButton button = (ToggleToolButton) Children
[index];
+ button.Label = label;
+ button.StockId = icon;
+ }
+
+ protected ToggleToolButton AddButton (string label, Gtk.Widget
page)
+ {
+ if (notebook == null)
+ return null;
+ updating = true;
+ ToggleToolButton button = new ToggleToolButton ();
+ button.Label = label;
+ button.IsImportant = true;
+ button.Clicked += new EventHandler (OnButtonToggled);
+ button.ShowAll ();
+ Insert (button, -1);
+ if (page != null)
+ notebook.AppendPage (page, new Gtk.Label ());
+ updating = false;
+ return button;
+ }
+
+ public void RemoveButton (int npage)
+ {
+ if (notebook == null)
+ return;
+ notebook.RemovePage (npage);
+ Gtk.Widget cw = Children [npage];
+ Remove (cw);
+ cw.Destroy ();
+ ShowPage (0);
+ }
+
+ void OnButtonToggled (object s, EventArgs args)
+ {
+ int i = Array.IndexOf (Children, s);
+ if (i != -1)
+ ShowPage (i);
+ }
+
+ public virtual void ShowPage (int npage)
+ {
+ if (notebook.CurrentPage == npage) {
+ ToggleToolButton but = (ToggleToolButton)
Children [npage];
+ but.Active = true;
+ return;
+ }
+
+ if (updating) return;
+
+ notebook.CurrentPage = npage;
+ }
+
+ protected override bool OnExposeEvent (Gdk.EventExpose evnt)
+ {
+ GdkWindow.DrawRectangle (Style.BackgroundGC (State), true,
Allocation);
+
+ foreach (Widget child in Children) {
+ PropagateExpose (child, evnt);
+ }
+
+ return true;
+ }
+ }
+}
Added:
trunk/monodevelop/main/src/core/MonoDevelop.Components/MonoDevelop.Components/TreeViewState.cs
===================================================================
---
trunk/monodevelop/main/src/core/MonoDevelop.Components/MonoDevelop.Components/TreeViewState.cs
2008-02-14 14:24:56 UTC (rev 95634)
+++
trunk/monodevelop/main/src/core/MonoDevelop.Components/MonoDevelop.Components/TreeViewState.cs
2008-02-14 14:56:56 UTC (rev 95635)
@@ -0,0 +1,128 @@
+// TreeViewState.cs
+//
+// Author:
+// Lluis Sanchez Gual <[EMAIL PROTECTED]>
+//
+// Copyright (c) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+//
+
+using System;
+using Gtk;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Components
+{
+ public class TreeViewState
+ {
+ TreeView tree;
+ int idColumn;
+ List<NodeInfo> state;
+
+ class NodeInfo {
+ public object Id;
+ public bool Expanded;
+ public bool Selected;
+ public List<NodeInfo> ChildInfo;
+ }
+
+ public TreeViewState (TreeView tree, int idColumn)
+ {
+ this.tree = tree;
+ this.idColumn = idColumn;
+ }
+
+ public void Save ()
+ {
+ TreeIter it;
+ state = new List<NodeInfo> ();
+ if (!tree.Model.GetIterFirst (out it))
+ return;
+ Save (state, it);
+ }
+
+ void Save (List<NodeInfo> info, TreeIter it)
+ {
+ do {
+ object id = tree.Model.GetValue (it, idColumn);
+ NodeInfo ni = new NodeInfo ();
+ ni.Id = id;
+ ni.Expanded = tree.GetRowExpanded
(tree.Model.GetPath (it));
+ ni.Selected = tree.Selection.IterIsSelected
(it);
+ info.Add (ni);
+ TreeIter cit;
+ if (tree.Model.IterChildren (out cit, it)) {
+ ni.ChildInfo = new List<NodeInfo> ();
+ Save (ni.ChildInfo, cit);
+ }
+ }
+ while (tree.Model.IterNext (ref it));
+ }
+
+ public void Load ()
+ {
+ if (state == null)
+ throw new InvalidOperationException ("State not
saved");
+ TreeIter it;
+ if (!tree.Model.GetIterFirst (out it))
+ return;
+ Load (state, it);
+ state = null;
+ }
+
+ void Load (List<NodeInfo> info, TreeIter it)
+ {
+ do {
+ object id = tree.Model.GetValue (it, idColumn);
+ NodeInfo ni = ExtractNodeInfo (info, id);
+ if (ni != null) {
+ if (ni.Expanded)
+ tree.ExpandRow
(tree.Model.GetPath (it), false);
+ else
+ tree.CollapseRow
(tree.Model.GetPath (it));
+ if (ni.Selected)
+ tree.Selection.SelectIter (it);
+ else
+ tree.Selection.UnselectIter
(it);
+
+ if (ni.ChildInfo != null) {
+ TreeIter cit;
+ if (tree.Model.IterChildren
(out cit, it))
+ Load (ni.ChildInfo,
cit);
+ }
+ }
+ }
+ while (tree.Model.IterNext (ref it));
+ }
+
+ NodeInfo ExtractNodeInfo (List<NodeInfo> info, object id)
+ {
+ for (int n=0; n<info.Count; n++) {
+ NodeInfo ni = (NodeInfo) info [n];
+ if (object.Equals (ni.Id, id)) {
+ info.RemoveAt (n);
+ return ni;
+ }
+ }
+ return null;
+ }
+ }
+}
Modified:
trunk/monodevelop/main/src/core/MonoDevelop.Components/MonoDevelop.Components.mdp
===================================================================
---
trunk/monodevelop/main/src/core/MonoDevelop.Components/MonoDevelop.Components.mdp
2008-02-14 14:24:56 UTC (rev 95634)
+++
trunk/monodevelop/main/src/core/MonoDevelop.Components/MonoDevelop.Components.mdp
2008-02-14 14:56:56 UTC (rev 95635)
@@ -101,27 +101,30 @@
<File name="MonoDevelop.Components.addin.xml" subtype="Code"
buildaction="EmbedAsResource" />
<File
name="MonoDevelop.Components.Commands.ExtensionNodes/SchemeExtensionNode.cs"
subtype="Code" buildaction="Compile" />
<File name="MonoDevelop.Components.Commands/CustomItem.cs" subtype="Code"
buildaction="Compile" />
+ <File name="MonoDevelop.Components/TreeViewState.cs" subtype="Code"
buildaction="Compile" />
+ <File name="MonoDevelop.Components/NotebookButtonBar.cs" subtype="Code"
buildaction="Compile" />
</Contents>
<References>
- <ProjectReference type="Gac" localcopy="False" refto="glade-sharp,
Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
- <ProjectReference type="Gac" localcopy="False" refto="gnome-sharp,
Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
- <ProjectReference type="Gac" localcopy="True" refto="pango-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
- <ProjectReference type="Gac" localcopy="True" refto="atk-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
- <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
- <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<ProjectReference type="Gac" localcopy="True" refto="System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<ProjectReference type="Gac" localcopy="True" refto="System.Drawing,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<ProjectReference type="Gac" localcopy="True" refto="System.Xml,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<ProjectReference type="Gac" localcopy="True" refto="Mono.Posix,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
<ProjectReference type="Project" localcopy="False"
refto="MonoDevelop.Core" />
<ProjectReference type="Gac" localcopy="True" refto="Mono.Addins,
Version=0.3.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
+ <ProjectReference type="Gac" localcopy="True" refto="glade-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<ProjectReference type="Gac" localcopy="True" refto="glib-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+ <ProjectReference type="Gac" localcopy="True" refto="gnome-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+ <ProjectReference type="Gac" localcopy="True" refto="pango-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+ <ProjectReference type="Gac" localcopy="True" refto="atk-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+ <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+ <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
</References>
- <GtkDesignInfo isWidgetLibrary="True"
gettextClass="MonoDevelop.Core.GettextCatalog">
+ <GtkDesignInfo isWidgetLibrary="True"
gettextClass="MonoDevelop.Core.GettextCatalog" gtkVersion="2.8.3">
<ExportedWidgets>
<Widget>MonoDevelop.Components.FileEntry</Widget>
<Widget>MonoDevelop.Components.FolderEntry</Widget>
<Widget>MonoDevelop.Components.IconView</Widget>
+ <Widget>MonoDevelop.Components.NotebookButtonBar</Widget>
</ExportedWidgets>
</GtkDesignInfo>
<MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True"
RelativeMakefileName="./Makefile.am" BuildTargetName="" CleanTargetName=""
SyncReferences="True" IsAutotoolsProject="True"
RelativeConfigureInPath="../../../">
Modified:
trunk/monodevelop/main/src/core/MonoDevelop.Components/gtk-gui/gui.stetic
===================================================================
--- trunk/monodevelop/main/src/core/MonoDevelop.Components/gtk-gui/gui.stetic
2008-02-14 14:24:56 UTC (rev 95634)
+++ trunk/monodevelop/main/src/core/MonoDevelop.Components/gtk-gui/gui.stetic
2008-02-14 14:56:56 UTC (rev 95635)
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<stetic-interface>
+ <configuration>
+ <target-gtk-version>2.8.3</target-gtk-version>
+ </configuration>
<import>
<widget-library name="../../../../build/AddIns/MonoDevelop.Components.dll"
/>
</import>
Modified:
trunk/monodevelop/main/src/core/MonoDevelop.Components/gtk-gui/objects.xml
===================================================================
--- trunk/monodevelop/main/src/core/MonoDevelop.Components/gtk-gui/objects.xml
2008-02-14 14:24:56 UTC (rev 95634)
+++ trunk/monodevelop/main/src/core/MonoDevelop.Components/gtk-gui/objects.xml
2008-02-14 14:56:56 UTC (rev 95635)
@@ -36,4 +36,8 @@
</itemgroup>
</signals>
</object>
+ <object type="MonoDevelop.Components.NotebookButtonBar"
palette-category="MonoDevelop.Components" allow-children="false"
base-type="Gtk.Toolbar">
+ <itemgroups />
+ <signals />
+ </object>
</objects>
\ No newline at end of file
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches