+void SamplingBar::update_sample_count_selector()
+{
+ GVariant *gvar;
+
+ if (_updating_sample_count)
+ return;
+
+ const shared_ptr<DevInst> dev_inst = get_selected_device();
+ if (!dev_inst)
+ return;
+
+ assert(!_updating_sample_count);
+ _updating_sample_count = true;
+
+ if (_sample_count_supported)
+ {
+ uint64_t sample_count = DefaultSampleCount;
+ uint64_t min_sample_count = 0;
+ uint64_t max_sample_count = MaxSampleCount;
+
+ if ((gvar = dev_inst->list_config(NULL, SR_CONF_LIMIT_SAMPLES)))
+ {
+ g_variant_get(gvar, "(tt)",
+ &min_sample_count, &max_sample_count);
+ g_variant_unref(gvar);
+ }
+
+ min_sample_count = min(max(min_sample_count, MinSampleCount),
+ max_sample_count);
+
+ _sample_count.show_125_list(
+ min_sample_count, max_sample_count);
+
+ if ((gvar = dev_inst->get_config(NULL, SR_CONF_LIMIT_SAMPLES)))
+ {
+ sample_count = g_variant_get_uint64(gvar);
+ if (sample_count == 0)
+ sample_count = DefaultSampleCount;
+ sample_count = min(max(sample_count, MinSampleCount),
+ max_sample_count);
+
+ g_variant_unref(gvar);
+ }
+
+ _sample_count.set_value(sample_count);
+ }
+ else
+ _sample_count.show_none();
+
+ _updating_sample_count = false;
+}
+
+void SamplingBar::commit_sample_count()
+{
+ uint64_t sample_count = 0;
+
+ if (_updating_sample_count)
+ return;
+
+ const shared_ptr<DevInst> dev_inst = get_selected_device();
+ if (!dev_inst)
+ return;
+
+ sample_count = _sample_count.value();
+
+ // Set the sample count
+ assert(!_updating_sample_count);
+ _updating_sample_count = true;
+ if (!dev_inst->set_config(NULL, SR_CONF_LIMIT_SAMPLES,
+ g_variant_new_uint64(sample_count))) {
+ qDebug() << "Failed to configure sample count.";
+ return;
+ }
+ _updating_sample_count = false;
+}
+