add a extension to filename on saving
[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 return hbox;
443 }
444
445 static GtkWidget* pane_operate_grid(GtkWidget* top, omnplay_instance_t* app)
446 {
447 GtkWidget *scrolledwindow;
448
449 scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
450 gtk_widget_show (scrolledwindow);
451 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
452 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
453
454 gtk_container_add (GTK_CONTAINER (scrolledwindow),
455 app->playlist_grid = create_treeview(top, "treeview_playlist", playlist_columns));
456
457 return scrolledwindow;
458 }
459
460 static GtkWidget* pane_operate_buttons_operate(GtkWidget* top, omnplay_instance_t* app)
461 {
462 GtkWidget* hbox;
463
464 hbox = gtk_hbox_new (FALSE, 0);
465 gtk_widget_show (hbox);
466
467 /* spacer */
468 gtk_box_pack_start (GTK_BOX (hbox),
469 create_label(top, NULL, NULL, GTK_JUSTIFY_CENTER),
470 TRUE, TRUE, 0);
471
472 /* playlist modify buttons */
473 gtk_box_pack_start (GTK_BOX (hbox),
474 ui_create_button(top, app, BUTTON_PLAYER_CUE),
475 FALSE, FALSE, 0);
476 gtk_box_pack_start (GTK_BOX (hbox),
477 ui_create_button(top, app, BUTTON_PLAYER_PLAY),
478 FALSE, FALSE, 0);
479 gtk_box_pack_start (GTK_BOX (hbox),
480 ui_create_button(top, app, BUTTON_PLAYER_PAUSE),
481 FALSE, FALSE, 0);
482 gtk_box_pack_start (GTK_BOX (hbox),
483 ui_create_button(top, app, BUTTON_PLAYER_STOP),
484 FALSE, FALSE, 0);
485
486 /* spacer */
487 gtk_box_pack_start (GTK_BOX (hbox),
488 create_label(top, NULL, NULL, GTK_JUSTIFY_CENTER),
489 TRUE, TRUE, 0);
490
491 return hbox;
492 }
493
494 static GtkWidget* pane_operate_operate(GtkWidget* top, omnplay_instance_t* app)
495 {
496 GtkWidget* vbox;
497
498 vbox = gtk_vbox_new (FALSE, 0);
499 gtk_widget_show (vbox);
500
501 /* add buttons box #1 */
502 gtk_box_pack_start (GTK_BOX (vbox),
503 pane_operate_buttons_playlist(top, app),
504 FALSE, FALSE, 0);
505
506 /* add buttons box */
507 gtk_box_pack_start (GTK_BOX (vbox),
508 pane_operate_grid(top, app),
509 TRUE, TRUE, 0);
510
511 /* add buttons box #1 */
512 gtk_box_pack_start (GTK_BOX (vbox),
513 pane_operate_buttons_operate(top, app),
514 FALSE, FALSE, 0);
515
516 return vbox;
517
518 }
519
520 static GtkWidget* pane_operate(GtkWidget* top, omnplay_instance_t* app)
521 {
522 GtkWidget* hbox;
523
524 hbox = gtk_hbox_new (FALSE, 0);
525 gtk_widget_show (hbox);
526
527 /* add buttons box */
528 gtk_box_pack_start (GTK_BOX (hbox),
529 pane_operate_status(top, app),
530 FALSE, FALSE, 0);
531
532 /* add buttons box */
533 gtk_box_pack_start (GTK_BOX (hbox),
534 pane_operate_operate(top, app),
535 TRUE, TRUE, 0);
536
537 return hbox;
538
539 };
540
541 static GtkWidget* pane_top(GtkWidget* top, omnplay_instance_t* app)
542 {
543 GtkWidget* pane;
544
545 pane = gtk_hpaned_new ();
546 gtk_widget_show (pane);
547
548 gtk_paned_set_position (GTK_PANED (pane), 800);
549
550 gtk_paned_pack1 (GTK_PANED (pane),
551 pane_operate(top, app),
552 TRUE, FALSE);
553
554 gtk_paned_pack2 (GTK_PANED (pane),
555 pane_library(top, app),
556 FALSE, FALSE);
557
558 return pane;
559 }
560
561 GtkWidget* ui_omnplay (omnplay_instance_t* app)
562 {
563 GtkWidget *wnd;
564 GtkWidget* vbox;
565
566 wnd = gtk_window_new (GTK_WINDOW_TOPLEVEL);
567 GLADE_HOOKUP_OBJECT_NO_REF (wnd, wnd, "omnplay_window");
568
569 gtk_window_set_title (GTK_WINDOW (wnd), _("Omneon Player"));
570 gtk_window_set_default_size (GTK_WINDOW (wnd), 1024, 768);
571
572 vbox = gtk_vbox_new(FALSE, 0);
573 gtk_widget_show(vbox);
574
575 gtk_container_add(GTK_CONTAINER(wnd), vbox);
576
577 gtk_box_pack_start (GTK_BOX (vbox),
578 pane_top(wnd, app),
579 TRUE, TRUE, 0);
580 gtk_box_pack_start (GTK_BOX (vbox),
581 app->status_label = create_label(wnd, "omnplay started", NULL, GTK_JUSTIFY_LEFT),
582 FALSE, FALSE, 0);
583
584 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_BLOCK_BEGIN] =
585 create_pixbuf("block_type_block_start_16x16.png");
586 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_BLOCK_BODY] =
587 create_pixbuf("block_type_block_middle_16x16.png");
588 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_BLOCK_END] =
589 create_pixbuf("block_type_block_end_16x16.png");
590 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_BLOCK_SINGLE] =
591 create_pixbuf("block_type_block_single_16x16.png");
592 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_LOOP_BEGIN] =
593 create_pixbuf("block_type_loop_start_16x16.png");
594 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_LOOP_BODY] =
595 create_pixbuf("block_type_loop_middle_16x16.png");
596 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_LOOP_END] =
597 create_pixbuf("block_type_loop_end_16x16.png");
598 app->playlist.block_icons[OMNPLAY_PLAYLIST_ITEM_LOOP_SINGLE] =
599 create_pixbuf("block_type_block_loop_16x16.png");
600
601 return wnd;
602 }
603
604 int ui_playlist_item_dialog(omnplay_instance_t* app, playlist_item_t* item)
605 {
606 int r, c;
607 char tc[32];
608 GtkWidget *dlg;
609 gint response;
610 GtkWidget *box, *table;
611 GtkWidget *entry[4], *combo;
612
613 dlg = gtk_dialog_new_with_buttons(
614 "Playlist item",
615 GTK_WINDOW(app->window),
616 GTK_DIALOG_MODAL,
617 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
618 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
619 NULL);
620
621 box = gtk_dialog_get_content_area(GTK_DIALOG(dlg));
622
623 table = gtk_table_new(5, 2, TRUE);
624 gtk_widget_show(table);
625 gtk_box_pack_start(GTK_BOX(box), table, TRUE, TRUE, 0);
626
627 gtk_table_attach(GTK_TABLE(table),
628 create_label(NULL, "ID:", NULL, 0),
629 0, 1, 0, 1,
630 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
631
632 gtk_table_attach(GTK_TABLE(table),
633 create_label(NULL, "IN:", NULL, GTK_JUSTIFY_RIGHT),
634 0, 1, 1, 2,
635 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
636
637 gtk_table_attach(GTK_TABLE(table),
638 create_label(NULL, "DUR:", NULL, GTK_JUSTIFY_RIGHT),
639 0, 1, 2, 3,
640 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
641
642 gtk_table_attach(GTK_TABLE(table),
643 create_label(NULL, "TITLE:", NULL, GTK_JUSTIFY_RIGHT),
644 0, 1, 3, 4,
645 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
646
647 gtk_table_attach(GTK_TABLE(table),
648 create_label(NULL, "CHANNEL:", NULL, GTK_JUSTIFY_RIGHT),
649 0, 1, 4, 5,
650 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
651
652
653 gtk_table_attach(GTK_TABLE(table),
654 entry[0] = gtk_entry_new_with_max_length(32),
655 1, 2, 0, 1,
656 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
657
658 gtk_table_attach(GTK_TABLE(table),
659 entry[1] = gtk_entry_new_with_max_length(12),
660 1, 2, 1, 2,
661 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
662
663 gtk_table_attach(GTK_TABLE(table),
664 entry[2] = gtk_entry_new_with_max_length(12),
665 1, 2, 2, 3,
666 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
667
668 gtk_table_attach(GTK_TABLE(table),
669 entry[3] = gtk_entry_new_with_max_length(128),
670 1, 2, 3, 4,
671 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
672
673 gtk_table_attach(GTK_TABLE(table),
674 combo = gtk_combo_box_new_text(),
675 1, 2, 4, 5,
676 GTK_FILL/* | GTK_SHRINK */, GTK_FILL | GTK_SHRINK, 5, 5);
677
678
679 /* setup data */
680 gtk_entry_set_text(GTK_ENTRY(entry[0]), item->id);
681 gtk_entry_set_text(GTK_ENTRY(entry[1]), frames2tc(item->in, 25.0, tc));
682 gtk_entry_set_text(GTK_ENTRY(entry[2]), frames2tc(item->dur, 25.0, tc));
683 gtk_entry_set_text(GTK_ENTRY(entry[3]), item->title);
684 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "A");
685 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "B");
686 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "C");
687 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "D");
688 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), item->player);
689
690 gtk_widget_show_all(dlg);
691
692 /* Run dialog */
693 for(c = 1; c;)
694 {
695 response = gtk_dialog_run(GTK_DIALOG(dlg));
696
697 if( GTK_RESPONSE_REJECT == response ||
698 GTK_RESPONSE_DELETE_EVENT == response ||
699 GTK_RESPONSE_CANCEL == response)
700 {
701 r = 0;
702 c = 0;
703 }
704 else
705 {
706 r = 1;
707
708 /* get item data back */
709 strncpy(item->id, gtk_entry_get_text(GTK_ENTRY(entry[0])), PATH_MAX);
710 tc2frames((char*)gtk_entry_get_text(GTK_ENTRY(entry[1])), 25.0, &item->in);
711 tc2frames((char*)gtk_entry_get_text(GTK_ENTRY(entry[2])), 25.0, &item->dur);
712 strncpy(item->title, gtk_entry_get_text(GTK_ENTRY(entry[3])), PATH_MAX);
713 item->player = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
714
715 /* check if all data entered correctly */
716 if(item->id[0])
717 c = 0;
718 };
719 };
720
721 gtk_widget_hide(dlg);
722 gtk_widget_destroy(dlg);
723
724 return r;
725 };