Author: miguel
Date: 2008-01-02 16:48:04 -0500 (Wed, 02 Jan 2008)
New Revision: 92132
Added:
trunk/mono-tools/gui-compare/Config.cs
Modified:
trunk/mono-tools/gui-compare/ChangeLog
trunk/mono-tools/gui-compare/MainWindow.cs
trunk/mono-tools/gui-compare/gtk-gui/MainWindow.cs
trunk/mono-tools/gui-compare/gtk-gui/gui.stetic
trunk/mono-tools/gui-compare/gui-compare.mdp
Log:
Add some configuration loading/saving.
Modified: trunk/mono-tools/gui-compare/ChangeLog
===================================================================
--- trunk/mono-tools/gui-compare/ChangeLog 2008-01-02 21:42:22 UTC (rev
92131)
+++ trunk/mono-tools/gui-compare/ChangeLog 2008-01-02 21:48:04 UTC (rev
92132)
@@ -1,5 +1,9 @@
2008-01-02 Miguel de Icaza <[EMAIL PROTECTED]>
+
+
+2008-01-02 Miguel de Icaza <[EMAIL PROTECTED]>
+
* CompareContext.cs: Provide some hints, not a great way of doing it.
2008-01-02 Miguel de Icaza <[EMAIL PROTECTED]>
Added: trunk/mono-tools/gui-compare/Config.cs
===================================================================
--- trunk/mono-tools/gui-compare/Config.cs 2008-01-02 21:42:22 UTC (rev
92131)
+++ trunk/mono-tools/gui-compare/Config.cs 2008-01-02 21:48:04 UTC (rev
92132)
@@ -0,0 +1,114 @@
+// Config.cs
+//
+// Copyright (c) 2008 Novell, Inc.
+//
+// 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 System.IO;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace GuiCompare
+{
+ public class CompareDefinition {
+ public bool ReferenceIsInfo = true;
+ public string ReferencePath = "";
+ public bool TargetIsInfo = true;
+ public string TargetPath = "";
+
+ public CompareDefinition ()
+ {
+ }
+
+ public CompareDefinition (bool rmaster, string rpath, bool
tmaster, string tpath)
+ {
+ ReferenceIsInfo = rmaster;
+ ReferencePath = rpath;
+ TargetIsInfo = tmaster;
+ TargetPath = tpath;
+ }
+ }
+
+ public class Config
+ {
+ public bool ShowErrors = true;
+ public bool ShowMissing = true;
+ public bool ShowExtra = true;
+ public bool ShowTodo = true;
+ public bool ShowPresent = true;
+
+ [XmlElement ("Recent", typeof (CompareDefinition))]
+ public CompareDefinition [] Recent;
+
+ static string config_dir, settings_file;
+ static XmlSerializer serializer = new XmlSerializer (typeof
(Config));
+
+ static Config ()
+ {
+ config_dir = Environment.GetFolderPath
(Environment.SpecialFolder.ApplicationData);
+ try {
+ Directory.CreateDirectory (config_dir);
+ } catch {
+ }
+ settings_file = System.IO.Path.Combine (config_dir,
"guicompare.xml");
+ }
+
+ public static Config GetConfig ()
+ {
+ if (File.Exists (settings_file)){
+ try {
+ return (Config) serializer.Deserialize
(new XmlTextReader (settings_file));
+ } catch {
+ return new Config ();
+ }
+ } else
+ return new Config ();
+ }
+
+ public void Save ()
+ {
+ try {
+ Directory.CreateDirectory (config_dir);
+ } catch {}
+
+ try {
+ using (FileStream fs = File.Create
(settings_file)){
+ serializer.Serialize (fs, this);
+ }
+ } catch {
+ }
+ }
+
+ public void AddRecent (CompareDefinition cd)
+ {
+ if (Recent == null || Recent.Length < 15){
+ CompareDefinition [] copy = new
CompareDefinition [Recent.Length+1];
+ copy [0] = cd;
+ if (Recent != null)
+ Recent.CopyTo (copy, 1);
+ Recent = copy;
+ } else {
+ Array.Copy (Recent, 0, Recent, 1, Recent.Length
- 1);
+ }
+ }
+ }
+}
Modified: trunk/mono-tools/gui-compare/MainWindow.cs
===================================================================
--- trunk/mono-tools/gui-compare/MainWindow.cs 2008-01-02 21:42:22 UTC (rev
92131)
+++ trunk/mono-tools/gui-compare/MainWindow.cs 2008-01-02 21:48:04 UTC (rev
92132)
@@ -51,6 +51,8 @@
Gtk.TreeStore treeStore;
Gtk.TreeModelFilter treeFilter;
+ public GuiCompare.Config Config;
+
static MainWindow ()
{
Assembly ta = typeof (MainWindow).Assembly;
@@ -75,7 +77,7 @@
extraPixbuf = new Gdk.Pixbuf (ta, "sx.gif");
Gdk.Color.Parse ("#ff0000", ref red);
Gdk.Color.Parse ("#00ff00", ref green);
- Gdk.Color.Parse ("#000000", ref black);
+ Gdk.Color.Parse ("#000000", ref black);
}
public MainWindow (): base (Gtk.WindowType.Toplevel)
@@ -152,6 +154,16 @@
countsColumn.AddAttribute (todoPixbufCell, "pixbuf", 9);
countsColumn.AddAttribute (todoTextCell, "text", 10);
+ //
+ // Load configuration
+ //
+ Config = GuiCompare.Config.GetConfig ();
+ ShowMissing.Active = Config.ShowMissing;
+ ShowErrors.Active = Config.ShowErrors;
+ ShowExtra.Active = Config.ShowExtra;
+ ShowPresent.Active = Config.ShowPresent;
+ ShowTodo.Active = Config.ShowTodo;
+
tree.Selection.Changed += delegate (object sender, EventArgs e)
{
Gtk.TreeIter iter;
if (tree.Selection.GetSelected (out iter)) {
@@ -390,26 +402,36 @@
protected virtual void OnShowErrorsToggled (object sender,
System.EventArgs e)
{
treeFilter.Refilter();
+ Config.ShowErrors = ShowErrors.Active;
+ Config.Save ();
}
protected virtual void OnShowMissingToggled (object sender,
System.EventArgs e)
{
treeFilter.Refilter();
+ Config.ShowMissing = ShowMissing.Active;
+ Config.Save ();
}
protected virtual void OnShowPresentToggled (object sender,
System.EventArgs e)
{
treeFilter.Refilter();
+ Config.ShowPresent = ShowPresent.Active;
+ Config.Save ();
}
protected virtual void OnShowExtraToggled (object sender,
System.EventArgs e)
{
treeFilter.Refilter();
+ Config.ShowPresent = ShowPresent.Active;
+ Config.Save ();
}
protected virtual void OnShowTodoToggled (object sender,
System.EventArgs e)
{
treeFilter.Refilter();
+ Config.ShowTodo = ShowTodo.Active;
+ Config.Save ();
}
protected virtual void OnRefreshActivated (object sender,
System.EventArgs e)
Modified: trunk/mono-tools/gui-compare/gtk-gui/MainWindow.cs
===================================================================
--- trunk/mono-tools/gui-compare/gtk-gui/MainWindow.cs 2008-01-02 21:42:22 UTC
(rev 92131)
+++ trunk/mono-tools/gui-compare/gtk-gui/MainWindow.cs 2008-01-02 21:48:04 UTC
(rev 92132)
@@ -38,6 +38,8 @@
private Gtk.ToggleAction ShowTodo;
+ private Gtk.Action RecentComparisons;
+
private Gtk.VBox vbox1;
private Gtk.MenuBar menubar1;
@@ -109,6 +111,9 @@
this.ShowTodo.Active = true;
this.ShowTodo.ShortLabel = Mono.Unix.Catalog.GetString("Show Todo");
w2.Add(this.ShowTodo, null);
+ this.RecentComparisons = new Gtk.Action("RecentComparisons",
Mono.Unix.Catalog.GetString("Recent Comparisons"), null, null);
+ this.RecentComparisons.ShortLabel =
Mono.Unix.Catalog.GetString("Recent Comparisons");
+ w2.Add(this.RecentComparisons, null);
w1.InsertActionGroup(w2, 0);
this.AddAccelGroup(w1.AccelGroup);
this.Name = "MainWindow";
@@ -119,7 +124,7 @@
this.vbox1.Name = "vbox1";
this.vbox1.Spacing = 6;
// Container child vbox1.Gtk.Box+BoxChild
- w1.AddUiFromString("<ui><menubar name='menubar1'><menu
action='File'><menuitem action='Refresh'/><separator/><menuitem
action='quit'/></menu><menu action='Compare'><menuitem
action='Custom'/><separator/></menu><menu action='View'><menuitem
action='ShowErrors'/><menuitem action='ShowMissing'/><menuitem
action='ShowExtra'/><menuitem action='ShowTodo'/><menuitem
action='ShowPresent'/></menu></menubar></ui>");
+ w1.AddUiFromString("<ui><menubar name='menubar1'><menu
action='File'><menu action='RecentComparisons'/><separator/><menuitem
action='Refresh'/><separator/><menuitem action='quit'/></menu><menu
action='Compare'><menuitem action='Custom'/><separator/></menu><menu
action='View'><menuitem action='ShowErrors'/><menuitem
action='ShowMissing'/><menuitem action='ShowExtra'/><menuitem
action='ShowTodo'/><menuitem action='ShowPresent'/></menu></menubar></ui>");
this.menubar1 = ((Gtk.MenuBar)(w1.GetWidget("/menubar1")));
this.menubar1.Name = "menubar1";
this.vbox1.Add(this.menubar1);
Modified: trunk/mono-tools/gui-compare/gtk-gui/gui.stetic
===================================================================
--- trunk/mono-tools/gui-compare/gtk-gui/gui.stetic 2008-01-02 21:42:22 UTC
(rev 92131)
+++ trunk/mono-tools/gui-compare/gtk-gui/gui.stetic 2008-01-02 21:48:04 UTC
(rev 92132)
@@ -94,6 +94,11 @@
<property name="Active">True</property>
<signal name="Toggled" handler="OnShowTodoToggled" />
</action>
+ <action id="RecentComparisons">
+ <property name="Type">Action</property>
+ <property name="Label" translatable="yes">Recent Comparisons</property>
+ <property name="ShortLabel" translatable="yes">Recent
Comparisons</property>
+ </action>
</action-group>
<property name="MemberName" />
<property name="Title" translatable="yes">MainWindow</property>
@@ -108,6 +113,8 @@
<property name="MemberName" />
<node name="menubar1" type="Menubar">
<node type="Menu" action="File">
+ <node type="Menu" action="RecentComparisons" />
+ <node type="Separator" />
<node type="Menuitem" action="Refresh" />
<node type="Separator" />
<node type="Menuitem" action="quit" />
Modified: trunk/mono-tools/gui-compare/gui-compare.mdp
===================================================================
--- trunk/mono-tools/gui-compare/gui-compare.mdp 2008-01-02 21:42:22 UTC
(rev 92131)
+++ trunk/mono-tools/gui-compare/gui-compare.mdp 2008-01-02 21:48:04 UTC
(rev 92132)
@@ -52,6 +52,7 @@
<File name="gtk-gui/guicompare.ProviderSelector.cs" subtype="Code"
buildaction="Compile" />
<File name="gtk-gui/objects.xml" subtype="Code"
buildaction="EmbedAsResource" />
<File name="AssemblyResolver.cs" subtype="Code" buildaction="Compile" />
+ <File name="Config.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="gtk-sharp,
Version=2.10.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches