Home /Modules/operating-system/SLDesktopTheme.sleela

SLDesktopTheme.sleela

lib/operating-system/SLDesktopTheme.sleela · 171 line(s) · sleela

<< lib/operating-system/SLDesktopTheme.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLDesktopTheme — the appearance a constructed OS's
     desktop adopts: a named set of role colors (background, foreground, accent)
     plus the desktop-asset identifiers an OS rollout applies — the GTK/widget
     theme, icon set, cursor theme, and wallpaper. It is the first-class home
     for the kind of look the `ubuntu-white` edition carries (gtk.css, icons,
     greeting), expressed as a model so the OS Creator can emit a desktop
     appearance for future users and developers.
   
   SLDesktopTheme composes INTO SLDesktopSpec (the desktop layer of SLOSModel):
     a desktop has a theme, seeded per shape alongside the display server,
     session shell, and toolkit. Because the desktop is optional, a headless
     (server) edition carries no theme. The role-color vocabulary is the SAME
     one the editor palettes and SleelaUI use (background/foreground/accent/...),
     so appearance is consistent across the editor, the toolkit, and the OS
     desktop rather than a third parallel scheme. The C backing is
     os/sleela_os_theme.{h,c} (the same source of truth in native code).
   
   The theme NAMES its assets; the actual gtk.css / icon / cursor / wallpaper
     bytes are fetched from the `desktop-loader` component of the OS-grade
     warehouse (SLOSSensitivitySource / OS.Sensitivity.III), not carried here.
   
   Family: operating-system. Pure design model; no native bridge calls. >>
#sleela 2.5
material;
class SLDesktopTheme {
  < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
  << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
     or catalog can read and (where appropriate) override this record.
     Values are faithful to the subject's real origin where publicly known. >>
  String metaVersion = "1.0.0";
  int metaId = 10935;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-10-23";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-10-23";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 7;
  < metaNationalSchedule: a real, citable instrument or "none" >
  String metaNationalSchedule = "none";

  String getMetaVersion() { return metaVersion; }
  void setMetaVersion(String v) { metaVersion = v; }
  int getMetaId() { return metaId; }
  void setMetaId(int v) { metaId = v; }
  String getAuthor() { return metaAuthor; }
  void setAuthor(String v) { metaAuthor = v; }
  String getDate() { return metaDate; }
  void setDate(String v) { metaDate = v; }
  String getCopyright() { return metaCopyright; }
  void setCopyright(String v) { metaCopyright = v; }
  String getTrademark() { return metaTrademark; }
  void setTrademark(String v) { metaTrademark = v; }
  String getCorporation() { return metaCorporation; }
  void setCorporation(String v) { metaCorporation = v; }
  String getOrigin() { return metaOrigin; }
  void setOrigin(String v) { metaOrigin = v; }
  String getBirthDate() { return metaBirthDate; }
  void setBirthDate(String v) { metaBirthDate = v; }
  int getScienceRating() { return metaScienceRating; }
  void setScienceRating(int v) { metaScienceRating = v; }
  String getNationalSchedule() { return metaNationalSchedule; }
  void setNationalSchedule(String v) { metaNationalSchedule = v; }

  < theme identity >
  String id;
  String label;
  < role colors (shared vocabulary with the editor palettes + SleelaUI accent) >
  String background;
  String foreground;
  String accent;
  < desktop asset identifiers (bytes come from the desktop-loader warehouse) >
  String gtkTheme;
  String iconSet;
  String cursor;
  String wallpaper;
  int configured;

  < Full configuration. >
  void configure(String themeId, String themeLabel,
                 String bg, String fg, String acc,
                 String gtk, String icons, String cur, String wall) {
    id = themeId; label = themeLabel;
    background = bg; foreground = fg; accent = acc;
    gtkTheme = gtk; iconSet = icons; cursor = cur; wallpaper = wall;
    configured = 1;
  }

  < ---- Presets (mirror os/sleela_os_theme.c) --------------------------- >
  < The SleelaUI-aligned matte-dark default. >
  void slickBlack() {
    configure("slick-black", "Slick Black",
              "#101014", "#F4F7FA", "#7FB3FF",
              "SleelaUI-Dark", "Sleela", "Adwaita", "slick-black-default");
  }
  < The White Edition look, aligned with ubuntu-white (Ubuntu-orange accent). >
  void white() {
    configure("white", "White Edition",
              "#FAFAFA", "#1C1F24", "#E95420",
              "Adwaita", "Yaru", "Yaru", "ubuntu-white-default");
  }
  < Per-shape native defaults. >
  void linuxDefault() {
    configure("linux-default", "Linux Default",
              "#1E1E1E", "#F0F0F0", "#3584E4",
              "Adwaita-dark", "Adwaita", "Adwaita", "linux-default");
  }
  void windowsDefault() {
    configure("windows-default", "Windows Default",
              "#202020", "#FFFFFF", "#0078D4",
              "Fluent", "Fluent", "aero", "windows-default");
  }
  void macosDefault() {
    configure("macos-default", "macOS Default",
              "#1E1E1E", "#F5F5F7", "#0A84FF",
              "Aqua", "SF Symbols", "macOS", "macos-default");
  }

  < Seed the native-default theme for a shape (mirrors the other forShape seeds). >
  void forShape(SLOSShape shape) {
    if (shape.isWindows()) { windowsDefault(); return; }
    if (shape.isMac())     { macosDefault();   return; }
    linuxDefault();
  }

  < Choose a theme by id; unknown ids fall back to the Linux default. >
  void select(String themeId) {
    if (themeId == "slick-black")     { slickBlack(); return; }
    if (themeId == "white")           { white(); return; }
    if (themeId == "windows-default") { windowsDefault(); return; }
    if (themeId == "macos-default")   { macosDefault(); return; }
    linuxDefault();
  }

  < ---- Accessors ------------------------------------------------------- >
  String themeId()    { return id; }
  String name()       { return label; }
  String bg()         { return background; }
  String fg()         { return foreground; }
  String accentColor(){ return accent; }
  String gtk()        { return gtkTheme; }
  String icons()      { return iconSet; }
  String cursorTheme(){ return cursor; }
  String wallpaperId(){ return wallpaper; }

  << The warehouse component whose bytes supply this theme's assets. The OS
     Creator fetches gtk.css / icons / cursors / wallpaper from here. >>
  String assetComponent() { return "desktop-loader"; }

  << A newline-separated appearance sheet the desktop loader emitter can write
     (e.g. into session.conf / appearance.conf). >>
  String appearanceSheet() {
    String s = "# desktop appearance\n";
    s = s + "theme: " + id + " (" + label + ")\n";
    s = s + "background: " + background + "\n";
    s = s + "foreground: " + foreground + "\n";
    s = s + "accent: " + accent + "\n";
    s = s + "gtk-theme: " + gtkTheme + "\n";
    s = s + "icon-set: " + iconSet + "\n";
    s = s + "cursor: " + cursor + "\n";
    s = s + "wallpaper: " + wallpaper + "\n";
    s = s + "assets-from: " + assetComponent() + "\n";
    return s;
  }
}