Skip to content

Commit f262cb5

Browse files
Rename MauiGtkApplication to MauiApplication (#18)
Rename MauiGtkApplication to MauiApplication
1 parent 1d6a999 commit f262cb5

File tree

8 files changed

+23
-17
lines changed

8 files changed

+23
-17
lines changed

src/Compatibility/Core/src/Gtk/GtkPlatformServices.cs_

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace Microsoft.Maui.Controls.Compatibility
1818

1919
public void BeginInvokeOnMainThread(Action action)
2020
{
21-
MauiGtkApplication.Invoke(action);
21+
MauiApplication.Invoke(action);
2222
}
2323
public Assembly[] GetAssemblies()
2424
{
@@ -96,7 +96,7 @@ namespace Microsoft.Maui.Controls.Compatibility
9696

9797
public void QuitApplication()
9898
{
99-
((GLib.Application)MauiGtkApplication.CurrentGtkApplication).Quit();
99+
((GLib.Application)MauiApplication.CurrentGtkApplication).Quit();
100100
}
101101

102102
public SizeRequest GetNativeSize(VisualElement view, double widthConstraint, double heightConstraint)

src/Controls/samples/Controls.Sample.Gtk/SimpleSampleApp/SimpleSampleGtkApplication.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Maui.SimpleSampleApp
88
{
99

10-
public class SimpleSampleGtkApplication : MauiGtkApplication
10+
public class SimpleSampleGtkApplication : MauiApplication
1111
{
1212

1313
protected override MauiApp CreateMauiApp()

src/Controls/samples/Controls.Sample/Platforms/Gtk/Main.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Maui.Controls.Sample.Platform
66
{
7-
class Program : MauiGtkApplication
7+
class Program : MauiApplication
88
{
99
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
1010

src/Core/src/LifecycleEvents/Gtk/GtkLifecycle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static class GtkLifecycle
2121

2222
public delegate void OnStartup(Gtk.Application application, EventArgs args);
2323

24-
public delegate void OnLaunching(MauiGtkApplication application, EventArgs args);
24+
public delegate void OnLaunching(MauiApplication application, EventArgs args);
2525

2626
public delegate void OnLaunched(Gtk.Application application, EventArgs args);
2727

src/Core/src/Platform/Gtk/MauiGtkApplication.cs renamed to src/Core/src/Platform/Gtk/MauiApplication.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@
77

88
namespace Microsoft.Maui
99
{
10-
public abstract class MauiGtkApplication : IPlatformApplication
10+
public abstract class MauiApplication : IPlatformApplication
1111
{
12+
protected MauiApplication()
13+
{
14+
Current = this;
15+
IPlatformApplication.Current = this;
16+
}
17+
1218
protected abstract MauiApp CreateMauiApp();
1319

1420
// https://docs.gtk.org/gio/type_func.Application.id_is_valid.html
1521
// TODO: find a better algo for id
16-
public virtual string ApplicationId => $"{typeof(MauiGtkApplication).Namespace}.{nameof(MauiGtkApplication)}.{Name}".PadRight(255, ' ').Substring(0, 255).Trim();
22+
public virtual string ApplicationId => $"{typeof(MauiApplication).Namespace}.{nameof(MauiApplication)}.{Name}".PadRight(255, ' ').Substring(0, 255).Trim();
1723

1824
string? _name;
1925

@@ -27,7 +33,7 @@ public string? Name
2733
// https://docs.gtk.org/gtk3/class.Application.html
2834
public static Gtk.Application CurrentGtkApplication { get; internal set; } = null!;
2935

30-
public static MauiGtkApplication Current { get; internal set; } = null!;
36+
public static MauiApplication Current { get; internal set; } = null!;
3137

3238
public MauiGtkMainWindow MainWindow { get; protected set; } = null!;
3339

src/Core/src/Platform/Gtk/MauiGtkMainWindow.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ public MauiGtkMainWindow() : base(WindowType.Toplevel)
2323

2424
void OnDeleteEvent(object o, DeleteEventArgs args)
2525
{
26-
MauiGtkApplication.Current.Services?.InvokeLifecycleEvents<GtkLifecycle.OnDelete>(del => del(this, args));
26+
MauiApplication.Current.Services?.InvokeLifecycleEvents<GtkLifecycle.OnDelete>(del => del(this, args));
2727

28-
if (MauiGtkApplication.Current.MainWindow == o)
28+
if (MauiApplication.Current.MainWindow == o)
2929
{
3030

31-
((Application)MauiGtkApplication.CurrentGtkApplication).Quit();
31+
((Application)MauiApplication.CurrentGtkApplication).Quit();
3232

3333
args.Event.SendEvent = true;
3434
}
@@ -37,22 +37,22 @@ void OnDeleteEvent(object o, DeleteEventArgs args)
3737
//GtkWidget::visibility-notify-event has been deprecated since version 3.12
3838
// void OnVisibilityNotifyEvent(object o, VisibilityNotifyEventArgs args)
3939
// {
40-
// MauiGtkApplication.Current.Services?.InvokeLifecycleEvents<GtkLifecycle.OnVisibilityChanged>(del => del(this, args));
40+
// MauiApplication.Current.Services?.InvokeLifecycleEvents<GtkLifecycle.OnVisibilityChanged>(del => del(this, args));
4141
// }
4242

4343
void OnHidden(object? sender, EventArgs args)
4444
{
45-
MauiGtkApplication.Current.Services?.InvokeLifecycleEvents<GtkLifecycle.OnHidden>(del => del(this, args));
45+
MauiApplication.Current.Services?.InvokeLifecycleEvents<GtkLifecycle.OnHidden>(del => del(this, args));
4646
}
4747

4848
void OnShown(object? sender, EventArgs args)
4949
{
50-
MauiGtkApplication.Current.Services?.InvokeLifecycleEvents<GtkLifecycle.OnShown>(del => del(this, args));
50+
MauiApplication.Current.Services?.InvokeLifecycleEvents<GtkLifecycle.OnShown>(del => del(this, args));
5151
}
5252

5353
void OnWindowStateEvent(object o, WindowStateEventArgs args)
5454
{
55-
MauiGtkApplication.Current.Services?.InvokeLifecycleEvents<GtkLifecycle.OnStateChanged>(del => del(this, args));
55+
MauiApplication.Current.Services?.InvokeLifecycleEvents<GtkLifecycle.OnStateChanged>(del => del(this, args));
5656
}
5757

5858
}

src/Core/src/Platform/Gtk/MauiWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Microsoft.Maui.Platform
77
{
88

9-
[Obsolete("use MauiGtkApplication")]
9+
[Obsolete("use MauiApplication")]
1010
public class MauiWindow : Window
1111
{
1212

src/Core/src/Platform/Gtk/WindowExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static void UpdateTitle(this Gtk.Window platformWindow, IWindow window) =
1212

1313
public static IWindow GetWindow(this Gtk.Window platformWindow)
1414
{
15-
foreach (var window in MauiGtkApplication.Current.Application.Windows)
15+
foreach (var window in MauiApplication.Current.Application.Windows)
1616
{
1717
if (window?.Handler?.PlatformView is Gtk.Window win && win == platformWindow)
1818
return window;

0 commit comments

Comments
 (0)