From c0b771337ad36f8f76790e159e21403d08ae34d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Janou=C5=A1ek?= Date: Mon, 20 Aug 2018 22:50:29 +0200 Subject: [PATCH] Add help URLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: tiliado/nuvolaruntime#423 Signed-off-by: Jiří Janoušek --- BUILD.md | 7 ++++--- src/nuvolakit-base/main.vala | 8 ++++++++ .../components/audio/AudioTweaksComponent.vala | 2 +- .../components/base/Component.vala | 7 +++++-- .../components/base/ComponentsManager.vala | 5 +++++ .../developer/DeveloperComponent.vala | 4 +++- .../HttpRemoteControlComponent.vala | 4 +++- .../components/lyrics/LyricsComponent.vala | 2 +- .../mediakeys/MediaKeysComponent.vala | 2 +- .../components/mpris/MPRISComponent.vala | 3 ++- .../notifications/NotificationsComponent.vala | 2 +- .../PasswordManagerComponent.vala | 4 +++- .../scrobbler/AudioScrobblerComponent.vala | 2 +- .../components/trayicon/TrayIconComponent.vala | 2 +- .../unity/UnityLauncherComponent.vala | 2 +- src/nuvolakit-runner/gui/PreferencesDialog.vala | 17 ++++++++++------- wscript | 2 ++ 17 files changed, 52 insertions(+), 23 deletions(-) diff --git a/BUILD.md b/BUILD.md index fc916839..f9f2ebde 100644 --- a/BUILD.md +++ b/BUILD.md @@ -15,11 +15,12 @@ branding files. A file in JSON format. All keys are optional. - * "name": The name of your Nuvola derivative, e.g. "Cloud Apps". - * "help_url": The web page to be opened when users activates a Help menu item or command. It should provide + * `"name"`: The name of your Nuvola derivative, e.g. "Cloud Apps". + * `"help_url"`: The web page to be opened when users activates a Help menu item or command. It should provide basic documentation. [Default page](https://github.com/tiliado/nuvolaplayer/wiki/Unofficial). - * "requirements_help_url": The web page to be opened when system fails to satisfy requirements of a particular app. + * `"help_url_template"`: Help URL for individual features. `{page}` is replaced with a page name. + * `"requirements_help_url"`: The web page to be opened when system fails to satisfy requirements of a particular app. It should provide information on how to install missing requirements (e.g. Adobe Flash plugin). [Default page](https://github.com/tiliado/nuvolaplayer/wiki/Web-App-Requirements). diff --git a/src/nuvolakit-base/main.vala b/src/nuvolakit-base/main.vala index f2b343bc..a002577f 100644 --- a/src/nuvolakit-base/main.vala +++ b/src/nuvolakit-base/main.vala @@ -38,6 +38,7 @@ private extern const string VERSION_SUFFIX; private extern const string LIBDIR; public extern const string HELP_URL; +public extern const string HELP_URL_TEMPLATE; public extern const string WEB_APP_REQUIREMENTS_HELP_URL; public extern const string REPOSITORY_INDEX; public extern const string REPOSITORY_ROOT; @@ -137,4 +138,11 @@ public async string? get_machine_hash() { return yield Drt.System.get_machine_id_hash("nuvolaruntime".data, GLib.ChecksumType.SHA256); } +public string? create_help_url(string? page) { + if (page == null) { + return null; + } + return page.has_prefix("https://") ? page : HELP_URL_TEMPLATE.replace("{page}", page); +} + } // namespace Nuvola diff --git a/src/nuvolakit-runner/components/audio/AudioTweaksComponent.vala b/src/nuvolakit-runner/components/audio/AudioTweaksComponent.vala index 29e89c15..91a1f30b 100644 --- a/src/nuvolakit-runner/components/audio/AudioTweaksComponent.vala +++ b/src/nuvolakit-runner/components/audio/AudioTweaksComponent.vala @@ -35,7 +35,7 @@ public class AudioTweaksComponent: Component { private HeadPhonesWatch? headphones_watch = null; public AudioTweaksComponent(AppRunnerController controller, Bindings bindings, Drt.KeyValueStorage config) { - base("audio_tweaks", "Audio Tweaks", "Tweaks for PulseAudio integration."); + base("audio_tweaks", "Audio Tweaks", "Tweaks for PulseAudio integration.", "audio_tweaks"); this.required_membership = TiliadoMembership.PREMIUM; this.has_settings = true; this.bindings = bindings; diff --git a/src/nuvolakit-runner/components/base/Component.vala b/src/nuvolakit-runner/components/base/Component.vala index 2c14434e..8c82b3f2 100644 --- a/src/nuvolakit-runner/components/base/Component.vala +++ b/src/nuvolakit-runner/components/base/Component.vala @@ -31,6 +31,7 @@ public abstract class Component: GLib.Object { public string id {get; construct;} public string name {get; construct;} public string description {get; construct;} + public string? help_url {get; construct;} public bool hidden {get; protected set; default = false;} public bool enabled {get; protected set; default = false;} public bool loaded {get; protected set; default = false;} @@ -40,8 +41,10 @@ public abstract class Component: GLib.Object { public bool available {get; protected set; default = true;} public TiliadoMembership required_membership {get; protected set; default = TiliadoMembership.NONE;} - public Component(string id, string name, string description) { - GLib.Object(id: id, name: name, description: description); + public Component(string id, string name, string description, string? help_page) { + GLib.Object( + id: id, name: name, description: description, + help_url: create_help_url(help_page)); } public bool is_membership_ok(TiliadoActivation? activation) { diff --git a/src/nuvolakit-runner/components/base/ComponentsManager.vala b/src/nuvolakit-runner/components/base/ComponentsManager.vala index 11178a4b..fef6ed7e 100644 --- a/src/nuvolakit-runner/components/base/ComponentsManager.vala +++ b/src/nuvolakit-runner/components/base/ComponentsManager.vala @@ -117,6 +117,7 @@ public class ComponentsManager : PreferencesDialog.SelectorGroup { public Panel(ComponentsManager manager, Component component) { this.component = component; this.manager = manager; + has_help = get_help_url() != null; is_toggle = true; refresh(); notify.connect_after(on_notify); @@ -160,6 +161,10 @@ public class ComponentsManager : PreferencesDialog.SelectorGroup { return component.description; } + public override unowned string? get_help_url() { + return component.help_url; + } + private void on_component_notify(GLib.Object emitter, ParamSpec param) { switch (param.name) { case "enabled": diff --git a/src/nuvolakit-runner/components/developer/DeveloperComponent.vala b/src/nuvolakit-runner/components/developer/DeveloperComponent.vala index a0a5089a..a0c5f9f1 100644 --- a/src/nuvolakit-runner/components/developer/DeveloperComponent.vala +++ b/src/nuvolakit-runner/components/developer/DeveloperComponent.vala @@ -31,7 +31,9 @@ public class DeveloperComponent: Component { private WebViewSidebar? web_view_sidebar = null; public DeveloperComponent(AppRunnerController app, Bindings bindings, Drt.KeyValueStorage config) { - base("developer", "Developer's tools", "Enables developer's sidebar "); + base( + "developer", "Developer's tools", "Enables developer's sidebar.", + "https://tiliado.github.io/nuvolaplayer/development/"); this.bindings = bindings; this.app = app; config.bind_object_property("component.%s.".printf(id), this, "enabled").set_default(false).update_property(); diff --git a/src/nuvolakit-runner/components/httpremotecontrol/HttpRemoteControlComponent.vala b/src/nuvolakit-runner/components/httpremotecontrol/HttpRemoteControlComponent.vala index 29d75b29..dd3732b0 100644 --- a/src/nuvolakit-runner/components/httpremotecontrol/HttpRemoteControlComponent.vala +++ b/src/nuvolakit-runner/components/httpremotecontrol/HttpRemoteControlComponent.vala @@ -32,7 +32,9 @@ public class Component: Nuvola.Component { #endif public Component(AppRunnerController app, Bindings bindings, Drt.KeyValueStorage config, IpcBus ipc_bus) { - base("httpremotecontrol", "Remote control over HTTP (experimental)", "Remote media player HTTP interface for control over network."); + base( + "httpremotecontrol", "Remote control over HTTP (experimental)", + "Remote media player HTTP interface for control over network.", "http_control"); this.required_membership = TiliadoMembership.PREMIUM; this.has_settings = true; #if EXPERIMENTAL diff --git a/src/nuvolakit-runner/components/lyrics/LyricsComponent.vala b/src/nuvolakit-runner/components/lyrics/LyricsComponent.vala index f8aca505..5e8c05d8 100644 --- a/src/nuvolakit-runner/components/lyrics/LyricsComponent.vala +++ b/src/nuvolakit-runner/components/lyrics/LyricsComponent.vala @@ -30,7 +30,7 @@ public class LyricsComponent: Component { private LyricsSidebar? sidebar = null; public LyricsComponent(AppRunnerController app, Bindings bindings, Drt.KeyValueStorage config) { - base("lyrics", "Lyrics", "Shows lyrics for the current song."); + base("lyrics", "Lyrics", "Shows lyrics for the current song.", "lyrics"); this.bindings = bindings; this.app = app; config.bind_object_property("component.%s.".printf(id), this, "enabled").set_default(true).update_property(); diff --git a/src/nuvolakit-runner/components/mediakeys/MediaKeysComponent.vala b/src/nuvolakit-runner/components/mediakeys/MediaKeysComponent.vala index 0ec12c8a..e3c52412 100644 --- a/src/nuvolakit-runner/components/mediakeys/MediaKeysComponent.vala +++ b/src/nuvolakit-runner/components/mediakeys/MediaKeysComponent.vala @@ -32,7 +32,7 @@ public class MediaKeysComponent: Component { private string web_app_id; public MediaKeysComponent(Drtgtk.Application app, Bindings bindings, Drt.KeyValueStorage config, IpcBus bus, string web_app_id) { - base("mediakeys", "Multimedia keys", "Handles multimedia keys of your keyboard."); + base("mediakeys", "Multimedia keys", "Handles multimedia keys of your keyboard.", "media_keys"); this.bindings = bindings; this.app = app; this.bus = bus; diff --git a/src/nuvolakit-runner/components/mpris/MPRISComponent.vala b/src/nuvolakit-runner/components/mpris/MPRISComponent.vala index 71da8e1e..c588c3b6 100644 --- a/src/nuvolakit-runner/components/mpris/MPRISComponent.vala +++ b/src/nuvolakit-runner/components/mpris/MPRISComponent.vala @@ -32,7 +32,8 @@ public class MPRISComponent: Component { public MPRISComponent(Drtgtk.Application app, Bindings bindings, Drt.KeyValueStorage config) { base( "mpris", "Media Player DBus Interface", - "Implementation of Media Player Remote Interface Specification (MPRIS 2) used by various applets."); + "Implementation of Media Player Remote Interface Specification (MPRIS 2) used by various applets.", + "mpris"); this.bindings = bindings; this.app = app; config.bind_object_property("component.mpris.", this, "enabled").set_default(true).update_property(); diff --git a/src/nuvolakit-runner/components/notifications/NotificationsComponent.vala b/src/nuvolakit-runner/components/notifications/NotificationsComponent.vala index b6325fd4..2102271f 100644 --- a/src/nuvolakit-runner/components/notifications/NotificationsComponent.vala +++ b/src/nuvolakit-runner/components/notifications/NotificationsComponent.vala @@ -32,7 +32,7 @@ public class NotificationsComponent: Component { public NotificationsComponent(AppRunnerController app, Bindings bindings, ActionsHelper actions_helper) { - base("notifications", "Notifications", "Shows desktop notifications."); + base("notifications", "Notifications", "Shows desktop notifications.", "notifications"); this.bindings = bindings; this.actions_helper = actions_helper; this.app = app; diff --git a/src/nuvolakit-runner/components/password-manager/PasswordManagerComponent.vala b/src/nuvolakit-runner/components/password-manager/PasswordManagerComponent.vala index 2519695f..c7745973 100644 --- a/src/nuvolakit-runner/components/password-manager/PasswordManagerComponent.vala +++ b/src/nuvolakit-runner/components/password-manager/PasswordManagerComponent.vala @@ -35,7 +35,9 @@ public class PasswordManagerComponent: Component { #endif public PasswordManagerComponent(Drt.KeyValueStorage config, IpcBus ipc_bus, WebWorker web_worker, string web_app_id, WebkitEngine engine) { - base("passwordmanager", "Password Manager (Experimental)", "Stores passwords from login forms in a keyring."); + base( + "passwordmanager", "Password Manager (Experimental)", + "Stores passwords from login forms in a keyring.", null); #if EXPERIMENTAL this.required_membership = TiliadoMembership.PREMIUM; this.ipc_bus = ipc_bus; diff --git a/src/nuvolakit-runner/components/scrobbler/AudioScrobblerComponent.vala b/src/nuvolakit-runner/components/scrobbler/AudioScrobblerComponent.vala index 997abf9a..137a9626 100644 --- a/src/nuvolakit-runner/components/scrobbler/AudioScrobblerComponent.vala +++ b/src/nuvolakit-runner/components/scrobbler/AudioScrobblerComponent.vala @@ -43,7 +43,7 @@ public class AudioScrobblerComponent: Component { public AudioScrobblerComponent( Drtgtk.Application app, Bindings bindings, Drt.KeyValueStorage? global_config, Drt.KeyValueStorage config, Soup.Session connection) { - base("scrobbler", "Audio Scrobbling", "Integration with an audio scrobbling service - Last FM."); + base("scrobbler", "Audio Scrobbling", "Integration with an audio scrobbling service - Last FM.", "scrobbling"); this.bindings = bindings; this.app = app; this.global_config = global_config ?? config; diff --git a/src/nuvolakit-runner/components/trayicon/TrayIconComponent.vala b/src/nuvolakit-runner/components/trayicon/TrayIconComponent.vala index c3e84e1c..aff69f6a 100644 --- a/src/nuvolakit-runner/components/trayicon/TrayIconComponent.vala +++ b/src/nuvolakit-runner/components/trayicon/TrayIconComponent.vala @@ -37,7 +37,7 @@ public class TrayIconComponent: Component { #endif public TrayIconComponent(AppRunnerController controller, Bindings bindings, Drt.KeyValueStorage config) { - base("tray_icon", "Tray Icon", "Small icon with menu shown in the notification area."); + base("tray_icon", "Tray Icon", "Small icon with menu shown in the notification area.", "tray_icon"); this.required_membership = TiliadoMembership.NONE; this.has_settings = true; #if APPINDICATOR diff --git a/src/nuvolakit-runner/components/unity/UnityLauncherComponent.vala b/src/nuvolakit-runner/components/unity/UnityLauncherComponent.vala index c8d8154e..d0015b5a 100644 --- a/src/nuvolakit-runner/components/unity/UnityLauncherComponent.vala +++ b/src/nuvolakit-runner/components/unity/UnityLauncherComponent.vala @@ -35,7 +35,7 @@ public class UnityLauncherComponent: Component { public UnityLauncherComponent(Drtgtk.Application app, Bindings bindings, Drt.KeyValueStorage config) { base( "unity_launcher", "Extra Dock Actions", - "Adds extra actions to the menu of the application icon in Unity Launcher or elementaryOS dock."); + "Adds extra actions to the menu of the application icon in Unity Launcher or elementaryOS dock.", "docks"); #if UNITY this.bindings = bindings; this.app = app; diff --git a/src/nuvolakit-runner/gui/PreferencesDialog.vala b/src/nuvolakit-runner/gui/PreferencesDialog.vala index 2ebaa3c4..986e7efb 100644 --- a/src/nuvolakit-runner/gui/PreferencesDialog.vala +++ b/src/nuvolakit-runner/gui/PreferencesDialog.vala @@ -113,15 +113,17 @@ public class PreferencesDialog : Gtk.Dialog { // Appearance groups[0].add(new SimplePanel( - "Appearance Tweaks", "Change user interface theme and window decoration preferences.", appearance)); + "Appearance Tweaks", "Change user interface theme and window decoration preferences.", + appearance, "appearance")); // Network settings groups[0].add(new SimplePanel( - "Network Proxy", "Change network proxy settings for this web app.", network_settings)); + "Network Proxy", "Change network proxy settings for this web app.", network_settings, "network")); // Keybindings groups[0].add(new SimplePanel( - "Keyboard Shortcuts", "Modify or disable in-app and global keyboard shortcuts.", keybindings)); + "Keyboard Shortcuts", "Modify or disable in-app and global keyboard shortcuts.", + keybindings, "keyboard_shortcuts")); // Web App form web_app_form.margin = 15; @@ -132,7 +134,8 @@ public class PreferencesDialog : Gtk.Dialog { scroll.add(web_app_form); scroll.show_all(); groups[0].add(new SimplePanel( - "Web App Settings", "Extra settings provided by the web app integration script.", scroll)); + "Web App Settings", "Extra settings provided by the web app integration script.", + scroll, "web_app_settings")); // Add panels var grid = new Gtk.Grid(); @@ -287,7 +290,7 @@ public class PreferencesDialog : Gtk.Dialog { private Gtk.Widget? widget; public SimplePanel( - owned string title, owned string? subtitle=null, Gtk.Widget? widget=null, string? help_url=null + owned string title, owned string? subtitle=null, Gtk.Widget? widget=null, string? help_page=null ) { this.title = (owned) title; this.subtitle = (owned) subtitle; @@ -302,8 +305,8 @@ public class PreferencesDialog : Gtk.Dialog { scroll.show(); this.widget = scroll; } - if (help_url != null) { - this.help_url = help_url; + if (help_page != null) { + this.help_url = create_help_url(help_page); has_help = true; } } diff --git a/wscript b/wscript index 07f5e878..193dfa5f 100644 --- a/wscript +++ b/wscript @@ -376,6 +376,7 @@ def configure(ctx): ctx.env.SHORT_NAME = branding.get("short_name", ctx.env.NAME) ctx.env.VENDOR = branding.get("vendor", "unknown") ctx.env.HELP_URL = branding.get("help_url", DEFAULT_HELP_URL) + ctx.env.HELP_URL_TEMPLATE = branding.get("help_url_template", "https://nuvola.tiliado.eu/docs/4/{page}.html?genuine=false") ctx.env.WEB_APP_REQUIREMENTS_HELP_URL = branding.get("requirements_help_url", DEFAULT_WEB_APP_REQUIREMENTS_HELP_URL) tiliado_api = branding.get("tiliado_api", {}) @@ -512,6 +513,7 @@ def configure(ctx): ctx.define("NUVOLA_REPOSITORY_ROOT", repo_root) ctx.define("NUVOLA_WEB_APP_REQUIREMENTS_HELP_URL", ctx.env.WEB_APP_REQUIREMENTS_HELP_URL) ctx.define("NUVOLA_HELP_URL", ctx.env.HELP_URL) + ctx.define("NUVOLA_HELP_URL_TEMPLATE", ctx.env.HELP_URL_TEMPLATE) ctx.define("NUVOLA_LIBDIR", ctx.env.NUVOLA_LIBDIR) ctx.define("NUVOLA_CEF_DEFAULT", int(ctx.options.cef_default))