View Full Version : Using libunity in C/C++
sajimon
May 14th, 2011, 08:13 PM
Hello,
I'm trying to familiarize myself with new unity API provided by libunity, I wrote a simple example application, but it is doesn't seems to work.
Heres the testing code, if someone could take a look
#include <unity/unity/unity.h>
int main(int argc, char **argv)
{
g_type_init();
UnityLauncherEntry* xx = unity_launcher_entry_get_for_desktop_id("evolution.desktop");
unity_launcher_entry_set_count(xx,12);
unity_launcher_entry_set_count_visible(xx,TRUE);
pause();
return 0;
}
There is no effect at all, std output not showing any messages or warnings as well
cgroza
May 14th, 2011, 08:29 PM
Hello,
I'm trying to familiarize myself with new unity API provided by libunity, I wrote a simple example application, but it is doesn't seems to work.
Heres the testing code, if someone could take a look
#include <unity/unity/unity.h>
int main(int argc, char **argv)
{
g_type_init();
UnityLauncherEntry* xx = unity_launcher_entry_get_for_desktop_id("evolution.desktop");
unity_launcher_entry_set_count(xx,12);
unity_launcher_entry_set_count_visible(xx,TRUE);
pause();
return 0;
}
There is no effect at all, std output not showing any messages or warnings as well
Don't you think there should be some kind of main loop? I am guessing the program executes, and when it's done, the entry goes away too.
sajimon
May 15th, 2011, 08:30 AM
Ok, I changed pause() function, to gtk_main(); and it worked.
Obviously something else important happening in gtk_main() for this api to work.
thanks for clue.
t1497f35
May 15th, 2011, 09:49 AM
#include <unity/unity/unity.h>
I suspect someone at Canonical is mad about tautology.
cgroza
May 15th, 2011, 07:37 PM
I suspect someone at Canonical is mad about tautology.
Kind of weird that directory hierarchy. Maybe because there are others libraries in the Unity folder.
mhr3
June 25th, 2012, 12:12 PM
The correct usage is:
#include <unity.h>
int main(int argc, char **argv)
{
g_type_init();
UnityLauncherEntry* entry =
unity_launcher_entry_get_for_desktop_id ("evolution.desktop");
unity_launcher_entry_set_count (entry, 12);
unity_launcher_entry_set_count_visible (entry, TRUE);
GMainLoop *ml = g_main_loop_new (NULL, FALSE);
g_main_loop_run (ml);
return 0;
}
Considering the file is called test.c, you can compile it with
gcc -o test test.c `pkg-config --cflags --libs unity`
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.