[Monodevelop-patches-list] r1624 - in trunk/MonoDevelop/src/Main: Base Base/Commands Base/Gui/Workbench Base/Internal/Parser/ReflectionLayer StartUp
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Mon May 24 20:42:52 EDT 2004
Author: tberman
Date: 2004-05-24 20:42:52 -0400 (Mon, 24 May 2004)
New Revision: 1624
Modified:
trunk/MonoDevelop/src/Main/Base/ChangeLog
trunk/MonoDevelop/src/Main/Base/Commands/AutostartCommands.cs
trunk/MonoDevelop/src/Main/Base/Gui/Workbench/DefaultWorkbench.cs
trunk/MonoDevelop/src/Main/Base/Internal/Parser/ReflectionLayer/ReflectionClass.cs
trunk/MonoDevelop/src/Main/StartUp/ChangeLog
trunk/MonoDevelop/src/Main/StartUp/Makefile.am
trunk/MonoDevelop/src/Main/StartUp/MonoDevelopMain.cs
Log:
couple small fixes, and setup DnD to allow text/uri-list to work properly.
also only one MD instance is opened at a time, and a unix socket is used to communicate between them and get the proper files opened.
Modified: trunk/MonoDevelop/src/Main/Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/Main/Base/ChangeLog 2004-05-24 03:49:30 UTC (rev 1623)
+++ trunk/MonoDevelop/src/Main/Base/ChangeLog 2004-05-25 00:42:52 UTC (rev 1624)
@@ -1,3 +1,11 @@
+2004-05-24 Todd Berman <tberman at sevenl.net>
+
+ * Gui/Workbench/DefaultWorkbench.cs: Setup text/uri-list DnD.
+ Tested with single and multiple files/projects from nautilus.
+ * Internal/Parser/ReflectionLayer/ReflectionClass.cs: workaround
+ potential nullref.
+ * Commands/AutostartCommands.cs: fix focus issue.
+
2004-05-22 Todd Berman <tberman at sevenl.net>
* Gui/Dialogs/NewProjectDialog.cs: Sort properly.
Modified: trunk/MonoDevelop/src/Main/Base/Commands/AutostartCommands.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Commands/AutostartCommands.cs 2004-05-24 03:49:30 UTC (rev 1623)
+++ trunk/MonoDevelop/src/Main/Base/Commands/AutostartCommands.cs 2004-05-25 00:42:52 UTC (rev 1624)
@@ -199,6 +199,7 @@
WorkbenchSingleton.Workbench.SetMemento ((IXmlConvertable)propertyService.GetProperty (workbenchMemento, new WorkbenchMemento ()));
((Gtk.Window)WorkbenchSingleton.Workbench).Visible = true;
WorkbenchSingleton.Workbench.RedrawAllComponents ();
+ ((Gtk.Window)WorkbenchSingleton.Workbench).Present ();
// Give Gtk time to display the workbench window before showing the TOTD.
while (Gtk.Application.EventsPending ())
Modified: trunk/MonoDevelop/src/Main/Base/Gui/Workbench/DefaultWorkbench.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Workbench/DefaultWorkbench.cs 2004-05-24 03:49:30 UTC (rev 1623)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Workbench/DefaultWorkbench.cs 2004-05-25 00:42:52 UTC (rev 1624)
@@ -53,6 +53,14 @@
protected static PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
public Gtk.MenuBar TopMenu = null;
+
+ enum TargetList {
+ UriList = 100
+ }
+
+ Gtk.TargetEntry[] targetEntryTypes = new Gtk.TargetEntry[] {
+ new Gtk.TargetEntry ("text/uri-list", 0, (uint)TargetList.UriList)
+ };
public bool FullScreen {
get {
@@ -145,6 +153,9 @@
dbgr.ResumedEvent += new EventHandler (onDebuggerResumed);
dbgr.StoppedEvent += new EventHandler (onDebuggerStopped);
}
+
+ Gtk.Drag.DestSet (this, Gtk.DestDefaults.Motion | Gtk.DestDefaults.Highlight | Gtk.DestDefaults.Drop, targetEntryTypes, Gdk.DragAction.Copy);
+ DragDataReceived += new Gtk.DragDataReceivedHandler (onDragDataRec);
}
void onDebuggerStarted (object o, EventArgs e)
@@ -152,6 +163,40 @@
context = WorkbenchContext.Debug;
ContextChanged (this, new EventArgs());
}
+
+ void onDragDataRec (object o, Gtk.DragDataReceivedArgs args)
+ {
+ if (args.Info != (uint) TargetList.UriList)
+ return;
+ string fullData = System.Text.Encoding.UTF8.GetString (args.SelectionData.Data);
+
+ foreach (string individualFile in fullData.Split ('\n')) {
+ string file = individualFile.Trim ();
+ if (file.StartsWith ("file://")) {
+ file = file.Substring (7);
+ switch (System.IO.Path.GetExtension(file).ToUpper()) {
+ case ".CMBX":
+ case ".PRJX":
+ try {
+ IProjectService projectService = (IProjectService)ServiceManager.Services.GetService (typeof (IProjectService));
+ projectService.OpenCombine(file);
+ } catch (Exception e) {
+ }
+
+ break;
+ default:
+ try {
+ IFileService fileService = (IFileService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(IFileService));
+ fileService.OpenFile(file);
+
+ } catch (Exception e) {
+ Console.WriteLine("unable to open file {0} exception was :\n{1}", file, e.ToString());
+ }
+ break;
+ }
+ }
+ }
+ }
void onDebuggerPaused (object o, EventArgs e)
{
Modified: trunk/MonoDevelop/src/Main/Base/Internal/Parser/ReflectionLayer/ReflectionClass.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Internal/Parser/ReflectionLayer/ReflectionClass.cs 2004-05-24 03:49:30 UTC (rev 1623)
+++ trunk/MonoDevelop/src/Main/Base/Internal/Parser/ReflectionLayer/ReflectionClass.cs 2004-05-25 00:42:52 UTC (rev 1624)
@@ -43,6 +43,10 @@
public ReflectionClass(Type type)
{
+ if (type == null)
+ type = Type.GetType ("System.Object");
+
+
//FIXME: remove after doc changes are complete.
Hashtable xmlComments = null;
Modified: trunk/MonoDevelop/src/Main/StartUp/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/Main/StartUp/ChangeLog 2004-05-24 03:49:30 UTC (rev 1623)
+++ trunk/MonoDevelop/src/Main/StartUp/ChangeLog 2004-05-25 00:42:52 UTC (rev 1624)
@@ -1,3 +1,12 @@
+2004-05-24 Todd Berman <tberman at sevenl.net>
+
+ * Makefile.am: add Mono.Posix reference
+ * MonoDevelopMain.cs: Use a unix socket to only allow one instance of
+ MD to be open at a time. This should eventually use something like
+ dbus or something else instead of a unix socket. Also, a --new-process
+ arg should be added or something similar to allow more than one
+ open copy of MD at a time.
+
2004-04-19 Todd Berman <tberman at sevenl.net>
* Makefile.am: only link the one .resources file we need.
Modified: trunk/MonoDevelop/src/Main/StartUp/Makefile.am
===================================================================
--- trunk/MonoDevelop/src/Main/StartUp/Makefile.am 2004-05-24 03:49:30 UTC (rev 1623)
+++ trunk/MonoDevelop/src/Main/StartUp/Makefile.am 2004-05-25 00:42:52 UTC (rev 1624)
@@ -15,6 +15,7 @@
REFS = /r:System.Drawing \
/r:../../../build/bin/MonoDevelop.Core.dll \
/r:../../../build/bin/MonoDevelop.Base.dll \
+ /r:Mono.Posix.dll \
$(BASE_DEPENDENCIES_LIBS)
$(DLL): $(build_sources)
Modified: trunk/MonoDevelop/src/Main/StartUp/MonoDevelopMain.cs
===================================================================
--- trunk/MonoDevelop/src/Main/StartUp/MonoDevelopMain.cs 2004-05-24 03:49:30 UTC (rev 1623)
+++ trunk/MonoDevelop/src/Main/StartUp/MonoDevelopMain.cs 2004-05-25 00:42:52 UTC (rev 1624)
@@ -11,12 +11,19 @@
using System.Reflection;
using System.Xml;
using System.Threading;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using Mono.Posix;
+
using MonoDevelop.Core.Properties;
using MonoDevelop.Core.AddIns.Codons;
using MonoDevelop.Core.AddIns;
using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
using MonoDevelop.Gui.Dialogs;
+using MonoDevelop.Gui;
namespace MonoDevelop
{
@@ -26,6 +33,7 @@
public class SharpDevelopMain
{
static string[] commandLineArgs = null;
+ static Socket listen_socket = null;
public static string[] CommandLineArgs {
get {
@@ -52,6 +60,19 @@
[STAThread()]
public static void Main(string[] args)
{
+ string socket_filename = "/tmp/md-" + Environment.GetEnvironmentVariable ("USER") + "-socket";
+ listen_socket = new Socket (AddressFamily.Unix, SocketType.Stream, ProtocolType.IP);
+ EndPoint ep = new UnixEndPoint (socket_filename);
+ if (File.Exists (socket_filename)) {
+ try {
+ listen_socket.Connect (ep);
+ listen_socket.Send (Encoding.UTF8.GetBytes (String.Join ("\n", args)));
+ return;
+ } catch {
+ }
+ }
+ File.Delete (socket_filename);
+
string name = Assembly.GetEntryAssembly ().GetName ().Name;
string version = Assembly.GetEntryAssembly ().GetName ().Version.Major + + "." + Assembly.GetEntryAssembly ().GetName ().Version.Minor;
@@ -110,12 +131,63 @@
}
// run the last autostart command, this must be the workbench starting command
+ listen_socket.Bind (ep);
+ listen_socket.Listen (5);
+ listen_socket.BeginAccept (new AsyncCallback (ListenCallback), listen_socket);
if (commands.Count > 0) {
((ICommand)commands[commands.Count - 1]).Run();
}
// unloading services
+ File.Delete (socket_filename);
ServiceManager.Services.UnloadAllServices();
}
+
+ static string fileToOpen = String.Empty;
+
+ static void ListenCallback (IAsyncResult state)
+ {
+ Socket client = ((Socket)state.AsyncState).EndAccept (state);
+ ((Socket)state.AsyncState).BeginAccept (new AsyncCallback (ListenCallback), state.AsyncState);
+ byte[] buf = new byte[1024];
+ client.Receive (buf);
+ foreach (string filename in Encoding.UTF8.GetString (buf).Split ('\n')) {
+ string trimmed = filename.Trim ();
+ string file = "";
+ foreach (char c in trimmed) {
+ if (c == 0x0000)
+ continue;
+ file += c;
+ }
+ fileToOpen = file;
+ GLib.Idle.Add (new GLib.IdleHandler (openFile));
+ }
+ }
+
+ static bool openFile ()
+ {
+ lock (fileToOpen) {
+ string file = fileToOpen;
+ switch (System.IO.Path.GetExtension(file).ToUpper()) {
+ case ".CMBX":
+ case ".PRJX":
+ try {
+ IProjectService projectService = (IProjectService)ServiceManager.Services.GetService (typeof (IProjectService));
+ projectService.OpenCombine(file);
+ } catch (Exception e) {
+ }
+ break;
+ default:
+ try {
+ IFileService fileService = (IFileService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(IFileService));
+ fileService.OpenFile(file);
+ } catch (Exception e) {
+ }
+ break;
+ }
+ ((Gtk.Window)WorkbenchSingleton.Workbench).Present ();
+ return false;
+ }
+ }
}
}
More information about the Monodevelop-patches-list
mailing list