diff --git a/ocarina/body/button.py b/ocarina/body/button.py index 0a31293e..3903e755 100644 --- a/ocarina/body/button.py +++ b/ocarina/body/button.py @@ -4,6 +4,7 @@ import gtk from libsaria.path import export from libsaria import controls from libsaria import sources +from ocarina import fsselect SIZE = gtk.ICON_SIZE_MENU @@ -83,6 +84,13 @@ def export_button(show): def update_button(show): return make_button(gtk.STOCK_REFRESH, sources.library.update_bg, "Update Library", show) +def save_button(show): + def save_func(): + loc = fsselect.select_save() + if loc != None: + export.save_playlist(loc) + return make_button(gtk.STOCK_SAVE, save_func, "Save Current Playlist", show) + def up_button(show): def up_func(): from ocarina.body import footer diff --git a/ocarina/body/header/__init__.py b/ocarina/body/header/__init__.py index 7d3c0a69..b7aab550 100644 --- a/ocarina/body/header/__init__.py +++ b/ocarina/body/header/__init__.py @@ -18,6 +18,7 @@ def add_button(name, button): header_body.pack_start(button, False, False) header_body.pack_start(entry.entry) +add_button( "SAVE", button.save_button(True)) add_button("EXPORT", button.export_button(True)) sep = gtk.VSeparator() diff --git a/ocarina/components/button.py b/ocarina/components/button.py index 34d35f65..4da7566e 100644 --- a/ocarina/components/button.py +++ b/ocarina/components/button.py @@ -38,16 +38,6 @@ class OpenButton(Button): fsselect.run_chooser2(LS.path.files.universal_open) ocarina.playlist.refresh() -class SaveButton(Button): - def __init__(self): - Button.__init__(self, gtk.STOCK_SAVE, "Save current playlist") - def clicked(self, button): - from ocarina import fsselect - from libsaria.path import export - loc = fsselect.save() - if loc != None: - export.save_playlist(loc) - class SettingsButton(Button): def __init__(self): Button.__init__(self, gtk.STOCK_PREFERENCES, "Configure Preferences") diff --git a/ocarina/fsselect.py b/ocarina/fsselect.py index f6fb4992..1889ae66 100644 --- a/ocarina/fsselect.py +++ b/ocarina/fsselect.py @@ -82,6 +82,6 @@ def select_dir(title = "Select a directory"): chooser = make_chooser(title, gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER) return run_chooser(chooser) -def save(title = "Select a location"): +def select_save(title = "Select a location"): chooser = make_chooser(title, gtk.FILE_CHOOSER_ACTION_SAVE) return run_chooser(chooser)