Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,10 @@ public class MyApp : Gtk.Application {

settings.bind ("window-maximized", main_window, "maximized", SettingsBindFlags.SET);

// Use Css
var provider = new Gtk.CssProvider ();
provider.load_from_resource ("/io/github/yourusername/yourrepositoryname/Application.css");

Gtk.StyleContext.add_provider_for_display (
Gdk.Display.get_default (),
provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
);

main_window.present ();
}

public static int main (string[] args) {
return new MyApp ().run (args);
}
}
}
6 changes: 5 additions & 1 deletion src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public class MainWindow : Gtk.ApplicationWindow {
}

construct {
var provider = new Gtk.CssProvider ();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You actually don't need to do this step at all anymore. Granite automatically loads gresourced stylesheets called "Application.css"

provider.load_from_resource ("/io/github/yourusername/yourrepositoryname/Application.css");
add_css_class (provider.to_string());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not do what you think it does 😅 you'd just get a probably invalid super long css class name. This won't load any styles


var start_header = new Gtk.HeaderBar () {
show_title_buttons = false,
title_widget = new Gtk.Label ("")
Expand Down Expand Up @@ -64,4 +68,4 @@ public class MainWindow : Gtk.ApplicationWindow {
gtk_settings.gtk_theme_name = "io.elementary.stylesheet.blueberry";
}
}
}
}