Exemple #1
0
static void tick_cb(struct game_state *gs)
{
	if (clock() - gs->lastdrop >= gs->delay) {
#if TICK
		drop_cb(gs);
#endif
		gs->lastdrop = clock();
	}

	SDL_RenderPresent(gs->surface);
}
Exemple #2
0
/* Emitted when the data has been received from the source. It should check
 * the GtkSelectionData sent by the source, and do something with it. Finally
 * it needs to finish the operation by calling gtk_drag_finish, which will emit
 * the "data-delete" signal if told to. */
static void drag_data_received_handler(GtkWidget *widget, GdkDragContext *context, 
    gint x, gint y, GtkSelectionData *selection_data, guint target_type, guint time,
    gpointer data)
{
    char *filename, *p, *lfn;
    gboolean dnd_success = FALSE;
    gboolean delete_selection_data = FALSE;
    DBG(("drag_data_received_handler"));

    /* Deal with what we are given from source */
    if(dropdata && (selection_data != NULL) && (gtk_selection_data_get_length (selection_data) >= 0))
    {
        dropdata = 0;
        if (gdk_drag_context_get_selected_action(context) == GDK_ACTION_MOVE) {
            delete_selection_data = TRUE;
        }

        /* FIXME; Check that we got a format we can use */
        filename = (char*)gtk_selection_data_get_data(selection_data);
        DBG(("DnD got string: %s", filename));
        dnd_success = TRUE;
        /* incase we got a list of files, terminate the list after the first
           file */
        p = filename;
        while (*p) {
            if ((*p == '\n') || (*p == '\r')) {
                *p = 0;
                break;
            }
            p++;
        }
	lfn = g_filename_from_uri(filename, NULL, NULL);
	if (!lfn) {
	    log_error(ui_log, "URI conversion failed: %s", filename);
	}
	
        DBG(("DnD using filename: '%s'", lfn));
        /* finally call the drop callback set by the individual ui */
        if (drop_cb) {
            drop_cb(lfn);
        }
        DBG(("DnD done"));
	if (lfn) {
	    free(lfn);
	}
    }

    if (dnd_success == FALSE) {
        DBG(("DnD data transfer failed!"));
    }

    gtk_drag_finish (context, dnd_success, delete_selection_data, time);
}
Exemple #3
0
void drop_block(struct game_state *gs)
{
	int k = -1;
	while (!collision(gs, 0, k + 1)) {
		k += 1;
	}

	put_shape(gs, 0);
	gs->y += k;

	drop_cb(gs);
}