forked from ebu/MXFTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetadataWindow.cpp
751 lines (702 loc) · 16.1 KB
/
metadataWindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
/*!
* \project_name EBU Player
* \file metadataWindow.cpp
* \brief EBUCore Metadata window
* \authors Marco Dos Santos Oliveira
* \version 0.1
* \dateOfCreation 20 august 2012
* \dateOfUpdate 21 march 2012
* \copyright This software is published under MPL v2.0
*
*/
// include files and libraries
#include "metadataWindow.hpp"
// class constructor
metadataWindow::metadataWindow
(
BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>& refGlade
)
:
Gtk::Window(cobject),
m_refGlade(refGlade)
{
refGladeButton(refGlade); // " " " " buttons
refGladeWidgets(refGlade);// " " " " widgets
initMetadataMenuPopup();
initMetadataWindow();
initRightSide();
connectSignals(); // clicked buttons
engine = new metadataEngine
(
status,
source,
sourceLabel,
size,
sizeValue,
lineOne,
lineTwo,
FirstScrolledWindowBox,
SecondScrolledWindowBox,
boxEntries,
boxStatus,
expanderRoot,
viewportTree,
switchEBUCoreEdition
);
set_has_resize_grip();
}
// class destructor
metadataWindow::~metadataWindow
(
void
)
{
// remove the previous temporary xml file to
// avoid to reload some previous metadata
// std::remove((Glib::get_current_dir ()+"/mxftmpmetadata.xml").c_str());
}
void metadataWindow::refGladeButton
(
const Glib::RefPtr<Gtk::Builder>& refGlade
)
{
/* metadata control buttons */
refGlade->get_widget
(
"importEBUCore",
importEBUCore
);
refGlade->get_widget
(
"exportEBUCore",
exportEBUCore
);
refGlade->get_widget
(
"removeEBUCore",
removeEBUCore
);
refGlade->get_widget
(
"switchEBUCoreEdition",
switchEBUCoreEdition
);
}
void metadataWindow::refGladeWidgets
(
const Glib::RefPtr<Gtk::Builder>& refGlade
)
{
/* instantiate widgets for metadata window*/
refGlade->get_widget
(
"expanderRoot",
expanderRoot
);
refGlade->get_widget
(
"viewportTree",
viewportTree
);
refGlade->get_widget
(
"FirstScrolledWindowBox",
FirstScrolledWindowBox
);
refGlade->get_widget
(
"SecondScrolledWindowBox",
SecondScrolledWindowBox
);
refGlade->get_widget
(
"boxEntries",
boxEntries
);
refGlade->get_widget
(
"boxStatus",
boxStatus
);
}
void metadataWindow::connectSignals
(
void
)
{
}
void metadataWindow::on_importEBUCore_clicked
(
bool EBUCoreKind,
bool isRemote
)
{
if (isRemote)
{
// instanciate a new remote filechooser
remoteStreamFileChooser * RFC = new remoteStreamFileChooser
(
*this,
"Remote media filechooser...",
"Type the path to the remote stream :",
false
);
if (RFC->getResponse() == Gtk::RESPONSE_OK)
{
std::cout<<"I'm opening the EBUCore file :"<<std::endl<<RFC->getURL()<<std::endl;
}
delete RFC;
}
else
{
// instanciate a new local filechooser
genericFilechooserWindow * FC = new genericFilechooserWindow
(
*this,
"Select an EBUCore file",
Gtk::FILE_CHOOSER_ACTION_OPEN,
Glib::get_home_dir(),
false,
((EBUCoreKind) ? MXFMETADATAMIMETYPE : XMLMETADATAMIMETYPE)
);
if (FC->getResponse() == Gtk::RESPONSE_OK)
{
// construct the treeview
if (genericFeatures::isExtension(FC->getPathToFile(),"xml"))
{
engine->constructTreeViewFromXML(FC->getPathToFile());
} else {
engine->constructTreeViewFromMXF(FC->getPathToFile());
}
// set the information about the file into the right side panel
engine->setRightSide(FC->getPathToFile());
// set the new size
set_size_request(engine->getViewportSize()+410,-1);
// force to reshow window with the new viewport size
reshow_with_initial_size();
}
delete FC;
}
}
void metadataWindow::on_removeEBUCore_clicked
(
void
)
{
// instanciate a new local filechooser
genericFilechooserWindow * FC = new genericFilechooserWindow
(
*this,
"Select an MXF file",
Gtk::FILE_CHOOSER_ACTION_OPEN,
Glib::get_home_dir(),
false,
MXFMETADATAMIMETYPE
);
if (FC->getResponse() == Gtk::RESPONSE_OK)
{
// set the information about the file into the right side panel
engine->removeEBUCore(FC->getPathToFile());
}
delete FC;
}
void metadataWindow::on_saveAndRemoveEBUCore_clicked
(
void
)
{
// instanciate a new local filechooser
genericFilechooserInputOutput * FCIO = new genericFilechooserInputOutput
(
*this,
"Convert MXF EBUCore into XML EBUCore",
"Select the input MXF file :",
"Save the output XML EBUCore file into :",
"Extract from ...",
"Save as ...",
"Set the input path to the MXF EBUCore file...",
"Set the output path to the XML EBUCore file...",
true
);
if (FCIO->getResponse() == Gtk::RESPONSE_OK)
{
engine->removeEBUCore(FCIO->getInputPath(),FCIO->getOutputPath());
}
delete FCIO;
}
void metadataWindow::on_embedXML2MXFEBUCore_clicked
(
void
)
{
metadataEncapsulationInputOutputDialog * MEIOD = new metadataEncapsulationInputOutputDialog (*this,"Encapsulate EBUCore metadata as ...");
if (MEIOD->getResponse() == Gtk::RESPONSE_OK) {
std::cout<<"Output MXF : "<<MEIOD->getOutputPath()<<std::endl;
std::cout<<"Input XML : "<<MEIOD->getInputPath()<<std::endl;
std::cout<<"Force to set XML into MXF header partition : "<<MEIOD->getHeader()<<std::endl;
std::cout<<"Set metadata as dark partition : "<<MEIOD->getDark()<<std::endl;
std::cout<<"Set metadata as sidecar reference : "<<MEIOD->getSidecar()<<std::endl;
engine->embedEBUCore
(
MEIOD->getOutputPath(),
MEIOD->getInputPath(),
MEIOD->getHeader(),
MEIOD->getDark(),
MEIOD->getSidecar()
);
}
// free memory
delete MEIOD;
}
void metadataWindow::on_embedEBUCore_clicked
(
void
)
{
metadataEncapsulationDialog * MetadataExportDialog = new metadataEncapsulationDialog
(
*this,
"Embed current EBUCore metadatas into current MXF file",
"",
"",
"",
"",
"",
"",
false,
false,
true,
true
);
if (MetadataExportDialog->getResponse() == Gtk::RESPONSE_OK) {
//engine->embedEBUCore();
}
// free memory
delete MetadataExportDialog;
}
void metadataWindow::on_exportMXF2XMLEBUCore_clicked
(
void
)
{
// instanciate a new local filechooser
genericFilechooserInputOutput * FCIO = new genericFilechooserInputOutput
(
*this,
"Convert MXF EBUCore into XML EBUCore",
"Select the input MXF file :",
"Save the output XML EBUCore file into :",
"Extract from ...",
"Save as ...",
"Set the input path to the MXF EBUCore file...",
"Set the output path to the XML EBUCore file...",
true
);
if (FCIO->getResponse() == Gtk::RESPONSE_OK)
{
engine->exportMXF2XMLEBUCore(FCIO->getInputPath(),FCIO->getOutputPath());
}
delete FCIO;
}
void metadataWindow::on_exportEBUCore_clicked
(
void
)
{
metadataEncapsulationDialog * MetadataExportDialog = new metadataEncapsulationDialog
(
*this,
"Embed current EBUCore metadatas into an XML file",
"",
"Set the output XML file :",
"",
"Save as",
"",
"Set the output XML filename...",
false,
true,
false,
true
);
if (MetadataExportDialog->getResponse() == Gtk::RESPONSE_OK) {
engine->exportXMLEBUCore(MetadataExportDialog->getOutputPath());
}
// free memory
delete MetadataExportDialog;
}
void metadataWindow::initMetadataMenuPopup
(
void
)
{
// Create action groups for the popup menus which has to
// be included into the metadata action buttons
importEBUCoreActionGroup = Gtk::ActionGroup::create();
exportEBUCoreActionGroup = Gtk::ActionGroup::create();
removeEBUCoreActionGroup = Gtk::ActionGroup::create();
//Add a new item action menu to the action group
importEBUCoreActionGroup->add(Gtk::Action::create("importEBUCoreMenu", "Import an EBUCore File ..."));
exportEBUCoreActionGroup->add(Gtk::Action::create("exportEBUCoreMenu", "Save / Export ..."));
exportEBUCoreActionGroup->add(Gtk::Action::create("removeEBUCoreMenu", "emove EBUCore metadatas from MXF file..."));
// add new menu items with their own action menu, a keyboard shortcut
// and a listener ; open a new playlist or append a playlist to the
// current playlist
////////////////////////////////////////////
//import menu xml and mxf ebucore
importEBUCoreActionGroup->add
(
Gtk::Action::create
(
"importEBUCoreXMLMenu",
Gtk::Stock::NEW,
"XML EBUCore",
"Open an XML EBUCore instance file..."
)
);
importEBUCoreActionGroup->add
(
Gtk::Action::create
(
"importEBUCoreMXFMenu",
Gtk::Stock::NEW,
"MXF EBUCore",
"Open an MXF EBUCore instance file"
)
);
// import submenu for xml
importEBUCoreActionGroup->add
(
Gtk::Action::create
(
"importEBUCoreXMLLocal",
Gtk::Stock::NEW,
"local file",
"Open a local XML EBUCore instance file..."
),
sigc::bind<bool,bool>
(
sigc::mem_fun
(
*this,
&metadataWindow::on_importEBUCore_clicked
),
false,
false
)
);
importEBUCoreActionGroup->add
(
Gtk::Action::create
(
"importEBUCoreXMLRemote",
Gtk::Stock::NEW,
"remote file",
"Open a remote XML EBUCore instance file..."
),
sigc::bind<bool,bool>
(
sigc::mem_fun
(
*this,
&metadataWindow::on_importEBUCore_clicked
),
false,
true
)
);
// import submenu for mxf
importEBUCoreActionGroup->add
(
Gtk::Action::create
(
"importEBUCoreMXFLocal",
Gtk::Stock::NEW,
"local file",
"Open a local MXF EBUCore instance file..."
),
sigc::bind<bool,bool>
(
sigc::mem_fun
(
*this,
&metadataWindow::on_importEBUCore_clicked
),
true,
false
)
);
importEBUCoreActionGroup->add
(
Gtk::Action::create
(
"importEBUCoreMXFRemote",
Gtk::Stock::NEW,
"remote file",
"Open a remote MXF EBUCore instance file..."
),
sigc::bind<bool,bool>
(
sigc::mem_fun
(
*this,
&metadataWindow::on_importEBUCore_clicked
),
true,
true
)
);
////////////////////////////////////////
exportEBUCoreActionGroup->add
(
Gtk::Action::create
(
"exportEBUCoreMXF2XMLMenu",
Gtk::Stock::ADD,
"MXF EBUCore to XML",
"Export MXF EBUCore to XML EBUCore..."
)
);
// export submenu for local xml from local mxf
exportEBUCoreActionGroup->add
(
Gtk::Action::create
(
"exportEBUCoreMXF2XMLLocal",
Gtk::Stock::NEW,
"Local file",
"Save the MXF EBUCore into an XML local file..."
),
sigc::mem_fun
(
*this,
&metadataWindow::on_exportMXF2XMLEBUCore_clicked
)
);
exportEBUCoreActionGroup->add
(
Gtk::Action::create
(
"exportEBUCoreXML2MXFMenu",
Gtk::Stock::ADD,
"XML EBUCore to MXF",
"Export XML EBUCore to MXF EBUCore..."
)
);
// export submenu for local mxf from local yml
exportEBUCoreActionGroup->add
(
Gtk::Action::create
(
"exportEBUCoreXML2MXFLocal",
Gtk::Stock::NEW,
"Local file",
"Embed an XML EBUCore into an MXF local file..."
),
sigc::mem_fun
(
*this,
&metadataWindow::on_embedXML2MXFEBUCore_clicked
)
);
exportEBUCoreActionGroup->add
(
Gtk::Action::create
(
"exportEBUCoreMXFFile",
Gtk::Stock::ADD,
"Save into MXF",
"Save current EBUCore metadata into EBUCore MXF file..."
),
sigc::mem_fun
(
*this,
&metadataWindow::on_embedEBUCore_clicked
)
);
exportEBUCoreActionGroup->add
(
Gtk::Action::create
(
"exportEBUCoreXMLFile",
Gtk::Stock::ADD,
"Save into XML",
"Save current EBUCore metadata into EBUCore XML file..."
),
sigc::mem_fun
(
*this,
&metadataWindow::on_exportEBUCore_clicked
)
);
/////////////////////////
removeEBUCoreActionGroup->add
(
Gtk::Action::create
(
"removeEBUCoreFromMXF",
Gtk::Stock::ADD,
"Remove EBUCore metadatas...",
"Remove EBUCore metadatas from MXF"
),
sigc::mem_fun
(
*this,
&metadataWindow::on_removeEBUCore_clicked
)
);
removeEBUCoreActionGroup->add
(
Gtk::Action::create
(
"saveAndRemoveEBUCoreFromMXF",
Gtk::Stock::ADD,
"Save and then remove...",
"Save and then remove EBUCore metadatas from MXF"
),
sigc::mem_fun
(
*this,
&metadataWindow::on_saveAndRemoveEBUCore_clicked
)
);
importEBUCoreUIManager = Gtk::UIManager::create();
exportEBUCoreUIManager = Gtk::UIManager::create();
removeEBUCoreUIManager = Gtk::UIManager::create();
importEBUCoreUIManager->insert_action_group(importEBUCoreActionGroup);
exportEBUCoreUIManager->insert_action_group(exportEBUCoreActionGroup);
removeEBUCoreUIManager->insert_action_group(removeEBUCoreActionGroup);
add_accel_group(importEBUCoreUIManager->get_accel_group());
add_accel_group(exportEBUCoreUIManager->get_accel_group());
add_accel_group(removeEBUCoreUIManager->get_accel_group());
//Layout the actions in a menubar and toolbar:
Glib::ustring ui_info =
"<ui>"
" <popup name='importEBUCorePopupMenu'>"
" <menu action='importEBUCoreXMLMenu'>"
" <menuitem action='importEBUCoreXMLLocal'/>"
" <menuitem action='importEBUCoreXMLRemote'/>"
" </menu>"
" <menu action='importEBUCoreMXFMenu'>"
" <menuitem action='importEBUCoreMXFLocal'/>"
" <menuitem action='importEBUCoreMXFRemote'/>"
" </menu>"
" </popup>"
"</ui>";
try
{
importEBUCoreUIManager->add_ui_from_string(ui_info);
} catch(const Glib::Error& ex) {
std::cerr << "building menus failed: " << ex.what();
}
importEBUCoreMenuPopup = dynamic_cast<Gtk::Menu*>
(
importEBUCoreUIManager->get_widget("/importEBUCorePopupMenu")
);
if(!importEBUCoreMenuPopup)
g_warning("menu not found");
//Layout the actions in a menubar and toolbar:
ui_info =
"<ui>"
" <popup name='exportEBUCorePopupMenu'>"
" <menuitem action='exportEBUCoreMXFFile'/>"
" <menuitem action='exportEBUCoreXMLFile'/>"
" <separator/>"
" <menu action='exportEBUCoreMXF2XMLMenu'>"
" <menuitem action='exportEBUCoreMXF2XMLLocal'/>"
" </menu>"
" <menu action='exportEBUCoreXML2MXFMenu'>"
" <menuitem action='exportEBUCoreXML2MXFLocal'/>"
" </menu>"
" </popup>"
"</ui>";
try
{
exportEBUCoreUIManager->add_ui_from_string(ui_info);
} catch(const Glib::Error& ex) {
std::cerr << "building menus failed: " << ex.what();
}
exportEBUCoreMenuPopup = dynamic_cast<Gtk::Menu*>
(
exportEBUCoreUIManager->get_widget("/exportEBUCorePopupMenu")
);
if(!exportEBUCoreMenuPopup)
g_warning("menu not found");
//Layout the actions in a menubar and toolbar:
ui_info =
"<ui>"
" <popup name='removeEBUCorePopupMenu'>"
" <menuitem action='removeEBUCoreFromMXF'/>"
" <menuitem action='saveAndRemoveEBUCoreFromMXF'/>"
" </popup>"
"</ui>";
try
{
removeEBUCoreUIManager->add_ui_from_string(ui_info);
} catch(const Glib::Error& ex) {
std::cerr << "building menus failed: " << ex.what();
}
removeEBUCoreMenuPopup = dynamic_cast<Gtk::Menu*>
(
removeEBUCoreUIManager->get_widget("/removeEBUCorePopupMenu")
);
if(!removeEBUCoreMenuPopup)
g_warning("menu not found");
// set the popup
importEBUCore->set_popup(*importEBUCoreMenuPopup);
exportEBUCore->set_popup(*exportEBUCoreMenuPopup);
removeEBUCore->set_popup(*removeEBUCoreMenuPopup);
}
void metadataWindow::initMetadataWindow
(
void
)
{
// menubutton to open an EBUCore file
importEBUCore->set_visible(true);
importEBUCore->set_sensitive(true);
// menubutton to save/export an EBUCore file
exportEBUCore->set_visible(true);
exportEBUCore->set_sensitive(true);
// menubutton to save/export an EBUCore file
removeEBUCore->set_visible(true);
removeEBUCore->set_sensitive(true);
// button to switch into edition mode
switchEBUCoreEdition->set_visible(true);
switchEBUCoreEdition->set_sensitive(false);
switchEBUCoreEdition->set_active(false);
// Initial window state
set_visible(false);
}
void metadataWindow::initRightSide
(
void
)
{
//boxStatus = manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL,0));
//boxStatus->show();
status = manage(new Gtk::Label("No EBUCore metadata detected"));
lineOne = manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL,0));
source = manage(new Gtk::Label("source : "));
sourceLabel = manage(new Gtk::Label("no source"));
lineTwo = manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL,0));
size = manage(new Gtk::Label("size : "));
sizeValue = manage(new Gtk::Label("0 byte"));
status->show();
source->show();
sourceLabel->show();
size->show();
sizeValue->show();
lineOne->show();
lineTwo->show();
lineOne->add(*source);
lineOne->add(*sourceLabel);
lineTwo->add(*size);
lineTwo->add(*sizeValue);
boxStatus->add(*status);
boxStatus->add(*lineOne);
boxStatus->add(*lineTwo);
boxStatus->show();
FirstScrolledWindowBox->hide();
boxEntries->hide();
}