[Monodevelop-patches-list] r1048 - in trunk/MonoDevelop/src: AddIns/DisplayBindings/SourceEditor/Gui Libraries Libraries/MonoDevelop.Gui.Utils/VFS Libraries/MonoDevelop.Gui.Widgets Libraries/MonoDevelop.Gui.Widgets/FileBrowser Main/Base/Gui/Pads Main/Base/Services/DisplayBinding

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Fri Feb 27 17:18:53 EST 2004


Author: jluke
Date: 2004-02-27 17:18:53 -0500 (Fri, 27 Feb 2004)
New Revision: 1048

Modified:
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs
   trunk/MonoDevelop/src/Libraries/Makefile.am
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/VFS/Vfs.cs
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/FileBrowser/FileBrowser.cs
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/Makefile.am
   trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs
   trunk/MonoDevelop/src/Main/Base/Services/DisplayBinding/DisplayBindingService.cs
Log:
patch from I?\195?\177igo Ill?\195?\161n <kodeport at terra.es>
modified the style
use Path.Combine in some places
s/MonoDevelop.GuiUtils/MonoDevelop.Gui.Utils


Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs	2004-02-27 15:01:15 UTC (rev 1047)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs	2004-02-27 22:18:53 UTC (rev 1048)
@@ -13,7 +13,7 @@
 using Gtk;
 using GtkSharp;
 
-using MonoDevelop.GuiUtils;
+using MonoDevelop.Gui.Utils;
 using MonoDevelop.EditorBindings.Properties;
 using MonoDevelop.EditorBindings.FormattingStrategy;
 

Modified: trunk/MonoDevelop/src/Libraries/Makefile.am
===================================================================
--- trunk/MonoDevelop/src/Libraries/Makefile.am	2004-02-27 15:01:15 UTC (rev 1047)
+++ trunk/MonoDevelop/src/Libraries/Makefile.am	2004-02-27 22:18:53 UTC (rev 1048)
@@ -1 +1 @@
-SUBDIRS=SharpAssembly SharpRefactory MonoDevelop.Core MonoDevelop.Gui.Widgets MonoDevelop.Gui.Utils
+SUBDIRS=SharpAssembly SharpRefactory MonoDevelop.Core MonoDevelop.Gui.Utils MonoDevelop.Gui.Widgets

Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/VFS/Vfs.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/VFS/Vfs.cs	2004-02-27 15:01:15 UTC (rev 1047)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/VFS/Vfs.cs	2004-02-27 22:18:53 UTC (rev 1048)
@@ -6,7 +6,7 @@
 using System;
 using System.Runtime.InteropServices;
 
-namespace MonoDevelop.GuiUtils
+namespace MonoDevelop.Gui.Utils
 {
 	public class Vfs
 	{

Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/FileBrowser/FileBrowser.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/FileBrowser/FileBrowser.cs	2004-02-27 15:01:15 UTC (rev 1047)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/FileBrowser/FileBrowser.cs	2004-02-27 22:18:53 UTC (rev 1048)
@@ -4,19 +4,28 @@
 //
 
 using System;
+using System.Diagnostics;
 using System.IO;
 using Gtk;
 using GtkSharp;
 
 using ICSharpCode.Core.Properties;
 using ICSharpCode.Core.Services;
+using MonoDevelop.Gui.Utils;
 
 namespace MonoDevelop.Gui.Widgets
 {
-	public class FileBrowser : ScrolledWindow
+	public delegate void DirectoryChangedEventHandler (string path);
+
+	public class FileBrowser : VBox
 	{
+		public DirectoryChangedEventHandler DirectoryChangedEvent;
 		private static GLib.GType gtype;
 		private Gtk.TreeView tv;
+		private Gtk.ScrolledWindow scrolledwindow;
+		private Gtk.HBox buttonbox;
+		private Gtk.Button upbutton, homebutton;
+		private Gtk.Entry entry;
 		private ListStore store;
 		private string currentDir;
 		private bool ignoreHidden = true;
@@ -26,24 +35,63 @@
 
 		public FileBrowser () : base (GType)
 		{
-			this.VscrollbarPolicy = PolicyType.Automatic;
-			this.HscrollbarPolicy = PolicyType.Automatic;
+			if (!Vfs.Initialized) {
+				Vfs.Init();
+			}
 
+			scrolledwindow = new ScrolledWindow();
+			scrolledwindow.VscrollbarPolicy = PolicyType.Automatic;
+			scrolledwindow.HscrollbarPolicy = PolicyType.Automatic;
+
+			homebutton = new Gtk.Button ();
+			homebutton.Add (new Gtk.Image (Stock.Home, Gtk.IconSize.SmallToolbar));
+			// homebuttonpix.ScaleSimple (20, 20, Gdk.InterpType.Bilinear)));
+			homebutton.Relief = Gtk.ReliefStyle.None;
+			homebutton.Clicked += new EventHandler (OnHomeClicked);
+
+			upbutton = new Gtk.Button ();
+			upbutton.Add (new Gtk.Image (Stock.GoUp, Gtk.IconSize.SmallToolbar));
+			upbutton.Relief = Gtk.ReliefStyle.None;
+			upbutton.Clicked += new EventHandler (OnUpClicked);
+
+			entry = new Gtk.Entry();
+			entry.Activated += new EventHandler (OnEntryActivated);
+
+			buttonbox = new HBox (false, 0);
+			buttonbox.PackStart(upbutton, false, false, 0);
+			buttonbox.PackStart(homebutton, false, false, 0);
+			buttonbox.PackStart(entry, true, true, 0);
+
 			IProperties p = (IProperties) PropertyService.GetProperty ("SharpDevelop.UI.SelectStyleOptions", new DefaultProperties ());
 			ignoreHidden = !p.GetProperty ("ICSharpCode.SharpDevelop.Gui.FileScout.ShowHidden", false);
 
 			tv = new Gtk.TreeView ();
 			tv.RulesHint = true;
-			tv.AppendColumn ("Directories", new CellRendererText (), "text", 0);
-			store = new ListStore (typeof (string));
-			currentDir = Environment.GetEnvironmentVariable ("HOME");
-			Populate ();
+
+			TreeViewColumn directorycolumn = new TreeViewColumn();
+			directorycolumn.Title = "Directories";
+			
+			Gtk.CellRendererPixbuf pix_render = new Gtk.CellRendererPixbuf ();
+			directorycolumn.PackStart (pix_render, false);
+			directorycolumn.AddAttribute (pix_render, "pixbuf", 0);
+
+			Gtk.CellRendererText text_render = new Gtk.CellRendererText();
+			directorycolumn.PackStart (text_render, false);
+			directorycolumn.AddAttribute (text_render, "text", 1);
+			
+			tv.AppendColumn (directorycolumn);
+
+			store = new ListStore (typeof(Gdk.Pixbuf), typeof (string));
+			CurrentDir = Environment.GetEnvironmentVariable ("HOME");
 			tv.Model = store;
 
 			tv.RowActivated += new RowActivatedHandler (OnRowActivated);
-			tv.Selection.Changed += new EventHandler (OnSelectionChanged);
+			tv.ButtonReleaseEvent += new ButtonReleaseEventHandler (OnButtonReleaseEvent);
 
-			this.Add (tv);
+			scrolledwindow.Add (tv);
+			this.Homogeneous = false;
+			this.PackStart (buttonbox, false, false, 0);
+			this.PackStart (scrolledwindow);
 			this.ShowAll ();
 			init = true;
 		}
@@ -75,8 +123,13 @@
 		public string CurrentDir
 		{
 			get { return System.IO.Path.GetFullPath (currentDir); }
-			set { currentDir = value;
-				  Populate (); }
+			set { 
+					currentDir = System.IO.Path.GetFullPath (value);
+					Populate ();
+					if (DirectoryChangedEvent != null) {
+						DirectoryChangedEvent(CurrentDir);
+					}
+				}
 		}
 
 		public string[] Files
@@ -103,29 +156,33 @@
 		void Populate ()
 		{
 			store.Clear ();
-			// seems unnecessary
-			store.AppendValues (".");
 
-			if (currentDir != "/")
-				store.AppendValues ("..");
+			if (System.IO.Path.GetPathRoot(CurrentDir) == CurrentDir)
+				upbutton.State = StateType.Insensitive;
+			else if (upbutton.State == StateType.Insensitive)
+				upbutton.State = StateType.Normal;
 
-			DirectoryInfo di = new DirectoryInfo (currentDir);
+			DirectoryInfo di = new DirectoryInfo (CurrentDir);
 			DirectoryInfo[] dirs = di.GetDirectories ();
-	
+			
 			foreach (DirectoryInfo d in dirs)
 			{
 				if (ignoreHidden)
 				{
 					if (!d.Name.StartsWith ("."))
-						store.AppendValues (d.Name);
+						store.AppendValues (FileIconLoader.GetPixbufForFile (System.IO.Path.Combine (CurrentDir, d.Name), 24, 24), d.Name);
 				}
 				else
 				{
-					store.AppendValues (d.Name);
+					store.AppendValues (FileIconLoader.GetPixbufForFile (System.IO.Path.Combine (CurrentDir, d.Name), 24, 24), d.Name);
 				}
 			}
 			if (init == true)
 				tv.Selection.SelectPath (new Gtk.TreePath ("0"));
+
+			entry.Text = CurrentDir;
+			//Console.WriteLine(CurrentDir);
+			files = Directory.GetFiles (CurrentDir);
 		}
 
 		private void OnSelectionChanged (object o, EventArgs args)
@@ -134,7 +191,7 @@
 			TreeModel model;
 			if (tv.Selection.GetSelected (out model, out iter))
 			{
-				string selection = (string) store.GetValue (iter, 0);
+				string selection = (string) store.GetValue (iter, 1);
 				files = Directory.GetFiles (System.IO.Path.Combine (currentDir, selection));
 			}
 		}
@@ -143,14 +200,80 @@
 		{
 			TreeIter iter;
 			store.GetIter (out iter, args.Path);
-			string file = (string) store.GetValue (iter, 0);
+			string file = (string) store.GetValue (iter, 1);
 			string newDir = System.IO.Path.Combine (currentDir, file);
 			if (Directory.Exists (newDir))
 			{
-				currentDir = newDir;
-				Populate ();
+				CurrentDir = newDir;
+				// Populate ();
 			}
 		}
+		
+		private void OnButtonReleaseEvent (object o, ButtonReleaseEventArgs args)
+		{
+ 			if (args.Event.Button == 3)
+			{
+				 Gtk.Menu menu = new Menu ();
+				 Gtk.MenuItem openfilebrowser = new MenuItem ("Open with file browser");
+				 openfilebrowser.Activated += new EventHandler (OpenFileBrowser);
+
+				 Gtk.MenuItem openterminal = new MenuItem ("Open with terminal");
+				 openterminal.Activated += new EventHandler (OpenTerminal);
+
+				 menu.Append (openterminal);
+				 menu.Append (openfilebrowser);
+				 menu.Popup (null, null, null, IntPtr.Zero, 3, Global.CurrentEventTime);
+				 menu.ShowAll ();
+			}
+		}
+		
+		private void OpenFileBrowser (object o, EventArgs args)
+		{
+			TreeIter iter;
+			TreeModel model;
+			// FIXME: look in GConf for the settings
+			string commandline = "nautilus \"";
+
+			if (tv.Selection.GetSelected (out model, out iter))
+			{
+				string selection = (string) store.GetValue (iter, 1);
+				commandline += System.IO.Path.Combine (currentDir, selection) + "\"";
+				Process.Start (commandline);
+			}
+		}
+		
+		private void OpenTerminal(object o, EventArgs args)
+		{
+			TreeIter iter;
+			TreeModel model;
+			// FIXME: look in GConf for the settings
+			string commandline = "gnome-terminal --working-directory=\"";
+			if (tv.Selection.GetSelected (out model, out iter))
+			{
+				string selection = (string) store.GetValue (iter, 1);
+				commandline += System.IO.Path.Combine (currentDir, selection) + "\"";
+				Process.Start (commandline);
+			}
+		}
+		
+		private void OnUpClicked (object o, EventArgs args)
+		{
+			if (System.IO.Path.GetPathRoot (CurrentDir) != CurrentDir)
+				CurrentDir = System.IO.Path.Combine (CurrentDir, "..");
+			else
+				Console.WriteLine ("at root");
+		}
+		
+		private void OnHomeClicked (object o, EventArgs args)
+		{
+			CurrentDir = Environment.GetEnvironmentVariable ("HOME");
+		}
+
+		void OnEntryActivated (object sender, EventArgs args)
+		{
+			if (Directory.Exists (entry.Text.Trim ()))
+				CurrentDir = entry.Text;
+		}
 	}
 }
 

Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/Makefile.am
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/Makefile.am	2004-02-27 15:01:15 UTC (rev 1047)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/Makefile.am	2004-02-27 22:18:53 UTC (rev 1048)
@@ -3,7 +3,7 @@
 
 DLL = ../../../build/bin/MonoDevelop.Gui.Widgets.dll
 
-REFERENCES = /r:System.Drawing.dll /r:gtk-sharp.dll /r:gdk-sharp.dll /r:pango-sharp.dll /r:gnome-sharp.dll /r:glib-sharp.dll /r:glade-sharp.dll /r:../../../build/bin/MonoDevelop.Core.dll
+REFERENCES = /r:System.Drawing.dll /r:gtk-sharp.dll /r:gdk-sharp.dll /r:pango-sharp.dll /r:gnome-sharp.dll /r:glib-sharp.dll /r:glade-sharp.dll /r:../../../build/bin/MonoDevelop.Core.dll /r:../../../build/bin/MonoDevelop.Gui.Utils.dll
 
 FILES = ./Tree/TreeView.cs \
 ./Tree/TreeNodeCollection.cs \

Modified: trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs	2004-02-27 15:01:15 UTC (rev 1047)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs	2004-02-27 22:18:53 UTC (rev 1048)
@@ -310,16 +310,17 @@
 		
 		FileList   filelister = new FileList();
 		FileBrowser fb = new FileBrowser ();
-		Gtk.Entry pathEntry;
+		// Gtk.Entry pathEntry;
 		PropertyService PropertyService = (PropertyService) ServiceManager.Services.GetService (typeof (PropertyService));
 
 		public FileScout()
 		{
-			fb.TreeView.Selection.Changed += new EventHandler (OnDirChanged);
+			// fb.TreeView.Selection.Changed += new EventHandler (OnDirChanged);
+			fb.DirectoryChangedEvent += new DirectoryChangedEventHandler (OnDirChanged);
 			filelister.RowActivated += new Gtk.RowActivatedHandler(FileSelected);
 
 			Gtk.Frame treef  = new Gtk.Frame();
-			Gtk.VBox utilVBox = new Gtk.VBox (false, 0);
+			/*Gtk.VBox utilVBox = new Gtk.VBox (false, 0);
 			Gtk.HBox hbox = new Gtk.HBox (false, 6);
 			pathEntry = new Gtk.Entry (fb.CurrentDir);
 			pathEntry.Activated += new EventHandler (OnPathEntryActivated);
@@ -331,38 +332,28 @@
 			homeButton.Clicked += new EventHandler (OnHomeClicked);
 			hbox.PackStart (homeButton, false, false, 0);
 			utilVBox.PackStart (hbox, false, true, 0);
-			utilVBox.PackStart (fb);
-			treef.Add(utilVBox);
+			utilVBox.PackStart (pathEntry, false, true, 0);
+			utilVBox.PackStart (fb);*/
+			treef.Add(fb);
 			
 			Gtk.ScrolledWindow listsw = new Gtk.ScrolledWindow ();
 			listsw.Add(filelister);
-			Gtk.Frame listf  = new Gtk.Frame();
-			listf.Add(listsw);
+			/*Gtk.Frame listf  = new Gtk.Frame();
+			listf.Add(listsw);*/
 			
 			Pack1(treef, true, true);
-			Pack2(listf, true, true);
+			Pack2(listsw, true, true);
 
 			fb.TreeView.Selection.SelectPath (new Gtk.TreePath ("0"));
+			
+			OnDirChanged(fb.CurrentDir);
 		}
 
-		void OnHomeClicked (object sender, EventArgs args)
-		{
-			fb.CurrentDir = Environment.GetEnvironmentVariable ("HOME");
-			OnDirChanged (sender, args);
-		}
-
-		void OnPathEntryActivated (object sender, EventArgs args)
-		{
-			if (Directory.Exists (pathEntry.Text.Trim ()))
-			{
-				fb.CurrentDir = pathEntry.Text;
-				OnDirChanged (sender, args);
-			}
-		}
 		
-		void OnDirChanged(object sender, EventArgs args) 
+		// void OnDirChanged(object sender, EventArgs args)
+		void OnDirChanged (string path) 
 		{
-			pathEntry.Text = fb.CurrentDir;
+			// pathEntry.Text = fb.CurrentDir;
 			filelister.Clear ();
 
 			PropertyService p = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));

Modified: trunk/MonoDevelop/src/Main/Base/Services/DisplayBinding/DisplayBindingService.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/DisplayBinding/DisplayBindingService.cs	2004-02-27 15:01:15 UTC (rev 1047)
+++ trunk/MonoDevelop/src/Main/Base/Services/DisplayBinding/DisplayBindingService.cs	2004-02-27 22:18:53 UTC (rev 1048)
@@ -50,7 +50,7 @@
 		
 		public DisplayBindingCodon GetCodonPerFileName(string filename)
 		{
-			string mimetype = MonoDevelop.GuiUtils.Vfs.GetMimeType (filename);
+			string mimetype = MonoDevelop.Gui.Utils.Vfs.GetMimeType (filename);
 			if (!filename.StartsWith ("http")) {
 				foreach (DisplayBindingCodon binding in bindings) {
 					if (binding.DisplayBinding != null && binding.DisplayBinding.CanCreateContentForMimeType (mimetype)) {




More information about the Monodevelop-patches-list mailing list