File: project.py

package info (click to toggle)
devede 4.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 3,864 kB
  • sloc: python: 5,416; makefile: 17
file content (727 lines) | stat: -rw-r--r-- 24,990 bytes parent folder | download
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
# Copyright 2014 (C) Raster Software Vigo (Sergio Costas)
#
# This file is part of DeVeDe-NG
#
# DeVeDe-NG is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# DeVeDe-NG is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>

from gi.repository import Gtk, Gdk
import os
import time
import shutil
import urllib.parse
import pickle
import math

import devedeng.file_movie
import devedeng.ask
import devedeng.add_files
import devedeng.message
import devedeng.dvd_menu
import devedeng.create_disk_window
import devedeng.runner
import devedeng.settings
import devedeng.dvdauthor_converter
import devedeng.mkisofs
import devedeng.end_job
import devedeng.vcdimager_converter
import devedeng.shutdown
import devedeng.about
import devedeng.opensave
import devedeng.help

class devede_project:

    def __init__(self):

        self.config  = devedeng.configuration_data.configuration.get_config()

        self.disc_type = self.config.disc_type
        self.menu = devedeng.dvd_menu.dvd_menu()

        self.current_title = None
        self.project_file = None

        builder = Gtk.Builder()
        builder.set_translation_domain(self.config.gettext_domain)

        builder.add_from_file(os.path.join(self.config.glade,"wmain.ui"))
        builder.connect_signals(self)

        # Interface widgets
        self.wmain_window = builder.get_object("wmain_window")
        self.wdisc_size = builder.get_object("disc_size")
        self.wliststore_files = builder.get_object("liststore_files")
        self.wfiles = builder.get_object("files")
        self.wdisc_fill_level = builder.get_object("disc_fill_level")
        self.wuse_pal = builder.get_object("use_pal")
        self.wuse_ntsc = builder.get_object("use_ntsc")
        self.wframe_titles = builder.get_object("frame_titles")

        self.wframe_menu = builder.get_object("frame_menu")
        self.wcreate_menu = builder.get_object("create_menu")
        self.wmenu_options = builder.get_object("menu_options")


        self.wadd_file = builder.get_object("add_file")
        self.wdelete_file = builder.get_object("delete_file")
        self.wup_file = builder.get_object("up_file")
        self.wdown_file = builder.get_object("down_file")
        self.wproperties_file = builder.get_object("properties_file")
        self.wpreview_file = builder.get_object("preview_file")

        self.wcreate_disc = builder.get_object("create_disc")

        selection = self.wfiles.get_selection()
        selection.set_mode(Gtk.SelectionMode.BROWSE)

        if (self.config.PAL):
            self.wuse_pal.set_active(True)
            self.pal = True
        else:
            self.wuse_ntsc.set_active(True)
            self.pal = False

        self.wcreate_menu.set_active(True)

        self.config.connect('disc_type',self.set_type)
        if (self.disc_type is not None):
            self.set_type(None, self.disc_type)

        self.wmain_window.drag_dest_set(Gtk.DestDefaults.ALL,[],Gdk.DragAction.COPY)
        targets = Gtk.TargetList.new([])
        targets.add(Gdk.Atom.intern("text/uri-list", False),0,0)
        self.wmain_window.drag_dest_set_target_list(targets)


    def set_type(self,obj=None,disc_type=None):
        """ this method sets the disk type to the specified one and adapts the interface
            in the main window to it. Also leaves everything ready to start creating a
            new disc """

        if (disc_type is not None):
            self.disc_type = disc_type
        self.wmain_window.show_all()
        self.set_interface_status(None)

        # Set the default disc size
        if (self.disc_type == "dvd") or (self.disc_type == "mkv"):
            self.wdisc_size.set_active(1) # 4.7 GB DVD
        else:
            self.wdisc_size.set_active(3) # 700 MB CD

        if (self.disc_type == "dvd"):
            self.wframe_menu.show_all()
            self.wcreate_menu.set_active(True)
        else:
            self.wframe_menu.hide()
            self.wcreate_menu.set_active(False)


    def get_current_file(self):

        """ returns the currently selected file """

        selection = self.wfiles.get_selection()
        model, treeiter = selection.get_selected()

        if treeiter is not None:
            element = model[treeiter][0]
            position = 0
            for row in self.wfiles.get_model():
                item = row.model[row.iter][0]
                if element == item:
                    break
                position += 1
            return ( (element, position, model, treeiter) )
        else:
            return ( (None, -1, None, None) )


    def get_all_files(self):

        retval = []

        for row in self.wfiles.get_model():
            retval.append(row.model[row.iter][0])
        return retval


    def set_interface_status(self,b):

        self.wadd_file.set_sensitive(True)
        self.wdelete_file.set_sensitive(True)
        self.wup_file.set_sensitive(True)
        self.wdown_file.set_sensitive(True)
        self.wproperties_file.set_sensitive(True)
        self.wpreview_file.set_sensitive(True)

        status = self.wcreate_menu.get_active()
        self.wmenu_options.set_sensitive(status)

        self.pal = self.wuse_pal.get_active()

        (element, position, model, treeiter) = self.get_current_file()
        if (element is None):
            self.wdelete_file.set_sensitive(False)
            self.wup_file.set_sensitive(False)
            self.wdown_file.set_sensitive(False)
            self.wproperties_file.set_sensitive(False)
            self.wpreview_file.set_sensitive(False)
        else:
            nfiles = len(self.wfiles.get_model())
            if (nfiles < 1):
                self.wdelete_file.set_sensitive(False)
            if (position == 0):
                self.wup_file.set_sensitive(False)
            if (position == (nfiles-1)):
                self.wdown_file.set_sensitive(False)


    def on_cellrenderertext3_edited(self, widget, path, text):
        self.wliststore_files[path][0].set_title(text)


    def on_use_pal_toggled(self,b):

        self.config.PAL = self.wuse_pal.get_active()
        self.set_interface_status(None)


    def on_wmain_window_delete_event(self,b,e=None):

        ask = devedeng.ask.ask_window()
        if (ask.run(_("Abort the current DVD and exit?"),_("Exit DeVeDe"))):
            Gtk.main_quit()
        return True

    def title_changed(self,obj,new_title):

        for item in self.wliststore_files:
            element = item.model[item.iter][0]
            if element == obj:
                item.model.set_value(item.iter,1,new_title)
        self.refresh_disc_usage()


    def on_help_clicked(self,b):
        
        help_file = devedeng.help.help("main.html")

    def on_help_index_activate(self,b):
        
        help_file = devedeng.help.help("index.html")


    def on_add_file_clicked(self,b):

        ask_files = devedeng.add_files.add_files()
        if (ask_files.run()):
            self.add_several_files(ask_files.files)


    def duration_to_string(self,duration):

        seconds = math.floor(duration%60)
        minutes = math.floor((duration/60)%60)
        hours = math.floor(duration/3600)

        output = str(seconds)+"s"
        if ((hours != 0) or (minutes != 0)):
            output = str(minutes)+"m "+output
        if (hours != 0):
            output = str(hours)+"h "+output
        return output


    def add_several_files(self,file_list):
        error_list = []
        for efile in file_list:
            if efile.startswith("file://"):
                efile = urllib.parse.unquote(efile[7:])
            new_file = devedeng.file_movie.file_movie(efile)
            if (new_file.error):
                error_list.append(os.path.basename(efile))
            else:
                new_file.connect('title_changed',self.title_changed)
                self.wliststore_files.append([new_file, new_file.title_name,True,self.duration_to_string(new_file.get_duration())])
        if (len(error_list)!=0):
            devedeng.message.message_window(_("The following files could not be added:"),_("Error while adding files"),error_list)
        self.set_interface_status(None)
        self.refresh_disc_usage()


    def on_delete_file_clicked(self,b):

        (element, position, model, treeiter) = self.get_current_file()
        if (element is None):
            return

        ask_w = devedeng.ask.ask_window()
        if (ask_w.run(_("The file <b>%(X)s</b> <i>(%(Y)s)</i> will be removed.") % {"X":element.title_name, "Y":element.file_name},_("Delete file"))):
            element.delete_file()
            model.remove(treeiter)
            self.set_interface_status(None)
            self.refresh_disc_usage()


    def on_up_file_clicked(self,b):

        (element, position, model, treeiter) = self.get_current_file()
        if (element is None) or (position == 0):
            return

        last_element = self.wfiles.get_model()[position-1]
        self.wfiles.get_model().swap(last_element.iter,treeiter)
        self.set_interface_status(None)


    def on_down_file_clicked(self,b):

        (element, position, model, treeiter) = self.get_current_file()
        if (element is None) or (position == (len(self.wfiles.get_model())-1)):
            return

        last_element = self.wfiles.get_model()[position+1]
        self.wfiles.get_model().swap(last_element.iter,treeiter)
        self.set_interface_status(None)


    def on_properties_file_clicked(self,b):
        (element, position, model, treeiter) = self.get_current_file()
        if (element is None):
            return
        element.properties()


    def on_create_menu_toggled(self,b):
        self.set_interface_status(None)
        self.refresh_disc_usage()


    def on_adjust_disc_usage_clicked(self,b):

        total_resolution = 0
        fixed_size = 0
        to_adjust = []
        for f in self.get_all_files():
            estimated_size, videorate_fixed_size, audio_rate, sub_rate, width, height, time_length = f.get_size_data()
            if videorate_fixed_size:
                fixed_size += estimated_size
            else:
                fixed_size += ((audio_rate + sub_rate) * time_length)
                # 76800 = 320x240, which is the smallest resolution
                surface = ((float(width) * float(height)) / 76800.0) * float(time_length)
                to_adjust.append( (f, surface, time_length, audio_rate, height) )
                total_resolution += surface

        if (self.disc_type == "dvd") and (self.wcreate_menu.get_active()):
            fixed_size += self.menu.get_estimated_size() * 8.0

        if (self.disc_type == "dvd"):
            max_bps_base = {0: 9000}
            min_bps = 300
            max_total = 10000
        elif (self.disc_type == "svcd") or (self.disc_type == "cvd"):
            max_bps_base = {0: 2700}
            min_bps = 200
            max_total = 2700
        elif (self.disc_type == "divx"):
            max_bps_base = {0: 4854, 720: 9708, 1080: 20000}
            min_bps = 300
            max_total = -1
        elif (self.disc_type == "mkv"):
            max_bps_base = {0: 192, 240: 2000, 480: 14000,  720: 50000, 1080: 240000}
            min_bps = 192
            max_total = -1
        else:
            max_bps_base = {0: 9000}
            min_bps = 300
            max_total = -1

        if (total_resolution != 0):
            remaining_disc_size = ((8000.0 * self.get_dvd_size()[0]) - fixed_size) # in kbits
            for l in to_adjust:
                f = l[0]
                surface = l[1]
                length = l[2]
                audio_rate = l[3]
                height = l[4]

                max_bps = max_bps_base[0]
                resy = 0
                for bitrates in max_bps_base:
                    if (height >= bitrates) and (resy < bitrates):
                        resy = bitrates
                        max_bps = max_bps_base[bitrates]

                video_rate = (remaining_disc_size * surface) / ( length * total_resolution)
                if max_total != -1:
                    max2 = max_total - audio_rate
                    if (max2 > max_bps):
                        max2 = max_bps
                else:
                    max2 = max_bps
                if (video_rate > max2):
                    video_rate = max2
                if (video_rate < min_bps):
                    video_rate = min_bps
                f.set_auto_video_audio_rate(video_rate, audio_rate)

        self.refresh_disc_usage()


    def refresh_disc_usage(self):

        used = 0.0

        for f in self.get_all_files():
            estimated_size = f.get_estimated_size()
            used += float(estimated_size)

        if self.wcreate_menu.get_active():
            used += float(self.menu.get_estimated_size())

        used /= 1000.0

        disc_size,minvrate,maxvrate = self.get_dvd_size()

        if used > disc_size:
            self.wdisc_fill_level.set_fraction(1.0)
            addv=1
        else:
            self.wdisc_fill_level.set_fraction(used / disc_size)
            addv=0

        self.wdisc_fill_level.set_text(str(addv+int((used / disc_size)*100))+"%")
        self.wdisc_fill_level.set_show_text(True)


    def on_menu_options_clicked(self,b):

        self.menu.show_configuration(self.get_all_files())


    def get_dvd_size(self):

        """ Returns the size for the currently selected disk type, and the minimum and maximum
            videorate for the current video disk """

        active = self.wdisc_size.get_active()

        # here we choose the size in Mbytes for the media
        if 5==active:
            size=170.0
        elif 4==active:
            size=700.0
        elif 3==active:
            size=750.0
        elif 2==active:
            size=1100.0
        elif 1==active:
            size=4200.0
        else:
            size=8000.0

        if self.disc_type=="vcd":
            minvrate=1152
            maxvrate=1152
        elif (self.disc_type == "svcd") or (self.disc_type == "cvd"):
            minvrate=400
            maxvrate=2300
        elif (self.disc_type == "dvd"):
            minvrate=400
            maxvrate=8500
        elif (self.disc_type == "divx") or (self.disc_type == "mkv"):
            minvrate=300
            maxvrate=6000
        else:
            minvrate = 0
            maxvrate = 8000

        size *= 0.90  # a safe margin of 10% to ensure that it never will be bigger
                    # (it's important to have in mind the space needed by disk structures like
                    # directories, file entries, and so on)

        return size,minvrate,maxvrate


    def on_disc_size_changed(self,c):

        self.refresh_disc_usage()


    def on_create_disc_clicked(self,b):

        if self.disc_type == "dvd":
            max_files = 62
        else:
            max_files = -1

        file_movies = self.get_all_files()
        t = len(file_movies)
        if (max_files != -1) and (t > max_files):
            devedeng.message.message_window(_("The limit for this format is %(l)d files, but your project has %(h)d.") % {"l": max_files, "h" : t}, _("Too many files in the project"))
            return

        data = devedeng.create_disk_window.create_disk_window()
        if (not data.run()):
            return

        if os.path.exists(data.path):
            ask_w = devedeng.ask.ask_window()
            retval = ask_w.run(_("The selected folder already exists. To create the project, Devede must delete it.\nIf you continue, the folder\n\n <b>%s</b>\n\n and all its contents <b>will be deleted</b>. Continue?") % data.path,_("Delete folder"))
            if retval:
                # delete only the bare minimun needed
                shutil.rmtree(os.path.join(data.path,"dvd_tree"),True)
                shutil.rmtree(os.path.join(data.path,"menu"),True)
                shutil.rmtree(os.path.join(data.path,"movies"),True)
                shutil.rmtree(os.path.join(data.path,"xml_data"),True)
                if self.config.disc_type == "dvd":
                    try:
                        os.unlink(os.path.join(data.path,data.name+".iso"))
                    except:
                        pass
                if (self.config.disc_type == "vcd") or (self.config.disc_type == "svcd") or (self.config.disc_type == "cvd"):
                    try:
                        os.unlink(os.path.join(data.path,data.name+".bin"))
                    except:
                        pass
                    try:
                        os.unlink(os.path.join(data.path,data.name+".cue"))
                    except:
                        pass
            else:
                return

        self.shutdown = data.shutdown

        run_window = devedeng.runner.runner()

        final_dependencies = []

        if (self.disc_type == "dvd") and (self.wcreate_menu.get_active()):
            processes,menu_entries = self.menu.create_dvd_menus(file_movies, data.path)
            for p in processes:
                run_window.add_process(p)
                final_dependencies.append(p)
        else:
            menu_entries = None

        movie_folder = os.path.join(data.path,"movies")
        try:
            os.makedirs(movie_folder)
        except:
            pass
        counter = 0
        for movie in file_movies:
            p = movie.do_conversion(os.path.join(movie_folder,"movie_"+str(counter)+".mpg"))
            run_window.add_process(p)
            final_dependencies.append(p)
            counter += 1

        if (self.disc_type == "dvd"):
            if (self.menu.at_startup == "menu_show_at_startup"):
                start_with_menu = True
            else:
                start_with_menu = False
            dvdauthor = devedeng.dvdauthor_converter.dvdauthor_converter()
            dvdauthor.create_dvd_project(data.path, data.name, file_movies, menu_entries, start_with_menu, self.menu.play_all_c)
            # dvdauthor must wait until all the files have been converted
            for element in final_dependencies:
                dvdauthor.add_dependency(element)
            run_window.add_process(dvdauthor)

            cv = devedeng.converter.converter.get_converter()
            isocreator = cv.get_mkiso()()
            isocreator.create_iso(data.path, data.name)
            isocreator.add_dependency(dvdauthor)
            run_window.add_process(isocreator)
            self.disc_image_name = os.path.join(data.path,data.name+".iso")
        elif (self.disc_type == "vcd") or (self.disc_type == "svcd") or (self.disc_type == "cvd"):
            vcdcreator = devedeng.vcdimager_converter.vcdimager_converter()
            vcdcreator.create_cd_project(data.path, data.name, file_movies)
            for element in final_dependencies:
                vcdcreator.add_dependency(element)
            run_window.add_process(vcdcreator)
            self.disc_image_name = os.path.join(data.path,data.name+".cue")
        else:
            self.disc_image_name = None

        run_window.connect("done",self.disc_done)
        self.wmain_window.hide()
        self.time_start = time.time()
        run_window.run()


    def disc_done(self,object,value):

        if self.shutdown:
            Gtk.main_quit()
            devedeng.shutdown.shutdown()

        if value == 0:
            ended = devedeng.end_job.end_window()
            if self.disc_image_name is None:
                do_burn = False
            else:
                do_burn = True
            if (ended.run(time.time() - self.time_start, do_burn)):
                cv = devedeng.converter.converter.get_converter()
                burner = cv.get_burner()()
                burner.burn(self.disc_image_name)
                run_window = devedeng.runner.runner(False)
                run_window.add_process(burner)
                run_window.connect("done", self.disc_done2)
                run_window.run()
                return

        self.wmain_window.show()


    def disc_done2(self,object, value):

        self.wmain_window.show()


    def on_preview_file_clicked(self,b):

        (element, position, model, treeiter) = self.get_current_file()
        if (element is None):
            return
        element.do_preview()


    def on_settings_activate(self,b):

        w = devedeng.settings.settings_window()


    def on_about_activate(self,b):

        w = devedeng.about.about_window()


    def on_new_activate(self,b):

        w = devedeng.ask.ask_window()
        if w.run(_("Close current project and start a fresh one?"), _("New project")):
            self.wliststore_files.clear()
            self.project_file = None
            self.wmain_window.hide()
            devedeng.choose_disc_type.choose_disc_type()


    def on_wmain_window_drag_motion(self,wid, context, x, y, time):
        Gdk.drag_status(context, Gdk.DragAction.COPY, time)
        return True


    def on_wmain_window_drag_drop(self, wid, context, x, y, time):
        # Used with windows drag and drop
        return True


    def on_wmain_window_drag_data_received(self, widget, drag_context, x,y, data, info, time):
        uris = data.get_uris()
        self.add_several_files(uris)
        Gtk.drag_finish (drag_context, True, Gdk.DragAction.COPY, time);


    def on_save_activate(self,b):
        if self.project_file is not None:
            self.save_current_project()
        else:
            self.on_save_as_activate(None)


    def on_save_as_activate(self,b):

        while True:
            w = devedeng.opensave.opensave_window(True)
            retval = w.run(self.project_file)
            if retval is None:
                return
            if not retval.endswith(".devedeng"):
                retval += ".devedeng"
            if os.path.isfile(retval):
                w = devedeng.ask.ask_window()
                if not w.run(_("The file already exists. Overwrite it?"), _("The file already exists")):
                    continue
            self.project_file = retval
            self.save_current_project()
            return


    def on_load_activate(self,b):
        w = devedeng.opensave.opensave_window(False)
        retval = w.run()
        if retval is not None:
            self.load_project(retval)


    def save_current_project(self):

        project = {}

        project["PAL"] = self.wuse_pal.get_active()
        project["create_menu"] = self.wcreate_menu.get_active()
        project["disc_type"] = self.config.disc_type
        project["disc_size"] = self.wdisc_size.get_active()
        project["files"] = []
        f = self.get_all_files()
        for i in f:
            project["files"].append(i.store_file())
        if self.disc_type == "dvd":
            project["menu"] = self.menu.store_menu()

        with open(self.project_file, 'wb') as f:
            pickle.dump(project, f, 3)


    def load_project(self,project_file):

        self.wliststore_files.clear()
        self.project_file = project_file
        with open(project_file, 'rb') as f:
            project = pickle.load(f)
        if "disc_type" in project:
            self.config.set_disc_type(project["disc_type"])
        if "PAL" in project:
            self.wuse_pal.set_active(project["PAL"])
        if "create_menu" in project:
            self.wcreate_menu.set_active(project["create_menu"])
        if "disc_size" in project:
            self.wdisc_size.set_active(project["disc_size"])
        if "menu" in project:
            self.menu.restore_menu(project["menu"])
        if "files" in project:
            error_list = []
            for efile in project["files"]:
                new_file = devedeng.file_movie.file_movie(efile["file_name"])
                if (new_file.error):
                    error_list.append(os.path.basename(efile["file_name"]))
                else:
                    new_file.restore_file(efile)
                    new_file.connect('title_changed',self.title_changed)
                    self.wliststore_files.append([new_file, new_file.title_name,True,self.duration_to_string(new_file.get_duration())])
            if (len(error_list)!=0):
                devedeng.message.message_window(_("The following files in the project could not be added again:"),_("Error while adding files"),error_list)
        self.set_interface_status(None)
        self.refresh_disc_usage()


    def on_multiproperties_activate(self,b):

        e = devedeng.file_movie.file_movie(None,self.get_all_files())
        e.properties()