relink funcionality added
[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 gtk_tree_view_set_grid_lines(GTK_TREE_VIEW(treeview), GTK_TREE_VIEW_GRID_LINES_BOTH);
136
137 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
138 gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
139
140 for(i = 0, count = 0; columns[i].title; i++, count++)
141 list_store_types[i] = (columns[i].type == G_TYPE_OBJECT)?GDK_TYPE_PIXBUF:columns[i].type;
142 list_store_types[count] = G_TYPE_INT;
143 list_store_types[count + 1] = G_TYPE_BOOLEAN;
144 list_store_types[count + 2] = G_TYPE_STRING;
145
146 list_store = gtk_list_store_newv(count + 3, list_store_types);
147
148 gtk_tree_view_set_model( GTK_TREE_VIEW( treeview ), GTK_TREE_MODEL( list_store ) );
149
150 for(i = 0; columns[i].title; i++)
151 {
152 char* prop;
153 column = NULL;
154
155 if(columns[i].type == G_TYPE_OBJECT)
156 {
157 renderer = gtk_cell_renderer_pixbuf_new();
158 gtk_cell_renderer_set_padding(renderer, 0, 0);
159 prop = "pixbuf";
160 }
161 else if(columns[i].type == G_TYPE_BOOLEAN)
162 {
163 renderer = gtk_cell_renderer_toggle_new();
164 prop = "active";
165 }
166 else
167 {
168 renderer = gtk_cell_renderer_text_new();
169 prop = "text";
170
171 column = gtk_tree_view_column_new_with_attributes(
172 columns[i].title, renderer,
173 prop, i,
174 "background-set", count + 1,
175 "background", count + 2,
176 NULL);
177 }
178
179 if(!column)
180 column = gtk_tree_view_column_new_with_attributes(
181 columns[i].title, renderer,
182 prop, i,
183 NULL);
184
185 gtk_tree_view_append_column(GTK_TREE_VIEW( treeview ), column);
186 };
187
188 g_object_unref(list_store);
189
190 GLADE_HOOKUP_OBJECT (top, treeview, name);
191
192 return treeview;
193 };
194
195 static GtkWidget* pane_library_grid(GtkWidget* top, omnplay_instance_t* app)
196 {
197 GtkWidget *scrolledwindow;
198
199 scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
200 gtk_widget_show (scrolledwindow);
201 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
202 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
203
204 gtk_container_add (GTK_CONTAINER (scrolledwindow),
205 app->library_grid = create_treeview(top, "treeview_library", library_columns));
206
207 return scrolledwindow;
208 }
209
210 static GtkWidget* pane_library_buttons(GtkWidget* top, omnplay_instance_t* app)
211 {
212 GtkWidget* hbox;
213
214 hbox = gtk_hbox_new (FALSE, 0);
215 gtk_widget_show (hbox);
216
217 /* playlist modify buttons */
218 gtk_box_pack_start (GTK_BOX (hbox),
219 ui_create_button(top, app, BUTTON_LIBRARY_ADD),
220 FALSE, FALSE, 0);
221 gtk_box_pack_start (GTK_BOX (hbox),
222 ui_create_button(top, app, BUTTON_LIBRARY_REFRESH),
223 FALSE, FALSE, 0);
224
225 /* spacer */
226 gtk_box_pack_start (GTK_BOX (hbox),
227 create_label(top, NULL, NULL, GTK_JUSTIFY_CENTER),
228 TRUE, TRUE, 0);
229
230 return hbox;
231 }
232
233 static GtkWidget* pane_library_search_buttons(GtkWidget* top, omnplay_instance_t* app)
234 {
235 GtkWidget* hbox;
236
237 hbox = gtk_hbox_new (FALSE, 0);
238 gtk_widget_show (hbox);
239
240 /* text entry */
241 gtk_box_pack_start (GTK_BOX (hbox),
242 app->library.search = gtk_entry_new(),
243 TRUE, TRUE, 0);
244 gtk_widget_show(app->library.search);
245
246 /* playlist modify buttons */
247 gtk_box_pack_start (GTK_BOX (hbox),
248 ui_create_button(top, app, BUTTON_LIBRARY_FIND),
249 FALSE, FALSE, 0);
250 gtk_box_pack_start (GTK_BOX (hbox),
251 ui_create_button(top, app, BUTTON_LIBRARY_FIND_NEXT),
252 FALSE, FALSE, 0);
253
254 return hbox;
255 }
256
257 static GtkWidget* pane_library(GtkWidget* top, omnplay_instance_t* app)
258 {
259 GtkWidget* vbox;
260
261 vbox = gtk_vbox_new (FALSE, 0);
262 gtk_widget_show (vbox);
263 gtk_widget_set_size_request(vbox, 300, -1);
264
265 /* add buttons box */
266 gtk_box_pack_start (GTK_BOX (vbox),
267 pane_library_buttons(top, app),
268 FALSE, FALSE, 0);
269
270 /* add grid */
271 gtk_box_pack_start (GTK_BOX (vbox),
272 pane_library_grid(top, app),
273 TRUE, TRUE, 0);
274
275 /* add search buttons */
276 gtk_box_pack_start (GTK_BOX (vbox),
277 pane_library_search_buttons(top, app),
278 FALSE, FALSE, 0);
279
280 return vbox;
281 }
282
283 static GtkWidget* create_channel_status(GtkWidget* top, omnplay_instance_t* app, int idx)
284 {
285 GtkWidget* vbox;
286 GtkWidget* hbox;
287 GtkWidget* frame;
288 char name[PATH_MAX];
289 omnplay_player_t* player;
290
291 player = &app->players.item[idx];
292
293 snprintf(name, sizeof(name), "%c [%s]", idx + 'A', player->name);
294
295 frame = gtk_frame_new(name);
296 gtk_widget_show(frame);
297
298 vbox = gtk_vbox_new(FALSE, 0);
299 gtk_container_add(GTK_CONTAINER(frame), vbox);
300 gtk_widget_show(vbox);
301
302 /* status label */
303 gtk_box_pack_start(GTK_BOX (vbox),
304 player->label_status = create_label(top, "OFFLINE", NULL, GTK_JUSTIFY_LEFT),
305 FALSE, FALSE, 0);
306
307 /* spacel label */
308 gtk_box_pack_start(GTK_BOX (vbox),
309 create_label(top, " ", NULL, GTK_JUSTIFY_CENTER),
310 FALSE, FALSE, 0);
311
312 /* clip label */
313 gtk_box_pack_start (GTK_BOX (vbox),
314 player->label_clip = create_label(top, "U0002323", NULL, GTK_JUSTIFY_LEFT),
315 FALSE, FALSE, 0);
316
317 /* block state/current timecode */
318 gtk_box_pack_start(GTK_BOX (vbox),
319 hbox = gtk_hbox_new(TRUE, 0),
320 FALSE, FALSE, 0);
321 gtk_widget_show(hbox);
322
323 {
324 /* clip state */
325 gtk_box_pack_start(GTK_BOX (hbox),
326 player->label_state = create_label(top, "PLAYING", NULL, GTK_JUSTIFY_LEFT),
327 TRUE, TRUE, 0);
328
329 /* current timecode */
330 gtk_box_pack_start(GTK_BOX (hbox),
331 player->label_tc_cur = create_label(top, "00:00:00:00", NULL, GTK_JUSTIFY_LEFT),
332 TRUE, TRUE, 0);
333 };
334
335 /* block remain label/remain timecode */
336 gtk_box_pack_start(GTK_BOX (vbox),
337 hbox = gtk_hbox_new(TRUE, 0),
338 FALSE, FALSE, 0);
339 gtk_widget_show (hbox);
340
341 {
342 /* label */
343 gtk_box_pack_start(GTK_BOX (hbox),
344 create_label(top, "remain:", NULL, GTK_JUSTIFY_LEFT),
345 TRUE, TRUE, 0);
346
347 /* remaining timecode */
348 gtk_box_pack_start(GTK_BOX (hbox),
349 player->label_tc_rem = create_label(top, "00:00:00:00", NULL, GTK_JUSTIFY_LEFT),
350 TRUE, TRUE, 0);
351 };
352
353 return frame;
354 }
355
356 static GtkWidget* pane_operate_status(GtkWidget* top, omnplay_instance_t* app)
357 {
358 int i;
359 GtkWidget* vbox;
360
361 vbox = gtk_vbox_new (FALSE, 0);
362 gtk_widget_show (vbox);
363 gtk_widget_set_size_request(vbox, 250, -1);
364
365 for(i = 0; i < app->players.count; i++)
366 {
367 gtk_box_pack_start (GTK_BOX (vbox),
368 create_channel_status(top, app, i),
369 FALSE, FALSE, 0);
370
371 /* spacer */
372 gtk_box_pack_start (GTK_BOX (vbox),
373 create_label(top, NULL, NULL, GTK_JUSTIFY_CENTER),
374 FALSE, FALSE, 0);
375 }
376
377 /* spacer */
378 gtk_box_pack_start (GTK_BOX (vbox),
379 create_label(top, NULL, NULL, GTK_JUSTIFY_CENTER),
380 TRUE, TRUE, 0);
381
382 return vbox;
383 }
384
385 static GtkWidget* pane_operate_buttons_playlist(GtkWidget* top, omnplay_instance_t* app)
386 {
387 GtkWidget* hbox;
388
389 hbox = gtk_hbox_new (FALSE, 0);
390 gtk_widget_show (hbox);
391
392 /* playlist load/save buttons */
393 gtk_box_pack_start (GTK_BOX (hbox),
394 ui_create_button(top, app, BUTTON_PLAYLIST_LOAD),
395 FALSE, FALSE, 0);
396 gtk_box_pack_start (GTK_BOX (hbox),
397 ui_create_button(top, app, BUTTON_PLAYLIST_SAVE),
398 FALSE, FALSE, 0);
399
400 /* spacer */
401 gtk_box_pack_start (GTK_BOX (hbox),
402 create_label(top, " ", NULL, GTK_JUSTIFY_CENTER),
403 FALSE, FALSE, 0);
404
405 /* playlist modify buttons */
406 gtk_box_pack_start (GTK_BOX (hbox),
407 ui_create_button(top, app, BUTTON_PLAYLIST_ITEM_ADD),
408 FALSE, FALSE, 0);
409 gtk_box_pack_start (GTK_BOX (hbox),
410 ui_create_button(top, app, BUTTON_PLAYLIST_ITEM_EDIT),
411 FALSE, FALSE, 0);
412 gtk_box_pack_start (GTK_BOX (hbox),
413 ui_create_button(top, app, BUTTON_PLAYLIST_ITEM_DEL),
414 FALSE, FALSE, 0);
415
416 /* spacer */
417 gtk_box_pack_start (GTK_BOX (hbox),
418 create_label(top, " ", NULL, GTK_JUSTIFY_CENTER),
419 FALSE, FALSE, 0);
420
421 /* playlist block buttons */
422 gtk_box_pack_start (GTK_BOX (hbox),
423 ui_create_button(top, app, BUTTON_PLAYLIST_BLOCK_SINGLE),
424 FALSE, FALSE, 0);
425 gtk_box_pack_start (GTK_BOX (hbox),
426 ui_create_button(top, app, BUTTON_PLAYLIST_BLOCK_LOOP),
427 FALSE, FALSE, 0);
428
429 /* spacer */
430 gtk_box_pack_start (GTK_BOX (hbox),
431 create_label(top, " ", NULL, GTK_JUSTIFY_CENTER),
432 FALSE, FALSE, 0);
433
434 /* playlist move items buttons */
435 gtk_box_pack_start (GTK_BOX (hbox),
436 ui_create_button(top, app, BUTTON_PLAYLIST_ITEM_UP),
437 FALSE, FALSE, 0);
438 gtk_box_pack_start (GTK_BOX (hbox),
439 ui_create_button(top, app, BUTTON_PLAYLIST_ITEM_DOWN),
440 FALSE, FALSE, 0);
441
442 /* spacer */
443 gtk_box_pack_start (GTK_BOX (hbox),
444 create_label(top, " ", NULL, GTK_JUSTIFY_CENTER),
445 FALSE, FALSE, 0);
446
447 /* playlist relink */
448 gtk_box_pack_start (GTK_BOX (hbox),
449 ui_create_button(top, app, BUTTON_PLAYLIST_RELINK),
450 FALSE, FALSE, 0);
451
452 return hbox;
453 }
454
455 static GtkWidget* pane_operate_grid(GtkWidget* top, omnplay_instance_t* app)
456 {
457 GtkWidget *scrolledwindow;
458
459 scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
460 gtk_widget_show (scrolledwindow);
461 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
462 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
463
464 gtk_container_add (GTK_CONTAINER (scrolledwindow),
465 app->playlist_grid = create_treeview(top, "treeview_playlist", playlist_columns));
466
467 return scrolledwindow;
468 }
469
470 static GtkWidget* pane_operate_buttons_operate(GtkWidget* top, omnplay_instance_t* app)
471 {
472 GtkWidget* hbox;
473
474 hbox = gtk_hbox_new (FALSE, 0);
475 gtk_widget_show (hbox);
476
477 /* spacer */
478 gtk_box_pack_start (GTK_BOX (hbox),
479 create_label(top, NULL, NULL, GTK_JUSTIFY_CENTER),
480 TRUE, TRUE, 0);
481
482 /* playlist modify buttons */
483 gtk_box_pack_start (GTK_BOX (hbox),
484 ui_create_button(top, app, BUTTON_PLAYER_CUE),
485 FALSE, FALSE, 0);
486 gtk_box_pack_start (GTK_BOX (hbox),
487 ui_create_button(top, app, BUTTON_PLAYER_PLAY),
488 FALSE, FALSE, 0);
489 gtk_box_pack_start (GTK_BOX (hbox),
490 ui_create_button(top, app, BUTTON_PLAYER_PAUSE),
491 FALSE, FALSE, 0);
492 gtk_box_pack_start (GTK_BOX (hbox),
493 ui_create_button(top, app, BUTTON_PLAYER_STOP),
494 FALSE, FALSE, 0);
495
496 /* spacer */
497 gtk_box_pack_start (GTK_BOX (hbox),
498 create_label(top, NULL, NULL, GTK_JUSTIFY_CENTER),
499 TRUE, TRUE, 0);
500
501 return hbox;
502 }
503
504 static GtkWidget* pane_operate_operate(GtkWidget* top, omnplay_instance_t* app)
505 {
506 GtkWidget* vbox;
507
508 vbox = gtk_vbox_new (FALSE, 0);
509 gtk_widget_show (vbox);
510
511 /* add buttons box #1 */
512 gtk_box_pack_start (GTK_BOX (vbox),
513 pane_operate_buttons_playlist(top, app),
514 FALSE, FALSE, 0);
515
516 /* add buttons box */
517 gtk_box_pack_start (GTK_BOX (vbox),
518 pane_operate_grid(top, app),
519 TRUE, TRUE, 0);
520
521 /* add buttons box #1 */
522 gtk_box_pack_start (GTK_BOX (vbox),
523 pane_operate_buttons_operate(top, app),
524 FALSE, FALSE, 0);
525
526 return vbox;
527
528 }
529
530 static GtkWidget* pane_operate(GtkWidget* top, omnplay_instance_t* app)
531 {
532 GtkWidget* hbox;
533
534 hbox = gtk_hbox_new (FALSE, 0);
535 gtk_widget_show (hbox);
536
537 /* add buttons box */
538 gtk_box_pack_start (GTK_BOX (hbox),
539 pane_operate_status(top, app),
540 FALSE, FALSE, 0);
541
542 /* add buttons box */
543 gtk_box_pack_start (GTK_BOX (hbox),
544 pane_operate_operate(top, app),
545 TRUE, TRUE, 0);
546
547 return hbox;
548
549 };
550
551 static GtkWidget* pane_top(GtkWidget* top, omnplay_instance_t* app)
552 {
553 GtkWidget* pane;
554
555 pane = gtk_hpaned_new ();
556 gtk_widget_show (pane);
557
558 gtk_paned_set_position (GTK_PANED (pane), 800);
559
560 gtk_paned_pack1 (GTK_PANED (pane),
561 pane_operate(top, app),
562 TRUE, FALSE);
563
564 gtk_paned_pack2 (GTK_PANED (pane),
565 pane_library(top, app),
566 FALSE, FALSE);
567
568 return pane;
569 }
570
571 GtkWidget* ui_omnplay (omnplay_instance_t* app)
572 {
573 GtkWidget *wnd;
574 GtkWidget* vbox;
575
576 wnd = gtk_window_new (GTK_WINDOW_TOPLEVEL);
577 GLADE_HOOKUP_OBJECT_NO_REF (wnd, wnd, "omnplay_window");
578
579 gtk_window_set_title (GTK_WINDOW (wnd), _("Omneon Player"));
580 gtk_window_set_default_size (GTK_WINDOW (wnd), 1024, 768);
581
582 vbox = gtk_vbox_new(FALSE, 0);
583 gtk_widget_show(vbox);
584
585 gtk_container_add(GTK_CONTAINER(wnd), vbox);
586
587 gtk_box_pack_start (GTK_BOX (vbox),
588 pane_top(wnd, app),
589 TRUE, TRUE, 0);
590 gtk_box_pack_start (GTK_BOX (vbox),
591 app->status_label = create_label(wnd, "omnplay started", NULL, GTK_JUSTIFY_LEFT),
592 FALSE, FALSE, 0);
593
594 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_BLOCK_BEGIN] =
595 create_pixbuf("block_type_block_start_16x16.png");
596 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_BLOCK_BODY] =
597 create_pixbuf("block_type_block_middle_16x16.png");
598 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_BLOCK_END] =
599 create_pixbuf("block_type_block_end_16x16.png");
600 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_BLOCK_SINGLE] =
601 create_pixbuf("block_type_block_single_16x16.png");
602 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_LOOP_BEGIN] =
603 create_pixbuf("block_type_loop_start_16x16.png");
604 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_LOOP_BODY] =
605 create_pixbuf("block_type_loop_middle_16x16.png");
606 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_LOOP_END] =
607 create_pixbuf("block_type_loop_end_16x16.png");
608 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_LOOP_SINGLE] =
609 create_pixbuf("block_type_block_loop_16x16.png");
610
611 return wnd;
612 }
613
614 int ui_playlist_item_dialog(omnplay_instance_t* app, playlist_item_t* item)
615 {
616 int r, c;
617 char tc[32];
618 GtkWidget *dlg;
619 gint response;
620 GtkWidget *box, *table;
621 GtkWidget *entry[4], *combo;
622
623 dlg = gtk_dialog_new_with_buttons(
624 "Playlist item",
625 GTK_WINDOW(app->window),
626 GTK_DIALOG_MODAL,
627 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
628 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
629 NULL);
630
631 box = gtk_dialog_get_content_area(GTK_DIALOG(dlg));
632
633 table = gtk_table_new(5, 2, TRUE);
634 gtk_widget_show(table);
635 gtk_box_pack_start(GTK_BOX(box), table, TRUE, TRUE, 0);
636
637 gtk_table_attach(GTK_TABLE(table),
638 create_label(NULL, "ID:", NULL, 0),
639 0, 1, 0, 1,
640 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
641
642 gtk_table_attach(GTK_TABLE(table),
643 create_label(NULL, "IN:", NULL, GTK_JUSTIFY_RIGHT),
644 0, 1, 1, 2,
645 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
646
647 gtk_table_attach(GTK_TABLE(table),
648 create_label(NULL, "DUR:", NULL, GTK_JUSTIFY_RIGHT),
649 0, 1, 2, 3,
650 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
651
652 gtk_table_attach(GTK_TABLE(table),
653 create_label(NULL, "TITLE:", NULL, GTK_JUSTIFY_RIGHT),
654 0, 1, 3, 4,
655 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
656
657 gtk_table_attach(GTK_TABLE(table),
658 create_label(NULL, "CHANNEL:", NULL, GTK_JUSTIFY_RIGHT),
659 0, 1, 4, 5,
660 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
661
662
663 gtk_table_attach(GTK_TABLE(table),
664 entry[0] = gtk_entry_new_with_max_length(32),
665 1, 2, 0, 1,
666 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
667
668 gtk_table_attach(GTK_TABLE(table),
669 entry[1] = gtk_entry_new_with_max_length(12),
670 1, 2, 1, 2,
671 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
672
673 gtk_table_attach(GTK_TABLE(table),
674 entry[2] = gtk_entry_new_with_max_length(12),
675 1, 2, 2, 3,
676 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
677
678 gtk_table_attach(GTK_TABLE(table),
679 entry[3] = gtk_entry_new_with_max_length(128),
680 1, 2, 3, 4,
681 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
682
683 gtk_table_attach(GTK_TABLE(table),
684 combo = gtk_combo_box_new_text(),
685 1, 2, 4, 5,
686 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
687
688
689 /* setup data */
690 gtk_entry_set_text(GTK_ENTRY(entry[0]), item->id);
691 gtk_entry_set_text(GTK_ENTRY(entry[1]), frames2tc(item->in, 25.0, tc));
692 gtk_entry_set_text(GTK_ENTRY(entry[2]), frames2tc(item->dur, 25.0, tc));
693 gtk_entry_set_text(GTK_ENTRY(entry[3]), item->title);
694 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "A");
695 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "B");
696 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "C");
697 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "D");
698 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), item->player);
699
700 gtk_widget_show_all(dlg);
701
702 /* Run dialog */
703 for(c = 1; c;)
704 {
705 response = gtk_dialog_run(GTK_DIALOG(dlg));
706
707 if( GTK_RESPONSE_REJECT == response ||
708 GTK_RESPONSE_DELETE_EVENT == response ||
709 GTK_RESPONSE_CANCEL == response)
710 {
711 r = 0;
712 c = 0;
713 }
714 else
715 {
716 r = 1;
717
718 /* get item data back */
719 strncpy(item->id, gtk_entry_get_text(GTK_ENTRY(entry[0])), PATH_MAX);
720 tc2frames((char*)gtk_entry_get_text(GTK_ENTRY(entry[1])), 25.0, &item->in);
721 tc2frames((char*)gtk_entry_get_text(GTK_ENTRY(entry[2])), 25.0, &item->dur);
722 strncpy(item->title, gtk_entry_get_text(GTK_ENTRY(entry[3])), PATH_MAX);
723 item->player = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
724
725 /* check if all data entered correctly */
726 if(item->id[0])
727 c = 0;
728 };
729 };
730
731 gtk_widget_hide(dlg);
732 gtk_widget_destroy(dlg);
733
734 return r;
735 };