summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/ardour_ui.cc6
-rw-r--r--gtk2_ardour/ardour_ui.h10
-rw-r--r--gtk2_ardour/ardour_ui2.cc8
-rw-r--r--gtk2_ardour/ardour_ui_options.cc2
-rw-r--r--gtk2_ardour/disk_space_indicator.cc99
-rw-r--r--gtk2_ardour/disk_space_indicator.h43
-rw-r--r--gtk2_ardour/rc_option_editor.cc8
-rw-r--r--gtk2_ardour/ui_config_vars.h1
-rw-r--r--gtk2_ardour/wscript1
9 files changed, 174 insertions, 4 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index 979ab3504a..3c61b74eef 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -1771,6 +1771,7 @@ void
ARDOUR_UI::update_disk_space()
{
if (_session == 0) {
+ disk_space_indicator.set_available_disk_sec (-1);
return;
}
@@ -1780,14 +1781,17 @@ ARDOUR_UI::update_disk_space()
if (fr == 0) {
/* skip update - no SR available */
+ disk_space_indicator.set_available_disk_sec (-1);
return;
}
if (!opt_samples) {
/* Available space is unknown */
snprintf (buf, sizeof (buf), "%s", _("Disk: <span foreground=\"green\">Unknown</span>"));
+ disk_space_indicator.set_available_disk_sec (-1);
} else if (opt_samples.get_value_or (0) == max_samplecnt) {
snprintf (buf, sizeof (buf), "%s", _("Disk: <span foreground=\"green\">24hrs+</span>"));
+ disk_space_indicator.set_available_disk_sec (max_samplecnt);
} else {
rec_enabled_streams = 0;
_session->foreach_route (this, &ARDOUR_UI::count_recenabled_streams, false);
@@ -1802,6 +1806,8 @@ ARDOUR_UI::update_disk_space()
int mins;
int secs;
+ disk_space_indicator.set_available_disk_sec (samples / (float)fr);
+
hrs = samples / (fr * 3600);
if (hrs > 24) {
diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h
index a703ac7c33..c6984d75c4 100644
--- a/gtk2_ardour/ardour_ui.h
+++ b/gtk2_ardour/ardour_ui.h
@@ -75,6 +75,7 @@
#include "ardour_dialog.h"
#include "ardour_window.h"
#include "dsp_load_indicator.h"
+#include "disk_space_indicator.h"
#include "editing.h"
#include "enums.h"
#include "mini_timeline.h"
@@ -484,10 +485,11 @@ private:
void toggle_time_master ();
void toggle_video_sync ();
- ShuttleControl shuttle_box;
- MiniTimeline mini_timeline;
- TimeInfoBox* time_info_box;
- DspLoadIndicator dsp_load_indicator;
+ ShuttleControl shuttle_box;
+ MiniTimeline mini_timeline;
+ TimeInfoBox* time_info_box;
+ DspLoadIndicator dsp_load_indicator;
+ DiskSpaceIndicator disk_space_indicator;
ArdourWidgets::ArdourButton auto_return_button;
ArdourWidgets::ArdourButton follow_edits_button;
diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc
index ebd6261fec..ef0c8fffcd 100644
--- a/gtk2_ardour/ardour_ui2.cc
+++ b/gtk2_ardour/ardour_ui2.cc
@@ -198,6 +198,14 @@ ARDOUR_UI::repack_transport_hbox ()
dsp_load_indicator.show();
}
+ if (disk_space_indicator.get_parent()) {
+ transport_hbox.remove (disk_space_indicator);
+ }
+ if (UIConfiguration::instance().get_show_disk_space_info ()) {
+ transport_hbox.pack_start (disk_space_indicator, false, false);
+ disk_space_indicator.show();
+ }
+
if (editor_meter) {
if (meter_box.get_parent()) {
transport_hbox.remove (meter_box);
diff --git a/gtk2_ardour/ardour_ui_options.cc b/gtk2_ardour/ardour_ui_options.cc
index b9e9d8d3f3..21a1449f30 100644
--- a/gtk2_ardour/ardour_ui_options.cc
+++ b/gtk2_ardour/ardour_ui_options.cc
@@ -472,6 +472,8 @@ ARDOUR_UI::parameter_changed (std::string p)
repack_transport_hbox ();
} else if (p == "show-dsp-load-info") {
repack_transport_hbox ();
+ } else if (p == "show-disk-space-info") {
+ repack_transport_hbox ();
} else if (p == "show-toolbar-recpunch") {
repack_transport_hbox ();
} else if (p == "show-toolbar-monitoring") {
diff --git a/gtk2_ardour/disk_space_indicator.cc b/gtk2_ardour/disk_space_indicator.cc
new file mode 100644
index 0000000000..2bc31babce
--- /dev/null
+++ b/gtk2_ardour/disk_space_indicator.cc
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
+ *
+ * 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.
+ */
+
+#include "ardour_ui.h"
+#include "dsp_load_indicator.h"
+
+#include "pbd/i18n.h"
+
+#define PADDING 3
+
+DiskSpaceIndicator::DiskSpaceIndicator ()
+ : ArdourGauge (">24h")
+ , _sec (-1)
+{
+}
+
+void
+DiskSpaceIndicator::set_available_disk_sec (float sec)
+{
+ if (_sec == sec) {
+ return;
+ }
+ _sec = sec;
+
+ if (sec < 0) {
+ update (_("N/A"));
+ return;
+ }
+
+ char buf[64];
+ if (_sec > 86400) {
+ update (_(">24h"));
+ return;
+ } else if (_sec > 32400 /* 9 hours */) {
+ snprintf (buf, sizeof (buf), "%.0fh", _sec / 3600.f);
+ } else if (_sec > 5940 /* 99 mins */) {
+ snprintf (buf, sizeof (buf), "%.1fh", _sec / 3600.f);
+ } else {
+ snprintf (buf, sizeof (buf), "%.0fm", _sec / 60.f);
+ }
+ update (std::string (buf));
+}
+
+float
+DiskSpaceIndicator::level () const {
+ static const float lm = 6.f * 3600.f;
+ if (_sec < 0) return 0;
+ if (_sec > lm) return 1.0;
+ return _sec / lm;
+}
+
+bool
+DiskSpaceIndicator::alert () const
+{
+ return _sec >=0 && _sec < 60.f * 10.f;
+}
+
+ArdourGauge::Status
+DiskSpaceIndicator::indicator () const
+{
+ if (_sec > 3600.f) {
+ return ArdourGauge::Level_OK;
+ } else if (_sec > 1800.f) {
+ return ArdourGauge::Level_WARN;
+ }
+ return ArdourGauge::Level_CRIT;
+}
+
+std::string
+DiskSpaceIndicator::tooltip_text ()
+{
+ if (_sec < 0) {
+ return _("Unkown");
+ }
+
+ int sec = floor (_sec);
+ char buf[64];
+ int hrs = sec / 3600;
+ int mins = (sec / 60) % 60;
+ int secs = sec % 60;
+
+ snprintf (buf, sizeof(buf), _("%02dh:%02dm:%02ds"), hrs, mins, secs);
+ return _("Available capture disk-space: ") + std::string (buf);
+}
diff --git a/gtk2_ardour/disk_space_indicator.h b/gtk2_ardour/disk_space_indicator.h
new file mode 100644
index 0000000000..e4a46f9c83
--- /dev/null
+++ b/gtk2_ardour/disk_space_indicator.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
+ *
+ * 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.
+ */
+
+#ifndef __gtkardour_disk_space_indicator_h__
+#define __gtkardour_disk_space_indicator_h__
+
+#include <pangomm.h>
+
+#include "ardour_gauge.h"
+
+class DiskSpaceIndicator : public ArdourGauge
+{
+public:
+ DiskSpaceIndicator ();
+
+ void set_available_disk_sec (float);
+
+protected:
+ bool alert () const;
+ ArdourGauge::Status indicator () const;
+ float level () const;
+ std::string tooltip_text ();
+
+private:
+ float _sec;
+};
+
+#endif
diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc
index 84d0628183..bef5780fad 100644
--- a/gtk2_ardour/rc_option_editor.cc
+++ b/gtk2_ardour/rc_option_editor.cc
@@ -3806,6 +3806,14 @@ RCOptionEditor::RCOptionEditor ()
add_option (_("Appearance/Toolbar"),
new BoolOption (
+ "show-disk-space-info",
+ _("Display Disk Space Information"),
+ sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::get_show_disk_space_info),
+ sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::set_show_disk_space_info)
+ ));
+
+ add_option (_("Appearance/Toolbar"),
+ new BoolOption (
"show-mini-timeline",
_("Display Navigation Timeline"),
sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::get_show_mini_timeline),
diff --git a/gtk2_ardour/ui_config_vars.h b/gtk2_ardour/ui_config_vars.h
index 315cb02b26..50960d70bf 100644
--- a/gtk2_ardour/ui_config_vars.h
+++ b/gtk2_ardour/ui_config_vars.h
@@ -83,6 +83,7 @@ UI_CONFIG_VARIABLE (bool, show_toolbar_monitoring, "show-toolbar-monitoring", fa
UI_CONFIG_VARIABLE (bool, show_toolbar_selclock, "show-toolbar-selclock", false)
UI_CONFIG_VARIABLE (bool, show_mini_timeline, "show-mini-timeline", true)
UI_CONFIG_VARIABLE (bool, show_dsp_load_info, "show-dsp-load-info", true)
+UI_CONFIG_VARIABLE (bool, show_disk_space_info, "show-disk-space-info", true)
UI_CONFIG_VARIABLE (bool, show_secondary_clock, "show-secondary-clock", true)
UI_CONFIG_VARIABLE (double, waveform_clip_level, "waveform-clip-level", -0.0933967) /* units of dB */
UI_CONFIG_VARIABLE (bool, hiding_groups_deactivates_groups, "hiding-groups-deactivates-groups", true)
diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript
index 7e08f20585..411744fab9 100644
--- a/gtk2_ardour/wscript
+++ b/gtk2_ardour/wscript
@@ -65,6 +65,7 @@ gtk2_ardour_sources = [
'cursor_context.cc',
'curvetest.cc',
'debug.cc',
+ 'disk_space_indicator.cc',
'duplicate_routes_dialog.cc',
'dsp_load_indicator.cc',
'edit_note_dialog.cc',