Skip to content
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
6 changes: 0 additions & 6 deletions schemas/com.github.alecaddd.sequeler.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@
<description>Automatically Save a Quick Connections into the Database Library.</description>
</key>

<key name="dark-theme" type="b">
<default>false</default>
<summary>Use dark theme</summary>
<description>Switch between Light and Dark theme.</description>
</key>

<key name="version" type="s">
<default>""</default>
<summary>Current Version</summary>
Expand Down
20 changes: 20 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,26 @@ public class Sequeler.Application : Gtk.Application {
return window;
}

private static bool granite_color_scheme_to_gtk_dark_theme (Binding binding, Value granite_prop, ref Value gtk_prop) {
gtk_prop.set_boolean ((Granite.Settings.ColorScheme) granite_prop == Granite.Settings.ColorScheme.DARK);
return true;
}

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

// Follow OS-wide dark preference
unowned var granite_settings = Granite.Settings.get_default ();
unowned var gtk_settings = Gtk.Settings.get_default ();

granite_settings.bind_property ("prefers-color-scheme", gtk_settings, "gtk-application-prefer-dark-theme",
BindingFlags.DEFAULT | BindingFlags.SYNC_CREATE,
// FIXME: Using the lambda expression here causes Window not being freed when it's destroyed.
// Maybe due to this issue in vala: https://gitlab.gnome.org/GNOME/vala/-/issues/957
(BindingTransformFunc) granite_color_scheme_to_gtk_dark_theme
);
}

protected override void activate () {
this.add_new_window ();
}
Expand Down
16 changes: 0 additions & 16 deletions src/Layouts/HeaderBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class Sequeler.Layouts.HeaderBar : Gtk.HeaderBar {
private Gtk.Button new_db_button;
private Gtk.Button delete_db_button;
private Gtk.Button edit_db_button;
private Granite.ModeSwitch mode_switch;
private Gtk.Popover menu_popover;

public bool logged_out { get; set; }
Expand Down Expand Up @@ -85,19 +84,6 @@ public class Sequeler.Layouts.HeaderBar : Gtk.HeaderBar {
delete_db_button.visible = false;
delete_db_button.no_show_all = true;

mode_switch = new Granite.ModeSwitch.from_icon_name ("display-brightness-symbolic", "weather-clear-night-symbolic");
mode_switch.primary_icon_tooltip_text = _("Light background");
mode_switch.secondary_icon_tooltip_text = _("Dark background");
mode_switch.valign = Gtk.Align.CENTER;
mode_switch.bind_property ("active", settings, "dark-theme");
mode_switch.notify.connect (() => {
Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = settings.dark_theme;
});

if (settings.dark_theme) {
mode_switch.active = true;
}

var new_window_item = new_menuitem (_("New Window"), "<Control>n");
new_window_item.action_name = Sequeler.Services.ActionManager.ACTION_PREFIX + Sequeler.Services.ActionManager.ACTION_NEW_WINDOW;

Expand Down Expand Up @@ -140,8 +126,6 @@ public class Sequeler.Layouts.HeaderBar : Gtk.HeaderBar {
pack_start (delete_db_button);

pack_end (open_menu);
pack_end (headerbar_separator ());
pack_end (mode_switch);
}

private Gtk.ModelButton new_menuitem (string label, string accels) {
Expand Down
4 changes: 0 additions & 4 deletions src/Services/Settings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ public class Sequeler.Services.Settings : GLib.Settings {
get { return get_int ("limit-results"); }
set { set_int ("limit-results", value); }
}
public bool dark_theme {
get { return get_boolean ("dark-theme"); }
set { set_boolean ("dark-theme", value); }
}
public bool save_quick {
get { return get_boolean ("save-quick"); }
set { set_boolean ("save-quick", value); }
Expand Down
2 changes: 0 additions & 2 deletions src/Window.vala
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ public class Sequeler.Window : Gtk.ApplicationWindow {
}

private void build_ui () {
Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = settings.dark_theme;

var css_provider = new Gtk.CssProvider ();
css_provider.load_from_resource ("/com/github/alecaddd/sequeler/stylesheet.css");

Expand Down