Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/record.py
diff options
context:
space:
mode:
Diffstat (limited to 'record.py')
-rwxr-xr-x[-rw-r--r--]record.py73
1 files changed, 72 insertions, 1 deletions
diff --git a/record.py b/record.py
index e25010e..6926b6f 100644..100755
--- a/record.py
+++ b/record.py
@@ -72,10 +72,66 @@ else:
class Record(activity.Activity):
+
+ DIALOG_OK = 13
+
+ def _getDirs(self, path, parent_item, tree_data_store, path_to_file):
+ """Gets all of the folders and adds them to
+ tree_data_store"""
+ logging.debug(path)
+ if os.path.exists(path):
+ for File in os.listdir(path):
+ filepath = os.path.join(path, File)
+ if os.path.isdir(filepath):
+ item = tree_data_store.append(parent_item, [File])
+ item_path = tree_data_store.get_path(item)
+ path_to_file[str(item_path)] = filepath
+ self._getDirs(filepath, item, tree_data_store, path_to_file)
+
+ def _getDirsWithoutRootFolder(self, path, tree_data_store, path_to_file):
+ """Like getDirs except omits the first folder in the tree"""
+ logging.debug(path)
+ if os.path.exists(path):
+ logging.debug(path)
+ for File in os.listdir(path):
+ filepath = os.path.join(path, File)
+ if os.path.isdir(filepath):
+ tree_data_store = self._getDirs(filepath, None, tree_data_store, path_to_file)
+
+ def _genFileTree(self, path_to_file):
+ """Generates the file tree of the external devices directory
+ and returns a tree data store"""
+ tree_data_store = gtk.TreeStore(str)
+
+ self._getDirsWithoutRootFolder("/run/media", tree_data_store, path_to_file)
+ self._getDirsWithoutRootFolder("/media", tree_data_store, path_to_file)
+
+ internal_item = tree_data_store.append(None, ["Internal Storage"])
+ path = tree_data_store.get_path(internal_item)
+ path_to_file[str(path)] = None
+ return tree_data_store
+
+ def _init_dialog(self):
+ """Returns a dialog with a folder picker
+ picks between /media folders or just 'internal'
+ also returns a tree view used"""
+ path_to_file = {}
+ tree_data_store = self._genFileTree(path_to_file)
+ tree_view = gtk.TreeView(tree_data_store)
+ renderer = gtk.CellRendererText()
+ column = gtk.TreeViewColumn("Media Folders", renderer, text=0)
+ tree_view.append_column(column)
+
+ folder_dialog = gtk.Dialog("Chose a folder")
+ folder_dialog.add_button("Use selected folder", self.DIALOG_OK)
+ folder_dialog.get_content_area().add(tree_view)
+ folder_dialog.get_content_area().show_all()
+ return folder_dialog, tree_view, path_to_file
+
def __init__(self, handle):
super(Record, self).__init__(handle)
self.props.enable_fullscreen_mode = False
- Instance(self)
+ self.Instance = Instance(self)
self.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK)
self.connect("visibility-notify-event", self._visibility_changed)
@@ -171,6 +227,11 @@ class Record(activity.Activity):
self._toolbar.insert(self._audio_button, -1)
self._toolbar.insert(gtk.SeparatorToolItem(), -1)
+
+ self._set_path_button = ToolButton()
+ self._set_path_button.props.label = _('Set Output File')
+ self._set_path_button.connect('clicked', self._set_path_button_clicked)
+ self._toolbar.insert(self._set_path_button, -1)
self._toolbar_controls = RecordControl(self._toolbar)
@@ -367,6 +428,16 @@ class Record(activity.Activity):
def _mode_button_clicked(self, button):
self.model.change_mode(button.mode)
+
+ def _set_path_button_clicked(self, button):
+ folder_dialog, tree_view, path_to_file = self._init_dialog()
+ dialog_responce = folder_dialog.run()
+ if dialog_responce == self.DIALOG_OK:
+ tree_sel = tree_view.get_selection()
+ (tree_store, ti) = tree_sel.get_selected()
+ ids = tree_store.get_path(ti)
+ self.Instance.savePath = path_to_file[str(ids)]
+ folder_dialog.destroy()
def _shutter_clicked(self, arg):
self.model.do_shutter()