def draganddrop(self, widget, drag_context, x, y, selection, info, time): """ Manages the Drag&Drop in the main window """ converter = devede_newfiles.newfile(self.global_vars["PAL"], self.disctocreate) list = converter.split_dnd(selection.data) if (len(list) == 1): # check if it's a configuration file filename = list[0].lower() if len(filename) > 6: if filename[-7:] == ".devede": self.on_devede_open_activate(None, list[0]) drag_context.finish(True, False, time) return fine = True list2 = [] for element in list: done, audio = converter.create_default_video_parameters( element) # check if files are videos print done print audio if (done == False): fine = False break list2.append(converter.file_properties) if fine: title, chapter = self.get_marked() element = self.structure[title] for element2 in list2: element.append(element2) self.refresh_chapters() self.set_buttons() else: error = devede_dialogs.show_error( self.gladefile, _("Some files weren't video files.\nNone added.")) error = None drag_context.finish(True, False, time)
def draganddrop(self,widget,drag_context, x, y, selection, info, time): """ Manages the Drag&Drop in the main window """ converter=devede_newfiles.newfile(self.global_vars["PAL"],self.disctocreate) list=converter.split_dnd(selection.data) if (len(list)==1): # check if it's a configuration file filename=list[0].lower() if len(filename)>6: if filename[-7:]==".devede": self.on_devede_open_activate(None, list[0]) drag_context.finish(True,False,time) return fine=True list2=[] for element in list: # Win32 Fix for unicode characters on win32 eg. á element.encode(sys.getfilesystemencoding() done,audio=converter.create_default_video_parameters(element.encode(sys.getfilesystemencoding())) # check if files are videos print done print audio if (done==False): fine=False break list2.append(converter.file_properties) if fine: title,chapter=self.get_marked() element=self.structure[title] for element2 in list2: element.append(element2) self.refresh_chapters() self.set_buttons() else: error=devede_dialogs.show_error(self.gladefile,_("Some files weren't video files.\nNone added.")) error=None drag_context.finish(True,False,time)
def load(self,file_name): """ This method loads a configuration file """ self.done = False if (len(self.structure)>1) or (len(self.structure[0])>1): w = devede_dialogs.ask_overwrite_onload(self.gladefile) retval = w.run() w = None if retval!=-8: return if file_name==None: tree=devede_other.create_tree(self,"wloadconfig",self.gladefile,False) window = tree.get_object("wloadconfig") filter = gtk.FileFilter() filter.add_pattern("*.devede") filter.set_name(".devede") window.add_filter(filter) window.show() retval = window.run() window.hide() if retval!=-5: window.destroy() window = None return file_name=window.get_filename() window.destroy() window = None try: output=open(file_name) except: w = devede_dialogs.show_error(self.gladefile,_("Can't open the file.")) w = None return try: values=pickle.load(output) except: w = devede_dialogs.show_error(self.gladefile,_("That file doesn't contain a disc structure.")) w = None return if values!="DeVeDe": w = devede_dialogs.show_error(self.gladefile,_("That file doesn't contain a disc structure.")) w = None return global_vars2={} try: values=pickle.load(output) global_vars2=pickle.load(output) except: w = devede_dialogs.show_error(self.gladefile,_("That file doesn't contain a DeVeDe structure.")) w = None return output.close() not_found=[] for element in values: for element2 in element[1:]: try: v=os.stat(element2["path"]) except: not_found.append(str(element2["path"])) continue if False==element2.has_key("copy_audio"): element2["copy_audio"]=False # for backward compatibility if False==element2.has_key("sound51"): element2["sound51"]=False # for backward compatibility if False==element2.has_key("rotate"): element2["rotate"]=0 if False==element2.has_key("vmirror"): element2["vmirror"]=False if False==element2.has_key("hmirror"): element2["hmirror"]=False if False==element2.has_key("gop12"): element2["gop12"]=True # for backward compatibility if False==element2.has_key("isvob"): element2["isvob"]=False # for backward compatibility if False==element2.has_key("swap_fields"): element2["swap_fields"]=False # for backward compatibility if False==element2.has_key("twopass"): element2["twopass"]=False # for backward compatibility if False==element2.has_key("turbo1stpass"): element2["turbo1stpass"]=False # for backward compatibility if False==element2.has_key("subfont_size"): element2["subfont_size"]=28 # subtitle font size if False==element2.has_key("sub_fill_color"): element2["sub_fill_color"]=[65535,65535,65535,65535] # subtitle fill color if False==element2.has_key("sub_outline_color"): element2["sub_outline_color"]=[0,0,0,65535] # subtitle outline color if False==element2.has_key("volume"): element2["volume"]=100 # default volume (in percentage) if False==element2.has_key("force_subs"): element2["force_subs"]=False # by default, subtitles aren't forced if False==element2.has_key("audio_stream"): fileprop=devede_newfiles.newfile("","") (fine,audio)=fileprop.read_file_values(element2["path"],0) if fine and (audio==0): element2["audio_list"]=fileprop.file_values["audio_list"] element2["audio_stream"]=fileprop.file_values["audio_stream"] fileprop=None if False==element2.has_key("sub_list"): element2["sub_list"]=[] if element2["subtitles"]!="": tmp={} tmp["subtitles"]=element2["subtitles"] tmp["sub_codepage"]=element2["sub_codepage"] tmp["sub_language"]="EN (ENGLISH)" tmp["subtitles_up"]=element2["subtitles_up"] del element2["subtitles"] del element2["sub_codepage"] del element2["subtitles_up"] element2["sub_list"].append(tmp) if len(not_found)!=0: t_string=_("Can't find the following movie files. Please, add them and try to load the disc structure again.\n") for element in not_found: t_string+="\n"+element w = devede_dialogs.show_error(self.gladefile,t_string) w = None return try: os.stat(global_vars2["menu_bg"]) except: w = devede_dialogs.show_error(self.gladefile,_("Can't find the menu background. I'll open the disc structure anyway with the default menu background, so don't forget to fix it before creating the disc.")) w = None global_vars2["menu_bg"]=os.path.join(self.global_vars["path"],"backgrounds","default_bg.png") use_default_sound=False if False==global_vars2.has_key("menu_sound"): use_default_sound=True else: if (global_vars2["menu_sound"][-11:]=="silence.mp3"): global_vars2["menu_sound"]=os.path.join(self.global_vars["path"],"silence.ogg") try: os.stat(global_vars2["menu_sound"]) except: use_default_sound=True w = devede_dialogs.show_error(self.gladefile,_("Can't find the menu soundtrack file. I'll open the disc structure anyway with a silent soundtrack, so don't forget to fix it before creating the disc.")) w = None if (use_default_sound): global_vars2["menu_sound"]=os.path.join(self.global_vars["path"],"silence.ogg") if False==global_vars2.has_key("with_menu"): global_vars2["with_menu"]=True if False==global_vars2.has_key("menu_halignment"): global_vars2["menu_halignment"]=2 # center if False==global_vars2.has_key("menu_shadow_color"): global_vars2["menu_shadow_color"]=[0,0,0,0] if False==global_vars2.has_key("menu_title_shadow"): global_vars2["menu_title_shadow"]=[0,0,0,0] test=devede_newfiles.file_get_params() check,channels=test.read_file_values(global_vars2["menu_sound"],True) if (check!=False) or (channels!=1): global_vars2["menu_sound"]=os.path.join(self.global_vars["path"],"silence.ogg") w = devede_dialogs.show_error(self.gladefile,_("The menu soundtrack seems damaged. Using the default silent soundtrack.")) w = None check,channels=test.read_file_values(global_vars2["menu_sound"],True) global_vars2["menu_sound_duration"]=test.length test=None while (len(self.structure)>0): self.structure.pop() for element in values: self.structure.append(element) for element in global_vars2: self.global_vars[element]=global_vars2[element] if self.global_vars.has_key("menu_top_margin")==False: self.global_vars["menu_top_margin"]=0.125 self.global_vars["menu_bottom_margin"]=0.125 self.global_vars["menu_left_margin"]=0.1 self.global_vars["menu_right_margin"]=0.1 if self.global_vars.has_key("menu_bgcolor")==False: self.global_vars["menu_bgcolor"]=[0,0,0,49152] self.global_vars["menu_font_color"]=[65535,65535,65535] self.global_vars["menu_selc_color"]=[0,65535,65535,65535] self.global_vars["menu_alignment"]=2 # middle if self.global_vars.has_key("menu_title_text")==False: self.global_vars["menu_title_color"]=[0,0,0,65535] self.global_vars["menu_title_text"]="" self.global_vars["menu_title_fontname"]="Sans 14" if global_vars2.has_key("erase_files")==False: w=self.tree.get_object("create_iso") w.set_active(True) self.global_vars["struct_name"]=file_name # update the path self.done = True