def run_dialog(self, *args): app = self.parent.application win = self.parent self.__sync_file_filters() if self.file_dlg.run() == gtk.RESPONSE_OK: filename = self.file_dlg.get_filename() basename = os.path.basename(filename) if os.path.exists(filename) and gtkutil.dialog_ok_cancel( _("Replace existing file"), _("A file named <i>%s</i> already exists. " "Do you want to replace it with the one " "you are saving?") % basename, win) != gtk.RESPONSE_OK: self.file_dlg.unselect_all() self.file_dlg.hide() return try: oper = app.savePlaylist.save(filename) except SerpentineNotSupportedError: gtkutil.dialog_error( _("Unsupported Format"), _("The playlist format you used (by the file extension) is " "currently not supported."), win) oper.listeners.append(self) oper.start() self.file_dlg.unselect_all() self.file_dlg.hide()
def run_dialog (self, *args): app = self.parent.application win = self.parent self.__sync_file_filters () if self.file_dlg.run () == gtk.RESPONSE_OK: filename = self.file_dlg.get_filename () basename = os.path.basename (filename) if os.path.exists (filename) and gtkutil.dialog_ok_cancel ( _("Replace existing file"), _("A file named <i>%s</i> already exists. " "Do you want to replace it with the one " "you are saving?") % basename, win ) != gtk.RESPONSE_OK: self.file_dlg.unselect_all() self.file_dlg.hide() return try: oper = app.savePlaylist.save (filename) except SerpentineNotSupportedError: gtkutil.dialog_error ( _("Unsupported Format"), _("The playlist format you used (by the file extension) is " "currently not supported."), win ) oper.listeners.append (self) oper.start () self.file_dlg.unselect_all() self.file_dlg.hide()
def __insert_cd(self, rec, reload_media, can_rewrite, busy_cd): # messages from nautilus-burner-cd.c if busy_cd: msg = _("Please make sure another application is not using the drive.") title = _("Drive is busy") elif not reload_media and can_rewrite: msg = _("Please put a rewritable or blank disc into the drive.") title = _("Insert rewritable or blank disc") elif not reload_media and not can_rewrite: msg = _("Please put a blank disc into the drive.") title = _("Insert blank disc") elif can_rewrite: msg = _("Please replace the disc in the drive with a " "rewritable or blank disc.") title = _("Reload rewritable or blank disc") else: msg = _("Please replace the disc in the drive a blank disc.") title = _("Reload blank disc") return gtkutil.dialog_ok_cancel(title, msg, parent=self.parent) == gtk.RESPONSE_OK
def __insert_cd(self, rec, reload_media, can_rewrite, busy_cd): # messages from nautilus-burner-cd.c if busy_cd: msg = _( "Please make sure another application is not using the drive.") title = _("Drive is busy") elif not reload_media and can_rewrite: msg = _("Please put a rewritable or blank disc into the drive.") title = _("Insert rewritable or blank disc") elif not reload_media and not can_rewrite: msg = _("Please put a blank disc into the drive.") title = _("Insert blank disc") elif can_rewrite: msg = _("Please replace the disc in the drive with a " "rewritable or blank disc.") title = _("Reload rewritable or blank disc") else: msg = _("Please replace the disc in the drive a blank disc.") title = _("Reload blank disc") return gtkutil.dialog_ok_cancel(title, msg, self.parent) == gtk.RESPONSE_OK
class SerpentineWindow(gtk.Window, OperationListener, operations.Operation, Component): # TODO: finish up implementing an Operation components = (AddFileComponent, PlaylistComponent, SavePlaylistComponent, ToolbarComponent) def __init__(self, application): gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) operations.Operation.__init__(self) Component.__init__(self, application) self.__application = application self.__masterer = AudioMastering() # Variable related to this being an Operation self.__running = False self.connect("show", self.__on_show) # We listen for GtkMusicList events self.music_list_widget.listeners.append(self) glade_file = os.path.join(constants.data_dir, "serpentine.glade") g = gtk.glade.XML(glade_file, "main_window_container") # Send glade to setup subcomponents for c in self._components: if hasattr(c, "_setup_glade"): c._setup_glade(g) self.add(g.get_widget("main_window_container")) self.set_title("Serpentine") self.set_default_size(450, 350) self.set_icon_name("gnome-dev-cdrom-audio") # record button # setup record button self.__write_to_disc = MapProxy( dict(button=g.get_widget("write_to_disc"), menu=g.get_widget("write_to_disc_mni"))) self.__write_to_disc.set_sensitive(False) self.__write_to_disc["button"].connect("clicked", self.__on_write_files) self.__write_to_disc["menu"].connect("activate", self.__on_write_files) # masterer widget box = self.get_child() self.music_list_widget.show() box.add(self.music_list_widget) # preferences g.get_widget("preferences_mni").connect("activate", self.__on_preferences) # setup remove buttons self.remove = MapProxy({ "menu": g.get_widget("remove_mni"), "button": g.get_widget("remove") }) self.remove["menu"].connect("activate", self.__on_remove_file) self.remove["button"].connect("clicked", self.__on_remove_file) self.remove.set_sensitive(False) # setup clear buttons self.clear = MapProxy({ "menu": g.get_widget("clear_mni"), "button": g.get_widget("clear") }) self.clear["button"].connect("clicked", self.clear_files) self.clear["menu"].connect("activate", self.clear_files) self.clear.set_sensitive(False) # setup quit menu item g.get_widget("quit_mni").connect("activate", self.stop) self.connect("delete-event", self.stop) # About dialog g.get_widget("about_mni").connect("activate", self.__on_about) # update buttons self.on_contents_changed() if self.__application.preferences.drive is None: gtkutil.dialog_warn( _("No recording drive found"), _("No recording drive found on your system, therefore some of " "Serpentine's functionalities will be disabled."), self) g.get_widget("preferences_mni").set_sensitive(False) self.__write_to_disc.set_sensitive(False) # Load internal XSPF playlist self.__load_playlist() music_list_widget = property(lambda self: self.__masterer) music_list = property(lambda self: self.__masterer.music_list) can_start = property(lambda self: True) # TODO: handle the can_stop property better can_stop = property(lambda self: True) masterer = property(lambda self: self.__masterer) application = property(lambda self: self.__application) def __on_show(self, *args): self.__running = True def __load_playlist(self): #TODO: move it to SerpentineApplication ? """Private method for loading the internal playlist.""" try: self.__application.preferences.loadPlaylist( self.music_list_widget.source) except: import traceback traceback.print_exc() def on_selection_changed(self, *args): self.remove.set_sensitive(self.music_list_widget.count_selected() > 0) def on_contents_changed(self, *args): is_sensitive = len(self.music_list_widget.source) > 0 self.clear.set_sensitive(is_sensitive) # Only set it sentitive if the drive is available and is not recording if self.__application.preferences.drive is not None: self.__write_to_disc.set_sensitive(is_sensitive) def __on_remove_file(self, *args): self.music_list_widget.remove_selected() def clear_files(self, *args): self.music_list_widget.source.clear() def __on_preferences(self, *args): # Triggered by preferences menu item self.__application.preferences.dialog.run() self.__application.preferences.dialog.hide() def __on_about(self, widget, *args): # Triggered by the about menu item a = gtk.AboutDialog() a.set_name("Serpentine") a.set_version(self.__application.preferences.version) a.set_website("http://s1x.homelinux.net/projects/serpentine") a.set_copyright("2004-2005 Tiago Cogumbreiro") a.set_transient_for(self) a.run() a.hide() def __on_write_files(self, *args): # TODO: move this to SerpentineApplication.write_files ? try: # Try to validate music list validate_music_list(self.music_list_widget.source, self.application.preferences) except SerpentineCacheError, err: show_prefs = False if err.error_id == SerpentineCacheError.INVALID: title = _("Cache directory location unavailable") show_prefs = True elif err.error_id == SerpentineCacheError.NO_SPACE: title = _("Not enough space on cache directory") gtkutil.dialog_warn(title, err.error_message) return # TODO: move this to recording module? if self.music_list_widget.source.total_duration > self.music_list_widget.disc_size: title = _("Do you want to overburn your disc?") msg = _("You are about to record a media disc in overburn mode. " "This may not work on all drives and shouldn't give you " "more then a couple of minutes.") btn = _("Write to Disc (Overburning)") self.__application.preferences.overburn = True else: title = _("Do you want to record your music?") msg = _("You are about to record a media disc. " "Canceling a writing operation will make " "your disc unusable.") btn = _("Write to Disc") self.__application.preferences.overburn = False if gtkutil.dialog_ok_cancel(title, msg, self, btn) != gtk.RESPONSE_OK: return self.application.write_files().start()
def run_dialog (self, *args): app = self.parent.application win = self.parent self.__sync_file_filters () while self.file_dlg.run () == gtk.RESPONSE_OK: filename = self.file_dlg.get_filename () basename = os.path.basename (filename) index = self.combo.get_active () if index == 0: extension = None else: extension = self.store[index][1] if os.path.exists (filename) and gtkutil.dialog_ok_cancel ( _("Replace existing file"), _("A file named <i>%s</i> already exists. " "Do you want to replace it with the one " "you are saving?") % basename, parent = win ) != gtk.RESPONSE_OK: self.file_dlg.unselect_all() self.file_dlg.hide() return try: oper = app.savePlaylist.save (filename, extension) oper.listeners.append (self) oper.start () break except SerpentineNotSupportedError: # In this case the user supplied a wrong extension # let's ask for him to choose one if extension is None: # convert to strings items = map(lambda row: row[0], self.store) # First row is useless del items[0] indexes, response = gtkutil.choice_dialog( _("Select one playlist format"), _("Serpentine will open any of these formats so the " "one you choose only matters if you are going to " "open with other applications."), one_text_item = _("Do you want to save as the %s " "format?"), min_select = 1, max_select = 1, parent = win, items = items, ok_button = gtk.STOCK_SAVE, ) if len(indexes) != 0: index, = indexes # Since we deleted the first row from the items then # the index have an offset of 1 index += 1 row = self.store[index] extension = row[1] # Save the file oper = app.savePlaylist.save (filename, extension) oper.listeners.append (self) oper.start () # Select the option in the list store self.combo.set_active(index) break else: gtkutil.dialog_error ( _("Unsupported Format"), _("The playlist format you used (by the file extension) is " "currently not supported."), parent = win ) self.file_dlg.unselect_all() self.file_dlg.hide()
def run_dialog(self, *args): app = self.parent.application win = self.parent self.__sync_file_filters() while self.file_dlg.run() == gtk.RESPONSE_OK: filename = self.file_dlg.get_filename() basename = os.path.basename(filename) index = self.combo.get_active() if index == 0: extension = None else: extension = self.store[index][1] if os.path.exists(filename) and gtkutil.dialog_ok_cancel( _("Replace existing file"), _("A file named <i>%s</i> already exists. " "Do you want to replace it with the one " "you are saving?") % basename, parent=win) != gtk.RESPONSE_OK: self.file_dlg.unselect_all() self.file_dlg.hide() return try: oper = app.savePlaylist.save(filename, extension) oper.listeners.append(self) oper.start() break except SerpentineNotSupportedError: # In this case the user supplied a wrong extension # let's ask for him to choose one if extension is None: # convert to strings items = map(lambda row: row[0], self.store) # First row is useless del items[0] indexes, response = gtkutil.choice_dialog( _("Select one playlist format"), _("Serpentine will open any of these formats so the " "one you choose only matters if you are going to " "open with other applications."), one_text_item=_("Do you want to save as the %s " "format?"), min_select=1, max_select=1, parent=win, items=items, ok_button=gtk.STOCK_SAVE, ) if len(indexes) != 0: index, = indexes # Since we deleted the first row from the items then # the index have an offset of 1 index += 1 row = self.store[index] extension = row[1] # Save the file oper = app.savePlaylist.save(filename, extension) oper.listeners.append(self) oper.start() # Select the option in the list store self.combo.set_active(index) break else: gtkutil.dialog_error( _("Unsupported Format"), _("The playlist format you used (by the file extension) is " "currently not supported."), parent=win) self.file_dlg.unselect_all() self.file_dlg.hide()