def __init__(self, path="About.glade", root="aboutdialog1", domain="OpenShot", version="0.0.0", project=None, **kwargs): SimpleGladeApp.__init__(self, os.path.join(project.GLADE_DIR, path), root, domain, **kwargs) # Add language support _ = Language_Init.Translator(project).lang.gettext # set version from constructor self.aboutdialog1.set_version(version) # init authors authors = [] for person in info.CREDITS['code']: name = person['name'] email = person['email'] authors.append("%s <%s>" % (name, email)) self.aboutdialog1.set_authors(authors) # init documenters authors = [] for person in info.CREDITS['documentation']: name = person['name'] email = person['email'] authors.append("%s <%s>" % (name, email)) self.aboutdialog1.set_documenters(authors) # init translators self.aboutdialog1.set_translator_credits("Translation credits are located on LaunchPad:\nhttps://translations.launchpad.net/openshot")
def __init__(self, path="TransitionProperties.glade", root="frmTransitionProperties", domain="OpenShot", form=None, project=None, current_transition=None, **kwargs): SimpleGladeApp.__init__(self, os.path.join(project.GLADE_DIR, path), root, domain, **kwargs) # Add language support _ = Language_Init.Translator(project).lang.gettext self._ = _ # add items to direction combo options = [_("Transition"), _("Mask")] # loop through export to options for option in options: # append profile to list self.cboType.append_text(option) # add items to direction combo options = [_("Up"), _("Down")] # loop through export to options for option in options: # append profile to list self.cboDirection.append_text(option) self.form = form self.project = project self.current_transition = current_transition self.frmTransitionProperties.show_all() # init the project type properties self.lblName.set_text(self.current_transition.name) self.hsSoftness.set_value(self.current_transition.softness * 100.0) self.hsThreshold.set_value(self.current_transition.mask_value) # set the dropdown boxes self.set_type_dropdown() self.set_direction_dropdown()
def __init__(self, instance, path="fontselector.glade", root="frmFontProperties", domain="OpenShot", project=None, **kwargs): SimpleGladeApp.__init__(self, os.path.join(project.GLADE_DIR, path), root, domain, **kwargs) # Add language support _ = Language_Init.Translator(project).lang.gettext self.calling_form = instance #get the list of available fonts fonts = gtk.ListStore(pango.FontFamily, str) self.init_treeview(self.treeFontList) pc = self.frmFontProperties.get_pango_context() for family in pc.list_families(): markup = "<span font_family=\"%s\">%s</span>" % (family.get_name(), family.get_name()) fonts.append([family, markup]) self.treeFontList.set_model(fonts) #sort the fonts alphabetically fonts.set_sort_column_id(1, gtk.SORT_ASCENDING) #add the callbacks self.treeFontList.connect("cursor-changed", self.family_changed_cb) self.btnItalic.connect("toggled", self.style_changed_cb) self.btnBold.connect("toggled", self.weight_changed_cb) self.frmFontProperties.show_all()
def __init__(self, path="profiles.glade", root="frmProfiles", domain="OpenShot", form=None, project=None, **kwargs): SimpleGladeApp.__init__(self, os.path.join(project.GLADE_DIR, path), root, domain, **kwargs) # Add language support _ = Language_Init.Translator(project).lang.gettext self._ = _ self.project = project self.form = form self.settings = preferences.Settings(self.project) self.settings.load_settings_from_xml() #find path where openshot is running self.path = self.project.BASE_DIR # init the list of possible project types / profiles self.profile_list = profiles.mlt_profiles(self.project).get_profile_list() # loop through each profile, and add it to the dropdown for file_name, p in self.profile_list: # append profile to list self.cmbProjectType.append_text(p.description()) self.save_prompt = False image = gtk.Image() image.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON) self.btnImport.set_image(image) self.frmProfiles.show_all() #set the default profile self.set_project_type_dropdown(self.settings.general["default_profile"])
def __init__(self, path="ImportImageSeq.glade", root="frmImportImageSequence", domain="OpenShot", form=None, project=None, **kwargs): SimpleGladeApp.__init__(self, os.path.join(project.GLADE_DIR, path), root, domain, **kwargs) # Add language support _ = Language_Init.Translator(project).lang.gettext self.form = form self.project = project self.frmImportImageSequence.show_all()
def __init__(self, file, path="FileProperties.glade", root="frmFileProperties", domain="OpenShot", form=None, project=None, **kwargs): SimpleGladeApp.__init__(self, os.path.join(project.GLADE_DIR, path), root, domain, **kwargs) # Add language support _ = Language_Init.Translator(project).lang.gettext self.form = form self.project = project self.file = file #set the thumbnail - use the preview thumbnail #for video & image files if file.file_type != "audio": if file.thumb_location != "": pixbuf = gtk.gdk.pixbuf_new_from_file(file.thumb_location) pixbuf = pixbuf.scale_simple(112,83,gtk.gdk.INTERP_BILINEAR) self.imgPreview.set_from_pixbuf(pixbuf) else: #use the generic OpenShot audio thumbnail pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(IMAGE_DIR, "AudioThumbnail.png")) pixbuf = pixbuf.scale_simple(112,83,gtk.gdk.INTERP_BILINEAR) self.imgPreview.set_from_pixbuf(pixbuf) #set the file type self.lblMimeType.set_label(file.file_type) #if the file name is too long to fit the space, add ellipses and a tooltip. self.lblLocation1.set_text(file.name) #self.lblLocation1.set_tooltip_text(file.name) #self.lblLocation1.set_ellipsize(pango.ELLIPSIZE_END) #format the file length milliseconds = file.length * 1000 time = timeline.timeline().get_friendly_time(milliseconds) hours = time[2] mins = time[3] secs = time[4] milli = time[5] time_str = "%02d:%02d:%02d" % (time[2], time[3], time[4]) self.lblLengthValue.set_label(time_str) #project label self.txtLabel.set_text(file.label) if file.file_type.startswith("video"): #video specific properties self.lblRateValue.set_label(str(file.videorate[0]) + "/" + str(file.videorate[1])) self.lblSizeValue.set_label(str(file.width) + " x " + str(file.height)) else: self.lblRate.set_sensitive(False) self.lblSize.set_sensitive(False) #show the form self.frmFileProperties.show_all()
def __init__(self, path="OpenProject.glade", root="frmOpenProject", domain="OpenShot", project=None, **kwargs): SimpleGladeApp.__init__(self, os.path.join(project.GLADE_DIR, path), root, domain, **kwargs) self.project = project self.form = self.project.form # Add language support _ = Language_Init.Translator(project).lang.gettext # set a file type filter (to limit the files to only valid files) OSPfilter = gtk.FileFilter() OSPfilter.add_pattern("*.osp") OSPfilter.set_name(_("OpenShot Project (*.osp)")) self.frmOpenProject.add_filter(OSPfilter)
def __init__(self, path="AddEffect.glade", root="frmAddEffect", domain="OpenShot", parent=None, form=None, project=None, **kwargs): SimpleGladeApp.__init__(self, os.path.join(project.GLADE_DIR, path), root, domain, **kwargs) # Add language support _ = Language_Init.Translator(project).lang.gettext self.form = form self.project = project self.parent = parent self.frmAddEffect.show_all() # Init List of Effects effect_list = self.form.effect_list # Add effects to dropdown for my_effect in effect_list: # add item self.cboEffects.append_text(my_effect.title)
def __init__(self, path="AddFiles.glade", root="frmAddFiles", domain="OpenShot", form=None, project=None, **kwargs): SimpleGladeApp.__init__(self, os.path.join(project.GLADE_DIR, path), root, domain, **kwargs) # Add language support _ = Language_Init.Translator(project).lang.gettext self.frmAddFiles.set_action(gtk.FILE_CHOOSER_ACTION_OPEN) self.frmAddFiles.set_select_multiple(True) #if the video folder exists, default to this #video_dir = os.path.join(os.path.expanduser("~"), "Video") #if video_dir: # self.frmAddFiles.set_current_folder(video_dir) self.form = form self.project = project #open the last used folder default_folder = preferences.Settings.app_state["import_folder"] if default_folder != "None": self.frmAddFiles.set_current_folder(preferences.Settings.app_state["import_folder"]) self.frmAddFiles.show_all()
def __init__(self, instance, path="titles.glade", root="frmEditText", domain="OpenShot", number_of_text_boxes=0, tspans=None, project=None, **kwargs): SimpleGladeApp.__init__(self, os.path.join(project.GLADE_DIR, path), root, domain, **kwargs) # Add language support _ = Language_Init.Translator(project).lang.gettext self.frmTitles = instance self.tspans = tspans self.number_of_text_boxes = number_of_text_boxes self.accepted = False for i in range(0, self.number_of_text_boxes): # get text in SVG SVG_Text = "" if len(tspans[i].childNodes) > 0: SVG_Text = tspans[i].childNodes[0].data # create textbox & add to window tbox = gtk.Entry(max=0) tbox.set_text(SVG_Text) self.vbox3.pack_start(tbox, expand=True, fill=False) self.frmEditText.show_all()
def __init__(self, mode="", path="NewProject.glade", root="frmNewProject", domain="OpenShot", project=None, **kwargs): print "init" SimpleGladeApp.__init__(self, os.path.join(project.GLADE_DIR, path), root, domain, **kwargs) # Add language support _ = Language_Init.Translator(project).lang.gettext # project instance self.project = project self.form = project.form # check the mode of the form (i.e. new project or save as screen) self.mode = mode # init the project type properties self.init_properties() # init the list of possible project types / profiles self.profile_list = profiles.mlt_profiles(self.project).get_profile_list() # loop through each profile, and add it to the dropdown for file_name, p in self.profile_list: # append profile to list self.cmbProjectType.append_text(p.description()) # get the model and iterator of the project type dropdown box model = self.cmbProjectType.get_model() iter = model.get_iter_first() while True: # get the value of each item in the dropdown value = model.get_value(iter, 0) # check for the matching project type if self.project.project_type == value: # set the item as active self.cmbProjectType.set_active_iter(iter) # get the next item in the list iter = model.iter_next(iter) # break loop when no more dropdown items are found if iter is None: break # SET THE SAVE FOLDER LOCATION if ".openshot" in self.project.folder: # This is the openshot default project (set the folder to 'DESKTOP') self.fileProjectFolder.set_current_folder(self.project.DESKTOP) elif len(self.project.folder) > 0: # set default folder (if there is a current folder) self.fileProjectFolder.set_current_folder(self.project.folder) if (self.mode == "saveas"): # init the values (based on the mode) self.txtProjectName.set_text(self.project.name) self.spinProjectLength.set_text(str(self.project.sequences[0].length / 60))
def __init__(self, path="ExportVideo.glade", root="frmExportVideo", domain="OpenShot", form=None, project=None, **kwargs): SimpleGladeApp.__init__(self, os.path.join(project.GLADE_DIR, path), root, domain, **kwargs) # Add language support _ = Language_Init.Translator(project).lang.gettext self._ = _ self.form = form self.project = project self.frmExportVideo.show_all() self.invalid_codecs = [] # init the project type properties self.init_properties(self.cmbProjectType.get_active_text()) # set the export file name self.txtFileName.set_text(self.project.name) # set the export folder as the project folder (if any) if ".openshot" in self.project.folder: # This is the openshot default project (set the folder to 'DESKTOP') self.fileExportFolder.set_current_folder(self.project.DESKTOP) else: # Set project folder self.fileExportFolder.set_current_folder(self.project.folder) # init the list of possible project types / profiles self.profile_list = profiles.mlt_profiles(self.project).get_profile_list() # loop through each profile, and add it to the dropdown for file_name, p in self.profile_list: # append profile to list self.cmbProjectType.append_text(p.description()) export_options = [_("Video & Audio"), _("Image Sequence")] # loop through export to options for option in export_options: # append profile to list self.cboExportTo.append_text(option) #populate the format/codec drop downs #formats format_model = self.cboVIdeoFormat.get_model() format_model.clear() for format in self.form.vformats: self.cboVIdeoFormat.append_text(format) #video codecs vcodecs_model = self.cboVideoCodec.get_model() vcodecs_model.clear() for vcodec in self.form.vcodecs: self.cboVideoCodec.append_text(vcodec) #audio codecs acodecs_model = self.cboAudioCodec.get_model() acodecs_model.clear() for acodec in self.form.acodecs: self.cboAudioCodec.append_text(acodec) # set the dropdown boxes self.set_project_type_dropdown() self.set_export_to_dropdown() #load the simple project type dropdown presets = [] for file in os.listdir(self.project.EXPORT_PRESETS_DIR): xmldoc = xml.parse(os.path.join(self.project.EXPORT_PRESETS_DIR,file)) type = xmldoc.getElementsByTagName("type") presets.append(_(type[0].childNodes[0].data)) #exclude duplicates presets = list(set(presets)) for item in sorted(presets): self.cboSimpleProjectType.append_text(item) #indicate that exporting cancelled self.cancelled = False
def __init__(self, path="ClipProperties.glade", root="frmClipProperties", domain="OpenShot", form=None, project=None, current_clip=None, current_clip_item=None, **kwargs): SimpleGladeApp.__init__(self, os.path.join(project.GLADE_DIR, path), root, domain, **kwargs) # Add language support _ = Language_Init.Translator(project).lang.gettext self._ = _ self.form = form self.project = project self.current_clip = current_clip self.current_clip_item = current_clip_item self.restore_window_size() self.frmClipProperties.show_all() # Stop the video thread consumer self.form.MyVideo.pause() self.form.MyVideo.c.stop() # Force SDL to write on our drawing area os.putenv('SDL_WINDOWID', str(self.previewscreen.window.xid)) gtk.gdk.flush() # make a copy of the current clip (for preview reasons) self.copy_of_clip = copy.copy(self.current_clip) self.copy_of_clip.keyframes = copy.deepcopy(self.current_clip.keyframes) self.copy_of_clip.effects = copy.deepcopy(self.current_clip.effects) self.copy_of_clip.position_on_track = 0 # add items to direction combo options = ["16x", "15x", "14x", "13x", "12x", "11x", "10x", "9x", "8x", "7x", "6x", "5x", "4x", "3x", "2x", _("Normal Speed"), "1/2", "1/3", "1/4", "1/5", "1/6", "1/7", "1/8", "1/9", "1/10", "1/11", "1/12", "1/13", "1/14", "1/15", "1/16" ] # loop through export to options for option in options: # append profile to list self.cboSimpleSpeed.append_text(option) # add items to direction combo options = [_("Forward"), _("Reverse")] # loop through export to options for option in options: # append profile to list self.cboDirection.append_text(option) # add items to direction combo options = [_("Start of Clip"), _("End of Clip")] # loop through export to options for option in options: # append profile to list self.cboKeyFrame.append_text(option) # get file name (dirName, fname) = os.path.split(self.current_clip.file_object.name) # get a local keyframe collection self.keyframes = copy.deepcopy(self.current_clip.keyframes) self.current_keyframe = "" # init the default properties self.txtFileName.set_text(fname) self.txtLength.set_value(self.current_clip.length()) self.txtIn.set_value(round(self.current_clip.start_time, 11)) self.txtOut.set_value(round(self.current_clip.end_time, 11)) self.txtAudioFadeAmount.set_value(round(self.current_clip.audio_fade_amount, 11)) self.txtVideoFadeAmount.set_value(round(self.current_clip.video_fade_amount, 11)) self.sliderVolume.set_value(self.current_clip.volume) self.chkFill.set_active(self.current_clip.fill) if self.current_clip.distort: self.chkMaintainAspect.set_active(False) else: self.chkMaintainAspect.set_active(True) self.chkVideoFadeIn.set_active(self.current_clip.video_fade_in) self.chkVideoFadeOut.set_active(self.current_clip.video_fade_out) self.chkAudioFadeIn.set_active(self.current_clip.audio_fade_in) self.chkAudioFadeOut.set_active(self.current_clip.audio_fade_out) self.spinAdvancedSpeed.set_value(self.current_clip.speed) self.set_horizontal_align_dropdown() self.set_vertical_align_dropdown() self.chkEnableVideo.set_active(self.current_clip.play_video) self.chkEnableAudio.set_active(self.current_clip.play_audio) self.set_direction_dropdown() self.set_keyframe_dropdown() self.set_speed_dropdown() # update effects tree self.OSTreeEffects = TreeEffects.OpenShotTree(self.treeEffects, self.project) self.update_effects_tree() # Refresh XML self.RefreshPreview() # start and stop the video self.form.MyVideo.play() self.form.MyVideo.pause() # mark project as modified # so that the real project is refreshed... even if these # preview changes are not accepted self.project.set_project_modified(is_modified=False, refresh_xml=True)
def __init__( self, path="Preferences.glade", root="frmPreferences", domain="OpenShot", form=None, project=None, **kwargs ): SimpleGladeApp.__init__(self, os.path.join(project.GLADE_DIR, path), root, domain, **kwargs) # Add language support _ = Language_Init.Translator(project).lang.gettext self._ = _ self.project = project self.form = form self.settings = Settings(self.project) if getIconPath("openshot"): self.frmPreferences.set_icon_from_file(getIconPath("openshot")) view = self.icvCategories self.model = gtk.ListStore(str, gtk.gdk.Pixbuf) # Populate the form with the preference category icons # General section pixbuf = view.render_icon(gtk.STOCK_PREFERENCES, size=gtk.ICON_SIZE_BUTTON, detail=None) self.model.append([_("General"), pixbuf]) # Formats section pixbuf = view.render_icon(gtk.STOCK_INFO, size=gtk.ICON_SIZE_BUTTON, detail=None) self.model.append([_("AV Formats"), pixbuf]) # Formats section pixbuf = view.render_icon(gtk.STOCK_INFO, size=gtk.ICON_SIZE_BUTTON, detail=None) self.model.append([_("Profiles"), pixbuf]) # Connect the iconview with the model view.set_model(self.model) # Map model text and pixbuf columns to iconview view.set_text_column(0) view.set_pixbuf_column(1) # populate the combo boxes # init the list of possible project types / profiles self.profile_list = profiles.mlt_profiles(self.project).get_profile_list() # loop through each profile, and add it to the dropdown for file_name, p in self.profile_list: # append profile to list self.cmbProfiles.append_text(str(file_name)) # populate the themes for dir in os.listdir(self.project.THEMES_DIR): self.cmbThemes.append_text(dir) # populate project file type combo for file_type in ["binary", "ascii"]: self.cmbFileType.append_text(file_type) # populate the codecs & formats self.VCodecList = gtk.ListStore(str) self.tvVCodecs.set_model(self.VCodecList) tree.treeviewAddGeneralTextColumn(self.tvVCodecs, _("Video Codecs"), 0) self.ACodecList = gtk.ListStore(str) self.tvACodecs.set_model(self.ACodecList) tree.treeviewAddGeneralTextColumn(self.tvACodecs, _("Audio Codecs"), 0) self.FormatsList = gtk.ListStore(str) self.tvFormats.set_model(self.FormatsList) tree.treeviewAddGeneralTextColumn(self.tvFormats, _("Formats"), 0) self.populate_codecs() # populate form objects self.txtImageLength.set_text(self.settings.general["imported_image_length"]) self.txtHistoryStackSize.set_text(self.settings.general["max_history_size"]) self.txtMeltCommandName.set_text(self.settings.general["melt_command"]) theme_name = self.settings.general["default_theme"] file_type = self.settings.general["project_file_type"] self.set_dropdown_values(theme_name, self.cmbThemes) self.set_dropdown_values(self.settings.general["default_profile"], self.cmbProfiles) self.set_dropdown_values(file_type, self.cmbFileType) # set the example theme icon self.load_theme_image(theme_name) # show the form self.frmPreferences.show_all()
def __init__(self, path="titles.glade", root="frmTitles", domain="OpenShot", form=None, project=None, file=None, **kwargs): SimpleGladeApp.__init__(self, os.path.join(project.GLADE_DIR, path), root, domain, **kwargs) # Add language support _ = Language_Init.Translator(project).lang.gettext self.project = project self.form = form self.file = file #find path where openshot is running self.path = self.project.BASE_DIR self.cmbTemplate.set_sensitive(True) self.xmldoc = "" self.bg_color_code = "" self.font_color_code = "#ffffff" self.bg_style_string = "" self.title_style_string = "" self.subtitle_style_string = "" self.font_weight = 'normal' self.font_style = 'normal' self.new_title_text = "" self.sub_title_text = "" self.subTitle = False self.display_name = "" self.font_family = "Bitstream Vera Sans" # get the aspect ratio of the current project p = profiles.mlt_profiles(self.project).get_profile(self.project.project_type) # determine which ratio folder to get titles from self.ratio_folder = "" if p.display_aspect_num() == 4 and p.display_aspect_den() == 3: self.ratio_folder = "4_3" else: self.ratio_folder = "16_9" #load the template files self.template_dir = os.path.join(self.path, "openshot", "titles", self.ratio_folder) for file in sorted(os.listdir(self.template_dir)): #pretty up the filename for display purposes if fnmatch.fnmatch(file, '*.svg'): (fileName, fileExtension)=os.path.splitext(file) self.cmbTemplate.append_text(fileName.replace("_"," ")) #add the changed event once the combo has been populated self.cmbTemplate.connect("changed", self.on_cmbTemplate_changed) if not self.file: self.cmbTemplate.grab_focus() # init dropdown self.set_template_dropdown() else: self.filename = self.file self.load_svg_template(self.file) #set edit button states self.btnEditText.set_sensitive(True) self.btnFont.set_sensitive(True) self.btnFontColor.set_sensitive(True) self.btnBackgroundColor.set_sensitive(True) self.btnAdvanced.set_sensitive(True) self.writeToFile(self.xmldoc) #show the text editor #if self.noTitles == False: # self.on_btnEditText_clicked(widget) #preview the file self.set_img_pixbuf(self.filename) self.on_btnEditText_clicked(None) #turn off the create button once we have created the new file self.btnCreate.set_sensitive(False) self.cmbTemplate.set_sensitive(False) if self.noTitles == True: self.btnEditText.set_sensitive(False) self.btnFont.set_sensitive(False) self.btnFontColor.set_sensitive(False)