Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GtkProjectServiceExtension.cs')
-rw-r--r--main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GtkProjectServiceExtension.cs49
1 files changed, 26 insertions, 23 deletions
diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GtkProjectServiceExtension.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GtkProjectServiceExtension.cs
index 191037ecd8..35cbbfb921 100644
--- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GtkProjectServiceExtension.cs
+++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GtkProjectServiceExtension.cs
@@ -4,12 +4,13 @@ using System.Threading;
using MonoDevelop.Core;
using MonoDevelop.Projects;
using MonoDevelop.Ide;
+using System.Threading.Tasks;
namespace MonoDevelop.GtkCore.GuiBuilder
{
- public class GtkProjectServiceExtension: ProjectServiceExtension
+ public class GtkProjectServiceExtension: DotNetProjectExtension
{
- public override bool SupportsItem (IBuildTarget item)
+ protected override bool SupportsObject (WorkspaceObject item)
{
if (!IdeApp.IsInitialized)
return false;
@@ -18,20 +19,19 @@ namespace MonoDevelop.GtkCore.GuiBuilder
return project != null && GtkDesignInfo.HasDesignedObjects (project);
}
- protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
+ protected async override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration)
{
- DotNetProject project = (DotNetProject) entry;
- GtkDesignInfo info = GtkDesignInfo.FromProject (project);
+ 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);
+ if (!await gen.Run (monitor, Project, configuration)) {
+ BuildResult gr = new BuildResult ();
+ foreach (string s in gen.Messages)
+ gr.AddError (info.GuiBuilderProject.File, 0, 0, null, s);
+ return gr;
}
- BuildResult res = base.Build (monitor, entry, configuration);
+ BuildResult res = await base.OnBuild (monitor, configuration);
if (gen.Messages != null) {
foreach (string s in gen.Messages)
@@ -43,7 +43,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder
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) {
+ 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. " +
@@ -59,19 +59,22 @@ namespace MonoDevelop.GtkCore.GuiBuilder
class Generator
{
- public void Run (IProgressMonitor monitor, DotNetProject project, ConfigurationSelector configuration)
+ public async Task<bool> Run (ProgressMonitor monitor, DotNetProject project, ConfigurationSelector configuration)
{
- lock (this) {
- try {
- Stetic.CodeGenerationResult res = GuiBuilderService.GenerateSteticCode (monitor, project, configuration);
- if (res != null)
- Messages = res.Warnings;
- } catch (Exception ex) {
- Error = ex;
- LoggingService.LogError (ex.ToString ());
- Messages = new string [] { Error.Message };
+ try {
+ Stetic.CodeGenerationResult res = await GuiBuilderService.GenerateSteticCode (monitor, project, configuration);
+ if (res != null) {
+ Messages = res.Warnings;
+ return true;
+ } else {
+ Messages = new [] { GettextCatalog.GetString ("Code generation failed") };
+ return false;
}
- Monitor.PulseAll (this);
+ } catch (Exception ex) {
+ Error = ex;
+ LoggingService.LogError (ex.ToString ());
+ Messages = new [] { Error.Message };
+ return false;
}
}
public string[] Messages;