[simple-scan/cherry-pick-a7b102f1] Additionally add the device name to the label if there are several identical models
- From: Bartosz <bkosiorek src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [simple-scan/cherry-pick-a7b102f1] Additionally add the device name to the label if there are several identical models
- Date: Wed, 1 Dec 2021 10:39:17 +0000 (UTC)
commit 340023cc5e04239361da90c1322143a94d4b2af6
Author: c0d3d3v <c0d3d3v mag-keinen-spam de>
Date: Wed Nov 24 14:06:16 2021 +0100
Additionally add the device name to the label if there are several identical models
(cherry picked from commit a7b102f11e2ade20b0e1ebabe8007916b654211d)
src/scanner.vala | 14 ++++++++++++++
1 file changed, 14 insertions(+)
---
diff --git a/src/scanner.vala b/src/scanner.vala
index d968aecb..bf72bb3a 100644
--- a/src/scanner.vala
+++ b/src/scanner.vala
@@ -354,6 +354,16 @@ public class Scanner : Object
return;
}
+ /* Determine the number of each model to additionally display the name if the model names are the
same. */
+ var seen = new HashTable<string, int> (str_hash, str_equal);
+ for (var i = 0; device_list[i] != null; i++)
+ {
+ if (seen.contains(device_list[i].model))
+ seen.set(device_list[i].model, seen.get(device_list[i].model) + 1);
+ else
+ seen.set(device_list[i].model, 1);
+ }
+
var devices = new List<ScanDevice> ();
for (var i = 0; device_list[i] != null; i++)
{
@@ -373,6 +383,10 @@ public class Scanner : Object
scan_device.label = device_list[i].model;
else
scan_device.label = "%s %s".printf (vendor, device_list[i].model);
+
+ /* Additionally add the device name to the label if there are several identical models. */
+ if (seen.get(device_list[i].model) > 1)
+ scan_device.label = "%s on %s".printf (scan_device.label, device_list[i].name);
/* Replace underscores in name */
scan_device.label.replace ("_", " ");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]