static int note_lookup(git_note **out, git_repository *repo, git_tree *tree, const char *target) { int error, fanout = 0; git_oid oid; git_blob *blob = NULL; git_note *note = NULL; git_tree *subtree = NULL; if ((error = find_subtree_r(&subtree, tree, repo, target, &fanout)) < 0) goto cleanup; if ((error = find_blob(&oid, subtree, target + fanout)) < 0) goto cleanup; if ((error = git_blob_lookup(&blob, repo, &oid)) < 0) goto cleanup; if ((error = note_new(¬e, &oid, blob)) < 0) goto cleanup; *out = note; cleanup: git_tree_free(subtree); git_blob_free(blob); return error; }
/* notes_note_add */ Note * notes_note_add(Notes * notes, Note * note) { GtkTreeIter iter; char * filename; if(note == NULL) { if((note = note_new()) == NULL) return NULL; if((filename = _notes_note_get_new_filename()) == NULL) { notes_error(notes, error_get(NULL), 0); note_delete(note); return NULL; } note_set_filename(note, filename); free(filename); note_set_title(note, _("New note")); note_save(note); } gtk_list_store_insert(notes->store, &iter, 0); gtk_list_store_set(notes->store, &iter, ND_COL_NOTE, note, ND_COL_TITLE, note_get_title(note), -1); return note; }
/* note_new_from_file */ Note * note_new_from_file(char const * filename) { Note * note; if((note = note_new()) == NULL) return NULL; if(note_set_filename(note, filename) != 0 || note_load(note) != 0) { note_delete(note); return NULL; } return note; }
static int ui_send_request(ui_t *ui) { note_t *note; note = note_new(0, VEL, 0, MAX_LEN); if (!note) { return 1; } lff_msg_write(ui->write, LFF_MSG_REQUEST, note, 0, ui->pattern); return 0; }
static int ui_send_play(ui_t *ui, int key) { note_t *note; note = note_new(key, VEL, 0, MAX_LEN); if (!note) { return 1; } lff_msg_write(ui->write, LFF_MSG_PLAY, note, 0, ui->pattern); return 0; }
static int ui_send_add(ui_t *ui, int key, int vel, int step, int len, int pattern) { note_t *note; /* TODO: would it be faster to have an allocad stack of notes for playing */ note = note_new(key, vel, step, len); if (!note) { return 1; } lff_msg_write(ui->write, LFF_MSG_ADD, note, 0, pattern); return 0; }