Skip to content

Commit

Permalink
Add Nuvola Lite version
Browse files Browse the repository at this point in the history
Issue: #371

Signed-off-by: Jiří Janoušek <[email protected]>
  • Loading branch information
jiri-janousek committed Jan 14, 2018
1 parent 5844bb0 commit f10bf79
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 21 deletions.
23 changes: 18 additions & 5 deletions src/nuvolakit-runner/AppRunnerController.vala
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ public class AppRunnerController: Drtgtk.Application
private WebOptions web_options;
private WebkitOptions webkit_options;
public WebEngine web_engine {get; private set;}
public Drt.KeyValueStorage master_config {get; private set;}
public Drt.KeyValueStorage? master_config {get; private set;}
public Bindings bindings {get; private set;}
public IpcBus ipc_bus {get; private set; default=null;}
public ActionsHelper actions_helper {get; private set; default = null;}
private AppDbusApi? dbus_api = null;
private uint dbus_api_id = 0;
private GlobalKeybindings global_keybindings;
private GlobalKeybindings? global_keybindings;
private const int MINIMAL_REMEMBERED_WINDOW_SIZE = 300;
private uint configure_event_cb_id = 0;
private MenuBar menu_bar;
Expand Down Expand Up @@ -262,6 +262,7 @@ public class AppRunnerController: Drtgtk.Application
web_worker_data["RUNNER_BUS_NAME"] = bus_name;
ipc_bus = new IpcBus(bus_name);
ipc_bus.start();
#if !NUVOLA_LITE
if (use_nuvola_dbus)
{
var nuvola_api = Bus.get_proxy_sync<MasterDbusIfce>(
Expand Down Expand Up @@ -301,6 +302,7 @@ public class AppRunnerController: Drtgtk.Application
assert(bus_name != null);
ipc_bus.connect_master(bus_name, api_token);
}
#endif
}
catch (GLib.Error e)
{
Expand All @@ -318,6 +320,7 @@ public class AppRunnerController: Drtgtk.Application
ipc_bus.router.add_method(IpcApi.CORE_GET_METADATA, Drt.RpcFlags.READABLE|Drt.RpcFlags.PRIVATE,
"Get web app metadata.", handle_get_metadata, null);

#if !NUVOLA_LITE
try
{
var response = ipc_bus.master.call_sync("/nuvola/core/runner-started", new Variant("(ss)", web_app.id, ipc_bus.router.hex_token));
Expand All @@ -335,6 +338,11 @@ public class AppRunnerController: Drtgtk.Application

var storage_client = new Drt.KeyValueStorageClient(ipc_bus.master);
master_config = storage_client.get_proxy("master.config");
startup_check.nuvola_service_status = StartupCheck.Status.OK;
#else
startup_check.nuvola_service_status = StartupCheck.Status.NOT_APPLICABLE;
#endif

ipc_bus.router.add_method("/nuvola/core/get-component-info", Drt.RpcFlags.READABLE,
"Get info about component.",
handle_get_component_info, {
Expand All @@ -353,7 +361,7 @@ public class AppRunnerController: Drtgtk.Application
new Drt.DoubleParam("type", true, null, "Info bar type."),
new Drt.StringParam("name", true, false, null, "Info bar text.")
});
startup_check.nuvola_service_status = StartupCheck.Status.OK;

return true;
}

Expand Down Expand Up @@ -422,8 +430,10 @@ public class AppRunnerController: Drtgtk.Application
private void init_app_runner()
{
append_actions();
#if !NUVOLA_LITE
var gakb = new ActionsKeyBinderClient(ipc_bus.master);
global_keybindings = new GlobalKeybindings(gakb, actions);
#endif
load_extensions();
web_engine.get_main_web_view().hide();
main_window.sidebar.hide();
Expand Down Expand Up @@ -590,7 +600,8 @@ public class AppRunnerController: Drtgtk.Application
}

var dialog = new PreferencesDialog(this, main_window, form);
dialog.add_tab("Keyboard shortcuts", new KeybindingsSettings(actions, config, global_keybindings.keybinder));
dialog.add_tab("Keyboard shortcuts", new KeybindingsSettings(
actions, config, global_keybindings != null ? global_keybindings.keybinder : null));
var network_settings = new NetworkSettings(connection);
dialog.add_tab("Network", network_settings);
dialog.add_tab("Features", new ComponentsManager(this, components, tiliado_activation));
Expand Down Expand Up @@ -694,7 +705,7 @@ public class AppRunnerController: Drtgtk.Application
if (webkit_engine != null) {
components.prepend(new PasswordManagerComponent(config, ipc_bus, web_worker, web_app.id, webkit_engine));
}
components.prepend(new AudioScrobblerComponent(this, bindings, master_config, config, connection.session));
components.prepend(new AudioScrobblerComponent(this, bindings, master_config ?? config, config, connection.session));
components.prepend(new MPRISComponent(this, bindings, config));
components.prepend(new HttpRemoteControl.Component(this, bindings, config, ipc_bus));
components.prepend(new LyricsComponent(this, bindings, config));
Expand Down Expand Up @@ -795,6 +806,7 @@ public class AppRunnerController: Drtgtk.Application
if (!main_window.is_active)
return;

#if !NUVOLA_LITE
try
{
var response = ipc_bus.master.call_sync("/nuvola/core/runner-activated", new Variant("(s)", web_app.id));
Expand All @@ -804,6 +816,7 @@ public class AppRunnerController: Drtgtk.Application
{
critical("Communication with master process failed: %s", e.message);
}
#endif
}

private bool on_configure_event(Gdk.EventConfigure event)
Expand Down
6 changes: 6 additions & 0 deletions src/nuvolakit-runner/components/base/ComponentsManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ public class ComponentsManager: Gtk.Stack
grid = new Gtk.Grid();
grid.margin = 10;
grid.column_spacing = 15;
#if !NUVOLA_LITE
component_not_available_widget = Drtgtk.Labels.markup(
"Your distributor has not enabled this feature. It is available in <a href=\"%s\">the genuine flatpak "
+ "builds of Nuvola Apps Runtime</a> though.", "https://nuvola.tiliado.eu");
#else
component_not_available_widget = Drtgtk.Labels.markup(
"This feature is not yet available in Nuvola Apps <i>snap packages</i>. You may switch to <a href=\"%s\">"
+ "the genuine <i>flatpak</i> builds of Nuvola Apps Runtime</a> instead.", "https://nuvola.tiliado.eu");
#endif
membership_widget = tiliado_activation != null ? new TiliadoUserWidget(tiliado_activation, app) : null;
refresh();
var scroll = new Gtk.ScrolledWindow(null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class KeybindingsSettings : Gtk.Grid
*
* @param app Application object
*/
public KeybindingsSettings(Drtgtk.Actions actions_reg, Config config, ActionsKeyBinder global_keybindings)
public KeybindingsSettings(Drtgtk.Actions actions_reg, Config config, ActionsKeyBinder? global_keybindings)
{

this.actions_reg = actions_reg;
Expand All @@ -61,6 +61,9 @@ public class KeybindingsSettings : Gtk.Grid
info_bar.no_show_all = true;
attach(info_bar, 0, 0, 1, 1);
var info_text = "Double click a keyboard shortcut and then press a new one to change it or the backspace key to delete it.";
if (global_keybindings == null) {
info_text += "\n\nGlobal keyboard shortcuts are not available in Nuvola snap packages.";
}
var info_label = new Gtk.Label(info_text);
info_label.margin = 10;
info_label.wrap = true;
Expand Down Expand Up @@ -93,7 +96,7 @@ public class KeybindingsSettings : Gtk.Grid
accel_mods = 0;
}

keybinding = global_keybindings.get_keybinding(action.name);
keybinding = global_keybindings != null ? global_keybindings.get_keybinding(action.name) : null;
uint glob_accel_key;
Gdk.ModifierType glob_accel_mods;
if (keybinding != null)
Expand Down Expand Up @@ -122,13 +125,14 @@ public class KeybindingsSettings : Gtk.Grid
accel_cell.accel_cleared.connect(on_accel_cleared);
view.insert_column_with_attributes(-1, "Shortcut", accel_cell, "accel-key", 2, "accel-mods", 3);

accel_cell = new Gtk.CellRendererAccel();
accel_cell.editable = true;
accel_cell.accel_mode = Gtk.CellRendererAccelMode.GTK;
accel_cell.accel_edited.connect(on_glob_accel_edited);
accel_cell.accel_cleared.connect(on_glob_accel_cleared);
view.insert_column_with_attributes(-1, "Global Shortcut", accel_cell, "accel-key", 4, "accel-mods", 5);

if (global_keybindings != null) {
accel_cell = new Gtk.CellRendererAccel();
accel_cell.editable = true;
accel_cell.accel_mode = Gtk.CellRendererAccelMode.GTK;
accel_cell.accel_edited.connect(on_glob_accel_edited);
accel_cell.accel_cleared.connect(on_glob_accel_cleared);
view.insert_column_with_attributes(-1, "Global Shortcut", accel_cell, "accel-key", 4, "accel-mods", 5);
}
scroll.vexpand = scroll.hexpand = true;
scroll.add(view);
show();
Expand Down Expand Up @@ -167,6 +171,7 @@ public class KeybindingsSettings : Gtk.Grid

private void on_glob_accel_edited(string path_string, uint accel_key, Gdk.ModifierType accel_mods, uint hardware_keycode)
{
assert(global_keybindings != null);
var keybinding = Gtk.accelerator_name(accel_key, accel_mods);
var path = new Gtk.TreePath.from_string(path_string);
Gtk.TreeIter iter;
Expand All @@ -192,6 +197,7 @@ public class KeybindingsSettings : Gtk.Grid

private void on_glob_accel_cleared(string path_string)
{
assert(global_keybindings != null);
var path = new Gtk.TreePath.from_string(path_string);
Gtk.TreeIter iter;
model.get_iter(out iter, path);
Expand Down
8 changes: 8 additions & 0 deletions src/nuvolakit-runner/components/lyrics/LyricsComponent.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,26 @@ namespace Nuvola

public class LyricsComponent: Component
{
#if !NUVOLA_LITE
private Bindings bindings;
private AppRunnerController app;
private LyricsSidebar? sidebar = null;
#endif

public LyricsComponent(AppRunnerController app, Bindings bindings, Drt.KeyValueStorage config)
{
base("lyrics", "Lyrics", "Shows lyrics for the current song.");
#if !NUVOLA_LITE
this.bindings = bindings;
this.app = app;
config.bind_object_property("component.%s.".printf(id), this, "enabled").set_default(true).update_property();
auto_activate = false;
#else
available = false;
#endif
}

#if !NUVOLA_LITE
protected override bool activate()
{
SList<LyricsFetcher> fetchers = null;
Expand All @@ -57,6 +64,7 @@ public class LyricsComponent: Component
sidebar = null;
return true;
}
#endif
}

} // namespace Nuvola
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,31 @@ namespace Nuvola

public class MediaKeysComponent: Component
{
#if !NUVOLA_LITE
private Bindings bindings;
private Drtgtk.Application app;
private MediaKeysClient? media_keys = null;
private Drt.RpcChannel conn;
private string web_app_id;
#endif

public MediaKeysComponent(Drtgtk.Application app, Bindings bindings, Drt.KeyValueStorage config, Drt.RpcChannel conn, string web_app_id)
public MediaKeysComponent(Drtgtk.Application app, Bindings bindings, Drt.KeyValueStorage config, Drt.RpcChannel? conn, string web_app_id)
{
base("mediakeys", "Media keys", "Handles multimedia keys of your keyboard.");
#if !NUVOLA_LITE
assert(conn != null);
this.bindings = bindings;
this.app = app;
this.conn = conn;
this.web_app_id = web_app_id;
config.bind_object_property("component.mediakeys.", this, "enabled").set_default(true).update_property();
auto_activate = false;
#else
available = false;
#endif
}

#if !NUVOLA_LITE
protected override bool activate()
{
media_keys = new MediaKeysClient(web_app_id, conn);
Expand All @@ -59,6 +67,7 @@ public class MediaKeysComponent: Component
media_keys = null;
return true;
}
#endif
}

} // namespace Nuvola
19 changes: 13 additions & 6 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ def options(ctx):
ctx.add_option(
'--cef-default', action='store_true', default=False, dest='cef_default',
help="Whether the CEF engine should be default.")

ctx.add_option(
'--nuvola-lite', action='store_true', default=False, dest='nuvola_lite',
help="Lite version of Nuvola.")

def configure(ctx):
add_version_info(ctx)
Expand Down Expand Up @@ -300,6 +304,9 @@ def configure(ctx):
vala_def(ctx, "NUVOLA_RUNTIME")
ctx.env.UNIQUE_NAME = "eu.tiliado.Nuvola"
ctx.env.ICON_NAME = ctx.env.UNIQUE_NAME
ctx.env.NUVOLA_LITE = ctx.options.nuvola_lite
if ctx.env.NUVOLA_LITE:
vala_def(ctx, "NUVOLA_LITE")

# Flatpak
if ctx.env.FLATPAK:
Expand Down Expand Up @@ -342,13 +349,13 @@ def configure(ctx):
ctx.env.WEBKIT_MSE = ctx.options.webkit_mse
if ctx.options.webkit_mse:
vala_def(ctx, "WEBKIT_SUPPORTS_MSE")
ctx.env.with_unity = ctx.options.unity
if ctx.options.unity:
ctx.env.with_unity = ctx.options.unity and not ctx.env.NUVOLA_LITE
if ctx.env.with_unity:
pkgconfig(ctx, 'unity', 'UNITY', '3.0')
pkgconfig(ctx, 'dbusmenu-glib-0.4', 'DBUSMENU', '0.4')
vala_def(ctx, "UNITY")
ctx.env.with_appindicator = ctx.options.appindicator
if ctx.options.appindicator:
ctx.env.with_appindicator = ctx.options.appindicator and not ctx.env.NUVOLA_LITE
if ctx.env.with_appindicator:
pkgconfig(ctx, 'appindicator3-0.1', 'APPINDICATOR', '0.4')
vala_def(ctx, "APPINDICATOR")
if ctx.options.cef_default:
Expand All @@ -370,7 +377,7 @@ def configure(ctx):
ctx.env.GENUINE = genuine
if genuine:
vala_def(ctx, "GENUINE")
if any((ctx.env.GENUINE, ctx.env.CDK, ctx.env.ADK)):
if any((ctx.env.GENUINE, ctx.env.CDK, ctx.env.ADK)) and not ctx.env.NUVOLA_LITE:
vala_def(ctx, "EXPERIMENTAL")
if tiliado_api.get("enabled", False):
vala_def(ctx, "TILIADO_API")
Expand Down Expand Up @@ -486,7 +493,7 @@ def build(ctx):

ctx(features = "checkvaladefs", source = ctx.path.ant_glob('**/*.vala'),
definitions="FLATPAK TILIADO_API WEBKIT_SUPPORTS_MSE GENUINE UNITY APPINDICATOR EXPERIMENTAL NUVOLA_RUNTIME"
+ " NUVOLA_ADK NUVOLA_CDK HAVE_CEF FALSE TRUE")
+ " NUVOLA_ADK NUVOLA_CDK HAVE_CEF FALSE TRUE NUVOLA_LITE")
ctx.add_group()

valalib(
Expand Down

0 comments on commit f10bf79

Please sign in to comment.