protected override void Run() { var item = IdeApp.ProjectOperations.CurrentSelectedProject; IdeApp.OpenFiles(new [] { new FileOpenInformation(item.Files[0].FilePath, item.Files[0].Project) }); //var userp = item.UserProperties; //var pp = item.ProjectProperties.GetProperties(); //var pol = item.Policies.DirectGetAll (); //foreach (var po in pol) //{ // if (po.PolicyType == typeof(TextStylePolicy)) // { // var scope = po.Scope; // var tsp = po.Policy as TextStylePolicy; // if (tsp.TabsToSpaces) // { // Console.WriteLine("TABS TO SPACES"); // } // } //} //foreach (var p in pp) //{ // Console.WriteLine(p.Name + " : " + p.Value); //} //Console.WriteLine(pp); }
void GlobalSetup() { //FIXME: should we remove these when finalizing? try { ApplicationEvents.Quit += delegate(object sender, ApplicationQuitEventArgs e) { // We can only attempt to quit safely if all windows are GTK windows and not modal if (!IsModalDialogRunning()) { e.UserCancelled = !IdeApp.Exit(); e.Handled = true; return; } // When a modal dialog is running, things are much harder. We can't just shut down MD behind the // dialog, and aborting the dialog may not be appropriate. // // There's NSTerminateLater but I'm not sure how to access it from carbon, maybe // we need to swizzle methods into the app's NSApplicationDelegate. // Also, it stops the main CFRunLoop and enters a special runloop mode, not sure how that would // interact with GTK+. // For now, just bounce NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest); // and abort the quit. e.UserCancelled = true; e.Handled = true; }; ApplicationEvents.Reopen += delegate(object sender, ApplicationEventArgs e) { if (IdeApp.Workbench != null && IdeApp.Workbench.RootWindow != null) { IdeApp.Workbench.RootWindow.Deiconify(); IdeApp.Workbench.RootWindow.Visible = true; IdeApp.Workbench.RootWindow.Present(); e.Handled = true; } }; ApplicationEvents.OpenDocuments += delegate(object sender, ApplicationDocumentEventArgs e) { //OpenFiles may pump the mainloop, but can't do that from an AppleEvent, so use a brief timeout GLib.Timeout.Add(10, delegate { IdeApp.OpenFiles(e.Documents.Select(doc => new FileOpenInformation(doc.Key, doc.Value, 1, OpenDocumentOptions.Default))); return(false); }); e.Handled = true; }; //if not running inside an app bundle (at dev time), need to do some additional setup if (NSBundle.MainBundle.InfoDictionary ["CFBundleIdentifier"] == null) { SetupWithoutBundle(); } } catch (Exception ex) { LoggingService.LogError("Could not install app event handlers", ex); setupFail = true; } }
protected override void Run() { var item = IdeApp.ProjectOperations.CurrentSelectedProject; IdeApp.OpenFiles(new [] { new FileOpenInformation(item.Files[0].FilePath, item.Files[0].Project) }); }
async void OnDragDataReceived(object o, Gtk.DragDataReceivedArgs args) { if (args.Info != (uint)TargetList.UriList) { return; } string fullData = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data); var loadWorkspaceItems = !IsInsideTabStrip(args.X, args.Y); var files = new List <Ide.Gui.FileOpenInformation> (); foreach (string individualFile in fullData.Split('\n')) { string file = individualFile.Trim(); if (file.StartsWith("file://")) { var filePath = new FilePath(file); if (filePath.IsDirectory) { if (!loadWorkspaceItems) // skip directories when not loading solutions { continue; } filePath = Directory.EnumerateFiles(filePath).FirstOrDefault(p => Services.ProjectService.IsWorkspaceItemFile(p)); } if (!filePath.IsNullOrEmpty) // skip empty paths { files.Add(new Ide.Gui.FileOpenInformation(filePath, null, 0, 0, Ide.Gui.OpenDocumentOptions.DefaultInternal) { DockNotebook = this }); } } } if (files.Count > 0) { if (loadWorkspaceItems) { try { IdeApp.OpenFiles(files); } catch (Exception e) { LoggingService.LogError($"Failed to open dropped files", e); } } else // open workspace items as files { foreach (var file in files) { try { await IdeApp.Workbench.OpenDocument(file).ConfigureAwait(false); } catch (Exception e) { LoggingService.LogError($"unable to open file {file}", e); } } } } }
static void GlobalSetup() { if (initedGlobal || setupFail) { return; } initedGlobal = true; //FIXME: should we remove these when finalizing? try { ApplicationEvents.Quit += delegate(object sender, ApplicationQuitEventArgs e) { if (!IdeApp.Exit()) { e.UserCancelled = true; } e.Handled = true; }; ApplicationEvents.Reopen += delegate(object sender, ApplicationEventArgs e) { if (IdeApp.Workbench != null && IdeApp.Workbench.RootWindow != null) { IdeApp.Workbench.RootWindow.Deiconify(); IdeApp.Workbench.RootWindow.Visible = true; e.Handled = true; } }; ApplicationEvents.OpenDocuments += delegate(object sender, ApplicationDocumentEventArgs e) { //OpenFiles may pump the mainloop, but can't do that from an AppleEvent, so use a brief timeout GLib.Timeout.Add(10, delegate { IdeApp.OpenFiles(e.Documents.Select(doc => new FileOpenInformation(doc.Key, doc.Value, 1, OpenDocumentOptions.Default))); return(false); }); e.Handled = true; }; //if not running inside an app bundle, assume usual MD build layout and load the app icon FilePath exePath = System.Reflection.Assembly.GetExecutingAssembly().Location; if (!exePath.ToString().Contains("MonoDevelop.app")) { var mdSrcMain = exePath.ParentDirectory.ParentDirectory.ParentDirectory; var icons = mdSrcMain.Combine("theme-icons", "Mac", "monodevelop.icns"); if (File.Exists(icons)) { NSApplication.SharedApplication.ApplicationIconImage = new NSImage(icons); } } } catch (Exception ex) { MonoDevelop.Core.LoggingService.LogError("Could not install app event handlers", ex); setupFail = true; } }
protected override void OnRun() { if (IdeApp.ProjectOperations.CurrentSelectedItem is ProjectFolder currentFolder) { try { var documentFilePath = new FilePath(Path.Combine(currentFolder.Path.FullPath, FigmaBundle.DocumentFileName)); IdeApp.OpenFiles(new[] { new Ide.Gui.FileOpenInformation(documentFilePath) }); } catch (Exception ex) { LoggingService.LogInternalError(ex); } } }
protected override Task <Response> HandleOpenFile(OpenFileRequest request) { DispatchToGuiThread(() => { var fileOpenInfo = new FileOpenInformation(new FilePath(request.File), project: null /* autodetect */, line: request.Line ?? 0, column: request.Column ?? 0, options: OpenDocumentOptions.Default ); IdeApp.OpenFiles(new[] { fileOpenInfo }); // Make the Ide window grab focus IdeApp.Workbench.Present(); }); return(Task.FromResult <Response>(new OpenFileResponse { Status = MessageStatus.Ok })); }
static void GlobalSetup() { if (initedGlobal || setupFail) { return; } initedGlobal = true; //FIXME: should we remove these when finalizing? try { ApplicationEvents.Quit += delegate(object sender, ApplicationQuitEventArgs e) { if (!IdeApp.Exit()) { e.UserCancelled = true; } e.Handled = true; }; ApplicationEvents.Reopen += delegate(object sender, ApplicationEventArgs e) { if (IdeApp.Workbench != null && IdeApp.Workbench.RootWindow != null) { IdeApp.Workbench.RootWindow.Deiconify(); IdeApp.Workbench.RootWindow.Visible = true; e.Handled = true; } }; ApplicationEvents.OpenDocuments += delegate(object sender, ApplicationDocumentEventArgs e) { //OpenFiles may pump the mainloop, but can't do that from an AppleEvent, so use a brief timeout GLib.Timeout.Add(10, delegate { IdeApp.OpenFiles(e.Documents.Select(doc => new FileOpenInformation(doc.Key, doc.Value, 1, true))); return(false); }); e.Handled = true; }; } catch (Exception ex) { MonoDevelop.Core.LoggingService.LogError("Could not install app event handlers", ex); setupFail = true; } }
void GlobalSetup() { //FIXME: should we remove these when finalizing? try { ApplicationEvents.Quit += delegate(object sender, ApplicationQuitEventArgs e) { // We can only attempt to quit safely if all windows are GTK windows and not modal if (!IsModalDialogRunning()) { e.UserCancelled = !IdeApp.Exit(); e.Handled = true; return; } // When a modal dialog is running, things are much harder. We can't just shut down MD behind the // dialog, and aborting the dialog may not be appropriate. // // There's NSTerminateLater but I'm not sure how to access it from carbon, maybe // we need to swizzle methods into the app's NSApplicationDelegate. // Also, it stops the main CFRunLoop and enters a special runloop mode, not sure how that would // interact with GTK+. // For now, just bounce NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest); // and abort the quit. e.UserCancelled = true; e.Handled = true; }; ApplicationEvents.Reopen += delegate(object sender, ApplicationEventArgs e) { if (IdeApp.Workbench != null && IdeApp.Workbench.RootWindow != null) { IdeApp.Workbench.RootWindow.Deiconify(); IdeApp.Workbench.RootWindow.Visible = true; IdeApp.Workbench.RootWindow.Present(); e.Handled = true; } }; ApplicationEvents.OpenDocuments += delegate(object sender, ApplicationDocumentEventArgs e) { //OpenFiles may pump the mainloop, but can't do that from an AppleEvent, so use a brief timeout GLib.Timeout.Add(10, delegate { IdeApp.OpenFiles(e.Documents.Select(doc => new FileOpenInformation(doc.Key, doc.Value, 1, OpenDocumentOptions.Default))); return(false); }); e.Handled = true; }; ApplicationEvents.OpenUrls += delegate(object sender, ApplicationUrlEventArgs e) { GLib.Timeout.Add(10, delegate { // Open files via the monodevelop:// URI scheme, compatible with the // common TextMate scheme: http://blog.macromates.com/2007/the-textmate-url-scheme/ IdeApp.OpenFiles(e.Urls.Select(url => { try { var uri = new Uri(url); if (uri.Host != "open") { return(null); } var qs = System.Web.HttpUtility.ParseQueryString(uri.Query); var fileUri = new Uri(qs ["file"]); int line, column; if (!Int32.TryParse(qs ["line"], out line)) { line = 1; } if (!Int32.TryParse(qs ["column"], out column)) { column = 1; } return(new FileOpenInformation(fileUri.AbsolutePath, line, column, OpenDocumentOptions.Default)); } catch (Exception ex) { LoggingService.LogError("Invalid TextMate URI: " + url, ex); return(null); } }).Where(foi => foi != null)); return(false); }); }; //if not running inside an app bundle (at dev time), need to do some additional setup if (NSBundle.MainBundle.InfoDictionary ["CFBundleIdentifier"] == null) { SetupWithoutBundle(); } } catch (Exception ex) { LoggingService.LogError("Could not install app event handlers", ex); setupFail = true; } }
static void GlobalSetup() { if (initedGlobal || setupFail) { return; } initedGlobal = true; //FIXME: should we remove these when finalizing? try { ApplicationEvents.Quit += delegate(object sender, ApplicationQuitEventArgs e) { //FIXME: can we avoid replying to the message until the app quits? //There's NSTerminateLate but I'm not sure how to access it from carbon, maybe //we need to swizzle methods into the app's NSApplicationDelegate. //Also, it stops the main CFRunLoop, hopefully GTK dialogs use a child runloop. //For now, just bounce. var topDialog = MessageService.GetDefaultModalParent() as Gtk.Dialog; if (topDialog != null && topDialog.Modal) { NSApplication.SharedApplication.RequestUserAttention( NSRequestUserAttentionType.CriticalRequest); } //FIXME: delay this until all existing modal dialogs were closed if (!IdeApp.Exit()) { e.UserCancelled = true; } e.Handled = true; }; ApplicationEvents.Reopen += delegate(object sender, ApplicationEventArgs e) { if (IdeApp.Workbench != null && IdeApp.Workbench.RootWindow != null) { IdeApp.Workbench.RootWindow.Deiconify(); // This is a workaround to a GTK+ bug. The HasTopLevelFocus flag is not properly // set when the main window is restored. The workaround is to hide and re-show it. // Since this happens before the next mainloop cycle, the window isn't actually affected. IdeApp.Workbench.RootWindow.Hide(); IdeApp.Workbench.RootWindow.Show(); IdeApp.Workbench.RootWindow.Present(); e.Handled = true; } }; ApplicationEvents.OpenDocuments += delegate(object sender, ApplicationDocumentEventArgs e) { //OpenFiles may pump the mainloop, but can't do that from an AppleEvent, so use a brief timeout GLib.Timeout.Add(10, delegate { IdeApp.OpenFiles(e.Documents.Select(doc => new FileOpenInformation(doc.Key, doc.Value, 1, OpenDocumentOptions.Default))); return(false); }); e.Handled = true; }; //if not running inside an app bundle, assume usual MD build layout and load the app icon FilePath exePath = System.Reflection.Assembly.GetExecutingAssembly().Location; if (!exePath.ToString().Contains("MonoDevelop.app")) { var mdSrcMain = exePath.ParentDirectory.ParentDirectory.ParentDirectory; var icons = mdSrcMain.Combine("theme-icons", "Mac", "monodevelop.icns"); if (File.Exists(icons)) { NSApplication.SharedApplication.ApplicationIconImage = new NSImage(icons); } } } catch (Exception ex) { MonoDevelop.Core.LoggingService.LogError("Could not install app event handlers", ex); setupFail = true; } }
void GlobalSetup() { //FIXME: should we remove these when finalizing? try { ApplicationEvents.Quit += delegate(object sender, ApplicationQuitEventArgs e) { // We can only attempt to quit safely if all windows are GTK windows and not modal if (GtkQuartz.GetToplevels().All(t => t.Value != null && (!t.Value.Visible || !t.Value.Modal))) { e.UserCancelled = !IdeApp.Exit(); e.Handled = true; return; } // When a modal dialog is running, things are much harder. We can't just shut down MD behind the // dialog, and aborting the dialog may not be appropriate. // // There's NSTerminateLater but I'm not sure how to access it from carbon, maybe // we need to swizzle methods into the app's NSApplicationDelegate. // Also, it stops the main CFRunLoop and enters a special runloop mode, not sure how that would // interact with GTK+. // For now, just bounce NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest); // and abort the quit. e.UserCancelled = true; e.Handled = true; }; ApplicationEvents.Reopen += delegate(object sender, ApplicationEventArgs e) { if (IdeApp.Workbench != null && IdeApp.Workbench.RootWindow != null) { IdeApp.Workbench.RootWindow.Deiconify(); // This is a workaround to a GTK+ bug. The HasTopLevelFocus flag is not properly // set when the main window is restored. The workaround is to hide and re-show it. // Since this happens before the next mainloop cycle, the window isn't actually affected. IdeApp.Workbench.RootWindow.Hide(); IdeApp.Workbench.RootWindow.Show(); IdeApp.Workbench.RootWindow.Present(); e.Handled = true; } }; ApplicationEvents.OpenDocuments += delegate(object sender, ApplicationDocumentEventArgs e) { //OpenFiles may pump the mainloop, but can't do that from an AppleEvent, so use a brief timeout GLib.Timeout.Add(10, delegate { IdeApp.OpenFiles(e.Documents.Select(doc => new FileOpenInformation(doc.Key, doc.Value, 1, OpenDocumentOptions.Default))); return(false); }); e.Handled = true; }; //if not running inside an app bundle, assume usual MD build layout and load the app icon FilePath exePath = System.Reflection.Assembly.GetExecutingAssembly().Location; string iconFile = null; iconFile = BrandingService.GetString("ApplicationIcon"); if (iconFile != null) { iconFile = BrandingService.GetFile(iconFile); } else if (!exePath.ToString().Contains("MonoDevelop.app")) { var mdSrcMain = exePath.ParentDirectory.ParentDirectory.ParentDirectory; iconFile = mdSrcMain.Combine("theme-icons", "Mac", "monodevelop.icns"); } else { //HACK: override the app image //NSApplication doesn't seem to pick up the image correctly, probably due to the //getting confused about the bundle root because of the launch script var bundleContents = exePath.ParentDirectory.ParentDirectory.ParentDirectory .ParentDirectory.ParentDirectory; iconFile = bundleContents.Combine("Resources", "monodevelop.icns"); } if (File.Exists(iconFile)) { NSApplication.SharedApplication.ApplicationIconImage = new NSImage(iconFile); } } catch (Exception ex) { LoggingService.LogError("Could not install app event handlers", ex); setupFail = true; } }
private void ProcessMessage(string message) { try { var msg = Decode(message); string cmd; if (!msg.TryGetValue("command", out cmd)) { LoggingService.LogError("Unity Tools: no command provided in '" + message + "'"); return; } if (cmd == "open") { string path; if (!msg.TryGetValue("path", out path)) { LoggingService.LogWarning(string.Format("Unity Tools: no path provided in '{0}'", message)); return; } int line = 0; string lineStr; if (msg.TryGetValue("line", out lineStr)) { int.TryParse(lineStr, out line); } var files = new List <FileOpenInformation>(); string solution; if (msg.TryGetValue("solution", out solution) && !string.IsNullOrWhiteSpace(solution)) { var sol = IdeApp.ProjectOperations.CurrentSelectedSolution; if (sol == null || !string.Equals(solution, sol.FileName, StringComparison.InvariantCultureIgnoreCase)) { files.Add(new FileOpenInformation( new FilePath(solution), null, 0, 0, OpenDocumentOptions.TryToReuseViewer | OpenDocumentOptions.BringToFront | OpenDocumentOptions.CenterCaretLine )); } } files.Add(new FileOpenInformation( new FilePath(path), null, line, 0, OpenDocumentOptions.TryToReuseViewer | OpenDocumentOptions.BringToFront | OpenDocumentOptions.CenterCaretLine )); IdeApp.OpenFiles(files.ToArray()); } else { LoggingService.LogWarning(string.Format("Unity Tools: unknown command '{0}' in '{1}'", cmd, message)); } } catch (Exception ex) { LoggingService.LogError("Unity Tools: unable to process message '" + message + "'", ex); } }
protected override void Run() { base.Run(); IdeApp.Exiting += (object sender, ExitEventArgs args) => { Service.Shutdown(); }; string file = null; string line = null; string solution = null; var cargs = Environment.GetCommandLineArgs(); int i = 1; while (i < cargs.Length - 1) { var a = cargs[i]; if (a == "--tortuga-team-file") { file = cargs[i + 1]; i++; } else if (a == "--tortuga-team-line") { line = cargs[i + 1]; i++; } else if (a == "--tortuga-team-solution") { solution = cargs[i + 1]; i++; } i++; } if (!string.IsNullOrWhiteSpace(file) || !string.IsNullOrWhiteSpace(solution)) { IdeApp.Initialized += (object sender, EventArgs e) => { var files = new List <FileOpenInformation>(); if (!string.IsNullOrWhiteSpace(solution)) { files.Add(new FileOpenInformation( new FilePath(solution), null, 0, 0, OpenDocumentOptions.TryToReuseViewer | OpenDocumentOptions.BringToFront | OpenDocumentOptions.CenterCaretLine )); } if (!string.IsNullOrWhiteSpace(file)) { int lineNum; if (line == null || !int.TryParse(line, out lineNum)) { lineNum = 0; } files.Add(new FileOpenInformation( new FilePath(file), null, lineNum, 0, OpenDocumentOptions.TryToReuseViewer | OpenDocumentOptions.BringToFront | OpenDocumentOptions.CenterCaretLine )); } IdeApp.OpenFiles(files.ToArray()); }; } Service.Initialize(); }