Home /Modules/operating-system/os-theme-demo.sleela

os-theme-demo.sleela

lib/operating-system/os-theme-demo.sleela · 66 line(s) · sleela

<< lib/operating-system/os-theme-demo.sleela
   SLeeLa OS Creator(TM) runnable -- desktop theming for future users and
   developers. Demonstrates the SLDesktopTheme model composed into the desktop
   layer (SLDesktopSpec) of an OS being constructed:
     1. seed a Linux desktop with its default theme,
     2. print the appearance sheet the desktop loader would emit,
     3. switch to the White Edition look (aligned with ubuntu-white) and show
        that its assets come from the `desktop-loader` warehouse component,
     4. show a headless (server) edition carries no theme.

   Run:
     ./impl/build/sleela run lib/operating-system/os-theme-demo.sleela >>
#sleela 2.5
material;

class OsThemeDemo {
  void printTheme(SLDesktopTheme t) {
    print("  theme:  " + t.name() + " (" + t.themeId() + ")");
    print("  colors: bg=" + t.bg() + " fg=" + t.fg() + " accent=" + t.accentColor());
    print("  gtk=" + t.gtk() + " icons=" + t.icons() + " cursor=" + t.cursorTheme());
    print("  wallpaper=" + t.wallpaperId() + "  assets-from=" + t.assetComponent());
  }

  void main() {
    print("================================================================");
    print("  SLeeLa OS Creator -- desktop theming");
    print("================================================================");

    < A Linux desktop, seeded with its default theme via the shape. >
    SLOSShape shape = new SLOSShape();
    shape.linux();
    SLDesktopSpec desktop = new SLDesktopSpec();
    desktop.forShape(shape);

    print("Linux desktop: " + desktop.shell() + " on " + desktop.server());
    if (desktop.hasTheme()) {
      print("default theme:");
      printTheme(desktop.theme());
    }

    < Offer the White Edition look to a future user. >
    print("");
    print("apply the White Edition look:");
    SLDesktopTheme white = new SLDesktopTheme();
    white.white();
    desktop.applyTheme(white);
    printTheme(desktop.theme());

    print("");
    print("appearance sheet (what the desktop loader emits):");
    print(desktop.theme().appearanceSheet());

    < A server edition: no desktop, no theme. >
    SLDesktopSpec server = new SLDesktopSpec();
    server.headless();
    print("server edition hasDesktop=" + server.hasDesktop() + " hasTheme=" + server.hasTheme());

    < The native subsystem now backs a 'theme' capability. >
    SLOSNativeSubsystem nat = new SLOSNativeSubsystem();
    nat.configure();
    print("");
    print("native theme backing: " + nat.headerFor("theme") + " -> " + nat.theSLeeLa("theme"));
    print("capabilities backed: " + nat.capabilityCount());
  }
}