private void Initialize(IHttpServer server) { m_log.DebugFormat("[Wifi]: Initializing. Server at port {0}.", server.Port); IConfig serverConfig = m_Config.Configs[ConfigName]; if (serverConfig == null) { throw new Exception(String.Format("No section {0} in config file", ConfigName)); } // Launch the WebApp m_WebApp = new WebApp(m_Config, ConfigName, m_Server, m_SceneActor); // Register all the handlers BaseStreamHandler defaultHandler = new WifiDefaultHandler(m_WebApp); AddStreamHandler(defaultHandler); AddStreamHandler(new WifiRootHandler(defaultHandler)); AddStreamHandler(new WifiHeadHandler(m_WebApp)); AddStreamHandler(new WifiNotifyHandler(m_WebApp)); AddStreamHandler(new WifiInstallGetHandler(m_WebApp)); AddStreamHandler(new WifiInstallPostHandler(m_WebApp)); AddStreamHandler(new WifiLoginHandler(m_WebApp)); AddStreamHandler(new WifiLogoutHandler(m_WebApp)); AddStreamHandler(new WifiForgotPasswordGetHandler(m_WebApp)); AddStreamHandler(new WifiForgotPasswordPostHandler(m_WebApp)); AddStreamHandler(new WifiPasswordRecoverGetHandler(m_WebApp)); AddStreamHandler(new WifiPasswordRecoverPostHandler(m_WebApp)); AddStreamHandler(new WifiUserAccountGetHandler(m_WebApp)); AddStreamHandler(new WifiUserAccountPostHandler(m_WebApp)); AddStreamHandler(new WifiUserManagementGetHandler(m_WebApp)); AddStreamHandler(new WifiUserManagementPostHandler(m_WebApp)); AddStreamHandler(new WifiConsoleHandler(m_WebApp)); AddStreamHandler(new WifiInventoryLoadGetHandler(m_WebApp)); AddStreamHandler(new WifiInventoryGetHandler(m_WebApp)); AddStreamHandler(new WifiInventoryPostHandler(m_WebApp)); AddStreamHandler(new WifiHyperlinkGetHandler(m_WebApp)); AddStreamHandler(new WifiHyperlinkPostHandler(m_WebApp)); AddStreamHandler(new WifiTOSGetHandler(m_WebApp)); AddStreamHandler(new WifiTOSPostHandler(m_WebApp)); AddStreamHandler(new WifiGroupsManagementGetHandler(m_WebApp)); AddStreamHandler(new WifiGroupsManagementPostHandler(m_WebApp)); //server.AddStreamHandler(new WifiRegionManagementPostHandler(app)); //server.AddStreamHandler(new WifiRegionManagementGetHandler(app)); // Add handlers for serving configured paths IEnumerable <string> servePaths = serverConfig.GetKeys().Where(option => option.StartsWith(m_ServePathPrefix)); if (servePaths.Count() > 0) { foreach (string servePath in servePaths) { string paths = serverConfig.GetString(servePath, string.Empty); string[] parts = paths.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Count() == 2) { AddStreamHandler(new WifiGetHandler(parts[0], parts[1])); } else { m_log.WarnFormat("[Wifi]: Invalid format with configuration option {0}: {1}", servePath, paths); } } } // Load addons IEnumerable <string> addonVars = serverConfig.GetKeys().Where(option => option.StartsWith(m_AddonPrefix)); if (addonVars.Count() > 0) { foreach (string addonVar in addonVars) { string addonDll = serverConfig.GetString(addonVar, string.Empty); if (addonDll != string.Empty) { m_log.InfoFormat("[Wifi]: Loading addon {0}", addonDll); object[] args = new object[] { m_Config, ConfigName, m_Server, m_WebApp }; IWifiAddon addon = ServerUtils.LoadPlugin <IWifiAddon>(addonDll, args); if (addon == null) { m_log.WarnFormat("[Wifi]: Unable to load addon {0}", addonDll); } } } } // Load Wifi addons as mono addins, if they exist try { AddinManager.AddExtensionNodeHandler("/Diva/Wifi/Addon", OnExtensionChanged); } catch (InvalidOperationException e) { m_log.DebugFormat("[Wifi]: extension point /Diva/Wifi/Addon not found"); } }
public override ICollection GetStandardStrings(ITypeDescriptorContext context) { var file = (context?.Instance as ProjectFileDescriptor)?.file; // determine which registered tools are valid for this file var registeredTools = AddinManager.GetExtensionNodes <CustomToolExtensionNode> ( "/MonoDevelop/Ide/CustomTools" ); // this shouldn't ever happen, but handle it just in case if (file == null) { var arr = registeredTools.Select(n => n.Name).Distinct().ToArray(); Array.Sort(arr, StringComparer.Ordinal); return(arr); } var extension = file.FilePath.Extension; var dedup = new HashSet <string> (StringComparer.OrdinalIgnoreCase); var values = new List <string> (); var toolsMap = registeredTools.ToDictionary(n => n.Name, StringComparer.OrdinalIgnoreCase); //add sections with values that other files in the project have //first, a section with values that files with this file's extension have //then, a section with values that other files have if (file?.Project != null) { var otherExtTools = new HashSet <string> (); // first, add all the tools that other files with this extension have // as these are the most likely to be the the ones that the user wants foreach (var f in file.Project.Files) { if (!string.IsNullOrEmpty(f.Generator)) { if (f.FilePath.HasExtension(extension)) { if (dedup.Add(f.Generator)) { values.Add(f.Generator); toolsMap.Remove(f.Generator); } } else { otherExtTools.Add(f.Generator); } } } // next, add all the tools that other files with this extension have, as there may be custom // tools used in the project that we're not aware of. if (otherExtTools.Count > 0) { foreach (var toolName in otherExtTools) { // however, skip them if they match one of the registered tools and are not marked // as compatible with this file's extension. if (toolsMap.TryGetValue(toolName, out var t) && !IsCompatible(t)) { continue; } if (dedup.Add(toolName)) { values.Add(toolName); toolsMap.Remove(toolName); } } } values.Sort(StringComparer.OrdinalIgnoreCase); } //add a section with any remaining registered tools that can handle the file if (toolsMap.Count > 0) { var tools = registeredTools .Where(t => dedup.Add(t.Name) && IsCompatible(t)) .Select(t => t.Name) .ToList(); if (tools.Count > 0) { tools.Sort(StringComparer.OrdinalIgnoreCase); values.Add("--"); values.AddRange(tools); } } bool IsCompatible(CustomToolExtensionNode node) { if (node.Extensions == null || node.Extensions.Length == 0) { return(true); } foreach (var ext in node.Extensions) { if (string.Equals(extension, ext, StringComparison.OrdinalIgnoreCase)) { return(true); } } return(false); } return(values); }
int Run(MonoDevelopOptions options) { LoggingService.LogInfo("Starting {0} {1}", BrandingService.ApplicationName, IdeVersionInfo.MonoDevelopVersion); LoggingService.LogInfo("Running on {0}", IdeVersionInfo.GetRuntimeInfo()); Counters.Initialization.BeginTiming(); if (options.PerfLog) { string logFile = Path.Combine(Environment.CurrentDirectory, "monodevelop.perf-log"); LoggingService.LogInfo("Logging instrumentation service data to file: " + logFile); InstrumentationService.StartAutoSave(logFile, 1000); } //ensure native libs initialized before we hit anything that p/invokes Platform.Initialize(); Counters.Initialization.Trace("Initializing GTK"); if (Platform.IsWindows && !CheckWindowsGtk()) { return(1); } SetupExceptionManager(); try { GLibLogging.Enabled = true; } catch (Exception ex) { LoggingService.LogError("Error initialising GLib logging.", ex); } SetupTheme(); var args = options.RemainingArgs.ToArray(); Gtk.Application.Init(BrandingService.ApplicationName, ref args); LoggingService.LogInfo("Using GTK+ {0}", IdeVersionInfo.GetGtkVersion()); // XWT initialization FilePath p = typeof(IdeStartup).Assembly.Location; Assembly.LoadFrom(p.ParentDirectory.Combine("Xwt.Gtk.dll")); Xwt.Application.InitializeAsGuest(Xwt.ToolkitType.Gtk); Xwt.Toolkit.CurrentEngine.RegisterBackend <IExtendedTitleBarWindowBackend, GtkExtendedTitleBarWindowBackend> (); //default to Windows IME on Windows if (Platform.IsWindows && Mono.TextEditor.GtkWorkarounds.GtkMinorVersion >= 16) { var settings = Gtk.Settings.Default; var val = Mono.TextEditor.GtkWorkarounds.GetProperty(settings, "gtk-im-module"); if (string.IsNullOrEmpty(val.Val as string)) { Mono.TextEditor.GtkWorkarounds.SetProperty(settings, "gtk-im-module", new GLib.Value("ime")); } } InternalLog.Initialize(); string socket_filename = null; EndPoint ep = null; DispatchService.Initialize(); // Set a synchronization context for the main gtk thread SynchronizationContext.SetSynchronizationContext(new GtkSynchronizationContext()); Runtime.MainSynchronizationContext = SynchronizationContext.Current; AddinManager.AddinLoadError += OnAddinError; var startupInfo = new StartupInfo(args); // If a combine was specified, force --newwindow. if (!options.NewWindow && startupInfo.HasFiles) { Counters.Initialization.Trace("Pre-Initializing Runtime to load files in existing window"); Runtime.Initialize(true); foreach (var file in startupInfo.RequestedFileList) { if (MonoDevelop.Projects.Services.ProjectService.IsWorkspaceItemFile(file.FileName)) { options.NewWindow = true; break; } } } Counters.Initialization.Trace("Initializing Runtime"); Runtime.Initialize(true); IdeApp.Customizer = options.IdeCustomizer ?? new IdeCustomizer(); Counters.Initialization.Trace("Initializing theme and splash window"); DefaultTheme = Gtk.Settings.Default.ThemeName; string theme = IdeApp.Preferences.UserInterfaceTheme; if (string.IsNullOrEmpty(theme)) { theme = DefaultTheme; } ValidateGtkTheme(ref theme); if (theme != DefaultTheme) { Gtk.Settings.Default.ThemeName = theme; } //don't show the splash screen on the Mac, so instead we get the expected "Dock bounce" effect //this also enables the Mac platform service to subscribe to open document events before the GUI loop starts. if (Platform.IsMac) { options.NoSplash = true; } IProgressMonitor monitor = null; if (!options.NoSplash) { try { monitor = new SplashScreenForm(); ((SplashScreenForm)monitor).ShowAll(); } catch (Exception ex) { LoggingService.LogError("Failed to create splash screen", ex); } } if (monitor == null) { monitor = new MonoDevelop.Core.ProgressMonitoring.ConsoleProgressMonitor(); } monitor.BeginTask(GettextCatalog.GetString("Starting {0}", BrandingService.ApplicationName), 2); //make sure that the platform service is initialised so that the Mac platform can subscribe to open-document events Counters.Initialization.Trace("Initializing Platform Service"); DesktopService.Initialize(); monitor.Step(1); if (options.IpcTcp) { listen_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); ep = new IPEndPoint(IPAddress.Loopback, ipcBasePort + HashSdbmBounded(Environment.UserName)); } else { socket_filename = "/tmp/md-" + Environment.GetEnvironmentVariable("USER") + "-socket"; listen_socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP); ep = new UnixEndPoint(socket_filename); } // If not opening a combine, connect to existing monodevelop and pass filename(s) and exit if (!options.NewWindow && startupInfo.HasFiles) { try { StringBuilder builder = new StringBuilder(); foreach (var file in startupInfo.RequestedFileList) { builder.AppendFormat("{0};{1};{2}\n", file.FileName, file.Line, file.Column); } listen_socket.Connect(ep); listen_socket.Send(Encoding.UTF8.GetBytes(builder.ToString())); return(0); } catch { // Reset the socket if (null != socket_filename && File.Exists(socket_filename)) { File.Delete(socket_filename); } } } Counters.Initialization.Trace("Checking System"); string version = Assembly.GetEntryAssembly().GetName().Version.Major + "." + Assembly.GetEntryAssembly().GetName().Version.Minor; if (Assembly.GetEntryAssembly().GetName().Version.Build != 0) { version += "." + Assembly.GetEntryAssembly().GetName().Version.Build; } if (Assembly.GetEntryAssembly().GetName().Version.Revision != 0) { version += "." + Assembly.GetEntryAssembly().GetName().Version.Revision; } CheckFileWatcher(); Exception error = null; int reportedFailures = 0; try { Counters.Initialization.Trace("Loading Icons"); //force initialisation before the workbench so that it can register stock icons for GTK before they get requested ImageService.Initialize(); if (errorsList.Count > 0) { if (monitor is SplashScreenForm) { ((SplashScreenForm)monitor).Hide(); } AddinLoadErrorDialog dlg = new AddinLoadErrorDialog((AddinError[])errorsList.ToArray(typeof(AddinError)), false); if (!dlg.Run()) { return(1); } if (monitor is SplashScreenForm) { ((SplashScreenForm)monitor).Show(); } reportedFailures = errorsList.Count; } // no alternative for Application.ThreadException? // Application.ThreadException += new ThreadExceptionEventHandler(ShowErrorBox); Counters.Initialization.Trace("Initializing IdeApp"); IdeApp.Initialize(monitor); // Load requested files Counters.Initialization.Trace("Opening Files"); IdeApp.OpenFiles(startupInfo.RequestedFileList); monitor.Step(1); } catch (Exception e) { error = e; } finally { monitor.Dispose(); } if (error != null) { LoggingService.LogFatalError(null, error); string message = BrandingService.BrandApplicationName(GettextCatalog.GetString( "MonoDevelop failed to start. The following error has been reported: {0}", error.Message )); MessageService.ShowException(error, message); return(1); } if (errorsList.Count > reportedFailures) { AddinLoadErrorDialog dlg = new AddinLoadErrorDialog((AddinError[])errorsList.ToArray(typeof(AddinError)), true); dlg.Run(); } errorsList = null; // FIXME: we should probably track the last 'selected' one // and do this more cleanly try { listen_socket.Bind(ep); listen_socket.Listen(5); listen_socket.BeginAccept(new AsyncCallback(ListenCallback), listen_socket); } catch { // Socket already in use } initialized = true; MessageService.RootWindow = IdeApp.Workbench.RootWindow; Thread.CurrentThread.Name = "GUI Thread"; Counters.Initialization.Trace("Running IdeApp"); Counters.Initialization.EndTiming(); AddinManager.AddExtensionNodeHandler("/MonoDevelop/Ide/InitCompleteHandlers", OnExtensionChanged); StartLockupTracker(); IdeApp.Run(); // unloading services if (null != socket_filename) { File.Delete(socket_filename); } lockupCheckRunning = false; Runtime.Shutdown(); InstrumentationService.Stop(); AddinManager.AddinLoadError -= OnAddinError; return(0); }
public void TestFixtureSetUp() { AddinManager.Initialize(); AddinManager.Registry.Update(null); }
public SingleView(SafeUri [] uris) { uri = uris [0]; Log.Debug("uri: " + uri); var builder = new GtkBeans.Builder("single_view.ui"); builder.Autoconnect(this); LoadPreference(Preferences.VIEWER_WIDTH); LoadPreference(Preferences.VIEWER_MAXIMIZED); Gtk.Toolbar toolbar = new Gtk.Toolbar(); toolbar_hbox.PackStart(toolbar); rl_button = GtkUtil.ToolButtonFromTheme("object-rotate-left", Catalog.GetString("Rotate Left"), true); rl_button.Clicked += HandleRotate270Command; rl_button.TooltipText = Catalog.GetString("Rotate photo left"); toolbar.Insert(rl_button, -1); rr_button = GtkUtil.ToolButtonFromTheme("object-rotate-right", Catalog.GetString("Rotate Right"), true); rr_button.Clicked += HandleRotate90Command; rr_button.TooltipText = Catalog.GetString("Rotate photo right"); toolbar.Insert(rr_button, -1); toolbar.Insert(new SeparatorToolItem(), -1); ToolButton fs_button = GtkUtil.ToolButtonFromTheme("view-fullscreen", Catalog.GetString("Fullscreen"), true); fs_button.Clicked += HandleViewFullscreen; fs_button.TooltipText = Catalog.GetString("View photos fullscreen"); toolbar.Insert(fs_button, -1); ToolButton ss_button = GtkUtil.ToolButtonFromTheme("media-playback-start", Catalog.GetString("Slideshow"), true); ss_button.Clicked += HandleViewSlideshow; ss_button.TooltipText = Catalog.GetString("View photos in a slideshow"); toolbar.Insert(ss_button, -1); collection = new UriCollection(uris); TargetList targetList = new TargetList(); targetList.AddTextTargets((uint)DragDropTargets.TargetType.PlainText); targetList.AddUriTargets((uint)DragDropTargets.TargetType.UriList); directory_view = new SelectionCollectionGridView(collection); directory_view.Selection.Changed += HandleSelectionChanged; directory_view.DragDataReceived += HandleDragDataReceived; Gtk.Drag.DestSet(directory_view, DestDefaults.All, (TargetEntry[])targetList, DragAction.Copy | DragAction.Move); directory_view.DisplayTags = false; directory_view.DisplayDates = false; directory_view.DisplayRatings = false; directory_scrolled = new ScrolledWindow(); directory_scrolled.Add(directory_view); sidebar = new Sidebar(); info_vbox.Add(sidebar); sidebar.AppendPage(directory_scrolled, Catalog.GetString("Folder"), "gtk-directory"); AddinManager.AddExtensionNodeHandler("/FSpot/Sidebar", OnSidebarExtensionChanged); sidebar.Context = ViewContext.Single; sidebar.CloseRequested += HandleHideSidePane; sidebar.Show(); App.Instance.Container.Resolve <IThumbnailLoader> ().OnPixbufLoaded += delegate { directory_view.QueueDraw(); }; image_view = new PhotoImageView(collection); GtkUtil.ModifyColors(image_view); GtkUtil.ModifyColors(image_scrolled); image_view.ZoomChanged += HandleZoomChanged; image_view.Item.Changed += HandleItemChanged; image_view.ButtonPressEvent += HandleImageViewButtonPressEvent; image_view.DragDataReceived += HandleDragDataReceived; Gtk.Drag.DestSet(image_view, DestDefaults.All, (TargetEntry[])targetList, DragAction.Copy | DragAction.Move); image_scrolled.Add(image_view); Window.ShowAll(); zoom_scale.ValueChanged += HandleZoomScaleValueChanged; LoadPreference(Preferences.VIEWER_SHOW_TOOLBAR); LoadPreference(Preferences.VIEWER_INTERPOLATION); LoadPreference(Preferences.VIEWER_TRANSPARENCY); LoadPreference(Preferences.VIEWER_TRANS_COLOR); ShowSidebar = collection.Count > 1; LoadPreference(Preferences.VIEWER_SHOW_FILENAMES); Preferences.SettingChanged += OnPreferencesChanged; Window.DeleteEvent += HandleDeleteEvent; collection.Changed += HandleCollectionChanged; // wrap the methods to fit to the delegate image_view.Item.Changed += delegate(object sender, BrowsablePointerChangedEventArgs old) { BrowsablePointer pointer = sender as BrowsablePointer; if (pointer == null) { return; } IPhoto [] item = { pointer.Current }; sidebar.HandleSelectionChanged(new PhotoList(item)); }; image_view.Item.Collection.ItemsChanged += sidebar.HandleSelectionItemsChanged; UpdateStatusLabel(); if (collection.Count > 0) { directory_view.Selection.Add(0); } export.Submenu = (Mono.Addins.AddinManager.GetExtensionNode("/FSpot/Menus/Exports") as FSpot.Extensions.SubmenuNode).GetMenuItem(this).Submenu; export.Submenu.ShowAll(); export.Activated += HandleExportActivated; }
public OptionsDialog(Gtk.Window parentWindow, object dataObject, string extensionPath, bool removeEmptySections) { buttonCancel = new Gtk.Button(Gtk.Stock.Cancel); AddActionWidget(this.buttonCancel, ResponseType.Cancel); buttonOk = new Gtk.Button(Gtk.Stock.Ok); this.ActionArea.PackStart(buttonOk); buttonOk.Clicked += OnButtonOkClicked; mainHBox = new HBox(); tree = new TreeView(); var sw = new ScrolledWindow(); sw.Add(tree); sw.HscrollbarPolicy = PolicyType.Never; sw.VscrollbarPolicy = PolicyType.Automatic; sw.ShadowType = ShadowType.None; var fboxTree = new HeaderBox(); fboxTree.SetMargins(0, 1, 0, 1); fboxTree.SetPadding(0, 0, 0, 0); fboxTree.BackgroundColor = new Gdk.Color(255, 255, 255); fboxTree.Add(sw); mainHBox.PackStart(fboxTree, false, false, 0); Realized += delegate { fboxTree.BackgroundColor = tree.Style.Base(Gtk.StateType.Normal); }; var vbox = new VBox(); mainHBox.PackStart(vbox, true, true, 0); var headerBox = new HBox(false, 6); image = new Image(); // headerBox.PackStart (image, false, false, 0); labelTitle = new Label(); labelTitle.Xalign = 0; textHeader = new Alignment(0, 0, 1, 1); textHeader.Add(labelTitle); textHeader.BorderWidth = 12; headerBox.PackStart(textHeader, true, true, 0); imageHeader = new OptionsDialogHeader(); imageHeader.Hide(); headerBox.PackStart(imageHeader.ToGtkWidget()); var fboxHeader = new HeaderBox(); fboxHeader.SetMargins(0, 1, 0, 0); fboxHeader.Add(headerBox); // fbox.GradientBackround = true; // fbox.BackgroundColor = new Gdk.Color (255, 255, 255); Realized += delegate { var c = new HslColor(Style.Background(Gtk.StateType.Normal)); c.L += 0.09; fboxHeader.BackgroundColor = c; }; vbox.PackStart(fboxHeader, false, false, 0); pageFrame = new HBox(); var fbox = new HeaderBox(); fbox.SetMargins(0, 1, 0, 0); fbox.ShowTopShadow = true; fbox.Add(pageFrame); vbox.PackStart(fbox, true, true, 0); this.VBox.PackStart(mainHBox, true, true, 0); this.removeEmptySections = removeEmptySections; extensionContext = AddinManager.CreateExtensionContext(); this.mainDataObject = dataObject; this.extensionPath = extensionPath; if (parentWindow != null) { TransientFor = parentWindow; } ImageService.EnsureStockIconIsLoaded(emptyCategoryIcon, treeIconSize); ImageService.EnsureStockIconIsLoaded(emptyCategoryIcon, headerIconSize); store = new TreeStore(typeof(OptionsDialogSection)); tree.Model = store; tree.HeadersVisible = false; // Column 0 is used to add some padding at the left of the expander TreeViewColumn col0 = new TreeViewColumn(); col0.MinWidth = 6; tree.AppendColumn(col0); TreeViewColumn col = new TreeViewColumn(); var crp = new CellRendererPixbuf(); col.PackStart(crp, false); col.SetCellDataFunc(crp, PixbufCellDataFunc); var crt = new CellRendererText(); col.PackStart(crt, true); col.SetCellDataFunc(crt, TextCellDataFunc); tree.AppendColumn(col); tree.ExpanderColumn = col; tree.Selection.Changed += OnSelectionChanged; Child.ShowAll(); InitializeContext(extensionContext); FillTree(); ExpandCategories(); this.DefaultResponse = Gtk.ResponseType.Ok; DefaultWidth = 722; DefaultHeight = 502; }
static TypeSystemService() { CleanupCache(); parsers = AddinManager.GetExtensionNodes <TypeSystemParserNode> ("/MonoDevelop/TypeSystem/Parser"); bool initialLoad = true; AddinManager.AddExtensionNodeHandler("/MonoDevelop/TypeSystem/Parser", delegate(object sender, ExtensionNodeEventArgs args) { //refresh entire list to respect insertbefore/insertafter ordering if (!initialLoad) { parsers = AddinManager.GetExtensionNodes <TypeSystemParserNode> ("/MonoDevelop/TypeSystem/Parser"); } }); initialLoad = false; try { emptyWorkspace = new MonoDevelopWorkspace(null); } catch (Exception e) { LoggingService.LogFatalError("Can't create roslyn workspace", e); } FileService.FileChanged += delegate(object sender, FileEventArgs e) { // if (!TrackFileChanges) // return; var filesToUpdate = new List <string> (); foreach (var file in e) { // Open documents are handled by the Document class itself. if (IdeApp.Workbench != null && IdeApp.Workbench.GetDocument(file.FileName) != null) { continue; } foreach (var w in workspaces) { foreach (var p in w.CurrentSolution.ProjectIds) { if (w.GetDocumentId(p, file.FileName) != null) { filesToUpdate.Add(file.FileName); goto found; } } } found :; } if (filesToUpdate.Count == 0) { return; } Task.Run(delegate { try { foreach (var file in filesToUpdate) { var text = MonoDevelop.Core.Text.StringTextSource.ReadFrom(file).Text; foreach (var w in workspaces) { w.UpdateFileContent(file, text); } } Gtk.Application.Invoke((o, args) => { if (IdeApp.Workbench != null) { foreach (var w in IdeApp.Workbench.Documents) { w.StartReparseThread(); } } }); } catch (Exception) {} }); }; IntitializeTrackedProjectHandling(); }
static void UpdatePlugins() { AddinManager.Initialize(FSpot.Core.Global.BaseDirectory); AddinManager.Registry.Update(null); }
static WebBrowserService() { AddinManager.AddExtensionNodeHandler(browserPath, new ExtensionNodeEventHandler(extensionHandler)); }
public GeneralOptionsPanel() { this.Build(); object[] compilers = AddinManager.GetExtensionObjects("/CBinding/Compilers"); foreach (ICompiler compiler in compilers) { if (compiler.Language == Language.C) { c_compilers.Add(compiler); } else if (compiler.Language == Language.CPP) { cpp_compilers.Add(compiler); } } foreach (ICompiler compiler in c_compilers) { cCombo.AppendText(compiler.Name); } foreach (ICompiler compiler in cpp_compilers) { cppCombo.AppendText(compiler.Name); } string c_compiler = PropertyService.Get <string> ("CBinding.DefaultCCompiler", new GccCompiler().Name); string cpp_compiler = PropertyService.Get <string> ("CBinding.DefaultCppCompiler", new GppCompiler().Name); ctagsEntry.Text = PropertyService.Get <string> ("CBinding.CTagsExecutable", "ctags"); parseSystemTagsCheck.Active = PropertyService.Get <bool> ("CBinding.ParseSystemTags", true); parseLocalVariablesCheck.Active = PropertyService.Get <bool> ("CBinding.ParseLocalVariables", false); foreach (ICompiler compiler in c_compilers) { if (compiler.Name == c_compiler) { default_c_compiler = compiler; } } if (default_c_compiler == null) { default_c_compiler = new GccCompiler(); } foreach (ICompiler compiler in cpp_compilers) { if (compiler.Name == cpp_compiler) { default_cpp_compiler = compiler; } } if (default_cpp_compiler == null) { default_cpp_compiler = new GppCompiler(); } int active; Gtk.TreeIter iter; Gtk.ListStore store; active = 0; store = (Gtk.ListStore)cCombo.Model; store.GetIterFirst(out iter); while (store.IterIsValid(iter)) { if ((string)store.GetValue(iter, 0) == default_c_compiler.Name) { break; } store.IterNext(ref iter); active++; } cCombo.Active = active; active = 0; store = (Gtk.ListStore)cppCombo.Model; store.GetIterFirst(out iter); while (store.IterIsValid(iter)) { if ((string)store.GetValue(iter, 0) == default_cpp_compiler.Name) { break; } store.IterNext(ref iter); active++; } cppCombo.Active = active; }
public void Initialise(OpenSimBase openSim) { m_openSim = openSim; m_openSim.ApplicationRegistry.RegisterInterface <IRegionModulesController>(this); m_log.DebugFormat("[REGIONMODULES]: Initializing..."); if (!LoadModulesFromAddins) { return; } // Who we are string id = AddinManager.CurrentAddin.Id; // Make friendly name int pos = id.LastIndexOf("."); if (pos == -1) { m_name = id; } else { m_name = id.Substring(pos + 1); } // The [Modules] section in the ini file IConfig modulesConfig = m_openSim.ConfigSource.Source.Configs["Modules"]; if (modulesConfig == null) { modulesConfig = m_openSim.ConfigSource.Source.AddConfig("Modules"); } Dictionary <RuntimeAddin, IList <int> > loadedModules = new Dictionary <RuntimeAddin, IList <int> >(); // Scan modules and load all that aren't disabled foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/OpenSim/RegionModules")) { AddNode(node, modulesConfig, loadedModules); } foreach (KeyValuePair <RuntimeAddin, IList <int> > loadedModuleData in loadedModules) { m_log.InfoFormat( "[REGIONMODULES]: From plugin {0}, (version {1}), loaded {2} modules, {3} shared, {4} non-shared {5} unknown", loadedModuleData.Key.Id, loadedModuleData.Key.Version, loadedModuleData.Value[0] + loadedModuleData.Value[1] + loadedModuleData.Value[2], loadedModuleData.Value[0], loadedModuleData.Value[1], loadedModuleData.Value[2]); } // Load and init the module. We try a constructor with a port // if a port was given, fall back to one without if there is // no port or the more specific constructor fails. // This will be removed, so that any module capable of using a port // must provide a constructor with a port in the future. // For now, we do this so migration is easy. // foreach (TypeExtensionNode node in m_sharedModules) { Object[] ctorArgs = new Object[] { (uint)0 }; // Read the config again string moduleString = modulesConfig.GetString("Setup_" + node.Id, String.Empty); // Test to see if we want this module if (moduleString == "disabled") { continue; } // Get the port number, if there is one if (moduleString != String.Empty) { // Get the port number from the string string[] moduleParts = moduleString.Split(new char[] { '/' }, 2); if (moduleParts.Length > 1) { ctorArgs[0] = Convert.ToUInt32(moduleParts[0]); } } // Try loading and initilaizing the module, using the // port if appropriate ISharedRegionModule module = null; try { module = (ISharedRegionModule)Activator.CreateInstance( node.Type, ctorArgs); } catch { module = (ISharedRegionModule)Activator.CreateInstance( node.Type); } // OK, we're up and running m_sharedInstances.Add(module); module.Initialise(m_openSim.ConfigSource.Source); } }
// static void PrintCategory (CodeFormatCategory c) // { // System.Console.WriteLine (c); // foreach (var o in c.Options) { // System.Console.WriteLine(o); // } // foreach (var sub in c.SubCategories) { // PrintCategory (sub); // } // } static TextFileService() { AddinManager.AddExtensionNodeHandler("/MonoDevelop/ProjectModel/TextFormatters", FormatterExtHandler); AddinManager.AddExtensionNodeHandler("/MonoDevelop/ProjectModel/TextPrettyPrinters", PrettyPrinterExtHandler); }
public OptionsDialog(MonoDevelop.Components.Window parentWindow, object dataObject, string extensionPath, bool removeEmptySections) { buttonCancel = new Gtk.Button(Gtk.Stock.Cancel); buttonCancel.Accessible.Name = "Dialogs.Options.Cancel"; buttonCancel.Accessible.Description = GettextCatalog.GetString("Close the options dialog and discard any changes"); AddActionWidget(this.buttonCancel, ResponseType.Cancel); buttonOk = new Gtk.Button(Gtk.Stock.Ok); buttonOk.Accessible.Name = "Dialogs.Options.Ok"; buttonOk.Accessible.Description = GettextCatalog.GetString("Close the options dialog and keep the changes"); this.ActionArea.PackStart(buttonOk); buttonOk.Clicked += OnButtonOkClicked; mainHBox = new HBox(); mainHBox.Accessible.SetShouldIgnore(true); tree = new TreeView(); tree.Accessible.Name = "Dialogs.Options.Categories"; tree.Accessible.Description = GettextCatalog.GetString("The categories of options that are available in this dialog"); var sw = new ScrolledWindow(); sw.Accessible.SetShouldIgnore(true); sw.Add(tree); sw.HscrollbarPolicy = PolicyType.Never; sw.VscrollbarPolicy = PolicyType.Automatic; sw.ShadowType = ShadowType.None; var fboxTree = new HeaderBox(); fboxTree.Accessible.SetShouldIgnore(true); fboxTree.SetMargins(0, 1, 0, 1); fboxTree.SetPadding(0, 0, 0, 0); fboxTree.BackgroundColor = new Gdk.Color(255, 255, 255); fboxTree.Add(sw); mainHBox.PackStart(fboxTree, false, false, 0); Realized += delegate { fboxTree.BackgroundColor = tree.Style.Base(Gtk.StateType.Normal); }; var vbox = new VBox(); vbox.Accessible.SetShouldIgnore(true); mainHBox.PackStart(vbox, true, true, 0); var headerBox = new HBox(false, 6); headerBox.Accessible.SetShouldIgnore(true); labelTitle = new Label(); labelTitle.Accessible.Name = "Dialogs.Options.PageTitle"; labelTitle.Xalign = 0; textHeader = new Alignment(0, 0, 1, 1); textHeader.Accessible.SetShouldIgnore(true); textHeader.Add(labelTitle); textHeader.BorderWidth = 12; headerBox.PackStart(textHeader, true, true, 0); imageHeader = new OptionsDialogHeader(); imageHeader.Hide(); var imageHeaderWidget = imageHeader.ToGtkWidget(); imageHeaderWidget.Accessible.SetShouldIgnore(true); headerBox.PackStart(imageHeaderWidget); var fboxHeader = new HeaderBox(); fboxHeader.Accessible.SetShouldIgnore(true); fboxHeader.SetMargins(0, 1, 0, 0); fboxHeader.Add(headerBox); // fbox.GradientBackround = true; // fbox.BackgroundColor = new Gdk.Color (255, 255, 255); Realized += delegate { var c = Style.Background(Gtk.StateType.Normal).ToXwtColor(); c.Light += 0.09; fboxHeader.BackgroundColor = c.ToGdkColor(); }; StyleSet += delegate { if (IsRealized) { var c = Style.Background(Gtk.StateType.Normal).ToXwtColor(); c.Light += 0.09; fboxHeader.BackgroundColor = c.ToGdkColor(); } }; vbox.PackStart(fboxHeader, false, false, 0); pageFrame = new HBox(); pageFrame.Accessible.SetShouldIgnore(true); var fbox = new HeaderBox(); fbox.Accessible.SetShouldIgnore(true); fbox.SetMargins(0, 1, 0, 0); fbox.ShowTopShadow = true; fbox.Add(pageFrame); vbox.PackStart(fbox, true, true, 0); this.VBox.PackStart(mainHBox, true, true, 0); this.removeEmptySections = removeEmptySections; extensionContext = AddinManager.CreateExtensionContext(); this.mainDataObject = dataObject; this.extensionPath = extensionPath; ImageService.EnsureStockIconIsLoaded(emptyCategoryIcon); store = new TreeStore(typeof(OptionsDialogSection)); tree.Model = store; tree.HeadersVisible = false; // Column 0 is used to add some padding at the left of the expander TreeViewColumn col0 = new TreeViewColumn(); col0.MinWidth = 6; tree.AppendColumn(col0); TreeViewColumn col = new TreeViewColumn(); var crp = new CellRendererImage(); col.PackStart(crp, false); col.SetCellDataFunc(crp, PixbufCellDataFunc); var crt = new CellRendererText(); col.PackStart(crt, true); col.SetCellDataFunc(crt, TextCellDataFunc); tree.AppendColumn(col); tree.ExpanderColumn = col; tree.Selection.Changed += OnSelectionChanged; Child.ShowAll(); InitializeContext(extensionContext); FillTree(); ExpandCategories(); RestoreLastPanel(); this.DefaultResponse = Gtk.ResponseType.Ok; buttonOk.CanDefault = true; buttonOk.GrabDefault(); DefaultWidth = 960; DefaultHeight = 680; }
protected override void Run() { IdeApp.Workbench.DocumentOpened += HandleDocumentOpened; AddinManager.AddExtensionNodeHandler(ResXEditorsExtensionPath, ExtensionNodesChanged); }
static CodeFormatterService() { AddinManager.AddExtensionNodeHandler("/MonoDevelop/Ide/CodeFormatters", FormatterExtHandler); }
void GetVersionControlHandler() { versionControlHandler = AddinManager.GetExtensionObjects("/MonoDevelop/Ide/VersionControlProjectTemplateHandler", typeof(IVersionControlProjectTemplateHandler), true) .Select(extensionObject => (IVersionControlProjectTemplateHandler)extensionObject) .FirstOrDefault(); }
int Run(MonoDevelopOptions options) { LoggingService.LogInfo("Starting {0} {1}", BrandingService.ApplicationName, IdeVersionInfo.MonoDevelopVersion); LoggingService.LogInfo("Running on {0}", IdeVersionInfo.GetRuntimeInfo()); //ensure native libs initialized before we hit anything that p/invokes Platform.Initialize(); LoggingService.LogInfo("Operating System: {0}", SystemInformation.GetOperatingSystemDescription()); Counters.Initialization.BeginTiming(); if (options.PerfLog) { string logFile = Path.Combine(Environment.CurrentDirectory, "monodevelop.perf-log"); LoggingService.LogInfo("Logging instrumentation service data to file: " + logFile); InstrumentationService.StartAutoSave(logFile, 1000); } Counters.Initialization.Trace("Initializing GTK"); if (Platform.IsWindows && !CheckWindowsGtk()) { return(1); } SetupExceptionManager(); IdeApp.Customizer = options.IdeCustomizer ?? new IdeCustomizer(); try { IdeApp.Customizer.Initialize(); } catch (UnauthorizedAccessException ua) { LoggingService.LogError("Unauthorized access: " + ua.Message); return(1); } try { GLibLogging.Enabled = true; } catch (Exception ex) { LoggingService.LogError("Error initialising GLib logging.", ex); } var args = options.RemainingArgs.ToArray(); IdeTheme.InitializeGtk(BrandingService.ApplicationName, ref args); LoggingService.LogInfo("Using GTK+ {0}", IdeVersionInfo.GetGtkVersion()); // XWT initialization FilePath p = typeof(IdeStartup).Assembly.Location; Assembly.LoadFrom(p.ParentDirectory.Combine("Xwt.Gtk.dll")); Xwt.Application.InitializeAsGuest(Xwt.ToolkitType.Gtk); Xwt.Toolkit.CurrentEngine.RegisterBackend <IExtendedTitleBarWindowBackend, GtkExtendedTitleBarWindowBackend> (); Xwt.Toolkit.CurrentEngine.RegisterBackend <IExtendedTitleBarDialogBackend, GtkExtendedTitleBarDialogBackend> (); IdeTheme.SetupXwtTheme(); //default to Windows IME on Windows if (Platform.IsWindows && GtkWorkarounds.GtkMinorVersion >= 16) { var settings = Gtk.Settings.Default; var val = GtkWorkarounds.GetProperty(settings, "gtk-im-module"); if (string.IsNullOrEmpty(val.Val as string)) { GtkWorkarounds.SetProperty(settings, "gtk-im-module", new GLib.Value("ime")); } } string socket_filename = null; EndPoint ep = null; DispatchService.Initialize(); // Set a synchronization context for the main gtk thread SynchronizationContext.SetSynchronizationContext(DispatchService.SynchronizationContext); Runtime.MainSynchronizationContext = SynchronizationContext.Current; AddinManager.AddinLoadError += OnAddinError; var startupInfo = new StartupInfo(args); // If a combine was specified, force --newwindow. if (!options.NewWindow && startupInfo.HasFiles) { Counters.Initialization.Trace("Pre-Initializing Runtime to load files in existing window"); Runtime.Initialize(true); foreach (var file in startupInfo.RequestedFileList) { if (MonoDevelop.Projects.Services.ProjectService.IsWorkspaceItemFile(file.FileName)) { options.NewWindow = true; break; } } } Counters.Initialization.Trace("Initializing Runtime"); Runtime.Initialize(true); IdeApp.Customizer.OnCoreInitialized(); Counters.Initialization.Trace("Initializing theme"); IdeTheme.SetupGtkTheme(); ProgressMonitor monitor = new MonoDevelop.Core.ProgressMonitoring.ConsoleProgressMonitor(); monitor.BeginTask(GettextCatalog.GetString("Starting {0}", BrandingService.ApplicationName), 2); //make sure that the platform service is initialised so that the Mac platform can subscribe to open-document events Counters.Initialization.Trace("Initializing Platform Service"); DesktopService.Initialize(); monitor.Step(1); if (options.IpcTcp) { listen_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); ep = new IPEndPoint(IPAddress.Loopback, ipcBasePort + HashSdbmBounded(Environment.UserName)); } else { socket_filename = "/tmp/md-" + Environment.GetEnvironmentVariable("USER") + "-socket"; listen_socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP); ep = new UnixEndPoint(socket_filename); } // If not opening a combine, connect to existing monodevelop and pass filename(s) and exit if (!options.NewWindow && startupInfo.HasFiles) { try { StringBuilder builder = new StringBuilder(); foreach (var file in startupInfo.RequestedFileList) { builder.AppendFormat("{0};{1};{2}\n", file.FileName, file.Line, file.Column); } listen_socket.Connect(ep); listen_socket.Send(Encoding.UTF8.GetBytes(builder.ToString())); return(0); } catch { // Reset the socket if (null != socket_filename && File.Exists(socket_filename)) { File.Delete(socket_filename); } } } Counters.Initialization.Trace("Checking System"); CheckFileWatcher(); Exception error = null; int reportedFailures = 0; try { Counters.Initialization.Trace("Loading Icons"); //force initialisation before the workbench so that it can register stock icons for GTK before they get requested ImageService.Initialize(); LocalizationService.Initialize(); // If we display an error dialog before the main workbench window on OS X then a second application menu is created // which is then replaced with a second empty Apple menu. // XBC #33699 Counters.Initialization.Trace("Initializing IdeApp"); IdeApp.Initialize(monitor); if (errorsList.Count > 0) { using (AddinLoadErrorDialog dlg = new AddinLoadErrorDialog((AddinError[])errorsList.ToArray(typeof(AddinError)), false)) { if (!dlg.Run()) { return(1); } } reportedFailures = errorsList.Count; } if (!CheckSCPlugin()) { return(1); } // Load requested files Counters.Initialization.Trace("Opening Files"); // load previous combine RecentFile openedProject = null; if (IdeApp.Preferences.LoadPrevSolutionOnStartup && !startupInfo.HasSolutionFile && !IdeApp.Workspace.WorkspaceItemIsOpening && !IdeApp.Workspace.IsOpen) { openedProject = DesktopService.RecentFiles.GetProjects().FirstOrDefault(); if (openedProject != null) { IdeApp.Workspace.OpenWorkspaceItem(openedProject.FileName).ContinueWith(t => IdeApp.OpenFiles(startupInfo.RequestedFileList), TaskScheduler.FromCurrentSynchronizationContext()); } } if (openedProject == null) { IdeApp.OpenFiles(startupInfo.RequestedFileList); } monitor.Step(1); } catch (Exception e) { error = e; } finally { monitor.Dispose(); } if (error != null) { string message = BrandingService.BrandApplicationName(GettextCatalog.GetString("MonoDevelop failed to start")); MessageService.ShowFatalError(message, null, error); return(1); } if (errorsList.Count > reportedFailures) { using (AddinLoadErrorDialog dlg = new AddinLoadErrorDialog((AddinError[])errorsList.ToArray(typeof(AddinError)), true)) dlg.Run(); } errorsList = null; AddinManager.AddinLoadError -= OnAddinError; // FIXME: we should probably track the last 'selected' one // and do this more cleanly try { listen_socket.Bind(ep); listen_socket.Listen(5); listen_socket.BeginAccept(new AsyncCallback(ListenCallback), listen_socket); } catch { // Socket already in use } initialized = true; MessageService.RootWindow = IdeApp.Workbench.RootWindow; Xwt.MessageDialog.RootWindow = Xwt.Toolkit.CurrentEngine.WrapWindow(IdeApp.Workbench.RootWindow); Thread.CurrentThread.Name = "GUI Thread"; Counters.Initialization.Trace("Running IdeApp"); Counters.Initialization.EndTiming(); AddinManager.AddExtensionNodeHandler("/MonoDevelop/Ide/InitCompleteHandlers", OnExtensionChanged); StartLockupTracker(); IdeApp.Run(); IdeApp.Customizer.OnIdeShutdown(); // unloading services if (null != socket_filename) { File.Delete(socket_filename); } lockupCheckRunning = false; Runtime.Shutdown(); IdeApp.Customizer.OnCoreShutdown(); InstrumentationService.Stop(); MonoDevelop.Components.GtkWorkarounds.Terminate(); return(0); }
// This seems to be the best place to place this code public override void SetNeedsBuilding(CombineEntry entry, bool val) { base.SetNeedsBuilding(entry, val); filesPerLanguage.Clear(); Project project = entry as Project; if (project == null) { return; } foreach (ProjectFile file in project.ProjectFiles) { if (file.Subtype != Subtype.Code) { continue; } for (int i = 0; i < SupportedExtensions.GetLength(0); i++) { if (Path.GetExtension(file.Name).ToUpper().Equals(SupportedExtensions[i, 1])) { string language = SupportedExtensions[i, 0]; if (!filesPerLanguage.ContainsKey(language)) { filesPerLanguage.Add(language, new List <string> ()); } filesPerLanguage[language].Add(file.Name); break; } } } StringBuilder builder = new StringBuilder(); string tagsDirectory = Path.Combine(entry.BaseDirectory, ".tags"); string arguments = string.Empty; object[] nodes = AddinManager.GetExtensionObjects("/CTagsCompletion/Specialization"); if (!Directory.Exists(tagsDirectory)) { Directory.CreateDirectory(tagsDirectory); } foreach (KeyValuePair <string, List <string> > kvp in filesPerLanguage) { foreach (ITagsSpecialization node in nodes) { if (node.Language.Equals(kvp.Key)) { arguments = node.CTagsArguments; } } builder.AppendFormat("-f {0}TAGS {1}", kvp.Key, arguments); foreach (string file in kvp.Value) { builder.Append(" " + file); } try { ProcessWrapper p = Runtime.ProcessService.StartProcess( "ctags", builder.ToString(), tagsDirectory, null); p.WaitForExit(); } catch (Exception ex) { throw new Exception("Could not create tags file", ex); } builder.Remove(0, builder.Length); } }
static AnalysisExtensions() { AddinManager.AddExtensionNodeHandler(EXT_RULES, OnRuleNodeChanged); AddinManager.AddExtensionNodeHandler(EXT_TYPES, OnTypeNodeChanged); AddinManager.AddExtensionNodeHandler(EXT_FIX_HANDLERS, OnFixHandlerNodeChanged); }
public static void InitAddins() { AddinManager.AddinLoadError += AddinManager_AddinLoadError; bool retry = false; bool errorDeletingFolder = false; AutoResetEvent initialized = new AutoResetEvent(false); do { Thread thread = new Thread(() => { try { AddinManager.Initialize(); AddinManager.Registry.Update(null); foreach (TypeExtensionNode addonOperation in AddinManager.GetExtensionNodes("/Warehouse/Business/Operations")) { IAdditionalOperation instance = (IAdditionalOperation)addonOperation.CreateInstance(); Operation.GetByIdHandlers [instance.Type] = instance.GetByOperationId; Operation.GetPendingHandlers [instance.Type] = instance.GetPendingOperation; } foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/Warehouse/Business/Config")) { IConfigurationAddin addin = (IConfigurationAddin)node.CreateInstance(); AppConfiguration.Addins [addin.GetType()] = addin; } retry = false; initialized.Set(); } catch (Exception ex) { try { AddinManager.Shutdown(); } catch { } if (Directory.Exists(StoragePaths.MonoAddinsDataFolder) && !errorDeletingFolder) { try { Directory.Delete(StoragePaths.MonoAddinsDataFolder, true); } catch (Exception) { errorDeletingFolder = true; } finally { retry = true; } } else { ErrorHandling.LogException(ex); } } }); thread.Start(); if (!initialized.WaitOne(10000)) { thread.Abort(); thread.Join(); } } while (retry); if (AppConfiguration.Addins.Count > 0) { AppConfiguration.Load(true); } }
IEnumerable <ISystemInformationProvider> InternalGetDescription() { foreach (var info in AddinManager.GetExtensionObjects <ISystemInformationProvider> ("/MonoDevelop/Core/SystemInformation", false)) { yield return(info); } var sb = new StringBuilder(); // First append the MonoDevelop build information var biFile = ((FilePath)Assembly.GetEntryAssembly().Location).ParentDirectory.Combine("buildinfo"); if (File.Exists(biFile)) { var lines = File.ReadAllLines(biFile) .Select(l => l.Trim()) .Where(l => !string.IsNullOrEmpty(l)) .ToArray(); if (lines.Length > 0) { foreach (var line in lines) { sb.AppendLine(line); } } } // Then append the Xamarin Addins information if it exists biFile = ((FilePath)Assembly.GetEntryAssembly().Location).ParentDirectory.Combine("buildinfo_xamarin"); if (File.Exists(biFile)) { var lines = File.ReadAllLines(biFile) .Select(l => l.Trim()) .Where(l => !string.IsNullOrEmpty(l)) .ToArray(); if (lines.Length > 0) { sb.Append("Xamarin addins: "); foreach (var line in lines) { sb.AppendLine(line); } } } if (!string.IsNullOrEmpty(MonoDevelop.BuildInfo.BuildLane)) { sb.Append("Build lane: ").AppendLine(MonoDevelop.BuildInfo.BuildLane); } if (sb.Length == 0) { sb.AppendLine("Build information unavailable"); } yield return(new SystemInformationSection() { Title = "Build Information", Description = sb.ToString() }); sb.Clear(); AppendOperatingSystem(sb); yield return(new SystemInformationSection() { Title = "Operating System", Description = sb.ToString() }); string userAddins = string.Join(Environment.NewLine, AddinManager.Registry.GetModules(AddinSearchFlags.IncludeAddins | AddinSearchFlags.LatestVersionsOnly) .Where(addin => addin.IsUserAddin && addin.Enabled) .Select(addin => string.Format("{0} {1}", addin.Name, addin.Version)) ); if (!string.IsNullOrEmpty(userAddins)) { yield return new SystemInformationSection() { Title = "Enabled user installed addins", Description = userAddins, } } ; }
public static void Initialize(IProgressMonitor monitor) { Counters.Initialization.Trace("Creating Workbench"); workbench = new Workbench(); Counters.Initialization.Trace("Creating Root Workspace"); workspace = new RootWorkspace(); Counters.Initialization.Trace("Creating Services"); projectOperations = new ProjectOperations(); helpOperations = new HelpOperations(); commandService = new CommandManager(); ideServices = new IdeServices(); CustomToolService.Init(); commandService.CommandTargetScanStarted += CommandServiceCommandTargetScanStarted; commandService.CommandTargetScanFinished += CommandServiceCommandTargetScanFinished; commandService.KeyBindingFailed += KeyBindingFailed; KeyBindingService.LoadBindingsFromExtensionPath("/MonoDevelop/Ide/KeyBindingSchemes"); KeyBindingService.LoadCurrentBindings("MD2"); commandService.CommandError += delegate(object sender, CommandErrorArgs args) { LoggingService.LogInternalError(args.ErrorMessage, args.Exception); }; FileService.ErrorHandler = FileServiceErrorHandler; monitor.BeginTask(GettextCatalog.GetString("Loading Workbench"), 5); Counters.Initialization.Trace("Loading Commands"); commandService.LoadCommands("/MonoDevelop/Ide/Commands"); monitor.Step(1); Counters.Initialization.Trace("Initializing Workbench"); workbench.Initialize(monitor); monitor.Step(1); InternalLog.EnableErrorNotification(); MonoDevelop.Ide.WelcomePage.WelcomePageService.Initialize(); MonoDevelop.Ide.WelcomePage.WelcomePageService.ShowWelcomePage(); monitor.Step(1); Counters.Initialization.Trace("Restoring Workbench State"); workbench.Show("SharpDevelop.Workbench.WorkbenchMemento"); monitor.Step(1); Counters.Initialization.Trace("Flushing GUI events"); DispatchService.RunPendingEvents(); Counters.Initialization.Trace("Flushed GUI events"); MessageService.RootWindow = workbench.RootWindow; commandService.EnableIdleUpdate = true; // Perser service initialization TypeSystemService.TrackFileChanges = true; TypeSystemService.ParseProgressMonitorFactory = new ParseProgressMonitorFactory(); Customizer.OnIdeInitialized(); // Startup commands Counters.Initialization.Trace("Running Startup Commands"); AddinManager.AddExtensionNodeHandler("/MonoDevelop/Ide/StartupHandlers", OnExtensionChanged); monitor.Step(1); monitor.EndTask(); // Set initial run flags Counters.Initialization.Trace("Upgrading Settings"); if (PropertyService.Get("MonoDevelop.Core.FirstRun", false)) { isInitialRun = true; PropertyService.Set("MonoDevelop.Core.FirstRun", false); PropertyService.Set("MonoDevelop.Core.LastRunVersion", BuildInfo.Version); PropertyService.Set("MonoDevelop.Core.LastRunRevision", CurrentRevision); PropertyService.SaveProperties(); } string lastVersion = PropertyService.Get("MonoDevelop.Core.LastRunVersion", "1.9.1"); int lastRevision = PropertyService.Get("MonoDevelop.Core.LastRunRevision", 0); if (lastRevision != CurrentRevision && !isInitialRun) { isInitialRunAfterUpgrade = true; if (lastRevision == 0) { switch (lastVersion) { case "1.0": lastRevision = 1; break; case "2.0": lastRevision = 2; break; case "2.2": lastRevision = 3; break; case "2.2.1": lastRevision = 4; break; } } upgradedFromRevision = lastRevision; PropertyService.Set("MonoDevelop.Core.LastRunVersion", BuildInfo.Version); PropertyService.Set("MonoDevelop.Core.LastRunRevision", CurrentRevision); PropertyService.SaveProperties(); } // The ide is now initialized isInitialized = true; if (isInitialRun) { try { OnInitialRun(); } catch (Exception e) { LoggingService.LogError("Error found while initializing the IDE", e); } } if (isInitialRunAfterUpgrade) { try { OnUpgraded(upgradedFromRevision); } catch (Exception e) { LoggingService.LogError("Error found while initializing the IDE", e); } } if (initializedEvent != null) { initializedEvent(null, EventArgs.Empty); initializedEvent = null; } //FIXME: we should really make this on-demand. consumers can display a "loading help cache" message like VS MonoDevelop.Projects.HelpService.AsyncInitialize(); UpdateInstrumentationIcon(); IdeApp.Preferences.EnableInstrumentationChanged += delegate { UpdateInstrumentationIcon(); }; AutoTestService.Start(commandService, Preferences.EnableAutomatedTesting); AutoTestService.NotifyEvent("MonoDevelop.Ide.IdeStart"); Gtk.LinkButton.SetUriHook((button, uri) => Xwt.Desktop.OpenUrl(uri)); }
async Task <int> MainLoop(MonoDevelopOptions options, StartupInfo startupInfo) { ProgressMonitor monitor = new MonoDevelop.Core.ProgressMonitoring.ConsoleProgressMonitor(); monitor.BeginTask(GettextCatalog.GetString("Starting {0}", BrandingService.ApplicationName), 2); //make sure that the platform service is initialised so that the Mac platform can subscribe to open-document events Counters.Initialization.Trace("Initializing Platform Service"); var desktopService = await Runtime.GetService <DesktopService> (); var commandService = await Runtime.GetService <CommandManager> (); // load the global menu for the welcome window to avoid unresponsive menus on Mac desktopService.SetGlobalMenu(commandService, DefaultWorkbench.MainMenuPath, DefaultWorkbench.AppMenuPath); IdeStartupTracker.StartupTracker.MarkSection("PlatformInitialization"); monitor.Step(1); Counters.Initialization.Trace("Checking System"); CheckFileWatcher(); IdeStartupTracker.StartupTracker.MarkSection("FileWatcherInitialization"); Exception error = null; int reportedFailures = 0; try { Counters.Initialization.Trace("Loading Icons"); //force initialisation before the workbench so that it can register stock icons for GTK before they get requested ImageService.Initialize(); IdeStartupTracker.StartupTracker.MarkSection("ImageInitialization"); // If we display an error dialog before the main workbench window on OS X then a second application menu is created // which is then replaced with a second empty Apple menu. // XBC #33699 Counters.Initialization.Trace("Initializing IdeApp"); hideWelcomePage = options.NoStartWindow || startupInfo.HasFiles || IdeApp.Preferences.StartupBehaviour.Value != OnStartupBehaviour.ShowStartWindow; await IdeApp.Initialize(monitor, hideWelcomePage); IdeStartupTracker.StartupTracker.MarkSection("AppInitialization"); if (errorsList.Count > 0) { using (AddinLoadErrorDialog dlg = new AddinLoadErrorDialog(errorsList.ToArray(), false)) { if (!dlg.Run()) { return(1); } } reportedFailures = errorsList.Count; } if (!CheckSCPlugin()) { return(1); } // Load requested files Counters.Initialization.Trace("Opening Files"); // load previous combine RecentFile openedProject = null; if (IdeApp.Preferences.StartupBehaviour.Value == OnStartupBehaviour.LoadPreviousSolution && !startupInfo.HasSolutionFile && !IdeApp.Workspace.WorkspaceItemIsOpening && !IdeApp.Workspace.IsOpen) { openedProject = IdeServices.DesktopService.RecentFiles.MostRecentlyUsedProject; if (openedProject != null) { var metadata = GetOpenWorkspaceOnStartupMetadata(); IdeApp.Workspace.OpenWorkspaceItem(openedProject.FileName, true, true, metadata).ContinueWith(t => IdeApp.OpenFilesAsync(startupInfo.RequestedFileList, metadata), TaskScheduler.FromCurrentSynchronizationContext()).Ignore(); startupInfo.OpenedRecentProject = true; } } if (openedProject == null) { IdeApp.OpenFilesAsync(startupInfo.RequestedFileList, GetOpenWorkspaceOnStartupMetadata()).Ignore(); startupInfo.OpenedFiles = startupInfo.HasFiles; } monitor.Step(1); } catch (Exception e) { error = e; } finally { monitor.Dispose(); } if (error != null) { string message = BrandingService.BrandApplicationName(GettextCatalog.GetString("MonoDevelop failed to start")); message = message + "\n\n" + error.Message; MessageService.ShowFatalError(message, null, error); return(1); } if (errorsList.Count > reportedFailures) { using (AddinLoadErrorDialog dlg = new AddinLoadErrorDialog(errorsList.ToArray(), true)) dlg.Run(); } errorsList = null; AddinManager.AddinLoadError -= OnAddinError; IdeStartupTracker.StartupTracker.MarkSection("BasicInitializationCompleted"); instanceConnection.FileOpenRequested += (sender, a) => { foreach (var e in a) { OpenFile(e.FileName); } }; instanceConnection.StartListening(); IdeStartupTracker.StartupTracker.MarkSection("SocketInitialization"); initialized = true; MessageService.RootWindow = IdeApp.Workbench.RootWindow; Xwt.MessageDialog.RootWindow = Xwt.Toolkit.CurrentEngine.WrapWindow(IdeApp.Workbench.RootWindow); IdeStartupTracker.StartupTracker.MarkSection("WindowOpened"); Thread.CurrentThread.Name = "GUI Thread"; Counters.Initialization.Trace("Running IdeApp"); Counters.Initialization.EndTiming(); AddinManager.AddExtensionNodeHandler("/MonoDevelop/Ide/InitCompleteHandlers", OnExtensionChanged); StartLockupTracker(); // This call is important so the current event loop is run before we run the main loop. // On Mac, the OpenDocuments event gets handled here, so we need to get the timeout // it queues before the OnIdle event so we can start opening a solution before // we show the main window. await Task.Yield(); IdeStartupTracker.StartupTracker.MarkSection("PumpEventLoop"); IdeStartupTracker.StartupTracker.Stop(startupInfo); GLib.Idle.Add(OnIdle); return(0); }
public static void LoadBindingsFromExtensionPath(string path) { AddinManager.AddExtensionNodeHandler(path, OnBindingExtensionChanged); }
//constructors static ProjectTemplate() { AddinManager.AddExtensionNodeHandler("/MonoDevelop/Ide/ProjectTemplates", OnExtensionChanged); }
public override bool IsVisible() { return(!AddinManager.IsAddinLoaded("MonoDevelop.Xamarin.Ide")); }
static bool CanShow(VersionControlItem item) { return(!item.IsDirectory && item.VersionInfo.IsVersioned && AddinManager.GetExtensionObjects <IVersionControlViewHandler> (DiffViewHandlers).Any(h => h.CanHandle(item, null))); }
public static void Initialize(bool updateAddinRegistry) { if (initialized) { return; } Counters.RuntimeInitialization.BeginTiming(); SetupInstrumentation(); Platform.Initialize(); mainThread = Thread.CurrentThread; // Set a default sync context if (SynchronizationContext.Current == null) { defaultSynchronizationContext = new SynchronizationContext(); SynchronizationContext.SetSynchronizationContext(defaultSynchronizationContext); } else { defaultSynchronizationContext = SynchronizationContext.Current; } // Hook up the SSL certificate validation codepath ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { if (sslPolicyErrors == SslPolicyErrors.None) { return(true); } if (sender is WebRequest) { sender = ((WebRequest)sender).RequestUri.Host; } return(WebCertificateService.GetIsCertificateTrusted(sender as string, certificate.GetPublicKeyString())); }; AddinManager.AddinLoadError += OnLoadError; AddinManager.AddinLoaded += OnLoad; AddinManager.AddinUnloaded += OnUnload; try { Counters.RuntimeInitialization.Trace("Initializing Addin Manager"); string configDir, addinsDir, databaseDir; GetAddinRegistryLocation(out configDir, out addinsDir, out databaseDir); AddinManager.Initialize(configDir, addinsDir, databaseDir); AddinManager.InitializeDefaultLocalizer(new DefaultAddinLocalizer()); if (updateAddinRegistry) { AddinManager.Registry.Update(null); } setupService = new AddinSetupService(AddinManager.Registry); Counters.RuntimeInitialization.Trace("Initialized Addin Manager"); PropertyService.Initialize(); WebRequestHelper.Initialize(); Mono.Addins.Setup.WebRequestHelper.SetRequestHandler(WebRequestHelper.GetResponse); //have to do this after the addin service and property service have initialized if (UserDataMigrationService.HasSource) { Counters.RuntimeInitialization.Trace("Migrating User Data from MD " + UserDataMigrationService.SourceVersion); UserDataMigrationService.StartMigration(); } RegisterAddinRepositories(); Counters.RuntimeInitialization.Trace("Initializing Assembly Service"); systemAssemblyService = new SystemAssemblyService(); systemAssemblyService.Initialize(); LoadMSBuildLibraries(); initialized = true; } catch (Exception ex) { Console.WriteLine(ex); AddinManager.AddinLoadError -= OnLoadError; AddinManager.AddinLoaded -= OnLoad; AddinManager.AddinUnloaded -= OnUnload; } finally { Counters.RuntimeInitialization.EndTiming(); } }
private List <T> CollectProcesser <T>() { return(new List <T>((IEnumerable <T>)AddinManager.GetExtensionObjects <T>())); }
public void Initialise(OpenSimBase openSim) { m_openSim = openSim; m_openSim.ApplicationRegistry.RegisterInterface <IRegionModulesController>(this); m_log.DebugFormat("[REGIONMODULES]: Initializing..."); // Who we are string id = AddinManager.CurrentAddin.Id; // Make friendly name int pos = id.LastIndexOf("."); if (pos == -1) { m_name = id; } else { m_name = id.Substring(pos + 1); } // The [Modules] section in the ini file IConfig modulesConfig = m_openSim.ConfigSource.Source.Configs["Modules"]; if (modulesConfig == null) { modulesConfig = m_openSim.ConfigSource.Source.AddConfig("Modules"); } // Scan modules and load all that aren't disabled foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/OpenSim/RegionModules")) { if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null) { if (CheckModuleEnabled(node, modulesConfig)) { m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type); m_sharedModules.Add(node); } } else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null) { if (CheckModuleEnabled(node, modulesConfig)) { m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type); m_nonSharedModules.Add(node); } } else { m_log.DebugFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type); } } // Load and init the module. We try a constructor with a port // if a port was given, fall back to one without if there is // no port or the more specific constructor fails. // This will be removed, so that any module capable of using a port // must provide a constructor with a port in the future. // For now, we do this so migration is easy. // foreach (TypeExtensionNode node in m_sharedModules) { Object[] ctorArgs = new Object[] { (uint)0 }; // Read the config again string moduleString = modulesConfig.GetString("Setup_" + node.Id, String.Empty); // Get the port number, if there is one if (moduleString != String.Empty) { // Get the port number from the string string[] moduleParts = moduleString.Split(new char[] { '/' }, 2); if (moduleParts.Length > 1) { ctorArgs[0] = Convert.ToUInt32(moduleParts[0]); } } // Try loading and initilaizing the module, using the // port if appropriate ISharedRegionModule module = null; try { module = (ISharedRegionModule)Activator.CreateInstance( node.Type, ctorArgs); } catch { module = (ISharedRegionModule)Activator.CreateInstance( node.Type); } // OK, we're up and running m_sharedInstances.Add(module); module.Initialise(m_openSim.ConfigSource.Source); } }