Results 1 to 6 of 6

Thread: Using libunity in C/C++

  1. #1
    Join Date
    Dec 2009
    Beans
    10

    Using libunity in C/C++

    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

    Code:
    #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

  2. #2
    Join Date
    Sep 2009
    Location
    Canada, Montreal QC
    Beans
    1,809
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: Using libunity in C/C++

    Quote Originally Posted by sajimon View Post
    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

    Code:
    #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.
    I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones.
    Freedom is measured in Stallmans.
    Projects: gEcrit

  3. #3
    Join Date
    Dec 2009
    Beans
    10

    Re: Using libunity in C/C++

    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.

  4. #4
    Join Date
    Nov 2010
    Location
    Down the rabbit hole
    Beans
    435
    Distro
    Ubuntu Development Release

    Re: Using libunity in C/C++

    #include <unity/unity/unity.h>
    I suspect someone at Canonical is mad about tautology.
    Your ads here, just 9.99$/week !!

  5. #5
    Join Date
    Sep 2009
    Location
    Canada, Montreal QC
    Beans
    1,809
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: Using libunity in C/C++

    Quote Originally Posted by t1497f35 View Post
    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.
    I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones.
    Freedom is measured in Stallmans.
    Projects: gEcrit

  6. #6
    Join Date
    Dec 2009
    Beans
    10

    Re: Using libunity in C/C++

    The correct usage is:

    Code:
    #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
    Code:
    gcc -o test test.c `pkg-config --cflags --libs unity`

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •