Author: spouliot
Date: 2007-06-29 14:48:26 -0400 (Fri, 29 Jun 2007)
New Revision: 81062
Modified:
trunk/cecil/monoxide/Monoxide/ChangeLog
trunk/cecil/monoxide/Monoxide/MainWindow.cs
trunk/cecil/monoxide/Monoxide/gtk-gui/Monoxide.MainWindow.cs
trunk/cecil/monoxide/Monoxide/gtk-gui/gui.stetic
Log:
2007-06-29 Sebastien Pouliot <[EMAIL PROTECTED]>
* MainWindow.cs: Re-introduce assembly-list files (as I'm too lazy
to live without them).
Modified: trunk/cecil/monoxide/Monoxide/ChangeLog
===================================================================
--- trunk/cecil/monoxide/Monoxide/ChangeLog 2007-06-29 18:47:00 UTC (rev
81061)
+++ trunk/cecil/monoxide/Monoxide/ChangeLog 2007-06-29 18:48:26 UTC (rev
81062)
@@ -1,3 +1,8 @@
+2007-06-29 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * MainWindow.cs: Re-introduce assembly-list files (as I'm too lazy
+ to live without them).
+
2007-06-28 Sebastien Pouliot <[EMAIL PROTECTED]>
* MainWindow.cs: Memorize last folder used to load assemblies. Fix
Modified: trunk/cecil/monoxide/Monoxide/MainWindow.cs
===================================================================
--- trunk/cecil/monoxide/Monoxide/MainWindow.cs 2007-06-29 18:47:00 UTC (rev
81061)
+++ trunk/cecil/monoxide/Monoxide/MainWindow.cs 2007-06-29 18:48:26 UTC (rev
81062)
@@ -50,7 +50,12 @@
private TreeIter tree_cursor;
private string current_directory;
+ private FileFilter dotnet_filter;
+ private FileFilter list_filter;
+ private FileFilter all_filter;
+
private List<AssemblyDefinition> assemblies;
+ private List<string> locations;
private Menu popup_assemblies;
private Menu popup_types;
@@ -93,13 +98,29 @@
treeview.Selection.Changed += OnSelectionChanged;
OnSelectionChanged (null, EventArgs.Empty);
- if (args.Length > 0) {
- foreach (string aname in args) {
- LoadAssembly (aname);
- }
- }
+ if (args.Length > 0)
+ Load (args);
}
+ private void BuildFilters ()
+ {
+ if (dotnet_filter != null)
+ return;
+
+ dotnet_filter = new FileFilter ();
+ dotnet_filter.Name = ".NET assemblies (*.exe, *.dll)";
+ dotnet_filter.AddPattern ("*.exe");
+ dotnet_filter.AddPattern ("*.dll");
+
+ list_filter = new FileFilter ();
+ list_filter.Name = "Assembly List (*.lst)";
+ list_filter.AddPattern ("*.lst");
+
+ all_filter = new FileFilter ();
+ all_filter.Name = "All (*.*)";
+ all_filter.AddPattern ("*.*");
+ }
+
private object GetSelectedObject ()
{
TreeIter iter;
@@ -110,6 +131,27 @@
return null;
}
+ private void OnAssemblySelection (AssemblyDefinition ad)
+ {
+ objectLabel.Text = ad.Name.FullName;
+ // very useful for debugging
+ textview.Buffer.Text = String.Empty;
+ }
+
+ private void OnTypeSelection (TypeDefinition td)
+ {
+ objectLabel.Text = td.ToString ();
+ // very useful for debugging
+ textview.Buffer.Text = String.Empty;
+ }
+
+ private void OnMethodSelection (MethodDefinition md)
+ {
+ objectLabel.Text = md.ToString ();
+ // very useful for debugging
+ textview.Buffer.Text = String.Empty;
+ }
+
private void OnSelectionChanged (object o, EventArgs args)
{
TreeIter iter;
@@ -119,15 +161,15 @@
AssemblyDefinition ad = (obj as
AssemblyDefinition);
if (ad != null) {
- objectLabel.Text = ad.Name.FullName;
+ OnAssemblySelection (ad);
} else {
TypeDefinition td = (obj as
TypeDefinition);
if (td != null) {
- objectLabel.Text = td.ToString
();
+ OnTypeSelection (td);
} else {
MethodDefinition md = (obj as
MethodDefinition);
if (md != null)
- objectLabel.Text =
md.ToString ();
+ OnMethodSelection (md);
}
}
}
@@ -142,6 +184,8 @@
{
if (assemblies == null)
assemblies = new List<AssemblyDefinition> ();
+ if (locations == null)
+ locations = new List<string> ();
try {
AssemblyDefinition ad =
AssemblyFactory.GetAssembly (filename);
@@ -153,12 +197,49 @@
// add assembly to the treeview
PopulateStore (ad);
+
+ locations.Add (filename);
}
catch (Exception e) {
Console.WriteLine (e);
}
}
+
+ private void LoadAssemblyList (string listname)
+ {
+ using (StreamReader sr = new StreamReader (listname)) {
+ while (!sr.EndOfStream) {
+ string filename = sr.ReadLine ();
+ if (filename.Length > 0)
+ LoadAssembly (filename);
+ }
+ }
+ }
+ private void Load (string[] filenames)
+ {
+ foreach (string filename in filenames) {
+ switch (System.IO.Path.GetExtension
(filename).ToLower ()) {
+ case ".lst":
+ LoadAssemblyList (filename);
+ break;
+ default:
+ LoadAssembly (filename);
+ break;
+ }
+ }
+ }
+
+ private void SaveAssemblyList (string listname)
+ {
+ using (StreamWriter sw = new StreamWriter (listname)) {
+ if (locations != null) {
+ foreach (string filename in locations)
+ sw.WriteLine (filename);
+ }
+ }
+ }
+
private void PopulateStore (AssemblyDefinition assembly)
{
tree_cursor = tree_store.AppendValues
(assembly.Name.FullName, assembly);
@@ -229,6 +310,7 @@
protected virtual void OnOpenActivated (object sender,
System.EventArgs e)
{
+ BuildFilters ();
using (FileChooserDialog fcd = new FileChooserDialog
("Open Assembly...", this, FileChooserAction.Open,
"Cancel", ResponseType.Cancel, "Open",
ResponseType.Accept)) {
@@ -236,18 +318,38 @@
fcd.SetCurrentFolder
(current_directory);
fcd.SelectMultiple = true;
+ fcd.AddFilter (dotnet_filter);
+ fcd.AddFilter (list_filter);
+ fcd.AddFilter (all_filter);
bool ok = (fcd.Run () == (int)
ResponseType.Accept);
fcd.Hide ();
if (ok) {
- foreach (string aname in fcd.Filenames)
- LoadAssembly (aname);
+ Load (fcd.Filenames);
current_directory = fcd.CurrentFolder;
}
}
}
+ protected virtual void OnSaveActivated (object sender,
System.EventArgs e)
+ {
+ using (FileChooserDialog fcd = new FileChooserDialog
("Save Assembly List...", this, FileChooserAction.Save,
+ "Cancel", ResponseType.Cancel, "Save",
ResponseType.Accept)) {
+
+ if (current_directory != null)
+ fcd.SetCurrentFolder
(current_directory);
+
+ bool ok = (fcd.Run () == (int)
ResponseType.Accept);
+ fcd.Hide ();
+ if (ok) {
+ SaveAssemblyList (fcd.Filename);
+
+ current_directory = fcd.CurrentFolder;
+ }
+ }
+ }
+
protected virtual void OnQuitActivated (object sender,
System.EventArgs e)
{
Application.Quit ();
Modified: trunk/cecil/monoxide/Monoxide/gtk-gui/Monoxide.MainWindow.cs
===================================================================
--- trunk/cecil/monoxide/Monoxide/gtk-gui/Monoxide.MainWindow.cs
2007-06-29 18:47:00 UTC (rev 81061)
+++ trunk/cecil/monoxide/Monoxide/gtk-gui/Monoxide.MainWindow.cs
2007-06-29 18:48:26 UTC (rev 81062)
@@ -31,6 +31,8 @@
private Gtk.Action About;
+ private Gtk.Action Save;
+
private Gtk.VBox vbox2;
private Gtk.MenuBar menubar1;
@@ -47,6 +49,8 @@
private Gtk.Expander objectExpander;
+ private Gtk.TextView textview;
+
private Gtk.Label objectLabel;
private Gtk.Notebook notebook;
@@ -88,6 +92,9 @@
this.About = new Gtk.Action("About",
Mono.Unix.Catalog.GetString("_About..."), null, "gtk-about");
this.About.ShortLabel = Mono.Unix.Catalog.GetString("_About...");
w2.Add(this.About, null);
+ this.Save = new Gtk.Action("Save",
Mono.Unix.Catalog.GetString("_Save..."), null, "gtk-save");
+ this.Save.ShortLabel = Mono.Unix.Catalog.GetString("_Save...");
+ w2.Add(this.Save, null);
w1.InsertActionGroup(w2, 0);
this.AddAccelGroup(w1.AccelGroup);
this.Name = "Monoxide.MainWindow";
@@ -98,7 +105,7 @@
this.vbox2.Name = "vbox2";
this.vbox2.Spacing = 6;
// Container child vbox2.Gtk.Box+BoxChild
- w1.AddUiFromString("<ui><menubar name='menubar1'><menu
action='File'><menuitem action='Open'/><separator/><menuitem
action='Quit'/></menu><menu action='View'><menuitem
action='refresh'/></menu><menu action='Tools'><menuitem
action='AddinManagerAction'/><separator/></menu><menu action='Help'><menuitem
action='About'/></menu></menubar></ui>");
+ w1.AddUiFromString("<ui><menubar name='menubar1'><menu
action='File'><menuitem action='Open'/><menuitem
action='Save'/><separator/><menuitem action='Quit'/></menu><menu
action='View'><menuitem action='refresh'/></menu><menu action='Tools'><menuitem
action='AddinManagerAction'/><separator/></menu><menu action='Help'><menuitem
action='About'/></menu></menubar></ui>");
this.menubar1 = ((Gtk.MenuBar)(w1.GetWidget("/menubar1")));
this.menubar1.Name = "menubar1";
this.vbox2.Add(this.menubar1);
@@ -146,16 +153,22 @@
this.objectExpander = new Gtk.Expander(null);
this.objectExpander.CanFocus = true;
this.objectExpander.Name = "objectExpander";
+ // Container child objectExpander.Gtk.Container+ContainerChild
+ this.textview = new Gtk.TextView();
+ this.textview.CanFocus = true;
+ this.textview.Name = "textview";
+ this.textview.Editable = false;
+ this.objectExpander.Add(this.textview);
this.objectLabel = new Gtk.Label();
this.objectLabel.Name = "objectLabel";
this.objectLabel.LabelProp =
Mono.Unix.Catalog.GetString("<empty>");
this.objectLabel.UseUnderline = true;
this.objectExpander.LabelWidget = this.objectLabel;
this.vbox1.Add(this.objectExpander);
- Gtk.Box.BoxChild w7 =
((Gtk.Box.BoxChild)(this.vbox1[this.objectExpander]));
- w7.Position = 0;
- w7.Expand = false;
- w7.Fill = false;
+ Gtk.Box.BoxChild w8 =
((Gtk.Box.BoxChild)(this.vbox1[this.objectExpander]));
+ w8.Position = 0;
+ w8.Expand = false;
+ w8.Fill = false;
// Container child vbox1.Gtk.Box+BoxChild
this.notebook = new Gtk.Notebook();
this.notebook.CanFocus = true;
@@ -170,33 +183,33 @@
this.scrolledwindow2.HscrollbarPolicy = ((Gtk.PolicyType)(1));
this.scrolledwindow2.ShadowType = ((Gtk.ShadowType)(1));
// Container child scrolledwindow2.Gtk.Container+ContainerChild
- Gtk.Viewport w8 = new Gtk.Viewport();
- w8.Name = "GtkViewport";
- w8.ShadowType = ((Gtk.ShadowType)(0));
+ Gtk.Viewport w9 = new Gtk.Viewport();
+ w9.Name = "GtkViewport";
+ w9.ShadowType = ((Gtk.ShadowType)(0));
// Container child GtkViewport.Gtk.Container+ContainerChild
this.image = new Gtk.Image();
this.image.Name = "image";
- w8.Add(this.image);
- this.scrolledwindow2.Add(w8);
+ w9.Add(this.image);
+ this.scrolledwindow2.Add(w9);
this.notebook.Add(this.scrolledwindow2);
- Gtk.Notebook.NotebookChild w11 =
((Gtk.Notebook.NotebookChild)(this.notebook[this.scrolledwindow2]));
- w11.TabExpand = false;
+ Gtk.Notebook.NotebookChild w12 =
((Gtk.Notebook.NotebookChild)(this.notebook[this.scrolledwindow2]));
+ w12.TabExpand = false;
this.vbox1.Add(this.notebook);
- Gtk.Box.BoxChild w12 =
((Gtk.Box.BoxChild)(this.vbox1[this.notebook]));
- w12.Position = 1;
+ Gtk.Box.BoxChild w13 =
((Gtk.Box.BoxChild)(this.vbox1[this.notebook]));
+ w13.Position = 1;
this.hpaned1.Add(this.vbox1);
this.vbox2.Add(this.hpaned1);
- Gtk.Box.BoxChild w14 =
((Gtk.Box.BoxChild)(this.vbox2[this.hpaned1]));
- w14.Position = 2;
+ Gtk.Box.BoxChild w15 =
((Gtk.Box.BoxChild)(this.vbox2[this.hpaned1]));
+ w15.Position = 2;
// Container child vbox2.Gtk.Box+BoxChild
this.statusbar1 = new Gtk.Statusbar();
this.statusbar1.Name = "statusbar1";
this.statusbar1.Spacing = 6;
this.vbox2.Add(this.statusbar1);
- Gtk.Box.BoxChild w15 =
((Gtk.Box.BoxChild)(this.vbox2[this.statusbar1]));
- w15.Position = 3;
- w15.Expand = false;
- w15.Fill = false;
+ Gtk.Box.BoxChild w16 =
((Gtk.Box.BoxChild)(this.vbox2[this.statusbar1]));
+ w16.Position = 3;
+ w16.Expand = false;
+ w16.Fill = false;
this.Add(this.vbox2);
if ((this.Child != null)) {
this.Child.ShowAll();
@@ -209,6 +222,7 @@
this.AddinManagerAction.Activated += new
System.EventHandler(this.OnAddinManagerActivated);
this.Open.Activated += new
System.EventHandler(this.OnOpenActivated);
this.About.Activated += new
System.EventHandler(this.OnAboutActivated);
+ this.Save.Activated += new
System.EventHandler(this.OnSaveActivated);
this.treeview.ButtonPressEvent += new
Gtk.ButtonPressEventHandler(this.OnTreeviewButtonPressEvent);
}
}
Modified: trunk/cecil/monoxide/Monoxide/gtk-gui/gui.stetic
===================================================================
--- trunk/cecil/monoxide/Monoxide/gtk-gui/gui.stetic 2007-06-29 18:47:00 UTC
(rev 81061)
+++ trunk/cecil/monoxide/Monoxide/gtk-gui/gui.stetic 2007-06-29 18:48:26 UTC
(rev 81062)
@@ -66,6 +66,13 @@
<property name="StockId">gtk-about</property>
<signal name="Activated" handler="OnAboutActivated" />
</action>
+ <action id="Save">
+ <property name="Type">Action</property>
+ <property name="Label" translatable="yes">_Save...</property>
+ <property name="ShortLabel" translatable="yes">_Save...</property>
+ <property name="StockId">gtk-save</property>
+ <signal name="Activated" handler="OnSaveActivated" />
+ </action>
</action-group>
<property name="MemberName" />
<property name="Title" translatable="yes">monoXide 0.2</property>
@@ -80,6 +87,7 @@
<node name="menubar1" type="Menubar">
<node type="Menu" action="File">
<node type="Menuitem" action="Open" />
+ <node type="Menuitem" action="Save" />
<node type="Separator" />
<node type="Menuitem" action="Quit" />
</node>
@@ -157,7 +165,12 @@
<property name="MemberName" />
<property name="CanFocus">True</property>
<child>
- <placeholder />
+ <widget class="Gtk.TextView" id="textview">
+ <property name="MemberName" />
+ <property name="CanFocus">True</property>
+ <property name="Editable">False</property>
+ <property name="Text" translatable="yes" />
+ </widget>
</child>
<child>
<widget class="Gtk.Label" id="objectLabel">
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches