Skip to content

Commit

Permalink
add - doc - You can now register homepage actions!
Browse files Browse the repository at this point in the history
---

Mods and addons can now expand The Nitrocid Homepage so that it provides additional actions, such as calendar.

---

Type: add
Breaking: False
Doc Required: True
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Sep 7, 2024
1 parent 75538c4 commit 9f9de73
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 71 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
changes!
-->
<NitrocidModAPIVersionMajor>3.0.26</NitrocidModAPIVersionMajor>
<NitrocidModAPIVersionChangeset>50</NitrocidModAPIVersionChangeset>
<NitrocidModAPIVersionChangeset>51</NitrocidModAPIVersionChangeset>

<!-- The above two properties are to be installed to the file version -->
<NitrocidModAPIVersion>$(NitrocidModAPIVersionMajor).$(NitrocidModAPIVersionChangeset)</NitrocidModAPIVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
using Nitrocid.Extras.Calendar.Calendar;
using Nitrocid.Kernel.Time.Calendars;
using EventInfo = Nitrocid.Extras.Calendar.Calendar.Events.EventInfo;
using Nitrocid.Shell.Homepage;

namespace Nitrocid.Extras.Calendar
{
Expand Down Expand Up @@ -247,6 +248,9 @@ void IAddon.FinalizeAddon()
EventManager.LoadEvents();
ReminderManager.LoadReminders();
DebugWriter.WriteDebug(DebugLevel.I, "Loaded events & reminders.");

// Add the calendar option to the homepage
HomepageTools.RegisterBuiltinAction(/* Localizable */ "Calendar", CalendarTui.OpenInteractive);
}

void IAddon.StartAddon()
Expand All @@ -262,6 +266,7 @@ void IAddon.StopAddon()
EventManager.CalendarEvents.Clear();
CommandManager.UnregisterAddonCommands(ShellType.Shell, [.. addonCommands.Select((ci) => ci.Command)]);
ConfigTools.UnregisterBaseSetting(nameof(CalendarConfig));
HomepageTools.UnregisterBuiltinAction("Calendar");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ internal static class KernelExceptionMessages
{ KernelExceptionType.Bootloader, Translate.DoTranslation("There was an error when trying to process a bootloader operation.") },
{ KernelExceptionType.Alarm, Translate.DoTranslation("There was an error when trying to process an alarm system operation.") },
{ KernelExceptionType.Widget, Translate.DoTranslation("There was an error when trying to process a widget system operation. If you're sure that this widget is registered properly, please make sure that you've written the widget class name properly.") },
{ KernelExceptionType.Homepage, Translate.DoTranslation("The homepage tools has encountered an error when trying to process your request. Please make sure that you've entered all the necessary data correctly.") },
};

internal static string GetFinalExceptionMessage(KernelExceptionType exceptionType, string message, Exception? e, params object[] vars)
Expand Down
4 changes: 4 additions & 0 deletions public/Nitrocid/Kernel/Exceptions/KernelExceptionType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,5 +496,9 @@ public enum KernelExceptionType
/// There was an error when trying to process a widget system operation. If you're sure that this widget is registered properly, please make sure that you've written the widget class name properly.
/// </summary>
Widget,
/// <summary>
/// The homepage tools has encountered an error when trying to process your request. Please make sure that you've entered all the necessary data correctly.
/// </summary>
Homepage,
}
}
Loading

0 comments on commit 9f9de73

Please sign in to comment.