int main(int argc, char** argv)
{
    UApplicationOptions* options = u_application_options_new_from_cmd_line(argc, argv);

    UApplicationDescription* desc = u_application_description_new();
    UApplicationId* id = u_application_id_new_from_stringn("UbuntuApplicationCAPI", 21);
    u_application_description_set_application_id(desc, id);
    UApplicationInstance* instance = u_application_instance_new_from_description_with_options(desc, options);

    UAUiSessionProperties* props = ua_ui_session_properties_new();
    ua_ui_session_properties_set_type(props, U_USER_SESSION);

    UAUiSession* ua_ui_session_new_with_properties(props);

    UAUiDisplay* display = ua_ui_display_new_with_index(0);

    printf("Display resolution: (x,y) = (%d,%d)\n",
           ua_ui_display_query_horizontal_res(display),
           ua_ui_display_query_vertical_res(display));
   
    UAUiWindowProperties* wprops = ua_ui_window_properties_new_for_normal_window();
    ua_ui_window_properties_set_titlen(wprops, "Window 1", 8);
    ua_ui_window_properties_set_role(wprops, U_MAIN_ROLE);
    ua_ui_window_properties_set_input_cb_and_ctx(wprops, on_new_event, NULL);
   
    UAUiWindow* surface = ua_ui_window_new_for_application_with_properties(instance, wprops);
    
    View view(surface);
    while(true)
    {
        view.render();
        view.step();
    }   
}
示例#2
0
static struct session *
create_session (void)
{
    struct session *session;
    char argv[1][1];
    session = malloc (sizeof *session);

    session->properties = ua_ui_session_properties_new ();
    ua_ui_session_properties_set_type (session->properties, U_SYSTEM_SESSION);
    session->session = ua_ui_session_new_with_properties (session->properties);
    if (!session->session)
        GST_WARNING ("Failed to start new Ubuntu Application API session");

    session->app_description = u_application_description_new ();
    session->app_lifecycle_delegate = u_application_lifecycle_delegate_new ();
    /* No context data to pass to the lifecycle delegate for now */
    u_application_lifecycle_delegate_set_context
    (session->app_lifecycle_delegate, NULL);
    u_application_description_set_application_lifecycle_delegate
    (session->app_description, session->app_lifecycle_delegate);

    /* The UA requires a command line option set, so give it a fake argv array */
    argv[0][0] = '\n';
    session->app_options =
        u_application_options_new_from_cmd_line (1, (char **) argv);
    session->app_instance =
        u_application_instance_new_from_description_with_options
        (session->app_description, session->app_options);
    if (!session->app_instance)
        GST_WARNING ("Failed to start a new Ubuntu Application API instance");

    return session;
}