Hello, I'm bumping this old thread because it is still a problem.

To refresh your memory, there is some bug with IUP GTK backends where
*sometimes* the sizing for a layout in a dialog is incorrect. It
happens *sometimes*, so while I can reproduce it, it is hard to
reproduce at will. When I launch the program, it is sometimes broken,
or not. It feels a little like it is a race condition between IUP and
GTK itself.

I have seen this problem with both the GTK2 and GTK3 backends, on many
different Linux distros and versions, including many versions of
Ubuntu, Debian, Raspbian, and Arch.

I have written a simplified test program that can reproduce the
problem (sometimes). I am attaching that program to this message. I
have uploaded a video showing the program working correctly and not
working correctly.

https://youtu.be/1ta8AK3jM2U
(The broken run version is at 7 seconds.)

I'm hoping you can help me trackdown what is causing this, or at least
narrow down what to look for. I tried stepping through a debugger, but
I can't seem to reproduce it when I do that, which is another reason I
think there is some kind of initialization race condition.

Thanks,
Eric
#include "iup.h"
#include <stddef.h>

const char* GenProj_GetLocalizedString(const char* key, const char* comment)
{
        return IupGetLanguageString(key);
}


Ihandle* NewOrOpenView_Create(
	Ihandle* image_new,
	Ihandle* image_open,
	Icallback on_new_project_callback,
	Icallback on_open_project_callback,
	void* user_data
)
{
	Ihandle* main_dialog = NULL;
	Ihandle* image_button_new = NULL;
	Ihandle* image_button_open = NULL;
	Ihandle* label_new = NULL;
	Ihandle* label_open = NULL;
	Ihandle* hbox_for_centered_ui = NULL;
	Ihandle* vbox_for_centered_ui = NULL;
	Ihandle* hbox_for_buttons = NULL;
	Ihandle* hbox_for_labels = NULL;
	Ihandle* vbox_for_new_button_and_label = NULL;
	Ihandle* vbox_for_open_button_and_label = NULL;


	image_button_new = IupButton(NULL, "newProjectButtonAction");
	image_button_open = IupButton(NULL, "openProjectButtonAction");

//	IupSetAttributeHandle(image_button_new, "IMAGE", image_new);
//	IupSetAttributeHandle(image_button_open, "IMAGE", image_open);        

	label_new = IupLabel(GenProj_GetLocalizedString("New Project", "New Project"));
	label_open = IupLabel(GenProj_GetLocalizedString("Open Project", "Open Project"));

	IupSetAttribute(label_new, "EXPAND", "HORIZONTAL");
	IupSetAttribute(label_open, "EXPAND", "HORIZONTAL");
	IupSetAttribute(label_new, "SHRINK", "HORIZONTAL");
	IupSetAttribute(label_open, "SHRINK", "HORIZONTAL");
	IupSetAttribute(image_button_new, "EXPAND", "YES");
	IupSetAttribute(image_button_open, "EXPAND", "YES");
	IupSetAttribute(image_button_new, "SHRINK", "YES");
	IupSetAttribute(image_button_open, "SHRINK", "YES");

	IupSetAttribute(image_button_new, "ALIGNMENT", "ACENTER:ACENTER");
	IupSetAttribute(image_button_open, "ALIGNMENT", "ACENTER:ACENTER");
	IupSetAttribute(label_new, "ALIGNMENT", "ACENTER:ACENTER");
	IupSetAttribute(label_open, "ALIGNMENT", "ACENTER:ACENTER");
	IupSetAttribute(label_new, "FONTSIZE", "24");
	IupSetAttribute(label_open, "FONTSIZE", "24");

	
	vbox_for_new_button_and_label = IupVbox(
		image_button_new, 
		label_new,
		NULL
	);

	vbox_for_open_button_and_label = IupVbox(
		image_button_open, 
		label_open,
		NULL
	);

	IupSetAttribute(vbox_for_new_button_and_label, "ALIGNMENT", "ACENTER:ACENTER");
	IupSetAttribute(vbox_for_open_button_and_label, "ALIGNMENT", "ACENTER:ACENTER");
	IupSetAttribute(vbox_for_new_button_and_label, "SHRINK", "YES");
	IupSetAttribute(vbox_for_open_button_and_label, "SHRINK", "YES");

	hbox_for_buttons = IupHbox(
		vbox_for_new_button_and_label,
		vbox_for_open_button_and_label,
		NULL
	);
	IupSetAttribute(hbox_for_buttons, "ALIGNMENT", "ACENTER:ACENTER");

	IupSetAttribute(hbox_for_buttons, "MARGIN", "10x10");


//	IupSetCallback(image_button_new, "ACTION", on_new_project_callback);
//	IupSetCallback(image_button_open, "ACTION", on_open_project_callback);

//	IupSetAttribute(image_button_new, "MY_USER_DATA", (const char*)user_data);
//	IupSetAttribute(image_button_open, "MY_USER_DATA", (const char*)user_data);
	
	return hbox_for_buttons;
}

static void IupExitPoint()
{
	IupClose();
}


/******************************************************************************
 * Main function                                                              *
 ******************************************************************************/
void IupEntryPoint()
{

	// IupSetFunction("EXIT_CB", (Icallback)IupExitPoint);


	Ihandle* box =  NewOrOpenView_Create(
		NULL,
		NULL,
		NULL,
		NULL,
		NULL
	);

	Ihandle* dialog = IupDialog(box);
	IupShow(dialog);
}

int main(int argc, char* argv[])
{
	IupOpen(&argc, &argv);

#if 0 // new ENTRY_POINT callback
	IupSetFunction("ENTRY_POINT", (Icallback)IupEntryPoint);
	IupMainLoop();
	
#else // legacy
	IupEntryPoint();
	IupMainLoop();
	// legacy: New way should assume IupMainLoop may return immediately or this code is never reached.
	IupClose();
#endif
	
	return 0;
}

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to