[Monodevelop-patches-list] r521 - in trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui: . FileEntry

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Sat Jan 17 15:34:31 EST 2004


Author: benm
Date: 2004-01-17 15:34:31 -0500 (Sat, 17 Jan 2004)
New Revision: 521

Added:
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/FileEntry/
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/FileEntry/BaseFileEntry.cs
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/FileEntry/FileEntry.cs
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/FileEntry/FolderEntry.cs
Log:
new widget

Added: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/FileEntry/BaseFileEntry.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/FileEntry/BaseFileEntry.cs	2004-01-17 20:27:04 UTC (rev 520)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/FileEntry/BaseFileEntry.cs	2004-01-17 20:34:31 UTC (rev 521)
@@ -0,0 +1,66 @@
+using System;
+using System.IO;
+using Gtk;
+using Gdk;
+using GtkSharp;
+using GdkSharp;
+
+namespace MonoDevelop.Gui {
+	public abstract class BaseFileEntry : Gtk.HBox {
+		
+		string name;
+		
+		Entry text;
+		Button browse;
+		
+		public event EventHandler PathChanged;
+		
+		protected BaseFileEntry (string name) : base (false, 6)
+		{
+			this.name = name;
+			text = new Entry ();
+			browse = Button.NewWithMnemonic ("_Browse...");
+			
+			text.Changed += new EventHandler (OnTextChanged);
+			browse.Clicked += new EventHandler (OnButtonClicked);
+			
+			PackStart (text, true, true, 0);
+			PackEnd (browse, false, false, 0);
+		}
+		
+		protected abstract string ShowBrowseDialog (string name, string start_in);
+		
+		
+		string default_path;
+		public string DefaultPath {
+			get { return default_path; }
+			set { default_path = value; }
+		}
+		
+		public string Path {
+			get { return System.IO.Path.Combine (default_path, text.Text); }
+		}
+		
+		void OnButtonClicked (object o, EventArgs args)
+		{
+			string start_in;
+			
+			if (Directory.Exists (Path))
+				start_in = Path;
+			else
+				start_in = default_path;
+			
+			string path = ShowBrowseDialog (name, start_in + System.IO.Path.DirectorySeparatorChar);
+			if (path != null) {
+				text.Text = path;
+				OnTextChanged (null, null);
+			}
+		}
+		
+		void OnTextChanged (object o, EventArgs args)
+		{
+			if (PathChanged != null)
+				PathChanged (this, EventArgs.Empty);
+		}
+	}
+}
\ No newline at end of file

Added: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/FileEntry/FileEntry.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/FileEntry/FileEntry.cs	2004-01-17 20:27:04 UTC (rev 520)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/FileEntry/FileEntry.cs	2004-01-17 20:34:31 UTC (rev 521)
@@ -0,0 +1,30 @@
+using System;
+using System.IO;
+using Gtk;
+using Gdk;
+using GtkSharp;
+using GdkSharp;
+
+namespace MonoDevelop.Gui {
+	public class FileEntry : BaseFileEntry{
+
+		public FileEntry (string name) : base (name)
+		{
+		}
+		
+		protected override string ShowBrowseDialog (string name, string start_in)
+		{
+			FileSelection fd = new FileSelection (name);
+			if (start_in != null)
+				fd.Filename = start_in;
+			
+			int response = fd.Run ();
+			fd.Hide ();
+			
+			if (response == (int) ResponseType.Ok)
+				return fd.Filename;
+			
+			return null;
+		}
+	}
+}
\ No newline at end of file

Added: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/FileEntry/FolderEntry.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/FileEntry/FolderEntry.cs	2004-01-17 20:27:04 UTC (rev 520)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/FileEntry/FolderEntry.cs	2004-01-17 20:34:31 UTC (rev 521)
@@ -0,0 +1,30 @@
+using System;
+using System.IO;
+using Gtk;
+using Gdk;
+using GtkSharp;
+using GdkSharp;
+
+namespace MonoDevelop.Gui {
+	public class FolderEntry : BaseFileEntry {
+
+		public FolderEntry (string name) : base (name)
+		{
+		}
+		
+		protected override string ShowBrowseDialog (string name, string start_in)
+		{
+			FolderDialog fd = new FolderDialog (name);
+			if (start_in != null)
+				fd.Filename = start_in;
+			
+			int response = fd.Run ();
+			fd.Hide ();
+			
+			if (response == (int) ResponseType.Ok)
+				return fd.Filename;
+			
+			return null;
+		}
+	}
+}
\ No newline at end of file




More information about the Monodevelop-patches-list mailing list