[Monodevelop-patches-list] r1770 - in trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets: . FileSelector

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Thu Jun 17 00:59:43 EDT 2004


Author: jluke
Date: 2004-06-17 00:59:43 -0400 (Thu, 17 Jun 2004)
New Revision: 1770

Added:
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/FileSelector/
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/FileSelector/FileSelector.cs
Modified:
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/ChangeLog
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/Makefile.am
Log:
add a FileSelector wrapper around Gtk.FileSelection


Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/ChangeLog	2004-06-17 02:46:15 UTC (rev 1769)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/ChangeLog	2004-06-17 04:59:43 UTC (rev 1770)
@@ -1,3 +1,8 @@
+2004-06-17  John Luke  <jluke at cfl.rr.com>
+
+	* FileSelector/FileSelector.cs: a thin wrapper for selecting files
+	* Makefile.am: add FileSelector
+
 2004-06-07  John Luke  <jluke at cfl.rr.com>
 
 	* FileBrowser/FileBrowser.cs: use a toolbar with tooltips

Added: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/FileSelector/FileSelector.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/FileSelector/FileSelector.cs	2004-06-17 02:46:15 UTC (rev 1769)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/FileSelector/FileSelector.cs	2004-06-17 04:59:43 UTC (rev 1770)
@@ -0,0 +1,69 @@
+using System;
+using Gtk;
+
+using MonoDevelop.Services;
+using MonoDevelop.Core.Services;
+
+namespace MonoDevelop.Gui.Widgets
+{
+	// basically just to remember the last directory
+	// we could do some if GTK2.4 then use new FileChooser
+	// but that is probably to be hacky at best
+	public class FileSelector : FileSelection
+	{
+		const string LastPathProperty = "MonoDevelop.FileSelector.LastPath";
+		string lastPath;
+		PropertyService propertyService = (PropertyService) ServiceManager.Services.GetService (typeof (PropertyService));
+
+		public FileSelector () : base (GettextCatalog.GetString ("Open file ..."))
+		{
+			CommonSetup ();
+		}
+
+		public FileSelector (string title) : base (title)
+		{
+			CommonSetup ();
+		}
+
+		void CommonSetup ()
+		{
+			// Restore the last active directory
+			string tmp = (string) propertyService.GetProperty (LastPathProperty);
+			if (tmp != null && tmp.Length > 0)
+			{
+				int start = tmp.IndexOf (':') + 1;
+				lastPath = tmp.Substring (start).Trim ();
+			}
+			else
+			{
+				// FIXME: use ~/DefaultPath
+				lastPath = Environment.GetEnvironmentVariable ("HOME");
+			}
+
+			// FIXME: surely there is a better way to set the dir
+			this.Complete (lastPath);
+
+			// Basically need to track if the directory has
+			// been changed in the simplest way possible
+			this.DirList.RowActivated += OnDirectoryChanged;
+			this.HistoryPulldown.Changed += OnOptionChanged;
+		}
+
+		void OnDirectoryChanged (object o, RowActivatedArgs args)
+		{
+			UpdateLastDir ();
+		}
+
+		void OnOptionChanged (object o, EventArgs args)
+		{
+			UpdateLastDir ();
+		}
+
+		void UpdateLastDir ()
+		{
+			lastPath = this.SelectionText.Text;
+			propertyService.SetProperty (LastPathProperty, lastPath);
+		}
+	}
+}
+

Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/Makefile.am
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/Makefile.am	2004-06-17 02:46:15 UTC (rev 1769)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/Makefile.am	2004-06-17 04:59:43 UTC (rev 1770)
@@ -16,6 +16,7 @@
 ./IconView/IconView.cs \
 ./AssemblyInfo.cs \
 ./FileBrowser/FileBrowser.cs \
+./FileSelector/FileSelector.cs \
 ./FolderDialog/FolderDialog.cs \
 ./FolderDialog/BaseFileEntry.cs \
 ./FolderDialog/FolderEntry.cs \




More information about the Monodevelop-patches-list mailing list