Permalink
Browse files

Implement delete dialog GUI

  • Loading branch information...
1 parent a0ac610 commit 1a64b4d61775b6476ea77a6bfd6e4148dc44baff @sole committed Jul 5, 2011
Showing with 45 additions and 1 deletion.
  1. +4 −1 android/file_explorer/file_explorer.py
  2. +41 −0 android/file_explorer/gfile_explorer.py
@@ -133,7 +133,6 @@ def action_device_make_directory(adb, device_directory):
command = '%s shell mkdir "%s" ' % (adb, device_directory )
execute(command)
-
def action_copy_from_host(adb, host_file, device_directory):
print "-------"
print "COPY FROM HOST:", host_file, "=>", device_directory
@@ -180,6 +179,10 @@ def action_copy_from_host(adb, host_file, device_directory):
for entry in entries:
action_copy_from_host(adb, os.path.join(host_file, entry), os.path.join(device_directory, os.path.basename(host_file)))
+def action_device_delete_item(adb, path):
+ print 'deleting', path
+
+
# ~~~
def run(args):
@@ -110,6 +110,8 @@ def __init__(self):
# Device specific buttons
btnDeviceCreateDirectory = builder.get_object('btnDeviceCreateDirectory')
btnDeviceCreateDirectory.connect('clicked', self.device_create_directory_callback, None)
+ btnDeviceDeleteItem = builder.get_object('btnDeviceDeleteItem')
+ btnDeviceDeleteItem.connect('clicked', self.device_delete_item_callback, None)
# Progress bar
self.progress_bar = builder.get_object('progressBar')
@@ -285,6 +287,45 @@ def device_navigate_callback(self, widget, path, view_column):
if is_dir:
self.device_cwd = os.path.normpath(os.path.join(self.device_cwd, name))
self.refreshDeviceFiles()
+
+
+ def device_delete_item_callback(self, widget, data=None):
+ model, rows = self.device_treeViewFile.getTree().get_selection().get_selected_rows()
+ print 'delete', len(rows)
+
+ if len(rows) > 0:
+ items = []
+ for r in rows:
+ iter = model.get_iter(r)
+ filename = model.get_value(iter, 1)
+ items.append(filename)
+
+ result = self.dialog_device_delete_confirmation(items)
+
+ def dialog_device_delete_confirmation(self, items):
+ items.sort()
+ joined = ', '.join(items)
+ print joined
+ dialog = gtk.MessageDialog(
+ parent = None,
+ flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+ type = gtk.MESSAGE_QUESTION,
+ buttons = gtk.BUTTONS_OK_CANCEL,
+ message_format = "Are you sure you want to delete %d items?" % len(items)
+ )
+ dialog.format_secondary_markup('%s will be deleted. This action cannot be undone.' % joined)
+ dialog.show_all()
+ result = dialog.run()
+
+ dialog.destroy()
+
+ if result == gtk.RESPONSE_OK:
+ for item in items:
+ full_item_path = os.path.join(self.device_cwd, item)
+ file_explorer.action_device_delete_item(self.adb, full_item_path)
+ else:
+ print 'no no'
+
def device_create_directory_callback(self, widget, data=None):
directory_name = self.dialog_get_directory_name()

0 comments on commit 1a64b4d

Please sign in to comment.