diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 83424385e..d639c2941 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -71,9 +71,39 @@ public class Camera.MainWindow : Hdy.ApplicationWindow { camera_view = new Widgets.CameraView (); camera_view.bind_property ("horizontal-flip", header_bar, "horizontal-flip", GLib.BindingFlags.BIDIRECTIONAL | GLib.BindingFlags.SYNC_CREATE); + var overlay = new Gtk.Overlay (); + overlay.add (camera_view); + + var recording_finished_toast = new Granite.Widgets.Toast (_("Saved to Videos")); + recording_finished_toast.set_default_action (_("View File")); + recording_finished_toast.set_data ("location", ""); + recording_finished_toast.default_action.connect (() => { + var file_path = recording_finished_toast.get_data ("location"); + var file = GLib.File.new_for_path (file_path); + try { + AppInfo.launch_default_for_uri (file.get_parent ().get_uri (), new Gdk.AppLaunchContext ()); + } catch (Error e) { + warning ("Error launching file manager: %s", e.message); + } + }); + overlay.add_overlay (recording_finished_toast); + + var recording_finished_fail_toast = new Granite.Widgets.Toast (_("Recording failed")); + overlay.add_overlay (recording_finished_fail_toast); + + camera_view.recording_finished.connect ((file_path) => { + if (file_path == "") { + recording_finished_fail_toast.send_notification (); + } else { + recording_finished_toast.set_data ("location", file_path); + recording_finished_toast.send_notification (); + } + }); + + var grid = new Gtk.Grid (); grid.attach (header_bar, 0, 0); - grid.attach (camera_view, 0, 1); + grid.attach (overlay, 0, 1); var window_handle = new Hdy.WindowHandle (); window_handle.add (grid); diff --git a/src/Widgets/CameraView.vala b/src/Widgets/CameraView.vala index fa1d18149..c977bdd6c 100644 --- a/src/Widgets/CameraView.vala +++ b/src/Widgets/CameraView.vala @@ -21,6 +21,8 @@ */ public class Camera.Widgets.CameraView : Gtk.Stack { + public signal void recording_finished (string file_path); + private Gtk.Grid status_grid; private Granite.Widgets.AlertView no_device_view; private Gtk.Label status_label; @@ -367,7 +369,7 @@ public class Camera.Widgets.CameraView : Gtk.Stack { missing_messages += Gst.PbUtils.missing_element_installer_detail_new ("vorbisenc"); } - var filesink = Gst.ElementFactory.make ("filesink", null); + var filesink = Gst.ElementFactory.make ("filesink", "filesink"); if (filesink == null) { missing_messages += Gst.PbUtils.missing_element_installer_detail_new ("filesink"); } else { @@ -404,6 +406,15 @@ public class Camera.Widgets.CameraView : Gtk.Stack { pipeline.set_state (Gst.State.PAUSED); tee.unlink (record_bin); + var filesink = record_bin.get_by_name ("filesink"); + + if (filesink != null) { + var locationval = GLib.Value (typeof (string)); + filesink.get_property ("location", ref locationval); + string location = locationval.get_string (); + recording_finished (location); + } + pipeline.remove (record_bin); pipeline.set_state (Gst.State.PLAYING); record_bin.set_state (Gst.State.NULL);