Skip to content

Commit

Permalink
Add help URLs
Browse files Browse the repository at this point in the history
Issue: #423

Signed-off-by: Jiří Janoušek <[email protected]>
  • Loading branch information
jiri-janousek committed Aug 23, 2018
1 parent 6ac2fb3 commit c0b7713
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 23 deletions.
7 changes: 4 additions & 3 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
8 changes: 8 additions & 0 deletions src/nuvolakit-base/main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions src/nuvolakit-runner/components/base/Component.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
Expand All @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions src/nuvolakit-runner/components/base/ComponentsManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/nuvolakit-runner/components/mpris/MPRISComponent.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 10 additions & 7 deletions src/nuvolakit-runner/gui/PreferencesDialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
}
Expand Down
2 changes: 2 additions & 0 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -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", {})

Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit c0b7713

Please sign in to comment.