]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change enable options cropping image
authorBastian Dehn <hhaalo@arcor.de>
Tue, 18 Feb 2025 18:22:49 +0000 (19:22 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 18 Feb 2025 18:22:49 +0000 (19:22 +0100)
src/kds_s2000w_handler_opts.c

index 55970779791079c67a1d694a7b3ad378fa10d574..015a58ee66c06c5e58f96ef87ede8f84224a9c7e 100644 (file)
@@ -104,16 +104,43 @@ void _kds_s2000w_handler_opts_set_enable_cropping_image(json_object* config)
        json_object* copping_image = json_object_object_get(config, "CroppingImage");
        SANE_Option_Descriptor* cropping_image = kds_s2000w_option_descriptors_get_by_name("cropping-image");
 
-       cropping_image->cap |= SANE_CAP_SOFT_SELECT;
        if (strcmp(cropping_mode_value, "Automatic") == 0) {
                _kds_s2000w_handler_opts_write_string_value_to_json(copping_image, "EntireDocument");
                cropping_image->cap &= ~SANE_CAP_SOFT_SELECT;
+               return;
        }
 
        if (strcmp(cropping_mode_value, "Manual") == 0) {
                _kds_s2000w_handler_opts_write_string_value_to_json(copping_image, "PartialDocument");
                cropping_image->cap &= ~SANE_CAP_SOFT_SELECT;
+               return;
+       }
+
+       cropping_image->cap |= SANE_CAP_SOFT_SELECT;
+}
+
+void _kds_s2000w_handler_opts_set_enable_suboptions_cropping_image(json_object* config)
+{
+       json_object* cropping_image = json_object_object_get(config, "CroppingImage");;
+       const char* cropping_image_value = json_object_get_string(cropping_image);
+
+       SANE_Option_Descriptor* image_offset_x = kds_s2000w_option_descriptors_get_by_name("image-offset-x");
+       SANE_Option_Descriptor* image_offset_y = kds_s2000w_option_descriptors_get_by_name("image-offset-y");
+       SANE_Option_Descriptor* image_width = kds_s2000w_option_descriptors_get_by_name("image-width");
+       SANE_Option_Descriptor* image_height = kds_s2000w_option_descriptors_get_by_name("image-height");
+
+       if (strcmp(cropping_image_value, "PartialDocument") == 0) {
+               image_offset_x->cap |= SANE_CAP_SOFT_SELECT;
+               image_offset_y->cap |= SANE_CAP_SOFT_SELECT;
+               image_width->cap |= SANE_CAP_SOFT_SELECT;
+               image_height->cap |= SANE_CAP_SOFT_SELECT;
+               return;
        }
+
+       image_offset_x->cap &= ~SANE_CAP_SOFT_SELECT;
+       image_offset_y->cap &= ~SANE_CAP_SOFT_SELECT;
+       image_width->cap &= ~SANE_CAP_SOFT_SELECT;
+       image_height->cap &= ~SANE_CAP_SOFT_SELECT;
 }
 
 void kds_s2000w_handler_opts_get_option(handler* h, uint32_t option, void* value, int32_t* info)
@@ -354,6 +381,7 @@ void kds_s2000w_handler_opts_set_option(handler* h, uint32_t option, void* value
                        value_object = json_object_object_get(config, "CroppingMode");
                        _kds_s2000w_handler_opts_write_string_value_to_json(value_object, value);
                        _kds_s2000w_handler_opts_set_enable_cropping_image(config);
+                       _kds_s2000w_handler_opts_set_enable_suboptions_cropping_image(config);
 
                        if (info != NULL)
                                *info = RELOAD_OPTIONS;
@@ -361,6 +389,10 @@ void kds_s2000w_handler_opts_set_option(handler* h, uint32_t option, void* value
                case 8:
                        value_object = json_object_object_get(config, "CroppingImage");
                        _kds_s2000w_handler_opts_write_string_value_to_json(value_object, value);
+                       _kds_s2000w_handler_opts_set_enable_suboptions_cropping_image(config);
+
+                       if (info != NULL)
+                               *info = RELOAD_OPTIONS;
                        break;
                case 9:
                        value_object = json_object_object_get(config, "ImageOffsetX");