X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fui.c;h=988561b557d7c2390bea8ad640fe5b3d7e26a9c0;hb=ee9061a5a0c2551a337d809c7040ec5790b10e0d;hp=bdd95b061a95b0f88e88e58ddc8f2b4195f1e4c3;hpb=f39680e42b24782f65c14c18d2f05df174330af8;p=melted_gui diff --git a/src/ui.c b/src/ui.c index bdd95b0..988561b 100644 --- a/src/ui.c +++ b/src/ui.c @@ -34,6 +34,7 @@ #include "ui_utils.h" #include "ui_buttons.h" #include "support.h" +#include "timecode.h" typedef struct column_desc { @@ -105,7 +106,8 @@ static GtkWidget* create_label(GtkWidget* top, char* text, char* reg, GtkJustifi label = gtk_label_new (""); gtk_widget_show (label); - gtk_label_set_justify (GTK_LABEL (label), jtype); + if(jtype) + gtk_label_set_justify (GTK_LABEL (label), jtype); if(reg) GLADE_HOOKUP_OBJECT (top, label, reg); @@ -121,6 +123,7 @@ static GtkWidget* create_treeview(GtkWidget* top, char* name, const column_desc_ int i, count; GtkWidget *treeview; + GtkTreeSelection *selection; GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkListStore *list_store; @@ -128,18 +131,25 @@ static GtkWidget* create_treeview(GtkWidget* top, char* name, const column_desc_ treeview = gtk_tree_view_new (); gtk_widget_show (treeview); + gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); + + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); + gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); for(i = 0, count = 0; columns[i].title; i++, count++) list_store_types[i] = (columns[i].type == G_TYPE_OBJECT)?GDK_TYPE_PIXBUF:columns[i].type; list_store_types[count] = G_TYPE_INT; + list_store_types[count + 1] = G_TYPE_BOOLEAN; + list_store_types[count + 2] = G_TYPE_STRING; - list_store = gtk_list_store_newv(count + 1, list_store_types); + list_store = gtk_list_store_newv(count + 3, list_store_types); gtk_tree_view_set_model( GTK_TREE_VIEW( treeview ), GTK_TREE_MODEL( list_store ) ); for(i = 0; columns[i].title; i++) { char* prop; + column = NULL; if(columns[i].type == G_TYPE_OBJECT) { @@ -156,10 +166,21 @@ static GtkWidget* create_treeview(GtkWidget* top, char* name, const column_desc_ { renderer = gtk_cell_renderer_text_new(); prop = "text"; + + column = gtk_tree_view_column_new_with_attributes( + columns[i].title, renderer, + prop, i, + "background-set", count + 1, + "background", count + 2, + NULL); } - column = gtk_tree_view_column_new_with_attributes( - columns[i].title, renderer, prop, i, NULL); + if(!column) + column = gtk_tree_view_column_new_with_attributes( + columns[i].title, renderer, + prop, i, + NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW( treeview ), column); }; @@ -536,3 +557,126 @@ GtkWidget* ui_omnplay (omnplay_instance_t* app) return wnd; } + +int ui_playlist_item_dialog(omnplay_instance_t* app, playlist_item_t* item) +{ + int r, c; + char tc[32]; + GtkWidget *dlg; + gint response; + GtkWidget *box, *table; + GtkWidget *entry[4], *combo; + + dlg = gtk_dialog_new_with_buttons( + "Playlist item", + GTK_WINDOW(app->window), + GTK_DIALOG_MODAL, + GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, + NULL); + + box = gtk_dialog_get_content_area(GTK_DIALOG(dlg)); + + table = gtk_table_new(5, 2, TRUE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(box), table, TRUE, TRUE, 0); + + gtk_table_attach(GTK_TABLE(table), + create_label(NULL, "ID:", NULL, 0), + 0, 1, 0, 1, + GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5); + + gtk_table_attach(GTK_TABLE(table), + create_label(NULL, "IN:", NULL, GTK_JUSTIFY_RIGHT), + 0, 1, 1, 2, + GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5); + + gtk_table_attach(GTK_TABLE(table), + create_label(NULL, "DUR:", NULL, GTK_JUSTIFY_RIGHT), + 0, 1, 2, 3, + GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5); + + gtk_table_attach(GTK_TABLE(table), + create_label(NULL, "TITLE:", NULL, GTK_JUSTIFY_RIGHT), + 0, 1, 3, 4, + GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5); + + gtk_table_attach(GTK_TABLE(table), + create_label(NULL, "CHANNEL:", NULL, GTK_JUSTIFY_RIGHT), + 0, 1, 4, 5, + GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5); + + + gtk_table_attach(GTK_TABLE(table), + entry[0] = gtk_entry_new_with_max_length(32), + 1, 2, 0, 1, + GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5); + + gtk_table_attach(GTK_TABLE(table), + entry[1] = gtk_entry_new_with_max_length(12), + 1, 2, 1, 2, + GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5); + + gtk_table_attach(GTK_TABLE(table), + entry[2] = gtk_entry_new_with_max_length(12), + 1, 2, 2, 3, + GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5); + + gtk_table_attach(GTK_TABLE(table), + entry[3] = gtk_entry_new_with_max_length(128), + 1, 2, 3, 4, + GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5); + + gtk_table_attach(GTK_TABLE(table), + combo = gtk_combo_box_new_text(), + 1, 2, 4, 5, + GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5); + + + /* setup data */ + gtk_entry_set_text(GTK_ENTRY(entry[0]), item->id); + gtk_entry_set_text(GTK_ENTRY(entry[1]), frames2tc(item->in, 25.0, tc)); + gtk_entry_set_text(GTK_ENTRY(entry[2]), frames2tc(item->dur, 25.0, tc)); + gtk_entry_set_text(GTK_ENTRY(entry[3]), item->title); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "A"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "B"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "C"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "D"); + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), item->player); + + gtk_widget_show_all(dlg); + + /* Run dialog */ + for(c = 1; c;) + { + response = gtk_dialog_run(GTK_DIALOG(dlg)); + + if( GTK_RESPONSE_REJECT == response || + GTK_RESPONSE_DELETE_EVENT == response || + GTK_RESPONSE_CANCEL == response) + { + r = 0; + c = 0; + } + else + { + r = 1; + + /* get item data back */ + strncpy(item->id, gtk_entry_get_text(GTK_ENTRY(entry[0])), PATH_MAX); + tc2frames((char*)gtk_entry_get_text(GTK_ENTRY(entry[1])), 25.0, &item->in); + tc2frames((char*)gtk_entry_get_text(GTK_ENTRY(entry[2])), 25.0, &item->dur); + strncpy(item->title, gtk_entry_get_text(GTK_ENTRY(entry[3])), PATH_MAX); + item->player = gtk_combo_box_get_active(GTK_COMBO_BOX(combo)); + + /* check if all data entered correctly */ + if(item->id[0]) + c = 0; + }; + }; + + gtk_widget_hide(dlg); + gtk_widget_destroy(dlg); + + return r; +};