Skip to content

Commit

Permalink
Merge pull request #14 from cassidyjames/about
Browse files Browse the repository at this point in the history
Small improvements
  • Loading branch information
cassidyjames authored Jan 6, 2024
2 parents aebe43a + c562dd8 commit 13ce25d
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 98 deletions.
25 changes: 0 additions & 25 deletions build-aux/meson/post_install.py

This file was deleted.

3 changes: 2 additions & 1 deletion data/gresource.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/cassidyjames/butler">
<gresource prefix="/com/cassidyjames/butler/">
<file preprocess="xml-stripblanks">metainfo.xml</file>
<file>style.css</file>
</gresource>
<gresource prefix="/com/cassidyjames/butler/icons/scalable/actions/">
Expand Down
23 changes: 20 additions & 3 deletions data/metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
<metadata_license>CC-BY-SA-4.0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>

<name>Butler for Home Assistant</name>
<summary>Control your smart home</summary>
<name>Butler</name>
<summary>Access your Home Assistant dashboard</summary>
<developer_name translatable="no">Cassidy James Blaede</developer_name>
<developer id="cassidyjames.com">
<name translatable="no">Cassidy James Blaede</name>
</developer>
<description>
<p>Hybrid native + web app for Home Assistant. Butler wraps your Home Assistant dashboard up in a native UI, integrating better with your OS. Native features include:</p>
<p>Hybrid native + web companion app for Home Assistant. Butler wraps your dashboard up in a native UI, integrating better with your OS. Native features include:</p>
<ul>
<li>Icon in your App Grid, Applications Menu, Dash, Dock, etc.</li>
<li>Native header bar</li>
<li>Save and restore current view and size when closed and re-opened</li>
<li>Two-finger swipe and mouse button support to go back/forward between views</li>
<li>Cross-desktop light/dark style support (if supported by your Lovelace theme)</li>
</ul>
<p>Butler is designed to make getting at your Home Assistant dashboard easier for kiosks, your laptop/desktop, or your Linux phone. It does not support companion app features from Android and iOS like location services, notifications, or exposing device sensors.</p>
<p>Other features include:</p>
<ul>
<li>Pinch-to-zoom</li>
Expand Down Expand Up @@ -55,6 +56,22 @@
</screenshots>

<releases>
<release version="1.0.2" date="2024-01-06">
<description>
<p>Small improvements</p>
<ul>
<li>Improved about window</li>
<li>Open links in default browser</li>
<li>Automatically prepend http:// to custom server if omitted</li>
<li>Start preparing for translations</li>
</ul>
</description>
<issues>
<issue url="https://github.com/cassidyjames/butler/issues/4">Better onboarding</issue>
<issue url="https://github.com/cassidyjames/butler/issues/8">Open links in default browser</issue>
<issue url="https://github.com/cassidyjames/butler/issues/13">Automatically prepend http:// to custom server if omitted</issue>
</issues>
</release>
<release version="1.0.1" date="2024-01-05">
<description>
<p>Improved accessibility and fullscreen experience</p>
Expand Down
7 changes: 3 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
project(
'com.cassidyjames.butler',
'vala', 'c',
version: '1.0.1'
version: '1.0.2',
meson_version: '>=0.58',
)

gnome = import('gnome')
Expand Down Expand Up @@ -35,13 +36,11 @@ executable(
dependencies: [
dependency('glib-2.0'),
dependency('gtk4'),
dependency('libadwaita-1'),
dependency('libadwaita-1', version: '>=1.4.2'),
dependency('webkitgtk-6.0'),
meson.get_compiler('vala').find_library('posix'),
],
install: true
)

subdir('data')

meson.add_install_script('build-aux' / 'meson'/ 'post_install.py')
9 changes: 1 addition & 8 deletions src/App.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@
*/

public class Butler.App : Adw.Application {
public const string NAME = "Butler";
public const string DEVELOPER = "Cassidy James Blaede";
public const string EMAIL = "[email protected]";
public const string URL = "https://cassidyjames.com";

public static GLib.Settings settings;

public App () {
Object (
application_id: APP_ID
);
Object ( application_id: APP_ID );
}

public static App _instance = null;
Expand Down
111 changes: 72 additions & 39 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
*/

public class Butler.MainWindow : Adw.ApplicationWindow {
public Adw.AboutWindow about_window;
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 },
Expand All @@ -21,9 +24,7 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
Object (
application: application,
height_request: 180,
icon_name: APP_ID,
resizable: true,
title: App.NAME,
width_request: 300
);
add_action_entries (ACTION_ENTRIES, this);
Expand All @@ -33,14 +34,45 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
maximized = App.settings.get_boolean ("window-maximized");
fullscreened = App.settings.get_boolean ("window-fullscreened");

about_window = new Adw.AboutWindow.from_appdata (
"/com/cassidyjames/butler/metainfo.xml", VERSION
) {
transient_for = this,
hide_on_close = true,
comments = _("Companion app to access your Home Assistant dashboard"),

/// The translator credits. Please translate this with your name(s).
translator_credits = _("translator-credits"),
};
about_window.copyright = "© 2020–%i %s".printf (
new DateTime.now_local ().get_year (),
about_window.developer_name
);
about_window.add_link (_("About Home Assistant"), "https://www.home-assistant.io/");
about_window.add_link (_("Home Assistant Privacy Policy"), "https://www.home-assistant.io/privacy/");

// Set MainWindow properties from the AppData already fetched and parsed
// by the AboutWindow construction
icon_name = about_window.application_icon;
title = about_window.application_name;

var home_button = new Gtk.Button.from_icon_name ("go-home-symbolic") {
tooltip_text = _("Go Home")
};

home_revealer = new Gtk.Revealer () {
child = home_button,
transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT
};

var site_menu = new Menu ();
site_menu.append (_("_Log Out…"), "win.log_out");

var app_menu = new Menu ();
// TODO: How do I add shortcuts to the menu?
app_menu.append (_("_Fullscreen"), "win.toggle_fullscreen");
app_menu.append (_("Change _Server…"), "win.set_server");
app_menu.append (_("_About %s").printf (App.NAME), "win.about");
app_menu.append (_("_About %s").printf (title), "win.about");

var menu = new Menu ();
menu.append_section (null, site_menu);
Expand All @@ -53,14 +85,20 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
};

var header = new Adw.HeaderBar ();
header.pack_start (home_revealer);
header.pack_end (menu_button);

header_revealer = new Gtk.Revealer () {
child = header,
reveal_child = !fullscreened
};

fullscreen_toast = new Adw.Toast ("Press <b>Ctrl F</b> or <b>F11</b> to toggle fullscreen") {
demo_banner = new Adw.Banner (_("Browsing Home Assistant Demo")) {
action_name = "win.set_server",
button_label = _("Set _Server…")
};

fullscreen_toast = new Adw.Toast (_("Press <b>Ctrl F</b> or <b>F11</b> to toggle fullscreen")) {
action_name = "win.toggle_fullscreen",
button_label = _("Exit _Fullscreen")
};
Expand All @@ -76,7 +114,7 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
}

var status_page = new Adw.StatusPage () {
title = _("%s for Home Assistant").printf (App.NAME),
title = title,
description = _("Loading the dashboard…"),
icon_name = APP_ID
};
Expand All @@ -99,6 +137,7 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
};
grid.attach (header_revealer, 0, 0);
grid.attach (toast_overlay, 0, 1);
grid.attach (demo_banner, 0, 2);

set_content (grid);

Expand All @@ -107,6 +146,10 @@ public class Butler.MainWindow : Adw.ApplicationWindow {

set_default_size (window_width, window_height);

home_button.clicked.connect (() => {
web_view.load_uri (server);
});

close_request.connect (() => {
save_window_state ();
return Gdk.EVENT_PROPAGATE;
Expand Down Expand Up @@ -148,7 +191,20 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
if (web_view.is_loading) {
// TODO: Add a loading progress bar or spinner somewhere?
} else {
App.settings.set_string ("current-url", web_view.uri);
string default_server = App.settings.get_default_value ("server").get_string ();
string server = App.settings.get_string ("server");
string current_url = web_view.uri;

App.settings.set_string ("current-url", current_url);

if (current_url.has_prefix (default_server)) {
demo_banner.revealed = true;
} else if (current_url.has_prefix (server)) {
demo_banner.revealed = false;
} else {
demo_banner.revealed = false;
home_revealer.set_reveal_child (true);
}
}
}

Expand Down Expand Up @@ -220,14 +276,14 @@ public class Butler.MainWindow : Adw.ApplicationWindow {

var server_dialog = new Adw.MessageDialog (
this,
"Set Server URL",
"Enter the full URL including protocol (e.g. <tt>http://</tt>) and any custom port (e.g. <tt>:8123</tt>)"
_("Set Server URL"),
_("Enter the full URL including any custom port")
) {
body_use_markup = true,
default_response = "save",
extra_child = server_entry,
};
server_dialog.add_response ("close", "_Cancel");
server_dialog.add_response ("close", _("_Cancel"));

server_dialog.add_response ("demo", _("_Reset to Demo"));
server_dialog.set_response_appearance ("demo", Adw.ResponseAppearance.DESTRUCTIVE);
Expand All @@ -245,6 +301,10 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
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);
Expand All @@ -262,13 +322,13 @@ public class Butler.MainWindow : Adw.ApplicationWindow {

var log_out_dialog = new Adw.MessageDialog (
this,
"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)
_("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)
) {
body_use_markup = true,
default_response = "log_out"
};
log_out_dialog.add_response ("close", "_Stay Logged In");
log_out_dialog.add_response ("close", _("_Stay Logged In"));
log_out_dialog.add_response ("log_out", _("_Log Out"));
log_out_dialog.set_response_appearance ("log_out", Adw.ResponseAppearance.DESTRUCTIVE);

Expand All @@ -282,33 +342,6 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
}

private void on_about_activate () {
var about_window = new Adw.AboutWindow () {
transient_for = this,

application_icon = APP_ID,
application_name = _("%s for Home Assistant").printf (App.NAME),
developer_name = App.DEVELOPER,
version = VERSION,

comments = _("Butler is a hybrid native + web app for your Home Assistant dashboard"),

website = App.URL,
issue_url = "https://github.com/cassidyjames/butler/issues",

// Credits
developers = { "%s <%s>".printf (App.DEVELOPER, App.EMAIL) },
designers = { "%s %s".printf (App.DEVELOPER, App.URL) },

/// The translator credits. Please translate this with your name(s).
translator_credits = _("translator-credits"),

// Legal
copyright = "Copyright © 2020–2024 %s".printf (App.DEVELOPER),
license_type = Gtk.License.GPL_3_0,
};
about_window.add_link (_("About Home Assistant"), "https://www.home-assistant.io/");
about_window.add_link (_("Home Assistant Privacy Policy"), "https://www.home-assistant.io/privacy/");

about_window.present ();
}
}
Loading

0 comments on commit 13ce25d

Please sign in to comment.