summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bindings/mono/efl_mono/efl_all.cs63
-rw-r--r--src/bindings/mono/efl_mono/efl_csharp_application.cs93
2 files changed, 107 insertions, 49 deletions
diff --git a/src/bindings/mono/efl_mono/efl_all.cs b/src/bindings/mono/efl_mono/efl_all.cs
index 66c7de2..c49ec4d 100644
--- a/src/bindings/mono/efl_mono/efl_all.cs
+++ b/src/bindings/mono/efl_mono/efl_all.cs
@@ -59,7 +59,7 @@ static class UnsafeNativeMethods
59/// </summary> 59/// </summary>
60public static class All 60public static class All
61{ 61{
62 private static bool InitializedUi = false; 62 private static Efl.Csharp.Components initComponents = Efl.Csharp.Components.Basic;
63 63
64 /// <summary> 64 /// <summary>
65 /// If the main loop was initialized. 65 /// If the main loop was initialized.
@@ -79,17 +79,28 @@ public static class All
79 /// <param name="components">The <see cref="Efl.Csharp.Components" /> that initialize the Efl.</param> 79 /// <param name="components">The <see cref="Efl.Csharp.Components" /> that initialize the Efl.</param>
80 public static void Init(Efl.Csharp.Components components = Efl.Csharp.Components.Basic) 80 public static void Init(Efl.Csharp.Components components = Efl.Csharp.Components.Basic)
81 { 81 {
82 Eina.Config.Init(); 82 if (components == Efl.Csharp.Components.None)
83 Efl.Eo.Config.Init(); 83 {
84 ecore_init(); 84 return;
85 ecore_init_ex(0, IntPtr.Zero); 85 }
86 evas_init(); 86
87 eldbus.Config.Init(); 87 initComponents = components;
88 88
89 if (components == Efl.Csharp.Components.Ui) 89 if ((initComponents & Efl.Csharp.Components.Basic)
90 == Efl.Csharp.Components.Basic)
91 {
92 Eina.Config.Init();
93 Efl.Eo.Config.Init();
94 ecore_init();
95 ecore_init_ex(0, IntPtr.Zero);
96 evas_init();
97 eldbus.Config.Init();
98 }
99
100 if ((initComponents & Efl.Csharp.Components.Ui)
101 == Efl.Csharp.Components.Ui)
90 { 102 {
91 Efl.Ui.Config.Init(); 103 Efl.Ui.Config.Init();
92 InitializedUi = true;
93 } 104 }
94 Monitor.Enter(InitLock); 105 Monitor.Enter(InitLock);
95 MainLoopInitialized = true; 106 MainLoopInitialized = true;
@@ -114,22 +125,32 @@ public static class All
114 MainLoopInitialized = false; 125 MainLoopInitialized = false;
115 Monitor.Exit(InitLock); 126 Monitor.Exit(InitLock);
116 127
117 if (InitializedUi) 128 if (initComponents == Efl.Csharp.Components.None)
129 {
130 return;
131 }
132
133 if ((initComponents & Efl.Csharp.Components.Ui)
134 == Efl.Csharp.Components.Ui)
118 { 135 {
119 Eina.Log.Debug("Shutting down Elementary"); 136 Eina.Log.Debug("Shutting down Elementary");
120 Efl.Ui.Config.Shutdown(); 137 Efl.Ui.Config.Shutdown();
121 } 138 }
122 139
123 Eina.Log.Debug("Shutting down Eldbus"); 140 if ((initComponents & Efl.Csharp.Components.Basic)
124 eldbus.Config.Shutdown(); 141 == Efl.Csharp.Components.Basic)
125 Eina.Log.Debug("Shutting down Evas"); 142 {
126 evas_shutdown(); 143 Eina.Log.Debug("Shutting down Eldbus");
127 Eina.Log.Debug("Shutting down Ecore"); 144 eldbus.Config.Shutdown();
128 ecore_shutdown(); 145 Eina.Log.Debug("Shutting down Evas");
129 Eina.Log.Debug("Shutting down Eo"); 146 evas_shutdown();
130 Efl.Eo.Config.Shutdown(); 147 Eina.Log.Debug("Shutting down Ecore");
131 Eina.Log.Debug("Shutting down Eina"); 148 ecore_shutdown();
132 Eina.Config.Shutdown(); 149 Eina.Log.Debug("Shutting down Eo");
150 Efl.Eo.Config.Shutdown();
151 Eina.Log.Debug("Shutting down Eina");
152 Eina.Config.Shutdown();
153 }
133 } 154 }
134} 155}
135 156
diff --git a/src/bindings/mono/efl_mono/efl_csharp_application.cs b/src/bindings/mono/efl_mono/efl_csharp_application.cs
index 4a93633..63d9aac 100644
--- a/src/bindings/mono/efl_mono/efl_csharp_application.cs
+++ b/src/bindings/mono/efl_mono/efl_csharp_application.cs
@@ -16,6 +16,9 @@
16using System; 16using System;
17using System.Runtime.InteropServices; 17using System.Runtime.InteropServices;
18using System.Threading; 18using System.Threading;
19using System.Diagnostics.CodeAnalysis;
20using System.Collections.Generic;
21
19using static Efl.UnsafeNativeMethods; 22using static Efl.UnsafeNativeMethods;
20 23
21namespace Efl.Csharp 24namespace Efl.Csharp
@@ -24,17 +27,32 @@ namespace Efl.Csharp
24/// <summary>The components to be initialized. 27/// <summary>The components to be initialized.
25/// <para>Since EFL 1.23.</para> 28/// <para>Since EFL 1.23.</para>
26/// </summary> 29/// </summary>
27public enum Components 30[Flags]
31public enum Components : Int32
28{ 32{
33 // Base flags.
34 /// <summary>
35 /// Initialize nothing.
36 /// <para>Since EFL 1.24.</para>
37 /// </summary>
38 None = 0x0,
29 ///<summary>Basic components: Eina, Eo, Ecore, Evas and DBus. 39 ///<summary>Basic components: Eina, Eo, Ecore, Evas and DBus.
30 /// <para>Since EFL 1.23.</para> 40 /// <para>Since EFL 1.24.</para>
31 /// </summary> 41 /// </summary>
32 Basic, 42 Basic = 0x1,
33 ///<summary>The same components of <see cref="Efl.Csharp.Components.Basic"/> 43 /// <summary>
34 /// and the Elementary widget toolkit. 44 /// Elementary Widget toolkit: Elm.
35 /// <para>Since EFL 1.23.</para> 45 /// <para>it's depend of <see cref="Efl.Csharp.Components.Basic" />.</para>
46 /// <para>Since EFL 1.24</para>
36 /// </summary> 47 /// </summary>
37 Ui, 48 Ui = Basic | 0x2,
49
50 // Combined flags.
51 /// <summary>
52 /// Enable all components, equals to <see cref="Efl.Csharp.Components.Ui" />.
53 /// <para>Since EFL 1.24.</para>
54 /// </summary>
55 All = int.MaxValue,
38} 56}
39 57
40/// <summary> 58/// <summary>
@@ -60,23 +78,36 @@ public enum Components
60public abstract class Application 78public abstract class Application
61{ 79{
62 //the initializied components 80 //the initializied components
63 private static Components initComponent; 81 private static Components initComponents = Components.All;
82
64 //what follows are 3 private functions to boot up the internals of efl 83 //what follows are 3 private functions to boot up the internals of efl
65 private static void Init(Efl.Csharp.Components component) 84 private static void Init(Efl.Csharp.Components components = Components.All)
66 { 85 {
67 Eina.Config.Init(); 86 if (components == Components.None)
68 Efl.Eo.Config.Init();
69 ecore_init();
70 ecore_init_ex(0, IntPtr.Zero);
71 evas_init();
72 eldbus.Config.Init();
73
74 if (component == Components.Ui)
75 { 87 {
88 return;
89 }
90
91 initComponents = components;
92
93 if ((initComponents & Components.Basic) == Components.Basic)
94 {
95 Eina.Config.Init();
96 Efl.Eo.Config.Init();
97 ecore_init();
98 ecore_init_ex(0, IntPtr.Zero);
99 evas_init();
100 eldbus.Config.Init();
101 }
102
103 if ((initComponents & Components.Ui) == Components.Ui)
104 {
105#if WIN32
76 // TODO Support elm command line arguments 106 // TODO Support elm command line arguments
77#if WIN32 // Not a native define, we define it in our build system 107 // Not a native define, we define it in our build system
78 // Ecore_Win32 uses OleInitialize, which requires single thread apartments 108 // Ecore_Win32 uses OleInitialize, which requires single thread apartments
79 if (System.Threading.Thread.CurrentThread.GetApartmentState() != ApartmentState.STA) 109 if (System.Threading.Thread.CurrentThread.GetApartmentState()
110 != ApartmentState.STA)
80 { 111 {
81 throw new InvalidOperationException("UI Applications require STAThreadAttribute in Main()"); 112 throw new InvalidOperationException("UI Applications require STAThreadAttribute in Main()");
82 } 113 }
@@ -85,8 +116,6 @@ public abstract class Application
85 116
86 Efl.Ui.Win.ExitOnAllWindowsClosed = new Eina.Value(0); 117 Efl.Ui.Win.ExitOnAllWindowsClosed = new Eina.Value(0);
87 } 118 }
88
89 initComponent = component;
90 } 119 }
91 120
92 private static void Shutdown() 121 private static void Shutdown()
@@ -95,16 +124,24 @@ public abstract class Application
95 System.GC.Collect(); 124 System.GC.Collect();
96 System.GC.WaitForPendingFinalizers(); 125 System.GC.WaitForPendingFinalizers();
97 126
98 if (initComponent == Components.Ui) 127 if (initComponents == Components.None)
128 {
129 return;
130 }
131
132 if ((initComponents & Components.Ui) == Components.Ui)
99 { 133 {
100 elm_shutdown(); 134 elm_shutdown();
101 } 135 }
102 136
103 eldbus.Config.Shutdown(); 137 if ((initComponents & Components.Basic) == Components.Basic)
104 evas_shutdown(); 138 {
105 ecore_shutdown(); 139 eldbus.Config.Shutdown();
106 Efl.Eo.Config.Shutdown(); 140 evas_shutdown();
107 Eina.Config.Shutdown(); 141 ecore_shutdown();
142 Efl.Eo.Config.Shutdown();
143 Eina.Config.Shutdown();
144 }
108 } 145 }
109 146
110 /// <summary> 147 /// <summary>
@@ -157,7 +194,7 @@ public abstract class Application
157 /// <para>Since EFL 1.23.</para> 194 /// <para>Since EFL 1.23.</para>
158 /// </summary> 195 /// </summary>
159 /// <param name="components">The <see cref="Efl.Csharp.Components" /> to run the application.</param> 196 /// <param name="components">The <see cref="Efl.Csharp.Components" /> to run the application.</param>
160 public void Launch(Efl.Csharp.Components components = Components.Ui) 197 public void Launch(Efl.Csharp.Components components = Components.All)
161 { 198 {
162 Init(components); 199 Init(components);
163 Efl.App app = Efl.App.AppMain; 200 Efl.App app = Efl.App.AppMain;