├── .prettierignore ├── .eslintignore ├── src ├── style-dark.css ├── init.js ├── main.js ├── icons │ ├── zoom-out-symbolic.svg │ ├── zoom-in-symbolic.svg │ ├── edit-find-symbolic.svg │ ├── tab-new-symbolic.svg │ ├── sidebar-show-symbolic.svg │ ├── view-grid-symbolic.svg │ └── loupe-large-symbolic.svg ├── WebView.blp ├── biblioteca ├── util.js ├── sidebar │ ├── ZoomButtons.blp │ ├── BrowseView.blp │ ├── SearchView.blp │ ├── ZoomButtons.js │ ├── DocumentationPage.js │ ├── Sidebar.blp │ ├── fzy.js │ ├── Sidebar.js │ ├── SearchView.js │ └── BrowseView.js ├── style.css ├── actions.js ├── application.js ├── bin.js ├── about.js ├── meson.build ├── Shortcuts.js ├── FindOverlay.blp ├── FindOverlay.js ├── Shortcuts.blp ├── window.blp ├── WebView.js └── window.js ├── data ├── screenshot.png ├── app.service ├── icons │ ├── app.drey.Biblioteca.png │ └── hicolor │ │ ├── symbolic │ │ └── apps │ │ │ └── app.drey.Biblioteca-symbolic.svg │ │ └── scalable │ │ └── apps │ │ ├── app.drey.Biblioteca.svg │ │ └── app.drey.Biblioteca.Devel.svg ├── app.desktop ├── app.gschema.xml ├── meson.build └── app.metainfo.xml.in ├── .gitmodules ├── .husky └── pre-commit ├── meson_options.txt ├── .gitignore ├── .editorconfig ├── .vscode ├── extensions.json └── settings.json ├── package.json ├── meson.build ├── README.md ├── Biblioteca.doap ├── .eslintrc.yaml ├── CONTRIBUTING.md ├── Makefile └── COPYING /.prettierignore: -------------------------------------------------------------------------------- 1 | troll 2 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | troll 2 | flatpak 3 | -------------------------------------------------------------------------------- /src/style-dark.css: -------------------------------------------------------------------------------- 1 | #top-toolbars { 2 | background-color: #121212; 3 | } 4 | -------------------------------------------------------------------------------- /data/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/workbenchdev/Biblioteca/HEAD/data/screenshot.png -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "troll"] 2 | path = troll 3 | url = https://github.com/sonnyp/troll.git 4 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npx lint-staged 5 | -------------------------------------------------------------------------------- /data/app.service: -------------------------------------------------------------------------------- 1 | [D-BUS Service] 2 | Name=@app_id@ 3 | Exec=@bindir@/biblioteca --gapplication-service 4 | -------------------------------------------------------------------------------- /data/icons/app.drey.Biblioteca.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/workbenchdev/Biblioteca/HEAD/data/icons/app.drey.Biblioteca.png -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option( 2 | 'profile', 3 | type: 'combo', 4 | choices: [ 5 | 'default', 6 | 'development' 7 | ], 8 | value: 'default' 9 | ) 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .flatpak 2 | .flatpak-builder 3 | build 4 | builddir 5 | /flatpak 6 | node_modules 7 | repo 8 | install 9 | .eslintcache 10 | *~ 11 | *.compiled 12 | *.flatpak 13 | -------------------------------------------------------------------------------- /src/init.js: -------------------------------------------------------------------------------- 1 | import "gi://Gtk?version=4.0"; 2 | import "gi://Adw?version=1"; 3 | import "gi://WebKit?version=6.0"; 4 | 5 | import Gio from "gi://Gio"; 6 | import Gtk from "gi://Gtk"; 7 | 8 | Gio._promisify(Gtk.UriLauncher.prototype, "launch", "launch_finish"); 9 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import "./init.js"; 2 | import application from "./application.js"; 3 | 4 | pkg.initGettext(); 5 | 6 | import "./style.css"; 7 | import "./style-dark.css"; 8 | 9 | export function main(argv) { 10 | return application.runAsync(argv); 11 | } 12 | -------------------------------------------------------------------------------- /src/icons/zoom-out-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/WebView.blp: -------------------------------------------------------------------------------- 1 | using Gtk 4.0; 2 | using WebKit 6.0; 3 | 4 | template $WebView : WebKit.WebView { 5 | vexpand: true; 6 | settings: WebKit.Settings { 7 | enable-back-forward-navigation-gestures: true; 8 | enable-developer-extras: false; 9 | enable-smooth-scrolling: true; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | end_of_line = lf 7 | insert_final_newline = true 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | indent_style = space 11 | indent_size = 2 12 | 13 | [{Makefile,**.mk}] 14 | indent_style = tab 15 | -------------------------------------------------------------------------------- /src/biblioteca: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # export G_MESSAGES_DEBUG=@app_id@ 4 | 5 | # We do not support translations but the AboutWindow is translated by default 6 | # force app in English see https://github.com/workbenchdev/Biblioteca/pull/40#issuecomment-1811380922 7 | LANG=en_US.UTF-8 8 | 9 | @app_id@ "$@" 10 | -------------------------------------------------------------------------------- /src/icons/zoom-in-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "bilelmoussaoui.flatpak-vscode", 4 | "editorconfig.editorconfig", 5 | "esbenp.prettier-vscode", 6 | "mrorz.language-gettext", 7 | "yzhang.markdown-all-in-one", 8 | "mesonbuild.mesonbuild", 9 | "bodil.blueprint-gtk", 10 | "dbaeumer.vscode-eslint" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/util.js: -------------------------------------------------------------------------------- 1 | import GLib from "gi://GLib"; 2 | import Gio from "gi://Gio"; 3 | 4 | export const settings = new Gio.Settings({ 5 | schema_id: pkg.name, 6 | path: "/app/drey/Biblioteca/", 7 | }); 8 | 9 | export function decode(data) { 10 | if (data instanceof GLib.Bytes) { 11 | data = data.toArray(); 12 | } 13 | return new TextDecoder().decode(data); 14 | } 15 | -------------------------------------------------------------------------------- /data/app.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | # TRANSLATORS: Don't translate 3 | Name=Biblioteca 4 | Comment=Learn and prototype with GNOME technologies 5 | Exec=biblioteca %U 6 | Terminal=false 7 | Type=Application 8 | Categories=Development;GNOME;GTK; 9 | Icon=@app_id@ 10 | # TRANSLATORS: Don't translate 11 | Keywords=GTK;libadwaita;doc;documentation;api;manual;devhelp; 12 | DBusActivatable=true 13 | StartupNotify=true 14 | -------------------------------------------------------------------------------- /src/icons/edit-find-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/tab-new-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/sidebar/ZoomButtons.blp: -------------------------------------------------------------------------------- 1 | using Gtk 4.0; 2 | 3 | template $ZoomButtons: Gtk.Box { 4 | homogeneous: true; 5 | 6 | Button button_zoom_out { 7 | halign: center; 8 | icon-name: "zoom-out-symbolic"; 9 | action-name: "win.zoom-out"; 10 | tooltip-text: _("Zoom out"); 11 | 12 | styles ["flat", "circular"] 13 | } 14 | 15 | Label label_zoom { 16 | label: "100%"; 17 | } 18 | 19 | Button button_zoom_in { 20 | halign: center; 21 | icon-name: "zoom-in-symbolic"; 22 | action-name: "win.zoom-in"; 23 | tooltip-text: _("Zoom in"); 24 | 25 | styles ["flat", "circular"] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/icons/sidebar-show-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /data/app.gschema.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 0 6 | 7 | 8 | 0 9 | 10 | 11 | 0 12 | 13 | 14 | false 15 | 16 | 17 | false 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "devDependencies": { 4 | "@babel/eslint-parser": "^7.22.11", 5 | "@babel/plugin-syntax-import-assertions": "^7.22.5", 6 | "eslint": "^8.48.0", 7 | "eslint-config-prettier": "^9.0.0", 8 | "eslint-plugin-import": "^2.28.1", 9 | "eslint-plugin-prettier": "^5.0.0", 10 | "events": "^3.3.0", 11 | "husky": "^8.0.3", 12 | "lint-staged": "^14.0.1", 13 | "prettier": "3.0.3" 14 | }, 15 | "type": "module", 16 | "scripts": { 17 | "prepare": "husky install" 18 | }, 19 | "lint-staged": { 20 | "*.{css,json,md,yaml,yml}": "prettier --write", 21 | "*.{js,cjs,mjs}": "eslint --fix" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/style.css: -------------------------------------------------------------------------------- 1 | #top-toolbars { 2 | background-color: #ffffff; 3 | } 4 | 5 | /* Enforce border radius */ 6 | .searchbar > * > * { 7 | border-radius: 12px; 8 | } 9 | 10 | .searchbar { 11 | box-shadow: 12 | 0 2px 5px 0px rgba(0, 0, 0, 0.09), 13 | 0 2px 14px 0px rgba(0, 0, 0, 0.05); 14 | } 15 | 16 | /* 17 | * From Builder's stylesheet: 18 | * https://gitlab.gnome.org/GNOME/gnome-builder/-/blob/45d4ec9b6f1aa2236c9bb7dfb846b35f9b959618/src/libide/gui/style.css#L33 19 | * Used to style the language tags for the demo entries in the Library 20 | */ 21 | button.pill.small { 22 | font-size: 0.83333em; 23 | border-radius: 99px; 24 | margin: 0; 25 | padding: 1px 12px; 26 | } 27 | -------------------------------------------------------------------------------- /src/sidebar/BrowseView.blp: -------------------------------------------------------------------------------- 1 | using Gtk 4.0; 2 | 3 | template $BrowseView: ScrolledWindow { 4 | vexpand: true; 5 | width-request: 400; 6 | 7 | ListView browse_list_view { 8 | enable-rubberband: false; 9 | factory: BuilderListItemFactory { 10 | template ListItem { 11 | focusable: true; 12 | child: TreeExpander expander { 13 | list-row: bind template.item; 14 | child: Inscription { 15 | hexpand: true; 16 | valign: center; 17 | nat-chars: 10; 18 | text-overflow: ellipsize_end; 19 | text: bind expander.item as <$DocumentationPage>.name; 20 | }; 21 | }; 22 | } 23 | }; 24 | styles ["navigation-sidebar"] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/icons/view-grid-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/actions.js: -------------------------------------------------------------------------------- 1 | import Gio from "gi://Gio"; 2 | 3 | import About from "./about.js"; 4 | import { settings } from "./util.js"; 5 | 6 | export default function Actions({ application }) { 7 | const quit = new Gio.SimpleAction({ 8 | name: "quit", 9 | parameter_type: null, 10 | }); 11 | quit.connect("activate", () => { 12 | application.quit(); 13 | }); 14 | application.add_action(quit); 15 | application.set_accels_for_action("app.quit", ["Q"]); 16 | 17 | const showAboutDialog = new Gio.SimpleAction({ 18 | name: "about", 19 | parameter_type: null, 20 | }); 21 | showAboutDialog.connect("activate", () => { 22 | About({ application }); 23 | }); 24 | application.add_action(showAboutDialog); 25 | 26 | application.add_action(settings.create_action("color-scheme")); 27 | } 28 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project('Biblioteca', 2 | version: '1.6', 3 | meson_version: '>= 0.59.0', 4 | license: 'GPL-3.0-only' 5 | ) 6 | 7 | gnome = import('gnome') 8 | 9 | if get_option('profile') == 'development' 10 | app_id = 'app.drey.Biblioteca.Devel' 11 | vcs_tag = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip() 12 | if vcs_tag == '' 13 | version_suffix = '-devel' 14 | else 15 | version_suffix = '-@0@'.format(vcs_tag) 16 | endif 17 | else 18 | app_id = 'app.drey.Biblioteca' 19 | version_suffix = '' 20 | endif 21 | 22 | prefix = get_option('prefix') 23 | bindir = join_paths(prefix, 'bin') 24 | datadir = join_paths(prefix, get_option('datadir')) 25 | pkgdatadir = join_paths(datadir, app_id) 26 | 27 | subdir('data') 28 | subdir('src') 29 | 30 | gnome.post_install( 31 | glib_compile_schemas: true, 32 | gtk_update_icon_cache: true, 33 | update_desktop_database: true 34 | ) 35 | -------------------------------------------------------------------------------- /src/sidebar/SearchView.blp: -------------------------------------------------------------------------------- 1 | using Gtk 4.0; 2 | 3 | template $SearchView : ScrolledWindow { 4 | vexpand: true; 5 | width-request: 400; 6 | 7 | ListView search_list_view { 8 | enable-rubberband: false; 9 | factory: BuilderListItemFactory { 10 | template ListItem { 11 | focusable: true; 12 | child: Box { 13 | Inscription { 14 | valign: center; 15 | hexpand: true; 16 | nat-chars: 25; 17 | text-overflow: ellipsize_end; 18 | text: bind template.item as <$DocumentationPage>.search_name; 19 | } 20 | Button { 21 | sensitive: false; 22 | valign: center; 23 | label: bind template.item as <$DocumentationPage>.tag; 24 | styles ["pill", "small", "doc-tag"] 25 | } 26 | }; 27 | } 28 | }; 29 | styles ["navigation-sidebar"] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": true, 3 | "javascript.preferences.importModuleSpecifierEnding": "js", 4 | "typescript.preferences.importModuleSpecifierEnding": "js", 5 | "files.watcherExclude": { 6 | "**/.git/objects/**": true, 7 | "**/.git/subtree-cache/**": true, 8 | "**/node_modules/*/**": true, 9 | "**/.hg/store/**": true, 10 | "**/.flatpak": true, 11 | "**/src/lib": true, 12 | ".flatpak": true, 13 | ".flatpak/**": true, 14 | "_build/**": true 15 | }, 16 | "editor.defaultFormatter": "esbenp.prettier-vscode", 17 | "[yaml]": { 18 | "editor.defaultFormatter": "esbenp.prettier-vscode" 19 | }, 20 | "[json]": { 21 | "editor.defaultFormatter": "esbenp.prettier-vscode" 22 | }, 23 | "vala.languageServerPath": "${workspaceFolder}/.flatpak/vala-language-server.sh", 24 | "mesonbuild.mesonPath": "${workspaceFolder}/.flatpak/meson.sh", 25 | "mesonbuild.configureOnOpen": false, 26 | "mesonbuild.buildFolder": "_build" 27 | } 28 | -------------------------------------------------------------------------------- /src/application.js: -------------------------------------------------------------------------------- 1 | import Adw from "gi://Adw"; 2 | 3 | import Actions from "./actions.js"; 4 | import { settings } from "./util.js"; 5 | import Window from "./window.js"; 6 | 7 | const application = new Adw.Application({ 8 | application_id: pkg.name, 9 | // Defaults to /app/drey/Biblioteca/Devel 10 | // if pkg.name is app.drey.Biblioteca.Devel 11 | resource_base_path: "/app/drey/Biblioteca", 12 | }); 13 | 14 | let window; 15 | application.connect("activate", () => { 16 | if (!window) { 17 | window = new Window({ application }); 18 | } 19 | setColorScheme(); 20 | window.open(); 21 | }); 22 | 23 | application.set_option_context_description( 24 | "", 25 | ); 26 | 27 | Actions({ application }); 28 | 29 | function setColorScheme() { 30 | const style_manager = Adw.StyleManager.get_default(); 31 | const color_scheme = settings.get_int("color-scheme"); 32 | style_manager.set_color_scheme(color_scheme); 33 | } 34 | settings.connect("changed::color-scheme", setColorScheme); 35 | 36 | export default application; 37 | -------------------------------------------------------------------------------- /src/bin.js: -------------------------------------------------------------------------------- 1 | #!@GJS@ -m 2 | 3 | import { exit, programArgs, programInvocationName } from "system"; 4 | import GLib from "gi://GLib"; 5 | import { setConsoleLogDomain } from "console"; 6 | import Xdp from "gi://Xdp"; 7 | 8 | // eslint-disable-next-line no-restricted-globals 9 | imports.package.init({ 10 | name: "@app_id@", 11 | version: "@version@", 12 | prefix: "@prefix@", 13 | libdir: "@libdir@", 14 | datadir: "@datadir@", 15 | }); 16 | setConsoleLogDomain(pkg.name); 17 | GLib.set_application_name("Biblioteca"); 18 | 19 | if (!Xdp.Portal.running_under_flatpak()) { 20 | console.error( 21 | "Flatpak required\nBiblioteca is only meant to be run sandboxed in a specific target environment.\nBypassing this will exposes users to arbitrary code breakage.", 22 | ); 23 | exit(1); 24 | } 25 | 26 | globalThis.__DEV__ = pkg.name.endsWith(".Devel"); 27 | if (__DEV__) { 28 | pkg.sourcedir = "@sourcedir@"; 29 | } 30 | 31 | const module = await import("resource:///app/drey/Biblioteca/main.js"); 32 | const exit_code = await module.main([programInvocationName, ...programArgs]); 33 | exit(exit_code); 34 | -------------------------------------------------------------------------------- /src/sidebar/ZoomButtons.js: -------------------------------------------------------------------------------- 1 | import Gtk from "gi://Gtk"; 2 | import GObject from "gi://GObject"; 3 | 4 | import Template from "./ZoomButtons.blp" with { type: "uri" }; 5 | 6 | import "../icons/zoom-in-symbolic.svg"; 7 | import "../icons/zoom-out-symbolic.svg"; 8 | 9 | class ZoomButtons extends Gtk.Box { 10 | constructor(...params) { 11 | super(params); 12 | 13 | this.bind_property_full( 14 | "zoom-level", 15 | this._label_zoom, 16 | "label", 17 | GObject.BindingFlags.SYNC_CREATE, 18 | (binding, from_value) => 19 | from_value ? [true, `${from_value * 100}%`] : [false, null], 20 | null, 21 | ); 22 | } 23 | } 24 | 25 | export default GObject.registerClass( 26 | { 27 | GTypeName: "ZoomButtons", 28 | Template, 29 | Properties: { 30 | "zoom-level": GObject.ParamSpec.double( 31 | "zoom-level", 32 | "zoom-level", 33 | "Zoom level of the active webview", 34 | GObject.ParamFlags.READWRITE, 35 | 0, 36 | Number.MAX_SAFE_INTEGER, 37 | 1, 38 | ), 39 | }, 40 | InternalChildren: ["button_zoom_out", "label_zoom", "button_zoom_in"], 41 | }, 42 | ZoomButtons, 43 | ); 44 | -------------------------------------------------------------------------------- /src/about.js: -------------------------------------------------------------------------------- 1 | import Gtk from "gi://Gtk"; 2 | import { gettext as _ } from "gettext"; 3 | import Adw from "gi://Adw"; 4 | 5 | export default function About({ application }) { 6 | const dialog = new Adw.AboutDialog({ 7 | application_name: "Biblioteca", 8 | developer_name: "Akshay Warrier", 9 | copyright: "© 2024 Akshay Warrier", 10 | license_type: Gtk.License.GPL_3_0_ONLY, 11 | version: pkg.version, 12 | website: "https://github.com/workbenchdev/Biblioteca", 13 | application_icon: pkg.name, 14 | issue_url: "https://github.com/workbenchdev/Biblioteca/issues", 15 | developers: [ 16 | "Akshay Warrier https://github.com/AkshayWarrier", 17 | "Sonny Piers https://sonny.re", 18 | ], 19 | designers: [], 20 | artists: ["Jakub Steiner https://jimmac.eu"], 21 | }); 22 | 23 | dialog.add_credit_section(_("Contributors"), [ 24 | // Add yourself as 25 | // "John Doe", 26 | // or 27 | // "John Doe ", 28 | // or 29 | // "John Doe https://john.com", 30 | "Sunniva Løvstad https://turtle.garden", 31 | "José Hunter https://github.com/halfmexican", 32 | ]); 33 | dialog.present(application.get_active_window()); 34 | 35 | return { dialog }; 36 | } 37 | -------------------------------------------------------------------------------- /src/meson.build: -------------------------------------------------------------------------------- 1 | bin_conf = configuration_data() 2 | bin_conf.set('GJS', find_program('gjs').full_path()) 3 | bin_conf.set('version', meson.project_version() + version_suffix) 4 | bin_conf.set('app_id', app_id) 5 | bin_conf.set('prefix', prefix) 6 | bin_conf.set('libdir', join_paths(get_option('prefix'), get_option('libdir'))) 7 | bin_conf.set('datadir', datadir) 8 | bin_conf.set('pkgdatadir', pkgdatadir) 9 | bin_conf.set('sourcedir', meson.project_source_root()) 10 | 11 | meson.add_install_script('../build-aux/build-index.js', pkgdatadir) 12 | 13 | configure_file( 14 | input: 'bin.js', 15 | output: app_id, 16 | configuration: bin_conf, 17 | install: true, 18 | install_dir: get_option('bindir') 19 | ) 20 | 21 | configure_file( 22 | input: 'biblioteca', 23 | output: 'biblioteca', 24 | configuration: bin_conf, 25 | install: true, 26 | install_dir: get_option('bindir') 27 | ) 28 | 29 | gjspack = find_program('../troll/gjspack/bin/gjspack') 30 | custom_target('gjspack', 31 | input: ['main.js'], 32 | output: app_id + '.src.gresource', 33 | command: [ 34 | gjspack, 35 | '--appid=' + app_id, 36 | '--prefix', '/app/drey/Biblioteca', 37 | '--project-root', meson.project_source_root(), 38 | '--resource-root', meson.project_source_root() / 'src', 39 | '--no-executable', 40 | '@INPUT0@', 41 | '@OUTDIR@', 42 | ], 43 | install: true, 44 | install_dir: pkgdatadir, 45 | build_always_stale: true, 46 | ) 47 | -------------------------------------------------------------------------------- /src/sidebar/DocumentationPage.js: -------------------------------------------------------------------------------- 1 | import GObject from "gi://GObject"; 2 | import Gio from "gi://Gio"; 3 | 4 | class DocumentationPage extends GObject.Object {} 5 | 6 | export default GObject.registerClass( 7 | { 8 | GTypeName: "DocumentationPage", 9 | Properties: { 10 | name: GObject.ParamSpec.string( 11 | "name", 12 | "name", 13 | "Display name in the sidebar", 14 | GObject.ParamFlags.READWRITE, 15 | "", 16 | ), 17 | tag: GObject.ParamSpec.string( 18 | "tag", 19 | "tag", 20 | "Tag of symbol", 21 | GObject.ParamFlags.READWRITE, 22 | "", 23 | ), 24 | search_name: GObject.ParamSpec.string( 25 | "search_name", 26 | "search_name", 27 | "Name used to search the item in sidebar", 28 | GObject.ParamFlags.READWRITE, 29 | "", 30 | ), 31 | score: GObject.ParamSpec.double( 32 | "score", 33 | "score", 34 | "Score assigned when searching an item in the sidebar", 35 | GObject.ParamFlags.READWRITE, 36 | Number.MIN_SAFE_INTEGER, 37 | Number.MAX_SAFE_INTEGER, 38 | Number.MIN_SAFE_INTEGER, 39 | ), 40 | uri: GObject.ParamSpec.string( 41 | "uri", 42 | "uri", 43 | "Uri to the documentation page", 44 | GObject.ParamFlags.READWRITE, 45 | "", 46 | ), 47 | children: GObject.ParamSpec.object( 48 | "children", 49 | "children", 50 | null, 51 | GObject.ParamFlags.READWRITE, 52 | Gio.ListStore, 53 | ), 54 | }, 55 | }, 56 | DocumentationPage, 57 | ); 58 | -------------------------------------------------------------------------------- /src/Shortcuts.js: -------------------------------------------------------------------------------- 1 | import Gtk from "gi://Gtk"; 2 | import Gio from "gi://Gio"; 3 | import resource from "./Shortcuts.blp"; 4 | 5 | export default function Shortcuts(window) { 6 | const { application } = window; 7 | 8 | const action_shortcuts = new Gio.SimpleAction({ name: "shortcuts" }); 9 | action_shortcuts.connect("activate", () => open()); 10 | application.add_action(action_shortcuts); 11 | application.set_accels_for_action("app.shortcuts", ["question"]); 12 | 13 | const accels = [ 14 | ["win.new-tab('file:///app/share/doc/gtk4/index.html')", ["T"]], 15 | ["win.close-tab", ["W"]], 16 | ["win.navigation-forward", ["Right"]], 17 | ["win.navigation-back", ["Left"]], 18 | ["win.zoom-in", ["plus", "equal"]], 19 | ["win.zoom-out", ["minus", "underscore"]], 20 | ["win.reset-zoom", ["0"]], 21 | ["win.global-search", ["K"]], 22 | ["win.focus-urlbar", ["L"]], 23 | ["win.toggle-sidebar", ["F9"]], 24 | ["win.toggle-overview", ["O"]], 25 | ["win.find", ["F"]], 26 | ["win.find-prev", ["G"]], 27 | ["win.find-next", ["G"]], 28 | ["win.close-find", ["Escape"]], 29 | ]; 30 | 31 | for (const accel of accels) { 32 | application.set_accels_for_action(accel[0], accel[1]); 33 | } 34 | 35 | let window_shortcuts; 36 | function open() { 37 | if (!window_shortcuts) { 38 | const builder = Gtk.Builder.new_from_resource(resource); 39 | window_shortcuts = builder.get_object("window_shortcuts"); 40 | window_shortcuts.set_transient_for(window); 41 | } 42 | window_shortcuts.present(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/FindOverlay.blp: -------------------------------------------------------------------------------- 1 | using Gtk 4.0; 2 | 3 | template $FindOverlay: Gtk.Overlay { 4 | [overlay] 5 | Box find_toolbar { 6 | vexpand: false; 7 | valign: start; 8 | hexpand: false; 9 | halign: end; 10 | margin-top: 12; 11 | margin-end: 24; 12 | 13 | SearchBar search_bar { 14 | styles ["searchbar"] 15 | 16 | Box { 17 | orientation: horizontal; 18 | spacing: 6; 19 | 20 | Box { 21 | valign: center; 22 | width-request: 220; 23 | css-name: "entry"; 24 | 25 | Image { 26 | icon-name: 'edit-find-symbolic'; 27 | } 28 | 29 | Text search_text { 30 | hexpand: true; 31 | vexpand: true; 32 | width-chars: 10; 33 | max-width-chars: 10; 34 | } 35 | 36 | Label label_info { 37 | label: ""; 38 | xalign: 1; 39 | opacity: 0.5; 40 | } 41 | } 42 | 43 | Box { 44 | Button button_previous { 45 | icon-name: "go-up-symbolic"; 46 | tooltip-text: _("Show Previous Result"); 47 | action-name: "win.find-prev"; 48 | } 49 | 50 | Button button_next { 51 | icon-name: "go-down-symbolic"; 52 | tooltip-text: _("Show Next Result"); 53 | action-name: "win.find-next"; 54 | } 55 | 56 | styles ["linked"] 57 | } 58 | 59 | Button close_find_button { 60 | icon-name: "window-close-symbolic"; 61 | tooltip-text: _("Close Search"); 62 | action-name: "win.close-find"; 63 | 64 | styles ["circular"] 65 | } 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /data/icons/hicolor/symbolic/apps/app.drey.Biblioteca-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Biblioteca 4 | 5 | Read documentation 6 | 7 | Download on Flathub 8 | 9 | Biblioteca lets you browse and read GNOME documentation. 10 | 11 | Among other things, Biblioteca comes with 12 | 13 | - Offline documentation 14 | - Dark mode support 15 | - Fuzzy search 16 | - Mobile / adaptive 17 | 18 | ℹ️ Biblioteca is made possible by Flatpak. Only Flathub Biblioteca is supported. 19 | 20 | ![Screenshot](./data/screenshot.png) 21 | 22 | ## History 23 | 24 | Biblioteca originally started as a built-in offline documentation viewer for [Workbench](https://github.com/workbenchdev/Workbench). It was built by Akshay Warrier as a "stretch-goal" of [his 2023 GSoC internship](https://akshaywarrier.medium.com/) under the mentorship of Andy Holmes and Sonny Piers. 25 | 26 | The offline documentation viewer has been extracted into a standalone repository/app and became Biblioteca. 27 | 28 | Akshay and Sonny keep maintaining this project. 29 | 30 | ## Code of conduct 31 | 32 | Biblioteca follows the [GNOME Code of Conduct](https://conduct.gnome.org/). 33 | 34 | - **Be friendly.** Use welcoming and inclusive language. 35 | - **Be empathetic.** Be respectful of differing viewpoints and experiences. 36 | - **Be respectful.** When we disagree, we do so in a polite and constructive manner. 37 | - **Be considerate.** Remember that decisions are often a difficult choice between competing priorities. 38 | - **Be patient and generous.** If someone asks for help it is because they need it. 39 | - **Try to be concise.** Read the discussion before commenting. 40 | 41 | ## License 42 | 43 | License 44 | GPLv3. Please see the [COPYING](./COPYING) file. 45 | -------------------------------------------------------------------------------- /data/meson.build: -------------------------------------------------------------------------------- 1 | desktop_file = configure_file( 2 | input: 'app.desktop', 3 | output: '@0@.desktop'.format(app_id), 4 | configuration: { 'app_id': app_id }, 5 | install_dir: join_paths(get_option('datadir'), 'applications') 6 | ) 7 | 8 | desktop_utils = find_program('desktop-file-validate', required: false) 9 | if desktop_utils.found() 10 | test('Validate desktop file', desktop_utils, 11 | args: [desktop_file] 12 | ) 13 | endif 14 | 15 | configure_file( 16 | input: 'app.service', 17 | output: '@0@.service'.format(app_id), 18 | configuration: { 'app_id': app_id, 'bindir': bindir }, 19 | install_dir: join_paths(get_option('datadir'), 'dbus-1/services') 20 | ) 21 | 22 | appstream_file = configure_file( 23 | input: 'app.metainfo.xml.in', 24 | output: '@0@.metainfo.xml'.format(app_id), 25 | configuration: { 'app_id': app_id }, 26 | install_dir: join_paths(get_option('datadir'), 'metainfo') 27 | ) 28 | 29 | appstream_cli = find_program('appstreamcli', required: false) 30 | if appstream_cli.found() 31 | test('Validate metainfo file', appstream_cli, 32 | args: ['validate', '--override=release-time-missing=info', '--no-net', appstream_file] 33 | ) 34 | endif 35 | 36 | appstream_util = find_program('appstream-util', required: false) 37 | if appstream_util.found() 38 | test('Validate appstream file', appstream_util, 39 | args: ['validate', appstream_file] 40 | ) 41 | endif 42 | 43 | configure_file( 44 | input: 'app.gschema.xml', 45 | output: '@0@.gschema.xml'.format(app_id), 46 | configuration: { 'app_id': app_id }, 47 | install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas') 48 | ) 49 | 50 | compile_schemas = find_program('glib-compile-schemas', required: false) 51 | if compile_schemas.found() 52 | test('Validate schema file', compile_schemas, 53 | args: ['--strict', '--dry-run', meson.current_source_dir()] 54 | ) 55 | endif 56 | 57 | install_subdir('icons/hicolor', install_dir : join_paths(get_option('datadir'), 'icons')) 58 | -------------------------------------------------------------------------------- /src/icons/loupe-large-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Biblioteca.doap: -------------------------------------------------------------------------------- 1 | 2 | 8 | Biblioteca 9 | Read documentation 10 | Biblioteca lets you browse and read GNOME documentation. 11 | 12 | 13 | 14 | JavaScript 15 | 16 | GTK 4 17 | Libadwaita 18 | 19 | 20 | 21 | Akshay Warrier 22 | 23 | akshaywarrier 24 | 25 | 26 | 27 | AkshayWarrier 28 | 29 | 30 | 31 | 32 | 33 | AkshayWarrier 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | Sonny Piers 42 | 43 | sonnyp 44 | 45 | 46 | 47 | sonnyp 48 | 49 | 50 | 51 | 52 | 53 | sonny 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /.eslintrc.yaml: -------------------------------------------------------------------------------- 1 | root: true 2 | env: 3 | es2023: true 4 | parser: "@babel/eslint-parser" 5 | parserOptions: 6 | sourceType: module 7 | ecmaVersion: 2023 8 | requireConfigFile: false 9 | babelOptions: 10 | plugins: 11 | - "@babel/plugin-syntax-import-assertions" 12 | extends: 13 | - eslint:recommended 14 | - plugin:import/errors 15 | - plugin:import/warnings 16 | - plugin:prettier/recommended 17 | globals: 18 | __DEV__: readonly 19 | pkg: readonly 20 | # gjs 21 | ARGV: readonly 22 | Debugger: readonly 23 | GIRepositoryGType: readonly 24 | globalThis: readonly 25 | imports: readonly 26 | Intl: readonly 27 | log: readonly 28 | logError: readonly 29 | print: readonly 30 | printerr: readonly 31 | window: readonly 32 | TextEncoder: readonly 33 | TextDecoder: readonly 34 | console: readonly 35 | setTimeout: readonly 36 | setInterval: readonly 37 | clearTimeout: readonly 38 | clearInterval: readonly 39 | rules: 40 | # Possible Problems 41 | # https://eslint.org/docs/latest/rules/#possible-problems 42 | array-callback-return: [error] # https://eslint.org/docs/latest/rules/array-callback-return 43 | no-duplicate-imports: [error] # https://eslint.org/docs/latest/rules/no-duplicate-imports 44 | no-new-native-nonconstructor: [error] # https://eslint.org/docs/latest/rules/no-new-native-nonconstructor 45 | # TODO: log and logError 46 | no-restricted-globals: # https://eslint.org/docs/rules/no-restricted-globals 47 | - error 48 | - window 49 | - printerr 50 | - print 51 | - imports 52 | - logError 53 | - log 54 | no-unused-vars: # https://eslint.org/docs/latest/rules/no-unused-vars 55 | - error 56 | - vars: all 57 | args: none 58 | ignoreRestSiblings: false 59 | 60 | # Suggestions 61 | # https://eslint.org/docs/latest/rules/#suggestions 62 | eqeqeq: [error, always] # https://eslint.org/docs/rules/eqeqeq 63 | no-implicit-globals: [error] # https://eslint.org/docs/latest/rules/no-implicit-globals 64 | no-var: [error] # https://eslint.org/docs/rules/no-var 65 | prefer-arrow-callback: [ 66 | error, 67 | { allowNamedFunctions: true, allowUnboundThis: true }, 68 | ] # https://eslint.org/docs/rules/prefer-arrow-callback 69 | prefer-const: [error] # https://eslint.org/docs/rules/prefer-const 70 | 71 | # eslint-plugin-import 72 | # https://github.com/benmosher/eslint-plugin-import/ 73 | import/extensions: ["error", "ignorePackages"] 74 | import/no-unresolved: 75 | [2, { ignore: ["gi://*", "resource://*", "cairo", "gettext", "system"] }] 76 | -------------------------------------------------------------------------------- /src/sidebar/Sidebar.blp: -------------------------------------------------------------------------------- 1 | using Gtk 4.0; 2 | using Adw 1; 3 | 4 | template $Sidebar : Adw.NavigationPage { 5 | title: "Biblioteca"; 6 | child: Adw.ToolbarView { 7 | [top] 8 | Adw.HeaderBar { 9 | [end] 10 | MenuButton button_menu { 11 | menu-model: menu_app; 12 | icon-name: "open-menu-symbolic"; 13 | tooltip-text: _("Main Menu"); 14 | primary: true; 15 | } 16 | } 17 | 18 | [top] 19 | Box { 20 | SearchEntry search_entry { 21 | search-delay: 200; 22 | hexpand: true; 23 | placeholder-text: _("Search Biblioteca"); 24 | } 25 | styles ["toolbar"] 26 | } 27 | 28 | content: Stack stack { 29 | transition-type: none; 30 | 31 | Adw.StatusPage status_page { 32 | title: _("No Results Found"); 33 | description: _("Try a different search term"); 34 | icon-name: "edit-find-symbolic"; 35 | styles ["compact"] 36 | } 37 | }; 38 | }; 39 | } 40 | 41 | menu menu_app { 42 | section { 43 | item { 44 | custom: "themeswitcher"; 45 | } 46 | } 47 | 48 | section { 49 | item { 50 | custom: "zoom_buttons"; 51 | } 52 | } 53 | 54 | section { 55 | submenu { 56 | label: _("Bookmarks"); 57 | 58 | item { 59 | label: _("Developer Documentation"); 60 | action: "win.new-tab"; 61 | target: "https://developer.gnome.org/documentation/index.html"; 62 | } 63 | 64 | 65 | item { 66 | label: _("Human Interface Guidelines"); 67 | action: "win.new-tab"; 68 | target: "https://developer.gnome.org/hig/"; 69 | } 70 | 71 | item { 72 | label: _("JavaScript"); 73 | action: "win.new-tab"; 74 | target: "https://gjs.guide"; 75 | } 76 | 77 | item { 78 | label: _("Vala"); 79 | action: "win.new-tab"; 80 | target: "https://valadoc.org/"; 81 | } 82 | 83 | item { 84 | label: _("Rust"); 85 | action: "win.new-tab"; 86 | target: "https://gtk-rs.org"; 87 | } 88 | 89 | item { 90 | label: _("Python"); 91 | action: "win.new-tab"; 92 | target: "https://pygobject.readthedocs.io/"; 93 | } 94 | 95 | item { 96 | label: _("Blueprint"); 97 | action: "win.new-tab"; 98 | target: "https://jwestman.pages.gitlab.gnome.org/blueprint-compiler/"; 99 | } 100 | 101 | item { 102 | label: _("DevDocs"); 103 | action: "win.new-tab"; 104 | target: "https://devdocs.io/"; 105 | } 106 | } 107 | } 108 | 109 | section { 110 | item { 111 | label: _("Keyboard Shortcuts"); 112 | action: "app.shortcuts"; 113 | } 114 | 115 | item { 116 | label: _("About Biblioteca"); 117 | action: "app.about"; 118 | } 119 | } 120 | } 121 | 122 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Thank you for considering contributing to Biblioteca. Feel free to [get in touch](https://matrix.to/#/%23biblioteca:gnome.org). 4 | 5 | Please note that we do not support localization at the moment. The GNOME documentation is only available in English and we don't want to mislead users i 6 | 7 | ## Running from source 8 | 9 | The following is the recommended setup: 10 | 11 | 1. Install [GNOME Builder from Flathub](https://flathub.org/apps/details/org.gnome.Builder) 12 | 2. Open Builder and select "Clone Repository..." 13 | 3. Clone `https://github.com/workbenchdev/Biblioteca.git` (or your fork) 14 | 4. Press the Run ▶ button 15 | 16 | Make sure that you're building the development target `app.drey.Biblioteca.Devel`. 17 | 18 | If you know what you are doing you can also use VSCode with the extensions recommended in this workspace or anything else you are comfortable with. Don't forget to fetch the submodules. 19 | 20 | ## Setup 21 | 22 | We provide a couple of tools to make the development process pleasant. 23 | 24 | - Code formatter that runs automatically on git commit 25 | - Single command to run all the tests locally 26 | 27 | ```sh 28 | # Ubuntu requirements 29 | # sudo apt install flatpak flatpak-builder nodejs make 30 | # Fedora requirements 31 | # sudo dnf install flatpak flatpak-builder nodejs make 32 | 33 | cd Biblioteca 34 | make setup 35 | ``` 36 | 37 | Before submitting a PR, we recommend running tests locally with 38 | 39 | ```sh 40 | make test 41 | ``` 42 | 43 | ## Translations 44 | 45 | Biblioteca doesn't currently support translations for its user interface. GNOME documentation is only available in English and we do not want to mislead non-English speakers. 46 | 47 | ## Maintenance 48 | 49 | Notes for maintainers. 50 | 51 | ### How to release? 52 | 53 | ```sh 54 | version=1.0 55 | cd Biblioteca # this repo 56 | # update version in meson.build 57 | # add or update the release in data/app.metainfo.xml 58 | git add meson.build data/app.meta.info.xml 59 | git commit -m v$version # it's a convention to prefix version tags with "v" 60 | git push 61 | git tag v$version 62 | git push -u origin v$version 63 | 64 | cd ../app.drey.Biblioteca/ # https://github.com/flathub/app.drey.Biblioteca/ 65 | git checkout -b v$V # It's not possible to push to master on flathub 66 | cp ../Biblioteca/build-aux/app.drey.Biblioteca.json . # copy the release manifest 67 | # update the commit and tag in the app.drey.Biblioteca.json 68 | cp -r ../Biblioteca/build-aux/modules . # copy the modules 69 | git add . 70 | git commit -m v$version 71 | git push 72 | ``` 73 | 74 | It will trigger a "Test" build on https://buildbot.flathub.org/#/apps/app.drey.Biblioteca 75 | 76 | Once the build is successful, you'll be able to test it and merge the PR into main. 77 | 78 | It will trigger an "Official" build on https://buildbot.flathub.org/#/apps/app.drey.Biblioteca 79 | 80 | It will eventually be published but if you don't want to wait you can login Buildbot, select the "Official" build and click the "Publish" button. 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/FindOverlay.js: -------------------------------------------------------------------------------- 1 | import Gtk from "gi://Gtk"; 2 | import GObject from "gi://GObject"; 3 | import Webkit from "gi://WebKit"; 4 | 5 | import Template from "./FindOverlay.blp" with { type: "uri" }; 6 | 7 | class FindOverlay extends Gtk.Overlay { 8 | constructor({ webview, ...params }) { 9 | super(params); 10 | this.child = webview; 11 | this.#initToolbar(); 12 | } 13 | 14 | #initToolbar = () => { 15 | this._find_controller = this.child.get_find_controller(); 16 | this._find_controller.connect("found-text", this.#onFoundMatch); 17 | this._find_controller.connect("failed-to-find-text", this.#onNotFoundMatch); 18 | this._current_match = 0; 19 | this._total_count = 0; 20 | this._search_bar.connect_entry(this._search_text); 21 | this._search_text.connect("notify::text", this.find); 22 | }; 23 | 24 | showFind = () => { 25 | this._search_bar.search_mode_enabled = true; 26 | this._search_text.grab_focus(); 27 | }; 28 | 29 | find = () => { 30 | this._new_search = true; 31 | this._find_controller.search( 32 | this._search_text.text, 33 | Webkit.FindOptions.CASE_INSENSITIVE | Webkit.FindOptions.WRAP_AROUND, 34 | 1000, 35 | ); 36 | }; 37 | 38 | findNext = () => { 39 | this._new_search = false; 40 | this._find_controller.search_next(); 41 | this._current_match++; 42 | if (this._current_match > this._total_count) this._current_match = 1; 43 | this.#updateLabelInfo(); 44 | }; 45 | 46 | findPrev = () => { 47 | this._new_search = false; 48 | this._find_controller.search_previous(); 49 | this._current_match--; 50 | if (this._current_match < 1) this._current_match = this._total_count; 51 | this.#updateLabelInfo(); 52 | }; 53 | 54 | closeSearch = () => { 55 | this._new_search = false; 56 | this._search_bar.search_mode_enabled = false; 57 | this._find_controller.search_finish(); 58 | this._current_match = 0; 59 | this._total_count = 0; 60 | this.#updateLabelInfo(); 61 | }; 62 | 63 | #onFoundMatch = (controller, count) => { 64 | if (this._new_search) { 65 | this._current_match = 1; 66 | this._total_count = count; 67 | this.#updateLabelInfo(); 68 | } 69 | }; 70 | 71 | #onNotFoundMatch = (controller) => { 72 | this._current_match = 0; 73 | this._total_count = 0; 74 | this.#updateLabelInfo(); 75 | }; 76 | 77 | #updateLabelInfo = () => { 78 | if (this._total_count === 0) { 79 | this._label_info.label = ""; 80 | } else { 81 | this._label_info.label = `${this._current_match} of ${this._total_count}`; 82 | } 83 | }; 84 | } 85 | 86 | export default GObject.registerClass( 87 | { 88 | GTypeName: "FindOverlay", 89 | Template, 90 | InternalChildren: [ 91 | "search_bar", 92 | "search_text", 93 | "label_info", 94 | "button_previous", 95 | "button_next", 96 | "close_find_button", 97 | ], 98 | }, 99 | FindOverlay, 100 | ); 101 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SHELL:=/bin/bash -O globstar 2 | .PHONY: setup lint test ci sandbox flatpak 3 | .DEFAULT_GOAL := ci 4 | 5 | setup: 6 | flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo 7 | flatpak remote-add --user --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo 8 | flatpak install --or-update --user --noninteractive flathub org.gnome.Sdk//46 org.gnome.Sdk.Docs//46 9 | flatpak install --or-update --user --noninteractive flathub org.flatpak.Builder org.freedesktop.Sdk.Extension.node18//23.08 10 | npm install 11 | 12 | lint: 13 | # ESLint 14 | flatpak run --user --command=/usr/lib/sdk/node18/bin/node --filesystem=host:ro org.gnome.Sdk//46beta node_modules/.bin/eslint --max-warnings=0 src 15 | # gettext 16 | # find po/ -type f -name "*po" -print0 | xargs -0 -n1 msgfmt -o /dev/null --check 17 | # Flatpak manifests 18 | flatpak run --user --command=flatpak-builder-lint org.flatpak.Builder manifest --exceptions build-aux/app.drey.Biblioteca.json 19 | flatpak run --user --command=flatpak-builder-lint org.flatpak.Builder manifest --exceptions build-aux/app.drey.Biblioteca.Devel.json 20 | 21 | # https://github.com/ximion/appstream/issues/398#issuecomment-1129454985 22 | # flatpak run org.freedesktop.appstream.cli validate --override=release-time-missing=info --no-net data/app.metainfo.xml 23 | # desktop-file-validate --no-hints data/app.desktop 24 | # https://discourse.gnome.org/t/gtk-builder-tool-requires-and-libraries/9222 25 | # gtk-builder-tool validate src/*.ui 26 | # flatpak run org.flathub.flatpak-external-data-checker app.drey.Biblioteca.json 27 | # flatpak run org.flathub.flatpak-external-data-checker app.drey.Biblioteca.Devel.json 28 | # as used by Flathub 29 | # flatpak run --env=G_DEBUG=fatal-criticals --command=appstream-util org.flatpak.Builder validate data/app.metainfo.xml 30 | 31 | test: lint 32 | 33 | ci: setup lint 34 | 35 | # Note that if you have Sdk extensions installed they will be used 36 | # make sure to test without the sdk extensions installed 37 | sandbox: setup 38 | flatpak-builder --ccache --user --install --force-clean flatpak build-aux/app.drey.Biblioteca.Devel.json 39 | # flatpak remove --noninteractive org.gnome.Sdk.Docs//45 org.freedesktop.Sdk.Extension.rust-stable//23.08 org.freedesktop.Sdk.Extension.vala//23.08 org.freedesktop.Sdk.Extension.llvm16//23.08 40 | flatpak run --command="bash" app.drey.Biblioteca.Devel 41 | 42 | flatpak: setup 43 | flatpak-builder --ccache --force-clean flatpak build-aux/app.drey.Biblioteca.Devel.json 44 | # This is what Flathub does - consider moving to lint 45 | flatpak run --env=G_DEBUG=fatal-criticals --command=appstream-util org.flatpak.Builder validate flatpak/files/share/appdata/app.drey.Biblioteca.Devel.appdata.xml 46 | flatpak run --command="desktop-file-validate" --filesystem=host:ro org.freedesktop.Sdk//23.08 flatpak/files/share/applications/app.drey.Biblioteca.Devel.desktop 47 | # appstreamcli validate --override=release-time-missing=info /path/to/your/app.metainfo.xml 48 | flatpak-builder --run flatpak build-aux/app.drey.Biblioteca.Devel.json bash 49 | -------------------------------------------------------------------------------- /src/sidebar/fzy.js: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2014 John Hawthorn 2 | // 3 | // SPDX-License-Identifier: MIT 4 | // https://github.com/jhawthorn/fzy.js 5 | 6 | const SCORE_MIN = Number.MIN_SAFE_INTEGER; 7 | const SCORE_MAX = Number.MAX_SAFE_INTEGER; 8 | 9 | const SCORE_GAP_LEADING = -0.005; 10 | const SCORE_GAP_TRAILING = -0.005; 11 | const SCORE_GAP_INNER = -0.01; 12 | const SCORE_MATCH_CONSECUTIVE = 1.0; 13 | const SCORE_MATCH_SLASH = 0.9; 14 | const SCORE_MATCH_WORD = 0.8; 15 | const SCORE_MATCH_CAPITAL = 0.7; 16 | const SCORE_MATCH_DOT = 0.6; 17 | 18 | function islower(s) { 19 | return s.toLowerCase() === s; 20 | } 21 | 22 | function isupper(s) { 23 | return s.toUpperCase() === s; 24 | } 25 | 26 | function precompute_bonus(haystack) { 27 | /* Which positions are beginning of words */ 28 | const m = haystack.length; 29 | const match_bonus = new Array(m); 30 | 31 | let last_ch = "/"; 32 | for (let i = 0; i < m; i++) { 33 | const ch = haystack[i]; 34 | 35 | if (last_ch === "/") { 36 | match_bonus[i] = SCORE_MATCH_SLASH; 37 | } else if (last_ch === "-" || last_ch === "_" || last_ch === " ") { 38 | match_bonus[i] = SCORE_MATCH_WORD; 39 | } else if (last_ch === ".") { 40 | match_bonus[i] = SCORE_MATCH_DOT; 41 | } else if (islower(last_ch) && isupper(ch)) { 42 | match_bonus[i] = SCORE_MATCH_CAPITAL; 43 | } else { 44 | match_bonus[i] = 0; 45 | } 46 | 47 | last_ch = ch; 48 | } 49 | 50 | return match_bonus; 51 | } 52 | 53 | function compute(needle, haystack, D, M) { 54 | const n = needle.length; 55 | const m = haystack.length; 56 | 57 | const match_bonus = precompute_bonus(haystack, needle); 58 | 59 | /* 60 | * D[][] Stores the best score for this position ending with a match. 61 | * M[][] Stores the best possible score at this position. 62 | */ 63 | 64 | for (let i = 0; i < n; i++) { 65 | D[i] = new Array(m); 66 | M[i] = new Array(m); 67 | 68 | let prev_score = SCORE_MIN; 69 | const gap_score = i === n - 1 ? SCORE_GAP_TRAILING : SCORE_GAP_INNER; 70 | 71 | for (let j = 0; j < m; j++) { 72 | if (needle[i] === haystack[j]) { 73 | let score = SCORE_MIN; 74 | if (!i) { 75 | score = j * SCORE_GAP_LEADING + match_bonus[j]; 76 | } else if (j) { 77 | /* i > 0 && j > 0*/ 78 | score = Math.max( 79 | M[i - 1][j - 1] + match_bonus[j], 80 | 81 | /* consecutive match, doesn't stack with match_bonus */ 82 | D[i - 1][j - 1] + SCORE_MATCH_CONSECUTIVE, 83 | ); 84 | } 85 | D[i][j] = score; 86 | M[i][j] = prev_score = Math.max(score, prev_score + gap_score); 87 | } else { 88 | D[i][j] = SCORE_MIN; 89 | M[i][j] = prev_score = prev_score + gap_score; 90 | } 91 | } 92 | } 93 | } 94 | 95 | function score(needle, haystack) { 96 | const n = needle.length; 97 | const m = haystack.length; 98 | 99 | if (!n || !m) return SCORE_MIN; 100 | 101 | if (n === m) { 102 | /* Since this method can only be called with a haystack which 103 | * matches needle. If the lengths of the strings are equal the 104 | * strings themselves must also be equal (ignoring case). 105 | */ 106 | return SCORE_MAX; 107 | } 108 | 109 | if (m > 1024) { 110 | /* 111 | * Unreasonably large candidate: return no score 112 | * If it is a valid match it will still be returned, it will 113 | * just be ranked below any reasonably sized candidates 114 | */ 115 | return SCORE_MIN; 116 | } 117 | 118 | const D = new Array(n); 119 | const M = new Array(n); 120 | 121 | compute(needle, haystack, D, M); 122 | 123 | return M[n - 1][m - 1]; 124 | } 125 | 126 | function hasMatch(needle, haystack) { 127 | const l = needle.length; 128 | for (let i = 0, j = 0; i < l; i += 1) { 129 | j = haystack.indexOf(needle[i], j) + 1; 130 | if (j === 0) return false; 131 | } 132 | return true; 133 | } 134 | 135 | export { score, hasMatch }; 136 | -------------------------------------------------------------------------------- /src/Shortcuts.blp: -------------------------------------------------------------------------------- 1 | using Gtk 4.0; 2 | 3 | ShortcutsWindow window_shortcuts { 4 | hide-on-close: true; 5 | modal: true; 6 | 7 | ShortcutsSection { 8 | section-name: "shortcuts"; 9 | 10 | ShortcutsGroup { 11 | title: _("Tabs"); 12 | 13 | ShortcutsShortcut { 14 | title: _("Open tab"); 15 | accelerator: "T"; 16 | } 17 | 18 | ShortcutsShortcut { 19 | title: _("Close tab"); 20 | accelerator: "W"; 21 | } 22 | 23 | ShortcutsShortcut { 24 | title: _("Switch to the next tab"); 25 | accelerator: "Page_Down Tab"; 26 | } 27 | 28 | ShortcutsShortcut { 29 | title: _("Switch to the previous tab"); 30 | accelerator: "Page_Up Tab"; 31 | } 32 | 33 | ShortcutsShortcut { 34 | title: _("Switch to the first tab"); 35 | accelerator: "Home"; 36 | } 37 | 38 | ShortcutsShortcut { 39 | title: _("Switch to the last tab"); 40 | accelerator: "End"; 41 | } 42 | 43 | ShortcutsShortcut { 44 | title: _("View all open tabs"); 45 | accelerator: "o"; 46 | } 47 | 48 | ShortcutsShortcut { 49 | title: _("Move current tab backward"); 50 | accelerator: "Page_Up"; 51 | } 52 | 53 | ShortcutsShortcut { 54 | title: _("Move current tab forward"); 55 | accelerator: "Page_Down"; 56 | } 57 | 58 | ShortcutsShortcut { 59 | title: _("Move current tab at the start"); 60 | accelerator: "Home"; 61 | } 62 | 63 | ShortcutsShortcut { 64 | title: _("Move current tab at the end"); 65 | accelerator: "End"; 66 | } 67 | 68 | ShortcutsShortcut { 69 | title: _("Switch to tabs 1⋯10"); 70 | accelerator: "1...0"; 71 | } 72 | } 73 | 74 | ShortcutsGroup { 75 | title: _("Navigation"); 76 | 77 | ShortcutsShortcut { 78 | title: _("Go back to the previous page"); 79 | accelerator: "Left"; 80 | } 81 | 82 | ShortcutsShortcut { 83 | title: _("Go forward to the next page"); 84 | accelerator: "Right"; 85 | } 86 | 87 | ShortcutsShortcut { 88 | title: _("Focus global search"); 89 | accelerator: "K"; 90 | } 91 | 92 | ShortcutsShortcut { 93 | title: _("Find in page"); 94 | accelerator: "F"; 95 | } 96 | 97 | ShortcutsShortcut { 98 | title: _("Find next match"); 99 | accelerator: "G"; 100 | } 101 | 102 | ShortcutsShortcut { 103 | title: _("Find previous match"); 104 | accelerator: "G"; 105 | } 106 | 107 | ShortcutsShortcut { 108 | title: _("Focus URL bar"); 109 | accelerator: "L"; 110 | } 111 | 112 | ShortcutsShortcut { 113 | shortcut-type: gesture_two_finger_swipe_right; 114 | title: _("Go back to the previous page"); 115 | } 116 | 117 | ShortcutsShortcut { 118 | shortcut-type: gesture_two_finger_swipe_left; 119 | title: _("Go forward to the next page"); 120 | } 121 | } 122 | 123 | ShortcutsGroup { 124 | title: _("Zoom"); 125 | 126 | ShortcutsShortcut { 127 | title: _("Zoom in"); 128 | accelerator: "plus"; 129 | } 130 | 131 | ShortcutsShortcut { 132 | title: _("Zoom out"); 133 | accelerator: "minus"; 134 | } 135 | 136 | ShortcutsShortcut { 137 | title: _("Reset zoom"); 138 | accelerator: "0"; 139 | } 140 | } 141 | 142 | ShortcutsGroup { 143 | title: _("General"); 144 | 145 | ShortcutsShortcut { 146 | title: _("Show sidebar"); 147 | accelerator: "F9"; 148 | } 149 | 150 | ShortcutsShortcut { 151 | title: _("Shortcuts"); 152 | accelerator: "question"; 153 | } 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/window.blp: -------------------------------------------------------------------------------- 1 | using Gtk 4.0; 2 | using Adw 1; 3 | 4 | template $Window: Adw.ApplicationWindow { 5 | width-request: 360; 6 | height-request: 360; 7 | default-width: 1080; 8 | default-height: 768; 9 | title: "Biblioteca"; 10 | 11 | styles ["main-window"] 12 | 13 | Adw.Breakpoint window_breakpoint { 14 | condition ("max-width: 850sp") 15 | 16 | setters { 17 | split_view.collapsed: true; 18 | button_sidebar.visible: true; 19 | } 20 | } 21 | 22 | content: Adw.TabOverview tab_overview { 23 | enable-new-tab: true; 24 | view: tab_view; 25 | 26 | Adw.OverlaySplitView split_view { 27 | show-sidebar: bind button_sidebar.active; 28 | 29 | content: Adw.NavigationPage content_page { 30 | title: _("Documentation"); 31 | child: Adw.BreakpointBin { 32 | width-request: 360; 33 | height-request: 360; 34 | 35 | Adw.Breakpoint toolbar_breakpoint { 36 | condition ("max-width: 450sp") 37 | 38 | setters { 39 | bottom_toolbar.visible: true; 40 | button_new_tab.visible: false; 41 | tab_bar.visible: false; 42 | tab_button.visible: true; 43 | } 44 | } 45 | 46 | child: Adw.ToolbarView { 47 | [top] 48 | Box { 49 | name: "top-toolbars"; 50 | orientation: vertical; 51 | 52 | Adw.HeaderBar content_header_bar { 53 | title-widget: Stack header_bar_stack { 54 | StackPage { 55 | name: "title"; 56 | child: Adw.WindowTitle header_bar_title { 57 | title: bind content_page.title; 58 | }; 59 | } 60 | 61 | StackPage { 62 | name: "url_bar"; 63 | child: Adw.Clamp { 64 | Gtk.Entry url_bar { 65 | hexpand: true; 66 | input-purpose: url; 67 | } 68 | }; 69 | } 70 | }; 71 | 72 | [start] 73 | ToggleButton button_sidebar { 74 | icon-name: "sidebar-show-symbolic"; 75 | tooltip-text: _("Open Sidebar"); 76 | visible: false; 77 | active: bind split_view.show-sidebar; 78 | 79 | styles ["flat"] 80 | } 81 | 82 | [start] 83 | Box box_navigation { 84 | spacing: 6; 85 | halign: start; 86 | 87 | Button button_back { 88 | icon-name: "go-previous-symbolic"; 89 | tooltip-text: _("Back"); 90 | action-name: "win.navigation-back"; 91 | 92 | styles ["flat"] 93 | } 94 | 95 | Button button_forward { 96 | icon-name: "go-next-symbolic"; 97 | tooltip-text: _("Forward"); 98 | action-name: "win.navigation-forward"; 99 | 100 | styles ["flat"] 101 | } 102 | } 103 | 104 | [end] 105 | Button button_new_tab { 106 | icon-name: "tab-new-symbolic"; 107 | action-name: "win.new-tab"; 108 | action-target: '"file:///app/share/doc/gtk4/index.html"'; 109 | tooltip-text: _("New Tab"); 110 | 111 | styles ["flat"] 112 | } 113 | } 114 | 115 | Adw.TabBar tab_bar { 116 | view: tab_view; 117 | } 118 | 119 | ProgressBar load_bar { 120 | styles ["osd"] 121 | } 122 | } 123 | 124 | [bottom] 125 | ActionBar bottom_toolbar { 126 | visible: false; 127 | 128 | [end] 129 | Adw.TabButton tab_button { 130 | halign: end; 131 | view: tab_view; 132 | visible: false; 133 | } 134 | } 135 | 136 | Adw.TabView tab_view { 137 | vexpand: true; 138 | shortcuts: all_shortcuts; 139 | } 140 | }; 141 | }; 142 | }; 143 | } 144 | }; 145 | } 146 | -------------------------------------------------------------------------------- /src/sidebar/Sidebar.js: -------------------------------------------------------------------------------- 1 | import Gio from "gi://Gio"; 2 | import Adw from "gi://Adw"; 3 | import GObject from "gi://GObject"; 4 | 5 | import ThemeSelector from "../../troll/src/widgets/ThemeSelector.js"; 6 | import ZoomButtons from "./ZoomButtons.js"; 7 | 8 | import BrowseView from "./BrowseView.js"; 9 | import SearchView from "./SearchView.js"; 10 | import DocumentationPage from "./DocumentationPage.js"; 11 | import { decode } from "../util.js"; 12 | 13 | import Template from "./Sidebar.blp" with { type: "uri" }; 14 | 15 | import "../icons/edit-find-symbolic.svg"; 16 | 17 | let doc_index; 18 | 19 | class Sidebar extends Adw.NavigationPage { 20 | constructor(...params) { 21 | super(params); 22 | this.uri_to_tree_path = {}; 23 | this.#initializeSidebar(); 24 | this._search_entry.connect("search-changed", this.#onSearch); 25 | } 26 | 27 | resetSidebar() { 28 | this.browse_view.collapseAllRows(); 29 | this.browse_view.selection_model.selected = doc_index?.start_index ?? 0; 30 | this._search_entry.text = ""; 31 | this._stack.visible_child = this.browse_view; 32 | } 33 | 34 | focusSearch() { 35 | this._search_entry.grab_focus(); 36 | this._search_entry.select_region(0, -1); 37 | } 38 | 39 | #initializeSidebar() { 40 | this.browse_view = new BrowseView(this); 41 | this.search_view = new SearchView(); 42 | this.flattened_model = this.#newListStore(); 43 | 44 | const index_file = Gio.File.new_for_path(pkg.pkgdatadir).get_child( 45 | "doc-index.json", 46 | ); 47 | const content = index_file.load_contents(null); 48 | doc_index = JSON.parse(decode(content[1])); 49 | 50 | let idx = 0; 51 | const promises = []; 52 | for (const item of doc_index.docs) { 53 | promises.push( 54 | this.#buildPage(this.browse_view.root_model, item, [idx++]), 55 | ); 56 | } 57 | 58 | Promise.all(promises).then(() => { 59 | this.browse_view.selection_model.selected = doc_index.start_index; 60 | this.search_view.initializeModel(this.flattened_model); 61 | }); 62 | 63 | this.browse_view.connect("notify::webview", () => { 64 | const webview_uri = this.browse_view.webview.uri; 65 | const path = this.uri_to_tree_path[webview_uri]; 66 | if (!path) return; 67 | this.browse_view.selectItem(path); 68 | }); 69 | 70 | this.search_view.connect("search-view-selection-changed", (_, uri) => { 71 | const path = this.uri_to_tree_path[uri]; 72 | if (!path) return; 73 | this.browse_view.selectItem(path); 74 | }); 75 | 76 | this._stack.add_child(this.browse_view); 77 | this._stack.add_child(this.search_view); 78 | this._stack.visible_child = this.browse_view; 79 | 80 | // Popover menu theme switcher 81 | const popover = this._button_menu.get_popover(); 82 | popover.add_child(new ThemeSelector(), "themeswitcher"); 83 | this.zoom_buttons = new ZoomButtons(); 84 | popover.add_child(this.zoom_buttons, "zoom_buttons"); 85 | } 86 | 87 | async #buildPage(parent, item, path) { 88 | const page = new DocumentationPage({ 89 | name: item.name ?? null, 90 | tag: item.tag ?? null, 91 | search_name: item.search_name ?? null, 92 | uri: item.uri ?? null, 93 | children: item.children ? this.#newListStore() : null, 94 | }); 95 | this.uri_to_tree_path[item.uri] = path.slice(); 96 | parent.append(page); 97 | if (item.search_name) this.flattened_model.append(page); 98 | if (item.children) { 99 | let idx = 1; 100 | for (const child of item.children) { 101 | await this.#buildPage(page.children, child, [...path, idx++]); 102 | } 103 | } 104 | } 105 | 106 | #newListStore() { 107 | return Gio.ListStore.new(DocumentationPage); 108 | } 109 | 110 | #onSearch = () => { 111 | if (this._search_entry.text) { 112 | this._stack.visible_child = this.search_view; 113 | this.search_view.search_term = this._search_entry.text; 114 | if (!this.search_view.selection_model.n_items) 115 | this._stack.visible_child = this._status_page; 116 | } else { 117 | const index = this.browse_view.selection_model.selected; 118 | this._stack.visible_child = this.browse_view; 119 | // Make sure the selection doesnt change when switching views 120 | this.browse_view.selection_model.selected = index; 121 | } 122 | }; 123 | } 124 | 125 | export default GObject.registerClass( 126 | { 127 | GTypeName: "Sidebar", 128 | Template, 129 | InternalChildren: ["stack", "search_entry", "button_menu", "status_page"], 130 | }, 131 | Sidebar, 132 | ); 133 | -------------------------------------------------------------------------------- /src/sidebar/SearchView.js: -------------------------------------------------------------------------------- 1 | import Gtk from "gi://Gtk"; 2 | import GLib from "gi://GLib"; 3 | import Gdk from "gi://Gdk"; 4 | import GObject from "gi://GObject"; 5 | 6 | import { hasMatch, score } from "./fzy.js"; 7 | 8 | import Template from "./SearchView.blp" with { type: "uri" }; 9 | 10 | const QUERY_TYPES = [ 11 | "additional", 12 | "alias", 13 | "bitfield", 14 | "callback", 15 | "class", 16 | "constant", 17 | "constructor", 18 | "enum", 19 | "error", 20 | "function", 21 | "interface", 22 | "namespace", 23 | "macro", 24 | "method", 25 | "property", 26 | "signal", 27 | "struct", 28 | "union", 29 | "vfunc", 30 | ]; 31 | 32 | const QUERY_PATTERN = new RegExp( 33 | "^(" + QUERY_TYPES.join("|") + ")\\s*:\\s*", 34 | "i", 35 | ); 36 | 37 | const ITEM_HEIGHT = 38; 38 | 39 | class SearchView extends Gtk.ScrolledWindow { 40 | constructor(params = {}) { 41 | super(params); 42 | this.connect("notify::search-term", this.#onNotifySearchTem); 43 | 44 | this._adj = this._search_list_view.get_vadjustment(); 45 | 46 | const gesture_click = new Gtk.GestureClick({ button: 0 }); 47 | this._search_list_view.add_controller(gesture_click); 48 | gesture_click.connect("pressed", this.#onGestureClick); 49 | } 50 | 51 | get search_term() { 52 | if (this._search_term === undefined) this._search_term = ""; 53 | return this._search_term; 54 | } 55 | 56 | set search_term(value) { 57 | if (this.search_term === value) return; 58 | this._search_term = value; 59 | this.notify("search-term"); 60 | } 61 | 62 | initializeModel(flattened_model) { 63 | this._flattened_model = flattened_model; 64 | this.#createSearchSelectionModel(); 65 | } 66 | 67 | #onGestureClick = (gesture, n_press, x, y) => { 68 | switch (gesture.get_current_button()) { 69 | case Gdk.BUTTON_MIDDLE: { 70 | const index = Math.floor((this._adj.value + y) / ITEM_HEIGHT); 71 | // Avoid loading the page into current tab when the user middle-clicks 72 | this.inhibit_emit = true; 73 | this.selection_model.selected = index; 74 | if (!this.selection_model.selected_item) return; 75 | const uri = this.selection_model.selected_item.uri; 76 | this.activate_action("win.new-tab", new GLib.Variant("s", uri)); 77 | break; 78 | } 79 | } 80 | }; 81 | 82 | #onNotifySearchTem = () => { 83 | this.selection_model.unselect_item(this.selection_model.selected); 84 | this._filter_model.filter = this.#createFilter(); 85 | this._search_list_view.scroll_to(0, Gtk.ListScrollFlags.NONE, null); 86 | }; 87 | 88 | #createFilter() { 89 | let search_term = this.search_term; 90 | const matches = search_term.match(QUERY_PATTERN); 91 | let tag = null; 92 | 93 | if (matches) { 94 | tag = matches[1].toLowerCase(); 95 | search_term = search_term.substring(matches[0].length); 96 | } 97 | 98 | const needle = search_term.replace(/\s+/g, ""); 99 | const isCaseSensitive = needle.toLowerCase() !== needle; 100 | const actualNeedle = isCaseSensitive ? needle : needle.toLowerCase(); 101 | 102 | return Gtk.CustomFilter.new((item) => { 103 | const haystack = isCaseSensitive 104 | ? item.search_name 105 | : item.search_name.toLowerCase(); 106 | const match = hasMatch(actualNeedle, haystack); 107 | const shouldKeep = match && (!tag || item.tag === tag); 108 | if (shouldKeep) item.score = score(actualNeedle, haystack); 109 | return shouldKeep; 110 | }); 111 | } 112 | 113 | #createSearchSelectionModel() { 114 | this._filter_model = Gtk.FilterListModel.new(this._flattened_model, null); 115 | const sorter = Gtk.CustomSorter.new((item1, item2) => { 116 | return Math.sign(item2.score - item1.score); 117 | }); 118 | const sort_model = new Gtk.SortListModel({ 119 | model: this._filter_model, 120 | sorter: sorter, 121 | }); 122 | 123 | this.selection_model = Gtk.SingleSelection.new(sort_model); 124 | this.selection_model.autoselect = false; 125 | this.selection_model.can_unselect = true; 126 | this.selection_model.connect("selection-changed", () => { 127 | if (!this.selection_model.selected_item) return; 128 | const uri = this.selection_model.selected_item.uri; 129 | if (this.inhibit_emit) { 130 | this.inhibit_emit = false; 131 | return; 132 | } 133 | this.emit("search-view-selection-changed", uri); 134 | }); 135 | 136 | this._search_list_view.model = this.selection_model; 137 | } 138 | } 139 | 140 | export default GObject.registerClass( 141 | { 142 | GTypeName: "SearchView", 143 | Template, 144 | Properties: { 145 | "search-term": GObject.ParamSpec.string( 146 | "search-term", 147 | "search-term", 148 | "Current active search term", 149 | GObject.ParamFlags.READWRITE, 150 | "", 151 | ), 152 | }, 153 | Signals: { 154 | "search-view-selection-changed": { 155 | param_types: [GObject.TYPE_STRING], 156 | }, 157 | }, 158 | InternalChildren: ["search_list_view"], 159 | }, 160 | SearchView, 161 | ); 162 | -------------------------------------------------------------------------------- /src/sidebar/BrowseView.js: -------------------------------------------------------------------------------- 1 | import Gdk from "gi://Gdk"; 2 | import Gtk from "gi://Gtk"; 3 | import Gio from "gi://Gio"; 4 | import GLib from "gi://GLib"; 5 | import GObject from "gi://GObject"; 6 | import Webkit from "gi://WebKit"; 7 | import DocumentationPage from "./DocumentationPage.js"; 8 | 9 | import Template from "./BrowseView.blp" with { type: "uri" }; 10 | 11 | const ITEM_HEIGHT = 38; 12 | 13 | class BrowseView extends Gtk.ScrolledWindow { 14 | constructor(sidebar, ...params) { 15 | super(params); 16 | this._sidebar = sidebar; 17 | this.root_model = Gio.ListStore.new(DocumentationPage); 18 | this.#createBrowseSelectionModel(); 19 | 20 | this._scrolled_to = false; 21 | this._adj = this._browse_list_view.get_vadjustment(); 22 | this._adj.connect("value-changed", () => { 23 | this.#adjustScrolling(); 24 | }); 25 | 26 | const gesture_click = new Gtk.GestureClick({ button: 0 }); 27 | this._browse_list_view.add_controller(gesture_click); 28 | gesture_click.connect("pressed", this.#onGestureClick); 29 | 30 | this._browse_list_view.connect("activate", (list_view, pos) => { 31 | const row = this._tree_model.get_row(pos); 32 | row.expanded = !row.expanded; 33 | }); 34 | } 35 | 36 | get webview() { 37 | if (this._webview === undefined) this._webview = null; 38 | return this._webview; 39 | } 40 | 41 | set webview(value) { 42 | if (this._webview === value) return; 43 | if (this._handler) this._webview.disconnect(this._handler); 44 | this._webview = value; 45 | this._handler = this._webview.connect("notify::uri", this.#syncSelection); 46 | this.notify("webview"); 47 | } 48 | 49 | selectItem(path) { 50 | const index = this.#getItemIndex(path); 51 | // If possible, overshoot scrolling by one row to ensure selected row is visible 52 | index + 1 === this.selection_model.n_items 53 | ? this._browse_list_view.scroll_to(index, Gtk.ListScrollFlags.NONE, null) 54 | : this._browse_list_view.scroll_to( 55 | index + 1, 56 | Gtk.ListScrollFlags.NONE, 57 | null, 58 | ); 59 | this.selection_model.selected = index; 60 | this._scrolled_to = true; 61 | } 62 | 63 | unselectSelection() { 64 | this.selection_model.unselect_item(this.selection_model.selected); 65 | } 66 | 67 | collapseAllRows() { 68 | for (let i = 0; i < this._tree_model.n_items; i++) { 69 | const row = this._tree_model.get_row(i); 70 | row.expanded = false; 71 | } 72 | } 73 | 74 | #syncSelection = (webview) => { 75 | const selected_item = this.selection_model.selected_item; 76 | if (selected_item === null || webview.uri !== selected_item.item.uri) { 77 | const path = this._sidebar.uri_to_tree_path[webview.uri]; 78 | if (!path) return; 79 | this.selectItem(path); 80 | } 81 | }; 82 | 83 | #onGestureClick = (gesture, n_press, x, y) => { 84 | switch (gesture.get_current_button()) { 85 | case Gdk.BUTTON_MIDDLE: { 86 | const index = Math.floor((this._adj.value + y) / ITEM_HEIGHT); 87 | const uri = this._tree_model.get_row(index).item.uri; 88 | this.activate_action("win.new-tab", new GLib.Variant("s", uri)); 89 | break; 90 | } 91 | } 92 | }; 93 | 94 | #adjustScrolling() { 95 | if (this._scrolled_to) { 96 | const index = this.selection_model.selected; 97 | const bottom_edge = (index + 1) * ITEM_HEIGHT - this._adj.value; 98 | const top_edge = bottom_edge - ITEM_HEIGHT; 99 | // If row is not visible after scroll_to, adjust 100 | if (bottom_edge === 0) { 101 | this._adj.value -= ITEM_HEIGHT; 102 | } else if (top_edge === this._adj.page_size) { 103 | this._adj.value += ITEM_HEIGHT; 104 | } 105 | this._scrolled_to = false; 106 | } 107 | } 108 | 109 | #getItemIndex(path) { 110 | let relative_index = 0; // Relative index of the item under its parent 111 | let absolute_index = 0; // Index of the item in the entire model 112 | let skip = 0; // Number of items to skip due to expanded rows 113 | 114 | for (let i = 0; i < path.length; i++) { 115 | while (relative_index < path[i]) { 116 | const row = this._tree_model.get_row(absolute_index); 117 | if (row.expanded) { 118 | skip += row.children.get_n_items(); 119 | } 120 | if (!skip) relative_index++; // Go to next sibling 121 | else skip--; 122 | absolute_index++; 123 | } 124 | // Check to ensure the last item is not expanded 125 | if (i < path.length - 1) { 126 | this._tree_model.get_row(absolute_index).expanded = true; 127 | absolute_index++; 128 | relative_index = 1; 129 | } 130 | } 131 | return absolute_index; 132 | } 133 | 134 | #createBrowseSelectionModel() { 135 | this._tree_model = Gtk.TreeListModel.new( 136 | this.root_model, 137 | false, 138 | false, 139 | (item) => item.children, 140 | ); 141 | this.selection_model = Gtk.SingleSelection.new(this._tree_model); 142 | this.selection_model.can_unselect = true; 143 | this.selection_model.connect("selection-changed", () => { 144 | if (!this.selection_model.selected_item) return; 145 | 146 | // If selection changed to sync the sidebar, dont load_uri again 147 | const uri = this.selection_model.selected_item.item.uri; 148 | if (this.webview.uri === uri) { 149 | return; 150 | } 151 | this.webview.load_uri(uri); 152 | }); 153 | this._browse_list_view.model = this.selection_model; 154 | } 155 | } 156 | 157 | export default GObject.registerClass( 158 | { 159 | GTypeName: "BrowseView", 160 | Template, 161 | Properties: { 162 | webview: GObject.ParamSpec.object( 163 | "webview", 164 | "webview", 165 | "Current active webview", 166 | GObject.ParamFlags.READWRITE, 167 | Webkit.WebView, 168 | ), 169 | }, 170 | InternalChildren: ["browse_list_view"], 171 | }, 172 | BrowseView, 173 | ); 174 | -------------------------------------------------------------------------------- /data/app.metainfo.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | @app_id@ 4 | @app_id@.desktop 5 | Biblioteca 6 | 7 | Akshay Warrier 8 | 9 | akshaywarrier@gnome.org 10 | CC0-1.0 11 | GPL-3.0 12 | Read GNOME documentation offline 13 | @app_id@ 14 | 15 |

Biblioteca lets you browse and read GNOME documentation. Among other things, Biblioteca comes with

16 |
    17 |
  • Offline documentation
  • 18 |
  • Web browsing
  • 19 |
  • Tabs
  • 20 |
  • Dark mode support
  • 21 |
  • Fuzzy search
  • 22 |
  • Mobile / adaptive
  • 23 |
24 |
25 | https://github.com/workbenchdev/Biblioteca 26 | https://github.com/workbenchdev/Biblioteca/issues 27 | 28 | 29 | https://github.com/workbenchdev/Biblioteca 30 | 31 | 32 | https://raw.githubusercontent.com/workbenchdev/Biblioteca/main/data/screenshot.png 33 | Biblioteca main window with GTK 4 docs selected 34 | 35 | 36 | 37 | 38 | 39 | 40 |
    41 |
  • Update to GNOME 49
  • 42 |
  • Add jsonrpc-glib
  • 43 |
  • Update libshumate to 1.5.1
  • 44 |
  • Update libspelling to 0.4.9
  • 45 |
  • Update vte to 0.82.1
  • 46 |
  • Update gom to 0.5.4
  • 47 |
48 |
49 |
50 | 51 | 52 |
    53 |
  • Add missing class method docs
  • 54 |
  • Update to GNOME 48
  • 55 |
  • Update vte to 0.80.1
  • 56 |
  • Update libportal to 0.9.1
  • 57 |
  • Update libshumate to 1.4.0
  • 58 |
  • Update libspelling to 0.4.8
  • 59 |
60 |
61 |
62 | 63 | 64 |
    65 |
  • Update to GNOME 47
  • 66 |
  • Add gom documentation
  • 67 |
  • Remember window size
  • 68 |
  • Update vte to 0.78
  • 69 |
  • Update libportal to 0.8.1
  • 70 |
  • Update libshumate to 1.3.0
  • 71 |
  • Update libspelling to 0.4.2
  • 72 |
  • Remove irrelevant context menu entries
  • 73 |
74 |
75 |
76 | 77 | 78 |
    79 |
  • Add support for Find in page (Ctrl + F)
  • 80 |
  • Fix bug where shortcuts don't work when WebView is focused
  • 81 |
  • Do not show a progress bar for offline docs
  • 82 |
83 |
84 |
85 | 86 | 87 |
    88 |
  • Add GLib/Gio/GObject docs
  • 89 |
  • Add support for web content
  • 90 |
  • Improve searching UI
  • 91 |
  • Add support for keyboard navigation in sidebar
  • 92 |
  • Fix bug where creating new tab updates current selected tab
  • 93 |
  • Add zoom buttons to primary menu
  • 94 |
  • Add raised border to WebView on scroll
  • 95 |
  • Make tags in search results insensitive
  • 96 |
  • Add shortcuts to view open tabs and toggle sidebar
  • 97 |
  • Fix modality of shortcuts window
  • 98 |
  • Update VTE to 0.76
  • 99 |
  • Update libshumate to 1.2
  • 100 |
101 |
102 |
103 | 104 | 105 |
    106 |
  • Add support for Tabs
  • 107 |
  • Add middle-click support in the sidebar for opening in a new tab
  • 108 |
  • Fix an issue where shortcuts window prevents app from closing
  • 109 |
  • Fix an issue where main window CSS leaks into other windows
  • 110 |
  • Show status page in sidebar when no results found
  • 111 |
  • Fix layout with "Large Text" accessibility option
  • 112 |
113 |
114 |
115 | 116 | 117 |

Various bug fixes.

118 |
119 |
120 | 121 | 122 |

This is the first release of Biblioteca with GNOME 45 documentation. We hope you like it.

123 |
124 |
125 |
126 | 127 | HiDpiIcon 128 | HighContrast 129 | ModernToolkit 130 | 131 | 132 | 360 133 | 134 | 135 | keyboard 136 | pointing 137 | touch 138 | always 139 | 140 | 141 | #99c1f1 142 | #1c71d8 143 | 144 |
145 | -------------------------------------------------------------------------------- /src/WebView.js: -------------------------------------------------------------------------------- 1 | import WebKit from "gi://WebKit"; 2 | import GObject from "gi://GObject"; 3 | import GLib from "gi://GLib"; 4 | 5 | import Template from "./WebView.blp" with { type: "uri" }; 6 | 7 | const UNDESIRED_CONTEXT_MENU_ACTIONS = [ 8 | // https://github.com/workbenchdev/Biblioteca/issues/105 9 | WebKit.ContextMenuAction.STOP, 10 | WebKit.ContextMenuAction.RELOAD, 11 | // unsupported 12 | WebKit.ContextMenuAction.OPEN_LINK_IN_NEW_WINDOW, 13 | WebKit.ContextMenuAction.DOWNLOAD_LINK_TO_DISK, 14 | WebKit.ContextMenuAction.OPEN_IMAGE_IN_NEW_WINDOW, 15 | WebKit.ContextMenuAction.DOWNLOAD_IMAGE_TO_DISK, 16 | WebKit.ContextMenuAction.OPEN_FRAME_IN_NEW_WINDOW, 17 | WebKit.ContextMenuAction.OPEN_VIDEO_IN_NEW_WINDOW, 18 | WebKit.ContextMenuAction.OPEN_AUDIO_IN_NEW_WINDOW, 19 | WebKit.ContextMenuAction.DOWNLOAD_VIDEO_TO_DISK, 20 | WebKit.ContextMenuAction.DOWNLOAD_AUDIO_TO_DISK, 21 | ]; 22 | 23 | class WebView extends WebKit.WebView { 24 | constructor({ uri, sidebar, ...params }) { 25 | super(params); 26 | this._sidebar = sidebar; 27 | this._browse_view = this._sidebar.browse_view; 28 | this.connect("notify::uri", () => this.#updateIsOnline(this.uri)); 29 | this.load_uri(uri); 30 | 31 | this.#disablePageSidebar(); 32 | this.#injectOverlayScript(); 33 | 34 | this.get_back_forward_list().connect("changed", () => { 35 | this.activate_action("win.update-buttons", null); 36 | }); 37 | this.connect("decide-policy", this.#onDecidePolicy); 38 | this.connect("context-menu", this.#onContextMenu); 39 | } 40 | 41 | get is_online() { 42 | if (this._is_online === undefined) this._is_online = false; 43 | return this._is_online; 44 | } 45 | 46 | set is_online(value) { 47 | if (this._is_online === value) return; 48 | this._is_online = value; 49 | this.notify("is-online"); 50 | } 51 | 52 | load_uri(uri) { 53 | this.#updateIsOnline(uri); 54 | super.load_uri(uri); 55 | } 56 | 57 | #disablePageSidebar() { 58 | const stylesheet = new WebKit.UserStyleSheet( 59 | ".devhelp-hidden { display: none; }", // source 60 | WebKit.UserContentInjectedFrames.ALL_FRAMES, // injected_frames 61 | WebKit.UserStyleLevel.USER, // level 62 | null, 63 | null, 64 | ); 65 | this.user_content_manager.add_style_sheet(stylesheet); 66 | } 67 | 68 | #injectOverlayScript() { 69 | // https://gitlab.com/news-flash/news_flash_gtk/-/blob/6c080e2b0cf6def97fc877f3cb817ba1e277f2f5/data/resources/article_view/overshoot_overlay.js 70 | const source = ` 71 | var body = document.body; 72 | var divTop = document.createElement('div'); 73 | body.insertBefore(divTop, body.firstChild); 74 | var divBottom = document.createElement('div'); 75 | body.insertAdjacentElement('beforeend', divBottom); 76 | 77 | window.addEventListener('scroll', on_scroll); 78 | 79 | function on_scroll() { 80 | if (window.scrollY > 0) { 81 | divTop.classList.add("overshoot-overlay-top"); 82 | } else { 83 | divTop.classList.remove("overshoot-overlay-top"); 84 | } 85 | 86 | var limit = Math.max( 87 | document.body.scrollHeight, 88 | document.body.offsetHeight, 89 | document.documentElement.clientHeight, 90 | document.documentElement.scrollHeight, 91 | document.documentElement.offsetHeight); 92 | var max_scroll = limit - window.innerHeight; 93 | 94 | if (window.scrollY >= max_scroll) { 95 | divBottom.classList.remove("overshoot-overlay-bottom"); 96 | } else { 97 | divBottom.classList.add("overshoot-overlay-bottom"); 98 | } 99 | } 100 | `; 101 | const script = new WebKit.UserScript( 102 | source, 103 | WebKit.UserContentInjectedFrames.ALL_FRAMES, // injected_frames 104 | WebKit.UserScriptInjectionTime.END, // level 105 | null, 106 | null, 107 | ); 108 | this.user_content_manager.add_script(script); 109 | this.#injectOverlayStyles(); 110 | } 111 | 112 | #injectOverlayStyles() { 113 | // https://gitlab.com/news-flash/news_flash_gtk/-/blob/6c080e2b0cf6def97fc877f3cb817ba1e277f2f5/data/resources/article_view/style.css#L22-33 114 | // https://gitlab.com/news-flash/news_flash_gtk/-/blob/6c080e2b0cf6def97fc877f3cb817ba1e277f2f5/data/resources/article_view/style.css#L424-428 115 | const styles = ` 116 | .overshoot-overlay-top { 117 | height: 100%; 118 | width: 100%; 119 | position: fixed; 120 | z-index: 1; 121 | left: 0; 122 | top: 0; 123 | box-shadow: inset 0 1px rgba(0, 0, 0, 0.07); 124 | background: linear-gradient(to bottom, rgba(0, 0, 0, 0.07), transparent 4px); 125 | overflow-x: hidden; 126 | pointer-events: none; 127 | } 128 | .overshoot-overlay-bottom { 129 | height: 100%; 130 | width: 100%; 131 | position: fixed; 132 | z-index: 2; 133 | left: 0; 134 | bottom: 0; 135 | background: linear-gradient(to top, rgba(0, 0, 0, 0.07), transparent 4px); 136 | overflow-x: hidden; 137 | pointer-events: none; 138 | } 139 | 140 | 141 | @media (prefers-color-scheme: dark) { 142 | .overshoot-overlay-top { 143 | box-shadow: inset 0 1px rgba(0, 0, 0, 0.36); 144 | background: linear-gradient(to bottom, rgba(0, 0, 0, 0.36), transparent 4px); 145 | } 146 | .overshoot-overlay-bottom { 147 | box-shadow: inset 0 -1px rgba(0, 0, 0, 0.36); 148 | background: linear-gradient(to top, rgba(0, 0, 0, 0.36), transparent 4px); 149 | } 150 | } 151 | `; 152 | const stylesheet = new WebKit.UserStyleSheet( 153 | styles, // source 154 | WebKit.UserContentInjectedFrames.ALL_FRAMES, // injected_frames 155 | WebKit.UserStyleLevel.USER, // level 156 | null, 157 | null, 158 | ); 159 | this.user_content_manager.add_style_sheet(stylesheet); 160 | } 161 | 162 | #updateIsOnline(uri) { 163 | if (!uri) { 164 | this.is_online = false; 165 | } else { 166 | const scheme = GLib.Uri.peek_scheme(uri); 167 | this.is_online = ["http", "https"].includes(scheme); 168 | } 169 | } 170 | 171 | #onDecidePolicy = (_self, decision, decision_type) => { 172 | console.debug( 173 | "decide-policy", 174 | getEnum(WebKit.PolicyDecisionType, decision_type), 175 | ); 176 | 177 | if (decision_type === WebKit.PolicyDecisionType.NAVIGATION_ACTION) { 178 | const navigation_action = decision.get_navigation_action(); 179 | const mouse_button = navigation_action.get_mouse_button(); 180 | const uri = navigation_action.get_request().get_uri(); 181 | console.debug( 182 | "navigation", 183 | getEnum(WebKit.NavigationType, navigation_action.get_navigation_type()), 184 | uri, 185 | ); 186 | 187 | if (mouse_button === 2) { 188 | decision.ignore(); 189 | this.activate_action("win.new-tab", new GLib.Variant("s", uri)); 190 | return true; 191 | } 192 | } 193 | return false; 194 | }; 195 | 196 | #onContextMenu = (web_view, context_menu, hit_test_result) => { 197 | const items = context_menu.get_items(); 198 | for (const item of items) { 199 | if (UNDESIRED_CONTEXT_MENU_ACTIONS.includes(item.get_stock_action())) { 200 | context_menu.remove(item); 201 | } 202 | } 203 | 204 | return false; 205 | }; 206 | } 207 | 208 | export function getEnum(enums, idx) { 209 | return Object.keys(enums).find((key) => { 210 | return enums[key] === idx; 211 | }); 212 | } 213 | 214 | export default GObject.registerClass( 215 | { 216 | GTypeName: "WebView", 217 | Template, 218 | Properties: { 219 | "is-online": GObject.ParamSpec.boolean( 220 | "is-online", 221 | "is-online", 222 | "True if the webview is online", 223 | GObject.ParamFlags.READWRITE, 224 | false, 225 | ), 226 | }, 227 | }, 228 | WebView, 229 | ); 230 | -------------------------------------------------------------------------------- /src/window.js: -------------------------------------------------------------------------------- 1 | import Adw from "gi://Adw"; 2 | import Gio from "gi://Gio"; 3 | import GLib from "gi://GLib"; 4 | import GObject from "gi://GObject"; 5 | import WebKit from "gi://WebKit"; 6 | import Shortcuts from "./Shortcuts.js"; 7 | import Sidebar from "./sidebar/Sidebar.js"; 8 | import WebView from "./WebView.js"; 9 | import FindOverlay from "./FindOverlay.js"; 10 | import { settings } from "./util.js"; 11 | import { persistWindowState } from "../troll/src/util.js"; 12 | 13 | import Template from "./window.blp" with { type: "uri" }; 14 | 15 | import "./icons/sidebar-show-symbolic.svg"; 16 | import "./icons/tab-new-symbolic.svg"; 17 | import "./icons/view-grid-symbolic.svg"; 18 | import "./icons/loupe-large-symbolic.svg"; 19 | 20 | class Window extends Adw.ApplicationWindow { 21 | constructor(params = {}) { 22 | super(params); 23 | 24 | persistWindowState({ window: this, settings }); 25 | 26 | if (__DEV__) { 27 | this.add_css_class("devel"); 28 | } 29 | 30 | this.#createSidebar(); 31 | this.newTab(); 32 | 33 | const win_group = new Gio.SimpleActionGroup(); 34 | this.insert_action_group("win", win_group); 35 | 36 | const action_entries = [ 37 | { 38 | name: "new-tab", 39 | activate: (action, parameter) => this.newTab(parameter.unpack()), 40 | parameter_type: "s", 41 | }, 42 | { 43 | name: "close-tab", 44 | activate: () => this.closeTab(), 45 | }, 46 | { 47 | name: "navigation-forward", 48 | activate: () => this.goForward(), 49 | }, 50 | { 51 | name: "navigation-back", 52 | activate: () => this.goBack(), 53 | }, 54 | { 55 | name: "zoom-in", 56 | activate: () => this.zoomIn(), 57 | }, 58 | { 59 | name: "zoom-out", 60 | activate: () => this.zoomOut(), 61 | }, 62 | { 63 | name: "reset-zoom", 64 | activate: () => this.resetZoom(), 65 | }, 66 | { 67 | name: "global-search", 68 | activate: () => this.focusGlobalSearch(), 69 | }, 70 | { 71 | name: "focus-urlbar", 72 | activate: () => this.focusURLBar(), 73 | }, 74 | { 75 | name: "toggle-sidebar", 76 | activate: () => this.toggleSidebar(), 77 | }, 78 | { 79 | name: "toggle-overview", 80 | activate: () => this.toggleOverview(), 81 | }, 82 | { 83 | name: "update-buttons", 84 | activate: () => this.#updateButtons(), 85 | }, 86 | { 87 | name: "find", 88 | activate: () => this._find_overlay.showFind(), 89 | }, 90 | { 91 | name: "find-prev", 92 | activate: () => this._find_overlay.findPrev(), 93 | }, 94 | { 95 | name: "find-next", 96 | activate: () => this._find_overlay.findNext(), 97 | }, 98 | { 99 | name: "close-find", 100 | activate: () => this._find_overlay.closeSearch(), 101 | }, 102 | ]; 103 | 104 | win_group.add_action_entries(action_entries); 105 | 106 | this._tab_button.connect("clicked", () => { 107 | this._tab_overview.open = !this._tab_overview.open; 108 | }); 109 | 110 | this._tab_overview.connect("create-tab", () => this.newTab()); 111 | 112 | this._tab_view.connect("notify::selected-page", this.#updateWebView); 113 | this.#setupBreakpoint(); 114 | 115 | this._toolbar_breakpoint.connect("apply", this.#moveNavigationDown); 116 | this._toolbar_breakpoint.connect("unapply", this.#moveNavigationUp); 117 | 118 | this._url_bar.connect("activate", this.#onActivateURLBar); 119 | 120 | Shortcuts(this); 121 | } 122 | 123 | open() { 124 | // The window is already open 125 | const mapped = this.get_mapped(); 126 | this.present(); 127 | this.focusGlobalSearch(); 128 | if (!mapped) { 129 | this._sidebar.resetSidebar(); 130 | } 131 | } 132 | 133 | goForward = () => { 134 | this._webview.go_forward(); 135 | }; 136 | 137 | goBack = () => { 138 | this._webview.go_back(); 139 | }; 140 | 141 | zoomIn = () => { 142 | if (this._webview.zoom_level < 2) this._webview.zoom_level += 0.25; 143 | }; 144 | 145 | zoomOut = () => { 146 | if (this._webview.zoom_level > 0.5) this._webview.zoom_level -= 0.25; 147 | }; 148 | 149 | resetZoom = () => { 150 | this._webview.zoom_level = 1; 151 | }; 152 | 153 | focusGlobalSearch = () => { 154 | this._tab_overview.open = false; 155 | this._split_view.show_sidebar = true; 156 | this._sidebar._search_entry.grab_focus(); 157 | this._sidebar._search_entry.select_region(0, -1); 158 | }; 159 | 160 | focusURLBar = () => { 161 | if (this._webview.is_online) this._url_bar.grab_focus(); 162 | }; 163 | 164 | newTab = (uri = "file:///app/share/doc/gtk4/index.html") => { 165 | this._webview = new WebView({ 166 | uri: uri, 167 | sidebar: this._sidebar, 168 | }); 169 | 170 | this._find_overlay = new FindOverlay({ webview: this._webview }); 171 | const tab_page = this._tab_view.append(this._find_overlay); 172 | this._tab_view.selected_page = tab_page; 173 | this.#updateWebView(); 174 | 175 | this._webview.connect("notify::is-online", this.#onWebViewOnline); 176 | 177 | this._webview.connect("notify::estimated-load-progress", () => { 178 | if (!this._webview.is_online) { 179 | this._load_bar.fraction = 0; 180 | return; 181 | } 182 | this._load_bar.fraction = this._webview.estimated_load_progress; 183 | if (this._load_bar.fraction === 1) { 184 | // Reset the load bar after a short delay 185 | setTimeout(() => { 186 | this._load_bar.fraction = 0; 187 | }, 500); 188 | } 189 | }); 190 | 191 | this._webview.connect("load-changed", (self, load_event) => { 192 | switch (load_event) { 193 | case WebKit.LoadEvent.STARTED: 194 | tab_page.loading = true; 195 | break; 196 | case WebKit.LoadEvent.FINISHED: 197 | tab_page.loading = false; 198 | break; 199 | } 200 | }); 201 | 202 | this._webview.bind_property( 203 | "title", 204 | tab_page, 205 | "title", 206 | GObject.BindingFlags.SYNC_CREATE, 207 | ); 208 | 209 | this._webview.bind_property_full( 210 | "title", 211 | this._content_page, 212 | "title", 213 | GObject.BindingFlags.SYNC_CREATE, 214 | (binding, from_value) => 215 | from_value ? [true, from_value] : [false, null], 216 | null, 217 | ); 218 | 219 | this._webview.bind_property_full( 220 | "title", 221 | this, 222 | "title", 223 | GObject.BindingFlags.SYNC_CREATE, 224 | (binding, from_value) => 225 | from_value ? [true, `${from_value} - Biblioteca`] : [false, null], 226 | null, 227 | ); 228 | 229 | this._webview.bind_property( 230 | "zoom-level", 231 | this._sidebar.zoom_buttons, 232 | "zoom-level", 233 | GObject.BindingFlags.SYNC_CREATE, 234 | ); 235 | return tab_page; 236 | }; 237 | 238 | closeTab = () => { 239 | if (this._tab_view.n_pages === 1 && !this._tab_overview.open) { 240 | this.close(); 241 | return; 242 | } 243 | this._tab_view.close_page(this._tab_view.selected_page); 244 | }; 245 | 246 | toggleSidebar = () => { 247 | if (this._split_view.collapsed && !this._tab_overview.open) { 248 | this._split_view.show_sidebar = !this._split_view.show_sidebar; 249 | } 250 | }; 251 | 252 | toggleOverview = () => { 253 | this._tab_overview.open = !this._tab_overview.open; 254 | }; 255 | 256 | #updateWebView = () => { 257 | if (!this._tab_view.selected_page) return; 258 | this._find_overlay = this._tab_view.selected_page.child; 259 | this._webview = this._find_overlay.child; 260 | this._sidebar.zoom_buttons.zoom_level = this._webview.zoom_level; 261 | this.#updateButtons(); 262 | if (this._webview.title) { 263 | this.title = `${this._webview.title} - Biblioteca`; 264 | this._content_page.title = this._webview.title; 265 | } 266 | this.#onWebViewOnline(); 267 | this._sidebar.browse_view.webview = this._webview; 268 | }; 269 | 270 | #onWebViewOnline = () => { 271 | if (this._webview.is_online) { 272 | this._sidebar.browse_view.unselectSelection(); 273 | 274 | this._binding_uri = this._webview.bind_property( 275 | "uri", 276 | this._url_bar.buffer, 277 | "text", 278 | GObject.BindingFlags.SYNC_CREATE, 279 | ); 280 | this._header_bar_stack.set_visible_child_name("url_bar"); 281 | return; 282 | } 283 | if (this._binding_uri) this._binding_uri.unbind(); 284 | this._header_bar_stack.set_visible_child_name("title"); 285 | }; 286 | 287 | #moveNavigationDown = () => { 288 | this._content_header_bar.remove(this._box_navigation); 289 | this._bottom_toolbar.pack_start(this._box_navigation); 290 | }; 291 | 292 | #moveNavigationUp = () => { 293 | this._bottom_toolbar.remove(this._box_navigation); 294 | this._content_header_bar.pack_start(this._box_navigation); 295 | }; 296 | 297 | #onActivateURLBar = () => { 298 | let url = this._url_bar.buffer.text; 299 | const scheme = GLib.Uri.peek_scheme(url); 300 | if (!scheme) { 301 | url = `http://${url}`; 302 | } 303 | this._webview.load_uri(url); 304 | }; 305 | 306 | #createSidebar() { 307 | this._sidebar = new Sidebar(); 308 | this._split_view.sidebar = this._sidebar; 309 | } 310 | 311 | #setupBreakpoint() { 312 | this._window_breakpoint.add_setters( 313 | [this._sidebar.browse_view, this._sidebar.search_view], 314 | ["width-request", "width-request"], 315 | [300, 300], 316 | ); 317 | } 318 | 319 | #updateButtons = () => { 320 | this._button_back.sensitive = this._webview.can_go_back(); 321 | this._button_forward.sensitive = this._webview.can_go_forward(); 322 | }; 323 | } 324 | 325 | export default GObject.registerClass( 326 | { 327 | GTypeName: "Window", 328 | Template, 329 | InternalChildren: [ 330 | "window_breakpoint", 331 | "split_view", 332 | "content_page", 333 | "toolbar_breakpoint", 334 | "content_header_bar", 335 | "header_bar_stack", 336 | "url_bar", 337 | "box_navigation", 338 | "button_back", 339 | "button_forward", 340 | "tab_button", 341 | "button_new_tab", 342 | "load_bar", 343 | "bottom_toolbar", 344 | "tab_overview", 345 | "tab_view", 346 | ], 347 | }, 348 | Window, 349 | ); 350 | -------------------------------------------------------------------------------- /data/icons/hicolor/scalable/apps/app.drey.Biblioteca.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 29 | 35 | 39 | 40 | 47 | 51 | 55 | 59 | 60 | 67 | 71 | 75 | 79 | 80 | 88 | 92 | 96 | 100 | 101 | 109 | 113 | 117 | 118 | 120 | 123 | 130 | 131 | 132 | 134 | 138 | 139 | 141 | 144 | 151 | 152 | 153 | 155 | 159 | 160 | 164 | 168 | 171 | 174 | 177 | 180 | 181 | 185 | 189 | 193 | 197 | 201 | 205 | 209 | 213 | 217 | 221 | 228 | 232 | 239 | 243 | 247 | 251 | 255 | 259 | 266 | 270 | 277 | 281 | 285 | 288 | 292 | 295 | 296 | 297 | 300 | 304 | 307 | 308 | 309 | 310 | -------------------------------------------------------------------------------- /data/icons/hicolor/scalable/apps/app.drey.Biblioteca.Devel.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | 676 | --------------------------------------------------------------------------------