def __init__(self, sink, config): Gtk.Window.__init__(self, Gtk.WindowType.TOPLEVEL) self.set_title(NAME) try: self.set_icon( myGtk.iconfactory.get_icon("ch.x29a.playitslowly", 128)) except GObject.GError: print("could not load playitslowly icon") self.set_default_size(600, 200) self.set_border_width(5) self.vbox = Gtk.VBox() self.accel_group = Gtk.AccelGroup() self.add_accel_group(self.accel_group) self.pipeline = Pipeline(sink) self.filedialog = myGtk.FileChooserDialog(None, self, Gtk.FileChooserAction.OPEN) self.filedialog.connect("response", self.filechanged) self.filedialog.set_local_only(False) filechooserhbox = Gtk.HBox() self.filechooser = Gtk.FileChooserButton.new_with_dialog( self.filedialog) self.filechooser.set_local_only(False) filechooserhbox.pack_start(self.filechooser, True, True, 0) self.recentbutton = Gtk.Button(_("Recent")) self.recentbutton.connect("clicked", self.show_recent) filechooserhbox.pack_end(self.recentbutton, False, False, 0) self.speedchooser = myGtk.TextScaleReset( Gtk.Adjustment.new(1.00, 0.10, 4.0, 0.05, 0.05, 0)) self.speedchooser.scale.connect("value-changed", self.speedchanged) self.speedchooser.scale.connect("button-press-event", self.speedpress) self.speedchooser.scale.connect("button-release-event", self.speedrelease) self.speedchangeing = False pitch_adjustment = Gtk.Adjustment.new(0.0, -24.0, 24.0, 1.0, 1.0, 1.0) self.pitchchooser = myGtk.TextScaleReset(pitch_adjustment) self.pitchchooser.scale.connect("value-changed", self.pitchchanged) self.pitchchooser_fine = myGtk.TextScaleReset( Gtk.Adjustment.new(0.0, -50, 50, 1.0, 1.0, 1.0)) self.pitchchooser_fine.scale.connect("value-changed", self.pitchchanged) self.positionchooser = myGtk.ClockScale( Gtk.Adjustment.new(0.0, 0.0, 100.0, 0, 0, 0)) self.positionchooser.scale.connect("button-press-event", self.start_seeking) self.positionchooser.scale.connect("button-release-event", self.positionchanged) self.seeking = False self.startchooser = myGtk.TextScaleWithCurPos( self.positionchooser, Gtk.Adjustment.new(0.0, 0, 100.0, 0, 0, 0)) self.startchooser.scale.connect("button-press-event", self.start_seeking) self.startchooser.scale.connect("button-release-event", self.seeked) self.startchooser.add_accelerator("clicked", self.accel_group, ord('['), Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE) self.startchooser.add_accelerator("clicked", self.accel_group, ord('['), 0, Gtk.AccelFlags.VISIBLE) self.endchooser = myGtk.TextScaleWithCurPos( self.positionchooser, Gtk.Adjustment.new(1.0, 0, 100.0, 0.01, 0.01, 0)) self.endchooser.scale.connect("button-press-event", self.start_seeking) self.endchooser.scale.connect("button-release-event", self.seeked) self.endchooser.add_accelerator("clicked", self.accel_group, ord(']'), Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE) self.endchooser.add_accelerator("clicked", self.accel_group, ord(']'), 0, Gtk.AccelFlags.VISIBLE) self.vbox.pack_start(filechooserhbox, False, False, 0) self.vbox.pack_start(self.positionchooser, True, True, 0) self.vbox.pack_start( myGtk.form([(_("Speed (times)"), self.speedchooser), (_("Pitch (semitones)"), self.pitchchooser), (_("Fine Pitch (cents)"), self.pitchchooser_fine), (_("Start Position (seconds)"), self.startchooser), (_("End Position (seconds)"), self.endchooser)]), False, False, 0) buttonbox = Gtk.HButtonBox() myGtk.add_style_class(buttonbox, 'buttonBox') self.vbox.pack_end(buttonbox, False, False, 0) self.play_button = Gtk.ToggleButton(stock=Gtk.STOCK_MEDIA_PLAY) self.play_button.connect("toggled", self.play) self.play_button.set_use_stock(True) self.play_button.set_sensitive(False) buttonbox.pack_start(self.play_button, True, True, 0) self.play_button.add_accelerator("clicked", self.accel_group, ord(' '), 0, Gtk.AccelFlags.VISIBLE) self.back_button = Gtk.Button.new_from_stock(Gtk.STOCK_MEDIA_REWIND) self.back_button.connect("clicked", self.back) #self.back_button.set_use_stock(True) self.back_button.set_sensitive(False) buttonbox.pack_start(self.back_button, True, True, 0) self.volume_button = Gtk.VolumeButton() self.volume_button.set_value(1.0) self.volume_button.set_relief(Gtk.ReliefStyle.NORMAL) self.volume_button.connect("value-changed", self.volumechanged) buttonbox.pack_start(self.volume_button, True, True, 0) self.save_as_button = Gtk.Button.new_from_stock(Gtk.STOCK_SAVE_AS) self.save_as_button.connect("clicked", self.save) self.save_as_button.set_sensitive(False) buttonbox.pack_start(self.save_as_button, True, True, 0) button_about = Gtk.Button.new_from_stock(Gtk.STOCK_ABOUT) button_about.connect("clicked", self.about) buttonbox.pack_end(button_about, True, True, 0) self.connect("key-release-event", self.key_release) self.add(self.vbox) self.connect("destroy", Gtk.main_quit) self.config = config self.config_saving = False self.load_config()
def __init__(self, sink, config): gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) self.set_title(NAME) try: self.set_icon(mygtk.iconfactory.get_icon("playitslowly", 128)) except gobject.GError: print "could not load playitslowly icon" self.set_default_size(500, 200) self.set_border_width(5) self.vbox = gtk.VBox() self.accel_group = gtk.AccelGroup() self.add_accel_group(self.accel_group) self.pipeline = Pipeline(sink) self.filedialog = mygtk.FileChooserDialog(None, self, gtk.FILE_CHOOSER_ACTION_OPEN) self.filedialog.connect("response", self.filechanged) self.filedialog.set_local_only(False) filechooserhbox = gtk.HBox() self.filechooser = gtk.FileChooserButton(self.filedialog) self.filechooser.set_local_only(False) filechooserhbox.pack_start(self.filechooser, True, True) self.recentbutton = gtk.Button(_("Recent")) self.recentbutton.connect("clicked", self.show_recent) filechooserhbox.pack_end(self.recentbutton, False, False) self.speedchooser = mygtk.TextScaleReset( gtk.Adjustment(1.00, 0.10, 4.0, 0.05, 0.05)) self.speedchooser.scale.connect("value-changed", self.speedchanged) self.speedchooser.scale.connect("button-press-event", self.speedpress) self.speedchooser.scale.connect("button-release-event", self.speedrelease) self.speedchangeing = False self.pitchchooser = mygtk.TextScaleReset( gtk.Adjustment(0.0, -24.0, 24.0, 1.0, 1.0, 1.0)) self.pitchchooser.scale.connect("value-changed", self.pitchchanged) self.pitchchooser_fine = mygtk.TextScaleReset( gtk.Adjustment(0.0, -50, 50, 1.0, 1.0, 1.0)) self.pitchchooser_fine.scale.connect("value-changed", self.pitchchanged) self.positionchooser = mygtk.ClockScale(gtk.Adjustment( 0.0, 0.0, 100.0)) self.positionchooser.scale.connect("button-press-event", self.start_seeking) self.positionchooser.scale.connect("button-release-event", self.positionchanged) self.seeking = False self.startchooser = mygtk.TextScaleWithCurPos( self.positionchooser, gtk.Adjustment(0.0, 0, 100.0)) self.startchooser.scale.connect("button-press-event", self.start_seeking) self.startchooser.scale.connect("button-release-event", self.seeked) self.startchooser.add_accelerator("clicked", self.accel_group, ord('['), gtk.gdk.CONTROL_MASK, ()) self.startchooser.add_accelerator("clicked", self.accel_group, ord('['), 0, ()) self.endchooser = mygtk.TextScaleWithCurPos( self.positionchooser, gtk.Adjustment(1.0, 0, 100.0, 0.01, 0.01)) self.endchooser.scale.connect("button-press-event", self.start_seeking) self.endchooser.scale.connect("button-release-event", self.seeked) self.endchooser.add_accelerator("clicked", self.accel_group, ord(']'), gtk.gdk.CONTROL_MASK, ()) self.endchooser.add_accelerator("clicked", self.accel_group, ord(']'), 0, ()) self.vbox.pack_start(filechooserhbox) self.vbox.pack_start(self.positionchooser) self.vbox.pack_start( mygtk.form([(_(u"Speed (times)"), self.speedchooser), (_(u"Pitch (semitones)"), self.pitchchooser), (_(u"Fine Pitch (cents)"), self.pitchchooser_fine), (_(u"Start Position (seconds)"), self.startchooser), (_(u"End Position (seconds)"), self.endchooser)]), False, False) buttonbox = gtk.HButtonBox() self.vbox.pack_end(buttonbox, False, False) self.play_button = gtk.ToggleButton(gtk.STOCK_MEDIA_PLAY) self.play_button.connect("toggled", self.play) self.play_button.set_use_stock(True) self.play_button.set_sensitive(False) buttonbox.pack_start(self.play_button) # make SPACE a shortcut for play/pause (CTRL-SPC would be better?) self.play_button.add_accelerator("clicked", self.accel_group, ord(' '), 0, ()) self.back_button = gtk.Button(gtk.STOCK_MEDIA_REWIND) self.back_button.connect("clicked", self.back) self.back_button.set_use_stock(True) self.back_button.set_sensitive(False) buttonbox.pack_start(self.back_button) self.volume_button = gtk.VolumeButton() self.volume_button.set_value(1.0) self.volume_button.set_relief(gtk.RELIEF_NORMAL) self.volume_button.connect("value-changed", self.volumechanged) buttonbox.pack_start(self.volume_button) self.save_as_button = gtk.Button(stock=gtk.STOCK_SAVE_AS) self.save_as_button.connect("clicked", self.save) self.save_as_button.set_sensitive(False) buttonbox.pack_start(self.save_as_button) button_about = gtk.Button(stock=gtk.STOCK_ABOUT) button_about.connect("clicked", self.about) buttonbox.pack_end(button_about) self.connect("key-release-event", self.key_release) self.add(self.vbox) self.connect("destroy", gtk.main_quit) self.config = config self.config_saving = False self.load_config()