Skip to content

Commit

Permalink
Another initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dar5hak committed Feb 26, 2019
1 parent 388ccc3 commit 11f3bf8
Show file tree
Hide file tree
Showing 11 changed files with 387 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2018 Darshak <{{email}}> -->
<!-- Copyright 2018 Darshak Parikh <darshak@protonmail.com> -->
<component type="desktop">
<id>com.github.dar5hak.ergobadger.desktop</id>
<id>com.github.dar5hak.badger.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_group>Darshak</project_group>
<project_group>Darshak Parikh</project_group>
<project_license>GPL-3.0+</project_license>
<name></name>
<summary></summary>
Expand All @@ -12,7 +12,7 @@
<release version="0.0.1" date="2018-05-05"/>
</releases>
<provides>
<binary>com.github.dar5hak.ergobadger</binary>
<binary>com.github.dar5hak.badger</binary>
</provides>
<content_rating type="oars-1.1">
<content_attribute id="violence-cartoon">none</content_attribute>
Expand Down Expand Up @@ -43,10 +43,10 @@
<content_attribute id="money-purchasing">none</content_attribute>
<content_attribute id="money-gambling">none</content_attribute>
</content_rating>
<developer_name>Darshak</developer_name>
<url type="homepage">https://dubiousdisc.xyz</url>
<url type="bugtracker">http://github.com/dar5hak/ergobadger/issues</url>
<url type="help">http://github.com/dar5hak/ergobadger/issues</url>
<developer_name>Darshak Parikh</developer_name>
<url type="homepage">http://github.com/dar5hak/badger</url>
<url type="bugtracker">http://github.com/dar5hak/badger/issues</url>
<url type="help">http://github.com/dar5hak/badger/issues</url>
<update_contact>darshak_AT_protonmail.com</update_contact>
<screenshots>
<screenshot type="default">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Name=
Comment=
GenericName=
Exec=@EXEC_NAME@ %U
Icon=com.github.dar5hak.ergobadger
Icon=com.github.dar5hak.badger
Terminal=false
Categories=Utility;GTK;Development;
Keywords=Develop
53 changes: 53 additions & 0 deletions data/gschema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema
path="/com/github/dar5hak/badger/reminders/"
id="com.github.dar5hak.badger.reminders"
gettext-domain="com.github.dar5hak.badger">
<key name="eyes" type="b">
<default>true</default>
<summary>Remind the user to blink their eyes</summary>
</key>
<key name="fingers" type="b">
<default>true</default>
<summary>Remind the user to stretch their fingers</summary>
</key>
<key name="legs" type="b">
<default>true</default>
<summary>Remind the user to stretch their legs</summary>
</key>
<key name="arms" type="b">
<default>true</default>
<summary>Remind the user to stretch their arms</summary>
</key>
<key name="neck" type="b">
<default>true</default>
<summary>Remind the user to stretch their neck</summary>
</key>
</schema>
<schema
path="/com/github/dar5hak/badger/window-state/"
id="com.github.dar5hak.badger.window-state"
gettext-domain="com.github.dar5hak.badger">
<key name="window-width" type="i">
<default>280</default>
<summary>The saved width of the window.</summary>
<description>The saved width of the window.</description>
</key>
<key name="window-height" type="i">
<default>320</default>
<summary>The saved height of the window.</summary>
<description>The saved height of the window.</description>
</key>
<key name="window-x" type="i">
<default>250</default>
<summary></summary>
<description></description>
</key>
<key name="window-y" type="i">
<default>250</default>
<summary></summary>
<description></description>
</key>
</schema>
</schemalist>
16 changes: 14 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# project name and programming language
project('com.github.dar5hak.ergobadger', 'vala', 'c', version: '0.1.0')
project('com.github.dar5hak.badger', 'vala', 'c', version: '0.1.0')

message ('project name and programming language')

Expand Down Expand Up @@ -46,6 +46,12 @@ foreach i : icon_sizes
)
endforeach

install_data(
'data/gschema.xml',
install_dir: join_paths(get_option('datadir'), 'glib-2.0', 'schemas'),
rename: meson.project_name() + '.gschema.xml'
)

config_data = configuration_data()
config_data.set('EXEC_NAME', meson.project_name())

Expand Down Expand Up @@ -86,7 +92,10 @@ appstream_file = i18n.merge_file(
message ('Adds files to build')

code_files = files(
'src/Application.vala'
'src/Application.vala',
'src/MainWindow.vala',
'src/Reminder.vala',
'src/MainGrid.vala'
)

message ('Defines executable')
Expand All @@ -97,3 +106,6 @@ executable(
dependencies: dependencies,
install: true
)

meson.add_install_script('meson/post_install.py')

26 changes: 26 additions & 0 deletions meson/post_install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3

import os
import subprocess

prefix = os.environ.get('MESON_INSTALL_PREFIX', '/usr/local')
datadir = os.path.join(prefix, 'share')
schemadir = os.path.join(os.environ['MESON_INSTALL_PREFIX'], 'share', 'glib-2.0', 'schemas')

# Packaging tools define DESTDIR and this isn't needed for them
if 'DESTDIR' not in os.environ:
print('Updating icon cache...')
icon_cache_dir = os.path.join(datadir, 'icons', 'hicolor')
if not os.path.exists(icon_cache_dir):
os.makedirs(icon_cache_dir)
subprocess.call(['gtk-update-icon-cache', '-qtf', icon_cache_dir])

print('Updating desktop database...')
desktop_database_dir = os.path.join(datadir, 'applications')
if not os.path.exists(desktop_database_dir):
os.makedirs(desktop_database_dir)
subprocess.call(['update-desktop-database', '-q', desktop_database_dir])

print('Compiling gsettings schemas...')
subprocess.call(['glib-compile-schemas', schemadir])

129 changes: 91 additions & 38 deletions src/Application.vala
Original file line number Diff line number Diff line change
@@ -1,50 +1,103 @@
/*
* Copyright (c) {{yearrange}} Darshak (https://dubiousdisc.xyz)
*
* 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: Darshak <https://dubiousdisc.xyz>
*/
* Copyright (C) 2019 Darshak Parikh
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
* Authored by: Darshak Parikh <darshak@protonmail.com>
*
*/

using Granite;
using Granite.Widgets;
using Gtk;

namespace ErgoBadger {
public class Application : Granite.Application {
public class Badger.Application : Granite.Application {

public Application () {
Object(
application_id: "com.github.dar5hak.ergobadger",
flags: ApplicationFlags.FLAGS_NONE
);
}
private Badger.MainWindow window;

protected override void activate () {
var window = new Gtk.ApplicationWindow (this);
var main = new Gtk.Grid ();
public Application () {
Object(
application_id: "com.github.dar5hak.badger",
flags: ApplicationFlags.FLAGS_NONE
);
}

window.title = "ErgoBadger";
window.set_default_size (640, 480);
window.add (main);
window.show_all ();
protected override void activate () {
if (window != null) {
window.present ();
return;
}

public static int main (string[] args) {
var app = new ergobadger.Application ();
return app.run (args);
}
window = new MainWindow (this);

var reminders = set_up_reminders ();
var main = new MainGrid (reminders);

window.add (main);
window.show_all ();
}

public static int main (string[] args) {
var app = new Badger.Application ();

return app.run (args);
}

private Reminder[] set_up_reminders () {
Reminder[] reminders = new Reminder[5];
reminders[0] = new Reminder (
"eyes",
"Blink your eyes",
"Look away from the screen and blink your eyes for 10 seconds.",
"Blink eyes:",
300,
this
);
reminders[1] = new Reminder (
"fingers",
"Stretch your fingers",
"Spread out your palm wide, then close it into a fist. Repeat 10 times.",
"Stretch fingers:",
500,
this
);
reminders[2] = new Reminder (
"legs",
"Stretch your legs",
"Stand up, twist your ankles, raise each leg and bend your knee.",
"Stretch legs",
700,
this
);
reminders[3] = new Reminder (
"arms",
"Stretch your arms",
"Stretch and twist your arms, elbows and wrists for 10 seconds.",
"Stretch arms",
800,
this
);
reminders[4] = new Reminder (
"neck",
"Twist your neck",
"Turn your head in all directions. Repeat 5 times.",
"Twist neck",
600,
this
);

return reminders;
}
}

57 changes: 57 additions & 0 deletions src/MainGrid.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (C) 2019 Darshak Parikh
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
* Authored by: Darshak Parikh <darshak@protonmail.com>
*
*/

using Granite;
using Granite.Widgets;
using Gtk;

public class Badger.MainGrid : Gtk.Grid {

public Reminder[] reminders;

public MainGrid (Reminder[] reminders) {
this.reminders = reminders;

var settings = new GLib.Settings ("com.github.dar5hak.badger.reminders");

row_spacing = 6;
column_spacing = 12;
margin = 12;

attach (new Granite.HeaderLabel ("Reminders"), 0, 0, 2, 1);

Gtk.Switch[] switches = new Gtk.Switch[reminders.length];

for (int index = 0; index < reminders.length; index++) {
var label = new Gtk.Label (reminders[index].switch_label);
switches[index] = new Gtk.Switch ();

label.margin_start = 12;
label.halign = Gtk.Align.END;
switches[index].halign = Gtk.Align.START;
switches[index].valign = Gtk.Align.CENTER;

attach (label, 0, index + 1, 1, 1);
attach_next_to (switches[index], label, Gtk.PositionType.RIGHT, 1, 1);

settings.bind (reminders[index].name, switches[index], "active", GLib.SettingsBindFlags.DEFAULT);
}
}
}
Loading

0 comments on commit 11f3bf8

Please sign in to comment.