@@ -29,28 +29,22 @@ use mainwindow::MainWindow;
29
29
mod settingswindow;
30
30
31
31
// Imports
32
- //use std::env;
33
- //use std::path::Path;
34
- //use libappindicator::{
35
- // /* SysTray */ AppIndicator, AppIndicatorStatus
36
- //};
37
-
38
32
use adwaita:: prelude:: * ;
39
- //use gtk::Application;
40
33
use adwaita:: {
41
34
/* Libraries */ gio,
42
35
/* Application */ Application ,
43
- // SplitButton
44
36
} ;
45
- use gio:: { resources_register_include, Settings } ;
37
+ use gtk:: { CssProvider , StyleContext } ;
38
+ use gio:: { resources_register_include} ;
39
+ use gdk:: { Display } ;
46
40
47
41
// Constants
48
- const APP_ID : & str = "com.gtk_d.NvidiaExtensionRust " ;
42
+ const APP_ID : & str = "com.gtk_d.NvidiaMonitorRust " ;
49
43
50
44
// Main Function
51
45
fn main ( ) {
52
46
// Resources
53
- resources_register_include ! ( "nvidiaextensionrust .gresource" )
47
+ resources_register_include ! ( "nvidiamonitorrust .gresource" )
54
48
. expect ( "Failed to register resources." ) ;
55
49
56
50
// Intialise GTK
@@ -59,8 +53,9 @@ fn main() {
59
53
// Create a new application
60
54
let app: Application = Application :: builder ( ) . application_id ( APP_ID ) . build ( ) ;
61
55
62
- // Connect to "activate" signal of `app`
56
+ // Connect to signals of `app`
63
57
//app.connect_startup(setup_shortcuts);
58
+ app. connect_startup ( |_| load_css ( ) ) ;
64
59
app. connect_activate ( build_ui) ;
65
60
66
61
// Run the application
@@ -77,6 +72,20 @@ fn setup_shortcuts(app: &Application) {
77
72
}
78
73
*/
79
74
75
+ // Load CSS styles
76
+ fn load_css ( ) {
77
+ // Load the CSS file and add it to the provider
78
+ let provider = CssProvider :: new ( ) ;
79
+ provider. load_from_path ( "style.css" ) ;
80
+
81
+ // Add the provider to the default screen
82
+ StyleContext :: add_provider_for_display (
83
+ & Display :: default ( ) . expect ( "..Could not connect to a display." ) ,
84
+ & provider,
85
+ gtk:: STYLE_PROVIDER_PRIORITY_APPLICATION ,
86
+ ) ;
87
+ }
88
+
80
89
// Build Function
81
90
fn build_ui ( app : & Application ) {
82
91
// Create a new custom window and show it
0 commit comments