Exemplo n.º 1
0
void
news_item_orient_set(News_Item *ni, int horizontal)
{
   e_box_orientation_set(ni->view.box, horizontal);

   e_box_align_set(ni->view.box, 0.5, 0.5);
}
Exemplo n.º 2
0
static void
_populate(app_t *app)
{
    FILE *fp;

    if (app->infile) {
        fp = fopen(app->infile, "r");
        if (fp == NULL) {
            fprintf(stderr, "Could not open file for reading \"%s\": %s\n",
                    app->infile, strerror(errno));
            return;
        }
    } else {
        fprintf(stderr, "No input file provided, reading from stdin.\n");
        fp = stdin;
    }

    while (!feof(fp)) {
        Evas_Object *obj;
        Evas_Coord w, h;
        char *line;
        unsigned n;
        int i;

        n = 0;
        line = NULL;
        i = getline(&line, &n, fp);
        if (i < 0)
            break;

        if (i == 0) {
            free(line);
            continue;
        }
        line[i - 1] = '\0';

        obj = _new_list_item(app, line);
        e_box_pack_end(app->e_box, obj);
        edje_object_size_min_calc(obj, &w, &h);
        e_box_pack_options_set(obj, 1, 1, 1, 0, 0.0, 0.5, w, h, 9999, h);
        evas_object_show(obj);

        free(line);
    }

    if (fp != stdin)
        fclose(fp);

    e_box_align_set(app->e_box, 0.0, 1.0);
    app->current = 0;
}
Exemplo n.º 3
0
int
main(int argc, char *argv[])
{
    app_t app;
    int i;
    Evas_Object *o;

    ecore_init();
    ecore_app_args_set(argc, (const char **)argv);
    ecore_evas_init();
    edje_init();

    edje_frametime_set(1.0 / 30.0);

    memset(&app, 0, sizeof(app));

    app.ee = ecore_evas_software_x11_new(NULL, 0,  0, 0, WIDTH, HEIGHT);
    ecore_evas_data_set(app.ee, "app", &app);
    ecore_evas_title_set(app.ee, TITLE);
    ecore_evas_name_class_set(app.ee, WM_NAME, WM_CLASS);
    app.theme = THEME;

    for (i=1; i < argc; i++)
        if (strcmp (argv[i], "-fs") == 0)
            ecore_evas_fullscreen_set(app.ee, 1);
        else if (strncmp (argv[i], "-theme=", sizeof("-theme=") - 1) == 0)
            app.theme = argv[i] + sizeof("-theme=") - 1;
        else if (argv[i][0] != '-')
            app.infile = argv[i];

    app.evas = ecore_evas_get(app.ee);

    app.edje_main = edje_object_add(app.evas);
    evas_data_attach_set(app.evas, &app);
    if (!edje_object_file_set(app.edje_main, app.theme, THEME_GROUP)) {
        fprintf(stderr, "Failed to load file \"%s\", part \"%s\".\n",
                app.theme, THEME_GROUP);
        return 1;
    }


    evas_object_move(app.edje_main, 0, 0);
    evas_object_resize(app.edje_main, WIDTH, HEIGHT);

    app.e_box = e_box_add(app.evas);
    e_box_orientation_set(app.e_box, 0);
    e_box_homogenous_set(app.e_box, 0);
    e_box_align_set(app.e_box, 0.0, 0.5);

    edje_object_part_swallow(app.edje_main, "contents_swallow", app.e_box);

    evas_object_show(app.edje_main);
    evas_object_show(app.e_box);
    ecore_evas_show(app.ee);

    _populate(&app);
    app.scroll.initial_delay_ms = 750;
    app.scroll.accel_ms = 600;
    setup_gui_list(&app);

    ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, app_signal_exit, NULL);
    ecore_evas_callback_resize_set(app.ee, resize_cb);

    evas_object_event_callback_add(app.edje_main, EVAS_CALLBACK_KEY_DOWN,
                                   key_down, &app);

    evas_object_focus_set(app.edje_main, 1);

    o = edje_object_part_object_get(app.edje_main, "back_button");
    evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
                                   mouse_down_back_button,
                                   &app);

    ecore_main_loop_begin();

    return 0;
}
Exemplo n.º 4
0
static void
setup_gui_list(app_t *app)
{
    Evas_Object *obj;
    int item_w, item_h, box_w, box_h, i, n_items;

    destroy_gui_list(app);

    obj = _new_list_item(app, NULL);
    edje_object_size_min_calc(obj, &item_w, &item_h);
    evas_object_del(obj);
    app->item_height = item_h;

    e_box_freeze(app->e_box);
    evas_object_geometry_get(app->e_box,
                             &app->box_x, &app->box_y,
                             &box_w, &box_h);

    app->box_y -= item_h;
    evas_object_move(app->e_box, app->box_x, app->box_y);

    n_items = box_h / item_h + 3;

    app->n_evas_items = n_items;
    app->evas_items = malloc(n_items * sizeof(Evas_Object *));
    for (i = 0; i < n_items; i++) {
        Evas_Object *obj;

        obj = _new_list_item(app, "");
        app->evas_items[i] = obj;
        e_box_pack_end(app->e_box, obj);
        edje_object_size_min_calc(obj, &item_w, &item_h);
        e_box_pack_options_set(obj, 1, 1, 1, 0, 0.0, 0.5,
                               item_w, item_h, 9999, item_h);
        evas_object_show(obj);
    }

    e_box_align_set(app->e_box, 0.0, 1.0);

    app->arrow_down = edje_object_part_object_get(app->edje_main,
                                                  "arrow_down");
    app->arrow_up = edje_object_part_object_get(app->edje_main,
                                                "arrow_up");

    evas_object_event_callback_add(app->arrow_up,
                                   EVAS_CALLBACK_MOUSE_DOWN,
                                   mouse_down_arrow_up,
                                   app);
    evas_object_event_callback_add(app->arrow_up,
                                   EVAS_CALLBACK_MOUSE_UP,
                                   mouse_up_arrow_up,
                                   app);

    evas_object_event_callback_add(app->arrow_down,
                                   EVAS_CALLBACK_MOUSE_DOWN,
                                   mouse_down_arrow_down,
                                   app);
    evas_object_event_callback_add(app->arrow_down,
                                   EVAS_CALLBACK_MOUSE_UP,
                                   mouse_up_arrow_down,
                                   app);

    fill_gui_list(app);
    e_box_thaw(app->e_box);
}