diff options
Diffstat (limited to 'main/src/addins/MonoDevelop.GtkCore')
21 files changed, 52 insertions, 455 deletions
diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/GtkFeatureWidget.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/GtkFeatureWidget.cs index 0b6e913dc9..1496e4cba0 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/GtkFeatureWidget.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/GtkFeatureWidget.cs @@ -48,7 +48,7 @@ namespace MonoDevelop.GtkCore.Dialogs get { return GettextCatalog.GetString ("Enables support for GTK# in the project. Allows the visual design of GTK# windows, and the creation of a GTK# widget library."); } } - public FeatureSupportLevel GetSupportLevel (SolutionFolder parentCombine, SolutionItem entry) + public FeatureSupportLevel GetSupportLevel (SolutionFolder parentCombine, SolutionFolderItem entry) { if (!(entry is DotNetProject) || !GtkDesignInfo.SupportsRefactoring (entry as DotNetProject)) return FeatureSupportLevel.NotSupported; @@ -59,18 +59,18 @@ namespace MonoDevelop.GtkCore.Dialogs if (GtkDesignInfo.SupportsDesigner ((Project)entry)) return FeatureSupportLevel.Enabled; - else if (entry is DotNetAssemblyProject) + else if (entry is DotNetProject) return FeatureSupportLevel.SupportedByDefault; else return FeatureSupportLevel.Supported; } - public Widget CreateFeatureEditor (SolutionFolder parentCombine, SolutionItem entry) + public Widget CreateFeatureEditor (SolutionFolder parentCombine, SolutionFolderItem entry) { return new GtkFeatureWidget ((DotNetProject) entry); } - public void ApplyFeature (SolutionFolder parentCombine, SolutionItem entry, Widget editor) + public void ApplyFeature (SolutionFolder parentCombine, SolutionFolderItem entry, Widget editor) { GtkFeatureWidget fw = (GtkFeatureWidget) editor; ReferenceManager refmgr = new ReferenceManager ((DotNetProject) entry); @@ -78,7 +78,7 @@ namespace MonoDevelop.GtkCore.Dialogs refmgr.Dispose (); } - public string Validate (SolutionFolder parentCombine, SolutionItem entry, Gtk.Widget editor) + public string Validate (SolutionFolder parentCombine, SolutionFolderItem entry, Gtk.Widget editor) { return null; } 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; diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs index 6a23250d36..9c381c600d 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs @@ -219,7 +219,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder } if (GtkDesignInfo.FromProject (project).UpdateGtkFolder () && saveMdProject) - IdeApp.ProjectOperations.Save (project); + IdeApp.ProjectOperations.SaveAsync (project); } public string File { diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs index 28dac4d37e..601733e9d3 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs @@ -42,6 +42,7 @@ using MonoDevelop.Projects.Policies; using MonoDevelop.Ide; using MonoDevelop.Ide.Gui.Content; using MonoDevelop.Ide.TypeSystem; +using System.Threading.Tasks; namespace MonoDevelop.GtkCore.GuiBuilder @@ -385,7 +386,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder } - public static Stetic.CodeGenerationResult GenerateSteticCode (IProgressMonitor monitor, DotNetProject project, ConfigurationSelector configuration) + public async static Task<Stetic.CodeGenerationResult> GenerateSteticCode (ProgressMonitor monitor, DotNetProject project, ConfigurationSelector configuration) { if (generating || !GtkDesignInfo.HasDesignedObjects (project)) return null; @@ -423,7 +424,6 @@ namespace MonoDevelop.GtkCore.GuiBuilder if (info.GuiBuilderProject.HasError) { monitor.ReportError (GettextCatalog.GetString ("GUI code generation failed for project '{0}'. The file '{1}' could not be loaded.", project.Name, info.SteticFile), null); - monitor.AsyncOperation.Cancel (); return null; } @@ -454,8 +454,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder if (!canGenerateInProcess) { timer.Trace ("Generating out of process"); - // Run the generation in another thread to avoid freezing the GUI - System.Threading.ThreadPool.QueueUserWorkItem (delegate { + await Task.Factory.StartNew (delegate { try { // Generate the code in another process if stetic is not isolated CodeGeneratorProcess cob = (CodeGeneratorProcess)Runtime.ProcessService.CreateExternalProcessObject (typeof(CodeGeneratorProcess), false); @@ -469,10 +468,6 @@ namespace MonoDevelop.GtkCore.GuiBuilder } }); - while (generating) { - DispatchService.RunPendingEvents (); - System.Threading.Thread.Sleep (100); - } } else { timer.Trace ("Generating in-process"); // No need to create another process, since stetic has its own backend process @@ -544,7 +539,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder // Make sure the generated files are added to the project if (info.UpdateGtkFolder ()) { Gtk.Application.Invoke (delegate { - IdeApp.ProjectOperations.Save (project); + IdeApp.ProjectOperations.SaveAsync (project); }); } diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/ActionGroupNodeBuilder.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/ActionGroupNodeBuilder.cs index b83e9e7a11..5b0fd87a2f 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/ActionGroupNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/ActionGroupNodeBuilder.cs @@ -136,7 +136,7 @@ namespace MonoDevelop.GtkCore.NodeBuilders } gproject.RemoveActionGroup (group); gproject.SaveProject (false); - IdeApp.ProjectOperations.Save (project); + IdeApp.ProjectOperations.SaveAsync (project); } } } diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/ProjectFolderNodeBuilderExtension.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/ProjectFolderNodeBuilderExtension.cs index 59c1529d1a..42cfbd603d 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/ProjectFolderNodeBuilderExtension.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/ProjectFolderNodeBuilderExtension.cs @@ -182,7 +182,7 @@ namespace MonoDevelop.GtkCore.NodeBuilders IdeApp.ProjectOperations.CreateProjectFile (project, path, id); - IdeApp.ProjectOperations.Save (project); + IdeApp.ProjectOperations.SaveAsync (project); ITreeNavigator nav = Tree.GetNodeAtObject (dataItem); if (nav != null) diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/WidgetNodeBuilder.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/WidgetNodeBuilder.cs index 79e0b00d81..c0d692977c 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/WidgetNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/WidgetNodeBuilder.cs @@ -141,7 +141,7 @@ namespace MonoDevelop.GtkCore.NodeBuilders } w.Project.Remove (w); w.Project.SaveProject (false); - IdeApp.ProjectOperations.Save (w.Project.Project); + IdeApp.ProjectOperations.SaveAsync (w.Project.Project); } } } diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.addin.xml b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.addin.xml index 8cf80f0493..a892ef2a5b 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.addin.xml +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.addin.xml @@ -146,8 +146,8 @@ <StockIcon stockid = "md-gtkcore-actiongroup" resource = "actiongroup.png" /> </Extension> - <Extension path = "/MonoDevelop/ProjectModel/ProjectServiceExtensions"> - <Class class = "MonoDevelop.GtkCore.GuiBuilder.GtkProjectServiceExtension" insertafter="MidStep"/> + <Extension path = "/MonoDevelop/ProjectModel/ProjectModelExtensions"> + <ProjectExtension class = "MonoDevelop.GtkCore.GuiBuilder.GtkProjectServiceExtension" insertafter="MidStep"/> </Extension> <Extension path = "/MonoDevelop/DesignerSupport/ToolboxProviders"> diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ProjectResourceProvider.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ProjectResourceProvider.cs index e1c46517d8..6128a6a9bf 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ProjectResourceProvider.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ProjectResourceProvider.cs @@ -65,7 +65,7 @@ namespace MonoDevelop.GtkCore public Stetic.ResourceInfo AddResource (string fileName) { ProjectFile file = project.AddFile (fileName, BuildAction.EmbeddedResource); - IdeApp.ProjectOperations.Save (project); + IdeApp.ProjectOperations.SaveAsync (project); return new Stetic.ResourceInfo (file.ResourceId, fileName); } @@ -74,7 +74,7 @@ namespace MonoDevelop.GtkCore foreach (ProjectFile file in project.Files) { if (resourceName == file.ResourceId) { project.Files.Remove (file); - IdeApp.ProjectOperations.Save (project); + IdeApp.ProjectOperations.SaveAsync (project); return; } } diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs index 68161a0a33..e9642c0d0e 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs @@ -77,7 +77,7 @@ namespace MonoDevelop.GtkCore return (project is DotNetProject) && GtkDesignInfo.SupportsRefactoring (project as DotNetProject); } - public override bool AddToProject (SolutionItem policyParent, Project project, string language, string directory, string name) + public override bool AddToProject (SolutionFolderItem policyParent, Project project, string language, string directory, string name) { if (!GtkDesignInfo.SupportsDesigner (project)) { ReferenceManager mgr = new ReferenceManager (project as DotNetProject); @@ -114,7 +114,7 @@ namespace MonoDevelop.GtkCore gproject.AddNewComponent (doc.DocumentElement); gproject.SaveAll (false); - IdeApp.ProjectOperations.Save (project); + IdeApp.ProjectOperations.SaveAsync (project); return true; } @@ -128,7 +128,7 @@ namespace MonoDevelop.GtkCore gproject.SteticProject.AddNewActionGroup (doc.DocumentElement); gproject.SaveAll (false); - IdeApp.ProjectOperations.Save (project); + IdeApp.ProjectOperations.SaveAsync (project); return true; } diff --git a/main/src/addins/MonoDevelop.GtkCore/libstetic/ImageInfo.cs b/main/src/addins/MonoDevelop.GtkCore/libstetic/ImageInfo.cs index 90e6e17c7b..0a766731d3 100644 --- a/main/src/addins/MonoDevelop.GtkCore/libstetic/ImageInfo.cs +++ b/main/src/addins/MonoDevelop.GtkCore/libstetic/ImageInfo.cs @@ -117,6 +117,8 @@ namespace Stetic } catch { // Not a valid image return WidgetUtils.MissingIcon; + } finally { + s.Dispose (); } case ImageSource.Theme: diff --git a/main/src/addins/MonoDevelop.GtkCore/libstetic/editor/SelectImageDialog.cs b/main/src/addins/MonoDevelop.GtkCore/libstetic/editor/SelectImageDialog.cs index 3f64c92369..c4f6330cb6 100644 --- a/main/src/addins/MonoDevelop.GtkCore/libstetic/editor/SelectImageDialog.cs +++ b/main/src/addins/MonoDevelop.GtkCore/libstetic/editor/SelectImageDialog.cs @@ -207,13 +207,14 @@ namespace Stetic.Editor { try { Gdk.Pixbuf pix = new Gdk.Pixbuf (stream); - stream.Close (); string txt = name + "\n<span foreground='darkgrey' size='x-small'>" + pix.Width + " x " + pix.Height + "</span>"; pix = GetThumbnail (pix); resourceListStore.AppendValues (pix, txt, name); resources [name] = pix; } catch { // Doesn't look like a valid image. Just ignore it. + } finally { + stream.Dispose (); } } diff --git a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/ButtonFunction.cs b/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/ButtonFunction.cs deleted file mode 100644 index 9fa8ef4907..0000000000 --- a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/ButtonFunction.cs +++ /dev/null @@ -1,20 +0,0 @@ -// This file was generated by the Gtk# code generator. -// Any changes made will be lost if regenerated. - -namespace Stetic.Metacity -{ - - using System; - using System.Runtime.InteropServices; - -#region Autogenerated code - internal enum ButtonFunction { - - Menu, - Minimize, - Maximize, - Close, - Last, - } -#endregion -} diff --git a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/ButtonLayout.cs b/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/ButtonLayout.cs deleted file mode 100644 index e954c20a3e..0000000000 --- a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/ButtonLayout.cs +++ /dev/null @@ -1,36 +0,0 @@ -// This file was generated by the Gtk# code generator. -// Any changes made will be lost if regenerated. - -namespace Stetic.Metacity -{ - - using System; - using System.Collections; - using System.Runtime.InteropServices; - -#region Autogenerated code - [StructLayout(LayoutKind.Sequential)] - internal struct ButtonLayout { - - [MarshalAs (UnmanagedType.ByValArray, SizeConst=4)] - public Metacity.ButtonFunction[] LeftButtons; - [MarshalAs (UnmanagedType.ByValArray, SizeConst=4)] - public Metacity.ButtonFunction[] RightButtons; - - public static Metacity.ButtonLayout Zero = new Metacity.ButtonLayout (); - - public static Metacity.ButtonLayout New(IntPtr raw) { - if (raw == IntPtr.Zero) { - return Metacity.ButtonLayout.Zero; - } - Metacity.ButtonLayout self = new Metacity.ButtonLayout(); - self = (Metacity.ButtonLayout) Marshal.PtrToStructure (raw, self.GetType ()); - return self; - } - - internal static GLib.GType GType { - get { return GLib.GType.Pointer; } - } -#endregion - } -} diff --git a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/FrameFlags.cs b/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/FrameFlags.cs deleted file mode 100644 index bc6172fbe8..0000000000 --- a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/FrameFlags.cs +++ /dev/null @@ -1,30 +0,0 @@ -// This file was generated by the Gtk# code generator. -// Any changes made will be lost if regenerated. - -namespace Stetic.Metacity -{ - - using System; - using System.Runtime.InteropServices; - -#region Autogenerated code - [Flags] - internal enum FrameFlags { - - AllowsDelete = 1 << 0, - AllowsMenu = 1 << 1, - AllowsMinimize = 1 << 2, - AllowsMaximize = 1 << 3, - AllowsVerticalResize = 1 << 4, - AllowsHorizontalResize = 1 << 5, - HasFocus = 1 << 6, - Shaded = 1 << 7, - Stuck = 1 << 8, - Maximized = 1 << 9, - AllowsShade = 1 << 10, - AllowsMove = 1 << 11, - Fullscreen = 1 << 12, - IsFlashing = 1 << 13, - } -#endregion -} diff --git a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/FrameType.cs b/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/FrameType.cs deleted file mode 100644 index 7ecc08d277..0000000000 --- a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/FrameType.cs +++ /dev/null @@ -1,22 +0,0 @@ -// This file was generated by the Gtk# code generator. -// Any changes made will be lost if regenerated. - -namespace Stetic.Metacity -{ - - using System; - using System.Runtime.InteropServices; - -#region Autogenerated code - internal enum FrameType { - - Normal, - Dialog, - ModalDialog, - Utility, - Menu, - Border, - Last, - } -#endregion -} diff --git a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/ObjectManager.cs b/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/ObjectManager.cs deleted file mode 100644 index 201c52370e..0000000000 --- a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/ObjectManager.cs +++ /dev/null @@ -1,19 +0,0 @@ -// This file was generated by the Gtk# code generator. -// Any changes made will be lost if regenerated. - -namespace GtkSharp.MetacitySharp { - - class ObjectManager { - - static bool initialized = false; - // Call this method from the appropriate module init function. - public static void Initialize () - { - if (initialized) - return; - - initialized = true; - GLib.GType.Register (Stetic.Metacity.Preview.GType, typeof (Stetic.Metacity.Preview)); - } - } -} diff --git a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/Preview.cs b/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/Preview.cs deleted file mode 100644 index b0bd5ba026..0000000000 --- a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/Preview.cs +++ /dev/null @@ -1,226 +0,0 @@ -// This file was generated by the Gtk# code generator. -// Any changes made will be lost if regenerated. - -namespace Stetic.Metacity { - - using System; - using System.Reflection; - using System.Collections; - using System.Runtime.InteropServices; - - internal class Preview : Gtk.Bin - { - const string LIBMETACITY = "libmetacity-private.so.0"; - static Theme theme; - public static bool ThemeError = false; - - public static Metacity.Preview Create (TopLevelWindow window) - { - Metacity.Preview metacityPreview; - - try { - Metacity.Preview.Init (); - metacityPreview = new Metacity.Preview (); - } - catch { - return null; - } - - switch (window.TypeHint) { - case Gdk.WindowTypeHint.Normal: - metacityPreview.FrameType = Metacity.FrameType.Normal; - break; - case Gdk.WindowTypeHint.Dialog: - metacityPreview.FrameType = window.Modal ? Metacity.FrameType.ModalDialog : Metacity.FrameType.Dialog; - break; - case Gdk.WindowTypeHint.Menu: - metacityPreview.FrameType = Metacity.FrameType.Menu; - break; - case Gdk.WindowTypeHint.Splashscreen: - metacityPreview.FrameType = Metacity.FrameType.Border; - break; - case Gdk.WindowTypeHint.Utility: - metacityPreview.FrameType = Metacity.FrameType.Utility; - break; - default: - metacityPreview.FrameType = Metacity.FrameType.Normal; - break; - } - - Metacity.FrameFlags flags = - Metacity.FrameFlags.AllowsDelete | - Metacity.FrameFlags.AllowsVerticalResize | - Metacity.FrameFlags.AllowsHorizontalResize | - Metacity.FrameFlags.AllowsMove | - Metacity.FrameFlags.AllowsShade | - Metacity.FrameFlags.HasFocus; - - if (window.Resizable) - flags = flags | Metacity.FrameFlags.AllowsMaximize; - - metacityPreview.FrameFlags = flags; - metacityPreview.ShowAll (); - metacityPreview.AddWindow (window); - - metacityPreview.Theme = GetTheme (); - - return metacityPreview; - } - - public void AddWindow (TopLevelWindow window) - { - base.Add (window); - - Title = window.Title ?? string.Empty; - window.PropertyChanged += OnWindowPropChange; - Destroyed += delegate { - window.PropertyChanged -= OnWindowPropChange; - }; - } - - void OnWindowPropChange (object ob, EventArgs e) - { - Title = ((TopLevelWindow)ob).Title ?? string.Empty; - } - - static Theme GetTheme () - { - if (theme == null) { - try { - Assembly assm = Assembly.LoadWithPartialName ("gconf-sharp"); - Type client_type = assm.GetType ("GConf.Client"); - MethodInfo method = client_type.GetMethod ("Get", BindingFlags.Instance | BindingFlags.Public); - object client = Activator.CreateInstance (client_type, new object[] { - - }); - string themeName = (string)method.Invoke (client, new object[] { "/apps/metacity/general/theme" }); - theme = Metacity.Theme.Load (themeName); - } catch { - // Set theme error flag - in case of a theme error a solid background needs to be drawn. - ThemeError = true; - // Don't crash if metacity is not available - return null; - } - } - return theme; - } - - /* static void GConfNotify (object obj, GConf.NotifyEventArgs args) - { - if (args.Key == "/apps/metacity/general/theme") { - theme = Metacity.Theme.Load ((string)args.Value); - foreach (Metacity.Preview prev in wrappers.Values) - prev.Theme = Theme; - } - } - */ - - ~Preview ( ) - { - Dispose(); - } - - public Preview(IntPtr raw) : base(raw) {} - - [DllImport(LIBMETACITY)] - static extern IntPtr meta_preview_new(); - - public Preview () : base (IntPtr.Zero) - { - if (GetType () != typeof (Preview)) { - CreateNativeObject (new string [0], new GLib.Value[0]); - return; - } - Raw = meta_preview_new(); - } - - [DllImport(LIBMETACITY)] - static extern void meta_preview_set_title(IntPtr raw, IntPtr title); - - public string Title { - set { - IntPtr title_as_native = GLib.Marshaller.StringToPtrGStrdup (value); - meta_preview_set_title(Handle, title_as_native); - GLib.Marshaller.Free (title_as_native); - } - } - - [DllImport(LIBMETACITY)] - static extern void meta_preview_set_button_layout(IntPtr raw, ref Stetic.Metacity.ButtonLayout button_layout); - - public Stetic.Metacity.ButtonLayout ButtonLayout - { - set { - meta_preview_set_button_layout(Handle, ref value); - } - } - - [DllImport(LIBMETACITY)] - static extern void meta_preview_set_theme(IntPtr raw, IntPtr theme); - - public Metacity.Theme Theme { - set { - meta_preview_set_theme(Handle, (value == null ? IntPtr.Zero : value.Handle)); - } - } - - [DllImport(LIBMETACITY)] - static extern IntPtr meta_preview_get_mini_icon(); - - public static Gdk.Pixbuf MiniIcon { - get { - IntPtr raw_ret = meta_preview_get_mini_icon(); - Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf; - return ret; - } - } - - [DllImport(LIBMETACITY)] - static extern IntPtr meta_preview_get_icon(); - - public static Gdk.Pixbuf Icon { - get { - IntPtr raw_ret = meta_preview_get_icon(); - Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf; - return ret; - } - } - - [DllImport(LIBMETACITY)] - static extern void meta_preview_set_frame_type(IntPtr raw, int type); - - public Stetic.Metacity.FrameType FrameType - { - set { - meta_preview_set_frame_type(Handle, (int) value); - } - } - - [DllImport(LIBMETACITY)] - static extern IntPtr meta_preview_get_type(); - - public static new GLib.GType GType { - get { - IntPtr raw_ret = meta_preview_get_type(); - GLib.GType ret = new GLib.GType(raw_ret); - return ret; - } - } - - [DllImport(LIBMETACITY)] - static extern void meta_preview_set_frame_flags(IntPtr raw, int flags); - - public Stetic.Metacity.FrameFlags FrameFlags - { - set { - meta_preview_set_frame_flags(Handle, (int) value); - } - } - - - public static void Init() - { - GtkSharp.MetacitySharp.ObjectManager.Initialize (); - } - } -} diff --git a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/Theme.cs b/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/Theme.cs deleted file mode 100644 index b9254d710d..0000000000 --- a/main/src/addins/MonoDevelop.GtkCore/libsteticui/Metacity/Theme.cs +++ /dev/null @@ -1,41 +0,0 @@ - -namespace Stetic.Metacity -{ - using System; - using System.Runtime.InteropServices; - - internal class Theme : GLib.Opaque { - - public Theme (IntPtr raw) : base (raw) {} - - [DllImport("libmetacity-private.so.0")] - static extern IntPtr meta_theme_get_current (); - - public static Theme Current { - get { - IntPtr raw = meta_theme_get_current (); - return (Theme)GetOpaque (raw, typeof (Metacity.Theme), true); - } - } - - [DllImport("libmetacity-private.so.0")] - static extern IntPtr meta_theme_load (string theme_name, IntPtr err); - - public static Theme Load (string name) - { - IntPtr raw = meta_theme_load (name, IntPtr.Zero); - if (raw == IntPtr.Zero) - return null; - else - return (Theme)GetOpaque (raw, typeof (Metacity.Theme), true); - } - - [DllImport("libmetacity-private.so.0")] - static extern void meta_theme_free (IntPtr raw); - - protected override void Free (IntPtr raw) - { - meta_theme_free (Raw); - } - } -} diff --git a/main/src/addins/MonoDevelop.GtkCore/libsteticui/WidgetDesignerBackend.cs b/main/src/addins/MonoDevelop.GtkCore/libsteticui/WidgetDesignerBackend.cs index aad811474c..e3d6864c2c 100644 --- a/main/src/addins/MonoDevelop.GtkCore/libsteticui/WidgetDesignerBackend.cs +++ b/main/src/addins/MonoDevelop.GtkCore/libsteticui/WidgetDesignerBackend.cs @@ -78,9 +78,7 @@ namespace Stetic TopLevelWindow window = container as TopLevelWindow; if (window != null) { - preview = Stetic.Metacity.Preview.Create (window); - if (preview == null) - preview = Stetic.Windows.Preview.Create (window); + preview = Stetic.Windows.Preview.Create (window); if (preview == null) { // Use a regular box. EventBox eventBox = new EventBox (); @@ -660,8 +658,7 @@ namespace Stetic PropagateExpose (cw, ev);*/ Gdk.Rectangle rect = child.Allocation; - if (Stetic.Metacity.Preview.ThemeError) - GdkWindow.DrawRectangle (this.Style.BackgroundGC (StateType.Normal), true, rect.X, rect.Y, rect.Width, rect.Height); + GdkWindow.DrawRectangle (this.Style.BackgroundGC (StateType.Normal), true, rect.X, rect.Y, rect.Width, rect.Height); Pixbuf sh = Shadow.AddShadow (rect.Width, rect.Height); GdkWindow.DrawPixbuf (this.Style.BackgroundGC (StateType.Normal), sh, 0, 0, rect.X - 5, rect.Y - 5, sh.Width, sh.Height, RgbDither.None, 0, 0); diff --git a/main/src/addins/MonoDevelop.GtkCore/libsteticui/libsteticui.csproj b/main/src/addins/MonoDevelop.GtkCore/libsteticui/libsteticui.csproj index fc38b4c1e5..fb9b52a59d 100644 --- a/main/src/addins/MonoDevelop.GtkCore/libsteticui/libsteticui.csproj +++ b/main/src/addins/MonoDevelop.GtkCore/libsteticui/libsteticui.csproj @@ -109,13 +109,6 @@ <Compile Include="GuiDispatchServerSink.cs" /> <Compile Include="GuiDispatchServerSinkProvider.cs" /> <Compile Include="LibraryCache.cs" /> - <Compile Include="Metacity\ButtonFunction.cs" /> - <Compile Include="Metacity\ButtonLayout.cs" /> - <Compile Include="Metacity\FrameFlags.cs" /> - <Compile Include="Metacity\FrameType.cs" /> - <Compile Include="Metacity\ObjectManager.cs" /> - <Compile Include="Metacity\Preview.cs" /> - <Compile Include="Metacity\Theme.cs" /> <Compile Include="Palette.cs" /> <Compile Include="PaletteBackend.cs" /> <Compile Include="PluggableWidget.cs" /> |