[simple-scan/gnome-3-34] Don't exclude INACTIVE descriptor from list of options



commit e8efb7b750ed9eee10135f132dc5ad072eae6292
Author: Bartosz Kosiorek <gang65 poczta onet pl>
Date:   Tue Dec 3 15:17:22 2019 +0100

    Don't exclude INACTIVE descriptor from list of options
    
    The Sane.Capability.INACTIVE capability indicates that
    the option is not currently active (e.g., because it's meaningful
    only if another option is set to some other value).
    
    With some proprietary backends (example: esci, Epson WF-7710),
    the 'duplex' option is INACTIVE at the start.
    To activate it, the 'source' option need to be set to 'ADF' value.
    
    With this patch, check if option is INACTIVE is made only during
    value set, and not during creation of list of available options.
    
    Fixes: #106

 src/scanner.vala | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/src/scanner.vala b/src/scanner.vala
index f9f3ef8..abe0668 100644
--- a/src/scanner.vala
+++ b/src/scanner.vala
@@ -1170,10 +1170,6 @@ public class Scanner : Object
         if (option.type == Sane.ValueType.GROUP)
             return;
 
-        /* Option disabled */
-        if ((option.cap & Sane.Capability.INACTIVE) != 0)
-            return;
-
         /* Some options are unnamed (e.g. Option 0) */
         if (option.name == null)
             return;
@@ -1200,7 +1196,18 @@ public class Scanner : Object
         if (index == 0)
             return null;
 
-        return Sane.get_option_descriptor (handle, index);
+        var option_descriptor = Sane.get_option_descriptor (handle, index);
+        /*
+        The Sane.Capability.INACTIVE capability indicates that
+        the option is not currently active (e.g., because it's meaningful
+        only if another option is set to some other value).
+        */
+        if ((option_descriptor.cap & Sane.Capability.INACTIVE) != 0)
+        {
+            warning ("The option %s (%d) is inactive and can't be set, please file a bug", name, index);
+            return null;
+        }
+        return option_descriptor;
     }
 
     private void do_complete_document ()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]