[gnome-break-timer/dylanmccall/meson-build: 1/3] Fix build errors and warnings
- From: Dylan McCall <dylanmccall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-break-timer/dylanmccall/meson-build: 1/3] Fix build errors and warnings
- Date: Fri, 13 Nov 2020 23:37:19 +0000 (UTC)
commit 7eec66304d1e02e719c6ef5ff1e7324d7e9f0080
Author: Dylan McCall <dylan dylanmccall ca>
Date: Fri Nov 13 15:14:58 2020 -0800
Fix build errors and warnings
config.vapi | 15 ---
gnome-break-timer.sh.in | 16 ---
meson.build | 14 +--
org.gnome.BreakTimer.appdata.xml | 1 +
org.gnome.BreakTimer.json | 24 +----
src/common/NaturalTime.vala | 4 +-
src/common/meson.build | 12 +--
src/config.vapi | 2 +
src/helper/BreakManager.vala | 8 +-
src/helper/HelperApplication.vala | 6 +-
src/helper/SessionStatus.vala | 14 ++-
.../MutterActivityMonitorBackend.vala | 19 +++-
src/helper/break/BreakController.vala | 10 +-
src/helper/break/BreakType.vala | 4 +-
src/helper/break/BreakView.vala | 2 +-
src/helper/break/TimerBreakController.vala | 2 +-
src/helper/break/TimerBreakType.vala | 6 +-
src/helper/break/TimerBreakView.vala | 2 +-
src/helper/meson.build | 59 ++--------
src/helper/microbreak/MicroBreakType.vala | 2 +-
src/helper/restbreak/RestBreakType.vala | 2 +-
src/meson.build | 43 +++++++-
src/settings/BreakInfoPanel.vala | 67 ++++++++++++
src/settings/BreakManager.vala | 5 +-
src/settings/BreakSettingsDialog.vala | 4 +-
src/settings/BreakSettingsPanel.vala | 78 ++++++++++++++
src/settings/BreakStatusPanel.vala | 32 ++++++
src/settings/BreakType.vala | 119 +--------------------
src/settings/CircleCounter.vala | 12 ++-
src/settings/MainWindow.vala | 28 +++--
src/settings/MicroBreakInfoPanel.vala | 56 ++++++++++
src/settings/MicroBreakSettingsPanel.vala | 30 ++++++
src/settings/MicroBreakStatusPanel.vala | 31 ++++++
src/settings/MicroBreakType.vala | 57 ----------
src/settings/RestBreakInfoPanel.vala | 57 ++++++++++
src/settings/RestBreakSettingsPanel.vala | 30 ++++++
src/settings/RestBreakStatusPanel.vala | 31 ++++++
src/settings/RestBreakType.vala | 58 ----------
src/settings/SettingsApplication.vala | 5 +-
src/settings/TimerBreakSettingsPanel.vala | 52 +++++++++
src/settings/TimerBreakStatusPanel.vala | 82 ++++++++++++++
src/settings/TimerBreakType.vala | 99 +----------------
src/settings/meson.build | 48 +++------
43 files changed, 716 insertions(+), 532 deletions(-)
---
diff --git a/meson.build b/meson.build
index f5e7826..a34b68a 100644
--- a/meson.build
+++ b/meson.build
@@ -36,7 +36,7 @@ locale_dir = join_paths(prefix, get_option('localedir'))
application_icon = 'org.gnome.BreakTimer'
application_url = 'https://wiki.gnome.org/Apps/BreakTimer'
-settings_application_id = 'org.gnome.BreakTimer'
+settings_application_id = 'org.gnome.BreakTimer.Settings'
helper_application_id = 'org.gnome.BreakTimer.Helper'
helper_bus_name = 'org.gnome.BreakTimer.Helper'
helper_object_path = '/org/gnome/BreakTimer'
@@ -50,7 +50,9 @@ build_conf.set_quoted('PROJECT_VERSION', meson.project_version())
build_conf.set_quoted('APPLICATION_ICON', application_icon)
build_conf.set_quoted('APPLICATION_URL', application_url)
build_conf.set_quoted('SETTINGS_APPLICATION_ID', settings_application_id)
+build_conf.set_quoted('SETTINGS_DESKTOP_FILE_ID', settings_application_id + '.desktop')
build_conf.set_quoted('HELPER_APPLICATION_ID', helper_application_id)
+build_conf.set_quoted('HELPER_DESKTOP_FILE_ID', helper_application_id + '.desktop')
build_conf.set_quoted('HELPER_BUS_NAME', helper_bus_name)
build_conf.set_quoted('HELPER_OBJECT_PATH', helper_object_path)
build_conf.set_quoted('HELPER_BREAK_OBJECT_BASE_PATH', helper_break_object_base_path)
@@ -61,16 +63,8 @@ add_project_arguments(['--vapidir', src_dir], language: 'vala')
run_script_conf = configuration_data()
run_script_conf.set('BINDIR', bindir)
-configure_file(
- input: 'gnome-break-timer.sh.in',
- output: 'gnome-break-timer',
- configuration: run_script_conf,
- install: true,
- install_dir: bindir
-)
-
subdir('po')
subdir('data')
subdir('src')
-meson.add_install_script('build-aux/meson/postinstall.py')
\ No newline at end of file
+meson.add_install_script('build-aux/meson/postinstall.py')
diff --git a/org.gnome.BreakTimer.appdata.xml b/org.gnome.BreakTimer.appdata.xml
new file mode 120000
index 0000000..ac0a64c
--- /dev/null
+++ b/org.gnome.BreakTimer.appdata.xml
@@ -0,0 +1 @@
+data/org.gnome.BreakTimer.appdata.xml.in.in
\ No newline at end of file
diff --git a/org.gnome.BreakTimer.json b/org.gnome.BreakTimer.json
index 9dd3c33..69872ab 100644
--- a/org.gnome.BreakTimer.json
+++ b/org.gnome.BreakTimer.json
@@ -1,9 +1,9 @@
{
"id" : "org.gnome.BreakTimer",
"runtime" : "org.gnome.Platform",
- "runtime-version" : "3.28",
+ "runtime-version" : "3.36",
"sdk" : "org.gnome.Sdk",
- "command" : "gnome-break-timer",
+ "command" : "gnome-break-timer-settings",
"finish-args" : [
"--share=ipc",
"--socket=x11",
@@ -31,30 +31,14 @@
}
},
"modules" : [
- {
- "name" : "libgee",
- "build-options" : {
- "env" : {
- "PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_GIRDIR" : "/app/share/gir-1.0",
- "PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_TYPELIBDIR" : "/app/lib/girepository-1.0"
- }
- },
- "sources" : [
- {
- "type" : "archive",
- "url" : "https://github.com/GNOME/libgee/archive/0.20.1.tar.gz",
- "sha256" : "d76d0bf8ae6659dba6018fadf2ccce218ccbc107666925552008806a29702c4b"
- }
- ]
- },
{
"name" : "gnome-break-timer",
"buildsystem" : "meson",
"builddir" : true,
"sources" : [
{
- "type" : "git",
- "url" : "https://gitlab.gnome.org/dylanmccall/gnome-break-timer.git"
+ "type" : "dir",
+ "path": "."
}
]
}
diff --git a/src/common/NaturalTime.vala b/src/common/NaturalTime.vala
index d706072..aecc519 100644
--- a/src/common/NaturalTime.vala
+++ b/src/common/NaturalTime.vala
@@ -22,7 +22,7 @@ public class NaturalTime : Object {
private struct TimeUnit {
public int seconds;
- public FormatTimeCb format_time;
+ public unowned FormatTimeCb format_time;
public TimeUnit (int seconds, FormatTimeCb format_time) {
this.seconds = seconds;
@@ -35,7 +35,7 @@ public class NaturalTime : Object {
}
}
- private TimeUnit[] units { get; private set; }
+ private TimeUnit[] units;
private NaturalTime () {
this.units = {
diff --git a/src/common/meson.build b/src/common/meson.build
index 93018e3..9dbed12 100644
--- a/src/common/meson.build
+++ b/src/common/meson.build
@@ -1,22 +1,22 @@
-common_sources = [
+common_sources = files(
'IBreakHelper.vala',
'ISessionStatus.vala',
'NaturalTime.vala'
-]
+)
common_dependencies = [
- config_lib_dep,
- gio_dep
+ gio_dep,
+ config_lib_dep
]
common_lib = static_library(
'common',
sources: common_sources,
- dependencies: common_dependencies
+ dependencies: common_dependencies,
+ include_directories: include_directories('.')
)
common_lib_dep = declare_dependency(
link_with: common_lib,
- dependencies: common_dependencies,
include_directories: include_directories('.')
)
diff --git a/src/config.vapi b/src/config.vapi
index 4b9e749..bec98a5 100644
--- a/src/config.vapi
+++ b/src/config.vapi
@@ -7,7 +7,9 @@ namespace Config {
public const string APPLICATION_ICON;
public const string APPLICATION_URL;
public const string HELPER_APPLICATION_ID;
+ public const string HELPER_DESKTOP_FILE_ID;
public const string SETTINGS_APPLICATION_ID;
+ public const string SETTINGS_DESKTOP_FILE_ID;
public const string HELPER_BUS_NAME;
public const string HELPER_OBJECT_PATH;
public const string HELPER_BREAK_OBJECT_BASE_PATH;
diff --git a/src/helper/BreakManager.vala b/src/helper/BreakManager.vala
index 43d714b..738d637 100644
--- a/src/helper/BreakManager.vala
+++ b/src/helper/BreakManager.vala
@@ -23,7 +23,7 @@ public class BreakManager : Object {
private Gee.Map<string, BreakType> breaks;
private BreakHelperServer break_helper_server;
- private Settings settings;
+ private GLib.Settings settings;
public bool master_enabled { get; set; }
public string[] selected_break_ids { get; set; }
@@ -31,10 +31,10 @@ public class BreakManager : Object {
this.ui_manager = ui_manager;
this.breaks = new Gee.HashMap<string, BreakType> ();
- this.settings = new Settings ("org.gnome.BreakTimer");
+ this.settings = new GLib.Settings ("org.gnome.BreakTimer");
- this.settings.bind ("enabled", this, "master-enabled", SettingsBindFlags.DEFAULT);
- this.settings.bind ("selected-breaks", this, "selected-break-ids", SettingsBindFlags.DEFAULT);
+ this.settings.bind ("enabled", this, "master-enabled", GLib.SettingsBindFlags.DEFAULT);
+ this.settings.bind ("selected-breaks", this, "selected-break-ids", GLib.SettingsBindFlags.DEFAULT);
this.notify["master-enabled"].connect (this.update_enabled_breaks);
this.notify["selected-break-ids"].connect (this.update_enabled_breaks);
diff --git a/src/helper/HelperApplication.vala b/src/helper/HelperApplication.vala
index 3e16144..0c3314d 100644
--- a/src/helper/HelperApplication.vala
+++ b/src/helper/HelperApplication.vala
@@ -65,11 +65,7 @@ public class HelperApplication : Gtk.Application {
this.session_status = new SessionStatus (this);
- try {
- this.activity_monitor_backend = new MutterActivityMonitorBackend ();
- } catch {
- GLib.error ("Failed to initialize activity monitor backend");
- }
+ this.activity_monitor_backend = new MutterActivityMonitorBackend ();
this.activity_monitor = new ActivityMonitor (session_status, activity_monitor_backend);
this.ui_manager = new UIManager (this, session_status);
diff --git a/src/helper/SessionStatus.vala b/src/helper/SessionStatus.vala
index 051b6d8..c37ce72 100644
--- a/src/helper/SessionStatus.vala
+++ b/src/helper/SessionStatus.vala
@@ -56,6 +56,8 @@ public class SessionStatus : ISessionStatus, Object {
} catch (IOError error) {
this.screensaver = null;
GLib.warning ("Error connecting to screensaver service: %s", error.message);
+ } catch (GLib.DBusError error) {
+ GLib.warning ("Error getting screensaver active status: %s", error.message);
}
}
@@ -85,7 +87,9 @@ public class SessionStatus : ISessionStatus, Object {
if (this.screensaver != null) {
try {
this.screensaver.lock ();
- } catch (IOError error) {
+ } catch (GLib.IOError error) {
+ GLib.warning ("Error connecting to screensaver service: %s", error.message);
+ } catch (GLib.DBusError error) {
GLib.warning ("Error locking screen: %s", error.message);
}
}
@@ -95,7 +99,9 @@ public class SessionStatus : ISessionStatus, Object {
if (this.screensaver != null) {
try {
this.screensaver.set_active (true);
- } catch (IOError error) {
+ } catch (GLib.IOError error) {
+ GLib.warning ("Error connecting to screensaver service: %s", error.message);
+ } catch (GLib.DBusError error) {
GLib.warning ("Error blanking screeen: %s", error.message);
}
}
@@ -105,7 +111,9 @@ public class SessionStatus : ISessionStatus, Object {
if (this.screensaver != null) {
try {
this.screensaver.set_active (false);
- } catch (IOError error) {
+ } catch (GLib.IOError error) {
+ GLib.warning ("Error connecting to screensaver service: %s", error.message);
+ } catch (GLib.DBusError error) {
GLib.warning ("Error unblanking screeen: %s", error.message);
}
}
diff --git a/src/helper/activity-monitor/MutterActivityMonitorBackend.vala
b/src/helper/activity-monitor/MutterActivityMonitorBackend.vala
index 0593990..99a8a70 100644
--- a/src/helper/activity-monitor/MutterActivityMonitorBackend.vala
+++ b/src/helper/activity-monitor/MutterActivityMonitorBackend.vala
@@ -69,6 +69,9 @@ public class MutterActivityMonitorBackend : ActivityMonitorBackend {
} catch (IOError error) {
this.mutter_idle_monitor = null;
GLib.warning ("Error connecting to mutter idle monitor service: %s", error.message);
+ } catch (GLib.DBusError error) {
+ this.mutter_idle_monitor = null;
+ GLib.warning ("Error adding mutter idle watch: %s", error.message);
}
}
@@ -81,7 +84,13 @@ public class MutterActivityMonitorBackend : ActivityMonitorBackend {
if (id == this.idle_watch_id) {
this.user_is_active = false;
this.update_last_idle_time();
- this.user_active_watch_id = this.mutter_idle_monitor.add_user_active_watch ();
+ try {
+ this.user_active_watch_id = this.mutter_idle_monitor.add_user_active_watch ();
+ } catch (IOError error) {
+ GLib.warning ("Error connecting to mutter idle monitor service: %s", error.message);
+ } catch (GLib.DBusError error) {
+ GLib.warning ("Error adding mutter user active watch: %s", error.message);
+ }
} else if (id == this.user_active_watch_id) {
this.user_is_active = true;
this.user_active_watch_id = 0;
@@ -89,7 +98,13 @@ public class MutterActivityMonitorBackend : ActivityMonitorBackend {
}
private void update_last_idle_time() {
- this.last_idle_time_ms = this.mutter_idle_monitor.get_idletime ();
+ try {
+ this.last_idle_time_ms = this.mutter_idle_monitor.get_idletime ();
+ } catch (IOError error) {
+ GLib.warning ("Error connecting to mutter idle monitor service: %s", error.message);
+ } catch (GLib.DBusError error) {
+ GLib.warning ("Error getting mutter idletime: %s", error.message);
+ }
this.last_idle_time_update_time_ms = Util.get_monotonic_time_ms ();
}
diff --git a/src/helper/break/BreakController.vala b/src/helper/break/BreakController.vala
index f652517..c616912 100644
--- a/src/helper/break/BreakController.vala
+++ b/src/helper/break/BreakController.vala
@@ -71,9 +71,9 @@ public abstract class BreakController : Object {
/** The break is active and it has progressed in some fashion (for example, remaining time has changed).
*/
public signal void active_changed ();
- private int64? activate_timestamp { get; set; }
+ private Value? activate_timestamp;
- public BreakController () {
+ protected BreakController () {
this.state = State.DISABLED;
this.activate_timestamp = null;
}
@@ -84,7 +84,7 @@ public abstract class BreakController : Object {
if (this.activate_timestamp == null) {
json_root.set_null_member ("activate_timestamp");
} else {
- json_root.set_int_member ("activate_timestamp", this.activate_timestamp);
+ json_root.set_int_member ("activate_timestamp", (int64) this.activate_timestamp);
}
return json_root;
}
@@ -139,7 +139,7 @@ public abstract class BreakController : Object {
*/
public int get_seconds_since_start () {
if (this.activate_timestamp != null) {
- return (int) (Util.get_real_time_seconds () - this.activate_timestamp);
+ return (int) (Util.get_real_time_seconds () - (int64) this.activate_timestamp);
} else {
return 0;
}
@@ -152,7 +152,7 @@ public abstract class BreakController : Object {
public void activate () {
if (this.state < State.ACTIVE) {
if (this.activate_timestamp == null) {
- this.activate_timestamp = Util.get_real_time_seconds ();
+ this.activate_timestamp = (int64) Util.get_real_time_seconds ();
}
this.state = State.ACTIVE;
this.activated ();
diff --git a/src/helper/break/BreakType.vala b/src/helper/break/BreakType.vala
index 3b0f544..9fc5af2 100644
--- a/src/helper/break/BreakType.vala
+++ b/src/helper/break/BreakType.vala
@@ -22,9 +22,9 @@ public abstract class BreakType : Object {
public BreakController break_controller;
public BreakView break_view;
- protected Settings settings;
+ protected GLib.Settings settings;
- public BreakType (string id, Settings settings) {
+ protected BreakType (string id, GLib.Settings settings) {
this.id = id;
this.settings = settings;
}
diff --git a/src/helper/break/BreakView.vala b/src/helper/break/BreakView.vala
index 66116df..131e3d7 100644
--- a/src/helper/break/BreakView.vala
+++ b/src/helper/break/BreakView.vala
@@ -22,7 +22,7 @@ public abstract class BreakView : UIFragment {
private int64 last_break_notification_time = 0;
- public BreakView (BreakController break_controller, UIManager ui_manager) {
+ protected BreakView (BreakController break_controller, UIManager ui_manager) {
this.ui_manager = ui_manager;
this.break_controller = break_controller;
diff --git a/src/helper/break/TimerBreakController.vala b/src/helper/break/TimerBreakController.vala
index b73bc16..0486445 100644
--- a/src/helper/break/TimerBreakController.vala
+++ b/src/helper/break/TimerBreakController.vala
@@ -38,7 +38,7 @@ public abstract class TimerBreakController : BreakController {
private StatefulTimer counting_timer = new StatefulTimer ();
private StatefulTimer delayed_timer = new StatefulTimer ();
- public TimerBreakController (ActivityMonitor activity_monitor, int fuzzy_seconds = 0) {
+ protected TimerBreakController (ActivityMonitor activity_monitor, int fuzzy_seconds = 0) {
base ();
this.fuzzy_seconds = fuzzy_seconds;
diff --git a/src/helper/break/TimerBreakType.vala b/src/helper/break/TimerBreakType.vala
index 6396379..f708aec 100644
--- a/src/helper/break/TimerBreakType.vala
+++ b/src/helper/break/TimerBreakType.vala
@@ -20,7 +20,7 @@ namespace BreakTimer.Helper {
public abstract class TimerBreakType : BreakType {
private BreakHelper_TimerBreakServer break_type_server;
- public TimerBreakType (string id, Settings settings) {
+ protected TimerBreakType (string id, GLib.Settings settings) {
base (id, settings);
}
@@ -30,8 +30,8 @@ public abstract class TimerBreakType : BreakType {
var timer_break_controller = (TimerBreakController)this.break_controller;
var timer_break_view = (TimerBreakView)this.break_view;
- this.settings.bind ("interval-seconds", timer_break_controller, "interval", SettingsBindFlags.GET);
- this.settings.bind ("duration-seconds", timer_break_controller, "duration", SettingsBindFlags.GET);
+ this.settings.bind ("interval-seconds", timer_break_controller, "interval",
GLib.SettingsBindFlags.GET);
+ this.settings.bind ("duration-seconds", timer_break_controller, "duration",
GLib.SettingsBindFlags.GET);
this.break_type_server = new BreakHelper_TimerBreakServer (
timer_break_controller,
diff --git a/src/helper/break/TimerBreakView.vala b/src/helper/break/TimerBreakView.vala
index db4dec9..1d15ea2 100644
--- a/src/helper/break/TimerBreakView.vala
+++ b/src/helper/break/TimerBreakView.vala
@@ -22,7 +22,7 @@ public abstract class TimerBreakView : BreakView {
get { return (TimerBreakController)this.break_controller; }
}
- public TimerBreakView (TimerBreakController timer_break, UIManager ui_manager) {
+ protected TimerBreakView (TimerBreakController timer_break, UIManager ui_manager) {
base (timer_break, ui_manager);
}
diff --git a/src/helper/meson.build b/src/helper/meson.build
index 0d83a7f..b798386 100644
--- a/src/helper/meson.build
+++ b/src/helper/meson.build
@@ -1,67 +1,28 @@
-helper_sources = [
+helper_sources = files(
'activity-monitor/ActivityMonitor.vala',
'activity-monitor/MutterActivityMonitorBackend.vala',
'activity-monitor/UserActivity.vala',
- 'util/Countdown.vala',
- 'util/PausableTimeout.vala',
- 'util/SimpleFocusManager.vala',
- 'util/StatefulTimer.vala',
- 'util/Util.vala',
'break/BreakController.vala',
'break/BreakType.vala',
'break/BreakView.vala',
+ 'BreakManager.vala',
'break/TimerBreakController.vala',
'break/TimerBreakType.vala',
'break/TimerBreakView.vala',
+ 'HelperApplication.vala',
+ 'main.vala',
'microbreak/MicroBreakController.vala',
'microbreak/MicroBreakType.vala',
'microbreak/MicroBreakView.vala',
'restbreak/RestBreakController.vala',
'restbreak/RestBreakType.vala',
'restbreak/RestBreakView.vala',
- 'BreakManager.vala',
- 'HelperApplication.vala',
'SessionStatus.vala',
'UIFragment.vala',
- 'UIManager.vala'
-]
-
-# TODO: Build and link activity_monitor and util subdirs
-
-helper_dependencies = [
- common_lib_dep,
- gtk_dep,
- gio_dep,
- gio_unix_dep,
- gee_dep,
- json_glib_dep,
- libnotify_dep,
- libcanberra_dep,
- posix_dep,
- m_dep
-]
-
-helper_lib = static_library(
- 'helper',
- sources: helper_sources,
- dependencies: helper_dependencies
-)
-
-helper_lib_dep = declare_dependency(
- link_with: helper_lib,
- dependencies: helper_dependencies,
- include_directories: include_directories('.')
+ 'UIManager.vala',
+ 'util/Countdown.vala',
+ 'util/PausableTimeout.vala',
+ 'util/SimpleFocusManager.vala',
+ 'util/StatefulTimer.vala',
+ 'util/Util.vala'
)
-
-helper_main_sources = [
- 'main.vala',
- break_timer_resources
-]
-
-executable(
- 'gnome-break-timer-service',
- sources : helper_main_sources,
- dependencies : helper_lib_dep,
- install: true,
- install_dir: bindir
-)
\ No newline at end of file
diff --git a/src/helper/microbreak/MicroBreakType.vala b/src/helper/microbreak/MicroBreakType.vala
index 6999e04..7aef0e6 100644
--- a/src/helper/microbreak/MicroBreakType.vala
+++ b/src/helper/microbreak/MicroBreakType.vala
@@ -21,7 +21,7 @@ public class MicroBreakType : TimerBreakType {
private ActivityMonitor activity_monitor;
public MicroBreakType (ActivityMonitor activity_monitor) {
- Settings settings = new Settings ("org.gnome.BreakTimer.microbreak");
+ GLib.Settings settings = new GLib.Settings ("org.gnome.BreakTimer.microbreak");
base ("microbreak", settings);
this.activity_monitor = activity_monitor;
}
diff --git a/src/helper/restbreak/RestBreakType.vala b/src/helper/restbreak/RestBreakType.vala
index 028ac51..09332f5 100644
--- a/src/helper/restbreak/RestBreakType.vala
+++ b/src/helper/restbreak/RestBreakType.vala
@@ -21,7 +21,7 @@ public class RestBreakType : TimerBreakType {
private ActivityMonitor activity_monitor;
public RestBreakType (ActivityMonitor activity_monitor) {
- Settings settings = new Settings ("org.gnome.BreakTimer.restbreak");
+ GLib.Settings settings = new GLib.Settings ("org.gnome.BreakTimer.restbreak");
base ("restbreak", settings);
this.activity_monitor = activity_monitor;
}
diff --git a/src/meson.build b/src/meson.build
index 03cdbd3..864fdf1 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,18 +1,55 @@
-configure_file(
+config_file = configure_file(
output: 'config.h',
configuration: build_conf
)
config_lib = valac.find_library(
'config',
- dirs: meson.source_root()
+ dirs: meson.current_source_dir()
)
config_lib_dep = declare_dependency(
+ sources: config_file,
dependencies: config_lib,
include_directories: include_directories('.')
)
subdir('common')
subdir('settings')
-subdir('helper')
\ No newline at end of file
+subdir('helper')
+
+main_dependencies = [
+ cairo_dep,
+ config_lib_dep,
+ gee_dep,
+ gio_dep,
+ gio_unix_dep,
+ gtk_dep,
+ json_glib_dep,
+ libcanberra_dep,
+ libnotify_dep,
+ m_dep,
+ posix_dep,
+ common_lib_dep,
+ break_timer_resources_dep
+]
+
+executable(
+ 'gnome-break-timer-settings',
+ sources : [
+ settings_sources
+ ],
+ dependencies : main_dependencies,
+ install: true,
+ install_dir: bindir
+)
+
+executable(
+ 'gnome-break-timer-service',
+ sources : [
+ helper_sources
+ ],
+ dependencies : main_dependencies,
+ install: true,
+ install_dir: bindir
+)
diff --git a/src/settings/BreakInfoPanel.vala b/src/settings/BreakInfoPanel.vala
new file mode 100644
index 0000000..7c8640f
--- /dev/null
+++ b/src/settings/BreakInfoPanel.vala
@@ -0,0 +1,67 @@
+/*
+ * This file is part of GNOME Break Timer.
+ *
+ * GNOME Break Timer 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.
+ *
+ * GNOME Break Timer 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 GNOME Break Timer. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace BreakTimer.Settings {
+
+public abstract class BreakInfoPanel : Gtk.Grid {
+ public BreakType break_type { public get; private set; }
+ public string title { public get; private set; }
+
+ private Gtk.Label heading_label;
+ private Gtk.Label description_label;
+ private Gtk.Label detail_label;
+
+ protected BreakInfoPanel (BreakType break_type, string title) {
+ Object ();
+ this.break_type = break_type;
+ this.title = title;
+
+ this.set_orientation (Gtk.Orientation.VERTICAL);
+ this.set_hexpand (true);
+ this.set_row_spacing (24);
+ this.get_style_context ().add_class ("_break-info");
+
+ this.heading_label = new Gtk.Label (null);
+ this.add (this.heading_label);
+ this.heading_label.get_style_context ().add_class ("_break-info-heading");
+
+ this.description_label = new Gtk.Label (null);
+ this.add (this.description_label);
+ this.description_label.set_line_wrap (true);
+ this.description_label.set_justify (Gtk.Justification.CENTER);
+ this.description_label.set_max_width_chars (60);
+
+ this.detail_label = new Gtk.Label (null);
+ this.add (this.detail_label);
+
+ this.show_all ();
+ }
+
+ protected void set_heading (string heading) {
+ this.heading_label.set_label (heading);
+ }
+
+ protected void set_description (string description) {
+ this.description_label.set_label (description);
+ }
+
+ protected void set_detail (string detail) {
+ this.detail_label.set_label (detail);
+ }
+}
+
+}
diff --git a/src/settings/BreakManager.vala b/src/settings/BreakManager.vala
index 3b22803..780a90e 100644
--- a/src/settings/BreakManager.vala
+++ b/src/settings/BreakManager.vala
@@ -140,7 +140,10 @@ public class BreakManager : Object {
private void launch_break_timer_service () {
// TODO: Use dbus activation once we can depend on GLib >= 2.37
- AppInfo helper_app_info = new DesktopAppInfo (Config.HELPER_APPLICATION_ID);
+ stdout.printf ("Trying to launch: %s\n", Config.HELPER_DESKTOP_FILE_ID);
+ AppInfo helper_app_info = new DesktopAppInfo (Config.HELPER_DESKTOP_FILE_ID);
+ stdout.printf ("helper_app_info: %s\n", helper_app_info.get_name());
+ stdout.printf ("helper_app_info: %s\n", helper_app_info.get_commandline());
AppLaunchContext app_launch_context = new AppLaunchContext ();
try {
helper_app_info.launch (null, app_launch_context);
diff --git a/src/settings/BreakSettingsDialog.vala b/src/settings/BreakSettingsDialog.vala
index bbe2bff..5d360cb 100644
--- a/src/settings/BreakSettingsDialog.vala
+++ b/src/settings/BreakSettingsDialog.vala
@@ -45,9 +45,9 @@ public class BreakSettingsDialog : Gtk.Dialog {
content_area.add (content);
content.set_orientation (Gtk.Orientation.VERTICAL);
content.set_margin_top (10);
- content.set_margin_right (10);
+ content.set_margin_start (10);
content.set_margin_bottom (10);
- content.set_margin_left (10);
+ content.set_margin_end (10);
this.configuration_chooser = new BreakConfigurationChooser ();
content.add (this.configuration_chooser);
diff --git a/src/settings/BreakSettingsPanel.vala b/src/settings/BreakSettingsPanel.vala
new file mode 100644
index 0000000..e083c01
--- /dev/null
+++ b/src/settings/BreakSettingsPanel.vala
@@ -0,0 +1,78 @@
+/*
+ * This file is part of GNOME Break Timer.
+ *
+ * GNOME Break Timer 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.
+ *
+ * GNOME Break Timer 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 GNOME Break Timer. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace BreakTimer.Settings {
+
+public abstract class BreakSettingsPanel : Gtk.Grid {
+ private Gtk.Grid header;
+ private Gtk.Grid details;
+
+ protected BreakSettingsPanel (BreakType break_type, string title, string? description) {
+ Object ();
+
+ this.set_orientation (Gtk.Orientation.VERTICAL);
+ this.set_row_spacing (10);
+
+ this.header = new Gtk.Grid ();
+ this.add (this.header);
+ this.header.set_column_spacing (12);
+
+ var title_grid = new Gtk.Grid ();
+ this.set_header (title_grid);
+ title_grid.set_orientation (Gtk.Orientation.VERTICAL);
+ title_grid.set_row_spacing (4);
+
+ var title_label = new Gtk.Label (title);
+ title_grid.add (title_label);
+ title_label.get_style_context ().add_class ("_settings-title");
+ title_label.set_halign (Gtk.Align.FILL);
+ title_label.set_hexpand (true);
+ title_label.set_justify (Gtk.Justification.CENTER);
+
+ // var description_label = new Gtk.Label ("<small>%s</small>".printf (description));
+ // title_grid.add (description_label);
+ // description_label.get_style_context ().add_class ("_settings-description");
+ // description_label.set_use_markup (true);
+ // description_label.set_halign (Gtk.Align.FILL);
+ // description_label.set_hexpand (true);
+ // description_label.set_justify (Gtk.Justification.CENTER);
+
+ this.details = new Gtk.Grid ();
+ this.add (this.details);
+ this.details.set_margin_start (12);
+ this.details.set_halign (Gtk.Align.CENTER);
+ this.details.set_hexpand (true);
+
+ this.show_all ();
+ }
+
+ protected void set_header (Gtk.Widget content) {
+ this.header.attach (content, 0, 0, 1, 1);
+ }
+
+ protected void set_header_action (Gtk.Widget content) {
+ this.header.attach (content, 1, 0, 1, 1);
+ content.set_halign (Gtk.Align.END);
+ content.set_valign (Gtk.Align.CENTER);
+ }
+
+ protected void set_details (Gtk.Widget content) {
+ this.details.add (content);
+ }
+}
+
+}
diff --git a/src/settings/BreakStatusPanel.vala b/src/settings/BreakStatusPanel.vala
new file mode 100644
index 0000000..402d679
--- /dev/null
+++ b/src/settings/BreakStatusPanel.vala
@@ -0,0 +1,32 @@
+/*
+ * This file is part of GNOME Break Timer.
+ *
+ * GNOME Break Timer 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.
+ *
+ * GNOME Break Timer 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 GNOME Break Timer. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace BreakTimer.Settings {
+
+public abstract class BreakStatusPanel : Gtk.Grid {
+ public BreakType break_type { public get; private set; }
+ public bool is_enabled { get; set; default=false; }
+
+ protected BreakStatusPanel (BreakType break_type) {
+ Object ();
+ this.break_type = break_type;
+
+ this.get_style_context ().add_class ("_break-status");
+ }
+}
+
+}
diff --git a/src/settings/BreakType.vala b/src/settings/BreakType.vala
index 3136638..46283cd 100644
--- a/src/settings/BreakType.vala
+++ b/src/settings/BreakType.vala
@@ -27,7 +27,7 @@ public abstract class BreakType : Object {
public GLib.Settings settings;
- public BreakType (string id, GLib.Settings settings) {
+ protected BreakType (string id, GLib.Settings settings) {
this.id = id;
this.settings = settings;
}
@@ -50,121 +50,4 @@ public abstract class BreakType : Object {
protected abstract BreakSettingsPanel get_settings_panel ();
}
-public abstract class BreakInfoPanel : Gtk.Grid {
- public BreakType break_type { public get; private set; }
- public string title { public get; private set; }
-
- private Gtk.Label heading_label;
- private Gtk.Label description_label;
- private Gtk.Label detail_label;
-
- public BreakInfoPanel (BreakType break_type, string title) {
- Object ();
- this.break_type = break_type;
- this.title = title;
-
- this.set_orientation (Gtk.Orientation.VERTICAL);
- this.set_hexpand (true);
- this.set_row_spacing (24);
- this.get_style_context ().add_class ("_break-info");
-
- this.heading_label = new Gtk.Label (null);
- this.add (this.heading_label);
- this.heading_label.get_style_context ().add_class ("_break-info-heading");
-
- this.description_label = new Gtk.Label (null);
- this.add (this.description_label);
- this.description_label.set_line_wrap (true);
- this.description_label.set_justify (Gtk.Justification.CENTER);
- this.description_label.set_max_width_chars (60);
-
- this.detail_label = new Gtk.Label (null);
- this.add (this.detail_label);
-
- this.show_all ();
- }
-
- protected void set_heading (string heading) {
- this.heading_label.set_label (heading);
- }
-
- protected void set_description (string description) {
- this.description_label.set_label (description);
- }
-
- protected void set_detail (string detail) {
- this.detail_label.set_label (detail);
- }
-}
-
-public abstract class BreakStatusPanel : Gtk.Grid {
- public BreakType break_type { public get; private set; }
- public bool is_enabled { get; set; default=false; }
-
- public BreakStatusPanel (BreakType break_type) {
- Object ();
- this.break_type = break_type;
-
- this.get_style_context ().add_class ("_break-status");
- }
-}
-
-public abstract class BreakSettingsPanel : Gtk.Grid {
- private Gtk.Grid header;
- private Gtk.Grid details;
-
- public BreakSettingsPanel (BreakType break_type, string title, string? description) {
- Object ();
-
- this.set_orientation (Gtk.Orientation.VERTICAL);
- this.set_row_spacing (10);
-
- this.header = new Gtk.Grid ();
- this.add (this.header);
- this.header.set_column_spacing (12);
-
- var title_grid = new Gtk.Grid ();
- this.set_header (title_grid);
- title_grid.set_orientation (Gtk.Orientation.VERTICAL);
- title_grid.set_row_spacing (4);
-
- var title_label = new Gtk.Label (title);
- title_grid.add (title_label);
- title_label.get_style_context ().add_class ("_settings-title");
- title_label.set_halign (Gtk.Align.FILL);
- title_label.set_hexpand (true);
- title_label.set_justify (Gtk.Justification.CENTER);
-
- // var description_label = new Gtk.Label ("<small>%s</small>".printf (description));
- // title_grid.add (description_label);
- // description_label.get_style_context ().add_class ("_settings-description");
- // description_label.set_use_markup (true);
- // description_label.set_halign (Gtk.Align.FILL);
- // description_label.set_hexpand (true);
- // description_label.set_justify (Gtk.Justification.CENTER);
-
- this.details = new Gtk.Grid ();
- this.add (this.details);
- this.details.set_margin_left (12);
- this.details.set_halign (Gtk.Align.CENTER);
- this.details.set_hexpand (true);
-
- this.show_all ();
- }
-
- protected void set_header (Gtk.Widget content) {
- this.header.attach (content, 0, 0, 1, 1);
- }
-
- protected void set_header_action (Gtk.Widget content) {
- this.header.attach (content, 1, 0, 1, 1);
- content.set_halign (Gtk.Align.END);
- content.set_valign (Gtk.Align.CENTER);
- }
-
- protected void set_details (Gtk.Widget content) {
- this.details.add (content);
- }
-}
-
}
diff --git a/src/settings/CircleCounter.vala b/src/settings/CircleCounter.vala
index ed58ba0..3ce5a8c 100644
--- a/src/settings/CircleCounter.vala
+++ b/src/settings/CircleCounter.vala
@@ -68,13 +68,17 @@ public class CircleCounter : Gtk.Widget {
int radius = int.min(center_x, center_y);
double arc_radius = radius - LINE_WIDTH / 2;
- Gdk.RGBA trough_color = style_context.get_background_color (state);
- Gdk.RGBA base_color = style_context.get_color (state);
+ Gdk.RGBA foreground_color = style_context.get_color (state);
- Gdk.cairo_set_source_rgba (cr, trough_color);
+ cr.set_operator (Cairo.Operator.MULTIPLY);
+
+ Gdk.cairo_set_source_rgba (cr, foreground_color);
cr.arc (center_x, center_y, arc_radius, 0, Math.PI * 2.0);
cr.set_line_width (LINE_WIDTH);
+ cr.push_group ();
cr.stroke ();
+ cr.pop_group_to_source ();
+ cr.paint_with_alpha (0.3);
double start_angle = 1.5 * Math.PI;
double progress_angle = this.progress * Math.PI * 2.0;
@@ -94,7 +98,7 @@ public class CircleCounter : Gtk.Widget {
// No progress: Draw nothing (arc will gradually appear)
}
- Gdk.cairo_set_source_rgba (cr, base_color);
+ Gdk.cairo_set_source_rgba (cr, foreground_color);
cr.set_line_width (LINE_WIDTH);
cr.set_line_cap (Cairo.LineCap.ROUND);
cr.stroke ();
diff --git a/src/settings/MainWindow.vala b/src/settings/MainWindow.vala
index 5018491..ff4f808 100644
--- a/src/settings/MainWindow.vala
+++ b/src/settings/MainWindow.vala
@@ -20,11 +20,14 @@ namespace BreakTimer.Settings {
public class MainWindow : Gtk.ApplicationWindow {
private BreakManager break_manager;
+ private GLib.Menu app_menu;
+
private Gtk.HeaderBar header;
private Gtk.Stack main_stack;
private Gtk.Button settings_button;
private Gtk.Switch master_switch;
+ private Gtk.MenuButton menu_button;
private BreakSettingsDialog break_settings_dialog;
@@ -44,6 +47,10 @@ public class MainWindow : Gtk.ApplicationWindow {
GLib.error ("Error loading UI: %s", e.message);
}
+ this.app_menu = new GLib.Menu ();
+ this.app_menu.append ( _("About"), "app.about");
+ this.app_menu.append ( _("Quit"), "app.quit");
+
this.break_settings_dialog = new BreakSettingsDialog (break_manager);
this.break_settings_dialog.set_modal (true);
this.break_settings_dialog.set_transient_for (this);
@@ -59,12 +66,16 @@ public class MainWindow : Gtk.ApplicationWindow {
this.header.set_hexpand (true);
this.master_switch = new Gtk.Switch ();
- header.pack_start (this.master_switch);
master_switch.set_valign (Gtk.Align.CENTER);
break_manager.bind_property ("master-enabled", this.master_switch, "active",
BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
+ header.pack_start (this.master_switch);
+
+ this.menu_button = new Gtk.MenuButton ();
+ this.menu_button.set_direction (Gtk.ArrowType.NONE);
+ this.menu_button.set_menu_model (this.app_menu);
+ header.pack_end (this.menu_button);
this.settings_button = new Gtk.Button ();
- header.pack_end (this.settings_button);
settings_button.clicked.connect (this.settings_clicked_cb);
// FIXME: This icon is not semantically correct. (Wrong category, especially).
settings_button.set_image (new Gtk.Image.from_icon_name (
@@ -73,6 +84,7 @@ public class MainWindow : Gtk.ApplicationWindow {
);
settings_button.valign = Gtk.Align.CENTER;
settings_button.set_always_show_image (true);
+ header.pack_end (this.settings_button);
this.main_stack = new Gtk.Stack ();
content.add (this.main_stack);
@@ -111,8 +123,8 @@ public class MainWindow : Gtk.ApplicationWindow {
private void break_added_cb (BreakType break_type) {
var info_panel = break_type.info_panel;
this.main_stack.add_named (info_panel, break_type.id);
- info_panel.set_margin_left (20);
- info_panel.set_margin_right (20);
+ info_panel.set_margin_start (20);
+ info_panel.set_margin_end (20);
info_panel.set_halign (Gtk.Align.CENTER);
info_panel.set_valign (Gtk.Align.CENTER);
}
@@ -297,9 +309,9 @@ private class StatusPanel : Gtk.Stack {
this.break_manager = break_manager;
this.set_margin_top (20);
- this.set_margin_right (20);
+ this.set_margin_end (20);
this.set_margin_bottom (20);
- this.set_margin_left (20);
+ this.set_margin_start (20);
this.set_hexpand (true);
this.set_vexpand (true);
@@ -329,9 +341,9 @@ private class StatusPanel : Gtk.Stack {
var status_panel = break_type.status_panel;
this.breaks_list.add (status_panel);
status_panel.set_margin_top (18);
- status_panel.set_margin_right (20);
+ status_panel.set_margin_end (20);
status_panel.set_margin_bottom (18);
- status_panel.set_margin_left (20);
+ status_panel.set_margin_start (20);
}
private void status_changed_cb () {
diff --git a/src/settings/MicroBreakInfoPanel.vala b/src/settings/MicroBreakInfoPanel.vala
new file mode 100644
index 0000000..d3f4cfe
--- /dev/null
+++ b/src/settings/MicroBreakInfoPanel.vala
@@ -0,0 +1,56 @@
+/*
+ * This file is part of GNOME Break Timer.
+ *
+ * GNOME Break Timer 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.
+ *
+ * GNOME Break Timer 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 GNOME Break Timer. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace BreakTimer.Settings {
+
+class MicroBreakInfoPanel : BreakInfoPanel {
+ private TimerBreakStatus? status;
+
+ public MicroBreakInfoPanel (MicroBreakType break_type) {
+ base (
+ break_type,
+ _("Microbreak")
+ );
+
+ break_type.timer_status_changed.connect (this.timer_status_changed_cb);
+ }
+
+ private void timer_status_changed_cb (TimerBreakStatus? status) {
+ this.status = status;
+ this.update_description ();
+ }
+
+ private void update_description () {
+ if (this.status == null) return;
+
+ int time_remaining_value;
+ string time_remaining_text = NaturalTime.instance.get_countdown_for_seconds_with_start (
+ this.status.time_remaining, this.status.current_duration, out time_remaining_value);
+ string description_text = ngettext (
+ /* %s will be replaced with a string that describes a time interval, such as "2 minutes", "40
seconds" or "1 hour" */
+ "Take a break from typing and look away from the screen for %s.",
+ "Take a break from typing and look away from the screen for %s.",
+ time_remaining_value
+ ).printf (time_remaining_text);
+
+ this.set_heading ( _("It’s microbreak time"));
+ this.set_description (description_text);
+ this.set_detail (_("I'll chime when it’s time to use the computer again."));
+ }
+}
+
+}
diff --git a/src/settings/MicroBreakSettingsPanel.vala b/src/settings/MicroBreakSettingsPanel.vala
new file mode 100644
index 0000000..c8a986f
--- /dev/null
+++ b/src/settings/MicroBreakSettingsPanel.vala
@@ -0,0 +1,30 @@
+/*
+ * This file is part of GNOME Break Timer.
+ *
+ * GNOME Break Timer 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.
+ *
+ * GNOME Break Timer 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 GNOME Break Timer. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace BreakTimer.Settings {
+
+class MicroBreakSettingsPanel : TimerBreakSettingsPanel {
+ public MicroBreakSettingsPanel (MicroBreakType break_type) {
+ base (
+ break_type,
+ _("Microbreak"),
+ _("Pause frequently to relax your eyes")
+ );
+ }
+}
+
+}
diff --git a/src/settings/MicroBreakStatusPanel.vala b/src/settings/MicroBreakStatusPanel.vala
new file mode 100644
index 0000000..d64902d
--- /dev/null
+++ b/src/settings/MicroBreakStatusPanel.vala
@@ -0,0 +1,31 @@
+/*
+ * This file is part of GNOME Break Timer.
+ *
+ * GNOME Break Timer 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.
+ *
+ * GNOME Break Timer 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 GNOME Break Timer. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace BreakTimer.Settings {
+
+class MicroBreakStatusPanel : TimerBreakStatusPanel {
+ public MicroBreakStatusPanel (MicroBreakType break_type) {
+ base (
+ break_type,
+ /* Label that explains a countdown timer, which shows a string such as "5 minutes" */
+ _("Your next microbreak is in"),
+ _("It's time for a microbreak")
+ );
+ }
+}
+
+}
diff --git a/src/settings/MicroBreakType.vala b/src/settings/MicroBreakType.vala
index 898a9f7..ffb8b5f 100644
--- a/src/settings/MicroBreakType.vala
+++ b/src/settings/MicroBreakType.vala
@@ -39,61 +39,4 @@ public class MicroBreakType : TimerBreakType {
}
}
-class MicroBreakInfoPanel : BreakInfoPanel {
- private TimerBreakStatus? status;
-
- public MicroBreakInfoPanel (MicroBreakType break_type) {
- base (
- break_type,
- _("Microbreak")
- );
-
- break_type.timer_status_changed.connect (this.timer_status_changed_cb);
- }
-
- private void timer_status_changed_cb (TimerBreakStatus? status) {
- this.status = status;
- this.update_description ();
- }
-
- private void update_description () {
- if (this.status == null) return;
-
- int time_remaining_value;
- string time_remaining_text = NaturalTime.instance.get_countdown_for_seconds_with_start (
- this.status.time_remaining, this.status.current_duration, out time_remaining_value);
- string description_text = ngettext (
- /* %s will be replaced with a string that describes a time interval, such as "2 minutes", "40
seconds" or "1 hour" */
- "Take a break from typing and look away from the screen for %s.",
- "Take a break from typing and look away from the screen for %s.",
- time_remaining_value
- ).printf (time_remaining_text);
-
- this.set_heading ( _("It’s microbreak time"));
- this.set_description (description_text);
- this.set_detail (_("I'll chime when it’s time to use the computer again."));
- }
-}
-
-class MicroBreakStatusPanel : TimerBreakStatusPanel {
- public MicroBreakStatusPanel (MicroBreakType break_type) {
- base (
- break_type,
- /* Label that explains a countdown timer, which shows a string such as "5 minutes" */
- _("Your next microbreak is in"),
- _("It's time for a microbreak")
- );
- }
-}
-
-class MicroBreakSettingsPanel : TimerBreakSettingsPanel {
- public MicroBreakSettingsPanel (MicroBreakType break_type) {
- base (
- break_type,
- _("Microbreak"),
- _("Pause frequently to relax your eyes")
- );
- }
-}
-
}
diff --git a/src/settings/RestBreakInfoPanel.vala b/src/settings/RestBreakInfoPanel.vala
new file mode 100644
index 0000000..0baf3e7
--- /dev/null
+++ b/src/settings/RestBreakInfoPanel.vala
@@ -0,0 +1,57 @@
+/*
+ * This file is part of GNOME Break Timer.
+ *
+ * GNOME Break Timer 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.
+ *
+ * GNOME Break Timer 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 GNOME Break Timer. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace BreakTimer.Settings {
+
+class RestBreakInfoPanel : BreakInfoPanel {
+ private TimerBreakStatus? status;
+
+ public RestBreakInfoPanel (RestBreakType break_type) {
+ base (
+ break_type,
+ _("Break")
+ );
+
+ break_type.notify["duration"].connect (this.update_description);
+ break_type.timer_status_changed.connect (this.timer_status_changed_cb);
+ }
+
+ private void timer_status_changed_cb (TimerBreakStatus? status) {
+ this.status = status;
+ this.update_description ();
+ }
+
+ private void update_description () {
+ if (this.status == null) return;
+
+ int time_remaining_value;
+ string time_remaining_text = NaturalTime.instance.get_countdown_for_seconds_with_start (
+ this.status.time_remaining, this.status.current_duration, out time_remaining_value);
+ string detail_text = ngettext (
+ /* %s will be replaced with a string that describes a time interval, such as "2 minutes", "40
seconds" or "1 hour" */
+ "Your break has %s remaining. I’ll remind you when it’s over.",
+ "Your break has %s remaining. I’ll remind you when it’s over.",
+ time_remaining_value
+ ).printf (time_remaining_text);
+
+ this.set_heading ( _("It’s break time"));
+ this.set_description (_("Take some time away from the computer. Stretch and move around."));
+ this.set_detail (detail_text);
+ }
+}
+
+}
diff --git a/src/settings/RestBreakSettingsPanel.vala b/src/settings/RestBreakSettingsPanel.vala
new file mode 100644
index 0000000..d3ed03e
--- /dev/null
+++ b/src/settings/RestBreakSettingsPanel.vala
@@ -0,0 +1,30 @@
+/*
+ * This file is part of GNOME Break Timer.
+ *
+ * GNOME Break Timer 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.
+ *
+ * GNOME Break Timer 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 GNOME Break Timer. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace BreakTimer.Settings {
+
+class RestBreakSettingsPanel : TimerBreakSettingsPanel {
+ public RestBreakSettingsPanel (RestBreakType break_type) {
+ base (
+ break_type,
+ _("Full break"),
+ _("And take some longer breaks to stretch your legs")
+ );
+ }
+}
+
+}
diff --git a/src/settings/RestBreakStatusPanel.vala b/src/settings/RestBreakStatusPanel.vala
new file mode 100644
index 0000000..e6777c8
--- /dev/null
+++ b/src/settings/RestBreakStatusPanel.vala
@@ -0,0 +1,31 @@
+/*
+ * This file is part of GNOME Break Timer.
+ *
+ * GNOME Break Timer 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.
+ *
+ * GNOME Break Timer 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 GNOME Break Timer. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace BreakTimer.Settings {
+
+class RestBreakStatusPanel : TimerBreakStatusPanel {
+ public RestBreakStatusPanel (RestBreakType break_type) {
+ base (
+ break_type,
+ /* Label that explains a countdown timer, which shows a string such as "30 minutes" */
+ _("Your next full break is in"),
+ _("It's break time")
+ );
+ }
+}
+
+}
diff --git a/src/settings/RestBreakType.vala b/src/settings/RestBreakType.vala
index 790a98e..0c569ee 100644
--- a/src/settings/RestBreakType.vala
+++ b/src/settings/RestBreakType.vala
@@ -39,62 +39,4 @@ public class RestBreakType : TimerBreakType {
}
}
-class RestBreakInfoPanel : BreakInfoPanel {
- private TimerBreakStatus? status;
-
- public RestBreakInfoPanel (RestBreakType break_type) {
- base (
- break_type,
- _("Break")
- );
-
- break_type.notify["duration"].connect (this.update_description);
- break_type.timer_status_changed.connect (this.timer_status_changed_cb);
- }
-
- private void timer_status_changed_cb (TimerBreakStatus? status) {
- this.status = status;
- this.update_description ();
- }
-
- private void update_description () {
- if (this.status == null) return;
-
- int time_remaining_value;
- string time_remaining_text = NaturalTime.instance.get_countdown_for_seconds_with_start (
- this.status.time_remaining, this.status.current_duration, out time_remaining_value);
- string detail_text = ngettext (
- /* %s will be replaced with a string that describes a time interval, such as "2 minutes", "40
seconds" or "1 hour" */
- "Your break has %s remaining. I’ll remind you when it’s over.",
- "Your break has %s remaining. I’ll remind you when it’s over.",
- time_remaining_value
- ).printf (time_remaining_text);
-
- this.set_heading ( _("It’s break time"));
- this.set_description (_("Take some time away from the computer. Stretch and move around."));
- this.set_detail (detail_text);
- }
-}
-
-class RestBreakStatusPanel : TimerBreakStatusPanel {
- public RestBreakStatusPanel (RestBreakType break_type) {
- base (
- break_type,
- /* Label that explains a countdown timer, which shows a string such as "30 minutes" */
- _("Your next full break is in"),
- _("It's break time")
- );
- }
-}
-
-class RestBreakSettingsPanel : TimerBreakSettingsPanel {
- public RestBreakSettingsPanel (RestBreakType break_type) {
- base (
- break_type,
- _("Full break"),
- _("And take some longer breaks to stretch your legs")
- );
- }
-}
-
}
diff --git a/src/settings/SettingsApplication.vala b/src/settings/SettingsApplication.vala
index 606fef8..4d42851 100644
--- a/src/settings/SettingsApplication.vala
+++ b/src/settings/SettingsApplication.vala
@@ -101,10 +101,7 @@ public class SettingsApplication : Gtk.Application {
this.add_action (quit_action);
quit_action.activate.connect (this.quit);
- GLib.Menu app_menu = new GLib.Menu ();
- app_menu.append ( _("About"), "app.about");
- app_menu.append ( _("Quit"), "app.quit");
- this.set_app_menu (app_menu);
+ this.set_accels_for_action ("app.quit", {"<Primary>q"});
this.break_manager = new BreakManager (this);
this.main_window = new MainWindow (this, this.break_manager);
diff --git a/src/settings/TimerBreakSettingsPanel.vala b/src/settings/TimerBreakSettingsPanel.vala
new file mode 100644
index 0000000..0328305
--- /dev/null
+++ b/src/settings/TimerBreakSettingsPanel.vala
@@ -0,0 +1,52 @@
+/*
+ * This file is part of GNOME Break Timer.
+ *
+ * GNOME Break Timer 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.
+ *
+ * GNOME Break Timer 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 GNOME Break Timer. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace BreakTimer.Settings {
+
+public abstract class TimerBreakSettingsPanel : BreakSettingsPanel {
+ protected TimerBreakSettingsPanel (TimerBreakType break_type, string title, string? description) {
+ base (break_type, title, description);
+
+ var details_grid = new Gtk.Grid ();
+ this.set_details (details_grid);
+
+ details_grid.set_column_spacing (8);
+ details_grid.set_row_spacing (8);
+
+ /* Label for the widget to choose how frequently a break occurs. (Choices such as "6 minutes" or "45
minutes") */
+ var interval_label = new Gtk.Label.with_mnemonic ( _("Every"));
+ interval_label.set_halign (Gtk.Align.END);
+ details_grid.attach (interval_label, 0, 1, 1, 1);
+
+ var interval_chooser = new TimeChooser (break_type.interval_options);
+ details_grid.attach_next_to (interval_chooser, interval_label, Gtk.PositionType.RIGHT, 1, 1);
+ break_type.settings.bind ("interval-seconds", interval_chooser, "time-seconds",
SettingsBindFlags.DEFAULT);
+
+ /* Label for the widget to choose how long a break lasts when it occurs. (Choices such as "30
seconds" or "5 minutes") */
+ var duration_label = new Gtk.Label.with_mnemonic ( _("For"));
+ duration_label.set_halign (Gtk.Align.END);
+ details_grid.attach (duration_label, 0, 2, 1, 1);
+
+ var duration_chooser = new TimeChooser (break_type.duration_options);
+ details_grid.attach_next_to (duration_chooser, duration_label, Gtk.PositionType.RIGHT, 1, 1);
+ break_type.settings.bind ("duration-seconds", duration_chooser, "time-seconds",
SettingsBindFlags.DEFAULT);
+
+ details_grid.show_all ();
+ }
+}
+
+}
diff --git a/src/settings/TimerBreakStatusPanel.vala b/src/settings/TimerBreakStatusPanel.vala
new file mode 100644
index 0000000..a8f8b4a
--- /dev/null
+++ b/src/settings/TimerBreakStatusPanel.vala
@@ -0,0 +1,82 @@
+/*
+ * This file is part of GNOME Break Timer.
+ *
+ * GNOME Break Timer 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.
+ *
+ * GNOME Break Timer 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 GNOME Break Timer. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace BreakTimer.Settings {
+
+public abstract class TimerBreakStatusPanel : BreakStatusPanel {
+ private string upcoming_text;
+ private string ongoing_text;
+
+ private CircleCounter circle_counter;
+ private Gtk.Label status_label;
+ private Gtk.Label time_label;
+
+ protected TimerBreakStatusPanel (TimerBreakType break_type, string upcoming_text, string ongoing_text) {
+ base (break_type);
+ this.upcoming_text = upcoming_text;
+ this.ongoing_text = ongoing_text;
+
+ this.set_column_spacing (12);
+
+ // FIXME: This is an application icon. It doesn't make sense here.
+ this.circle_counter = new CircleCounter ();
+ this.attach (this.circle_counter, 0, 0, 1, 1);
+
+ var labels_grid = new Gtk.Grid ();
+ this.attach (labels_grid, 1, 0, 1, 1);
+ labels_grid.set_orientation (Gtk.Orientation.VERTICAL);
+ labels_grid.set_row_spacing (18);
+ labels_grid.set_valign (Gtk.Align.CENTER);
+
+ this.status_label = new Gtk.Label (null);
+ labels_grid.add (this.status_label);
+ this.status_label.set_width_chars (25);
+ this.status_label.get_style_context ().add_class ("_break-status-heading");
+
+ this.time_label = new Gtk.Label (null);
+ labels_grid.add (this.time_label);
+ this.time_label.set_width_chars (25);
+ this.time_label.get_style_context ().add_class ("_break-status-body");
+
+ this.show_all ();
+
+ break_type.timer_status_changed.connect (this.timer_status_changed_cb);
+ }
+
+ private void timer_status_changed_cb (TimerBreakStatus? status) {
+ if (status == null) return;
+
+ TimerBreakType timer_break = (TimerBreakType) this.break_type;
+
+ if (status.is_active) {
+ this.status_label.set_label (this.ongoing_text);
+ string time_text = NaturalTime.instance.get_countdown_for_seconds_with_start (
+ status.time_remaining, status.current_duration);
+ this.time_label.set_label (time_text);
+ this.circle_counter.direction = CircleCounter.Direction.COUNT_DOWN;
+ this.circle_counter.progress = (status.current_duration - status.time_remaining) /
(double)status.current_duration;
+ } else {
+ this.status_label.set_label (this.upcoming_text);
+ string time_text = NaturalTime.instance.get_countdown_for_seconds (status.starts_in);
+ this.time_label.set_label (time_text);
+ this.circle_counter.direction = CircleCounter.Direction.COUNT_UP;
+ this.circle_counter.progress = (timer_break.interval - status.starts_in) /
(double)timer_break.interval;
+ }
+ }
+}
+
+}
diff --git a/src/settings/TimerBreakType.vala b/src/settings/TimerBreakType.vala
index 09881fa..742443d 100644
--- a/src/settings/TimerBreakType.vala
+++ b/src/settings/TimerBreakType.vala
@@ -26,7 +26,7 @@ public abstract class TimerBreakType : BreakType {
public IBreakHelper_TimerBreak? break_server;
- public TimerBreakType (string name, GLib.Settings settings) {
+ protected TimerBreakType (string name, GLib.Settings settings) {
base (name, settings);
settings.bind ("interval-seconds", this, "interval", SettingsBindFlags.GET);
settings.bind ("duration-seconds", this, "duration", SettingsBindFlags.GET);
@@ -65,6 +65,9 @@ public abstract class TimerBreakType : BreakType {
try {
return this.break_server.get_status ();
} catch (IOError error) {
+ GLib.warning ("Error connecting to break helper service: %s", error.message);
+ return null;
+ } catch (GLib.DBusError error) {
GLib.warning ("Error getting break status: %s", error.message);
return null;
}
@@ -101,98 +104,4 @@ public abstract class TimerBreakType : BreakType {
}
}
-public abstract class TimerBreakStatusPanel : BreakStatusPanel {
- private string upcoming_text;
- private string ongoing_text;
-
- private CircleCounter circle_counter;
- private Gtk.Label status_label;
- private Gtk.Label time_label;
-
- public TimerBreakStatusPanel (TimerBreakType break_type, string upcoming_text, string ongoing_text) {
- base (break_type);
- this.upcoming_text = upcoming_text;
- this.ongoing_text = ongoing_text;
-
- this.set_column_spacing (12);
-
- // FIXME: This is an application icon. It doesn't make sense here.
- this.circle_counter = new CircleCounter ();
- this.attach (this.circle_counter, 0, 0, 1, 1);
-
- var labels_grid = new Gtk.Grid ();
- this.attach (labels_grid, 1, 0, 1, 1);
- labels_grid.set_orientation (Gtk.Orientation.VERTICAL);
- labels_grid.set_row_spacing (18);
- labels_grid.set_valign (Gtk.Align.CENTER);
-
- this.status_label = new Gtk.Label (null);
- labels_grid.add (this.status_label);
- this.status_label.set_width_chars (25);
- this.status_label.get_style_context ().add_class ("_break-status-heading");
-
- this.time_label = new Gtk.Label (null);
- labels_grid.add (this.time_label);
- this.time_label.set_width_chars (25);
- this.time_label.get_style_context ().add_class ("_break-status-body");
-
- this.show_all ();
-
- break_type.timer_status_changed.connect (this.timer_status_changed_cb);
- }
-
- private void timer_status_changed_cb (TimerBreakStatus? status) {
- if (status == null) return;
-
- TimerBreakType timer_break = (TimerBreakType) this.break_type;
-
- if (status.is_active) {
- this.status_label.set_label (this.ongoing_text);
- string time_text = NaturalTime.instance.get_countdown_for_seconds_with_start (
- status.time_remaining, status.current_duration);
- this.time_label.set_label (time_text);
- this.circle_counter.direction = CircleCounter.Direction.COUNT_DOWN;
- this.circle_counter.progress = (status.current_duration - status.time_remaining) /
(double)status.current_duration;
- } else {
- this.status_label.set_label (this.upcoming_text);
- string time_text = NaturalTime.instance.get_countdown_for_seconds (status.starts_in);
- this.time_label.set_label (time_text);
- this.circle_counter.direction = CircleCounter.Direction.COUNT_UP;
- this.circle_counter.progress = (timer_break.interval - status.starts_in) /
(double)timer_break.interval;
- }
- }
-}
-
-public abstract class TimerBreakSettingsPanel : BreakSettingsPanel {
- public TimerBreakSettingsPanel (TimerBreakType break_type, string title, string? description) {
- base (break_type, title, description);
-
- var details_grid = new Gtk.Grid ();
- this.set_details (details_grid);
-
- details_grid.set_column_spacing (8);
- details_grid.set_row_spacing (8);
-
- /* Label for the widget to choose how frequently a break occurs. (Choices such as "6 minutes" or "45
minutes") */
- var interval_label = new Gtk.Label.with_mnemonic ( _("Every"));
- interval_label.set_halign (Gtk.Align.END);
- details_grid.attach (interval_label, 0, 1, 1, 1);
-
- var interval_chooser = new TimeChooser (break_type.interval_options);
- details_grid.attach_next_to (interval_chooser, interval_label, Gtk.PositionType.RIGHT, 1, 1);
- break_type.settings.bind ("interval-seconds", interval_chooser, "time-seconds",
SettingsBindFlags.DEFAULT);
-
- /* Label for the widget to choose how long a break lasts when it occurs. (Choices such as "30
seconds" or "5 minutes") */
- var duration_label = new Gtk.Label.with_mnemonic ( _("For"));
- duration_label.set_halign (Gtk.Align.END);
- details_grid.attach (duration_label, 0, 2, 1, 1);
-
- var duration_chooser = new TimeChooser (break_type.duration_options);
- details_grid.attach_next_to (duration_chooser, duration_label, Gtk.PositionType.RIGHT, 1, 1);
- break_type.settings.bind ("duration-seconds", duration_chooser, "time-seconds",
SettingsBindFlags.DEFAULT);
-
- details_grid.show_all ();
- }
-}
-
}
diff --git a/src/settings/meson.build b/src/settings/meson.build
index 1251ea4..8d0ab32 100644
--- a/src/settings/meson.build
+++ b/src/settings/meson.build
@@ -2,50 +2,28 @@
# $(top_srcdir)/settings/resources.c: $(top_srcdir)/data/gnome-break-timer.gresource.xml $(shell
$(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir=$(top_srcdir)/data/
$(top_srcdir)/data/gnome-break-timer.gresource.xml)
# $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(top_srcdir)/data/ --generate-source $<
-settings_sources = [
+settings_sources = files(
+ 'BreakInfoPanel.vala',
'BreakManager.vala',
'BreakSettingsDialog.vala',
+ 'BreakSettingsPanel.vala',
+ 'BreakStatusPanel.vala',
'BreakType.vala',
'CircleCounter.vala',
+ 'main.vala',
'MainWindow.vala',
+ 'MicroBreakInfoPanel.vala',
+ 'MicroBreakSettingsPanel.vala',
+ 'MicroBreakStatusPanel.vala',
'MicroBreakType.vala',
'OverlayArrow.vala',
+ 'RestBreakInfoPanel.vala',
+ 'RestBreakSettingsPanel.vala',
+ 'RestBreakStatusPanel.vala',
'RestBreakType.vala',
'SettingsApplication.vala',
'TimeChooser.vala',
+ 'TimerBreakSettingsPanel.vala',
+ 'TimerBreakStatusPanel.vala',
'TimerBreakType.vala'
-]
-
-settings_dependencies = [
- common_lib_dep,
- cairo_dep,
- gtk_dep,
- gio_dep,
- gio_unix_dep,
- gee_dep
-]
-
-settings_lib = static_library(
- 'settings',
- sources: settings_sources,
- dependencies: settings_dependencies
-)
-
-settings_lib_dep = declare_dependency(
- link_with: settings_lib,
- dependencies: settings_dependencies,
- include_directories: include_directories('.')
)
-
-settings_main_sources = [
- 'main.vala',
- break_timer_resources
-]
-
-executable(
- 'gnome-break-timer-settings',
- sources : settings_main_sources,
- dependencies : settings_lib_dep,
- install: true,
- install_dir: bindir
-)
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]