diff --git a/data/AlbumImage.css b/data/AlbumImage.css deleted file mode 100644 index 7180f244c..000000000 --- a/data/AlbumImage.css +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SPDX-License-Identifier: LGPL-3.0-or-later - * SPDX-FileCopyrightText: 2021 elementary, Inc. (https://elementary.io) - */ - -album { - background-image: - linear-gradient( - 170deg, - alpha( - @highlight_color, - 0.1 - ), - alpha( - @highlight_color, - 0.15 - ) 43%, - alpha( - @highlight_color, - 0 - ) 44% - ), - -gtk-icontheme("audio-x-generic-symbolic"), - linear-gradient( - to bottom, - @base_color, - @base_color - ); - background-size: cover, 50%, cover; - background-repeat: no-repeat; - background-position: center center; - color: alpha(@insensitive_fg_color, 0.75); -} diff --git a/data/PlaybackIndicator.css b/data/Application.css similarity index 66% rename from data/PlaybackIndicator.css rename to data/Application.css index db80e7cb3..bccb159ea 100644 --- a/data/PlaybackIndicator.css +++ b/data/Application.css @@ -1,16 +1,50 @@ -spinner { +/* + * SPDX-License-Identifier: LGPL-3.0-or-later + * SPDX-FileCopyrightText: 2021 elementary, Inc. (https://elementary.io) + */ + +album { + background-image: + linear-gradient( + 170deg, + alpha( + @highlight_color, + 0.1 + ), + alpha( + @highlight_color, + 0.15 + ) 43%, + alpha( + @highlight_color, + 0 + ) 44% + ), + -gtk-icontheme("audio-x-generic-symbolic"), + linear-gradient( + to bottom, + @base_color, + @base_color + ); + background-size: cover, 50%, cover; + background-repeat: no-repeat; + background-position: center center; + color: alpha(@insensitive_fg_color, 0.75); +} + +spinner.play-indicator { animation: none; color: @accent_color; min-width: 16px; transition: none; } -spinner:checked { +spinner.play-indicator:checked { opacity: 1; -gtk-icon-source: -gtk-icontheme("playback-paused-symbolic"); } -spinner:checked.playing { +spinner.play-indicator:checked.playing { animation: playing 1.1s linear infinite; -gtk-icon-source: -gtk-icontheme("playback-playing-00-symbolic"); } @@ -36,4 +70,3 @@ spinner:checked.playing { 95% { -gtk-icon-source: -gtk-icontheme("playback-playing-17-symbolic"); } 100% { -gtk-icon-source: -gtk-icontheme("playback-playing-00-symbolic"); } } - diff --git a/data/music.gresource.xml b/data/music.gresource.xml index b411c04c8..4e9ae4a65 100644 --- a/data/music.gresource.xml +++ b/data/music.gresource.xml @@ -1,9 +1,9 @@ - AlbumImage.css - - PlaybackIndicator.css + Application.css + + playback-indicator/paused.svg playback-indicator/playing-00.svg playback-indicator/playing-01.svg diff --git a/src/Application.vala b/src/Application.vala index 1b3c4df39..f27503c75 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -33,11 +33,10 @@ public class Music.Application : Gtk.Application { GLib.Intl.textdomain (Constants.GETTEXT_PACKAGE); } - protected override void activate () { - if (active_window != null) { - active_window.present_with_time (Gdk.CURRENT_TIME); - return; - } + protected override void startup () { + base.startup (); + + Granite.init (); add_action_entries (ACTION_ENTRIES, this); @@ -47,6 +46,29 @@ public class Music.Application : Gtk.Application { ((SimpleAction) lookup_action (ACTION_PREVIOUS)).set_enabled (false); ((SimpleAction) lookup_action (ACTION_SHUFFLE)).set_enabled (false); + var granite_settings = Granite.Settings.get_default (); + var gtk_settings = Gtk.Settings.get_default (); + + gtk_settings.gtk_icon_theme_name = "elementary"; + gtk_settings.gtk_theme_name = "io.elementary.stylesheet.orange"; + + gtk_settings.gtk_application_prefer_dark_theme = ( + granite_settings.prefers_color_scheme == DARK + ); + + granite_settings.notify["prefers-color-scheme"].connect (() => { + gtk_settings.gtk_application_prefer_dark_theme = ( + granite_settings.prefers_color_scheme == DARK + ); + }); + } + + protected override void activate () { + if (active_window != null) { + active_window.present (); + return; + } + playback_manager = PlaybackManager.get_default (); var mpris_id = Bus.own_name ( @@ -69,24 +91,6 @@ public class Music.Application : Gtk.Application { add_window (main_window); - Gtk.IconTheme.get_for_display (Gdk.Display.get_default ()).add_resource_path ("/io/elementary/music"); - - var granite_settings = Granite.Settings.get_default (); - var gtk_settings = Gtk.Settings.get_default (); - - gtk_settings.gtk_icon_theme_name = "elementary"; - gtk_settings.gtk_theme_name = "io.elementary.stylesheet.orange"; - - gtk_settings.gtk_application_prefer_dark_theme = ( - granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK - ); - - granite_settings.notify["prefers-color-scheme"].connect (() => { - gtk_settings.gtk_application_prefer_dark_theme = ( - granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK - ); - }); - /* * This is very finicky. Bind size after present else set_titlebar gives us bad sizes * Set maximize after height/width else window is min size on unmaximize diff --git a/src/Widgets/AlbumImage.vala b/src/Widgets/AlbumImage.vala index a92f5c806..0d7d45b81 100644 --- a/src/Widgets/AlbumImage.vala +++ b/src/Widgets/AlbumImage.vala @@ -6,21 +6,11 @@ public class Music.AlbumImage : Gtk.Grid { public Gtk.Image image; - private static Gtk.CssProvider css_provider; - class construct { set_css_name ("album"); } - static construct { - css_provider = new Gtk.CssProvider (); - css_provider.load_from_resource ("/io/elementary/music/AlbumImage.css"); - } - construct { - unowned var style_context = get_style_context (); - style_context.add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - image = new Gtk.Image (); add_css_class (Granite.STYLE_CLASS_CARD); diff --git a/src/Widgets/TrackRow.vala b/src/Widgets/TrackRow.vala index df929364a..4ac199d7c 100644 --- a/src/Widgets/TrackRow.vala +++ b/src/Widgets/TrackRow.vala @@ -6,7 +6,6 @@ public class Music.TrackRow : Gtk.ListBoxRow { public AudioObject audio_object { get; construct; } - private static Gtk.CssProvider css_provider; private static PlaybackManager playback_manager; private Gtk.Spinner play_icon; @@ -17,16 +16,13 @@ public class Music.TrackRow : Gtk.ListBoxRow { static construct { playback_manager = PlaybackManager.get_default (); - - css_provider = new Gtk.CssProvider (); - css_provider.load_from_resource ("io/elementary/music/PlaybackIndicator.css"); } construct { play_icon = new Gtk.Spinner () { spinning = playback_manager.current_audio == audio_object }; - play_icon.get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + play_icon.add_css_class ("play-indicator"); var album_image = new Music.AlbumImage (); album_image.image.height_request = 32;