def run(self): """Sets up widgets and run the dialog.""" # TODO: in "onApplyButtonClicked", we only use the first stream... # If we have multiple audio or video streams, we should reflect that # in the UI, instead of acting as if there was only one. But that means # dynamically creating checkboxes and labels in a table and such. for stream in self.audio_streams: self.channels.set_text(format_audiochannels(stream)) self.sample_rate.set_text(format_audiorate(stream)) self.has_audio = True break for stream in self.video_streams: self.size_width.set_text(str(stream.get_square_width())) self.size_height.set_text(str(stream.get_height())) self.is_image = stream.is_image() if not self.is_image: num = stream.get_framerate_num() denom = stream.get_framerate_denom() if denom != 0: fps = num / denom else: fps = 0 if fps > 500: # Sometimes you have "broken" 1000fps clips (WebM files # from YouTube, for example), but it could also be a # real framerate, so just uncheck instead of disabling: self.framerate_checkbutton.set_active(False) elif fps == 0: self.frame_rate.set_text(_("Variable")) self.framerate_checkbutton.set_active(False) # For consistency, insensitize the checkbox AND value # labels self.framerate_checkbutton.set_sensitive(False) self.frame_rate.set_sensitive(False) else: self.frame_rate.set_text(format_framerate(stream)) par_num = stream.get_par_num() par_denom = stream.get_par_denom() aspect_ratio = "{0:n}:{1:n}".format(par_num, par_denom) self.aspect_ratio.set_text(aspect_ratio) self.has_video = True break if not self.has_video: self.frame1.hide() if not self.has_audio: self.frame2.hide() if self.is_image: self.hbox2.hide() self.hbox3.hide() self.video_header_label.set_markup("<b>" + _("Image:") + "</b>") self.dialog.connect("key-press-event", self._keyPressCb) self.dialog.connect("response", self.__response_cb) self.dialog.run()
def __check(self, channels, expected): stream = mock.Mock(spec=GstPbutils.DiscovererAudioInfo) stream.get_channels = mock.Mock(return_value=channels) self.assertEqual(format_audiochannels(stream), expected) self.assertEqual(format_audiochannels(channels), expected)
def run(self): """Sets up widgets and run the dialog.""" # TODO: in "onApplyButtonClicked", we only use the first stream... # If we have multiple audio or video streams, we should reflect that # in the UI, instead of acting as if there was only one. But that means # dynamically creating checkboxes and labels in a table and such. for stream in self.audio_streams: self.channels.set_text(format_audiochannels(stream)) self.sample_rate.set_text(format_audiorate(stream)) self.has_audio = True break for stream in self.video_streams: self.size_width.set_text(str(stream.get_square_width())) self.size_height.set_text(str(stream.get_height())) self.is_image = stream.is_image() if not self.is_image: num = stream.get_framerate_num() denom = stream.get_framerate_denom() if denom != 0: fps = num / denom else: fps = 0 if fps > 500: # Sometimes you have "broken" 1000fps clips (WebM files # from YouTube, for example), but it could also be a # real framerate, so just uncheck instead of disabling: self.framerate_checkbutton.set_active(False) elif fps == 0: self.frame_rate.set_text(_("Variable")) self.framerate_checkbutton.set_active(False) # For consistency, insensitize the checkbox AND value # labels self.framerate_checkbutton.set_sensitive(False) self.frame_rate.set_sensitive(False) else: self.frame_rate.set_text(format_framerate(stream)) par_num = stream.get_par_num() par_denom = stream.get_par_denom() aspect_ratio = "{0:n}:{1:n}".format(par_num, par_denom) self.aspect_ratio.set_text(aspect_ratio) self.has_video = True break if not self.has_video: self.frame1.hide() if not self.has_audio: self.frame2.hide() if self.is_image: self.frame_rate.hide() self.aspect_ratio.hide() self.PAR_checkbutton.hide() self.framerate_checkbutton.hide() self.video_header_label.set_markup("<b>" + _("Image:") + "</b>") self.dialog.connect("key-press-event", self._keyPressCb) self.dialog.connect("response", self.__response_cb) self.dialog.run()
def __check(self, channels, expected): stream = Mock(spec=GstPbutils.DiscovererAudioInfo) stream.get_channels = Mock(return_value=channels) self.assertEqual(format_audiochannels(stream), expected) self.assertEqual(format_audiochannels(channels), expected)