#include <unique/unique.h>
int main( int argc, char *argv[])
{
UniqueApp *app;
app = unique_app_new( "org.dmedvinsky.gsimplecal" , NULL );
if (unique_app_is_running(app)) {
unique_app_send_message(app, UNIQUE_CLOSE, NULL );
}
else {
create_main_window();
unique_app_watch_window(app, GTK_WINDOW(main_window));
g_signal_connect(app, "message-received" , G_CALLBACK(message_received_cb), NULL );
}
static UniqueResponse message_received_cb(UniqueApp *app, UniqueCommand command,
UniqueMessageData *message, guint time_, gpointer user_data)
{
if (command == UNIQUE_CLOSE) {
gtk_signal_emit_by_name(GTK_OBJECT(main_window), "destroy" );
}
return UNIQUE_RESPONSE_OK;
}
g_object_unref(app);
Source: https://habr.com/ru/post/88314/