Skip to content

Commit

Permalink
GNOME 47 “Denver” (#47)
Browse files Browse the repository at this point in the history
* Settings: redo dialog

* Settings: change default dark color

* Update screenshots

* Bump dependencies

* MetaInfo: add updated screenshots

* MetaInfo: More release notes

* Lint: remove extra newline

* Actions: Update to GNOME 47, add release-test job

* Revert container image change; change Devel manifest to 47
  • Loading branch information
cassidyjames authored Sep 19, 2024
1 parent 90ab176 commit 25ed118
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 93 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@ jobs:
bundle: com.cassidyjames.butler.Devel.flatpak
manifest-path: com.cassidyjames.butler.Devel.json
cache-key: "flatpak-builder-${{ github.sha }}"
flatpak-release:
name: Flatpak (Release)
runs-on: ubuntu-latest
container:
image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-46
options: --privileged
steps:
- uses: actions/checkout@v4
- uses: flathub-infra/flatpak-github-actions/flatpak-builder@master
with:
bundle: com.cassidyjames.butler.flatpak
manifest-path: com.cassidyjames.butler.json
cache-key: "flatpak-builder-${{ github.sha }}"
2 changes: 1 addition & 1 deletion com.cassidyjames.butler.Devel.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"app-id": "com.cassidyjames.butler.Devel",
"runtime": "org.gnome.Platform",
"runtime-version": "46",
"runtime-version": "47",
"sdk": "org.gnome.Sdk",
"command": "com.cassidyjames.butler.Devel",
"finish-args": [
Expand Down
2 changes: 1 addition & 1 deletion com.cassidyjames.butler.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"app-id": "com.cassidyjames.butler",
"runtime": "org.gnome.Platform",
"runtime-version": "46",
"runtime-version": "47",
"sdk": "org.gnome.Sdk",
"command": "com.cassidyjames.butler",
"finish-args": [
Expand Down
2 changes: 2 additions & 0 deletions data/gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
<file>style-dark.css</file>
<file alias="Devel/style.css">style.css</file>
<file alias="Devel/style-dark.css">style-dark.css</file>
<file alias="icons/scalable/actions/step-back-symbolic.svg" preprocess="xml-stripblanks">icons/step-back-symbolic.svg</file>
<file alias="Devel/icons/scalable/actions/step-back-symbolic.svg" preprocess="xml-stripblanks">icons/step-back-symbolic.svg</file>
</gresource>
</gresources>
2 changes: 1 addition & 1 deletion data/gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<description>The last-viewed URL for restoring state</description>
</key>
<key name="headerbar-colors" type="(ss)">
<default>("#03a9f5", "#03a9f5")</default>
<default>("#03a9f5", "#101e24")</default>
<summary>Headerbar Colors</summary>
<description>Colors for the header bar to better integrate into custom servers, stored as a (light, dark) pair to be used according to the system color scheme preference</description>
</key>
Expand Down
2 changes: 2 additions & 0 deletions data/icons/step-back-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 21 additions & 2 deletions data/metainfo.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,35 @@

<screenshots>
<screenshot type="default">
<image>https://raw.githubusercontent.com/cassidyjames/butler/518b5c81e35d366fa6ea62d4835d8e9a61e039e1/data/screenshots/light.png</image>
<image>https://raw.githubusercontent.com/cassidyjames/butler/3c3c6f7182049db184e6f7533326d5240ea3bdfc/data/screenshots/light.png</image>
<caption>Home Assistant dashboard with many rooms and devices</caption>
</screenshot>
<screenshot>
<image>https://raw.githubusercontent.com/cassidyjames/butler/518b5c81e35d366fa6ea62d4835d8e9a61e039e1/data/screenshots/dark.png</image>
<image>https://raw.githubusercontent.com/cassidyjames/butler/3c3c6f7182049db184e6f7533326d5240ea3bdfc/data/screenshots/light-settings.png</image>
<caption>Available settings, including server URL and custom header colors</caption>
</screenshot>
<screenshot>
<image>https://raw.githubusercontent.com/cassidyjames/butler/3c3c6f7182049db184e6f7533326d5240ea3bdfc/data/screenshots/dark.png</image>
<caption>Home Assistant dashboard in dark style</caption>
</screenshot>
<screenshot>
<image>https://raw.githubusercontent.com/cassidyjames/butler/3c3c6f7182049db184e6f7533326d5240ea3bdfc/data/screenshots/dark-settings.png</image>
<caption>Available settings in dark style</caption>
</screenshot>
</screenshots>

<releases>
<release version="1.3.0" date="2024-09-18">
<description>
<p>GNOME 47 “Denver”</p>
<ul>
<li>Updated with the latest GNOME 47 platform and design</li>
<li>Matched the default dark header color to the Home Assistant dark theme</li>
<li>Reworked adaptive “Settings” dialog with individually-resettable options</li>
<li>Improved reliability of saving server URLs</li>
</ul>
</description>
</release>
<release version="1.2.0" date="2024-08-27">
<description>
<p>The Rise of Settings</p>
Expand Down
Binary file added data/screenshots/dark-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/screenshots/dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/screenshots/light-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/screenshots/light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
project(
'com.cassidyjames.butler',
'vala', 'c',
version: '1.2.0',
meson_version: '>=1.1',
version: '1.3.0',
meson_version: '>=1.5.1',
)

app_id = meson.project_name()
Expand Down
175 changes: 93 additions & 82 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
*/

public class Butler.MainWindow : Adw.ApplicationWindow {
public Adw.AboutDialog about_dialog;
public Adw.Banner demo_banner;
public Adw.Toast fullscreen_toast;
public Adw.ToastOverlay toast_overlay;
public Gtk.Revealer header_revealer;
public Gtk.Revealer home_revealer;

private const GLib.ActionEntry[] ACTION_ENTRIES = {
{ "toggle_fullscreen", toggle_fullscreen },
{ "settings", on_settings_activate },
{ "log_out", on_log_out_activate },
{ "about", on_about_activate },
};

private Adw.Banner demo_banner;
private Adw.Toast fullscreen_toast;
private Adw.ToastOverlay toast_overlay;
private Gtk.Revealer header_revealer;
private Gtk.Revealer home_revealer;
private Adw.AboutDialog about_dialog;
private Butler.WebView web_view;
private Gtk.ColorDialogButton color_light_button;
private Gtk.ColorDialogButton color_dark_button;

private const string CSS = """
@define-color headerbar_bg_light %s;
Expand Down Expand Up @@ -81,7 +82,7 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
var app_menu = new Menu ();
// TODO: How do I add shortcuts to the menu?
app_menu.append (_("_Fullscreen"), "win.toggle_fullscreen");
app_menu.append (_("_Server Settings"), "win.settings");
app_menu.append (_("_Settings"), "win.settings");
app_menu.append (_("_About %s").printf (APP_NAME), "win.about");

var menu = new Menu ();
Expand Down Expand Up @@ -171,10 +172,6 @@ public class Butler.MainWindow : Adw.ApplicationWindow {

web_view.load_changed.connect ((load_event) => {
if (load_event == WebKit.LoadEvent.FINISHED) {
// NOTE: As of WebKitGTK in the GNOME 46 SDK, this seems
// glitchier… not sure how to fix it. A GLib.Timeout doesn't
// seem to help, as it just looks glitchy after the stack child
// changes to the WebView.
stack.visible_child_name = "web";
}
});
Expand Down Expand Up @@ -242,6 +239,8 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
} else if (current_url.has_prefix (server)) {
demo_banner.revealed = false;
} else {
// Somehow you got away from the server without opening a link
// in the browser…
demo_banner.revealed = false;
home_revealer.set_reveal_child (true);
}
Expand Down Expand Up @@ -282,8 +281,6 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
}

private void log_out () {
// Home Assistant doesn't use cookies for login; clear ALL to include
// local storage and cache
web_view.network_session.get_website_data_manager ().clear.begin (
WebKit.WebsiteDataTypes.ALL, 0, null, () => {
debug ("Cleared data; going home.");
Expand Down Expand Up @@ -317,19 +314,28 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
var current_rgba_dark = Gdk.RGBA ();
current_rgba_dark.parse (current_color_dark);

var server_reset_button = new Gtk.Button.from_icon_name ("step-back-symbolic") {
tooltip_text = _("Reset to Demo"),
valign = Gtk.Align.CENTER,
};
server_reset_button.add_css_class ("flat");

var server_entry = new Adw.EntryRow () {
activates_default = true,
input_purpose = Gtk.InputPurpose.URL,
show_apply_button = true,
text = current_server,
title = _("Server URL"),
};
server_entry.add_suffix (server_reset_button);

var server_group = new Adw.PreferencesGroup () {
title = _("Server Settings"),
title = _("Server"),
description = _("Enter the full URL including any custom port"),
};
server_group.add (server_entry);

var color_light_button = new Gtk.ColorDialogButton (new Gtk.ColorDialog ()) {
color_light_button = new Gtk.ColorDialogButton (new Gtk.ColorDialog ()) {
rgba = current_rgba_light,
valign = Gtk.Align.CENTER,
};
Expand All @@ -341,7 +347,7 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
};
color_light_row.add_suffix (color_light_button);

var color_dark_button = new Gtk.ColorDialogButton (new Gtk.ColorDialog ()) {
color_dark_button = new Gtk.ColorDialogButton (new Gtk.ColorDialog ()) {
rgba = current_rgba_dark,
valign = Gtk.Align.CENTER,
};
Expand All @@ -353,91 +359,96 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
};
color_dark_row.add_suffix (color_dark_button);

var colors_group = new Adw.PreferencesGroup () {
title = _("Header Bar Color"),
var color_reset_button = new Gtk.Button.from_icon_name ("step-back-symbolic") {
tooltip_text = _("Reset to Default"),
valign = Gtk.Align.CENTER,
};
color_reset_button.add_css_class ("flat");

var color_group = new Adw.PreferencesGroup () {
title = _("Header Colors"),
description = _("Better match your dashboard"),
};
colors_group.add (color_light_row);
colors_group.add (color_dark_row);
color_group.add (color_light_row);
color_group.add (color_dark_row);
color_group.set_header_suffix (color_reset_button);

var settings_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 24);
settings_box.append (server_group);
settings_box.append (colors_group);
var settings_page = new Adw.PreferencesPage ();
settings_page.add (server_group);
settings_page.add (color_group);

var settings_dialog = new Adw.AlertDialog (null, null) {
body_use_markup = true,
default_response = "save",
extra_child = settings_box,
var settings_dialog = new Adw.PreferencesDialog () {
content_width = 480,
title = _("Settings"),
};
settings_dialog.add_response ("close", _("_Cancel"));
settings_dialog.add (settings_page);

settings_dialog.add_response ("reset", _("_Reset to Default"));
settings_dialog.set_response_appearance ("reset", Adw.ResponseAppearance.DESTRUCTIVE);
settings_dialog.present (this);

settings_dialog.add_response ("save", _("_Save"));
settings_dialog.set_response_appearance ("save", Adw.ResponseAppearance.SUGGESTED);
server_entry.apply.connect (() => {
string new_server = server_entry.text.strip ();

settings_dialog.present (this);
if (new_server == "") {
new_server = default_server;
}

settings_dialog.response.connect ((response_id) => {
switch (response_id) {
case "save":
string new_server = server_entry.text;
string new_color_light = color_light_button.get_rgba ().to_string ();
string new_color_dark = color_dark_button.get_rgba ().to_string ();

if (new_server == "") {
new_server = default_server;
}

if (!new_server.contains ("://")) {
new_server = "http://" + new_server;
}

if (new_server != current_server) {
// FIXME: There's currently no validation of this
App.settings.set_string ("server", new_server);
log_out ();
}

if (
new_color_light != current_color_light ||
new_color_dark != current_color_dark
) {
App.settings.set (
"headerbar-colors", "(ss)", new_color_light, new_color_dark
);
update_headerbar_colors (new_color_light, new_color_dark);
}
break;

case "reset":
App.settings.reset ("headerbar-colors");
App.settings.reset ("server");

string color_light, color_dark;
App.settings.get ("headerbar-colors", "(ss)", out color_light, out color_dark);
update_headerbar_colors (color_light, color_dark);

log_out ();
break;

case "close":
default:
break;
if (!new_server.contains ("://")) {
new_server = "http://" + new_server;
}

if (new_server != current_server) {
// FIXME: There's currently no validation of this
App.settings.set_string ("server", new_server);
log_out ();
}
});

server_reset_button.clicked.connect (() => {
server_entry.text = default_server;
server_entry.apply ();
});

color_reset_button.clicked.connect (() => {
string light, dark;

App.settings.reset ("headerbar-colors");
App.settings.get ("headerbar-colors", "(ss)", out light, out dark);

var light_rgba = Gdk.RGBA ();
light_rgba.parse (light);

var dark_rgba = Gdk.RGBA ();
dark_rgba.parse (dark);

color_light_button.rgba = light_rgba;
color_dark_button.rgba = dark_rgba;
});

color_light_button.notify["rgba"].connect (on_color_button_change);
color_dark_button.notify["rgba"].connect (on_color_button_change);
}

private void on_color_button_change () {
string light = color_light_button.get_rgba ().to_string ();
string dark = color_dark_button.get_rgba ().to_string ();

App.settings.set (
"headerbar-colors", "(ss)", light, dark
);

update_headerbar_colors (light, dark);
}

private void on_log_out_activate () {
string server = App.settings.get_string ("server");

var log_out_dialog = new Adw.AlertDialog (
_("Log out of Home Assistant?"),
_("You will need to re-enter your username and password for <b>%s</b> to log back in.").printf (server)
_("You will need to re-enter any username and password required to log back in to <b>%s</b>.").printf (server)
) {
body_use_markup = true,
default_response = "log_out"
default_response = "log_out",
prefer_wide_layout = true,
};
log_out_dialog.add_response ("close", _("_Stay Logged In"));
log_out_dialog.add_response ("log_out", _("_Log Out"));
Expand Down
8 changes: 4 additions & 4 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ executable(
config_file,
include_directories: config_include,
dependencies: [
dependency('glib-2.0'),
dependency('gtk4'),
dependency('libadwaita-1', version: '>=1.5'),
dependency('webkitgtk-6.0'),
dependency('glib-2.0', version: '>=2.82.0'),
dependency('gtk4', version: '>=4.16.1'),
dependency('libadwaita-1', version: '>=1.6.0'),
dependency('webkitgtk-6.0', version: '>=2.46.0'),
meson.get_compiler('c').find_library('m'), # GLib.Math
meson.get_compiler('vala').find_library('posix'),
],
Expand Down

0 comments on commit 25ed118

Please sign in to comment.