From ac7045942a4ff62c524280e6fb5d0270236ec68d Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Mon, 8 Mar 2021 19:46:51 +0100 Subject: [PATCH 01/39] Fix compilation error --- src/controllers/DeviceController.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/DeviceController.vala b/src/controllers/DeviceController.vala index fed60ca..de43c35 100644 --- a/src/controllers/DeviceController.vala +++ b/src/controllers/DeviceController.vala @@ -22,7 +22,7 @@ public abstract class Controllers.DeviceController : Object { protected Models.Device _device; - public DeviceController (Models.Device device) { + protected DeviceController (Models.Device device) { Object ( device : device ); From 76c612e7ad68e188c77a90a8ab90cc2015fd660e Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Mon, 8 Mar 2021 19:58:20 +0100 Subject: [PATCH 02/39] Use libhandy --- .github/workflows/main.yml | 24 ++++++++++++++++++++---- README.md | 1 + debian/control | 1 + meson.build | 1 + src/MainWindow.vala | 25 +++++++++++++++++++------ src/meson.build | 2 ++ 6 files changed, 44 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f617616..fda19aa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,14 +3,30 @@ name: CI on: [push, pull_request] jobs: - lint: + build: runs-on: ubuntu-latest container: - image: valalang/lint + image: elementary/docker:unstable + + steps: + - uses: actions/checkout@v1 + - name: Install Dependencies + run: | + apt update + apt install -y libgranite-dev libgtk-3-dev libjson-glib-dev libgee-0.8-dev libsoup2.4-dev libxml2-dev uuid-dev libhandy-1-dev meson valac + - name: Build + env: + DESTDIR: out + run: | + meson build + ninja -C build + ninja -C build install + lint: + + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - name: Lint - run: io.elementary.vala-lint -d . + - uses: elementary/actions/vala-lint@master diff --git a/README.md b/README.md index c3ff94c..1c1b948 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ These dependencies must be present before building: - `meson (>=0.40)` - `valac (>=0.40)` - `libgtk-3-dev` + - `libhandy-1-dev` >=1.0.0 - `libjson-glib-dev` - `libgee-0.8-dev` - `libgranite-dev` diff --git a/debian/control b/debian/control index 301a63f..0f15f98 100644 --- a/debian/control +++ b/debian/control @@ -5,6 +5,7 @@ Maintainer: Marius Meisenzahl Build-Depends: meson, debhelper (>= 9), libgtk-3-dev, + libhandy-1-dev, libjson-glib-dev, libgee-0.8-dev, libgranite-dev, diff --git a/meson.build b/meson.build index 34a2406..ef6346f 100644 --- a/meson.build +++ b/meson.build @@ -11,6 +11,7 @@ add_project_arguments( gtk_plus_3_dep = dependency('gtk+-3.0') json_glib_1_dep = dependency('json-glib-1.0') +libhandy_dep = dependency('libhandy-1', version: '>=1.0.0') posix_dep = meson.get_compiler('vala').find_library('posix') gee_dep = dependency('gee-0.8') granite_dep = dependency('granite') diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 35edb63..18f3917 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -19,7 +19,7 @@ * Authored by: Marius Meisenzahl */ -public class MainWindow : Gtk.ApplicationWindow { +public class MainWindow : Hdy.Window { private static MainWindow? instance; private Settings settings; private Gtk.Stack stack; @@ -37,9 +37,11 @@ public class MainWindow : Gtk.ApplicationWindow { settings = Settings.get_default (); load_settings (); - var headerbar = new Gtk.HeaderBar (); - headerbar.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); - headerbar.show_close_button = true; + var headerbar = new Hdy.HeaderBar () { + decoration_layout = "close:", + show_close_button = true, + title = Config.APP_NAME + }; return_button = new Gtk.Button (); return_button.no_show_all = true; @@ -63,11 +65,18 @@ public class MainWindow : Gtk.ApplicationWindow { headerbar.pack_end (mode_switch); } - set_titlebar (headerbar); title = Config.APP_NAME; overlay = Widgets.Overlay.instance; - add (overlay); + + var main_layout = new Gtk.Grid (); + main_layout.attach (headerbar, 0, 0); + main_layout.attach (overlay, 0, 1); + + var window_handle = new Hdy.WindowHandle (); + window_handle.add (main_layout); + + add (window_handle); stack = new Gtk.Stack (); overlay.add (stack); @@ -92,6 +101,10 @@ public class MainWindow : Gtk.ApplicationWindow { }); } + construct { + Hdy.init (); + } + public static MainWindow get_default () { return instance; } diff --git a/src/meson.build b/src/meson.build index f49fff9..bf18753 100644 --- a/src/meson.build +++ b/src/meson.build @@ -49,6 +49,7 @@ executable( dependencies: [ gtk_plus_3_dep, json_glib_1_dep, + libhandy_dep, posix_dep, gee_dep, granite_dep, @@ -70,6 +71,7 @@ foreach test_name : tests dependencies: [ gtk_plus_3_dep, json_glib_1_dep, + libhandy_dep, posix_dep, gee_dep, granite_dep, From 5778a8e92331c419bda4b7f224e72683a4b6ef9d Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Mon, 8 Mar 2021 20:00:15 +0100 Subject: [PATCH 03/39] Add support for dark mode --- src/Application.vala | 13 +++++++++++++ src/MainWindow.vala | 17 ----------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index c2485cc..3a25b6a 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -30,6 +30,19 @@ public class Application : Granite.Application { } protected override void activate () { + 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 + ); + }); + window = new MainWindow (this); window.show_all (); diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 18f3917..57c1eb6 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -50,23 +50,6 @@ public class MainWindow : Hdy.Window { return_button.clicked.connect (go_back); headerbar.pack_start (return_button); - if (!settings.is_freedesktop_prefers_color_scheme_available ()) { - var gtk_settings = Gtk.Settings.get_default (); - - var 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", gtk_settings, "gtk_application_prefer_dark_theme"); - settings.bind ("prefer-dark-style", mode_switch, "active", GLib.SettingsBindFlags.DEFAULT); - headerbar.pack_end (mode_switch); - } - - title = Config.APP_NAME; - overlay = Widgets.Overlay.instance; var main_layout = new Gtk.Grid (); From 54ce5e9bd45cedba228d5bd088aa351283b944cc Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Mon, 8 Mar 2021 20:01:50 +0100 Subject: [PATCH 04/39] Use Granite style classes --- src/MainWindow.vala | 2 +- src/pages/AbstractDevicePage.vala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 57c1eb6..0bc9288 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -46,7 +46,7 @@ public class MainWindow : Hdy.Window { return_button = new Gtk.Button (); return_button.no_show_all = true; return_button.valign = Gtk.Align.CENTER; - return_button.get_style_context ().add_class ("back-button"); + return_button.get_style_context ().add_class (Granite.STYLE_CLASS_BACK_BUTTON); return_button.clicked.connect (go_back); headerbar.pack_start (return_button); diff --git a/src/pages/AbstractDevicePage.vala b/src/pages/AbstractDevicePage.vala index b6085db..589ea90 100644 --- a/src/pages/AbstractDevicePage.vala +++ b/src/pages/AbstractDevicePage.vala @@ -86,7 +86,7 @@ public abstract class Pages.AbstractDevicePage : Granite.SettingsPage { title_label = new Gtk.Label (title); title_label.ellipsize = Pango.EllipsizeMode.END; title_label.xalign = 0; - title_label.get_style_context ().add_class ("h2"); + title_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); var header_area = new Gtk.Grid (); header_area.column_spacing = 12; From efc9bda2885b0e2a554b6f41f4f9dbe0d326f2d0 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Mon, 8 Mar 2021 20:16:22 +0100 Subject: [PATCH 05/39] Satisfy linter --- src/MainWindow.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 0bc9288..234fca4 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -51,7 +51,7 @@ public class MainWindow : Hdy.Window { headerbar.pack_start (return_button); overlay = Widgets.Overlay.instance; - + var main_layout = new Gtk.Grid (); main_layout.attach (headerbar, 0, 0); main_layout.attach (overlay, 0, 1); From f2b8679b8010d3ac343a2f9e96e40bffc06b13d2 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 12:02:44 +0200 Subject: [PATCH 06/39] Delete Travis CI --- .travis.yml | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0151138..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- - -language: node_js - -node_js: - - 10.17.0 - -sudo: required - -services: - - docker - -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - libstdc++-5-dev - -install: - - npm i -g @elementaryos/houston - -script: - - houston ci From 5740208a7b5bb9f4a3aa5aab9456e50bf46db5f1 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 12:13:13 +0200 Subject: [PATCH 07/39] Add Flatpak manifest --- .github/workflows/main.yml | 14 ++++++++++++++ .gitignore | 5 +++-- com.github.manexim.home.yml | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 com.github.manexim.home.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fda19aa..526f327 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,6 +23,20 @@ jobs: meson build ninja -C build ninja -C build install + + flatpak: + runs-on: ubuntu-latest + container: + image: docker.io/bilelmoussaoui/flatpak-github-actions + options: --privileged + steps: + - uses: actions/checkout@v2 + - uses: bilelmoussaoui/flatpak-github-actions@v2 + with: + bundle: "home.flatpak" + manifest-path: "com.github.manexim.home.yml" + run-tests: "true" + lint: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 701cc25..8aba8c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *~ -build/ -src/Application +build +build-dir +.flatpak-builder diff --git a/com.github.manexim.home.yml b/com.github.manexim.home.yml new file mode 100644 index 0000000..d10a7d4 --- /dev/null +++ b/com.github.manexim.home.yml @@ -0,0 +1,37 @@ +app-id: com.github.manexim.home +runtime: org.gnome.Platform +runtime-version: '3.38' +base: io.elementary.BaseApp +base-version: juno-20.08 +sdk: org.gnome.Sdk +command: com.github.manexim.home +finish-args: + - '--share=ipc' + - '--share=network' + - '--socket=fallback-x11' + - '--socket=wayland' + + # needed for perfers-color-scheme + - '--system-talk-name=org.freedesktop.Accounts' +modules: + - name: granite + buildsystem: meson + sources: + - type: git + url: https://github.com/elementary/granite.git + + - name: handy + buildsystem: meson + config-opts: + - '-Dexamples=false' + - '-Dtests=false' + sources: + - type: git + url: https://gitlab.gnome.org/GNOME/libhandy.git + tag: '1.2.0' + + - name: home + buildsystem: meson + sources: + - type: dir + path: . From 0f8e89ba26cd90c9d07721268c75455be680f648 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 12:13:32 +0200 Subject: [PATCH 08/39] Delete debian packaging --- debian/changelog | 107 ------------------------------------------- debian/compat | 1 - debian/control | 22 --------- debian/copyright | 7 --- debian/rules | 29 ------------ debian/source/format | 1 - 6 files changed, 167 deletions(-) delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100755 debian/rules delete mode 100644 debian/source/format diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index aafc198..0000000 --- a/debian/changelog +++ /dev/null @@ -1,107 +0,0 @@ -com.github.manexim.home (0.5.0) bionic; urgency=medium - -[NEW] - * Use color picker to set color of smart bulbs -[IMPROVED] - * Show an error page if network is not available -[FIXED] -[TRANSLATIONS] - * Russian (by camellan) - * French (by NathanBnm) - * German (by meisenzahl) - * Japanese (by ryonakano) - * Portuguese (by aimproxy) - * Polish (by oskarkunik) - - -- Marius Meisenzahl Sun, 03 Nov 2019 14:24:03 +0100 - -com.github.manexim.home (0.4.2) bionic; urgency=medium - -[NEW] -[IMPROVED] -[FIXED] - * Fix of overlapping elements -[TRANSLATIONS] - * Russian (by camellan) - * French (by NathanBnm) - * German (by meisenzahl) - * Japanese (by ryonakano) - * Portuguese (by aimproxy) - * Polish (by oskarkunik) - - -- Marius Meisenzahl Wed, 07 Aug 2019 19:43:12 +0200 - -com.github.manexim.home (0.4.1) bionic; urgency=medium - -[NEW] -[IMPROVED] -[FIXED] - * Show loading page if no device is found -[TRANSLATIONS] - * Russian (by camellan) - * French (by NathanBnm) - * German (by meisenzahl) - * Japanese (by ryonakano) - * Portuguese (by aimproxy) - * Polish (by oskarkunik) - - -- Marius Meisenzahl Wed, 07 Aug 2019 06:56:37 +0200 - -com.github.manexim.home (0.4.0) bionic; urgency=medium - -[NEW] - * Set custom device icons - * Set dim level for dimmable bulbs - * Set color for supported bulbs -[IMPROVED] - * UI styling -[FIXED] -[TRANSLATIONS] - * Russian (by camellan) - * French (by NathanBnm) - * German (by meisenzahl) - * Japanese (by ryonakano) - * Portuguese (by aimproxy) - * Polish (by oskarkunik) - - -- Marius Meisenzahl Sun, 04 Aug 2019 12:49:14 +0200 - -com.github.manexim.home (0.3.0) bionic; urgency=medium - -[NEW] - * Add new UI - * Add initial support for Philips Hue devices - * Add discovery for Philips Hue bridges - * Add page to configure Philips Hue bridges - * Add service to save configurations -[IMPROVED] - * Update welcome view - * Add mode switch for dark theme if freedesktop schema is not available -[FIXED] -[TRANSLATIONS] - * French (by NathanBnm) - * German - * Russian (by camellan) - - -- Marius Meisenzahl Thu, 14 Jul 2019 19:40:29 +0200 - -com.github.manexim.home (0.2.0) bionic; urgency=medium - -[NEW] - * Add welcome view for onboarding - * Show loading page if no smart home gadget is found - * Show manufacturer and model of device -[IMPROVED] - * Save and load window settings -[FIXED] - * Remove mention of elementary OS in app description - * Suffix symbolic icon names with -symbolic - * Install all available icon sizes - - -- Marius Meisenzahl Fri, 14 Jun 2019 09:28:04 +0200 - -com.github.manexim.home (0.1.0) bionic; urgency=medium - - * Initial Release. - - -- Marius Meisenzahl Tue, 11 Jun 2019 21:06:00 +0200 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index ec63514..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/debian/control b/debian/control deleted file mode 100644 index 0f15f98..0000000 --- a/debian/control +++ /dev/null @@ -1,22 +0,0 @@ -Source: com.github.manexim.home -Section: x11 -Priority: optional -Maintainer: Marius Meisenzahl -Build-Depends: meson, - debhelper (>= 9), - libgtk-3-dev, - libhandy-1-dev, - libjson-glib-dev, - libgee-0.8-dev, - libgranite-dev, - libsoup2.4-dev, - libxml2-dev, - uuid-dev, - valac -Standards-Version: 3.9.3 - -Package: com.github.manexim.home -Architecture: any -Depends: ${misc:Depends}, ${shlibs:Depends} -Description: Home - Control your smart home gadgets diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 65775db..0000000 --- a/debian/copyright +++ /dev/null @@ -1,7 +0,0 @@ -Format: http://dep.debian.net/deps/dep5 -Upstream-Name: com.github.manexim.home -Source: https://github.com/manexim/home - -Files: src/* data/* debian/* -Copyright: 2019 Marius Meisenzahl -License: GPL-3.0+ diff --git a/debian/rules b/debian/rules deleted file mode 100755 index b50d9e9..0000000 --- a/debian/rules +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -%: - dh $@ - -override_dh_auto_clean: - rm -rf debian/build - -override_dh_auto_configure: - mkdir -p debian/build - cd debian/build && meson --prefix=/usr ../.. - -override_dh_auto_build: - cd debian/build && ninja -v - -override_dh_auto_test: - cd debian/build && ninja test - -override_dh_auto_install: - cd debian/build && DESTDIR=${CURDIR}/debian/com.github.manexim.home ninja install diff --git a/debian/source/format b/debian/source/format deleted file mode 100644 index 89ae9db..0000000 --- a/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (native) From b75ec3ad22b75510a363f2e06d376ddc4f5f06f0 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 12:48:47 +0200 Subject: [PATCH 09/39] Add Flux dependency --- meson.build | 1 + src/meson.build | 6 ++++-- subprojects/flux.wrap | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 subprojects/flux.wrap diff --git a/meson.build b/meson.build index 34a2406..9a00994 100644 --- a/meson.build +++ b/meson.build @@ -17,6 +17,7 @@ granite_dep = dependency('granite') soup_dep = dependency('libsoup-2.4') xml_dep = dependency('libxml-2.0') uuid_dep = dependency('uuid') +flux_dep = dependency('flux', fallback : ['flux', 'libflux_dep']) vala_flags = [] enable_demo_mode = get_option('demo_mode') == 'true' diff --git a/src/meson.build b/src/meson.build index f49fff9..cd25009 100644 --- a/src/meson.build +++ b/src/meson.build @@ -54,7 +54,8 @@ executable( granite_dep, soup_dep, xml_dep, - uuid_dep + uuid_dep, + flux_dep, ], install: true ) @@ -75,7 +76,8 @@ foreach test_name : tests granite_dep, soup_dep, xml_dep, - uuid_dep + uuid_dep, + flux_dep, ] ) test( diff --git a/subprojects/flux.wrap b/subprojects/flux.wrap new file mode 100644 index 0000000..ebc3922 --- /dev/null +++ b/subprojects/flux.wrap @@ -0,0 +1,3 @@ +[wrap-git] +url = https://github.com/manexim/flux.git +revision = add-initial-version From a33c2a450b0042e1f3e7b5e9df6101620b8e9027 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 13:16:12 +0200 Subject: [PATCH 10/39] Build with GitHub CI --- .github/workflows/main.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f617616..4c82f42 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,6 +3,27 @@ name: CI on: [push, pull_request] jobs: + build: + + runs-on: ubuntu-latest + + container: + image: elementary/docker:stable + + steps: + - uses: actions/checkout@v1 + - name: Install Dependencies + run: | + apt update + apt install -y libgranite-dev libgtk-3-dev libjson-glib-dev libgee-0.8-dev libsoup2.4-dev libxml2-dev uuid-dev meson valac + - name: Build + env: + DESTDIR: out + run: | + meson build + ninja -C build + ninja -C build install + lint: runs-on: ubuntu-latest From d9a4574c73b3c886bf9615adfc2d5d39f692e410 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 13:19:11 +0200 Subject: [PATCH 11/39] Add intial files --- src/Actions/ActionType.vala | 24 ++++++++++++++++++++ src/Actions/DeviceActions.vala | 31 ++++++++++++++++++++++++++ src/Application.vala | 6 +++++ src/Middlewares/LoggingMiddleware.vala | 26 +++++++++++++++++++++ src/Payloads/DevicePayload.vala | 24 ++++++++++++++++++++ src/Stores/Store.vala | 29 ++++++++++++++++++++++++ src/lifx/Controller.vala | 1 + src/meson.build | 5 +++++ subprojects/flux | 1 + 9 files changed, 147 insertions(+) create mode 100644 src/Actions/ActionType.vala create mode 100644 src/Actions/DeviceActions.vala create mode 100644 src/Middlewares/LoggingMiddleware.vala create mode 100644 src/Payloads/DevicePayload.vala create mode 100644 src/Stores/Store.vala create mode 160000 subprojects/flux diff --git a/src/Actions/ActionType.vala b/src/Actions/ActionType.vala new file mode 100644 index 0000000..f92baad --- /dev/null +++ b/src/Actions/ActionType.vala @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ + +namespace ActionType { + const string SET_POWER = "SET_POWER"; +} diff --git a/src/Actions/DeviceActions.vala b/src/Actions/DeviceActions.vala new file mode 100644 index 0000000..f1e7071 --- /dev/null +++ b/src/Actions/DeviceActions.vala @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ + +public class DeviceActions { + public static void set_power (string id) { + var type = ActionType.SET_POWER; + var payload = new DevicePayload () { + id = id + }; + var action = new Flux.Action (type, payload); + Flux.Dispatcher.get_instance ().dispatch (action); + } +} diff --git a/src/Application.vala b/src/Application.vala index c2485cc..fc18f99 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -30,6 +30,12 @@ public class Application : Granite.Application { } protected override void activate () { + // Register Middlewares + Flux.Dispatcher.get_instance ().register_middleware (new LoggingMiddleware ()); + + // Register Stores + Flux.Dispatcher.get_instance ().register_store (new Store ()); + window = new MainWindow (this); window.show_all (); diff --git a/src/Middlewares/LoggingMiddleware.vala b/src/Middlewares/LoggingMiddleware.vala new file mode 100644 index 0000000..896dcf7 --- /dev/null +++ b/src/Middlewares/LoggingMiddleware.vala @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ + +public class LoggingMiddleware : Flux.Middleware { + public override void process (Flux.Action action) { + debug ("%s: %s", action.action_type, Json.gobject_to_data (action.payload, null)); + } +} diff --git a/src/Payloads/DevicePayload.vala b/src/Payloads/DevicePayload.vala new file mode 100644 index 0000000..8096cff --- /dev/null +++ b/src/Payloads/DevicePayload.vala @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ + +public class DevicePayload : Flux.Payload { + public string id { get; set; } +} diff --git a/src/Stores/Store.vala b/src/Stores/Store.vala new file mode 100644 index 0000000..28b074d --- /dev/null +++ b/src/Stores/Store.vala @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ + +public class Store : Flux.Store { + public override void process (Flux.Action action) { + switch (action.action_type) { + default: + break; + } + } +} diff --git a/src/lifx/Controller.vala b/src/lifx/Controller.vala index 3518f4f..56f0df8 100644 --- a/src/lifx/Controller.vala +++ b/src/lifx/Controller.vala @@ -68,6 +68,7 @@ public class Lifx.Controller : Controllers.DeviceController { } public override void switch_power (bool on) { + DeviceActions.set_power (device.id); service.set_power (device as Lifx.Lamp, on ? 65535 : 0); _device.power = on ? Types.Power.ON : Types.Power.OFF; diff --git a/src/meson.build b/src/meson.build index cd25009..a5999a4 100644 --- a/src/meson.build +++ b/src/meson.build @@ -39,6 +39,11 @@ sources = [ 'widgets/ColorPicker.vala', 'widgets/IconPopover.vala', 'widgets/Overlay.vala', + 'Actions/ActionType.vala', + 'Actions/DeviceActions.vala', + 'Middlewares/LoggingMiddleware.vala', + 'Payloads/DevicePayload.vala', + 'Stores/Store.vala', 'MainWindow.vala' ] diff --git a/subprojects/flux b/subprojects/flux new file mode 160000 index 0000000..0bc74cf --- /dev/null +++ b/subprojects/flux @@ -0,0 +1 @@ +Subproject commit 0bc74cf9214faafb967158b6699b44c5786c4e05 From 559bf3246c0541389b2f69b781451accca297ef3 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 13:22:22 +0200 Subject: [PATCH 12/39] Delete subproject --- subprojects/flux | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/flux b/subprojects/flux index 0bc74cf..73ef77f 160000 --- a/subprojects/flux +++ b/subprojects/flux @@ -1 +1 @@ -Subproject commit 0bc74cf9214faafb967158b6699b44c5786c4e05 +Subproject commit 73ef77f06674db2db14953f8d193f9cb456360e5 From fb6ec3e968ff197acd898eeda4c1539f8e9b8581 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 13:25:16 +0200 Subject: [PATCH 13/39] Delete subproject --- subprojects/flux | 1 - 1 file changed, 1 deletion(-) delete mode 160000 subprojects/flux diff --git a/subprojects/flux b/subprojects/flux deleted file mode 160000 index 73ef77f..0000000 --- a/subprojects/flux +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 73ef77f06674db2db14953f8d193f9cb456360e5 From cc7b5af0c23fae372c82bf6ac9c359f8ff59e81e Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 13:26:53 +0200 Subject: [PATCH 14/39] Update .gitignore --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 701cc25..3651ec6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ *~ -build/ -src/Application +build +subprojects/flux From 6e8bfb761ef3753c51ecac7774d8fbd03700ed1b Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 13:28:07 +0200 Subject: [PATCH 15/39] Install git --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 0151138..a401b42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ addons: - ubuntu-toolchain-r-test packages: - libstdc++-5-dev + - git install: - npm i -g @elementaryos/houston From 34e8b0319fe80852991b7dac810317eb63b1c641 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 13:29:39 +0200 Subject: [PATCH 16/39] Install git --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4c82f42..1a66c13 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: - name: Install Dependencies run: | apt update - apt install -y libgranite-dev libgtk-3-dev libjson-glib-dev libgee-0.8-dev libsoup2.4-dev libxml2-dev uuid-dev meson valac + apt install -y libgranite-dev libgtk-3-dev libjson-glib-dev libgee-0.8-dev libsoup2.4-dev libxml2-dev uuid-dev meson valac git - name: Build env: DESTDIR: out From 49527945228f353d857522f53c42dff27b15cbbf Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 13:38:17 +0200 Subject: [PATCH 17/39] Add git --- debian/control | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/control b/debian/control index 301a63f..609734c 100644 --- a/debian/control +++ b/debian/control @@ -11,6 +11,7 @@ Build-Depends: meson, libsoup2.4-dev, libxml2-dev, uuid-dev, + git, valac Standards-Version: 3.9.3 From 3959616cd0d828a96f88d916e39b1b2159c541a7 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 14:47:08 +0200 Subject: [PATCH 18/39] Update --- src/{Actions => Flux}/ActionType.vala | 1 + .../DeviceActions.vala => Flux/Actions.vala} | 23 +++++++++++++++---- .../LoggingMiddleware.vala | 0 .../DevicePayload.vala => Flux/Payloads.vala} | 13 ++++++++++- src/{Stores => Flux}/Store.vala | 0 src/lifx/Controller.vala | 7 +++++- src/meson.build | 10 ++++---- src/philips/hue/Controller.vala | 1 + 8 files changed, 44 insertions(+), 11 deletions(-) rename src/{Actions => Flux}/ActionType.vala (95%) rename src/{Actions/DeviceActions.vala => Flux/Actions.vala} (59%) rename src/{Middlewares => Flux}/LoggingMiddleware.vala (100%) rename src/{Payloads/DevicePayload.vala => Flux/Payloads.vala} (69%) rename src/{Stores => Flux}/Store.vala (100%) diff --git a/src/Actions/ActionType.vala b/src/Flux/ActionType.vala similarity index 95% rename from src/Actions/ActionType.vala rename to src/Flux/ActionType.vala index f92baad..3e5a1c9 100644 --- a/src/Actions/ActionType.vala +++ b/src/Flux/ActionType.vala @@ -20,5 +20,6 @@ */ namespace ActionType { + const string SET_COLOR = "SET_COLOR"; const string SET_POWER = "SET_POWER"; } diff --git a/src/Actions/DeviceActions.vala b/src/Flux/Actions.vala similarity index 59% rename from src/Actions/DeviceActions.vala rename to src/Flux/Actions.vala index f1e7071..dea7c6a 100644 --- a/src/Actions/DeviceActions.vala +++ b/src/Flux/Actions.vala @@ -19,11 +19,26 @@ * Authored by: Marius Meisenzahl */ -public class DeviceActions { - public static void set_power (string id) { +public class Actions { + public static void set_color (string id, uint16 hue, uint16 saturation, uint16 brightness, uint16 kelvin, uint32 duration=0) { + var type = ActionType.SET_COLOR; + var payload = new SetColorPayload () { + id = id, + hue = hue, + saturation = saturation, + brightness = brightness, + kelvin = kelvin, + duration = duration + }; + var action = new Flux.Action (type, payload); + Flux.Dispatcher.get_instance ().dispatch (action); + } + + public static void set_power (string id, bool on) { var type = ActionType.SET_POWER; - var payload = new DevicePayload () { - id = id + var payload = new SetPowerPayload () { + id = id, + on = on }; var action = new Flux.Action (type, payload); Flux.Dispatcher.get_instance ().dispatch (action); diff --git a/src/Middlewares/LoggingMiddleware.vala b/src/Flux/LoggingMiddleware.vala similarity index 100% rename from src/Middlewares/LoggingMiddleware.vala rename to src/Flux/LoggingMiddleware.vala diff --git a/src/Payloads/DevicePayload.vala b/src/Flux/Payloads.vala similarity index 69% rename from src/Payloads/DevicePayload.vala rename to src/Flux/Payloads.vala index 8096cff..5078cf0 100644 --- a/src/Payloads/DevicePayload.vala +++ b/src/Flux/Payloads.vala @@ -19,6 +19,17 @@ * Authored by: Marius Meisenzahl */ -public class DevicePayload : Flux.Payload { +public class SetColorPayload : Flux.Payload { public string id { get; set; } + public bool on { get; set; } + public uint16 hue { get; set; } + public uint16 saturation { get; set; } + public uint16 brightness { get; set; } + public uint16 kelvin { get; set; } + public uint32 duration { get; set; } +} + +public class SetPowerPayload : Flux.Payload { + public string id { get; set; } + public bool on { get; set; } } diff --git a/src/Stores/Store.vala b/src/Flux/Store.vala similarity index 100% rename from src/Stores/Store.vala rename to src/Flux/Store.vala diff --git a/src/lifx/Controller.vala b/src/lifx/Controller.vala index 56f0df8..7d1fd87 100644 --- a/src/lifx/Controller.vala +++ b/src/lifx/Controller.vala @@ -32,6 +32,7 @@ public class Lifx.Controller : Controllers.DeviceController { public override void switch_hue (uint16 hue) { var lamp = device as Lifx.Lamp; + Actions.set_color (device.id, hue, lamp.saturation, lamp.brightness, 0, 0); service.set_color (lamp, hue, lamp.saturation, lamp.brightness, 0, 0); lamp.hue = hue; @@ -39,6 +40,7 @@ public class Lifx.Controller : Controllers.DeviceController { public override void switch_saturation (uint16 saturation) { var lamp = device as Lifx.Lamp; + Actions.set_color (device.id, lamp.hue, saturation, lamp.brightness, 0, 0); service.set_color (lamp, lamp.hue, saturation, lamp.brightness, 0, 0); lamp.saturation = saturation; @@ -46,6 +48,7 @@ public class Lifx.Controller : Controllers.DeviceController { public override void switch_brightness (uint16 brightness) { var lamp = device as Lifx.Lamp; + Actions.set_color (device.id, lamp.hue, lamp.saturation, brightness, lamp.color_temperature, 0); service.set_color (lamp, lamp.hue, lamp.saturation, brightness, lamp.color_temperature, 0); lamp.brightness = brightness; @@ -53,6 +56,7 @@ public class Lifx.Controller : Controllers.DeviceController { public override void switch_hsb (uint16 hue, uint16 saturation, uint16 brightness) { var lamp = device as Lifx.Lamp; + Actions.set_color (device.id, hue, saturation, brightness, 0, 0); service.set_color (lamp, hue, saturation, brightness, 0, 0); lamp.hue = hue; @@ -62,13 +66,14 @@ public class Lifx.Controller : Controllers.DeviceController { public override void switch_color_temperature (uint16 color_temperature) { var lamp = device as Lifx.Lamp; + Actions.set_color (device.id, 0, 0, lamp.brightness, color_temperature, 0); service.set_color (lamp, 0, 0, lamp.brightness, color_temperature, 0); lamp.color_temperature = color_temperature; } public override void switch_power (bool on) { - DeviceActions.set_power (device.id); + Actions.set_power (device.id, on); service.set_power (device as Lifx.Lamp, on ? 65535 : 0); _device.power = on ? Types.Power.ON : Types.Power.OFF; diff --git a/src/meson.build b/src/meson.build index a5999a4..bbe0033 100644 --- a/src/meson.build +++ b/src/meson.build @@ -39,11 +39,11 @@ sources = [ 'widgets/ColorPicker.vala', 'widgets/IconPopover.vala', 'widgets/Overlay.vala', - 'Actions/ActionType.vala', - 'Actions/DeviceActions.vala', - 'Middlewares/LoggingMiddleware.vala', - 'Payloads/DevicePayload.vala', - 'Stores/Store.vala', + 'Flux/Actions.vala', + 'Flux/ActionType.vala', + 'Flux/LoggingMiddleware.vala', + 'Flux/Payloads.vala', + 'Flux/Store.vala', 'MainWindow.vala' ] diff --git a/src/philips/hue/Controller.vala b/src/philips/hue/Controller.vala index c9c1b30..df6573e 100644 --- a/src/philips/hue/Controller.vala +++ b/src/philips/hue/Controller.vala @@ -68,6 +68,7 @@ public class Philips.Hue.Controller : Controllers.DeviceController { } public override void switch_power (bool on) { + Actions.set_power (device.id, on); controller.switch_light_power (device as Philips.Hue.Lamp, on); _device.power = on ? Types.Power.ON : Types.Power.OFF; From 9120228fe00942050358d61ebdce7cdb0e9c0dae Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 14:58:55 +0200 Subject: [PATCH 19/39] Add Hue actions --- src/Flux/ActionType.vala | 5 ++++ src/Flux/Actions.vala | 52 +++++++++++++++++++++++++++++++++ src/Flux/Payloads.vala | 27 +++++++++++++++++ src/philips/hue/Controller.vala | 5 ++++ 4 files changed, 89 insertions(+) diff --git a/src/Flux/ActionType.vala b/src/Flux/ActionType.vala index 3e5a1c9..bfdd5bb 100644 --- a/src/Flux/ActionType.vala +++ b/src/Flux/ActionType.vala @@ -21,5 +21,10 @@ namespace ActionType { const string SET_COLOR = "SET_COLOR"; + const string SET_HUE = "SET_HUE"; + const string SET_SATURATION = "SET_SATURATION"; + const string SET_BRIGHTNESS = "SET_BRIGHTNESS"; + const string SET_HSB = "SET_HSB"; + const string SET_COLOR_TEMPERATURE = "SET_COLOR_TEMPERATURE"; const string SET_POWER = "SET_POWER"; } diff --git a/src/Flux/Actions.vala b/src/Flux/Actions.vala index dea7c6a..1a9fb0a 100644 --- a/src/Flux/Actions.vala +++ b/src/Flux/Actions.vala @@ -34,6 +34,58 @@ public class Actions { Flux.Dispatcher.get_instance ().dispatch (action); } + public static void set_hue (string id, uint16 hue) { + var type = ActionType.SET_HUE; + var payload = new SetHuePayload () { + id = id, + hue = hue + }; + var action = new Flux.Action (type, payload); + Flux.Dispatcher.get_instance ().dispatch (action); + } + + public static void set_saturation (string id, uint16 saturation) { + var type = ActionType.SET_SATURATION; + var payload = new SetSaturationPayload () { + id = id, + saturation = saturation + }; + var action = new Flux.Action (type, payload); + Flux.Dispatcher.get_instance ().dispatch (action); + } + + public static void set_brightness (string id, uint16 brightness) { + var type = ActionType.SET_BRIGHTNESS; + var payload = new SetBrightnessPayload () { + id = id, + brightness = brightness + }; + var action = new Flux.Action (type, payload); + Flux.Dispatcher.get_instance ().dispatch (action); + } + + public static void set_hsb (string id, uint16 hue, uint16 saturation, uint16 brightness) { + var type = ActionType.SET_HSB; + var payload = new SetHsbPayload () { + id = id, + hue = hue, + saturation = saturation, + brightness = brightness + }; + var action = new Flux.Action (type, payload); + Flux.Dispatcher.get_instance ().dispatch (action); + } + + public static void set_color_temperature (string id, uint16 color_temperature) { + var type = ActionType.SET_COLOR_TEMPERATURE; + var payload = new SetColorTemperaturePayload () { + id = id, + color_temperature = color_temperature + }; + var action = new Flux.Action (type, payload); + Flux.Dispatcher.get_instance ().dispatch (action); + } + public static void set_power (string id, bool on) { var type = ActionType.SET_POWER; var payload = new SetPowerPayload () { diff --git a/src/Flux/Payloads.vala b/src/Flux/Payloads.vala index 5078cf0..3b06d51 100644 --- a/src/Flux/Payloads.vala +++ b/src/Flux/Payloads.vala @@ -29,6 +29,33 @@ public class SetColorPayload : Flux.Payload { public uint32 duration { get; set; } } +public class SetHuePayload : Flux.Payload { + public string id { get; set; } + public uint16 hue { get; set; } +} + +public class SetSaturationPayload : Flux.Payload { + public string id { get; set; } + public uint16 saturation { get; set; } +} + +public class SetBrightnessPayload : Flux.Payload { + public string id { get; set; } + public uint16 brightness { get; set; } +} + +public class SetHsbPayload : Flux.Payload { + public string id { get; set; } + public uint16 hue { get; set; } + public uint16 saturation { get; set; } + public uint16 brightness { get; set; } +} + +public class SetColorTemperaturePayload : Flux.Payload { + public string id { get; set; } + public uint16 color_temperature { get; set; } +} + public class SetPowerPayload : Flux.Payload { public string id { get; set; } public bool on { get; set; } diff --git a/src/philips/hue/Controller.vala b/src/philips/hue/Controller.vala index df6573e..f2cc6b3 100644 --- a/src/philips/hue/Controller.vala +++ b/src/philips/hue/Controller.vala @@ -32,6 +32,7 @@ public class Philips.Hue.Controller : Controllers.DeviceController { public override void switch_hue (uint16 hue) { var lamp = device as Philips.Hue.Lamp; + Actions.set_hue (device.id, hue); controller.switch_light_hue (lamp, hue); lamp.hue = hue; @@ -39,6 +40,7 @@ public class Philips.Hue.Controller : Controllers.DeviceController { public override void switch_saturation (uint16 saturation) { var lamp = device as Philips.Hue.Lamp; + Actions.set_saturation (device.id, saturation); controller.switch_light_saturation (lamp, saturation); lamp.saturation = saturation; @@ -46,6 +48,7 @@ public class Philips.Hue.Controller : Controllers.DeviceController { public override void switch_brightness (uint16 brightness) { var lamp = device as Philips.Hue.Lamp; + Actions.set_brightness (device.id, brightness); controller.switch_light_brightness (lamp, brightness); lamp.brightness = brightness; @@ -53,6 +56,7 @@ public class Philips.Hue.Controller : Controllers.DeviceController { public override void switch_hsb (uint16 hue, uint16 saturation, uint16 brightness) { var lamp = device as Philips.Hue.Lamp; + Actions.set_hsb (device.id, hue, saturation, brightness); controller.switch_light_hsb (lamp, hue, saturation, brightness); lamp.hue = hue; @@ -62,6 +66,7 @@ public class Philips.Hue.Controller : Controllers.DeviceController { public override void switch_color_temperature (uint16 color_temperature) { var lamp = device as Philips.Hue.Lamp; + Actions.set_color_temperature (device.id, color_temperature); controller.switch_light_color_temperature (lamp, color_temperature); lamp.color_temperature = color_temperature; From af0d435b0bfb1e31467506e89719688a0742464e Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 15:08:34 +0200 Subject: [PATCH 20/39] Add middlewares --- src/Application.vala | 3 +++ src/Flux/HueMiddleware.vala | 24 ++++++++++++++++++++++++ src/Flux/LifxMiddleware.vala | 24 ++++++++++++++++++++++++ src/meson.build | 4 ++++ 4 files changed, 55 insertions(+) create mode 100644 src/Flux/HueMiddleware.vala create mode 100644 src/Flux/LifxMiddleware.vala diff --git a/src/Application.vala b/src/Application.vala index fc18f99..eec1436 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -33,6 +33,9 @@ public class Application : Granite.Application { // Register Middlewares Flux.Dispatcher.get_instance ().register_middleware (new LoggingMiddleware ()); + Flux.Dispatcher.get_instance ().register_middleware (new HueMiddleware ()); + Flux.Dispatcher.get_instance ().register_middleware (new LifxMiddleware ()); + // Register Stores Flux.Dispatcher.get_instance ().register_store (new Store ()); diff --git a/src/Flux/HueMiddleware.vala b/src/Flux/HueMiddleware.vala new file mode 100644 index 0000000..4c62ac4 --- /dev/null +++ b/src/Flux/HueMiddleware.vala @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ + +public class HueMiddleware : Flux.Middleware { + public override void process (Flux.Action action) {} +} diff --git a/src/Flux/LifxMiddleware.vala b/src/Flux/LifxMiddleware.vala new file mode 100644 index 0000000..e6e43ed --- /dev/null +++ b/src/Flux/LifxMiddleware.vala @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ + +public class LifxMiddleware : Flux.Middleware { + public override void process (Flux.Action action) {} +} diff --git a/src/meson.build b/src/meson.build index bbe0033..f68e6a1 100644 --- a/src/meson.build +++ b/src/meson.build @@ -39,11 +39,15 @@ sources = [ 'widgets/ColorPicker.vala', 'widgets/IconPopover.vala', 'widgets/Overlay.vala', + 'Flux/Actions.vala', 'Flux/ActionType.vala', + 'Flux/HueMiddleware.vala', + 'Flux/LifxMiddleware.vala', 'Flux/LoggingMiddleware.vala', 'Flux/Payloads.vala', 'Flux/Store.vala', + 'MainWindow.vala' ] From 4bfeb39d2b6a2a92aa6af302e56c0ca0d8bf6e12 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 16:03:56 +0200 Subject: [PATCH 21/39] Add more Flux actions --- src/Flux/ActionType.vala | 2 ++ src/Flux/Actions.vala | 30 ++++++++++++++++++++++++++ src/Flux/Payloads.vala | 10 +++++++++ src/Flux/Store.vala | 10 ++++++++- src/controllers/DevicesController.vala | 8 +++++++ 5 files changed, 59 insertions(+), 1 deletion(-) diff --git a/src/Flux/ActionType.vala b/src/Flux/ActionType.vala index bfdd5bb..81d47e9 100644 --- a/src/Flux/ActionType.vala +++ b/src/Flux/ActionType.vala @@ -20,6 +20,8 @@ */ namespace ActionType { + const string ADD_DEVICE = "ADD_DEVICE"; + const string UPDATE_DEVICE = "UPDATE_DEVICE"; const string SET_COLOR = "SET_COLOR"; const string SET_HUE = "SET_HUE"; const string SET_SATURATION = "SET_SATURATION"; diff --git a/src/Flux/Actions.vala b/src/Flux/Actions.vala index 1a9fb0a..16c8ee0 100644 --- a/src/Flux/Actions.vala +++ b/src/Flux/Actions.vala @@ -20,6 +20,36 @@ */ public class Actions { + public static void add_device (string id, string name, string manufacturer, string model, string power, string icon, string? default_icon=null) { + var type = ActionType.ADD_DEVICE; + var payload = new DevicePayload () { + id = id, + name = name, + manufacturer = manufacturer, + model = model, + power = power, + icon = icon, + default_icon = default_icon + }; + var action = new Flux.Action (type, payload); + Flux.Dispatcher.get_instance ().dispatch (action); + } + + public static void update_device (string id, string name, string manufacturer, string model, string power, string icon, string? default_icon=null) { + var type = ActionType.UPDATE_DEVICE; + var payload = new DevicePayload () { + id = id, + name = name, + manufacturer = manufacturer, + model = model, + power = power, + icon = icon, + default_icon = default_icon + }; + var action = new Flux.Action (type, payload); + Flux.Dispatcher.get_instance ().dispatch (action); + } + public static void set_color (string id, uint16 hue, uint16 saturation, uint16 brightness, uint16 kelvin, uint32 duration=0) { var type = ActionType.SET_COLOR; var payload = new SetColorPayload () { diff --git a/src/Flux/Payloads.vala b/src/Flux/Payloads.vala index 3b06d51..5c2806b 100644 --- a/src/Flux/Payloads.vala +++ b/src/Flux/Payloads.vala @@ -19,6 +19,16 @@ * Authored by: Marius Meisenzahl */ +public class DevicePayload : Flux.Payload { + public string id { get; set; } + public string name { get; set; } + public string manufacturer { get; set; } + public string model { get; set; } + public string power { get; set; } + public string icon { get; set; } + public string default_icon { get; set; } +} + public class SetColorPayload : Flux.Payload { public string id { get; set; } public bool on { get; set; } diff --git a/src/Flux/Store.vala b/src/Flux/Store.vala index 28b074d..9b25dce 100644 --- a/src/Flux/Store.vala +++ b/src/Flux/Store.vala @@ -22,8 +22,16 @@ public class Store : Flux.Store { public override void process (Flux.Action action) { switch (action.action_type) { - default: + case ActionType.ADD_DEVICE: + process_add_device (action); + break; + case ActionType.UPDATE_DEVICE: + process_update_device (action); break; } } + + private void process_add_device (Flux.Action action) {} + + private void process_update_device (Flux.Action action) {} } diff --git a/src/controllers/DevicesController.vala b/src/controllers/DevicesController.vala index 6fe1937..9f0123a 100644 --- a/src/controllers/DevicesController.vala +++ b/src/controllers/DevicesController.vala @@ -51,12 +51,16 @@ public class Controllers.DevicesController { device.icon = device_loaded_map.get (device.id).icon; } + Actions.add_device (device.id, device.name, device.manufacturer, device.model, device.power.to_string (), device.icon, device.default_icon); + on_new_device (device); device_list.add (device); }); lifx_service.on_updated_device.connect ((device) => { + Actions.update_device (device.id, device.name, device.manufacturer, device.model, device.power.to_string (), device.icon, device.default_icon); + on_updated_device (device); }); @@ -67,12 +71,16 @@ public class Controllers.DevicesController { device.icon = device_loaded_map.get (device.id).icon; } + Actions.add_device (device.id, device.name, device.manufacturer, device.model, device.power.to_string (), device.icon, device.default_icon); + on_new_device (device); device_list.add (device); }); philips_hue_service.on_updated_device.connect ((device) => { + Actions.update_device (device.id, device.name, device.manufacturer, device.model, device.power.to_string (), device.icon, device.default_icon); + on_updated_device (device); }); } From 026a32d5760b8b453f0603ee20b82fb7e1ed1c65 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 1 Apr 2021 16:56:05 +0200 Subject: [PATCH 22/39] Process devices in Store --- src/Flux/Actions.vala | 4 +-- src/Flux/Payloads.vala | 2 +- src/Flux/Store.vala | 42 ++++++++++++++++++++++++-- src/controllers/DevicesController.vala | 8 ++--- 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/src/Flux/Actions.vala b/src/Flux/Actions.vala index 16c8ee0..b908565 100644 --- a/src/Flux/Actions.vala +++ b/src/Flux/Actions.vala @@ -20,7 +20,7 @@ */ public class Actions { - public static void add_device (string id, string name, string manufacturer, string model, string power, string icon, string? default_icon=null) { + public static void add_device (string id, string name, string manufacturer, string model, Types.Power power, string icon, string? default_icon=null) { var type = ActionType.ADD_DEVICE; var payload = new DevicePayload () { id = id, @@ -35,7 +35,7 @@ public class Actions { Flux.Dispatcher.get_instance ().dispatch (action); } - public static void update_device (string id, string name, string manufacturer, string model, string power, string icon, string? default_icon=null) { + public static void update_device (string id, string name, string manufacturer, string model, Types.Power power, string icon, string? default_icon=null) { var type = ActionType.UPDATE_DEVICE; var payload = new DevicePayload () { id = id, diff --git a/src/Flux/Payloads.vala b/src/Flux/Payloads.vala index 5c2806b..c3977c4 100644 --- a/src/Flux/Payloads.vala +++ b/src/Flux/Payloads.vala @@ -24,7 +24,7 @@ public class DevicePayload : Flux.Payload { public string name { get; set; } public string manufacturer { get; set; } public string model { get; set; } - public string power { get; set; } + public Types.Power power { get; set; } public string icon { get; set; } public string default_icon { get; set; } } diff --git a/src/Flux/Store.vala b/src/Flux/Store.vala index 9b25dce..8da1109 100644 --- a/src/Flux/Store.vala +++ b/src/Flux/Store.vala @@ -20,6 +20,8 @@ */ public class Store : Flux.Store { + public Gee.List devices; + public override void process (Flux.Action action) { switch (action.action_type) { case ActionType.ADD_DEVICE: @@ -31,7 +33,43 @@ public class Store : Flux.Store { } } - private void process_add_device (Flux.Action action) {} + private void process_add_device (Flux.Action action) { + var payload = (DevicePayload) action.payload; + + var device = new Models.Device () { + id = payload.id, + name = payload.name, + manufacturer = payload.manufacturer, + model = payload.model, + power = payload.power, + icon = payload.icon, + default_icon = payload.default_icon + }; + + devices.add (device); + } + + private void process_update_device (Flux.Action action) { + var payload = (DevicePayload) action.payload; + + for (int i = 0; i < devices.size; i++) { + if (devices[i].id == payload.id) { + devices[i] = new Models.Device () { + id = payload.id, + name = payload.name, + manufacturer = payload.manufacturer, + model = payload.model, + power = payload.power, + icon = payload.icon, + default_icon = payload.default_icon + }; - private void process_update_device (Flux.Action action) {} + break; + } + } + } + + public Store () { + devices = new Gee.ArrayList (); + } } diff --git a/src/controllers/DevicesController.vala b/src/controllers/DevicesController.vala index 9f0123a..8766cfe 100644 --- a/src/controllers/DevicesController.vala +++ b/src/controllers/DevicesController.vala @@ -51,7 +51,7 @@ public class Controllers.DevicesController { device.icon = device_loaded_map.get (device.id).icon; } - Actions.add_device (device.id, device.name, device.manufacturer, device.model, device.power.to_string (), device.icon, device.default_icon); + Actions.add_device (device.id, device.name, device.manufacturer, device.model, device.power, device.icon, device.default_icon); on_new_device (device); @@ -59,7 +59,7 @@ public class Controllers.DevicesController { }); lifx_service.on_updated_device.connect ((device) => { - Actions.update_device (device.id, device.name, device.manufacturer, device.model, device.power.to_string (), device.icon, device.default_icon); + Actions.update_device (device.id, device.name, device.manufacturer, device.model, device.power, device.icon, device.default_icon); on_updated_device (device); }); @@ -71,7 +71,7 @@ public class Controllers.DevicesController { device.icon = device_loaded_map.get (device.id).icon; } - Actions.add_device (device.id, device.name, device.manufacturer, device.model, device.power.to_string (), device.icon, device.default_icon); + Actions.add_device (device.id, device.name, device.manufacturer, device.model, device.power, device.icon, device.default_icon); on_new_device (device); @@ -79,7 +79,7 @@ public class Controllers.DevicesController { }); philips_hue_service.on_updated_device.connect ((device) => { - Actions.update_device (device.id, device.name, device.manufacturer, device.model, device.power.to_string (), device.icon, device.default_icon); + Actions.update_device (device.id, device.name, device.manufacturer, device.model, device.power, device.icon, device.default_icon); on_updated_device (device); }); From 2dfce31b42d984d6f931f05695f22a50163ddc24 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 15 Apr 2021 20:11:45 +0200 Subject: [PATCH 23/39] Update Flatpak manifest --- com.github.manexim.home.yml | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/com.github.manexim.home.yml b/com.github.manexim.home.yml index d10a7d4..1b671fe 100644 --- a/com.github.manexim.home.yml +++ b/com.github.manexim.home.yml @@ -1,9 +1,7 @@ app-id: com.github.manexim.home -runtime: org.gnome.Platform -runtime-version: '3.38' -base: io.elementary.BaseApp -base-version: juno-20.08 -sdk: org.gnome.Sdk +runtime: io.elementary.Platform +runtime-version: '0.1.0' +sdk: io.elementary.Sdk command: com.github.manexim.home finish-args: - '--share=ipc' @@ -14,22 +12,6 @@ finish-args: # needed for perfers-color-scheme - '--system-talk-name=org.freedesktop.Accounts' modules: - - name: granite - buildsystem: meson - sources: - - type: git - url: https://github.com/elementary/granite.git - - - name: handy - buildsystem: meson - config-opts: - - '-Dexamples=false' - - '-Dtests=false' - sources: - - type: git - url: https://gitlab.gnome.org/GNOME/libhandy.git - tag: '1.2.0' - - name: home buildsystem: meson sources: From a493dfe28aab85caf8549747b93440a335085783 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 15 Apr 2021 20:11:54 +0200 Subject: [PATCH 24/39] Update GitHub CI --- .github/workflows/main.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 526f327..af35955 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,14 +4,11 @@ on: [push, pull_request] jobs: build: - runs-on: ubuntu-latest - container: image: elementary/docker:unstable - steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Install Dependencies run: | apt update @@ -27,20 +24,21 @@ jobs: flatpak: runs-on: ubuntu-latest container: - image: docker.io/bilelmoussaoui/flatpak-github-actions + image: docker.io/bilelmoussaoui/flatpak-github-actions:elementary-juno options: --privileged steps: - uses: actions/checkout@v2 - - uses: bilelmoussaoui/flatpak-github-actions@v2 + - uses: bilelmoussaoui/flatpak-github-actions@master with: bundle: "home.flatpak" manifest-path: "com.github.manexim.home.yml" run-tests: "true" + repository-name: "elementary" + repository-url: "https://flatpak.elementary.io/elementary.flatpakrepo" + cache-key: "flatpak-builder-${{ github.sha }}" lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - uses: elementary/actions/vala-lint@master From 58f1e2b275df34c8932768265d90ddf62c1b11b4 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 15 Apr 2021 20:12:03 +0200 Subject: [PATCH 25/39] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1c1b948..ff71115 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@

- - + + From 968d140e9a0f115def0a9bf4b3aab9a1f428a866 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 15 Apr 2021 21:35:01 +0200 Subject: [PATCH 26/39] Use RDNN --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index af35955..d6e147f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: - uses: actions/checkout@v2 - uses: bilelmoussaoui/flatpak-github-actions@master with: - bundle: "home.flatpak" + bundle: "com.github.manexim.home.flatpak" manifest-path: "com.github.manexim.home.yml" run-tests: "true" repository-name: "elementary" From a8ad934ac0133f0c4876c2b98bc05ac0f1eebb05 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Mon, 19 Apr 2021 16:28:01 +0200 Subject: [PATCH 27/39] Use daily as runtime-version --- com.github.manexim.home.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.github.manexim.home.yml b/com.github.manexim.home.yml index 1b671fe..c118671 100644 --- a/com.github.manexim.home.yml +++ b/com.github.manexim.home.yml @@ -1,6 +1,6 @@ app-id: com.github.manexim.home runtime: io.elementary.Platform -runtime-version: '0.1.0' +runtime-version: daily sdk: io.elementary.Sdk command: com.github.manexim.home finish-args: From e0f31d8286874615a99f4a2fa584940a0671626f Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 29 Apr 2021 19:53:45 +0200 Subject: [PATCH 28/39] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d6e147f..83c71fa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,7 +34,7 @@ jobs: manifest-path: "com.github.manexim.home.yml" run-tests: "true" repository-name: "elementary" - repository-url: "https://flatpak.elementary.io/elementary.flatpakrepo" + repository-url: "https://flatpak.elementary.io/repo.flatpakrepo" cache-key: "flatpak-builder-${{ github.sha }}" lint: From b492896c1fc819ed2852853f5c2f1c1af3754981 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Mon, 26 Jul 2021 20:21:29 +0200 Subject: [PATCH 29/39] Update runtime version --- com.github.manexim.home.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.github.manexim.home.yml b/com.github.manexim.home.yml index c118671..8fe9c2f 100644 --- a/com.github.manexim.home.yml +++ b/com.github.manexim.home.yml @@ -1,6 +1,6 @@ app-id: com.github.manexim.home runtime: io.elementary.Platform -runtime-version: daily +runtime-version: '6' sdk: io.elementary.Sdk command: com.github.manexim.home finish-args: From 51ee1947cd42103245524be2d0fa0d75976b23e1 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Mon, 26 Jul 2021 20:21:37 +0200 Subject: [PATCH 30/39] Add stripe key --- data/com.github.manexim.home.appdata.xml.in | 1 + 1 file changed, 1 insertion(+) diff --git a/data/com.github.manexim.home.appdata.xml.in b/data/com.github.manexim.home.appdata.xml.in index d60b07a..44c8711 100644 --- a/data/com.github.manexim.home.appdata.xml.in +++ b/data/com.github.manexim.home.appdata.xml.in @@ -212,6 +212,7 @@ #333 5 + pk_live_qZp2vPHK4sgLn3D0WrU5oDSS001IuweZie none From 57c5077ef209ff7f3b97422045b4f9ae59e99330 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Mon, 26 Jul 2021 20:24:06 +0200 Subject: [PATCH 31/39] Update stripe key --- data/com.github.manexim.home.appdata.xml.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/com.github.manexim.home.appdata.xml.in b/data/com.github.manexim.home.appdata.xml.in index 44c8711..c46b5ec 100644 --- a/data/com.github.manexim.home.appdata.xml.in +++ b/data/com.github.manexim.home.appdata.xml.in @@ -212,7 +212,7 @@ #333 5 - pk_live_qZp2vPHK4sgLn3D0WrU5oDSS001IuweZie + pk_live_FiCVZObTHO7IaLtSXRETuJiJ00aW6Su9kN none From 68a343bba602624b36d13dbe2429eb3f0d0cc37b Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sat, 14 Aug 2021 11:57:31 +0200 Subject: [PATCH 32/39] Update AppCenter colors --- data/com.github.manexim.home.appdata.xml.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/com.github.manexim.home.appdata.xml.in b/data/com.github.manexim.home.appdata.xml.in index c46b5ec..9bf79b0 100644 --- a/data/com.github.manexim.home.appdata.xml.in +++ b/data/com.github.manexim.home.appdata.xml.in @@ -208,8 +208,8 @@ https://github.com/manexim/home/issues - #fafafa - #333 + #802392 + #fafafa 5 pk_live_FiCVZObTHO7IaLtSXRETuJiJ00aW6Su9kN From 2d74b834087fc448e482a58c376bc58f72d10772 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sat, 20 Nov 2021 22:19:27 +0100 Subject: [PATCH 33/39] Fix icon --- ...github.manexim.home.logo.lifx-symbolic.svg | 124 ++++-------------- 1 file changed, 25 insertions(+), 99 deletions(-) diff --git a/data/icons/symbolic/com.github.manexim.home.logo.lifx-symbolic.svg b/data/icons/symbolic/com.github.manexim.home.logo.lifx-symbolic.svg index fa58df4..040c3fe 100644 --- a/data/icons/symbolic/com.github.manexim.home.logo.lifx-symbolic.svg +++ b/data/icons/symbolic/com.github.manexim.home.logo.lifx-symbolic.svg @@ -2,124 +2,54 @@ - - - - - - - - - - - - - - - + id="svg846" + inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" + sodipodi:docname="com.github.manexim.home.logo.lifx-symbolic.svg" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:i="&#38;ns_ai;"> - - - - image/svg+xml - - - - - + inkscape:window-maximized="1" + inkscape:current-layer="layer1" /> + + id="layer1"> - - + height="1" /> @@ -143,7 +72,6 @@ id="g8" style="fill:#440294;fill-opacity:1"> @@ -152,7 +80,6 @@ id="g12" style="fill:#440294;fill-opacity:1"> @@ -161,7 +88,6 @@ id="g16" style="fill:#440294;fill-opacity:1"> From f4eb8efa7b9af3ba9b618ca01ad5a9e355be6421 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sat, 20 Nov 2021 22:19:43 +0100 Subject: [PATCH 34/39] Improve tooling --- .vscode/tasks.json | 17 +++++++++++++++++ app | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .vscode/tasks.json create mode 100755 app diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..57738a0 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Build & Run", + "type": "shell", + "command": "./app build && ./app install && ./app run", + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} diff --git a/app b/app new file mode 100755 index 0000000..ca31bff --- /dev/null +++ b/app @@ -0,0 +1,19 @@ +#!/bin/bash + +# fail on first error +set -e + +APP=com.github.manexim.home + +case "$1" in + build) + flatpak-builder --repo=repo build ${APP}.yml --force-clean + flatpak build-bundle repo ${APP}.flatpak --runtime-repo=https://flatpak.elementary.io/repo.flatpakrepo ${APP} master + ;; + install) + flatpak install --user -y ${APP}.flatpak + ;; + run) + flatpak run ${APP} + ;; +esac From 4c7fea42cf41157d2286703aee8cdc98d0348f03 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sat, 20 Nov 2021 22:19:51 +0100 Subject: [PATCH 35/39] Update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 8aba8c9..bed0ac0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ build build-dir .flatpak-builder +repo/ +*.flatpak From 9bacccea86804053992c2bc7659a54d3c775b11c Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sat, 20 Nov 2021 22:20:05 +0100 Subject: [PATCH 36/39] MainWindow: Remove WindowHandle --- src/MainWindow.vala | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 234fca4..85a9e8a 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -56,10 +56,7 @@ public class MainWindow : Hdy.Window { main_layout.attach (headerbar, 0, 0); main_layout.attach (overlay, 0, 1); - var window_handle = new Hdy.WindowHandle (); - window_handle.add (main_layout); - - add (window_handle); + add (main_layout); stack = new Gtk.Stack (); overlay.add (stack); From 727c0977f11fc8d10ea594201850f9f39130e5fa Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sat, 20 Nov 2021 22:21:09 +0100 Subject: [PATCH 37/39] GitHub CI: Add build for ARM --- .github/workflows/ci.yml | 58 ++++++++++++++++++++++++++++++++++++++ .github/workflows/main.yml | 44 ----------------------------- 2 files changed, 58 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b097f9c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,58 @@ +name: CI + +on: + pull_request: + types: + - opened + - reopened + - synchronize + +jobs: + flatpak: + name: Flatpak + runs-on: ubuntu-latest + + strategy: + matrix: + arch: [x86_64, aarch64] + # Don't fail the whole workflow if one architecture fails + fail-fast: false + + container: + image: ghcr.io/elementary/flatpak-platform/runtime:6-${{ matrix.arch }} + options: --privileged + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up QEMU for aarch64 emulation + if: ${{ matrix.arch != 'x86_64' }} + uses: docker/setup-qemu-action@v1 + with: + platforms: arm64 + + - name: Build + uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4 + with: + bundle: com.github.manexim.home.flatpak + manifest-path: com.github.manexim.home.yml + run-tests: true + repository-name: appcenter + repository-url: https://flatpak.elementary.io/repo.flatpakrepo + cache-key: "flatpak-builder-${{ github.sha }}" + arch: ${{ matrix.arch }} + + lint: + name: Lint + runs-on: ubuntu-latest + + container: + image: valalang/lint + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Lint + run: io.elementary.vala-lint -d . diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 83c71fa..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: CI - -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - container: - image: elementary/docker:unstable - steps: - - uses: actions/checkout@v2 - - name: Install Dependencies - run: | - apt update - apt install -y libgranite-dev libgtk-3-dev libjson-glib-dev libgee-0.8-dev libsoup2.4-dev libxml2-dev uuid-dev libhandy-1-dev meson valac - - name: Build - env: - DESTDIR: out - run: | - meson build - ninja -C build - ninja -C build install - - flatpak: - runs-on: ubuntu-latest - container: - image: docker.io/bilelmoussaoui/flatpak-github-actions:elementary-juno - options: --privileged - steps: - - uses: actions/checkout@v2 - - uses: bilelmoussaoui/flatpak-github-actions@master - with: - bundle: "com.github.manexim.home.flatpak" - manifest-path: "com.github.manexim.home.yml" - run-tests: "true" - repository-name: "elementary" - repository-url: "https://flatpak.elementary.io/repo.flatpakrepo" - cache-key: "flatpak-builder-${{ github.sha }}" - - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: elementary/actions/vala-lint@master From 8bc0c43780a25e87d429f2af05d3e81198ac3ce9 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sat, 20 Nov 2021 22:36:28 +0100 Subject: [PATCH 38/39] Add gettext domain --- meson.build | 2 +- src/Application.vala | 9 ++++++++- src/{config/Constants.vala => Constants.vala.in} | 13 ++++++++----- src/MainWindow.vala | 2 +- src/meson.build | 16 ++++++++++++++-- src/onboarding/StartView.vala | 2 +- src/services/Settings.vala | 2 +- 7 files changed, 34 insertions(+), 12 deletions(-) rename src/{config/Constants.vala => Constants.vala.in} (71%) diff --git a/meson.build b/meson.build index ef6346f..0bfea21 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('com.github.manexim.home', 'vala', 'c') +project('com.github.manexim.home', 'vala', 'c', version: '0.5.0') gnome = import('gnome') i18n = import('i18n') diff --git a/src/Application.vala b/src/Application.vala index 3a25b6a..99ba340 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -24,11 +24,18 @@ public class Application : Granite.Application { public Application () { Object ( - application_id: Config.APP_ID, + application_id: Constants.APP_ID, flags: ApplicationFlags.FLAGS_NONE ); } + construct { + Intl.setlocale (LocaleCategory.ALL, ""); + Intl.bindtextdomain (Constants.GETTEXT_PACKAGE, Constants.LOCALEDIR); + Intl.bind_textdomain_codeset (Constants.GETTEXT_PACKAGE, "UTF-8"); + Intl.textdomain (Constants.GETTEXT_PACKAGE); + } + protected override void activate () { var granite_settings = Granite.Settings.get_default (); var gtk_settings = Gtk.Settings.get_default (); diff --git a/src/config/Constants.vala b/src/Constants.vala.in similarity index 71% rename from src/config/Constants.vala rename to src/Constants.vala.in index 1ebc517..83ef9f8 100644 --- a/src/config/Constants.vala +++ b/src/Constants.vala.in @@ -19,9 +19,12 @@ * Authored by: Marius Meisenzahl */ -namespace Config { - public const string APP_ID = "com.github.manexim.home"; - public const string APP_AUTHOR = "Manexim"; - public const string APP_NAME = "Home"; - public const string APP_VERSION = "0.5.0"; +namespace Constants { + private const string APP_ID = "@APP_ID@"; + private const string APP_AUTHOR = "Manexim"; + private const string APP_NAME = "Home"; + private const string APP_VERSION = "@APP_VERSION@"; + + private const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@"; + private const string LOCALEDIR = "@LOCALEDIR@"; } diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 85a9e8a..1d62b94 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -40,7 +40,7 @@ public class MainWindow : Hdy.Window { var headerbar = new Hdy.HeaderBar () { decoration_layout = "close:", show_close_button = true, - title = Config.APP_NAME + title = Constants.APP_NAME }; return_button = new Gtk.Button (); diff --git a/src/meson.build b/src/meson.build index bf18753..23475ba 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,7 +1,18 @@ +config_data = configuration_data() +config_data.set('APP_ID', meson.project_name()) +config_data.set('APP_VERSION', meson.project_version()) +config_data.set('GETTEXT_PACKAGE', meson.project_name()) +config_data.set('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir'))) + +config_file = configure_file( + input: 'Constants.vala.in', + output: '@BASENAME@', + configuration: config_data +) + sources = [ 'colors/HSB.vala', 'colors/RGB.vala', - 'config/Constants.vala', 'controllers/DeviceController.vala', 'controllers/DevicesController.vala', 'lifx/Controller.vala', @@ -39,7 +50,8 @@ sources = [ 'widgets/ColorPicker.vala', 'widgets/IconPopover.vala', 'widgets/Overlay.vala', - 'MainWindow.vala' + 'MainWindow.vala', + config_file, ] executable( diff --git a/src/onboarding/StartView.vala b/src/onboarding/StartView.vala index fc3e151..9446936 100644 --- a/src/onboarding/StartView.vala +++ b/src/onboarding/StartView.vala @@ -24,7 +24,7 @@ public class Onboarding.StartView : Onboarding.AbstractOnboardingView { Object ( description: _("Control your smart home gadgets"), icon_name: "com.github.manexim.home", - title: _("Welcome to %s!").printf (Config.APP_AUTHOR + " " + Config.APP_NAME) + title: _("Welcome to %s!").printf (Constants.APP_AUTHOR + " " + Constants.APP_NAME) ); } } diff --git a/src/services/Settings.vala b/src/services/Settings.vala index 52f057a..d1c9caf 100644 --- a/src/services/Settings.vala +++ b/src/services/Settings.vala @@ -114,7 +114,7 @@ public class Settings : Granite.Services.Settings { return; #endif - last_started_app_version = Config.APP_VERSION; + last_started_app_version = Constants.APP_VERSION; var philips_hue_service = Philips.Hue.Service.instance; From 952d285376a0d6b00ae1f4170a1eb7c73748539a Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sat, 20 Nov 2021 23:08:13 +0100 Subject: [PATCH 39/39] Set default values --- src/models/Thing.vala | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/models/Thing.vala b/src/models/Thing.vala index 4933d83..89258ef 100644 --- a/src/models/Thing.vala +++ b/src/models/Thing.vala @@ -25,6 +25,10 @@ public class Models.Thing : Object { public Thing () { _obj = new Json.Object (); default_icon = "com.github.manexim.home.icon.thing-symbolic"; + id = ""; + name = ""; + manufacturer = ""; + model = ""; } public Thing.from_object (Json.Object object) {