diff --git a/README.md b/README.md index bb2bc598..926357b0 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,6 @@ See [this issue](https://github.com/tkashkin/GameHub/issues/156) for more inform #### Build dependencies * `meson` * `valac` -* `libgranite-dev` * `libgtk-3-dev` * `libglib2.0-dev` * `libwebkit2gtk-4.0-dev` @@ -68,7 +67,7 @@ See [this issue](https://github.com/tkashkin/GameHub/issues/156) for more inform * `libsqlite3-dev` * `libxml2-dev` * `libpolkit-gobject-1-dev` -* `libunity-dev` (optional, required for launcher icon quicklist, progress indicator and counter) +* `libunity-dev` (optional, required for launcher icon quicklist, progress indicator and counter; pass `-Duse_libunity=true` to `meson` to use) * `libmanette-0.2-dev`, `libx11-dev`, `libxtst-dev` (optional, required for gamepad support) #### Building diff --git a/debian/control.in b/debian/control.in index 1bd81235..778c51ca 100644 --- a/debian/control.in +++ b/debian/control.in @@ -5,7 +5,6 @@ Maintainer: tkashkin Build-Depends: meson (>= 0.40), valac (>= 0.16), debhelper (>= 9), - libgranite-dev, libgtk-3-dev, libglib2.0-dev, libwebkit2gtk-4.0-dev, diff --git a/flatpak/com.github.tkashkin.gamehub.json.in b/flatpak/com.github.tkashkin.gamehub.json.in index 1dc87bc4..433aa6ff 100644 --- a/flatpak/com.github.tkashkin.gamehub.json.in +++ b/flatpak/com.github.tkashkin.gamehub.json.in @@ -50,8 +50,6 @@ "--filesystem=~/.config/dconf:ro", "--env=DCONF_USER_CONFIG_DIR=.config/dconf", - "--talk-name=com.canonical.Unity", - "--filesystem=host", "--filesystem=home", "--filesystem=~/.var/app/com.valvesoftware.Steam" diff --git a/flatpak/libs/bundled/dee-1.2.7.tar.gz b/flatpak/libs/bundled/dee-1.2.7.tar.gz deleted file mode 100644 index cdbe0771..00000000 Binary files a/flatpak/libs/bundled/dee-1.2.7.tar.gz and /dev/null differ diff --git a/flatpak/libs/bundled/libdbusmenu-16.04.0.tar.gz b/flatpak/libs/bundled/libdbusmenu-16.04.0.tar.gz deleted file mode 100644 index e97d2421..00000000 Binary files a/flatpak/libs/bundled/libdbusmenu-16.04.0.tar.gz and /dev/null differ diff --git a/flatpak/libs/bundled/libunity_7.1.4+16.04.20180209.1.orig.tar.gz b/flatpak/libs/bundled/libunity_7.1.4+16.04.20180209.1.orig.tar.gz deleted file mode 100644 index e1885e5b..00000000 Binary files a/flatpak/libs/bundled/libunity_7.1.4+16.04.20180209.1.orig.tar.gz and /dev/null differ diff --git a/flatpak/libs/libs.json b/flatpak/libs/libs.json index e3d83f66..e7c97ee5 100644 --- a/flatpak/libs/libs.json +++ b/flatpak/libs/libs.json @@ -36,41 +36,6 @@ "path": "bundled/libmanette-0.2.2.tar.gz" } ] - }, - - { - "name": "libdee", - "build-options": { "cflags": "-Wno-error=misleading-indentation" }, - "sources": [ - { - "type": "archive", - "path": "bundled/dee-1.2.7.tar.gz" - } - ] - }, - { - "name": "libdbusmenu", - "config-opts": ["--enable-gtk", "--disable-dumper"], - "make-install-args": ["typelibdir=/app/lib/girepository-1.0"], - "sources": [ - { - "type": "archive", - "path": "bundled/libdbusmenu-16.04.0.tar.gz" - } - ] - }, - { - "name": "libunity", - "sources": [ - { - "type": "archive", - "path": "bundled/libunity_7.1.4+16.04.20180209.1.orig.tar.gz" - }, - { - "type": "patch", - "path": "libunity.patch" - } - ] } ] } diff --git a/flatpak/libs/libunity.patch b/flatpak/libs/libunity.patch deleted file mode 100644 index 6806cd7d..00000000 --- a/flatpak/libs/libunity.patch +++ /dev/null @@ -1,215 +0,0 @@ -From 96bf265fc11c5bf2f188caf6fc3a27d21e87a1fd Mon Sep 17 00:00:00 2001 -From: Michael Gratton -Date: Mon, 18 Mar 2019 00:24:31 +1100 -Subject: [PATCH] Fix build errors (but not warnings) with vala 0.44 - ---- - protocol/protocol-scope-interface.vala | 4 ++-- - protocol/unity-scope-proxy-remote.vala | 1 + - src/unity-aggregator-scope-private.vala | 10 +++++----- - src/unity-deprecated-scope-impl.vala | 14 +++++++------- - src/unity-scope-channel.vala | 2 +- - src/unity-scope-dbus-impl.vala | 10 +++++----- - src/unity-synchronizer.vala | 8 ++++---- - 7 files changed, 25 insertions(+), 24 deletions(-) - -diff --git a/protocol/protocol-scope-interface.vala b/protocol/protocol-scope-interface.vala -index 4d8aa48..0905037 100644 ---- a/protocol/protocol-scope-interface.vala -+++ b/protocol/protocol-scope-interface.vala -@@ -131,8 +131,8 @@ public interface ScopeService : GLib.Object - uint channel_type, - HashTable hints, - Cancellable? cancellable = null, -- out HashTable out_hints, -- BusName? sender = null) throws IOError; -+ BusName? sender = null, -+ out HashTable out_hints) throws IOError; - - public abstract async void close_channel ( - string channel_id, -diff --git a/protocol/unity-scope-proxy-remote.vala b/protocol/unity-scope-proxy-remote.vala -index 8b8125f..df7b8eb 100644 ---- a/protocol/unity-scope-proxy-remote.vala -+++ b/protocol/unity-scope-proxy-remote.vala -@@ -369,6 +369,7 @@ private class ScopeProxyRemote : GLib.Object, ScopeProxy - HashTable out_hints; - var channel_id = yield _service.open_channel ((uint) channel_type, hints, - cancellable, -+ null, - out out_hints); - Dee.Peer peer = private_channel ? - new Dee.Client (out_hints[CHANNEL_SWARM_NAME_HINT].get_string ()) : -diff --git a/src/unity-aggregator-scope-private.vala b/src/unity-aggregator-scope-private.vala -index 014efe0..5b21745 100644 ---- a/src/unity-aggregator-scope-private.vala -+++ b/src/unity-aggregator-scope-private.vala -@@ -493,13 +493,13 @@ private class AggregatorScopeImpl : GLib.Object, ScopeService, ScopeDBusImpl, - } - } - -- public void set_categories (List categories) -+ public void set_categories (List categories) - { - bool categories_model_empty = categories_model.get_n_rows () == 0; - if (!categories_model_empty) - { - // we support only appending new categories, no changes/deletes -- unowned List cats = categories; -+ unowned List cats = categories; - uint cats_length = categories.length (); - bool data_matches = cats_length >= categories_model.get_n_rows (); - -@@ -541,7 +541,7 @@ private class AggregatorScopeImpl : GLib.Object, ScopeService, ScopeDBusImpl, - } - } - -- public void set_filters (List filters) -+ public void set_filters (List filters) - { - filters_model.clear (); - -@@ -1418,8 +1418,8 @@ private class AggregatorScopeImpl : GLib.Object, ScopeService, ScopeDBusImpl, - uint channel_type, - HashTable hints, - GLib.Cancellable? cancellable, -- out HashTable out_hints, -- BusName? sender = null) throws IOError -+ BusName? sender, -+ out HashTable out_hints) throws IOError - { - Unity.AggregatorScope aggscope = owner as Unity.AggregatorScope; - -diff --git a/src/unity-deprecated-scope-impl.vala b/src/unity-deprecated-scope-impl.vala -index 52ca9c7..04e6229 100644 ---- a/src/unity-deprecated-scope-impl.vala -+++ b/src/unity-deprecated-scope-impl.vala -@@ -29,8 +29,8 @@ namespace Unity.Internal { - - private interface DeprecatedScopeDBusImpl : ScopeDBusImpl - { -- public abstract void set_categories (List categories); -- public abstract void set_filters (List filters); -+ public abstract void set_categories (List categories); -+ public abstract void set_filters (List filters); - } - /* - * The private implementation of the Scope. This makes sure that none of the -@@ -151,13 +151,13 @@ private class DeprecatedScopeImpl : GLib.Object, ScopeService, ScopeDBusImpl, De - } - } - -- public void set_categories (List categories) -+ public void set_categories (List categories) - { - bool categories_model_empty = categories_model.get_n_rows () == 0; - if (!categories_model_empty) - { - // we support only appending new categories, no changes/deletes -- unowned List cats = categories; -+ unowned List cats = categories; - uint cats_length = categories.length (); - bool data_matches = cats_length >= categories_model.get_n_rows (); - -@@ -199,7 +199,7 @@ private class DeprecatedScopeImpl : GLib.Object, ScopeService, ScopeDBusImpl, De - } - } - -- public void set_filters (List filters) -+ public void set_filters (List filters) - { - filters_model.clear (); - -@@ -609,8 +609,8 @@ private class DeprecatedScopeImpl : GLib.Object, ScopeService, ScopeDBusImpl, De - uint channel_type, - HashTable hints, - GLib.Cancellable? cancellable, -- out HashTable out_hints, -- BusName? sender) throws IOError -+ BusName? sender, -+ out HashTable out_hints) throws IOError - { - ChannelFlags flags = ChannelFlags.from_hints (hints); - var channel = new ScopeChannel ((ChannelType) channel_type); -diff --git a/src/unity-scope-channel.vala b/src/unity-scope-channel.vala -index 76c551d..1fa9df8 100644 ---- a/src/unity-scope-channel.vala -+++ b/src/unity-scope-channel.vala -@@ -140,7 +140,7 @@ internal class ScopeChannel : Object - unowned string schema; - - var vardict_schema = -- new HashTable (str_hash, str_equal); -+ new HashTable (str_hash, str_equal); - var iter = HashTableIter (optional_metadata); - while (iter.next (out field_name, out schema)) - { -diff --git a/src/unity-scope-dbus-impl.vala b/src/unity-scope-dbus-impl.vala -index 9d5524f..1f9c5a8 100644 ---- a/src/unity-scope-dbus-impl.vala -+++ b/src/unity-scope-dbus-impl.vala -@@ -232,13 +232,13 @@ private class DefaultScopeDBusImpl : GLib.Object, ScopeService, ScopeDBusImpl - } - } - -- public void set_categories (List categories) -+ public void set_categories (List categories) - { - bool categories_model_empty = categories_model.get_n_rows () == 0; - if (!categories_model_empty) - { - // we support only appending new categories, no changes/deletes -- unowned List cats = categories; -+ unowned List cats = categories; - uint cats_length = categories.length (); - bool data_matches = cats_length >= categories_model.get_n_rows (); - -@@ -277,7 +277,7 @@ private class DefaultScopeDBusImpl : GLib.Object, ScopeService, ScopeDBusImpl - new Variant.variant (this.categories)); - } - -- public void set_filters (List filters) -+ public void set_filters (List filters) - { - filters_model.clear (); - -@@ -716,8 +716,8 @@ private class DefaultScopeDBusImpl : GLib.Object, ScopeService, ScopeDBusImpl - uint channel_type, - HashTable hints, - GLib.Cancellable? cancellable, -- out HashTable out_hints, -- BusName? sender) throws IOError -+ BusName? sender, -+ out HashTable out_hints) throws IOError - { - ChannelFlags flags = ChannelFlags.from_hints (hints); - var channel = new ScopeChannel ((ChannelType) channel_type); -diff --git a/src/unity-synchronizer.vala b/src/unity-synchronizer.vala -index 60dd135..5fcf1ca 100644 ---- a/src/unity-synchronizer.vala -+++ b/src/unity-synchronizer.vala -@@ -42,8 +42,8 @@ internal class ResultsSynchronizer : GLib.Object, MergeStrategy - private HashTable _provider_ids; - // need unowned getter, so no Gee - private HashTable _provider_signal_ids; -- private HashTable> _provider_tags; -- private HashTable> _clear_seqnum_tags; -+ private HashTable> _provider_tags; -+ private HashTable> _clear_seqnum_tags; - private Variant[] row_buf = new Variant[9]; - private Quark scope_id_quark = Quark.from_string ("scope-id"); - private uint _clear_seq_num = 1; -@@ -58,8 +58,8 @@ internal class ResultsSynchronizer : GLib.Object, MergeStrategy - _providers = new HashTable (null, null); - _provider_ids = new HashTable (str_hash, str_equal); - _provider_signal_ids = new HashTable (null, null); -- _provider_tags = new HashTable (null, null); -- _clear_seqnum_tags = new HashTable (null, null); -+ _provider_tags = new HashTable> (null, null); -+ _clear_seqnum_tags = new HashTable> (null, null); - merge_strategy = this; - } - --- -libgit2 0.26.0 - diff --git a/po/POTFILES b/po/POTFILES index 3c94f66e..221be805 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -87,6 +87,12 @@ src/ui/widgets/CompatToolOptions.vala src/ui/widgets/CompatToolPicker.vala src/ui/widgets/GameTagsList.vala src/ui/widgets/TagRow.vala +src/ui/widgets/Styles.vala +src/ui/widgets/AlertView.vala +src/ui/widgets/ModeButton.vala +src/ui/widgets/OverlayBar.vala +src/ui/widgets/Welcome.vala +src/ui/widgets/SettingsSidebar.vala src/utils/Utils.vala src/utils/ImageCache.vala src/utils/FSUtils.vala @@ -94,6 +100,7 @@ src/utils/FSOverlay.vala src/utils/Parser.vala src/utils/downloader/Downloader.vala src/utils/downloader/SoupDownloader.vala +src/settings/Settings.vala src/settings/UI.vala src/settings/SavedState.vala src/settings/Auth.vala diff --git a/scripts/build.sh b/scripts/build.sh index e12e83d9..dcaba797 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -102,7 +102,7 @@ deps() sudo DEBIAN_FRONTEND="noninteractive" add-apt-repository ppa:elementary-os/daily -y sudo DEBIAN_FRONTEND="noninteractive" add-apt-repository ppa:vala-team/next -y sudo DEBIAN_FRONTEND="noninteractive" apt update -qq - sudo DEBIAN_FRONTEND="noninteractive" apt install -y meson valac checkinstall build-essential dput fakeroot moreutils git-buildpackage elementary-sdk libgranite-dev libgtk-3-dev libglib2.0-dev libwebkit2gtk-4.0-dev libjson-glib-dev libgee-0.8-dev libsoup2.4-dev libsqlite3-dev libxml2-dev libpolkit-gobject-1-dev + sudo DEBIAN_FRONTEND="noninteractive" apt install -y meson valac checkinstall build-essential dput fakeroot moreutils git-buildpackage elementary-sdk libgtk-3-dev libglib2.0-dev libwebkit2gtk-4.0-dev libjson-glib-dev libgee-0.8-dev libsoup2.4-dev libsqlite3-dev libxml2-dev libpolkit-gobject-1-dev #sudo apt full-upgrade -y if [[ "$APPVEYOR_BUILD_WORKER_IMAGE" = "Ubuntu1604" ]]; then sudo DEBIAN_FRONTEND="noninteractive" dpkg -i "$_SCRIPTROOT/deps/xenial/"*.deb @@ -279,7 +279,7 @@ appimage_checkrt() _mv_deps "libgtk-3.so.0" "$APPDIR/usr/lib" "$APPDIR/usr/optlib/libgtk-3.so.0/" echo "[scripts/build.sh] Moving back non-GTK-specific dependencies" - find "$APPDIR/usr/lib/" -maxdepth 1 -type f -not -name "libgranite.so.*" -not -name "libwebkit2gtk-4.0.so.*" -print0 | while read -d $'\0' dep; do + find "$APPDIR/usr/lib/" -maxdepth 1 -type f -not -name "libwebkit2gtk-4.0.so.*" -print0 | while read -d $'\0' dep; do _mv_deps "$(basename $dep)" "$APPDIR/usr/optlib/libgtk-3.so.0" "$APPDIR/usr/lib/" "false" done diff --git a/src/app.vala b/src/app.vala index 77053181..77f7560b 100644 --- a/src/app.vala +++ b/src/app.vala @@ -19,7 +19,6 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; using GameHub.Data; using GameHub.Data.DB; @@ -226,7 +225,7 @@ namespace GameHub var app = new Application(); - Utils.Logger.initialize("GameHub"); + Utils.Logger.init(); var lang = Environment.get_variable("LC_ALL") ?? ""; Intl.setlocale(LocaleCategory.ALL, lang); @@ -293,7 +292,7 @@ namespace GameHub return true; } - Granite.Services.Logger.DisplayLevel = opt_debug_log ? Granite.Services.LogLevel.DEBUG : Granite.Services.LogLevel.INFO; + Logger.DisplayLevel = opt_debug_log ? Logger.LogLevel.DEBUG : Logger.LogLevel.INFO; if(opt_gdb || opt_gdb_bt_full || opt_gdb_fatal_criticals) { @@ -362,7 +361,7 @@ namespace GameHub warning(e.message); } - Granite.Services.Logger.DisplayLevel = opt_debug_log ? Granite.Services.LogLevel.DEBUG : Granite.Services.LogLevel.INFO; + Logger.DisplayLevel = opt_debug_log ? Logger.LogLevel.DEBUG : Logger.LogLevel.INFO; init(); diff --git a/src/data/Game.vala b/src/data/Game.vala index 59c2367f..5d7bbae4 100644 --- a/src/data/Game.vala +++ b/src/data/Game.vala @@ -497,11 +497,18 @@ namespace GameHub.Data } else { - FSUtils.mv_up(game.install_dir, @"$(FSUtils.GAMEHUB_DIR)/$(FSUtils.OVERLAYS_DIR)/$(BASE)"); - game.overlays.clear(); - game.install_dir.get_child(FSUtils.GAMEHUB_DIR).get_child(FSUtils.OVERLAYS_DIR).get_child(FSUtils.OVERLAYS_LIST).delete(); - game.install_dir.get_child(FSUtils.GAMEHUB_DIR).get_child(FSUtils.OVERLAYS_DIR).delete(); - game.notify_property("overlays-enabled"); + try + { + FSUtils.mv_up(game.install_dir, @"$(FSUtils.GAMEHUB_DIR)/$(FSUtils.OVERLAYS_DIR)/$(BASE)"); + game.overlays.clear(); + game.install_dir.get_child(FSUtils.GAMEHUB_DIR).get_child(FSUtils.OVERLAYS_DIR).get_child(FSUtils.OVERLAYS_LIST).delete(); + game.install_dir.get_child(FSUtils.GAMEHUB_DIR).get_child(FSUtils.OVERLAYS_DIR).delete(); + game.notify_property("overlays-enabled"); + } + catch(Error e) + { + warning("[Game.Overlay.remove] %s", e.message); + } } }); } diff --git a/src/data/adapters/GamesAdapter.vala b/src/data/adapters/GamesAdapter.vala index 9506a88c..e775f58a 100644 --- a/src/data/adapters/GamesAdapter.vala +++ b/src/data/adapters/GamesAdapter.vala @@ -22,6 +22,7 @@ using GameHub.Data.DB; using GameHub.Utils; using GameHub.Settings; +using GameHub.UI.Widgets; using GameHub.UI.Views.GamesView; namespace GameHub.Data.Adapters @@ -364,8 +365,7 @@ namespace GameHub.Data.Adapters if(prev_item != null && f == pf && (f || s == ps)) row.set_header(null); else { - var label = new Granite.HeaderLabel(f ? C_("status_header", "Favorites") : item.game.status.header); - label.get_style_context().add_class("games-list-header"); + var label = Styled.H4Label(f ? C_("status_header", "Favorites") : item.game.status.header, "games-list-header"); list.size_allocate.connect(alloc => { label.set_size_request(alloc.width, -1); }); diff --git a/src/data/providers/data/IGDB.vala b/src/data/providers/data/IGDB.vala index 247958f3..658e3c4d 100644 --- a/src/data/providers/data/IGDB.vala +++ b/src/data/providers/data/IGDB.vala @@ -372,7 +372,7 @@ namespace GameHub.Data.Providers.Data desc_src_label.valign = Gtk.Align.CENTER; desc_src_label.hexpand = true; - var desc_src = new Granite.Widgets.ModeButton(); + var desc_src = new GameHub.UI.Widgets.ModeButton(); desc_src.homogeneous = false; desc_src.append_text(C_("igdb_preferred_description", "of game")); desc_src.append_text(C_("igdb_preferred_description", "from IGDB")); diff --git a/src/meson.build b/src/meson.build index 9e2b73f4..2e0313b4 100644 --- a/src/meson.build +++ b/src/meson.build @@ -23,7 +23,6 @@ project_config = vcs_tag( ) deps = [ - dependency('granite', version: '>=5.2.0'), dependency('gdk-3.0'), dependency('webkit2gtk-4.0'), dependency('glib-2.0'), @@ -142,6 +141,12 @@ sources = [ 'ui/widgets/CompatToolPicker.vala', 'ui/widgets/GameTagsList.vala', 'ui/widgets/TagRow.vala', + 'ui/widgets/Styles.vala', + 'ui/widgets/AlertView.vala', + 'ui/widgets/ModeButton.vala', + 'ui/widgets/OverlayBar.vala', + 'ui/widgets/Welcome.vala', + 'ui/widgets/SettingsSidebar.vala', 'utils/Utils.vala', 'utils/ImageCache.vala', @@ -150,6 +155,7 @@ sources = [ 'utils/Parser.vala', 'utils/BinaryVDF.vala', + 'settings/Settings.vala', 'settings/UI.vala', 'settings/SavedState.vala', 'settings/Auth.vala', diff --git a/src/settings/Auth.vala b/src/settings/Auth.vala index ebd11217..ab9a7fe4 100644 --- a/src/settings/Auth.vala +++ b/src/settings/Auth.vala @@ -16,11 +16,9 @@ You should have received a copy of the GNU General Public License along with GameHub. If not, see . */ -using Granite; - namespace GameHub.Settings.Auth { - public class Steam: Granite.Services.Settings + public class Steam: SettingsSchema { public bool enabled { get; set; } public bool authenticated { get; set; } @@ -58,7 +56,7 @@ namespace GameHub.Settings.Auth } } - public class GOG: Granite.Services.Settings + public class GOG: SettingsSchema { public bool enabled { get; set; } public bool authenticated { get; set; } @@ -84,7 +82,7 @@ namespace GameHub.Settings.Auth } } - public class Humble: Granite.Services.Settings + public class Humble: SettingsSchema { public bool enabled { get; set; } public bool authenticated { get; set; } diff --git a/src/settings/Compat.vala b/src/settings/Compat.vala index 4feeddbd..1e0d78db 100644 --- a/src/settings/Compat.vala +++ b/src/settings/Compat.vala @@ -16,11 +16,11 @@ You should have received a copy of the GNU General Public License along with GameHub. If not, see . */ -using Granite; + namespace GameHub.Settings.Compat { - public class RetroArch: Granite.Services.Settings + public class RetroArch: SettingsSchema { public string core_dir { get; set; } public string core_info_dir { get; set; } diff --git a/src/settings/Controller.vala b/src/settings/Controller.vala index b4737cf5..5a9c92e6 100644 --- a/src/settings/Controller.vala +++ b/src/settings/Controller.vala @@ -16,11 +16,11 @@ You should have received a copy of the GNU General Public License along with GameHub. If not, see . */ -using Granite; + namespace GameHub.Settings { - public class Controller: Granite.Services.Settings + public class Controller: SettingsSchema { public bool enabled { get; set; } public bool focus_window { get; set; } diff --git a/src/settings/Providers.vala b/src/settings/Providers.vala index eb48bd25..a0080679 100644 --- a/src/settings/Providers.vala +++ b/src/settings/Providers.vala @@ -16,13 +16,13 @@ You should have received a copy of the GNU General Public License along with GameHub. If not, see . */ -using Granite; + namespace GameHub.Settings.Providers { namespace Images { - public class SteamGridDB: Granite.Services.Settings + public class SteamGridDB: SettingsSchema { public bool enabled { get; set; } public string api_key { get; set; } @@ -59,7 +59,7 @@ namespace GameHub.Settings.Providers } } - public class JinxSGVI: Granite.Services.Settings + public class JinxSGVI: SettingsSchema { public bool enabled { get; set; } @@ -85,7 +85,7 @@ namespace GameHub.Settings.Providers namespace Data { - public class IGDB: Granite.Services.Settings + public class IGDB: SettingsSchema { public bool enabled { get; set; } public string api_key { get; set; } diff --git a/src/settings/SavedState.vala b/src/settings/SavedState.vala index 52939d8b..d9916acc 100644 --- a/src/settings/SavedState.vala +++ b/src/settings/SavedState.vala @@ -16,11 +16,11 @@ You should have received a copy of the GNU General Public License along with GameHub. If not, see . */ -using Granite; + namespace GameHub.Settings.SavedState { - public class Window: Granite.Services.Settings + public class Window: SettingsSchema { public int width { get; set; } public int height { get; set; } @@ -52,7 +52,7 @@ namespace GameHub.Settings.SavedState } } - public class GamesView: Granite.Services.Settings + public class GamesView: SettingsSchema { public GamesView.Style style { get; set; } public GamesView.SortMode sort_mode { get; set; } diff --git a/src/settings/Settings.vala b/src/settings/Settings.vala new file mode 100644 index 00000000..0ad3e538 --- /dev/null +++ b/src/settings/Settings.vala @@ -0,0 +1,228 @@ +/* +This file is part of GameHub. +Copyright(C) 2018-2019 Anatoliy Kashkin + +GameHub is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GameHub is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GameHub. If not, see . +*/ + +/* Based on Granite.Services.Settings */ + +namespace GameHub.Settings +{ + public abstract class SettingsSchema: Object + { + bool saving_key; + [Signal(no_recurse = true, run = "first", action = true, no_hooks = true, detailed = true)] + public signal void changed(); + + public GLib.Settings schema { get; construct; } + + protected SettingsSchema(string schema) + { + Object(schema: new GLib.Settings(schema)); + } + + construct + { + debug("Loading settings from schema '%s'", schema.schema_id); + + var obj_class = (ObjectClass) get_type().class_ref(); + var properties = obj_class.list_properties(); + foreach(var prop in properties) + load_key(prop.name); + + start_monitor(); + } + + ~SettingsSchema() + { + stop_monitor(); + } + + private void stop_monitor() + { + schema.changed.disconnect(load_key); + } + + private void start_monitor() + { + schema.changed.connect(load_key); + } + + void handle_notify(Object sender, ParamSpec property) + { + notify.disconnect(handle_notify); + call_verify(property.name); + notify.connect(handle_notify); + save_key(property.name); + } + + void handle_verify_notify(Object sender, ParamSpec property) + { + warning("Key '%s' failed verification in schema '%s', changing value", property.name, schema.schema_id); + } + + private void call_verify(string key) + { + notify.connect(handle_verify_notify); + verify(key); + changed[key](); + notify.disconnect(handle_verify_notify); + } + + protected virtual void verify(string key){} + + private void load_key(string key) + { + if(key == "schema") return; + + var obj_class = (ObjectClass) get_type().class_ref(); + var prop = obj_class.find_property(key); + + if(prop == null) + return; + + notify.disconnect(handle_notify); + + var type = prop.value_type; + var val = Value(type); + this.get_property(prop.name, ref val); + + if(val.type() == prop.value_type) + { + if(type == typeof(int)) + set_property(prop.name, schema.get_int(key)); + else if(type == typeof(uint)) + set_property(prop.name, schema.get_uint(key)); + else if(type == typeof(double)) + set_property(prop.name, schema.get_double(key)); + else if(type == typeof(string)) + set_property(prop.name, schema.get_string(key)); + else if(type == typeof(string[])) + set_property(prop.name, schema.get_strv(key)); + else if(type == typeof(bool)) + set_property(prop.name, schema.get_boolean(key)); + else if(type == typeof(int64)) + set_property(prop.name, schema.get_value(key).get_int64()); + else if(type == typeof(uint64)) + set_property(prop.name, schema.get_value(key).get_uint64()); + else if(type.is_enum()) + set_property(prop.name, schema.get_enum(key)); + } + else + { + debug("Unsupported settings type '%s' for key '%s' in schema '%s'", type.name(), key, schema.schema_id); + notify.connect(handle_notify); + return; + } + + call_verify(key); + notify.connect(handle_notify); + } + + void save_key(string key) + { + if(key == "schema" || saving_key) return; + + var obj_class = (ObjectClass) get_type().class_ref(); + var prop = obj_class.find_property(key); + + if(prop == null) return; + + bool success = true; + + saving_key = true; + notify.disconnect(handle_notify); + + var type = prop.value_type; + var val = Value(type); + this.get_property(prop.name, ref val); + + if(val.type() == prop.value_type) + { + if(type == typeof(int)) + { + if(val.get_int() != schema.get_int(key)) + { + success = schema.set_int(key, val.get_int()); + } + } + else if(type == typeof(uint)) + { + if(val.get_uint() != schema.get_uint(key)) + { + success = schema.set_uint(key, val.get_uint()); + } + } + else if(type == typeof(int64)) + { + if(val.get_int64() != schema.get_value(key).get_int64()) + { + success = schema.set_value(key, new Variant.int64(val.get_int64())); + } + } + else if(type == typeof(uint64)) + { + if(val.get_uint64() != schema.get_value(key).get_uint64()) + { + success = schema.set_value(key, new Variant.uint64(val.get_uint64())); + } + } + else if(type == typeof(double)) + { + if(val.get_double() != schema.get_double(key)) + { + success = schema.set_double(key, val.get_double()); + } + } + else if(type == typeof(string)) + { + if(val.get_string() != schema.get_string(key)) + { + success = schema.set_string(key, val.get_string()); + } + } + else if(type == typeof(string[])) + { + string[] strings = null; + this.get(key, &strings); + if(strings != schema.get_strv(key)) + { + success = schema.set_strv(key, strings); + } + } + else if(type == typeof(bool)) + { + if(val.get_boolean() != schema.get_boolean(key)) + { + success = schema.set_boolean(key, val.get_boolean()); + } + } + else if(type.is_enum()) + { + if(val.get_enum() != schema.get_enum(key)) + { + success = schema.set_enum(key, val.get_enum()); + } + } + } + else debug("Unsupported settings type '%s' for key '%s' in schema '%s'", type.name(), key, schema.schema_id); + + if(!success) warning("Key '%s' could not be written to.", key); + + notify.connect(handle_notify); + saving_key = false; + } + } +} diff --git a/src/settings/UI.vala b/src/settings/UI.vala index de525eaf..f6e483e7 100644 --- a/src/settings/UI.vala +++ b/src/settings/UI.vala @@ -17,11 +17,11 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; + namespace GameHub.Settings.UI { - public class Appearance: Granite.Services.Settings + public class Appearance: SettingsSchema { public const string[] COLORED_ICONS_THEMES = { "elementary" }; @@ -99,7 +99,7 @@ namespace GameHub.Settings.UI } } - public class Behavior: Granite.Services.Settings + public class Behavior: SettingsSchema { public bool grid_doubleclick { get; set; } public bool merge_games { get; set; } diff --git a/src/ui/dialogs/CompatRunDialog.vala b/src/ui/dialogs/CompatRunDialog.vala index 7787e6a7..eac9b546 100644 --- a/src/ui/dialogs/CompatRunDialog.vala +++ b/src/ui/dialogs/CompatRunDialog.vala @@ -18,7 +18,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; -using Granite; + using GLib; using Gee; using GameHub.Utils; @@ -60,12 +60,11 @@ namespace GameHub.UI.Dialogs content = new Box(Orientation.VERTICAL, 0); - title_label = new Label(game.name); + title_label = Styled.H2Label(game.name); title_label.margin_start = 4; title_label.halign = Align.START; title_label.valign = Align.START; title_label.hexpand = true; - title_label.get_style_context().add_class(Granite.STYLE_CLASS_H2_LABEL); content.add(title_label); compat_tool_picker = new CompatToolPicker(game, false); diff --git a/src/ui/dialogs/CorruptedInstallerDialog.vala b/src/ui/dialogs/CorruptedInstallerDialog.vala index ded8420c..ad211a6b 100644 --- a/src/ui/dialogs/CorruptedInstallerDialog.vala +++ b/src/ui/dialogs/CorruptedInstallerDialog.vala @@ -18,7 +18,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; -using Granite; + using GLib; using Gee; using GameHub.Utils; @@ -61,12 +61,11 @@ namespace GameHub.UI.Dialogs content = new Box(Orientation.VERTICAL, 0); content.margin_bottom = 8; - title_label = new Label(game.name); + title_label = Styled.H2Label(game.name); title_label.margin_start = 8; title_label.halign = Align.START; title_label.valign = Align.START; title_label.hexpand = true; - title_label.get_style_context().add_class(Granite.STYLE_CLASS_H2_LABEL); content.add(title_label); subtitle_label = new Label(_("Corrupted installer: checksum mismatch in")); diff --git a/src/ui/dialogs/GameDetailsDialog.vala b/src/ui/dialogs/GameDetailsDialog.vala index 05ee31ff..8992514b 100644 --- a/src/ui/dialogs/GameDetailsDialog.vala +++ b/src/ui/dialogs/GameDetailsDialog.vala @@ -18,7 +18,7 @@ along with GameHub. If not, see . using Gtk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Utils; diff --git a/src/ui/dialogs/GameFSOverlaysDialog.vala b/src/ui/dialogs/GameFSOverlaysDialog.vala index 2593f904..35270da0 100644 --- a/src/ui/dialogs/GameFSOverlaysDialog.vala +++ b/src/ui/dialogs/GameFSOverlaysDialog.vala @@ -19,7 +19,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Data.DB; @@ -37,7 +37,7 @@ namespace GameHub.UI.Dialogs private Stack stack; private Box disabled_box; - private Granite.Widgets.AlertView disabled_alert; + private AlertView disabled_alert; private Button enable_btn; private Box content; @@ -68,13 +68,13 @@ namespace GameHub.UI.Dialogs disabled_box = new Box(Orientation.VERTICAL, 0); - disabled_alert = new Granite.Widgets.AlertView(_("Overlays are disabled"), _("Enable overlays to manage DLCs and mods\n\nEnabling will move game to the “base“ overlay"), "dialog-information"); + disabled_alert = new AlertView(_("Overlays are disabled"), _("Enable overlays to manage DLCs and mods\n\nEnabling will move game to the “base“ overlay"), "dialog-information"); disabled_alert.get_style_context().remove_class(Gtk.STYLE_CLASS_VIEW); disabled_alert.halign = Align.START; disabled_box.add(disabled_alert); - var overlays_header = new HeaderLabel(_("Overlays")); + var overlays_header = Styled.H4Label(_("Overlays")); overlays_header.xpad = 8; content.add(overlays_header); diff --git a/src/ui/dialogs/GamePropertiesDialog.vala b/src/ui/dialogs/GamePropertiesDialog.vala index 90fbfe3e..99677c0c 100644 --- a/src/ui/dialogs/GamePropertiesDialog.vala +++ b/src/ui/dialogs/GamePropertiesDialog.vala @@ -19,7 +19,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Data.DB; @@ -59,7 +59,7 @@ namespace GameHub.UI.Dialogs properties_box = new Box(Orientation.VERTICAL, 0); - var name_header = new HeaderLabel(_("Name")); + var name_header = Styled.H4Label(_("Name")); name_header.xpad = 8; properties_box.add(name_header); @@ -78,15 +78,11 @@ namespace GameHub.UI.Dialogs game.save(); }); - var images_header = new HeaderLabel(_("Images")); + var images_header = Styled.H4Label(_("Images")); images_header.xpad = 8; properties_box.add(images_header); - var images_card = new Frame(null); - images_card.get_style_context().add_class(Granite.STYLE_CLASS_CARD); - images_card.get_style_context().add_class("gamecard"); - images_card.get_style_context().add_class("static"); - images_card.shadow_type = ShadowType.NONE; + var images_card = Styled.Card("gamecard", "static"); images_card.margin = 4; icon_view = new AutoSizeImage(); @@ -144,7 +140,7 @@ namespace GameHub.UI.Dialogs if(!(game is Data.Sources.Steam.SteamGame) && game.install_dir != null && game.install_dir.query_exists()) { - var executable_header = new HeaderLabel(_("Executable")); + var executable_header = Styled.H4Label(_("Executable")); executable_header.xpad = 8; properties_box.add(executable_header); @@ -180,7 +176,7 @@ namespace GameHub.UI.Dialogs properties_box.add(args_entry); - var compat_header = new HeaderLabel(_("Compatibility")); + var compat_header = Styled.H4Label(_("Compatibility")); compat_header.no_show_all = true; compat_header.xpad = 8; properties_box.add(compat_header); @@ -202,7 +198,7 @@ namespace GameHub.UI.Dialogs game.notify_property("use-compat"); } - var gh_run_args_header = new HeaderLabel(_("Launch from terminal")); + var gh_run_args_header = Styled.H4Label(_("Launch from terminal")); gh_run_args_header.xpad = 8; properties_box.add(gh_run_args_header); diff --git a/src/ui/dialogs/ImportEmulatedGamesDialog.vala b/src/ui/dialogs/ImportEmulatedGamesDialog.vala index a8344a4b..d2eee873 100644 --- a/src/ui/dialogs/ImportEmulatedGamesDialog.vala +++ b/src/ui/dialogs/ImportEmulatedGamesDialog.vala @@ -18,7 +18,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; -using Granite; + using GLib; using Gee; using GameHub.Utils; @@ -77,10 +77,10 @@ namespace GameHub.UI.Dialogs dir_chooser.file_set.connect(start_search); - dir_hbox.add(new HeaderLabel(_("Directory"))); + dir_hbox.add(Styled.H4Label(_("Directory"))); dir_hbox.add(dir_chooser); - var header_label = new HeaderLabel(_("Detected games")); + var header_label = Styled.H4Label(_("Detected games")); header_label.margin_start = header_label.margin_end = 8; header_label.xalign = 0; header_label.hexpand = true; @@ -554,7 +554,7 @@ namespace GameHub.UI.Dialogs { if(prev == null || prev.game.parent_directory.get_path() != game.parent_directory.get_path()) { - var header = new HeaderLabel(game.parent_directory.get_path()); + var header = Styled.H4Label(game.parent_directory.get_path()); header.margin_end = 8; header.ellipsize = Pango.EllipsizeMode.START; header.tooltip_text = header.label; diff --git a/src/ui/dialogs/InstallDialog.vala b/src/ui/dialogs/InstallDialog.vala index 4695f598..f8f2b21e 100644 --- a/src/ui/dialogs/InstallDialog.vala +++ b/src/ui/dialogs/InstallDialog.vala @@ -42,7 +42,7 @@ namespace GameHub.UI.Dialogs private Label title_label; private Label subtitle_label; - private Granite.Widgets.ModeButton platforms_list; + private ModeButton platforms_list; private ListBox installers_list; private bool is_finished = false; @@ -73,13 +73,12 @@ namespace GameHub.UI.Dialogs content = new Box(Orientation.VERTICAL, 0); - title_label = new Label(null); + title_label = Styled.H2Label(null); title_label.margin_start = title_label.margin_end = 4; title_label.halign = Align.START; title_label.xalign = 0; title_label.wrap = true; title_label.max_width_chars = 36; - title_label.get_style_context().add_class(Granite.STYLE_CLASS_H2_LABEL); var subtitle_hbox = new Box(Orientation.HORIZONTAL, 8); @@ -123,7 +122,7 @@ namespace GameHub.UI.Dialogs bbox.set_child_non_homogeneous(import_btn, true); } - platforms_list = new Granite.Widgets.ModeButton(); + platforms_list = new ModeButton(); platforms_list.get_style_context().add_class("installer-platforms-list"); platforms_list.halign = Align.END; platforms_list.valign = Align.CENTER; diff --git a/src/ui/dialogs/SettingsDialog/SettingsDialog.vala b/src/ui/dialogs/SettingsDialog/SettingsDialog.vala index 5eb8b5c3..cf19e09b 100644 --- a/src/ui/dialogs/SettingsDialog/SettingsDialog.vala +++ b/src/ui/dialogs/SettingsDialog/SettingsDialog.vala @@ -17,7 +17,8 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; +using GameHub.UI.Widgets; + using GameHub.Utils; namespace GameHub.UI.Dialogs.SettingsDialog @@ -132,7 +133,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog }); } - private void add_page(string id, SettingsPage page) + private void add_page(string id, SettingsSidebar.SettingsPage page) { pages.add_named(page, id); } diff --git a/src/ui/dialogs/SettingsDialog/SettingsDialogPage.vala b/src/ui/dialogs/SettingsDialog/SettingsDialogPage.vala index 1b36f3fb..7ff1ed25 100644 --- a/src/ui/dialogs/SettingsDialog/SettingsDialogPage.vala +++ b/src/ui/dialogs/SettingsDialog/SettingsDialogPage.vala @@ -17,14 +17,13 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; +using GameHub.UI.Widgets; using GameHub.Utils; -using GameHub.UI.Widgets; namespace GameHub.UI.Dialogs.SettingsDialog { - public abstract class SettingsDialogPage: SimpleSettingsPage + public abstract class SettingsDialogPage: SettingsSidebar.SimpleSettingsPage { public SettingsDialog dialog { construct; protected get; } @@ -40,7 +39,6 @@ namespace GameHub.UI.Dialogs.SettingsDialog construct { - //margin_start = margin_end = 8; content_area.orientation = Orientation.VERTICAL; content_area.row_spacing = 0; @@ -158,26 +156,15 @@ namespace GameHub.UI.Dialogs.SettingsDialog return add_widget(hbox); } - protected HeaderLabel add_header(string text) + protected Label add_header(string text) { - var label = new HeaderLabel(text); + var label = Styled.H4Label(text); label.xpad = 4; label.halign = Align.START; label.hexpand = true; return add_widget(label); } - protected CheckButton add_header_with_checkbox(string text, bool enabled, owned SwitchAction action) - { - var cb = new CheckButton.with_label(text); - cb.active = enabled; - cb.halign = Align.START; - cb.hexpand = true; - cb.notify["active"].connect(() => { action(cb.active); }); - cb.get_style_context().add_class(Granite.STYLE_CLASS_H4_LABEL); - return add_widget(cb); - } - protected LinkButton add_link(string text, string uri) { var link = new LinkButton.with_label(uri, text); @@ -211,7 +198,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog protected T add_widget(T widget) { - if(!(widget is HeaderLabel)) + if(!((widget as Widget).get_style_context().has_class(StyleClass.Label.H4))) { (widget as Widget).margin = 4; (widget as Widget).margin_end = 0; diff --git a/src/ui/dialogs/SettingsDialog/pages/About.vala b/src/ui/dialogs/SettingsDialog/pages/About.vala index 0497d476..0bb305f1 100644 --- a/src/ui/dialogs/SettingsDialog/pages/About.vala +++ b/src/ui/dialogs/SettingsDialog/pages/About.vala @@ -17,12 +17,13 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; +using GameHub.UI.Widgets; + using GameHub.Utils; namespace GameHub.UI.Dialogs.SettingsDialog.Pages { - public class About: SettingsPage + public class About: SettingsSidebar.SettingsPage { private Settings.UI.Appearance ui_settings; @@ -57,10 +58,9 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Pages appinfo_grid.row_spacing = 0; appinfo_grid.column_spacing = 8; - var app_title = new Label("GameHub"); + var app_title = Styled.H2Label("GameHub"); app_title.hexpand = true; app_title.xalign = 0; - app_title.get_style_context().add_class(Granite.STYLE_CLASS_H2_LABEL); var app_version = new Label(ProjectConfig.VERSION); app_version.hexpand = true; @@ -75,11 +75,10 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Pages app_info_copy.clicked.connect(copy_app_info); - var app_subtitle = new Label(_("All your games in one place")); + var app_subtitle = Styled.H3Label(_("All your games in one place")); app_subtitle.margin_top = 4; app_subtitle.hexpand = true; app_subtitle.xalign = 0; - app_subtitle.get_style_context().add_class(Granite.STYLE_CLASS_H3_LABEL); appinfo_grid.attach(app_title, 0, 0); appinfo_grid.attach(app_version, 0, 1); diff --git a/src/ui/dialogs/SettingsDialog/pages/emulators/Emulators.vala b/src/ui/dialogs/SettingsDialog/pages/emulators/Emulators.vala index 5f989a31..8e62b2e7 100644 --- a/src/ui/dialogs/SettingsDialog/pages/emulators/Emulators.vala +++ b/src/ui/dialogs/SettingsDialog/pages/emulators/Emulators.vala @@ -17,7 +17,7 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; + using GameHub.Data; using GameHub.Utils; @@ -28,7 +28,7 @@ using GameHub.Data.DB; namespace GameHub.UI.Dialogs.SettingsDialog.Pages.Emulators { - public class Emulators: SettingsPage + public class Emulators: SettingsSidebar.SettingsPage { public SettingsDialog dialog { construct; protected get; } @@ -194,7 +194,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Pages.Emulators private Grid grid; private int rows = 0; - private Granite.Widgets.ModeButton mode; + private ModeButton mode; private new Entry name; private FileChooserEntry emudir; @@ -245,7 +245,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Pages.Emulators run_btn.valign = Align.END; run_btn.sensitive = false; - mode = new Granite.Widgets.ModeButton(); + mode = new ModeButton(); mode.margin_bottom = 8; mode.halign = Align.CENTER; mode.append_text(_("Executable")); @@ -305,7 +305,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Pages.Emulators add_separator(); - var patterns_header = new HeaderLabel(_("Game file patterns")); + var patterns_header = Styled.H4Label(_("Game file patterns")); patterns_header.margin_start = patterns_header.margin_end = 4; grid.attach(patterns_header, 0, rows, 2, 1); rows++; diff --git a/src/ui/dialogs/SettingsDialog/pages/emulators/RetroArch.vala b/src/ui/dialogs/SettingsDialog/pages/emulators/RetroArch.vala index 15c8d33d..334ecf2f 100644 --- a/src/ui/dialogs/SettingsDialog/pages/emulators/RetroArch.vala +++ b/src/ui/dialogs/SettingsDialog/pages/emulators/RetroArch.vala @@ -17,7 +17,7 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; + using GameHub.Utils; namespace GameHub.UI.Dialogs.SettingsDialog.Pages.Emulators diff --git a/src/ui/dialogs/SettingsDialog/pages/general/Collection.vala b/src/ui/dialogs/SettingsDialog/pages/general/Collection.vala index 1bfcf3c7..24ee90a4 100644 --- a/src/ui/dialogs/SettingsDialog/pages/general/Collection.vala +++ b/src/ui/dialogs/SettingsDialog/pages/general/Collection.vala @@ -17,7 +17,7 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; + using GameHub.Data; using GameHub.Utils; diff --git a/src/ui/dialogs/SettingsDialog/pages/general/Controller.vala b/src/ui/dialogs/SettingsDialog/pages/general/Controller.vala index 934eee6c..17fba55f 100644 --- a/src/ui/dialogs/SettingsDialog/pages/general/Controller.vala +++ b/src/ui/dialogs/SettingsDialog/pages/general/Controller.vala @@ -17,7 +17,7 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; + using GameHub.Utils; using GameHub.UI.Widgets; diff --git a/src/ui/dialogs/SettingsDialog/pages/providers/Providers.vala b/src/ui/dialogs/SettingsDialog/pages/providers/Providers.vala index 1168de81..428c0eea 100644 --- a/src/ui/dialogs/SettingsDialog/pages/providers/Providers.vala +++ b/src/ui/dialogs/SettingsDialog/pages/providers/Providers.vala @@ -17,7 +17,7 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; + using GameHub.Utils; using GameHub.UI.Widgets; using GameHub.Data.Providers; diff --git a/src/ui/dialogs/SettingsDialog/pages/sources/GOG.vala b/src/ui/dialogs/SettingsDialog/pages/sources/GOG.vala index 503d4074..d4f461f1 100644 --- a/src/ui/dialogs/SettingsDialog/pages/sources/GOG.vala +++ b/src/ui/dialogs/SettingsDialog/pages/sources/GOG.vala @@ -17,7 +17,7 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; + using GameHub.Utils; using GameHub.UI.Widgets; diff --git a/src/ui/dialogs/SettingsDialog/pages/sources/Humble.vala b/src/ui/dialogs/SettingsDialog/pages/sources/Humble.vala index fdd83459..02e4a87b 100644 --- a/src/ui/dialogs/SettingsDialog/pages/sources/Humble.vala +++ b/src/ui/dialogs/SettingsDialog/pages/sources/Humble.vala @@ -17,7 +17,7 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; + using GameHub.Utils; using GameHub.UI.Widgets; diff --git a/src/ui/dialogs/SettingsDialog/pages/sources/Steam.vala b/src/ui/dialogs/SettingsDialog/pages/sources/Steam.vala index 1dcd72ee..f87c0ccc 100644 --- a/src/ui/dialogs/SettingsDialog/pages/sources/Steam.vala +++ b/src/ui/dialogs/SettingsDialog/pages/sources/Steam.vala @@ -17,7 +17,7 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; + using GameHub.Utils; namespace GameHub.UI.Dialogs.SettingsDialog.Pages.Sources diff --git a/src/ui/dialogs/SettingsDialog/pages/ui/Appearance.vala b/src/ui/dialogs/SettingsDialog/pages/ui/Appearance.vala index d195d6f0..9877a16b 100644 --- a/src/ui/dialogs/SettingsDialog/pages/ui/Appearance.vala +++ b/src/ui/dialogs/SettingsDialog/pages/ui/Appearance.vala @@ -17,7 +17,8 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; +using GameHub.UI.Widgets; + using GameHub.Utils; namespace GameHub.UI.Dialogs.SettingsDialog.Pages.UI @@ -42,7 +43,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Pages.UI add_switch(_("Dark theme"), settings.dark_theme, v => { settings.dark_theme = v; }); - var icon_style = new Granite.Widgets.ModeButton(); + var icon_style = new ModeButton(); icon_style.homogeneous = false; icon_style.halign = Align.END; icon_style.append_text(C_("icon_style", "Theme-based")); diff --git a/src/ui/dialogs/SettingsDialog/pages/ui/Behavior.vala b/src/ui/dialogs/SettingsDialog/pages/ui/Behavior.vala index 742a569d..53f3d000 100644 --- a/src/ui/dialogs/SettingsDialog/pages/ui/Behavior.vala +++ b/src/ui/dialogs/SettingsDialog/pages/ui/Behavior.vala @@ -17,7 +17,7 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; + using GameHub.Utils; namespace GameHub.UI.Dialogs.SettingsDialog.Pages.UI diff --git a/src/ui/views/BaseView.vala b/src/ui/views/BaseView.vala index 93cf3047..ef66c455 100644 --- a/src/ui/views/BaseView.vala +++ b/src/ui/views/BaseView.vala @@ -17,7 +17,7 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; + using GameHub.UI.Windows; namespace GameHub.UI.Views diff --git a/src/ui/views/GameDetailsView/GameDetailsBlock.vala b/src/ui/views/GameDetailsView/GameDetailsBlock.vala index 7561c51e..d3c703ff 100644 --- a/src/ui/views/GameDetailsView/GameDetailsBlock.vala +++ b/src/ui/views/GameDetailsView/GameDetailsBlock.vala @@ -17,9 +17,11 @@ along with GameHub. If not, see . */ using Gtk; +using GameHub.UI.Widgets; + using Gdk; using Gee; -using Granite; + using GameHub.Data; namespace GameHub.UI.Views.GameDetailsView @@ -41,7 +43,7 @@ namespace GameHub.UI.Views.GameDetailsView { if(text == null || text == "") return null; - var title_label = new Granite.HeaderLabel(title); + var title_label = Styled.H4Label(title); title_label.set_size_request(multiline ? -1 : 128, -1); title_label.valign = Align.START; diff --git a/src/ui/views/GameDetailsView/GameDetailsPage.vala b/src/ui/views/GameDetailsView/GameDetailsPage.vala index 0c603798..ec86c888 100644 --- a/src/ui/views/GameDetailsView/GameDetailsPage.vala +++ b/src/ui/views/GameDetailsView/GameDetailsPage.vala @@ -19,7 +19,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Utils; using GameHub.UI.Widgets; @@ -126,12 +126,11 @@ namespace GameHub.UI.Views.GameDetailsView icon_overlay.add(no_icon_indicator); icon_overlay.add_overlay(icon); - title = new Label(null); + title = Styled.H2Label(null); title.halign = Align.START; title.wrap = true; title.xalign = 0; title.hexpand = true; - title.get_style_context().add_class(Granite.STYLE_CLASS_H2_LABEL); status = new Label(null); status.halign = Align.START; diff --git a/src/ui/views/GameDetailsView/GameDetailsView.vala b/src/ui/views/GameDetailsView/GameDetailsView.vala index 43c843a2..4a0fd183 100644 --- a/src/ui/views/GameDetailsView/GameDetailsView.vala +++ b/src/ui/views/GameDetailsView/GameDetailsView.vala @@ -19,7 +19,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Data.DB; using GameHub.Utils; @@ -107,7 +107,7 @@ namespace GameHub.UI.Views.GameDetailsView back_button.expand = false; back_button.visible = false; back_button.margin_top = back_button.margin_bottom = 6; - back_button.get_style_context().add_class(Granite.STYLE_CLASS_BACK_BUTTON); + StyleClass.add(back_button, StyleClass.BACK_BUTTON); back_button.clicked.connect(() => { if(navigation.size > 1) diff --git a/src/ui/views/GameDetailsView/MultipleGamesDetailsView.vala b/src/ui/views/GameDetailsView/MultipleGamesDetailsView.vala index 9a04701f..047fbd83 100644 --- a/src/ui/views/GameDetailsView/MultipleGamesDetailsView.vala +++ b/src/ui/views/GameDetailsView/MultipleGamesDetailsView.vala @@ -19,7 +19,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Data.DB; using GameHub.Utils; @@ -63,13 +63,12 @@ namespace GameHub.UI.Views.GameDetailsView construct { - header = new Label(null); + header = Styled.H2Label(null); header.halign = Align.START; header.wrap = true; header.xalign = 0; header.hexpand = true; header.margin = 24; - header.get_style_context().add_class(Granite.STYLE_CLASS_H2_LABEL); var actions_wrapper = new Box(Orientation.VERTICAL, 0); actions_wrapper.expand = true; diff --git a/src/ui/views/GameDetailsView/blocks/Achievements.vala b/src/ui/views/GameDetailsView/blocks/Achievements.vala index 0cb90b8b..da824117 100644 --- a/src/ui/views/GameDetailsView/blocks/Achievements.vala +++ b/src/ui/views/GameDetailsView/blocks/Achievements.vala @@ -19,7 +19,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Data.Sources.Steam; @@ -52,9 +52,8 @@ namespace GameHub.UI.Views.GameDetailsView.Blocks vbox.add(new Separator(Orientation.HORIZONTAL)); - var header = new Granite.HeaderLabel(_("Achievements")); + var header = Styled.H4Label(_("Achievements"), "description-header"); header.margin_start = header.margin_end = 7; - header.get_style_context().add_class("description-header"); var achievements_scrolled = new ScrolledWindow(null, null); achievements_scrolled.hscrollbar_policy = PolicyType.AUTOMATIC; diff --git a/src/ui/views/GameDetailsView/blocks/Description.vala b/src/ui/views/GameDetailsView/blocks/Description.vala index 2b7ea089..5c74b877 100644 --- a/src/ui/views/GameDetailsView/blocks/Description.vala +++ b/src/ui/views/GameDetailsView/blocks/Description.vala @@ -17,9 +17,11 @@ along with GameHub. If not, see . */ using Gtk; +using GameHub.UI.Widgets; + using Gdk; using Gee; -using Granite; + using WebKit; using GameHub.Data; @@ -29,7 +31,7 @@ namespace GameHub.UI.Views.GameDetailsView.Blocks { public class Description: GameDetailsBlock { - private Granite.HeaderLabel description_header; + private Label description_header; private WebView description; private const string CSS = "body{overflow: hidden; font-size: 0.8em; margin: 7px; line-height: 1.4; %s} h1,h2,h3{line-height: 1.2;} ul{padding: 4px 0 4px 16px;} img{max-width: 100%; display: block;}"; @@ -49,9 +51,8 @@ namespace GameHub.UI.Views.GameDetailsView.Blocks if(!Providers.Data.IGDB.instance.enabled) add(new Separator(Orientation.HORIZONTAL)); - description_header = new Granite.HeaderLabel(_("Description")); + description_header = Styled.H4Label(_("Description"), "description-header"); description_header.margin_start = description_header.margin_end = 7; - description_header.get_style_context().add_class("description-header"); get_style_context().add_class(Gtk.STYLE_CLASS_BACKGROUND); diff --git a/src/ui/views/GameDetailsView/blocks/GOGDetails.vala b/src/ui/views/GameDetailsView/blocks/GOGDetails.vala index a3b44f86..08855f5e 100644 --- a/src/ui/views/GameDetailsView/blocks/GOGDetails.vala +++ b/src/ui/views/GameDetailsView/blocks/GOGDetails.vala @@ -19,11 +19,11 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; using GameHub.Data; using GameHub.Data.Sources.GOG; +using GameHub.UI.Widgets; using GameHub.UI.Views.GamesView; using GameHub.Utils; @@ -86,7 +86,7 @@ namespace GameHub.UI.Views.GameDetailsView.Blocks bonuslist.add(new BonusContentRow(bonus)); } - var header = new Granite.HeaderLabel(_("Bonus content")); + var header = Styled.H4Label(_("Bonus content")); header.margin_start = header.margin_end = 8; downloads_visible = true; @@ -113,7 +113,7 @@ namespace GameHub.UI.Views.GameDetailsView.Blocks dlclist.add(new DLCRow(dlc, details_page)); } - var header = new Granite.HeaderLabel(_("DLC")); + var header = Styled.H4Label(_("DLC")); header.margin_start = header.margin_end = 8; downloads_visible = true; diff --git a/src/ui/views/GameDetailsView/blocks/IGDBInfo.vala b/src/ui/views/GameDetailsView/blocks/IGDBInfo.vala index a66a505c..1a5e9242 100644 --- a/src/ui/views/GameDetailsView/blocks/IGDBInfo.vala +++ b/src/ui/views/GameDetailsView/blocks/IGDBInfo.vala @@ -19,7 +19,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Utils; @@ -188,7 +188,7 @@ namespace GameHub.UI.Views.GameDetailsView.Blocks private Box? add_link_list(string title, Providers.Data.IGDB.Result.Link[] links, Container? parent=null) { - var title_label = new Granite.HeaderLabel(title); + var title_label = Styled.H4Label(title); title_label.set_size_request(128, -1); title_label.valign = Align.CENTER; diff --git a/src/ui/views/GameDetailsView/blocks/Playtime.vala b/src/ui/views/GameDetailsView/blocks/Playtime.vala index 689fe121..ac4da861 100644 --- a/src/ui/views/GameDetailsView/blocks/Playtime.vala +++ b/src/ui/views/GameDetailsView/blocks/Playtime.vala @@ -19,7 +19,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Data.Sources.Steam; @@ -44,7 +44,7 @@ namespace GameHub.UI.Views.GameDetailsView.Blocks var hbox = new Box(Orientation.HORIZONTAL, 0); - var header = new Granite.HeaderLabel(_("Playtime")); + var header = Styled.H4Label(_("Playtime")); var add_separator = false; diff --git a/src/ui/views/GameDetailsView/blocks/SteamDetails.vala b/src/ui/views/GameDetailsView/blocks/SteamDetails.vala index 580bde93..f6e9b7be 100644 --- a/src/ui/views/GameDetailsView/blocks/SteamDetails.vala +++ b/src/ui/views/GameDetailsView/blocks/SteamDetails.vala @@ -19,7 +19,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Data.Sources.Steam; diff --git a/src/ui/views/GamesView/AddGamePopover.vala b/src/ui/views/GamesView/AddGamePopover.vala index a57df46f..2d8f2f4d 100644 --- a/src/ui/views/GamesView/AddGamePopover.vala +++ b/src/ui/views/GamesView/AddGamePopover.vala @@ -19,7 +19,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Data.DB; using GameHub.Utils; @@ -39,7 +39,7 @@ namespace GameHub.UI.Views.GamesView private bool suppress_updates = false; - private Granite.Widgets.ModeButton mode; + private ModeButton mode; private new Entry name; private FileChooserEntry gamedir; @@ -61,7 +61,7 @@ namespace GameHub.UI.Views.GamesView grid.column_spacing = 4; grid.set_size_request(270, -1); - mode = new Granite.Widgets.ModeButton(); + mode = new ModeButton(); mode.margin_bottom = 8; mode.halign = Align.CENTER; mode.append_text(_("Executable")); diff --git a/src/ui/views/GamesView/DownloadProgressView.vala b/src/ui/views/GamesView/DownloadProgressView.vala index f179b199..4e814a38 100644 --- a/src/ui/views/GamesView/DownloadProgressView.vala +++ b/src/ui/views/GamesView/DownloadProgressView.vala @@ -18,7 +18,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; -using Granite; + using GameHub.Data; using GameHub.Utils; using GameHub.UI.Widgets; diff --git a/src/ui/views/GamesView/FiltersPopover.vala b/src/ui/views/GamesView/FiltersPopover.vala index c97e231a..75b96faf 100644 --- a/src/ui/views/GamesView/FiltersPopover.vala +++ b/src/ui/views/GamesView/FiltersPopover.vala @@ -19,7 +19,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Data.DB; using GameHub.Utils; @@ -39,8 +39,8 @@ namespace GameHub.UI.Views.GamesView public SavedState.GamesView.PlatformFilter filter_platform { get; private set; default = SavedState.GamesView.PlatformFilter.ALL; } public signal void filter_platform_changed(SavedState.GamesView.PlatformFilter filter_platform); - private Granite.Widgets.ModeButton sort_mode_button; - private Granite.Widgets.ModeButton platform_button; + private ModeButton sort_mode_button; + private ModeButton platform_button; private CheckButton tags_header_check; private ListBox tags_list; @@ -69,7 +69,7 @@ namespace GameHub.UI.Views.GamesView var sort_image = new Image.from_icon_name("view-sort-descending-symbolic", IconSize.BUTTON); sort_hbox.add(sort_image); - var sort_label = new HeaderLabel(_("Sort")); + var sort_label = Styled.H4Label(_("Sort")); sort_label.margin_end = 2; sort_label.xpad = 0; sort_label.halign = Align.START; @@ -77,7 +77,7 @@ namespace GameHub.UI.Views.GamesView sort_label.hexpand = true; sort_hbox.add(sort_label); - sort_mode_button = new Granite.Widgets.ModeButton(); + sort_mode_button = new ModeButton(); sort_mode_button.get_style_context().add_class("filters-sort-mode"); sort_mode_button.halign = Align.END; sort_mode_button.valign = Align.CENTER; @@ -94,7 +94,7 @@ namespace GameHub.UI.Views.GamesView var platform_image = new Image.from_icon_name("application-x-executable-symbolic", IconSize.BUTTON); platform_hbox.add(platform_image); - var platform_label = new HeaderLabel(_("Platform")); + var platform_label = Styled.H4Label(_("Platform")); platform_label.margin_end = 2; platform_label.xpad = 0; platform_label.halign = Align.START; @@ -102,7 +102,7 @@ namespace GameHub.UI.Views.GamesView platform_label.hexpand = true; platform_hbox.add(platform_label); - platform_button = new Granite.Widgets.ModeButton(); + platform_button = new ModeButton(); platform_button.get_style_context().add_class("filters-platform"); platform_button.halign = Align.END; platform_button.valign = Align.CENTER; @@ -191,7 +191,7 @@ namespace GameHub.UI.Views.GamesView tags_header_check = new CheckButton(); tags_header_check.can_focus = false; - var header = new HeaderLabel(_("Tags")); + var header = Styled.H4Label(_("Tags")); header.halign = Align.START; header.xalign = 0; header.hexpand = true; diff --git a/src/ui/views/GamesView/GameCard.vala b/src/ui/views/GamesView/GameCard.vala index c5ad2c05..0f73b2c6 100644 --- a/src/ui/views/GamesView/GameCard.vala +++ b/src/ui/views/GamesView/GameCard.vala @@ -19,7 +19,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Data.Adapters; using GameHub.Data.DB; @@ -83,10 +83,7 @@ namespace GameHub.UI.Views.GamesView { margin = 0; - card = new Frame(null); - card.get_style_context().add_class(Granite.STYLE_CLASS_CARD); - card.get_style_context().add_class("gamecard"); - card.shadow_type = ShadowType.NONE; + card = Styled.Card("gamecard"); card.margin = 4; child = card; diff --git a/src/ui/views/GamesView/GameContextMenu.vala b/src/ui/views/GamesView/GameContextMenu.vala index e0e348e6..4c0c6b95 100644 --- a/src/ui/views/GamesView/GameContextMenu.vala +++ b/src/ui/views/GamesView/GameContextMenu.vala @@ -18,7 +18,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; -using Granite; + using GameHub.Data; using GameHub.Data.DB; using GameHub.Utils; diff --git a/src/ui/views/GamesView/GameListRow.vala b/src/ui/views/GamesView/GameListRow.vala index cb11493a..3e2d8b1b 100644 --- a/src/ui/views/GamesView/GameListRow.vala +++ b/src/ui/views/GamesView/GameListRow.vala @@ -19,7 +19,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Data.Adapters; using GameHub.Data.DB; diff --git a/src/ui/views/GamesView/GamesView.vala b/src/ui/views/GamesView/GamesView.vala index 01325d12..39a36a92 100644 --- a/src/ui/views/GamesView/GamesView.vala +++ b/src/ui/views/GamesView/GamesView.vala @@ -20,11 +20,12 @@ using Gtk; using Gdk; using GLib; using Gee; -using Granite; + using GameHub.Data; using GameHub.Data.Adapters; using GameHub.Data.DB; using GameHub.Utils; +using GameHub.UI.Widgets; using GameHub.UI.Windows; using GameHub.Settings; @@ -42,7 +43,7 @@ namespace GameHub.UI.Views.GamesView private Stack stack; - private Granite.Widgets.AlertView empty_alert; + private AlertView empty_alert; private ScrolledWindow games_grid_scrolled; private FlowBox games_grid; @@ -51,12 +52,12 @@ namespace GameHub.UI.Views.GamesView private ListBox games_list; private GameDetailsView.GameDetailsView games_list_details; - private Granite.Widgets.ModeButton view; + private ModeButton view; - private Granite.Widgets.ModeButton filter; + private ModeButton filter; private SearchEntry search; - private Granite.Widgets.OverlayBar status_overlay; + private OverlayBar status_overlay; private Button settings; @@ -130,7 +131,7 @@ namespace GameHub.UI.Views.GamesView stack = new Stack(); stack.transition_type = StackTransitionType.CROSSFADE; - empty_alert = new Granite.Widgets.AlertView(_("No games"), _("Get some games or enable some game sources in settings"), "dialog-warning"); + empty_alert = new AlertView(_("No games"), _("Get some games or enable some game sources in settings"), "dialog-warning"); games_grid = new FlowBox(); games_grid.get_style_context().add_class("games-grid"); @@ -178,7 +179,7 @@ namespace GameHub.UI.Views.GamesView attach(messages, 0, 0); attach(overlay, 0, 1); - view = new Granite.Widgets.ModeButton(); + view = new ModeButton(); view.halign = Align.CENTER; view.valign = Align.CENTER; @@ -187,7 +188,7 @@ namespace GameHub.UI.Views.GamesView view.mode_changed.connect(update_view); - filter = new Granite.Widgets.ModeButton(); + filter = new ModeButton(); filter.halign = Align.CENTER; filter.valign = Align.CENTER; @@ -383,7 +384,7 @@ namespace GameHub.UI.Views.GamesView titlebar.pack_end(gamepad_image("a", _("Select"))); #endif - status_overlay = new Granite.Widgets.OverlayBar(overlay); + status_overlay = new OverlayBar(overlay); games_adapter.notify["status"].connect(() => { update_status(games_adapter.status); }); @@ -955,7 +956,7 @@ namespace GameHub.UI.Views.GamesView if(text != null) { - var label = new HeaderLabel(text); + var label = Styled.H4Label(text); var box = new Box(Orientation.HORIZONTAL, 8); box.margin_start = box.margin_end = 4; box.add(image); diff --git a/src/ui/views/WelcomeView.vala b/src/ui/views/WelcomeView.vala index ee497967..1ff59e7a 100644 --- a/src/ui/views/WelcomeView.vala +++ b/src/ui/views/WelcomeView.vala @@ -17,7 +17,8 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; +using GameHub.UI.Widgets; + using GameHub.Data; using GameHub.Utils; @@ -26,8 +27,8 @@ namespace GameHub.UI.Views public class WelcomeView: BaseView { private Stack stack; - private Granite.Widgets.AlertView empty_alert; - private Granite.Widgets.Welcome welcome; + private AlertView empty_alert; + private Welcome welcome; private Button skip_btn; private Button settings; @@ -48,12 +49,12 @@ namespace GameHub.UI.Views spinner.valign = Align.CENTER; stack.add(spinner); - empty_alert = new Granite.Widgets.AlertView(_("No enabled game sources"), _("Enable some game sources in settings"), "dialog-warning"); + empty_alert = new AlertView(_("No enabled game sources"), _("Enable some game sources in settings"), "dialog-warning"); empty_alert.show_action(_("Settings")); stack.add(empty_alert); - welcome = new Granite.Widgets.Welcome(_("All your games in one place"), _("Let's get started")); + welcome = new Welcome(_("All your games in one place"), _("Let's get started")); welcome.activated.connect(index => { on_entry_clicked.begin(index); diff --git a/src/ui/widgets/ActionButton.vala b/src/ui/widgets/ActionButton.vala index cb4619cf..caecae09 100644 --- a/src/ui/widgets/ActionButton.vala +++ b/src/ui/widgets/ActionButton.vala @@ -71,8 +71,7 @@ namespace GameHub.UI.Widgets if(show_text) { - var label = new Label(text.replace("&", "&").replace("&", "&")); - label.get_style_context().add_class(Granite.STYLE_CLASS_H3_LABEL); + var label = Styled.H3Label(text.replace("&", "&").replace("&", "&")); label.halign = Align.START; label.valign = Align.CENTER; label.xalign = 0; diff --git a/src/ui/widgets/AlertView.vala b/src/ui/widgets/AlertView.vala new file mode 100644 index 00000000..a32f4b54 --- /dev/null +++ b/src/ui/widgets/AlertView.vala @@ -0,0 +1,153 @@ +/* +This file is part of GameHub. +Copyright(C) 2018-2019 Anatoliy Kashkin + +GameHub is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GameHub is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GameHub. If not, see . +*/ + +/* Based on Granite.Widgets.AlertView */ + +using Gtk; + +namespace GameHub.UI.Widgets +{ + public class AlertView: Grid + { + public signal void action_activated(); + + public string title + { + get + { + return title_label.label; + } + set + { + title_label.label = value; + } + } + + public string description + { + get + { + return description_label.label; + } + set + { + description_label.label = value; + } + } + + public string icon_name + { + owned get + { + return image.icon_name ?? ""; + } + set + { + if(value != null && value != "") + { + image.set_from_icon_name(value, IconSize.DIALOG); + image.no_show_all = false; + image.show(); + } + else + { + image.no_show_all = true; + image.hide(); + } + } + } + + private Label title_label; + private Label description_label; + private Image image; + private Button action_button; + private Revealer action_revealer; + + public AlertView(string title, string description, string icon_name) + { + Object(title: title, description: description, icon_name: icon_name); + } + + construct + { + get_style_context().add_class(Gtk.STYLE_CLASS_VIEW); + + title_label = Styled.H2Label(null); + title_label.hexpand = true; + title_label.max_width_chars = 75; + title_label.wrap = true; + title_label.wrap_mode = Pango.WrapMode.WORD_CHAR; + title_label.use_markup = true; + title_label.xalign = 0; + + description_label = new Label(null); + description_label.hexpand = true; + description_label.max_width_chars = 75; + description_label.wrap = true; + description_label.use_markup = true; + description_label.xalign = 0; + description_label.valign = Align.START; + + action_button = new Button(); + action_button.margin_top = 24; + + action_revealer = new Revealer(); + action_revealer.add(action_button); + action_revealer.halign = Align.END; + action_revealer.transition_type = RevealerTransitionType.SLIDE_UP; + + image = new Image(); + image.margin_top = 6; + image.valign = Align.START; + + var layout = new Grid(); + layout.column_spacing = 12; + layout.row_spacing = 6; + layout.halign = Align.CENTER; + layout.valign = Align.CENTER; + layout.vexpand = true; + layout.margin = 24; + + layout.attach(image, 1, 1, 1, 2); + layout.attach(title_label, 2, 1, 1, 1); + layout.attach(description_label, 2, 2, 1, 1); + layout.attach(action_revealer, 2, 3, 1, 1); + + add(layout); + + action_button.clicked.connect(() => {action_activated();}); + } + + public void show_action(string? label=null) + { + if(label != null) + action_button.label = label; + + if(action_button.label == null) + return; + + action_revealer.set_reveal_child(true); + action_revealer.show_all(); + } + + public void hide_action() + { + action_revealer.set_reveal_child(false); + } + } +} diff --git a/src/ui/widgets/AutoSizeImage.vala b/src/ui/widgets/AutoSizeImage.vala index 7178e2e8..6797bc1b 100644 --- a/src/ui/widgets/AutoSizeImage.vala +++ b/src/ui/widgets/AutoSizeImage.vala @@ -155,7 +155,7 @@ namespace GameHub.UI.Widgets var x = (width - scaled.width) / 2; var y = (height - scaled.height) / 2; - Granite.Drawing.Utilities.cairo_rounded_rectangle(ctx, int.max(x, 0), int.max(y, 0), int.min(scaled.width, width), int.min(scaled.height, height), corner_radius * scale_factor); + cairo_rounded_rectangle(ctx, int.max(x, 0), int.max(y, 0), int.min(scaled.width, width), int.min(scaled.height, height), corner_radius * scale_factor); cairo_set_source_pixbuf(ctx, scaled, x, y); ctx.clip(); @@ -164,5 +164,15 @@ namespace GameHub.UI.Widgets return false; } + + private static void cairo_rounded_rectangle(Cairo.Context cr, double x, double y, double width, double height, double radius) + { + cr.move_to(x + radius, y); + cr.arc(x + width - radius, y + radius, radius, Math.PI * 1.5, Math.PI * 2); + cr.arc(x + width - radius, y + height - radius, radius, 0, Math.PI * 0.5); + cr.arc(x + radius, y + height - radius, radius, Math.PI * 0.5, Math.PI); + cr.arc(x + radius, y + radius, radius, Math.PI, Math.PI * 1.5); + cr.close_path(); + } } } diff --git a/src/ui/widgets/CompatToolOptions.vala b/src/ui/widgets/CompatToolOptions.vala index 73316230..5b6a6fb8 100644 --- a/src/ui/widgets/CompatToolOptions.vala +++ b/src/ui/widgets/CompatToolOptions.vala @@ -18,7 +18,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; -using Granite; + using GameHub.Data; using GameHub.Utils; diff --git a/src/ui/widgets/CompatToolPicker.vala b/src/ui/widgets/CompatToolPicker.vala index 59fe6ab2..93fe46a4 100644 --- a/src/ui/widgets/CompatToolPicker.vala +++ b/src/ui/widgets/CompatToolPicker.vala @@ -18,7 +18,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; -using Granite; + using GameHub.Data; using GameHub.Data.DB; diff --git a/src/ui/widgets/ExtendedStackSwitcher.vala b/src/ui/widgets/ExtendedStackSwitcher.vala index dc3f2177..d24347a4 100644 --- a/src/ui/widgets/ExtendedStackSwitcher.vala +++ b/src/ui/widgets/ExtendedStackSwitcher.vala @@ -18,11 +18,11 @@ along with GameHub. If not, see . using Gtk; using Gee; -using Granite; + namespace GameHub.UI.Widgets { - public class ExtendedStackSwitcher: Granite.Widgets.ModeButton + public class ExtendedStackSwitcher: ModeButton { public Stack stack { get; construct; } diff --git a/src/ui/widgets/GameTagsList.vala b/src/ui/widgets/GameTagsList.vala index ec43c99c..9162f1c8 100644 --- a/src/ui/widgets/GameTagsList.vala +++ b/src/ui/widgets/GameTagsList.vala @@ -19,7 +19,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Data.DB; @@ -55,7 +55,7 @@ namespace GameHub.UI.Widgets construct { - var header = new HeaderLabel(_("Tags")); + var header = Styled.H4Label(_("Tags")); header.xpad = 8; add(header); diff --git a/src/ui/widgets/ImagesDownloadPopover.vala b/src/ui/widgets/ImagesDownloadPopover.vala index 32bbd647..eda04e79 100644 --- a/src/ui/widgets/ImagesDownloadPopover.vala +++ b/src/ui/widgets/ImagesDownloadPopover.vala @@ -17,7 +17,7 @@ along with GameHub. If not, see . */ using Gtk; -using Granite; + using GameHub.Data; using GameHub.Data.Providers; @@ -39,7 +39,7 @@ namespace GameHub.UI.Widgets private Stack stack; private Spinner spinner; - private Granite.Widgets.AlertView no_images_alert; + private AlertView no_images_alert; private ScrolledWindow images_scroll; private Box images; @@ -75,7 +75,7 @@ namespace GameHub.UI.Widgets spinner.margin = 16; spinner.start(); - no_images_alert = new Granite.Widgets.AlertView(_("No images"), _("There are no images found for this game\nMake sure game name is correct"), "dialog-information"); + no_images_alert = new AlertView(_("No images"), _("There are no images found for this game\nMake sure game name is correct"), "dialog-information"); no_images_alert.get_style_context().remove_class(Gtk.STYLE_CLASS_VIEW); images_scroll = new ScrolledWindow(null, null); @@ -144,7 +144,7 @@ namespace GameHub.UI.Widgets var header_hbox = new Box(Orientation.HORIZONTAL, 8); header_hbox.margin_start = header_hbox.margin_end = 4; - var header = new HeaderLabel(src.name); + var header = Styled.H4Label(src.name); header.hexpand = true; header_hbox.add(header); @@ -225,12 +225,8 @@ namespace GameHub.UI.Widgets { margin = 0; - var card = new Frame(null); + var card = Styled.Card("gamecard", "static"); card.sensitive = false; - card.get_style_context().add_class(Granite.STYLE_CLASS_CARD); - card.get_style_context().add_class("gamecard"); - card.get_style_context().add_class("static"); - card.shadow_type = ShadowType.NONE; card.margin = 4; card.tooltip_markup = image.description; diff --git a/src/ui/widgets/ModeButton.vala b/src/ui/widgets/ModeButton.vala new file mode 100644 index 00000000..319741a3 --- /dev/null +++ b/src/ui/widgets/ModeButton.vala @@ -0,0 +1,237 @@ +/* +This file is part of GameHub. +Copyright(C) 2018-2019 Anatoliy Kashkin + +GameHub is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GameHub is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GameHub. If not, see . +*/ + +/* Based on Granite.Widgets.ModeButton */ + +using Gtk; +using Gee; + +namespace GameHub.UI.Widgets +{ + public class ModeButton: Box + { + private class Item: ToggleButton + { + public int index { get; construct; } + public Item(int index) + { + Object(index: index); + can_focus = false; + add_events(Gdk.EventMask.SCROLL_MASK); + } + } + + public signal void mode_added(int index, Widget widget); + public signal void mode_removed(int index, Widget widget); + public signal void mode_changed(Widget widget); + + public int selected + { + get { return _selected; } + set { set_active(value); } + } + + public uint n_items { get { return item_map.size; } } + + private int _selected = -1; + private HashMap item_map; + + public ModeButton(){} + + construct + { + homogeneous = true; + spacing = 0; + can_focus = false; + item_map = new HashMap(); + StyleClass.add(this, Gtk.STYLE_CLASS_LINKED, "raised"); + } + + public int append_pixbuf(Gdk.Pixbuf pixbuf) + { + return append(new Image.from_pixbuf(pixbuf)); + } + + public int append_text(string text) + { + return append(new Label(text)); + } + + public int append_icon(string icon_name, IconSize size) + { + return append(new Image.from_icon_name(icon_name, size)); + } + + public int append(Widget w) + { + int index; + for(index = item_map.size; item_map.has_key(index); index++); + assert(item_map[index] == null); + + var item = new Item(index); + item.scroll_event.connect(on_scroll_event); + item.add(w); + + item.toggled.connect(() => { + if(item.active) + { + selected = item.index; + } + else if(selected == item.index) + { + item.active = true; + } + }); + + item_map[index] = item; + + add(item); + item.show_all(); + + mode_added(index, w); + + return index; + } + + private void clear_selected() + { + _selected = -1; + foreach(var item in item_map.values) + { + if(item != null && item.active) + { + item.set_active(false); + } + } + } + + public void set_active(int new_active_index) + { + if(new_active_index <= -1) + { + clear_selected(); + return; + } + + return_if_fail(item_map.has_key(new_active_index)); + var new_item = item_map[new_active_index] as Item; + + if(new_item != null) + { + assert(new_item.index == new_active_index); + new_item.set_active(true); + + if(_selected == new_active_index) return; + + var old_item = item_map[_selected] as Item; + + _selected = new_active_index; + + if(old_item != null) + { + old_item.set_active(false); + } + + mode_changed(new_item.get_child()); + } + } + + public void set_item_visible(int index, bool val) { + return_if_fail(item_map.has_key(index)); + var item = item_map[index] as Item; + + if(item != null) + { + assert(item.index == index); + item.no_show_all = !val; + item.visible = val; + } + } + + public new void remove(int index) + { + return_if_fail(item_map.has_key(index)); + var item = item_map[index] as Item; + + if(item != null) + { + assert(item.index == index); + item_map.unset(index); + mode_removed(index, item.get_child()); + item.destroy(); + } + } + + public void clear_children() + { + foreach(weak Widget button in get_children()) + { + button.hide(); + if(button.get_parent() != null) + { + base.remove(button); + } + } + + item_map.clear(); + _selected = -1; + } + + private bool on_scroll_event(Widget widget, Gdk.EventScroll ev) + { + int offset; + switch(ev.direction) + { + case Gdk.ScrollDirection.DOWN: + case Gdk.ScrollDirection.RIGHT: + offset = 1; + break; + case Gdk.ScrollDirection.UP: + case Gdk.ScrollDirection.LEFT: + offset = -1; + break; + default: + return false; + } + + var children = get_children(); + uint n_children = children.length(); + + var selected_item = item_map[selected]; + if(selected_item == null) return false; + + int new_item = children.index(selected_item); + if(new_item < 0) return false; + + do + { + new_item += offset; + var item = children.nth_data(new_item) as Item; + + if(item != null && item.visible && item.sensitive) + { + selected = item.index; + break; + } + } + while(new_item >= 0 && new_item < n_children); + + return false; + } + } +} diff --git a/src/ui/widgets/OverlayBar.vala b/src/ui/widgets/OverlayBar.vala new file mode 100644 index 00000000..75a72fbb --- /dev/null +++ b/src/ui/widgets/OverlayBar.vala @@ -0,0 +1,126 @@ +/* +This file is part of GameHub. +Copyright(C) 2018-2019 Anatoliy Kashkin + +GameHub is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GameHub is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GameHub. If not, see . +*/ + +/* Based on Granite.Widgets.OverlayBar */ + +using Gtk; + +namespace GameHub.UI.Widgets +{ + public class OverlayBar: EventBox + { + private Label status_label; + private Revealer revealer; + private Spinner spinner; + + public string label + { + get + { + return status_label.label; + } + set + { + status_label.label = value; + } + } + + public bool active + { + get + { + return spinner.active; + } + set + { + spinner.active = value; + revealer.reveal_child = value; + } + } + + public OverlayBar(Overlay? overlay=null) + { + if(overlay != null) + { + overlay.add_events(Gdk.EventMask.ENTER_NOTIFY_MASK); + overlay.add_overlay(this); + } + } + + construct + { + status_label = new Label(""); + status_label.set_ellipsize(Pango.EllipsizeMode.END); + + spinner = new Spinner(); + + revealer = new Revealer(); + revealer.reveal_child = false; + revealer.transition_type = RevealerTransitionType.SLIDE_LEFT; + revealer.add(spinner); + + var grid = new Grid(); + StyleClass.add(grid, "overlay-bar"); + grid.add(status_label); + grid.add(revealer); + + add(grid); + + set_halign(Align.END); + set_valign(Align.END); + + var ctx = grid.get_style_context(); + var state = ctx.get_state(); + + var padding = ctx.get_padding(state); + status_label.margin_top = padding.top; + status_label.margin_bottom = padding.bottom; + status_label.margin_start = padding.left; + status_label.margin_end = padding.right; + spinner.margin_end = padding.right; + + var margin = ctx.get_margin(state); + grid.margin_top = margin.top; + grid.margin_bottom = margin.bottom; + grid.margin_start = margin.left; + grid.margin_end = margin.right; + } + + public override void parent_set(Widget? old_parent) + { + Widget parent = get_parent(); + + if(old_parent != null) + old_parent.enter_notify_event.disconnect(enter_notify_callback); + if(parent != null) + parent.enter_notify_event.connect(enter_notify_callback); + } + + private bool enter_notify_callback(Gdk.EventCrossing event) + { + if(get_halign() == Align.START) + set_halign(Align.END); + else + set_halign(Align.START); + + queue_resize(); + + return false; + } + } +} diff --git a/src/ui/widgets/SettingsSidebar.vala b/src/ui/widgets/SettingsSidebar.vala new file mode 100644 index 00000000..e7ea3f31 --- /dev/null +++ b/src/ui/widgets/SettingsSidebar.vala @@ -0,0 +1,410 @@ +/* +This file is part of GameHub. +Copyright(C) 2018-2019 Anatoliy Kashkin + +GameHub is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GameHub is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GameHub. If not, see . +*/ + +/* Based on Granite.SettingsSidebar */ + +using Gtk; + +namespace GameHub.UI.Widgets +{ + public class SettingsSidebar: ScrolledWindow + { + private ListBox listbox; + public Stack stack { get; construct; } + + public string? visible_child_name + { + get + { + var selected_row = listbox.get_selected_row(); + if(selected_row == null) + { + return null; + } + else + { + return ((Row) selected_row).name; + } + } + set + { + foreach(unowned Widget listbox_child in listbox.get_children()) + { + if(((Row) listbox_child).name == value) + { + listbox.select_row((ListBoxRow) listbox_child); + } + } + } + } + + public SettingsSidebar(Stack stack) + { + Object(stack: stack); + } + + construct + { + hscrollbar_policy = PolicyType.NEVER; + width_request = 200; + listbox = new ListBox(); + listbox.activate_on_single_click = true; + listbox.selection_mode = SelectionMode.SINGLE; + + add(listbox); + + on_sidebar_changed(); + stack.add.connect(on_sidebar_changed); + stack.remove.connect(on_sidebar_changed); + + listbox.row_selected.connect((row) => { + stack.visible_child = ((Row) row).page; + }); + + listbox.set_header_func((row, before) => { + var header = ((Row) row).header; + if(header != null) + { + row.set_header(Styled.H4Label(header)); + } + }); + } + + private void on_sidebar_changed() + { + listbox.get_children().foreach((listbox_child) => { + listbox_child.destroy(); + }); + + stack.get_children().foreach((child) => { + if(child is SettingsSidebar.SettingsPage) + { + var row = new Row((SettingsPage) child); + listbox.add(row); + } + }); + + listbox.show_all(); + } + + public abstract class SettingsPage: ScrolledWindow + { + protected string _icon_name; + protected string _title; + + public enum StatusType { ERROR, WARNING, NONE } + + public StatusType status_type { get; set; default = StatusType.NONE; } + public Widget? display_widget { get; construct; } + public string? header { get; construct; } + public string status { get; set; } + + public string? icon_name + { + get + { + return _icon_name; + } + construct set + { + _icon_name = value; + } + } + + public string title + { + get + { + return _title; + } + construct set + { + _title = value; + } + } + } + + public abstract class SimpleSettingsPage: SettingsPage + { + private Image header_icon; + private Label description_label; + private Label title_label; + private string _description; + + public ButtonBox action_area { get; construct; } + public Grid content_area { get; construct; } + public Switch? status_switch { get; construct; } + public bool activatable { get; construct; } + + public string description + { + get + { + return _description; + } + construct set + { + if(description_label != null) + { + description_label.label = value; + } + _description = value; + } + } + + public new string icon_name + { + get + { + return _icon_name; + } + construct set + { + if(header_icon != null) + { + header_icon.icon_name = value; + } + _icon_name = value; + } + } + + construct + { + header_icon = new Image.from_icon_name(icon_name, IconSize.DIALOG); + header_icon.pixel_size = 48; + header_icon.valign = Align.START; + + title_label = Styled.H2Label(title); + title_label.ellipsize = Pango.EllipsizeMode.END; + title_label.xalign = 0; + + var header_area = new Grid(); + header_area.column_spacing = 12; + header_area.row_spacing = 3; + + header_area.attach(title_label, 1, 0); + + if(description != null) + { + description_label = new Label(description); + description_label.xalign = 0; + description_label.wrap = true; + + header_area.attach(header_icon, 0, 0, 1, 2); + header_area.attach(description_label, 1, 1); + } + else + { + header_area.attach(header_icon, 0, 0); + } + + if(activatable) + { + status_switch = new Switch(); + status_switch.hexpand = true; + status_switch.halign = Align.END; + status_switch.valign = Align.CENTER; + header_area.attach(status_switch, 2, 0); + } + + content_area = new Grid(); + content_area.column_spacing = 12; + content_area.row_spacing = 12; + content_area.vexpand = true; + + action_area = new ButtonBox(Orientation.HORIZONTAL); + action_area.set_layout(ButtonBoxStyle.END); + action_area.spacing = 6; + + var grid = new Grid(); + grid.margin = 12; + grid.orientation = Orientation.VERTICAL; + grid.row_spacing = 24; + grid.add(header_area); + grid.add(content_area); + grid.add(action_area); + + add(grid); + + set_action_area_visibility(); + + action_area.add.connect(set_action_area_visibility); + action_area.remove.connect(set_action_area_visibility); + + notify["icon-name"].connect(() => { + if(header_icon != null) { + header_icon.icon_name = icon_name; + } + }); + + notify["title"].connect(() => { + if(title_label != null) { + title_label.label = title; + } + }); + } + + private void set_action_area_visibility() + { + if(action_area.get_children() != null) + { + action_area.no_show_all = false; + action_area.show(); + } + else + { + action_area.no_show_all = true; + action_area.hide(); + } + } + } + + private class Row: ListBoxRow + { + public SettingsPage.StatusType status_type + { + set + { + switch(value) + { + case SettingsPage.StatusType.ERROR: + status_icon.icon_name = "dialog-error-symbolic"; + break; + case SettingsPage.StatusType.WARNING: + status_icon.icon_name = "dialog-warning-symbolic"; + break; + } + } + } + + public Widget display_widget { get; construct; } + + public string? header { get; set; } + + public unowned SettingsPage page { get; construct; } + + public string icon_name + { + get + { + return _icon_name; + } + set + { + _icon_name = value; + if(display_widget is Image) + { + ((Image) display_widget).icon_name = value; + ((Image) display_widget).pixel_size = 32; + } + } + } + + public string status + { + set + { + status_label.label = "%s".printf(value); + status_label.no_show_all = false; + status_label.show(); + } + } + + public string title + { + get + { + return _title; + } + set + { + _title = value; + title_label.label = value; + } + } + + private Image status_icon; + private Label status_label; + private Label title_label; + private string _icon_name; + private string _title; + + public Row(SettingsPage page) + { + Object(page: page); + } + + construct + { + title_label = Styled.H3Label(page.title); + title_label.ellipsize = Pango.EllipsizeMode.END; + title_label.xalign = 0; + + status_icon = new Image(); + status_icon.halign = Align.END; + status_icon.valign = Align.END; + + status_label = new Label(null); + status_label.no_show_all = true; + status_label.use_markup = true; + status_label.ellipsize = Pango.EllipsizeMode.END; + status_label.xalign = 0; + + if(page.icon_name != null) + { + display_widget = new Image(); + icon_name = page.icon_name; + } + else + { + display_widget = page.display_widget; + } + + var overlay = new Overlay(); + overlay.width_request = 38; + overlay.add(display_widget); + overlay.add_overlay(status_icon); + + var grid = new Grid(); + grid.margin = 6; + grid.column_spacing = 6; + grid.attach(overlay, 0, 0, 1, 2); + grid.attach(title_label, 1, 0, 1, 1); + grid.attach(status_label, 1, 1, 1, 1); + + add(grid); + + header = page.header; + page.bind_property("icon-name", this, "icon-name", BindingFlags.DEFAULT); + page.bind_property("status", this, "status", BindingFlags.DEFAULT); + page.bind_property("status-type", this, "status-type", BindingFlags.DEFAULT); + page.bind_property("title", this, "title", BindingFlags.DEFAULT); + + if(page.status != null) + { + status = page.status; + } + + if(page.status_type != SettingsPage.StatusType.NONE) + { + status_type = page.status_type; + } + } + } + } +} diff --git a/src/ui/widgets/Styles.vala b/src/ui/widgets/Styles.vala new file mode 100644 index 00000000..e2290fa9 --- /dev/null +++ b/src/ui/widgets/Styles.vala @@ -0,0 +1,105 @@ +/* +This file is part of GameHub. +Copyright (C) 2018-2019 Anatoliy Kashkin + +GameHub is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GameHub is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GameHub. If not, see . +*/ + +using Gtk; + +namespace GameHub.UI.Widgets +{ + namespace StyleClass + { + namespace Label + { + public const string H1 = "h1"; + public const string H2 = "h2"; + public const string H3 = "h3"; + public const string H4 = "h4"; + } + + public const string CARD = "card"; + public const string BACK_BUTTON = "back-button"; + + public void add(Widget widget, ...) + { + add_va(widget, va_list()); + } + + public void remove(Widget widget, ...) + { + remove_va(widget, va_list()); + } + + public void add_va(Widget widget, va_list classes) + { + var ctx = widget.get_style_context(); + for(string? class = classes.arg(); class != null; class = classes.arg()) + { + ctx.add_class(class); + } + } + + public void remove_va(Widget widget, va_list classes) + { + var ctx = widget.get_style_context(); + for(string? class = classes.arg(); class != null; class = classes.arg()) + { + ctx.remove_class(class); + } + } + } + + namespace Styled + { + public Label Label(string? text, string main_class, va_list classes) + { + var label = new Gtk.Label(text); + StyleClass.add(label, main_class); + StyleClass.add_va(label, classes); + return label; + } + + public Label H1Label(string? text, ...) + { + return Styled.Label(text, StyleClass.Label.H1, va_list()); + } + public Label H2Label(string? text, ...) + { + return Styled.Label(text, StyleClass.Label.H2, va_list()); + } + public Label H3Label(string? text, ...) + { + return Styled.Label(text, StyleClass.Label.H3, va_list()); + } + public Label H4Label(string? text, ...) + { + var label = Styled.Label(text, StyleClass.Label.H4, va_list()); + label.halign = Gtk.Align.START; + label.xalign = 0; + return label; + } + + public Frame Card(string main_class, ...) + { + var card = new Frame(null); + card.shadow_type = ShadowType.NONE; + StyleClass.add(card, StyleClass.CARD); + StyleClass.add(card, main_class); + StyleClass.add_va(card, va_list()); + return card; + } + } +} diff --git a/src/ui/widgets/TagRow.vala b/src/ui/widgets/TagRow.vala index 27709e24..07fb20e4 100644 --- a/src/ui/widgets/TagRow.vala +++ b/src/ui/widgets/TagRow.vala @@ -19,7 +19,7 @@ along with GameHub. If not, see . using Gtk; using Gdk; using Gee; -using Granite; + using GameHub.Data; using GameHub.Data.DB; diff --git a/src/ui/widgets/Welcome.vala b/src/ui/widgets/Welcome.vala new file mode 100644 index 00000000..d6bc2f88 --- /dev/null +++ b/src/ui/widgets/Welcome.vala @@ -0,0 +1,224 @@ +/* +This file is part of GameHub. +Copyright(C) 2018-2019 Anatoliy Kashkin + +GameHub is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GameHub is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GameHub. If not, see . +*/ + +/* Based on Granite.Widgets.Welcome */ + +using Gtk; + +namespace GameHub.UI.Widgets +{ + public class Welcome: EventBox + { + public signal void activated(int index); + protected new GLib.List