Skip to content

Commit

Permalink
Merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Jan 23, 2024
2 parents 7c88a79 + c0c3399 commit 476f5ac
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,33 @@ namespace Switchboard {
activate ();
}

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

Granite.init ();

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;
});

var back_action = new SimpleAction ("back", null);
var quit_action = new SimpleAction ("quit", null);

add_action (back_action);
add_action (quit_action);

set_accels_for_action ("app.back", {"<Alt>Left", "Back"});
set_accels_for_action ("app.quit", {"<Control>q"});

back_action.activate.connect (action_navigate_back);
quit_action.activate.connect (quit);
}

public override void activate () {
var plugsmanager = Switchboard.PlugsManager.get_default ();
if (link != null) {
Expand Down Expand Up @@ -106,26 +133,8 @@ namespace Switchboard {
return;
}

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;
});

plug_widgets = new GLib.HashTable <Gtk.Widget, Switchboard.Plug> (null, null);

var back_action = new SimpleAction ("back", null);
var quit_action = new SimpleAction ("quit", null);

add_action (back_action);
add_action (quit_action);

set_accels_for_action ("app.back", {"<Alt>Left", "Back"});
set_accels_for_action ("app.quit", {"<Control>q"});

navigation_button = new Gtk.Button.with_label (_(all_settings_label));
navigation_button.action_name = "app.back";
navigation_button.set_tooltip_markup (
Expand Down Expand Up @@ -181,14 +190,6 @@ namespace Switchboard {

main_window.bind_property ("title", title_label, "label");

back_action.activate.connect (() => {
handle_navigation_button_clicked ();
});

quit_action.activate.connect (() => {
quit ();
});

shutdown.connect (() => {
if (plug_widgets[leaflet.visible_child] != null && plug_widgets[leaflet.visible_child] is Switchboard.Plug) {
plug_widgets[leaflet.visible_child].hidden ();
Expand Down Expand Up @@ -294,7 +295,7 @@ namespace Switchboard {
}

// Handles clicking the navigation button
private void handle_navigation_button_clicked () {
private void action_navigate_back () {
if (leaflet.get_adjacent_child (Adw.NavigationDirection.BACK) == category_view) {
opened_directly = false;
leaflet.mode_transition_duration = 200;
Expand Down

0 comments on commit 476f5ac

Please sign in to comment.