Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application: use startup #81

Merged
merged 2 commits into from
Sep 23, 2024
Merged
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
30 changes: 20 additions & 10 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,37 @@ public class Taxi.Taxi : Gtk.Application {
);
}

protected override void activate () {
var main_window = new MainWindow (
this,
new LocalFileAccess (),
new RemoteFileAccess (),
new FileOperations (),
new ConnectionSaver ()
);
protected override void startup () {
base.startup ();

Hdy.init ();

var provider = new Gtk.CssProvider ();
provider.load_from_resource ("com/github/alecaddd/taxi/Application.css");
Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);

var granite_settings = Granite.Settings.get_default ();
var gtk_settings = Gtk.Settings.get_default ();

gtk_settings.gtk_application_prefer_dark_theme = (
granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK
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 == Granite.Settings.ColorScheme.DARK
granite_settings.prefers_color_scheme == DARK
);
});
}

protected override void activate () {
var main_window = new MainWindow (
this,
new LocalFileAccess (),
new RemoteFileAccess (),
new FileOperations (),
new ConnectionSaver ()
);

main_window.show_all ();
}
Expand Down
6 changes: 0 additions & 6 deletions src/Frontend/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ class Taxi.MainWindow : Hdy.ApplicationWindow {
}

construct {
Hdy.init ();

connect_box = new ConnectBox ();
connect_box.valign = Gtk.Align.CENTER;

Expand Down Expand Up @@ -154,10 +152,6 @@ class Taxi.MainWindow : Hdy.ApplicationWindow {
maximize ();
}

var provider = new Gtk.CssProvider ();
provider.load_from_resource ("com/github/alecaddd/taxi/Application.css");
Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);

connect_box.connect_initiated.connect (on_connect_initiated);
connect_box.ask_hostname.connect (on_ask_hostname);
connect_box.bookmarked.connect (bookmark);
Expand Down