sane.ds: Add support for word list options.

Vincent Povirk vincent at codeweavers.com
Mon Sep 11 13:47:55 CDT 2017


Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
---
 dlls/sane.ds/ui.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/dlls/sane.ds/ui.c b/dlls/sane.ds/ui.c
index 5574c5a..80aa9ce 100644
--- a/dlls/sane.ds/ui.c
+++ b/dlls/sane.ds/ui.c
@@ -716,6 +716,23 @@ static BOOL UpdateSaneBoolOption(int index, BOOL position)
     return FALSE;
 }
 
+static BOOL UpdateSaneIntOption(int index, SANE_Int value)
+{
+    SANE_Status rc = SANE_STATUS_GOOD;  
+    SANE_Int result = 0;
+
+    rc = psane_control_option (activeDS.deviceHandle,index,
+            SANE_ACTION_SET_VALUE, &value, &result);
+
+    if(rc == SANE_STATUS_GOOD)
+    {
+        if (result & SANE_INFO_RELOAD_OPTIONS || 
+                result & SANE_INFO_RELOAD_PARAMS || result & SANE_INFO_INEXACT) 
+            return TRUE;
+    }
+    return FALSE;
+}
+
 static BOOL UpdateSaneStringOption(int index, SANE_String value)
 {
     SANE_Status rc = SANE_STATUS_GOOD;  
@@ -791,6 +808,21 @@ static INT_PTR InitializeDialog(HWND hwnd)
                 SendMessageA(control,BM_SETCHECK,BST_CHECKED,0);
 
         }
+        else if (opt->type == SANE_TYPE_INT &&
+                 opt->constraint_type == SANE_CONSTRAINT_WORD_LIST)
+        {
+            int j, count = opt->constraint.word_list[0];
+            CHAR buffer[16];
+            SANE_Int val;
+            for (j=1; j<=count; j++)
+            {
+                sprintf(buffer, "%d", opt->constraint.word_list[j]);
+                SendMessageA(control, CB_ADDSTRING, 0, (LPARAM)buffer);
+            }
+            psane_control_option(activeDS.deviceHandle, i, SANE_ACTION_GET_VALUE, &val, NULL);
+            sprintf(buffer, "%d", val);
+            SendMessageA(control,CB_SELECTSTRING,0,(LPARAM)buffer);
+        }
         else if (opt->constraint_type == SANE_CONSTRAINT_RANGE)
         {
             if (opt->type == SANE_TYPE_INT)
@@ -977,6 +1009,11 @@ static void ComboChanged(HWND hwnd, INT id, HWND control)
         if (UpdateSaneStringOption(index, value))
                 InitializeDialog(hwnd);
     }
+    else if (opt->type == SANE_TYPE_INT)
+    {
+        if (UpdateSaneIntOption(index, atoi(value)))
+            InitializeDialog(hwnd);
+    }
 }
 
 
-- 
2.7.4




More information about the wine-patches mailing list