From 5ae95471fd8ddacd59d02fbee07c04aa44a9dac1 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Fri, 13 Aug 2021 12:34:21 +0200 Subject: [PATCH] Odin (#5) --- .github/workflows/main.yml | 33 +++++++++---------- .gitignore | 2 ++ .travis.yml | 24 -------------- README.md | 5 +-- com.github.manexim.insomnia.yml | 21 ++++++++++++ ...com.github.manexim.insomnia.appdata.xml.in | 1 + debian/changelog | 5 --- debian/compat | 1 - debian/control | 16 --------- debian/copyright | 7 ---- debian/rules | 29 ---------------- debian/source/format | 1 - meson.build | 2 ++ src/Application.vala | 10 +++--- src/Inhibitor.vala | 27 --------------- src/MainWindow.vala | 28 ++++++++++------ 16 files changed, 68 insertions(+), 144 deletions(-) delete mode 100644 .travis.yml create mode 100644 com.github.manexim.insomnia.yml 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/.github/workflows/main.yml b/.github/workflows/main.yml index 26180ef..d7d9997 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,31 +3,28 @@ name: CI on: [push, pull_request] jobs: - build: - + flatpak: runs-on: ubuntu-latest container: - image: elementary/docker:stable + image: ghcr.io/elementary/flatpak-platform/runtime:6 + options: --privileged steps: - - uses: actions/checkout@v1 - - name: Install Dependencies - run: | - apt update - apt install -y libgranite-dev libgtk-3-dev meson valac - - name: Build - env: - DESTDIR: out - run: | - meson build - ninja -C build - ninja -C build install + - uses: actions/checkout@v2 + - uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v3 + with: + bundle: com.github.manexim.insomnia.flatpak + manifest-path: com.github.manexim.insomnia.yml - lint: + run-tests: true - runs-on: ubuntu-latest + repository-name: appcenter + repository-url: https://flatpak.elementary.io/repo.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 diff --git a/.gitignore b/.gitignore index bdc5af0..8aba8c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *~ build +build-dir +.flatpak-builder 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 diff --git a/README.md b/README.md index 6c67b5b..2788b2e 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@

- - + + @@ -45,6 +45,7 @@ These dependencies must be present before building: - `libgranite-dev` - `libgtk-3-dev` +- `libhandy-1-dev` >=1.0.0 - `meson` - `valac` diff --git a/com.github.manexim.insomnia.yml b/com.github.manexim.insomnia.yml new file mode 100644 index 0000000..cb45b9a --- /dev/null +++ b/com.github.manexim.insomnia.yml @@ -0,0 +1,21 @@ +app-id: com.github.manexim.insomnia +runtime: io.elementary.Platform +runtime-version: '6' +sdk: io.elementary.Sdk +command: com.github.manexim.insomnia +finish-args: + - '--share=ipc' + - '--socket=fallback-x11' + - '--socket=wayland' + + # needed for perfers-color-scheme + - '--system-talk-name=org.freedesktop.Accounts' + + # needed for inhibitor + - '--talk-name=org.freedesktop.ScreenSaver' +modules: + - name: insomnia + buildsystem: meson + sources: + - type: dir + path: . diff --git a/data/com.github.manexim.insomnia.appdata.xml.in b/data/com.github.manexim.insomnia.appdata.xml.in index 9b16823..a1ec80e 100644 --- a/data/com.github.manexim.insomnia.appdata.xml.in +++ b/data/com.github.manexim.insomnia.appdata.xml.in @@ -45,6 +45,7 @@ #333 5 + pk_live_51EkDoMLYdJjuk3fQWqfwmLR9iSEtCiuaUOOJK61aay69r2W2gC6QoHEkOklKcIk2wMMebVKn5trxMYjCULqKKyZs00e78s0Kzo none diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 4f35972..0000000 --- a/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -com.github.manexim.insomnia (1.0.0) bionic; urgency=medium - - * Initial release - - -- Marius Meisenzahl Sat, 23 Jan 2021 13:27:29 +0100 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 6cc1674..0000000 --- a/debian/control +++ /dev/null @@ -1,16 +0,0 @@ -Source: com.github.manexim.insomnia -Section: x11 -Priority: optional -Maintainer: Marius Meisenzahl -Build-Depends: meson, - debhelper (>= 9), - libgtk-3-dev, - libgranite-dev, - valac -Standards-Version: 3.9.3 - -Package: com.github.manexim.insomnia -Architecture: any -Depends: ${misc:Depends}, ${shlibs:Depends} -Description: Insomnia - Prevent the display from being turned off or the device from going into sleep mode diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 6be35b6..0000000 --- a/debian/copyright +++ /dev/null @@ -1,7 +0,0 @@ -Format: http://dep.debian.net/deps/dep5 -Upstream-Name: com.github.manexim.insomnia -Source: https://github.com/manexim/insomnia - -Files: src/* data/* debian/* -Copyright: 2021 Marius Meisenzahl -License: GPL-3.0+ diff --git a/debian/rules b/debian/rules deleted file mode 100755 index bb6e803..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.insomnia 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) diff --git a/meson.build b/meson.build index 6241041..9498ade 100644 --- a/meson.build +++ b/meson.build @@ -8,10 +8,12 @@ add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name()), la granite_dep = dependency('granite') gtk_plus_3_dep = dependency('gtk+-3.0') +libhandy_dep = dependency('libhandy-1', version: '>=1.0.0') dependencies = [ granite_dep, gtk_plus_3_dep, + libhandy_dep, ] subdir('data') diff --git a/src/Application.vala b/src/Application.vala index 8dc4771..8d8af7c 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -66,12 +66,14 @@ public class Insomnia.Application : Gtk.Application { 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; + 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; + gtk_settings.gtk_application_prefer_dark_theme = ( + granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK + ); }); window.show_all (); diff --git a/src/Inhibitor.vala b/src/Inhibitor.vala index ec6d5c3..d243c6d 100644 --- a/src/Inhibitor.vala +++ b/src/Inhibitor.vala @@ -23,7 +23,6 @@ public interface Insomnia.ScreenSaverIface : Object { public abstract uint32 inhibit (string app_name, string reason) throws Error; public abstract void un_inhibit (uint32 cookie) throws Error; - public abstract void simulate_user_activity () throws Error; } public class Insomnia.Inhibitor : Object { @@ -37,7 +36,6 @@ public class Insomnia.Inhibitor : Object { private ScreenSaverIface? screensaver_iface = null; private bool inhibited = false; - private bool simulator_started = false; private Inhibitor () { try { @@ -60,7 +58,6 @@ public class Insomnia.Inhibitor : Object { try { inhibited = true; inhibit_cookie = screensaver_iface.inhibit (Constants.APP_ID, Constants.INHIBIT_STRING); - simulate_activity (); debug ("Inhibiting screen"); } catch (Error e) { warning ("Could not inhibit screen: %s", e.message); @@ -79,28 +76,4 @@ public class Insomnia.Inhibitor : Object { } } } - - /* - * Inhibit currently does not block a suspend from ocurring, - * so we simulate user activity every 2 mins to prevent it - */ - private void simulate_activity () { - if (simulator_started) return; - - simulator_started = true; - Timeout.add_full (Priority.DEFAULT, 120000, ()=> { - if (inhibited) { - try { - debug ("Simulating activity"); - screensaver_iface.simulate_user_activity (); - } catch (Error e) { - warning ("Could not simulate user activity: %s", e.message); - } - } else { - simulator_started = false; - } - - return inhibited; - }); - } } diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 037f941..98ace48 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -19,8 +19,8 @@ * Authored by: Marius Meisenzahl */ -public class Insomnia.MainWindow : Gtk.ApplicationWindow { - private Gtk.HeaderBar headerbar; +public class Insomnia.MainWindow : Hdy.Window { + private Hdy.HeaderBar headerbar; private Gtk.Label title_label; private bool timer_started; @@ -38,12 +38,13 @@ public class Insomnia.MainWindow : Gtk.ApplicationWindow { } construct { - get_style_context ().add_class ("rounded"); + Hdy.init (); - headerbar = new Gtk.HeaderBar () { - show_close_button = true + headerbar = new Hdy.HeaderBar () { + decoration_layout = "close:", + show_close_button = true, + title = Constants.APP_NAME }; - headerbar.get_style_context ().add_class ("default-decoration"); var menu_widget = new Gtk.Grid () { orientation = Gtk.Orientation.VERTICAL, @@ -113,11 +114,11 @@ public class Insomnia.MainWindow : Gtk.ApplicationWindow { headerbar.pack_end (app_menu); - set_titlebar (headerbar); - var grid = new Gtk.Grid () { halign = Gtk.Align.CENTER, - valign = Gtk.Align.CENTER + valign = Gtk.Align.CENTER, + hexpand = true, + vexpand = true }; title_label = new Gtk.Label ("") { @@ -127,7 +128,14 @@ public class Insomnia.MainWindow : Gtk.ApplicationWindow { grid.add (title_label); - add (grid); + var main_layout = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); + main_layout.add (headerbar); + main_layout.add (grid); + + var window_handle = new Hdy.WindowHandle (); + window_handle.add (main_layout); + + add (window_handle); } private void update () {