I found here the solution: https://developer.tizen.org/zh-hans/forums/native-application-development/limit-number-widget?langswitch=zh-hans
We can do it programatically by adding a variable to count the widget's instances
int instance_count =0;
Then in the widget instance create callback we check the variable and increment it if there is only one instance or return error if it already has one instance created
static int
_on_create_cb(widget_context_h context, bundle *content, int w, int h, void *user_data) {
if(instance_count >0) return WIDGET_ERROR_ALREADY_EXIST;
instance_count++;
return WIDGET_ERROR_NONE;
}
In the destroy callback we decrement the counter
static int
_on_destroy_cb(widget_context_h context, widget_app_destroy_type_e reason, bundle *content, void *user_data) {
instance_count--;
return WIDGET_ERROR_NONE;
}
This is not the perfect solution because it still allows the user to select the widget from the list, but it works.
I also tested crashing the app on purpose and this solution works.
When the app crashes the _on_destroy_cb is not called, but the instance_count is reset to 0 anyway.