static void OnProjectCompiled(object s, BuildEventArgs args) { if (args.Success) { // Unload stetic projects which are not currently // being used by the IDE. This will avoid unnecessary updates. if (IdeApp.Workspace.IsOpen) { foreach (Project prj in IdeApp.Workspace.GetAllProjects()) { GtkDesignInfo info = GtkDesignInfo.FromProject(prj); if (!HasOpenDesigners(prj, false)) { info.ReloadGuiBuilderProject(); } } } SteticApp.UpdateWidgetLibraries(false); } else { // Some gtk# packages don't include the .pc file unless you install gtk-sharp-devel if (Runtime.SystemAssemblyService.DefaultAssemblyContext.GetPackage("gtk-sharp-2.0") == null) { string msg = GettextCatalog.GetString("ERROR: MonoDevelop could not find the Gtk# 2.0 development package. Compilation of projects depending on Gtk# libraries will fail. You may need to install development packages for gtk-sharp-2.0."); args.ProgressMonitor.Log.WriteLine(); args.ProgressMonitor.Log.WriteLine(msg); } } }
protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration) { DotNetProject project = (DotNetProject)entry; GtkDesignInfo info = GtkDesignInfo.FromProject(project); // The code generator must run in the GUI thread since it needs to // access to Gtk classes Generator gen = new Generator(); lock (gen) { Gtk.Application.Invoke(delegate { gen.Run(monitor, project, configuration); }); Monitor.Wait(gen); } BuildResult res = base.Build(monitor, entry, configuration); if (gen.Messages != null) { foreach (string s in gen.Messages) { res.AddWarning(info.GuiBuilderProject.File, 0, 0, null, s); } if (gen.Messages.Length > 0) { info.ForceCodeGenerationOnBuild(); } } return(res); }
public override bool CanCreateContentForUri(string fileName) { Project project = IdeApp.Workspace.GetProjectContainingFile(fileName); GtkDesignInfo info = GtkDesignInfo.FromProject((DotNetProject)project); if (excludeThis) { return(false); } if (fileName.Contains(info.BuildFileExtension)) { return(false); } if (!IdeApp.Workspace.IsOpen) { return(false); } if (GetActionGroup(fileName) == null) { return(false); } excludeThis = true; var db = DisplayBindingService.GetDefaultBindingForUri(fileName); excludeThis = false; return(db != null); }
public INamedTypeSymbol FindClass(string className, bool getUserClass) { FilePath gui_folder = GtkDesignInfo.FromProject(project).GtkGuiFolder; var ctx = GetParserContext(); if (ctx == null) { return(null); } foreach (var cls in ctx.GetAllTypesInMainAssembly()) { if (cls.GetFullName() == className) { if (getUserClass) { // Return this class only if it is declared outside the gtk-gui // folder. Generated partial classes will be ignored. foreach (var part in cls.Locations) { var filePath = part.SourceTree.FilePath; if (!string.IsNullOrEmpty(filePath) && !((FilePath)filePath).IsChildPathOf(gui_folder)) { return(cls); } } continue; } return(cls); } } return(null); }
public void Convert(string guiFolderName, bool makeBackup) { GtkDesignInfo info = GtkDesignInfo.FromProject(project); Stetic.Project gproject = GuiBuilderService.SteticApp.CreateProject(info); //Stetic.Project does not implement IDisposable try { string newGuiFolderName = project.BaseDirectory.Combine(guiFolderName); gproject.ConvertProject(info.SteticFile, newGuiFolderName); info.ConvertGtkFolder(guiFolderName, makeBackup); info.UpdateGtkFolder(); folderName = newGuiFolderName; IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBuildProgressMonitor(); try { ConfigurationSelector configuration = IdeApp.Workspace.ActiveConfiguration; Generator generator = new Generator(); generator.Run(monitor, project, configuration); monitor.ReportSuccess("Converting was succesfull"); } finally { monitor.Dispose(); } } finally { gproject.Dispose(); } }
public override async Task <DocumentController> CreateController(FileDescriptor file, DocumentControllerDescription controllerDescription) { var info = GtkDesignInfo.FromProject((DotNetProject)file.Owner); var view = new ActionGroupView(GetActionGroup(file.FilePath), info.GuiBuilderProject); return(view); }
public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { Project project = dataObject as Project; if (project is DotNetProject) { GtkDesignInfo info = GtkDesignInfo.FromProject(project); if (info.NeedsConversion) { ProjectConversionDialog dialog = new ProjectConversionDialog(project, info.SteticFolderName); try { if (dialog.Run() == (int)ResponseType.Yes) { info.GuiBuilderProject.Convert(dialog.GuiFolderName, dialog.MakeBackup); IdeApp.ProjectOperations.Save(project); } } finally { dialog.Destroy(); } } project.FileAddedToProject += HandleProjectFileAddedToProject; } }
public static GtkComponentType GetComponentType(this ProjectFile pf) { GtkDesignInfo info = GtkDesignInfo.FromProject(pf.Project); ParsedDocument doc = ProjectDomService.GetParsedDocument(ProjectDomService.GetProjectDom(pf.Project), pf.Name); //ParsedDocument doc = ProjectDomService.ParseFile (ProjectDomService.GetProjectDom (pf.Project), pf.FilePath.ToString ()); if (doc != null && doc.CompilationUnit != null) { foreach (IType t in doc.CompilationUnit.Types) { string className = t.FullName; if (className != null) { GuiBuilderWindow win = info.GuiBuilderProject.GetWindowForClass(className); if (win != null) { return(win.RootWidget.IsWindow ? GtkComponentType.Dialog : GtkComponentType.Widget); } Stetic.ActionGroupInfo action = info.GuiBuilderProject.GetActionGroup(className); if (action != null) { return(GtkComponentType.ActionGroup); } } } } if (pf.Name.Contains("IconFactory.gtkx")) { return(GtkComponentType.IconFactory); } return(GtkComponentType.None); }
public WindowsFolder(Project project) { this.project = project; GtkDesignInfo info = GtkDesignInfo.FromProject(project); gproject = info.GuiBuilderProject; gproject.Changed += OnUpdateFiles; }
public override void RenameItem(string newName) { Project project = CurrentNode.GetParentDataItem(typeof(Project), true) as Project; GtkDesignInfo info = GtkDesignInfo.FromProject(project); info.SteticFolderName = newName; base.RenameItem(newName); }
void AttachWindow(GuiBuilderWindow window) { gproject = window.Project; GtkDesignInfo info = GtkDesignInfo.FromProject(gproject.Project); gproject.SteticProject.ImagesRootPath = FileService.AbsoluteToRelativePath(info.GtkGuiFolder, gproject.Project.BaseDirectory); gproject.UpdateLibraries(); LoadDesigner(); }
public CodeBinder(MonoDevelop.Projects.Project project, ITextFileProvider textFileProvider, Stetic.Component targetObject) { this.project = project; this.textFileProvider = textFileProvider; gproject = GtkDesignInfo.FromProject(project).GuiBuilderProject; TargetObject = targetObject; }
protected void OnEditIcons() { Project project = CurrentNode.GetParentDataItem(typeof(Project), true) as Project; GuiBuilderProject gp = GtkDesignInfo.FromProject(project).GuiBuilderProject; Stetic.Project sp = gp.SteticProject; sp.EditIcons(); gp.SaveProject(true); }
protected void OnGenerateCode() { ProjectFile pf = CurrentNode.DataItem as ProjectFile; Project project = CurrentNode.GetParentDataItem(typeof(Project), true) as Project; GtkDesignInfo info = GtkDesignInfo.FromProject(project); GuiBuilderProject gproject = info.GuiBuilderProject; gproject.GenerateCode(pf.FilePath); }
public WidgetBuilderOptionPanelWidget(Project project) : base(false, 6) { this.project = project as DotNetProject; Gtk.HBox box = new Gtk.HBox(false, 3); Gtk.Label lbl = new Gtk.Label(GettextCatalog.GetString("Target Gtk# version:")); box.PackStart(lbl, false, false, 0); comboVersions = ComboBox.NewText(); ReferenceManager refmgr = new ReferenceManager(project as DotNetProject); foreach (string v in refmgr.SupportedGtkVersions) { comboVersions.AppendText(v); } comboVersions.Active = refmgr.SupportedGtkVersions.IndexOf(refmgr.GtkPackageVersion); refmgr.Dispose(); box.PackStart(comboVersions, false, false, 0); box.ShowAll(); PackStart(box, false, false, 0); HSeparator sep = new HSeparator(); sep.Show(); PackStart(sep, false, false, 0); if (!GtkDesignInfo.HasDesignedObjects(project)) { return; } GtkDesignInfo designInfo = GtkDesignInfo.FromProject(project); checkGettext = new CheckButton(GettextCatalog.GetString("Enable gettext support")); checkGettext.Active = designInfo.GenerateGettext; checkGettext.Show(); PackStart(checkGettext, false, false, 0); box = new Gtk.HBox(false, 3); box.PackStart(new Label(GettextCatalog.GetString("Gettext class:")), false, false, 0); entryGettext = new Gtk.Entry(); entryGettext.Text = designInfo.GettextClass; entryGettext.Sensitive = checkGettext.Active; box.PackStart(entryGettext, false, false, 0); box.ShowAll(); PackStart(box, false, false, 0); checkGettext.Clicked += delegate { box.Sensitive = checkGettext.Active; if (checkGettext.Active) { entryGettext.Text = "Mono.Unix.Catalog"; } }; }
Stetic.ActionGroupInfo GetActionGroup(string file) { var project = IdeApp.Workspace.GetProjectsContainingFile(file).FirstOrDefault(); if (!GtkDesignInfo.HasDesignedObjects(project)) { return(null); } return(GtkDesignInfo.FromProject(project).GuiBuilderProject.GetActionGroupForFile(file)); }
public override void BuildChildNodes(ITreeBuilder builder, object dataObject) { Project project = (Project)dataObject; GtkDesignInfo info = GtkDesignInfo.FromProject(project); if (GtkDesignInfo.HasDesignedObjects(project)) { GuiProjectFolder folder = new GuiProjectFolder(info.SteticFolder.FullPath, project, null); builder.AddChild(folder); } }
public override void BuildChildNodes(ITreeBuilder builder, object dataObject) { Project p = ((WindowsFolder)dataObject).Project; GtkDesignInfo info = GtkDesignInfo.FromProject(p); if (!info.GuiBuilderProject.HasError) { builder.AddChild(new StockIconsNode(p)); builder.AddChildren(info.GuiBuilderProject.Windows); builder.AddChildren(info.GuiBuilderProject.SteticProject.ActionGroups); } }
void Load() { if (gproject != null || disposed || fileName == null) { return; } gproject = GuiBuilderService.SteticApp.CreateProject(); formInfos = new List <GuiBuilderWindow> (); if (!System.IO.File.Exists(fileName)) { // Regenerate the gtk-gui folder if the stetic project // doesn't exist. GtkDesignInfo.FromProject(project).UpdateGtkFolder(); } try { gproject.Load(fileName); } catch (Exception ex) { MessageService.ShowException(ex, GettextCatalog.GetString("The GUI designer project file '{0}' could not be loaded.", fileName)); hasError = true; } Counters.SteticProjectsLoaded++; gproject.ResourceProvider = GtkDesignInfo.FromProject(project).ResourceProvider; gproject.WidgetAdded += OnAddWidget; gproject.WidgetRemoved += OnRemoveWidget; gproject.ActionGroupsChanged += OnGroupsChanged; project.FileAddedToProject += OnFileAdded; project.FileRemovedFromProject += OnFileRemoved; project.ReferenceAddedToProject += OnReferenceAdded; project.ReferenceRemovedFromProject += OnReferenceRemoved; foreach (Stetic.WidgetInfo ob in gproject.Widgets) { RegisterWindow(ob, false); } // Monitor changes in the file lastSaveTime = System.IO.File.GetLastWriteTime(fileName); watcher = new FileSystemWatcher(); if (System.IO.File.Exists(fileName)) { watcher.Path = Path.GetDirectoryName(fileName); watcher.Filter = Path.GetFileName(fileName); watcher.Changed += (FileSystemEventHandler)DispatchService.GuiDispatch(new FileSystemEventHandler(OnSteticFileChanged)); watcher.EnableRaisingEvents = true; } }
public IViewContent CreateContent(FilePath fileName, string mimeType, Project ownerProject) { excludeThis = true; var db = DisplayBindingService.GetDefaultViewBinding(fileName, mimeType, ownerProject); GtkDesignInfo info = GtkDesignInfo.FromProject((DotNetProject)ownerProject); var content = db.CreateContent(fileName, mimeType, ownerProject); ActionGroupView view = new ActionGroupView(content, GetActionGroup(fileName), info.GuiBuilderProject); excludeThis = false; return(view); }
public override IViewContent CreateContentForUri(string fileName) { excludeThis = true; var db = DisplayBindingService.GetDefaultBindingForUri(fileName); Project project = IdeApp.Workspace.GetProjectContainingFile(fileName); GtkDesignInfo info = GtkDesignInfo.FromProject((DotNetProject)project); ActionGroupView view = new ActionGroupView(db.CreateContentForUri(fileName), GetActionGroup(fileName), info.GuiBuilderProject); excludeThis = false; return(view); }
internal static GuiBuilderWindow GetWindow(string file, Project project) { if (!IdeApp.Workspace.IsOpen) { return(null); } if (!GtkDesignInfo.HasDesignedObjects(project)) { return(null); } GtkDesignInfo info = GtkDesignInfo.FromProject(project); if (file.StartsWith(info.GtkGuiFolder)) { return(null); } var docId = IdeApp.TypeSystemService.GetDocumentId(project, file); if (docId == null) { return(null); } var doc = IdeApp.TypeSystemService.GetCodeAnalysisDocument(docId); if (doc == null) { return(null); } Microsoft.CodeAnalysis.SemanticModel semanticModel; try { semanticModel = doc.GetSemanticModelAsync().Result; } catch { return(null); } if (semanticModel == null) { return(null); } var root = semanticModel.SyntaxTree.GetRoot(); foreach (var classDeclaration in root.DescendantNodesAndSelf(child => !(child is BaseTypeDeclarationSyntax)).OfType <ClassDeclarationSyntax> ()) { var c = semanticModel.GetDeclaredSymbol(classDeclaration); GuiBuilderWindow win = info.GuiBuilderProject.GetWindowForClass(c.ToDisplayString(Microsoft.CodeAnalysis.SymbolDisplayFormat.CSharpErrorMessageFormat)); if (win != null) { return(win); } } return(null); }
public override void ActivateItem() { StockIconsNode node = (StockIconsNode)CurrentNode.DataItem; GtkDesignInfo info = GtkDesignInfo.FromProject(node.Project); GuiBuilderProject gp = info.GuiBuilderProject; Stetic.Project sp = gp.SteticProject; sp.ImagesRootPath = FileService.AbsoluteToRelativePath(info.GtkGuiFolder, gp.Project.BaseDirectory); sp.ImportFileCallback = delegate(string file) { return(GuiBuilderService.ImportFile(gp.Project, file)); }; sp.EditIcons(); gp.Save(true); }
protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration) { DotNetProject project = (DotNetProject)entry; GtkDesignInfo info = GtkDesignInfo.FromProject(project); // The code generator must run in the GUI thread since it needs to // access to Gtk classes Generator gen = new Generator(); lock (gen) { Gtk.Application.Invoke(delegate { gen.Run(monitor, project, configuration); }); Monitor.Wait(gen); } BuildResult res = base.Build(monitor, entry, configuration); if (gen.Messages != null) { foreach (string s in gen.Messages) { res.AddWarning(info.GuiBuilderProject.File, 0, 0, null, s); } if (gen.Messages.Length > 0) { info.ForceCodeGenerationOnBuild(); } } if (res.Failed && !Platform.IsWindows && !Platform.IsMac) { // Some gtk# packages don't include the .pc file unless you install gtk-sharp-devel if (project.AssemblyContext.GetPackage("gtk-sharp-2.0") == null) { string msg = GettextCatalog.GetString( "ERROR: MonoDevelop could not find the Gtk# 2.0 development package. " + "Compilation of projects depending on Gtk# libraries will fail. " + "You may need to install development packages for gtk-sharp-2.0."); monitor.Log.WriteLine(); monitor.Log.WriteLine(msg); } } return(res); }
public override void RenameItem(string newName) { base.RenameItem(newName); Project project = CurrentNode.GetParentDataItem(typeof(Project), true) as Project; if (project != null) { ProjectFile pf = CurrentNode.DataItem as ProjectFile; if (pf.IsComponentFile()) { GtkDesignInfo info = GtkDesignInfo.FromProject(project); info.RenameComponentFile(pf); } } }
public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { Project p = ((WindowsFolder)dataObject).Project; GtkDesignInfo info = GtkDesignInfo.FromProject(p); if (info.GuiBuilderProject.HasError) { label = GettextCatalog.GetString("User Interface (GUI project load failed)"); } else { label = GettextCatalog.GetString("User Interface"); } icon = Context.GetIcon(Stock.OpenResourceFolder); closedIcon = Context.GetIcon(Stock.ClosedResourceFolder); }
internal static GuiBuilderWindow GetWindow(string file) { if (!IdeApp.Workspace.IsOpen) { return(null); } Project project = null; foreach (Project p in IdeApp.Workspace.GetAllProjects()) { if (p.IsFileInProject(file)) { project = p; break; } } if (!GtkDesignInfo.HasDesignedObjects(project)) { return(null); } GtkDesignInfo info = GtkDesignInfo.FromProject(project); if (file.StartsWith(info.GtkGuiFolder)) { return(null); } var doc = TypeSystemService.ParseFile(project, file); if (doc == null) { return(null); } foreach (var t in doc.TopLevelTypeDefinitions) { GuiBuilderWindow win = info.GuiBuilderProject.GetWindowForClass(t.FullName); if (win != null) { return(win); } } return(null); }
internal static GuiBuilderWindow GetWindow(string file) { if (!IdeApp.Workspace.IsOpen) { return(null); } Project project = null; foreach (Project p in IdeApp.Workspace.GetAllProjects()) { if (p.IsFileInProject(file)) { project = p; break; } } if (!GtkDesignInfo.HasDesignedObjects(project)) { return(null); } GtkDesignInfo info = GtkDesignInfo.FromProject(project); if (file.StartsWith(info.GtkGuiFolder)) { return(null); } ParsedDocument doc = ProjectDomService.GetParsedDocument(null, file); if (doc == null || doc.CompilationUnit == null) { return(null); } foreach (IType t in doc.CompilationUnit.Types) { GuiBuilderWindow win = info.GuiBuilderProject.GetWindowForClass(t.FullName); if (win != null) { return(win); } } return(null); }
public IType FindClass(string className, bool getUserClass) { GtkDesignInfo info = GtkDesignInfo.FromProject(project); FilePath gui_folder = info.SteticFolder; ProjectDom ctx = GetParserContext(); if (ctx == null) { return(null); } IEnumerable <IType> classes = ctx.Types; if (classes == null) { return(null); } foreach (IType cls in classes) { if (cls.FullName == className) { if (getUserClass) { // Return this class only if it is declared outside the gtk-gui // folder. Generated partial classes will be ignored. foreach (IType part in cls.Parts) { if (part.CompilationUnit.FileName.FullPath.IsChildPathOf(gui_folder)) { continue; } if (part.CompilationUnit != null && !part.CompilationUnit.FileName.IsNullOrEmpty && !part.CompilationUnit.FileName.FileName.Contains(info.BuildFileExtension)) { return(part); } } continue; } if (getUserClass && cls.CompilationUnit != null && !string.IsNullOrEmpty(cls.CompilationUnit.FileName) && cls.CompilationUnit.FileName.IsChildPathOf(gui_folder)) { continue; } return(cls); } } return(null); }
public override void GetNodeAttributes(ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes) { if (treeNavigator.Options ["ShowAllFiles"]) { return; } ProjectFolder folder = dataObject as ProjectFolder; if (folder != null && folder.Project is DotNetProject) { GtkDesignInfo info = GtkDesignInfo.FromProject(folder.Project); if (info.GtkGuiFolder == folder.Path) { attributes |= NodeAttributes.Hidden; } } }