JFLib

ui/assoc.rs#

Source: lib/ui/assoc.rs

assoc -- the app's file types and URL schemes at start-up (plat::assoc): the switches every
app gets through ui::main!

  --register            register this program for PACKAGE filetypes= / schemes= (Windows:
                        HKCU\Software\Classes; Linux: a .desktop file, the own MIME types,
                        mimeapps.list); defaults of other programs stay and are listed; with
                        browser=1 also as a web browser (Windows: Default Programs)
  --register-replace    the same, and those defaults go to this app too (the user's own pick
                        in Windows' dialog always stays)
  --unregister          remove exactly what the registration added, put back what it replaced
They print what they did (a Windows GUI program: on the console it was started from) and end
the program: exit code 0 done, 1 failed, 2 not possible here or nothing declared.

  desk_boot(package) -> Option<exit code>   (main!) keep the built-in PACKAGE text
                        (plat::assoc::package_set), run a switch; headless runs (--shot,
                        --script, the agent protocols) leave the system's list of recent files
                        alone (plat::recent::recent_os(false); jfgui_RECENT still redirects it).
                        Without a switch, Windows: the app id as the explicit AppUserModelID
                        once the setup installed the program or --register registered it
                        (plat::assoc::app_id_boot), before the first window
  assoc_switch(pkg, switch) -> Option<(exit code, text)>   one switch for pkg (None: no switch)

(E13) A web browser (PACKAGE browser=1):
  ui.default_browser() -> BrowserStatus   plat::default_browser_status; headless runs: what the
                        script said (`system browser default|other|unknown`, at first other;
                        the command then sends UIC_ACTIVE 0 and 1 as a real change would)
  ui.default_browser_request() -> Result<(), AssocError>   plat::default_browser_request (the
                        system's page or question); headless runs open nothing: they print
                        "ui_default_browser_request" and answer Ok

impl Ui

  • fn default_browser(&self) -> BrowserStatus (PACKAGE browser=1) is this app the system's web browser (plat::default_browser_status: Default, NotDefault, Unknown). Keep the answer and ask again when the app is active again (UIC_ACTIVE 1): the user may have chosen in the system's settings. Headless runs answer what the script said (system browser default|other|unknown, at first NotDefault; the command is followed by UIC_ACTIVE 0 and 1, as a real change would be)

  • fn default_browser_request(&mut self) -> Result<(), AssocError> (PACKAGE browser=1) let the user make this app the web browser, from the user's click (plat::default_browser_request: Windows' Settings at the app's page of the default apps, Linux sets it, macOS asks). Headless runs open nothing: they print "ui_default_browser_request" and answer Ok

  • fn desk_boot(package: Option<&str>) -> Option<i32> (main!) PACKAGE, then the switches -> Some(exit code) when one of them ran

  • fn assoc_switch(pkg: &Package, switch: &str) -> Option<(i32, String)> run --register / --register-replace / --unregister for pkg -> (exit code, what it says)

Source: docs/API.md in the JFLib repository.