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