#include "ui_buttons.h"
#include "support.h"
#include "timecode.h"
+#include "playlist.h"
typedef struct column_desc
{
gdk_flush();
gdk_threads_leave();
};
+
+void ui_playlist_select_item(instance_t* app, int idx)
+{
+ GtkTreePath* path;
+
+ path = gtk_tree_path_new_from_indices(idx, -1);
+
+ gtk_tree_selection_select_path(gtk_tree_view_get_selection(GTK_TREE_VIEW(app->playlist_grid)), path);
+ gtk_tree_view_set_cursor(GTK_TREE_VIEW(app->playlist_grid), path, NULL, FALSE);
+ gtk_tree_path_free(path);
+};
+
+void ui_playlist_draw(instance_t* app)
+{
+ int i;
+ int sel;
+ char tc1[12], tc2[12];
+ GtkListStore *list_store;
+ GtkTreeIter iter;
+
+ sel = playlist_get_first_selected_item_idx(app);
+
+ list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(app->playlist_grid)));
+ gtk_list_store_clear(list_store);
+
+ pthread_mutex_lock(&app->playlist.lock);
+
+ for(i = 0;i < app->playlist.count; i++)
+ {
+ char ch[3];
+
+ if(PLAYLIST_BLOCK_BEGIN & app->playlist.item[i].type)
+ snprintf(ch, sizeof(ch), "%c", 'A' + app->playlist.item[i].player);
+ else
+ ch[0] = 0;
+
+ gtk_list_store_append(list_store, &iter);
+
+ gtk_list_store_set(list_store, &iter,
+ 0, "",
+ 1, app->playlist.block_icons[app->playlist.item[i].type],
+ 2, ch,
+ 3, app->playlist.item[i].id,
+ 4, frames2tc(app->playlist.item[i].in, 25.0, tc1),
+ 5, frames2tc(app->playlist.item[i].dur, 25.0, tc2),
+ 6, app->playlist.item[i].title,
+ 7, i,
+ 8, (app->playlist.item[i].error != 0),
+ 9, (app->playlist.item[i].error & PLAYLIST_ITEM_ERROR_LIB)?"red":"orange",
+ -1 );
+ }
+
+ app->playlist.ver_prev = app->playlist.ver_curr;
+
+ if(sel >= 0)
+ ui_playlist_select_item(app, sel);
+
+ pthread_mutex_unlock(&app->playlist.lock);
+};
+
+typedef struct ui_playlist_draw_item_desc
+{
+ GtkListStore *list_store;
+ instance_t* app;
+ int idx;
+} ui_playlist_draw_item_t;
+
+static gboolean ui_playlist_draw_item_iter
+(
+ GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer user_data
+)
+{
+ int i;
+ char tc1[12], tc2[12];
+ char ch[3];
+ ui_playlist_draw_item_t* item = (ui_playlist_draw_item_t*)user_data;
+ instance_t* app = item->app;
+
+ gtk_tree_model_get(model, iter, 7, &i, -1);
+
+ if(i != item->idx) return FALSE;
+
+ if(PLAYLIST_BLOCK_BEGIN & app->playlist.item[i].type)
+ snprintf(ch, sizeof(ch), "%c", 'A' + app->playlist.item[i].player);
+ else
+ ch[0] = 0;
+
+ gtk_list_store_set(item->list_store, iter,
+ 0, "",
+ 1, app->playlist.block_icons[app->playlist.item[i].type],
+ 2, ch,
+ 3, app->playlist.item[i].id,
+ 4, frames2tc(app->playlist.item[i].in, 25.0, tc1),
+ 5, frames2tc(app->playlist.item[i].dur, 25.0, tc2),
+ 6, app->playlist.item[i].title,
+ 7, i,
+ 8, (app->playlist.item[i].error != 0),
+ 9, (app->playlist.item[i].error & PLAYLIST_ITEM_ERROR_LIB)?"red":"orange",
+ -1 );
+
+ return TRUE;
+};
+
+void ui_playlist_draw_item(instance_t* app, int idx)
+{
+ GtkListStore *list_store;
+ ui_playlist_draw_item_t item;
+
+ list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(app->playlist_grid)));
+
+ pthread_mutex_lock(&app->playlist.lock);
+
+ item.idx = idx;
+ item.app = app;
+ item.list_store = list_store;
+ gtk_tree_model_foreach(GTK_TREE_MODEL(list_store), ui_playlist_draw_item_iter, &item);
+
+ pthread_mutex_unlock(&app->playlist.lock);
+};