On Tue, 23 Apr 2019 18:15:01 GMT, Ron Tarrant wrote:

I hooked up some signals to a few SpinButtons (one with double increments, the other two with float) and I'm getting some double-firings on the two float buttons, but not all the time.

I saw the note from here

When setting multiple adjustment properties via their individual setters, multiple “changed” signals will be emitted. However, since the emission of the “changed” signal is tied to the emission of the “notify” signals of the changed properties, it’s possible to compress the “changed” signals into one by calling gobjectfreezenotify() and gobjectthawnotify() around the calls to the individual setters.

Alternatively, using a single gobjectset() for all the properties to change, or using gtkadjustmentconfigure() has the same effect of compressing “changed” emissions.

But I think it doesn't really apply here(?). Rather it has to do with rounding maybe? if you use double instead of float for the config variables it triggers only once. in my test even changing only variable step to type double changed that. But you have to use variables to get it triggered twice, new Adjustment(0.0f, ... doesn't reproduce it.

// SpinButton madness

import std.stdio;

import gtk.Main;
import gtk.MainWindow;
import gtk.Widget;
import gtk.SpinButton;
import gtk.Adjustment;

class MySpinButton : SpinButton
{

	this()
	{

		// triggers once
		//super(0.0f, 1.0f, 0.1f);
		//Adjustment a = new Adjustment(0.0f, -1.0f, 1.0f, 0.1f, 0.5f, 0.0f);

		// triggers once
		//super(0.0, 1.0, 0.1);
		//Adjustment a = new Adjustment(0.0, -1.0, 1.0, 0.1, 0.5, 0.0);

		// triggers twice
		float step = 0.1;
		super(0.0, 1.0, step);
		Adjustment a = new Adjustment(0.0, -1.0, 1.0, step, 0.5, 0.0);


		setAdjustment(a);
		addOnValueChanged(&onValueChanged);
	}

	void onValueChanged(SpinButton sb)
	{
		writeln("onValueChanged : ", getValue());
	}
}

void main(string[] args)
{
	Main.init(args);

	MainWindow window = new MainWindow("title");
	window.setSizeRequest(400, 200);

	MySpinButton msb = new MySpinButton();

	window.add(msb);

	window.showAll();
	Main.run();
}