camera: add a back button if not found

fixes #235
This commit is contained in:
Bilal Elmoussaoui 2021-02-01 20:32:23 +01:00
parent 5d29e2628a
commit 92f0db5385
4 changed files with 45 additions and 24 deletions

View file

@ -39,7 +39,7 @@
<child type="start">
<object class="GtkButton" id="back_btn">
<property name="receives-default">True</property>
<property name="action-name">add.back</property>
<property name="action-name">add.previous</property>
<property name="icon-name">go-previous-symbolic</property>
<property name="tooltip-text" translatable="yes">Go Back</property>
</object>
@ -253,11 +253,11 @@
</child>
<child>
<object class='GtkShortcutController'>
<property name='scope'>global</property>
<property name='scope'>local</property>
<child>
<object class='GtkShortcut'>
<property name='trigger'>Escape</property>
<property name='action'>action(window.close)</property>
<property name='action'>action(add.previous)</property>
</object>
</child>
</object>

View file

@ -23,24 +23,41 @@
<object class="GtkStackPage">
<property name="name">not-found</property>
<property name="child">
<object class="AdwStatusPage">
<property name="vexpand">True</property>
<property name="icon-name">camera-hardware-disabled-symbolic</property>
<property name="title" translatable="yes">No Camera Found</property>
<property name="child">
<object class="GtkButton">
<property name="label" translatable="yes">_From a Screenshot</property>
<property name="action-name">add.screenshot</property>
<property name="halign">center</property>
<property name="margin-top">24</property>
<property name="use-underline">True</property>
<style>
<class name="large-button" />
<class name="pill-button" />
<class name="suggested-action" />
</style>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkHeaderBar">
<child type="start">
<object class="GtkButton">
<property name="receives-default">True</property>
<property name="action-name">add.previous</property>
<property name="icon-name">go-previous-symbolic</property>
<property name="tooltip-text" translatable="yes">Go Back</property>
</object>
</child>
</object>
</property>
</child>
<child>
<object class="AdwStatusPage">
<property name="vexpand">True</property>
<property name="icon-name">camera-hardware-disabled-symbolic</property>
<property name="title" translatable="yes">No Camera Found</property>
<property name="child">
<object class="GtkButton">
<property name="label" translatable="yes">_From a Screenshot</property>
<property name="action-name">add.screenshot</property>
<property name="halign">center</property>
<property name="margin-top">24</property>
<property name="use-underline">True</property>
<style>
<class name="large-button" />
<class name="pill-button" />
<class name="suggested-action" />
</style>
</object>
</property>
</object>
</child>
</object>
</property>
</object>

View file

@ -262,11 +262,17 @@ impl AccountAddDialog {
let self_ = imp::AccountAddDialog::from_instance(self);
action!(
self_.actions,
"back",
"previous",
clone!(@weak self as dialog => move |_, _| {
dialog.close();
let self_ = imp::AccountAddDialog::from_instance(&dialog);
if self_.deck.get_visible_child_name().unwrap() == "camera" {
self_.deck.set_visible_child_name("main");
} else {
dialog.close();
}
})
);
action!(
self_.actions,
"save",

View file

@ -95,7 +95,6 @@ mod imp {
#[derive(Debug, CompositeTemplate)]
#[template(resource = "/com/belmoussaoui/Authenticator/camera.ui")]
pub struct Camera {
pub actions: gio::SimpleActionGroup,
pub sender: Sender<CameraEvent>,
pub receiver: RefCell<Option<Receiver<CameraEvent>>>,
pub pipeline: gst::Pipeline,
@ -137,7 +136,6 @@ mod imp {
let receiver = RefCell::new(Some(r));
Self {
actions: gio::SimpleActionGroup::new(),
sink,
sender,
receiver,