Permalink
Browse files

Added initial code to convert Linux UI to Qt (using Qyoto).

Added log4net infrastructure.
Added MonoAttribute for versioning information.
Fixed bugs relating to loading the Linux platform module.
  • Loading branch information...
1 parent 1473c2e commit 32e2f3988984bbf9c30ff7723dcc193e2e6c5d0d James Rhodes committed Apr 29, 2012
View
@@ -13,9 +13,10 @@ vs2008/moai-harness/Debug/BuildLog.htm
*.ncb
*.pidb
*.userprefs
+*.resources
ide/src/Moai.IDE/Deployment/Engines/*
ide/src/Moai.IDE/Deployment/Framework/*
ide/libraries/*/bin
ide/libraries/*/obj
-ide/src/*/bin/*
-ide/src/*/obj/*
+ide/bin/*
+ide/src/*/obj/*
View
@@ -1,3 +1,7 @@
using Moai.Versioning;
-[assembly: VisualStudio2008()]
+#if __MONOCS__
+[assembly: Mono()]
+#else
+[assembly: VisualStudio2008()]
+#endif
View
Binary file not shown.
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -16,7 +16,8 @@ static class Program
[STAThread]
static void Main()
{
- Central.Initialize(new Manager(), PlatformDetection.Detect());
+ Central.InitializeLogger();
+ Central.InitializeSystem(new Manager(), PlatformDetection.Detect());
Central.Manager.Initalize();
Central.Manager.Start();
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -2,25 +2,25 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Gtk;
using Moai.Platform.Linux.Menus;
using Moai.Platform.Linux.UI;
using Moai.Platform.Linux.Tools;
+using Qyoto;
namespace Moai.Platform.Linux
{
- public partial class LinuxIDE : Window, IIDE
+ public partial class LinuxIDE : QWidget, IIDE
{
public event EventHandler Opened;
public event EventHandler Closed;
public event EventHandler ActiveTabChanged;
public event EventHandler ResizeEnd;
- public LinuxIDE() : base("Moai IDE")
+ public LinuxIDE()
{
InitializeComponent();
- this.Title += " (" + Versioning.Version.GetVersionString() + ")";
- this.Icon = LinuxImageList.ConvertToPixbuf(Properties.Resources.MoaiIcon);
+ this.WindowTitle = "Moai IDE (" + Versioning.Version.GetVersionString() + ")";
+ this.WindowIcon = LinuxImageList.ConvertToQIcon(Properties.Resources.MoaiIcon);
}
/// <summary>
@@ -31,16 +31,16 @@ public LinuxIDE() : base("Moai IDE")
void IDE_Shown(object sender, EventArgs e)
{
// Load the main menu.
- this.SetMainMenu(ActionWrapper.GetMainMenu(Central.Manager.MenuManager.MainMenu));
+ //this.SetMainMenu(ActionWrapper.GetMainMenu(Central.Manager.MenuManager.MainMenu));
// Load the tool bar.
- this.SetToolBar(ActionWrapper.GetToolBar(Central.Manager.MenuManager.ToolBar));
+ //this.SetToolBar(ActionWrapper.GetToolBar(Central.Manager.MenuManager.ToolBar));
// Set up the workspace.
- Central.Manager.ToolsManager = new Moai.Platform.Linux.Tools.Manager();
+ //Central.Manager.ToolsManager = new Moai.Platform.Linux.Tools.Manager();
//Central.Manager.ToolsManager.Show(typeof(Moai.Platform.Linux.Tools.ErrorListTool));
//Central.Manager.ToolsManager.Show(typeof(Moai.Platform.Linux.Tools.ImmediateWindowTool));
- Central.Manager.ToolsManager.Show(typeof(Moai.Platform.Linux.Tools.SolutionExplorerTool));
+ //Central.Manager.ToolsManager.Show(typeof(Moai.Platform.Linux.Tools.SolutionExplorerTool));
// Show the start page.
//this.ShowDock(new Moai.Platform.Windows.Designers.Start.Designer(null), ToolPosition.Document);
@@ -50,7 +50,7 @@ void IDE_Shown(object sender, EventArgs e)
public void Exit()
{
- Application.Quit();
+ QApplication.Quit();
}
public Moai.Platform.UI.ITab ActiveTab
@@ -65,13 +65,15 @@ public bool IsDisposed
public void ShowDock(Moai.Platform.UI.ITool tool, Moai.Platform.UI.ToolPosition position)
{
+ throw new NotSupportedException();
+
switch (position)
{
case Moai.Platform.UI.ToolPosition.DockRight:
- this.c_RightTools.AppendPage(tool as Widget, new AccelLabel((tool as Tool).Title));
+ //this.c_RightTools.AppendPage(tool as Widget, new AccelLabel((tool as Tool).Title));
break;
case Moai.Platform.UI.ToolPosition.DockBottom:
- this.c_BottomTools.AppendPage(tool as Widget, new AccelLabel((tool as Tool).Title));
+ //this.c_BottomTools.AppendPage(tool as Widget, new AccelLabel((tool as Tool).Title));
break;
default:
throw new NotSupportedException();
@@ -2,16 +2,17 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Gtk;
+using Qyoto;
namespace Moai.Platform.Linux
{
public class LinuxPlatform : IPlatform
{
public LinuxPlatform()
{
+ new QApplication(new string[] { });
this.UI = new LinuxUI();
- Application.Init();
+ //Application.Init();
}
public IIDE CreateIDE()
@@ -21,9 +22,9 @@ public IIDE CreateIDE()
public void RunIDE(IIDE ide)
{
- (ide as LinuxIDE).Maximize();
- (ide as LinuxIDE).ShowAll();
- Application.Run();
+ //(ide as LinuxIDE).Maximize();
+ //(ide as LinuxIDE).ShowAll();
+ QApplication.Exec();
}
public Type GetDesignerTypeImplementing(Type type)
@@ -54,8 +54,8 @@ public void ShowMessage(string message, string title, MessageBoxButtons buttons,
throw new NotSupportedException();
}
- MessageDialog dialog = new MessageDialog((Central.Manager.IDE as LinuxIDE), DialogFlags.Modal, nativeIcon, nativeButtons, message);
- dialog.Show();
+ //MessageDialog dialog = new MessageDialog((Central.Manager.IDE as LinuxIDE), DialogFlags.Modal, nativeIcon, nativeButtons, message);
+ //dialog.Show();
}
public void ShowMessage(string message, string title, MessageBoxButtons buttons)
@@ -75,7 +75,8 @@ public void ShowMessage(string message)
public string PickExistingFile(PickingData data)
{
- FileChooserDialog fcd = new FileChooserDialog(
+ throw new NotImplementedException();
+ /*FileChooserDialog fcd = new FileChooserDialog(
"Select File",
(Central.Manager.IDE as LinuxIDE),
FileChooserAction.Open,
@@ -89,7 +90,7 @@ public string PickExistingFile(PickingData data)
if (fcd.Run() == (int)ResponseType.Accept)
result = fcd.Filename;
fcd.Destroy();
- return result;
+ return result;*/
}
public Moai.Platform.Templates.Solutions.SolutionCreationData PickNewSolution()
@@ -44,7 +44,7 @@ private static void ActionSyncDataChanged(Moai.Platform.Menus.Action.ActionSyncD
//mi.ShortcutKeys = KeyUtil.FromPlatform(data.Shortcut);
//mi.ShowShortcutKeys = false;
mi.Sensitive = data.Enabled && data.Implemented;
- mi.Image = LinuxImageList.ConvertToGtk(data.ItemIcon);
+ //mi.Image = LinuxImageList.ConvertToGtk(data.ItemIcon);
};
/*if (mi.Parent != null && (mi.Window.InvokeRequired)
mi.Parent.Invoke(act);
@@ -48,6 +48,12 @@
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
+ <Reference Include="qt-dotnet">
+ <HintPath>..\..\..\..\..\..\..\..\usr\lib\mono\gac\qt-dotnet\4.5.0.0__194a23ba31c08164\qt-dotnet.dll</HintPath>
+ </Reference>
+ <Reference Include="qscintilla">
+ <HintPath>..\..\..\..\..\..\..\..\usr\lib\mono\gac\qscintilla\2.2.0.0__194a23ba31c08164\qscintilla.dll</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\VersionInfo.cs">
@@ -6,6 +6,7 @@
using System.Collections.Specialized;
using Moai.Platform.UI;
using System.IO;
+using Qyoto;
namespace Moai.Platform.Linux.UI
{
@@ -14,41 +15,29 @@ public class LinuxImageList : IImageList
private OrderedDictionary m_Images = new OrderedDictionary();
#region Conversion Methods
-
- internal static Gtk.Image ConvertToGtk(Image image)
- {
- if (image == null) return null;
- return new Gtk.Image(LinuxImageList.ConvertToPixbuf(image));
- }
-
- internal static Gtk.Image ConvertToGtk(Icon icon)
- {
- if (icon == null) return null;
- return new Gtk.Image(LinuxImageList.ConvertToPixbuf(icon));
- }
-
- internal static Gdk.Pixbuf ConvertToPixbuf(Image image)
+
+ internal static QIcon ConvertToQIcon(Icon icon)
{
- if (image == null) return null;
- using (MemoryStream stream = new MemoryStream())
- {
- image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
- stream.Position = 0;
- Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(stream);
- return pixbuf;
- }
+ // FIXME: On Linux systems we should use some sort of
+ // icon caching mechanism so we're not writing out the
+ // every single time we want to use it.
+ string fname = Path.GetTempFileName();
+ icon.ToBitmap().Save(fname, System.Drawing.Imaging.ImageFormat.Png);
+ QIcon result = new QIcon(fname);
+ File.Delete(fname);
+ return result;
}
-
- internal static Gdk.Pixbuf ConvertToPixbuf(Icon icon)
+
+ internal static QImage ConvertToQImage(Image image)
{
- if (icon == null) return null;
- using (MemoryStream stream = new MemoryStream())
- {
- icon.ToBitmap().Save(stream, System.Drawing.Imaging.ImageFormat.Png);
- stream.Position = 0;
- Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(stream);
- return pixbuf;
- }
+ // FIXME: On Linux systems we should use some sort of
+ // icon caching mechanism so we're not writing out the
+ // every single time we want to use it.
+ string fname = Path.GetTempFileName();
+ image.Save(fname, System.Drawing.Imaging.ImageFormat.Png);
+ QImage result = new QImage(fname);
+ File.Delete(fname);
+ return result;
}
#endregion
@@ -3,17 +3,41 @@
using System.Linq;
using System.Text;
using Moai.Platform;
+using log4net;
+using log4net.Config;
+using System.IO;
namespace Moai
{
public static class Central
{
private static bool m_Initialized = false;
+ private static bool m_LogInitialized = false;
public static IRootManager Manager { get; private set; }
public static IPlatform Platform { get; private set; }
+ private static readonly ILog m_Log = LogManager.GetLogger(typeof(Central));
+
+ public static void InitializeLogger()
+ {
+ if (Central.m_LogInitialized)
+ return;
+ if (File.Exists("Moai.Platform.Logging.xml"))
+ {
+ XmlConfigurator.Configure(new FileInfo("Moai.Platform.Logging.xml"));
+ m_Log.Debug("Logging system is using XML file for configuration.");
+ }
+ else
+ {
+ BasicConfigurator.Configure();
+ m_Log.Warn("Unable to locate Moai.Platform.Logging.xml. Logging system will be set to defaults.");
+ }
+ Central.m_LogInitialized = true;
+ }
- public static void Initialize(IRootManager manager, IPlatform platform)
+ public static void InitializeSystem(IRootManager manager, IPlatform platform)
{
+ if (!Central.m_LogInitialized)
+ throw new InvalidOperationException("Moai central management system does not have logging infrastructure initialized before starting main application execution.");
if (Central.m_Initialized)
throw new InvalidOperationException("Moai central management system can not be initialized twice.");
Central.m_Initialized = true;
@@ -0,0 +1,15 @@
+<log4net>
+ <!-- A1 is set to be a ConsoleAppender -->
+ <appender name="A1" type="log4net.Appender.ConsoleAppender">
+ <layout type="log4net.Layout.PatternLayout">
+ <!-- Pattern to output the caller's file name and line number -->
+ <conversionPattern value="%date [%thread] (%-5level) %logger - %message%newline" />
+ </layout>
+ </appender>
+
+ <!-- Set root logger level to DEBUG and its only appender to A1 -->
+ <root>
+ <level value="DEBUG" />
+ <appender-ref ref="A1" />
+ </root>
+</log4net>
Oops, something went wrong.

0 comments on commit 32e2f39

Please sign in to comment.