[simple-scan/gnome-3-38] Add redetect button next to device list
- From: Bartosz <bkosiorek src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [simple-scan/gnome-3-38] Add redetect button next to device list
- Date: Mon, 23 Nov 2020 15:46:03 +0000 (UTC)
commit 07138a0cc12f4e3ce753b5185d21c8497db8bad6
Author: Iskren Chernev <me iskren info>
Date: Sun Oct 25 16:31:45 2020 +0000
Add redetect button next to device list
Refreshing the devices every time a scan is done is time consuming and
might lead to subtle bugs with faulty backends. Also it is not very
common to change scanner right after a successful scan.
Replace auto-redetect on new document with a refresh button next to the
device list.
(cherry picked from commit 73e41d59730bb8a98e3e2431b9529e6596d19c87)
src/app-window.ui | 41 ++++++++++++++++++++++++++++++++++++++---
src/app-window.vala | 21 ++++++++++++++-------
2 files changed, 52 insertions(+), 10 deletions(-)
---
diff --git a/src/app-window.ui b/src/app-window.ui
index 6f42a516..0f7ba27d 100644
--- a/src/app-window.ui
+++ b/src/app-window.ui
@@ -794,10 +794,45 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="device_combo">
+ <object class="GtkBox" id="device_combo_box">
<property name="visible">False</property>
- <property name="model">device_model</property>
- <signal name="changed" handler="device_combo_changed_cb" swapped="no"/>
+ <property name="can_focus">False</property>
+ <property name="orientation">horizontal</property>
+ <property name="spacing">10</property>
+ <child>
+ <object class="GtkComboBox" id="device_combo">
+ <property name="visible">True</property>
+ <property name="model">device_model</property>
+ <signal name="changed" handler="device_combo_changed_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="refresh_devices">
+ <property name="height_request">40</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes" comments="Tooltip for stop
button">Refresh device list</property>
+ <signal name="clicked" handler="redetect_button_clicked_cb" swapped="no"/>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">view-refresh-symbolic</property>
+ <property name="icon_size">1</property>
+ </object>
+ </child>
+ <style>
+ <class name="image-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="fill">False</property>
+ </packing>
+ </child>
</object>
</child>
</object>
diff --git a/src/app-window.vala b/src/app-window.vala
index 67f10a8b..6d025b5b 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -58,6 +58,8 @@ public class AppWindow : Gtk.ApplicationWindow
[GtkChild]
private Gtk.ListStore device_model;
[GtkChild]
+ private Gtk.Box device_combo_box;
+ [GtkChild]
private Gtk.ComboBox device_combo;
[GtkChild]
private Gtk.Label status_secondary_label;
@@ -252,7 +254,7 @@ public class AppWindow : Gtk.ApplicationWindow
status_primary_label.set_text (/* Label shown when searching for scanners */
_("Searching for Scanners…"));
status_secondary_label.visible = false;
- device_combo.visible = false;
+ device_combo_box.visible = false;
}
else if (get_selected_device () != null)
{
@@ -261,7 +263,7 @@ public class AppWindow : Gtk.ApplicationWindow
_("Ready to Scan"));
status_secondary_label.set_text (get_selected_device_label ());
status_secondary_label.visible = false;
- device_combo.visible = true;
+ device_combo_box.visible = true;
device_combo.sensitive = true;
}
else if (this.missing_driver != null)
@@ -271,7 +273,7 @@ public class AppWindow : Gtk.ApplicationWindow
/* Instructions to install driver software */
status_secondary_label.set_markup (_("You need to <a href=\"install-firmware\">install driver
software</a> for your scanner."));
status_secondary_label.visible = true;
- device_combo.visible = false;
+ device_combo_box.visible = false;
}
else
{
@@ -280,7 +282,7 @@ public class AppWindow : Gtk.ApplicationWindow
/* Hint to user on why there are no scanners detected */
status_secondary_label.set_text (_("Please check your scanner is connected and powered on"));
status_secondary_label.visible = true;
- device_combo.visible = false;
+ device_combo_box.visible = false;
}
}
@@ -796,9 +798,6 @@ public class AppWindow : Gtk.ApplicationWindow
if (scanning)
stop_scan ();
- have_devices = false;
- /* Refresh list of devices to detect network scanners, and fix issues with disconnected scanners
*/
- redetect ();
clear_document ();
});
}
@@ -820,6 +819,14 @@ public class AppWindow : Gtk.ApplicationWindow
new_document ();
}
+ [GtkCallback]
+ private void redetect_button_clicked_cb (Gtk.Button button)
+ {
+ have_devices = false;
+ update_scan_status ();
+ redetect ();
+ }
+
private void scan (ScanOptions options)
{
status_primary_label.set_text (/* Label shown when scan started */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]