drop library update window
[melted_gui] / src / ui.c
1 /*
2 * ui.c -- GTK+ 2 omnplay
3 * Copyright (C) 2011 Maksym Veremeyenko <verem@m1stereo.tv>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 #ifdef HAVE_CONFIG_H
21 # include <config.h>
22 #endif
23
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <unistd.h>
27 #include <string.h>
28 #include <stdio.h>
29
30 #include <gdk/gdkkeysyms.h>
31 #include <gtk/gtk.h>
32
33 #include "ui.h"
34 #include "ui_utils.h"
35 #include "ui_buttons.h"
36 #include "support.h"
37 #include "timecode.h"
38
39 typedef struct column_desc
40 {
41 char* title;
42 GType type;
43 } column_desc_t;
44
45 static const column_desc_t playlist_columns[] =
46 {
47 {
48 "REM",
49 G_TYPE_STRING
50 },
51 {
52 "B",
53 G_TYPE_OBJECT
54 },
55 {
56 "CH",
57 G_TYPE_STRING
58 },
59 {
60 "ID",
61 G_TYPE_STRING
62 },
63 {
64 "IN",
65 G_TYPE_STRING
66 },
67 {
68 "DUR",
69 G_TYPE_STRING
70 },
71 {
72 "TITLE",
73 G_TYPE_STRING
74 },
75 {
76 NULL,
77 G_TYPE_STRING
78 }
79 };
80
81 const static column_desc_t library_columns[] =
82 {
83 {
84 "ID",
85 G_TYPE_STRING
86 },
87 {
88 "DUR",
89 G_TYPE_STRING
90 },
91 {
92 "TITLE",
93 G_TYPE_STRING
94 },
95 {
96 NULL,
97 G_TYPE_STRING
98 }
99 };
100
101
102 static GtkWidget* create_label(GtkWidget* top, char* text, char* reg, GtkJustification jtype)
103 {
104 GtkWidget* label;
105
106 label = gtk_label_new ("");
107 gtk_widget_show (label);
108
109 if(jtype)
110 gtk_label_set_justify (GTK_LABEL (label), jtype);
111
112 if(reg)
113 GLADE_HOOKUP_OBJECT (top, label, reg);
114
115 if(text)
116 gtk_label_set_text(GTK_LABEL (label), text);
117
118 return label;
119 };
120
121 static GtkWidget* create_treeview(GtkWidget* top, char* name, const column_desc_t columns[])
122 {
123 int i, count;
124
125 GtkWidget *treeview;
126 GtkTreeSelection *selection;
127 GtkCellRenderer *renderer;
128 GtkTreeViewColumn *column;
129 GtkListStore *list_store;
130 GType list_store_types[32];
131
132 treeview = gtk_tree_view_new ();
133 gtk_widget_show (treeview);
134 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE);
135
136 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
137 gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
138
139 for(i = 0, count = 0; columns[i].title; i++, count++)
140 list_store_types[i] = (columns[i].type == G_TYPE_OBJECT)?GDK_TYPE_PIXBUF:columns[i].type;
141 list_store_types[count] = G_TYPE_INT;
142 list_store_types[count + 1] = G_TYPE_BOOLEAN;
143 list_store_types[count + 2] = G_TYPE_STRING;
144
145 list_store = gtk_list_store_newv(count + 3, list_store_types);
146
147 gtk_tree_view_set_model( GTK_TREE_VIEW( treeview ), GTK_TREE_MODEL( list_store ) );
148
149 for(i = 0; columns[i].title; i++)
150 {
151 char* prop;
152 column = NULL;
153
154 if(columns[i].type == G_TYPE_OBJECT)
155 {
156 renderer = gtk_cell_renderer_pixbuf_new();
157 gtk_cell_renderer_set_padding(renderer, 0, 0);
158 prop = "pixbuf";
159 }
160 else if(columns[i].type == G_TYPE_BOOLEAN)
161 {
162 renderer = gtk_cell_renderer_toggle_new();
163 prop = "active";
164 }
165 else
166 {
167 renderer = gtk_cell_renderer_text_new();
168 prop = "text";
169
170 column = gtk_tree_view_column_new_with_attributes(
171 columns[i].title, renderer,
172 prop, i,
173 "background-set", count + 1,
174 "background", count + 2,
175 NULL);
176 }
177
178 if(!column)
179 column = gtk_tree_view_column_new_with_attributes(
180 columns[i].title, renderer,
181 prop, i,
182 NULL);
183
184 gtk_tree_view_append_column(GTK_TREE_VIEW( treeview ), column);
185 };
186
187 g_object_unref(list_store);
188
189 GLADE_HOOKUP_OBJECT (top, treeview, name);
190
191 return treeview;
192 };
193
194 static GtkWidget* pane_library_grid(GtkWidget* top, omnplay_instance_t* app)
195 {
196 GtkWidget *scrolledwindow;
197
198 scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
199 gtk_widget_show (scrolledwindow);
200 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
201 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
202
203 gtk_container_add (GTK_CONTAINER (scrolledwindow),
204 app->library_grid = create_treeview(top, "treeview_library", library_columns));
205
206 return scrolledwindow;
207 }
208
209 static GtkWidget* pane_library_buttons(GtkWidget* top, omnplay_instance_t* app)
210 {
211 GtkWidget* hbox;
212
213 hbox = gtk_hbox_new (FALSE, 0);
214 gtk_widget_show (hbox);
215
216 /* playlist modify buttons */
217 gtk_box_pack_start (GTK_BOX (hbox),
218 ui_create_button(top, app, BUTTON_LIBRARY_ADD),
219 FALSE, FALSE, 0);
220 gtk_box_pack_start (GTK_BOX (hbox),
221 ui_create_button(top, app, BUTTON_LIBRARY_REFRESH),
222 FALSE, FALSE, 0);
223
224 /* spacer */
225 gtk_box_pack_start (GTK_BOX (hbox),
226 create_label(top, NULL, NULL, GTK_JUSTIFY_CENTER),
227 TRUE, TRUE, 0);
228
229 return hbox;
230 }
231
232 static GtkWidget* pane_library_search_buttons(GtkWidget* top, omnplay_instance_t* app)
233 {
234 GtkWidget* hbox;
235
236 hbox = gtk_hbox_new (FALSE, 0);
237 gtk_widget_show (hbox);
238
239 /* text entry */
240 gtk_box_pack_start (GTK_BOX (hbox),
241 app->library.search = gtk_entry_new(),
242 TRUE, TRUE, 0);
243 gtk_widget_show(app->library.search);
244
245 /* playlist modify buttons */
246 gtk_box_pack_start (GTK_BOX (hbox),
247 ui_create_button(top, app, BUTTON_LIBRARY_FIND),
248 FALSE, FALSE, 0);
249 gtk_box_pack_start (GTK_BOX (hbox),
250 ui_create_button(top, app, BUTTON_LIBRARY_FIND_NEXT),
251 FALSE, FALSE, 0);
252
253 return hbox;
254 }
255
256 static GtkWidget* pane_library(GtkWidget* top, omnplay_instance_t* app)
257 {
258 GtkWidget* vbox;
259
260 vbox = gtk_vbox_new (FALSE, 0);
261 gtk_widget_show (vbox);
262 gtk_widget_set_size_request(vbox, 300, -1);
263
264 /* add buttons box */
265 gtk_box_pack_start (GTK_BOX (vbox),
266 pane_library_buttons(top, app),
267 FALSE, FALSE, 0);
268
269 /* add grid */
270 gtk_box_pack_start (GTK_BOX (vbox),
271 pane_library_grid(top, app),
272 TRUE, TRUE, 0);
273
274 /* add search buttons */
275 gtk_box_pack_start (GTK_BOX (vbox),
276 pane_library_search_buttons(top, app),
277 FALSE, FALSE, 0);
278
279 return vbox;
280 }
281
282 static GtkWidget* create_channel_status(GtkWidget* top, omnplay_instance_t* app, int idx)
283 {
284 GtkWidget* vbox;
285 GtkWidget* hbox;
286 GtkWidget* frame;
287 char name[PATH_MAX];
288 omnplay_player_t* player;
289
290 player = &app->players.item[idx];
291
292 snprintf(name, sizeof(name), "%c [%s]", idx + 'A', player->name);
293
294 frame = gtk_frame_new(name);
295 gtk_widget_show(frame);
296
297 vbox = gtk_vbox_new(FALSE, 0);
298 gtk_container_add(GTK_CONTAINER(frame), vbox);
299 gtk_widget_show(vbox);
300
301 /* status label */
302 gtk_box_pack_start(GTK_BOX (vbox),
303 player->label_status = create_label(top, "OFFLINE", NULL, GTK_JUSTIFY_LEFT),
304 FALSE, FALSE, 0);
305
306 /* spacel label */
307 gtk_box_pack_start(GTK_BOX (vbox),
308 create_label(top, " ", NULL, GTK_JUSTIFY_CENTER),
309 FALSE, FALSE, 0);
310
311 /* clip label */
312 gtk_box_pack_start (GTK_BOX (vbox),
313 player->label_clip = create_label(top, "U0002323", NULL, GTK_JUSTIFY_LEFT),
314 FALSE, FALSE, 0);
315
316 /* block state/current timecode */
317 gtk_box_pack_start(GTK_BOX (vbox),
318 hbox = gtk_hbox_new(TRUE, 0),
319 FALSE, FALSE, 0);
320 gtk_widget_show(hbox);
321
322 {
323 /* clip state */
324 gtk_box_pack_start(GTK_BOX (hbox),
325 player->label_state = create_label(top, "PLAYING", NULL, GTK_JUSTIFY_LEFT),
326 TRUE, TRUE, 0);
327
328 /* current timecode */
329 gtk_box_pack_start(GTK_BOX (hbox),
330 player->label_tc_cur = create_label(top, "00:00:00:00", NULL, GTK_JUSTIFY_LEFT),
331 TRUE, TRUE, 0);
332 };
333
334 /* block remain label/remain timecode */
335 gtk_box_pack_start(GTK_BOX (vbox),
336 hbox = gtk_hbox_new(TRUE, 0),
337 FALSE, FALSE, 0);
338 gtk_widget_show (hbox);
339
340 {
341 /* label */
342 gtk_box_pack_start(GTK_BOX (hbox),
343 create_label(top, "remain:", NULL, GTK_JUSTIFY_LEFT),
344 TRUE, TRUE, 0);
345
346 /* remaining timecode */
347 gtk_box_pack_start(GTK_BOX (hbox),
348 player->label_tc_rem = create_label(top, "00:00:00:00", NULL, GTK_JUSTIFY_LEFT),
349 TRUE, TRUE, 0);
350 };
351
352 return frame;
353 }
354
355 static GtkWidget* pane_operate_status(GtkWidget* top, omnplay_instance_t* app)
356 {
357 int i;
358 GtkWidget* vbox;
359
360 vbox = gtk_vbox_new (FALSE, 0);
361 gtk_widget_show (vbox);
362 gtk_widget_set_size_request(vbox, 250, -1);
363
364 for(i = 0; i < app->players.count; i++)
365 {
366 gtk_box_pack_start (GTK_BOX (vbox),
367 create_channel_status(top, app, i),
368 FALSE, FALSE, 0);
369
370 /* spacer */
371 gtk_box_pack_start (GTK_BOX (vbox),
372 create_label(top, NULL, NULL, GTK_JUSTIFY_CENTER),
373 FALSE, FALSE, 0);
374 }
375
376 /* spacer */
377 gtk_box_pack_start (GTK_BOX (vbox),
378 create_label(top, NULL, NULL, GTK_JUSTIFY_CENTER),
379 TRUE, TRUE, 0);
380
381 return vbox;
382 }
383
384 static GtkWidget* pane_operate_buttons_playlist(GtkWidget* top, omnplay_instance_t* app)
385 {
386 GtkWidget* hbox;
387
388 hbox = gtk_hbox_new (FALSE, 0);
389 gtk_widget_show (hbox);
390
391 /* playlist load/save buttons */
392 gtk_box_pack_start (GTK_BOX (hbox),
393 ui_create_button(top, app, BUTTON_PLAYLIST_LOAD),
394 FALSE, FALSE, 0);
395 gtk_box_pack_start (GTK_BOX (hbox),
396 ui_create_button(top, app, BUTTON_PLAYLIST_SAVE),
397 FALSE, FALSE, 0);
398
399 /* spacer */
400 gtk_box_pack_start (GTK_BOX (hbox),
401 create_label(top, " ", NULL, GTK_JUSTIFY_CENTER),
402 FALSE, FALSE, 0);
403
404 /* playlist modify buttons */
405 gtk_box_pack_start (GTK_BOX (hbox),
406 ui_create_button(top, app, BUTTON_PLAYLIST_ITEM_ADD),
407 FALSE, FALSE, 0);
408 gtk_box_pack_start (GTK_BOX (hbox),
409 ui_create_button(top, app, BUTTON_PLAYLIST_ITEM_EDIT),
410 FALSE, FALSE, 0);
411 gtk_box_pack_start (GTK_BOX (hbox),
412 ui_create_button(top, app, BUTTON_PLAYLIST_ITEM_DEL),
413 FALSE, FALSE, 0);
414
415 /* spacer */
416 gtk_box_pack_start (GTK_BOX (hbox),
417 create_label(top, " ", NULL, GTK_JUSTIFY_CENTER),
418 FALSE, FALSE, 0);
419
420 /* playlist block buttons */
421 gtk_box_pack_start (GTK_BOX (hbox),
422 ui_create_button(top, app, BUTTON_PLAYLIST_BLOCK_SINGLE),
423 FALSE, FALSE, 0);
424 gtk_box_pack_start (GTK_BOX (hbox),
425 ui_create_button(top, app, BUTTON_PLAYLIST_BLOCK_LOOP),
426 FALSE, FALSE, 0);
427
428 /* spacer */
429 gtk_box_pack_start (GTK_BOX (hbox),
430 create_label(top, " ", NULL, GTK_JUSTIFY_CENTER),
431 FALSE, FALSE, 0);
432
433 /* playlist move items buttons */
434 gtk_box_pack_start (GTK_BOX (hbox),
435 ui_create_button(top, app, BUTTON_PLAYLIST_ITEM_UP),
436 FALSE, FALSE, 0);
437 gtk_box_pack_start (GTK_BOX (hbox),
438 ui_create_button(top, app, BUTTON_PLAYLIST_ITEM_DOWN),
439 FALSE, FALSE, 0);
440
441 return hbox;
442 }
443
444 static GtkWidget* pane_operate_grid(GtkWidget* top, omnplay_instance_t* app)
445 {
446 GtkWidget *scrolledwindow;
447
448 scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
449 gtk_widget_show (scrolledwindow);
450 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
451 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
452
453 gtk_container_add (GTK_CONTAINER (scrolledwindow),
454 app->playlist_grid = create_treeview(top, "treeview_playlist", playlist_columns));
455
456 return scrolledwindow;
457 }
458
459 static GtkWidget* pane_operate_buttons_operate(GtkWidget* top, omnplay_instance_t* app)
460 {
461 GtkWidget* hbox;
462
463 hbox = gtk_hbox_new (FALSE, 0);
464 gtk_widget_show (hbox);
465
466 /* spacer */
467 gtk_box_pack_start (GTK_BOX (hbox),
468 create_label(top, NULL, NULL, GTK_JUSTIFY_CENTER),
469 TRUE, TRUE, 0);
470
471 /* playlist modify buttons */
472 gtk_box_pack_start (GTK_BOX (hbox),
473 ui_create_button(top, app, BUTTON_PLAYER_CUE),
474 FALSE, FALSE, 0);
475 gtk_box_pack_start (GTK_BOX (hbox),
476 ui_create_button(top, app, BUTTON_PLAYER_PLAY),
477 FALSE, FALSE, 0);
478 gtk_box_pack_start (GTK_BOX (hbox),
479 ui_create_button(top, app, BUTTON_PLAYER_PAUSE),
480 FALSE, FALSE, 0);
481 gtk_box_pack_start (GTK_BOX (hbox),
482 ui_create_button(top, app, BUTTON_PLAYER_STOP),
483 FALSE, FALSE, 0);
484
485 /* spacer */
486 gtk_box_pack_start (GTK_BOX (hbox),
487 create_label(top, NULL, NULL, GTK_JUSTIFY_CENTER),
488 TRUE, TRUE, 0);
489
490 return hbox;
491 }
492
493 static GtkWidget* pane_operate_operate(GtkWidget* top, omnplay_instance_t* app)
494 {
495 GtkWidget* vbox;
496
497 vbox = gtk_vbox_new (FALSE, 0);
498 gtk_widget_show (vbox);
499
500 /* add buttons box #1 */
501 gtk_box_pack_start (GTK_BOX (vbox),
502 pane_operate_buttons_playlist(top, app),
503 FALSE, FALSE, 0);
504
505 /* add buttons box */
506 gtk_box_pack_start (GTK_BOX (vbox),
507 pane_operate_grid(top, app),
508 TRUE, TRUE, 0);
509
510 /* add buttons box #1 */
511 gtk_box_pack_start (GTK_BOX (vbox),
512 pane_operate_buttons_operate(top, app),
513 FALSE, FALSE, 0);
514
515 return vbox;
516
517 }
518
519 static GtkWidget* pane_operate(GtkWidget* top, omnplay_instance_t* app)
520 {
521 GtkWidget* hbox;
522
523 hbox = gtk_hbox_new (FALSE, 0);
524 gtk_widget_show (hbox);
525
526 /* add buttons box */
527 gtk_box_pack_start (GTK_BOX (hbox),
528 pane_operate_status(top, app),
529 FALSE, FALSE, 0);
530
531 /* add buttons box */
532 gtk_box_pack_start (GTK_BOX (hbox),
533 pane_operate_operate(top, app),
534 TRUE, TRUE, 0);
535
536 return hbox;
537
538 };
539
540 static GtkWidget* pane_top(GtkWidget* top, omnplay_instance_t* app)
541 {
542 GtkWidget* pane;
543
544 pane = gtk_hpaned_new ();
545 gtk_widget_show (pane);
546
547 gtk_paned_set_position (GTK_PANED (pane), 800);
548
549 gtk_paned_pack1 (GTK_PANED (pane),
550 pane_operate(top, app),
551 TRUE, FALSE);
552
553 gtk_paned_pack2 (GTK_PANED (pane),
554 pane_library(top, app),
555 FALSE, FALSE);
556
557 return pane;
558 }
559
560 GtkWidget* ui_omnplay (omnplay_instance_t* app)
561 {
562 GtkWidget *wnd;
563
564 wnd = gtk_window_new (GTK_WINDOW_TOPLEVEL);
565 GLADE_HOOKUP_OBJECT_NO_REF (wnd, wnd, "omnplay_window");
566
567 gtk_window_set_title (GTK_WINDOW (wnd), _("Omneon Player"));
568 gtk_window_set_default_size (GTK_WINDOW (wnd), 1024, 768);
569
570 gtk_container_add (GTK_CONTAINER (wnd),
571 pane_top(wnd, app));
572
573 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_BLOCK_BEGIN] =
574 create_pixbuf("block_type_block_start_16x16.png");
575 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_BLOCK_BODY] =
576 create_pixbuf("block_type_block_middle_16x16.png");
577 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_BLOCK_END] =
578 create_pixbuf("block_type_block_end_16x16.png");
579 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_BLOCK_SINGLE] =
580 create_pixbuf("block_type_block_single_16x16.png");
581 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_LOOP_BEGIN] =
582 create_pixbuf("block_type_loop_start_16x16.png");
583 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_LOOP_BODY] =
584 create_pixbuf("block_type_loop_middle_16x16.png");
585 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_LOOP_END] =
586 create_pixbuf("block_type_loop_end_16x16.png");
587 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_LOOP_SINGLE] =
588 create_pixbuf("block_type_block_loop_16x16.png");
589
590 return wnd;
591 }
592
593 int ui_playlist_item_dialog(omnplay_instance_t* app, playlist_item_t* item)
594 {
595 int r, c;
596 char tc[32];
597 GtkWidget *dlg;
598 gint response;
599 GtkWidget *box, *table;
600 GtkWidget *entry[4], *combo;
601
602 dlg = gtk_dialog_new_with_buttons(
603 "Playlist item",
604 GTK_WINDOW(app->window),
605 GTK_DIALOG_MODAL,
606 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
607 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
608 NULL);
609
610 box = gtk_dialog_get_content_area(GTK_DIALOG(dlg));
611
612 table = gtk_table_new(5, 2, TRUE);
613 gtk_widget_show(table);
614 gtk_box_pack_start(GTK_BOX(box), table, TRUE, TRUE, 0);
615
616 gtk_table_attach(GTK_TABLE(table),
617 create_label(NULL, "ID:", NULL, 0),
618 0, 1, 0, 1,
619 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
620
621 gtk_table_attach(GTK_TABLE(table),
622 create_label(NULL, "IN:", NULL, GTK_JUSTIFY_RIGHT),
623 0, 1, 1, 2,
624 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
625
626 gtk_table_attach(GTK_TABLE(table),
627 create_label(NULL, "DUR:", NULL, GTK_JUSTIFY_RIGHT),
628 0, 1, 2, 3,
629 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
630
631 gtk_table_attach(GTK_TABLE(table),
632 create_label(NULL, "TITLE:", NULL, GTK_JUSTIFY_RIGHT),
633 0, 1, 3, 4,
634 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
635
636 gtk_table_attach(GTK_TABLE(table),
637 create_label(NULL, "CHANNEL:", NULL, GTK_JUSTIFY_RIGHT),
638 0, 1, 4, 5,
639 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
640
641
642 gtk_table_attach(GTK_TABLE(table),
643 entry[0] = gtk_entry_new_with_max_length(32),
644 1, 2, 0, 1,
645 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
646
647 gtk_table_attach(GTK_TABLE(table),
648 entry[1] = gtk_entry_new_with_max_length(12),
649 1, 2, 1, 2,
650 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
651
652 gtk_table_attach(GTK_TABLE(table),
653 entry[2] = gtk_entry_new_with_max_length(12),
654 1, 2, 2, 3,
655 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
656
657 gtk_table_attach(GTK_TABLE(table),
658 entry[3] = gtk_entry_new_with_max_length(128),
659 1, 2, 3, 4,
660 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
661
662 gtk_table_attach(GTK_TABLE(table),
663 combo = gtk_combo_box_new_text(),
664 1, 2, 4, 5,
665 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
666
667
668 /* setup data */
669 gtk_entry_set_text(GTK_ENTRY(entry[0]), item->id);
670 gtk_entry_set_text(GTK_ENTRY(entry[1]), frames2tc(item->in, 25.0, tc));
671 gtk_entry_set_text(GTK_ENTRY(entry[2]), frames2tc(item->dur, 25.0, tc));
672 gtk_entry_set_text(GTK_ENTRY(entry[3]), item->title);
673 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "A");
674 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "B");
675 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "C");
676 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "D");
677 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), item->player);
678
679 gtk_widget_show_all(dlg);
680
681 /* Run dialog */
682 for(c = 1; c;)
683 {
684 response = gtk_dialog_run(GTK_DIALOG(dlg));
685
686 if( GTK_RESPONSE_REJECT == response ||
687 GTK_RESPONSE_DELETE_EVENT == response ||
688 GTK_RESPONSE_CANCEL == response)
689 {
690 r = 0;
691 c = 0;
692 }
693 else
694 {
695 r = 1;
696
697 /* get item data back */
698 strncpy(item->id, gtk_entry_get_text(GTK_ENTRY(entry[0])), PATH_MAX);
699 tc2frames((char*)gtk_entry_get_text(GTK_ENTRY(entry[1])), 25.0, &item->in);
700 tc2frames((char*)gtk_entry_get_text(GTK_ENTRY(entry[2])), 25.0, &item->dur);
701 strncpy(item->title, gtk_entry_get_text(GTK_ENTRY(entry[3])), PATH_MAX);
702 item->player = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
703
704 /* check if all data entered correctly */
705 if(item->id[0])
706 c = 0;
707 };
708 };
709
710 gtk_widget_hide(dlg);
711 gtk_widget_destroy(dlg);
712
713 return r;
714 };