Implement support for dedicated theme CSS files from our gresource.
Properly implement light and gruvbox themes. Yay!
This commit is contained in:
parent
4cc5c6efd4
commit
8334323af8
27 changed files with 285 additions and 121 deletions
|
@ -75,8 +75,6 @@ static void koto_window_init (KotoWindow * self) {
|
|||
current_playlist = koto_current_playlist_new();
|
||||
playback_engine = koto_playback_engine_new();
|
||||
|
||||
self->provider = gtk_css_provider_new();
|
||||
gtk_css_provider_load_from_resource(self->provider, "/com/github/joshstrobl/koto/style.css");
|
||||
koto_window_manage_style(config, 0, self); // Immediately apply the theme
|
||||
g_signal_connect(config, "notify::ui-theme-desired", G_CALLBACK(koto_window_manage_style), self); // Handle changes to desired theme
|
||||
g_signal_connect(config, "notify::ui-theme-override", G_CALLBACK(koto_window_manage_style), self); // Handle changes to theme overriding
|
||||
|
@ -184,12 +182,14 @@ void koto_window_manage_style(
|
|||
desired_theme = "dark";
|
||||
}
|
||||
|
||||
GtkStyleContext * context = gtk_widget_get_style_context(GTK_WIDGET(self));
|
||||
if (!GTK_IS_CSS_PROVIDER(self->provider)) { // Don't have a CSS provider yet
|
||||
self->provider = gtk_css_provider_new();
|
||||
}
|
||||
|
||||
gtk_css_provider_load_from_resource(self->provider, g_strdup_printf("/com/github/joshstrobl/koto/koto-builtin-%s.css", desired_theme));
|
||||
|
||||
if (!overriding_theme) { // If we are not overriding the theme
|
||||
if (!gtk_style_context_has_class(context, "koto-theme-dark")) { // Don't have our css class for a theme
|
||||
gtk_style_context_add_provider_for_display(gdk_display_get_default(), GTK_STYLE_PROVIDER(self->provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
}
|
||||
gtk_style_context_add_provider_for_display(gdk_display_get_default(), GTK_STYLE_PROVIDER(self->provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
GList * themes = NULL;
|
||||
themes = g_list_append(themes, "dark");
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/com/github/joshstrobl/koto">
|
||||
<file alias="style.css">../theme/style.css</file>
|
||||
<file alias="koto-builtin-dark.css">../theme/koto-builtin-dark.css</file>
|
||||
<file alias="koto-builtin-gruvbox.css">../theme/koto-builtin-gruvbox.css</file>
|
||||
<file alias="koto-builtin-light.css">../theme/koto-builtin-light.css</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
|
|
@ -55,7 +55,7 @@ gnome = import('gnome')
|
|||
|
||||
koto_sources += gnome.compile_resources('koto-resources',
|
||||
'koto.gresource.xml',
|
||||
dependencies: [ theme ],
|
||||
dependencies: themes,
|
||||
c_name: 'koto',
|
||||
)
|
||||
|
||||
|
|
|
@ -105,7 +105,11 @@ static void koto_album_view_init(KotoAlbumView * self) {
|
|||
gtk_box_append(GTK_BOX(self->album_tracks_box), self->discs); // Add the discs list box to the albums tracks box
|
||||
|
||||
self->album_cover = koto_cover_art_button_new(220, 220, NULL);
|
||||
gtk_box_prepend(GTK_BOX(self->main), koto_cover_art_button_get_main(self->album_cover));
|
||||
GtkWidget * album_cover_main = koto_cover_art_button_get_main(self->album_cover);
|
||||
|
||||
gtk_widget_set_valign(album_cover_main, GTK_ALIGN_START);
|
||||
|
||||
gtk_box_prepend(GTK_BOX(self->main), album_cover_main);
|
||||
KotoButton * cover_art_button = koto_cover_art_button_get_button(self->album_cover); // Get the button for the cover art
|
||||
koto_button_add_click_handler(cover_art_button, KOTO_BUTTON_CLICK_TYPE_PRIMARY, G_CALLBACK(koto_album_view_toggle_album_playback), self);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue