Skip to content

Commit

Permalink
Application: use startup (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Jun 13, 2023
1 parent e68337d commit c7b60ca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
4 changes: 3 additions & 1 deletion data/gresource.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/io/elementary/tasks">
<file alias="location-marker.svg" compressed="true" preprocess="xml-stripblanks">LocationMarker.svg</file>
<file compressed="true">EditableLabel.css</file>
<file compressed="true">EntryPopover.css</file>
<file compressed="true">SourceRow.css</file>
<file compressed="true">TaskRow.css</file>
</gresource>
<gresource prefix="/io/elementary/tasks/icons">
<file alias="location-marker.svg" compressed="true" preprocess="xml-stripblanks">LocationMarker.svg</file>
</gresource>
</gresources>
24 changes: 15 additions & 9 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ public class Tasks.Application : Gtk.Application {
GLib.Intl.textdomain (GETTEXT_PACKAGE);

add_main_option_entries (OPTIONS);
}

protected override void startup () {
base.startup ();

Hdy.init ();

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

gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == DARK;

granite_settings.notify["prefers-color-scheme"].connect ((obj) => {
gtk_settings.gtk_application_prefer_dark_theme = ((Granite.Settings) obj).prefers_color_scheme == DARK;
});

var quit_action = new SimpleAction ("quit", null);
quit_action.activate.connect (() => {
Expand Down Expand Up @@ -101,15 +116,6 @@ public class Tasks.Application : Gtk.Application {
main_window.maximize ();
}

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.notify["prefers-color-scheme"].connect (() => {
gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK;
});

main_window.show_all ();
}

Expand Down
4 changes: 0 additions & 4 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow {
}

static construct {
Hdy.init ();

action_accelerators[ACTION_DELETE_SELECTED_LIST] = "<Control>BackSpace";

Gtk.IconTheme.get_default ().add_resource_path ("/io/elementary/tasks");
}

construct {
Expand Down

0 comments on commit c7b60ca

Please sign in to comment.