Ejemplo n.º 1
0
static unsigned long get_next_day(GCContext *context)
{
    GCConfig *config = context->config;
    int       d      = get_current_day(context);

    if (++d > get_number_of_days(context))
        d = 1;
    
    return d;
}
Ejemplo n.º 2
0
static unsigned long get_prev_day(GCContext *context)
{
    GCConfig *config = context->config;
    int       d      = get_current_day(context);

    if (--d < 1)
        d = get_number_of_days(context);
    
    return d;
}
Ejemplo n.º 3
0
static unsigned long get_rand_day(GCContext *context)
{
    int cd   = get_current_day(context);
    int d    = 0;
    int cntr = 0;

    do {
        d = g_random_int_range(1, get_number_of_days(context) + 1);
    } while (d == cd && ++cntr < MAX_RAND_DAY_TRIES);

    return d;
}
Ejemplo n.º 4
0
static unsigned long get_frame_offset(GCContext *context, goToDayType dayType, dayOffsetType offsetType)
{
    GCConfig      *config = context->config;
    Movie         *movie  =  context->movie_context;
    unsigned long  offset = 0;
    int            day    = 1;

    switch (dayType) {
        case GO_TO_NEXT_DAY:
            day = get_next_day(context);
            break;
        case GO_TO_PREV_DAY:
            day = get_prev_day(context);
            //exit(1);
            break;
        case GO_TO_RAND_DAY:
            day = get_rand_day(context);
            break;
        case GO_TO_CURR_DAY:
        default:
            day = get_current_day(context);
            break;
    }

    switch (offsetType) {
        case DAY_OFFSET_START:
            offset = get_frame_offset_day(context, day);
            break;
        case DAY_OFFSET_NOW:
        default:
            offset = get_frame_offset_day_now(context, day);
            break;
    }

    g_message("Offset for day %d: %lu", day, offset);

    return offset;
}
Ejemplo n.º 5
0
void
ical_events_list_create(gint calendar, GUI *appGUI) {

struct ics_file *entry;
struct ics_entry *item;
gint j;
GtkTreeIter iter;
GSList *node;
guint32 julian;
gboolean year_flag;

    gtk_list_store_clear (GTK_LIST_STORE(appGUI->cal->ical_events_list_store));

    j = 0;

    while (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(appGUI->opt->calendar_ical_files_store), &iter, NULL, j++)) {
        gtk_tree_model_get(GTK_TREE_MODEL(appGUI->opt->calendar_ical_files_store), &iter, 
                           ICAL_COLUMN_USE_YEAR, &year_flag, -1);
        if (j-1 == calendar) break;
    }

    entry = g_slist_nth_data (appGUI->cal->ics_files_list, calendar);

    if (entry->entries_list != NULL) {
    
        for (j = 0, node = entry->entries_list; node != NULL; node = node->next, j++) {
            item = g_slist_nth_data (entry->entries_list, j);

            if (year_flag == TRUE) {
                julian = date_to_julian(item->date.day, item->date.month-1, item->date.year);
            } else {
                julian = date_to_julian(item->date.day, item->date.month-1, get_current_year());
            }

            gtk_list_store_append(appGUI->cal->ical_events_list_store, &iter);

            if (year_flag == TRUE) {
                gtk_list_store_set(appGUI->cal->ical_events_list_store, &iter, 
                                   I_COLUMN_DATE, julian_to_str (julian, config.date_format),
                                   I_COLUMN_DATE_JULIAN, julian,
                                   I_COLUMN_SUMMARY, str_remove_backslash (item->summary), -1); 
            } else {
                gtk_list_store_set(appGUI->cal->ical_events_list_store, &iter, 
                                   I_COLUMN_DATE, julian_to_str (julian, DATE_NAME_DAY),
                                   I_COLUMN_DATE_JULIAN, julian,
                                   I_COLUMN_SUMMARY, str_remove_backslash (item->summary), -1); 
            }

            if (get_current_day() == item->date.day && get_current_month()+1 == item->date.month && year_flag == FALSE) {
                gtk_list_store_set(appGUI->cal->ical_events_list_store, &iter, 
                                   I_COLUMN_FONT_WEIGHT, PANGO_WEIGHT_BOLD, -1);
            } else if (get_current_day() == item->date.day && get_current_month()+1 == item->date.month && get_current_year() == item->date.year) {
                gtk_list_store_set(appGUI->cal->ical_events_list_store, &iter, 
                                   I_COLUMN_FONT_WEIGHT, PANGO_WEIGHT_BOLD, -1);
            } else {
                gtk_list_store_set(appGUI->cal->ical_events_list_store, &iter, 
                                   I_COLUMN_FONT_WEIGHT, PANGO_WEIGHT_NORMAL, -1);
            }
        }
    }

}
Ejemplo n.º 6
0
int main (int argc, char *argv[])
{
    GCContext    gc_context;
    GMainLoop   *mainLoop;
    GKeyFile    *keyFile;
    GThread     *displayThread;
    GThread     *inputControllerThread;
    GThread     *x11EventThread;
    int          i;

    
    GCConfig config = {
        .movie_path          = DEFAULT_MOVIE_PATH,
        .mask_path           = DEFAULT_MASK_PATH,
        .controller_path     = DEFAULT_CONTROLLER_PATH,
        .seconds_per_frame   = DEFAULT_SECONDS_PER_FRAME,
        .easing_factor       = DEFAULT_EASING_FACTOR,
        .frames_per_tick     = 0,
        .diameter_controller = 0,
        .diameter_rim        = 0,
        .ctr                 = 0,
        .fpr                 = 0,
        .number_of_frames    = 0,
        .fullscreen          = TRUE,
        .timeZone            = NULL,
    };

    Movie movie = {
        .planes             = NULL,
        .frame_offset       = 0,
        .fd_movie           = -1,
        .frame              = { .pitches = { FRAME_PITCH, 0, 0 } },
        .fd_mask            = -1,
        .mask               = { .pitches = { MASK_PITCH, 0, 0 } },
        .pre_load_surface   = VDP_INVALID_HANDLE,
        .play_direction     = DIRECTION_FORWARD,
        .ticks              = 0,
        .new_frame          = FALSE,
        .ease_to            = TRUE,
    };

    keyFile = g_key_file_new();
    if (argc > 1 && g_key_file_load_from_file(keyFile, argv[1], G_KEY_FILE_NONE, NULL)) {
        if (g_key_file_has_group(keyFile, "MAIN")) {
            if (g_key_file_has_key(keyFile, "MAIN", "utc_offset", NULL))
                config.timeZone = g_time_zone_new(g_key_file_get_string(keyFile, "MAIN", "utc_offset", NULL));
            if (g_key_file_has_key(keyFile, "MAIN", "ease_to_time", NULL))
                movie.ease_to = g_key_file_get_boolean(keyFile, "MAIN", "ease_to_time", NULL);
        }
 
        if (g_key_file_has_group(keyFile, "MOVIE")) {
           if (g_key_file_has_key(keyFile, "MOVIE", "file", NULL))
              config.movie_path = g_key_file_get_string(keyFile, "MOVIE", "file", NULL);
           if (g_key_file_has_key(keyFile, "MOVIE", "mask", NULL))
              config.mask_path = g_key_file_get_string(keyFile, "MOVIE", "mask", NULL);
           if (g_key_file_has_key(keyFile, "MOVIE", "seconds_per_frame", NULL))
              config.seconds_per_frame = (float)g_key_file_get_double(keyFile, "MOVIE", "seconds_per_frame", NULL);
           if (g_key_file_has_key(keyFile, "MOVIE", "easing_factor", NULL))
              config.easing_factor = (float)g_key_file_get_integer(keyFile, "MOVIE", "easing_factor", NULL);
        }
        
        if (g_key_file_has_group(keyFile, "CONTROLLER")) {
           if (g_key_file_has_key(keyFile, "CONTROLLER", "path", NULL))
              config.controller_path = g_key_file_get_string(keyFile, "CONTROLLER", "path", NULL);

           if (g_key_file_has_key(keyFile, "CONTROLLER", "diameter_controller", NULL))
              config.diameter_controller = (float)g_key_file_get_double(keyFile, "CONTROLLER", "diameter_controller", NULL);
           if (g_key_file_has_key(keyFile, "CONTROLLER", "diameter_rim", NULL))
              config.diameter_rim = (float)g_key_file_get_double(keyFile, "CONTROLLER", "diameter_rim", NULL);
           if (g_key_file_has_key(keyFile, "CONTROLLER", "ctr", NULL))
              config.ctr = (float)g_key_file_get_double(keyFile, "CONTROLLER", "ctr", NULL);
           if (g_key_file_has_key(keyFile, "CONTROLLER", "fpr", NULL))
              config.fpr = (float)g_key_file_get_double(keyFile, "CONTROLLER", "fpr", NULL);
           if (g_key_file_has_key(keyFile, "CONTROLLER", "frames_per_tick", NULL))
              config.frames_per_tick = (float)g_key_file_get_double(keyFile, "CONTROLLER", "frames_per_tick", NULL);
        }

        if (g_key_file_has_group(keyFile, "SCREEN")) {
           if (g_key_file_has_key(keyFile, "SCREEN", "fullscreen", NULL))
              config.fullscreen = g_key_file_get_boolean(keyFile, "SCREEN", "fullscreen", NULL);
        }
        g_key_file_free(keyFile);
    }

    if (!config.timeZone)
        config.timeZone = g_time_zone_new_local();

    if (!config.frames_per_tick && 
        !(config.frames_per_tick = frames_per_tick(config.diameter_controller,
                                                   config.diameter_rim,
                                                   config.ctr,
                                                   config.fpr)))
    {
        g_warning("No valid tick settings, using default frames per tick: %f", DEFAULT_FRAMES_PER_TICK);
        config.frames_per_tick = DEFAULT_FRAMES_PER_TICK;
    }

    config.movie_size = get_file_size(config.movie_path);
    config.number_of_frames = config.movie_size / FRAME_SIZE;
    
    mainLoop = g_main_loop_new(NULL, FALSE);

    gc_context.g_main_loop        = mainLoop;
    gc_context.g_main_context     = g_main_loop_get_context(mainLoop);
    gc_context.window_size.width  = MOVIE_WIDTH;
    gc_context.window_size.height = MOVIE_HEIGHT;
    gc_context.exit               = FALSE;
    gc_context.movie_context      = &movie;
    gc_context.config             = &config;


    g_message("movie file: %s",                           config.movie_path);
    g_message("movie size: %lu",                          config.movie_size);
    g_message("movie frames: %lu",                        config.number_of_frames);
    g_message("movie mask file: %s",                      config.mask_path);
    g_message("frames per minute: %f",                    get_frames_per_minute(&gc_context));
    g_message("frames per day:    %lu",                   get_frames_per_day(&gc_context));
    g_message("frames per tick:   %f",                    config.frames_per_tick);
    g_message("number of days:    %d",                    get_number_of_days(&gc_context));
    g_message("current day:       %d",                    get_current_day(&gc_context));

    if (movie.ease_to) {
        movie.ease_to_frame = get_frame_offset(&gc_context, GO_TO_RAND_DAY, DAY_OFFSET_NOW);
        g_message("ease to frame:    %lu", movie.ease_to_frame);
    }

    x11_init(&gc_context);
    vdpau_init(&gc_context);

    load_movie(&gc_context);
    load_mask(&gc_context);

    g_cond_init(&movie.tick_cond);
    g_mutex_init(&movie.tick_lock);
    g_mutex_init(&movie.frame_lock);

    displayThread = g_thread_new("Display thread", display_thread, (gpointer)&gc_context);
    inputControllerThread = g_thread_new("Input controller thread", input_controller_thread, (gpointer)&gc_context);
    x11EventThread = g_thread_new("X11 Event thread", x11_event_thread, (gpointer)&gc_context);

    g_main_loop_run(mainLoop);

    gc_context.exit = TRUE;
    g_thread_join(displayThread); 
    g_thread_join(inputControllerThread); 
    g_thread_join(x11EventThread); 
    g_cond_clear(&movie.tick_cond);
    g_mutex_clear(&movie.tick_lock);
    g_mutex_clear(&movie.frame_lock);
    g_time_zone_unref(config.timeZone);
}