AGlActor* list_view(WaveformActor* _) { instance_count++; _init(); bool list_paint(AGlActor* actor) { ListView* view = (ListView*)actor; #define row_height 20 #define N_ROWS_VISIBLE(A) (agl_actor__height(((AGlActor*)A)) / row_height) int n_rows = N_ROWS_VISIBLE(actor); int col[] = {0, 150, 260, 360, 420}; GtkTreeIter iter; if(!gtk_tree_model_get_iter_first((GtkTreeModel*)samplecat.store, &iter)){ gerr ("cannot get iter."); return false; } int i = 0; for(;i<view->scroll_offset;i++){ gtk_tree_model_iter_next((GtkTreeModel*)samplecat.store, &iter); } int row_count = 0; do { if(row_count == view->selection - view->scroll_offset){ agl->shaders.plain->uniform.colour = 0x6677ff77; agl_use_program((AGlShader*)agl->shaders.plain); agl_rect_((AGlRect){0, row_count * row_height - 2, agl_actor__width(actor), row_height}); } Sample* sample = samplecat_list_store_get_sample_by_iter(&iter); if(sample){ char* len[32]; format_smpte((char*)len, sample->frames); char* f[32]; samplerate_format((char*)f, sample->sample_rate); char* val[4] = {sample->name, sample->sample_dir, (char*)len, (char*)f}; int c; for(c=0;c<G_N_ELEMENTS(val);c++){ agl_enable_stencil(0, 0, col[c + 1] - 6, actor->region.y2); agl_print(col[c], row_count * row_height, 0, 0xffffffff, val[c]); } sample_unref(sample); } } while (++row_count < n_rows && gtk_tree_model_iter_next((GtkTreeModel*)samplecat.store, &iter)); agl_disable_stencil(); return true; }
void samplecat_list_store_add (SamplecatListStore* self, Sample* sample) { if(!samplecat.store) return; g_return_if_fail(sample); #if 1 /* these has actualy been checked _before_ here * but backend may 'inject' mime types. ?! */ if(!sample->mimetype){ dbg(0,"no mimetype given -- this should NOT happen: fix backend"); return; } if(mimestring_is_unsupported(sample->mimetype)){ dbg(0, "unsupported MIME type: %s", sample->mimetype); return; } #endif if(!sample->sample_rate){ // needed w/ tracker backend. sample_get_file_info(sample); } char samplerate_s[32]; samplerate_format(samplerate_s, sample->sample_rate); char length_s[64]; format_smpte(length_s, sample->length); #ifdef USE_AYYI GdkPixbuf* ayyi_icon = NULL; //is the file loaded in the current Ayyi song? if(ayyi.got_shm){ gchar* fullpath = g_build_filename(sample->sample_dir, sample->name, NULL); if(ayyi_song__have_file(fullpath)){ dbg(1, "sample is used in current project TODO set icon"); } else dbg(2, "sample not used in current project"); g_free(fullpath); } #endif #define NSTR(X) (X?X:"") //icon (only shown if the sound file is currently available) GdkPixbuf* iconbuf = sample->online ? get_iconbuf_from_mimetype(sample->mimetype) : NULL; GtkTreeIter iter; gtk_list_store_append(samplecat.store, &iter); gtk_list_store_set(samplecat.store, &iter, COL_ICON, iconbuf, COL_NAME, sample->name, COL_FNAME, sample->sample_dir, COL_IDX, sample->id, COL_MIMETYPE, sample->mimetype, COL_KEYWORDS, NSTR(sample->keywords), COL_PEAKLEVEL, sample->peaklevel, COL_OVERVIEW, sample->overview, COL_LENGTH, length_s, COL_SAMPLERATE, samplerate_s, COL_CHANNELS, sample->channels, COL_COLOUR, sample->colour_index, #ifdef USE_AYYI COL_AYYI_ICON, ayyi_icon, #endif COL_SAMPLEPTR, sample, COL_LEN, sample->length, -1); GtkTreePath* treepath; if((treepath = gtk_tree_model_get_path(GTK_TREE_MODEL(samplecat.store), &iter))){ sample->row_ref = gtk_tree_row_reference_new(GTK_TREE_MODEL(samplecat.store), treepath); gtk_tree_path_free(treepath); } g_return_if_fail (self); if(sample->row_ref && sample->online){ request_analysis(sample); } sample_ref (sample); }
void samplecat_list_store_on_sample_changed (SamplecatListStore* self, Sample* sample, gint prop, void* val) { g_return_if_fail (self != NULL); g_return_if_fail (sample->row_ref); GtkTreePath* path = gtk_tree_row_reference_get_path(sample->row_ref); if(!path) return; GtkTreeIter iter; gtk_tree_model_get_iter(GTK_TREE_MODEL(samplecat.store), &iter, path); gtk_tree_path_free(path); dbg(1, "prop=%i %s", prop, samplecat_model_print_col_name(prop)); switch(prop){ case COL_ICON: // online/offline, mtime { GdkPixbuf* iconbuf = NULL; if (sample->online) { MIME_type* mime_type = mime_type_lookup(sample->mimetype); type_to_icon(mime_type); if (!mime_type->image) dbg(0, "no icon."); iconbuf = mime_type->image->sm_pixbuf; } gtk_list_store_set(samplecat.store, &iter, COL_ICON, iconbuf, -1); } break; case COL_KEYWORDS: gtk_list_store_set(samplecat.store, &iter, COL_KEYWORDS, (char*)val, -1); break; case COL_OVERVIEW: gtk_list_store_set((GtkListStore*)self, &iter, COL_OVERVIEW, sample->overview, -1); break; case COL_COLOUR: gtk_list_store_set(samplecat.store, &iter, prop, *((guint*)val), -1); break; case COL_PEAKLEVEL: gtk_list_store_set((GtkListStore*)self, &iter, COL_PEAKLEVEL, sample->peaklevel, -1); break; case COL_FNAME: gtk_list_store_set(samplecat.store, &iter, COL_FNAME, sample->sample_dir, -1); break; case COL_X_EBUR: case COL_X_NOTES: // nothing to do. break; case COL_ALL: case -1: // deprecated { //char* metadata = sample_get_metadata_str(s); char samplerate_s[32]; samplerate_format(samplerate_s, sample->sample_rate); char length_s[64]; format_smpte(length_s, sample->length); gtk_list_store_set((GtkListStore*)samplecat.store, &iter, COL_CHANNELS, sample->channels, COL_SAMPLERATE, samplerate_s, COL_LENGTH, length_s, COL_PEAKLEVEL, sample->peaklevel, COL_OVERVIEW, sample->overview, -1); dbg(1, "file info updated."); //if(metadata) g_free(metadata); } break; default: dbg(0, "property not handled %i", prop); break; } }