From 83e912b9b7e2e24fcb8b627d0c13db5010d4e23f Mon Sep 17 00:00:00 2001
From: Simon Schampijer <simon@schampijer.de>
Date: Fri, 3 Sep 2010 15:27:21 +0200
Subject: [PATCH] Feedback when deleting files on a USB-Stick #10351
---
src/jarabe/journal/listview.py | 39 ++++++++++++---------------------------
src/jarabe/journal/model.py | 4 +++-
2 files changed, 15 insertions(+), 28 deletions(-)
diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py
index 6556b08..e1ca620 100644
a
|
b
|
|
1 | | # Copyright (C) 2007, One Laptop Per Child |
| 1 | # Copyright (C) 2007, 2010 One Laptop Per Child |
2 | 2 | # |
3 | 3 | # This program is free software; you can redistribute it and/or modify |
4 | 4 | # it under the terms of the GNU General Public License as published by |
… |
… |
import time |
23 | 23 | import hippo |
24 | 24 | import gobject |
25 | 25 | import gtk |
26 | | import dbus |
27 | 26 | |
28 | 27 | from sugar.graphics import style |
29 | 28 | from sugar.graphics.icon import CanvasIcon, Icon |
… |
… |
from sugar.graphics.icon import CanvasIcon, Icon |
31 | 30 | from jarabe.journal.collapsedentry import CollapsedEntry |
32 | 31 | from jarabe.journal import model |
33 | 32 | |
34 | | DS_DBUS_SERVICE = 'org.laptop.sugar.DataStore' |
35 | | DS_DBUS_INTERFACE = 'org.laptop.sugar.DataStore' |
36 | | DS_DBUS_PATH = '/org/laptop/sugar/DataStore' |
37 | | |
38 | 33 | UPDATE_INTERVAL = 300 |
39 | 34 | |
40 | 35 | EMPTY_JOURNAL = _("Your Journal is empty") |
… |
… |
class BaseListView(gtk.HBox): |
109 | 104 | self._refresh_idle_handler = None |
110 | 105 | self._update_dates_timer = None |
111 | 106 | |
112 | | bus = dbus.SessionBus() |
113 | | datastore = dbus.Interface( |
114 | | bus.get_object(DS_DBUS_SERVICE, DS_DBUS_PATH), DS_DBUS_INTERFACE) |
115 | | self._datastore_created_handler = \ |
116 | | datastore.connect_to_signal('Created', |
117 | | self.__datastore_created_cb) |
118 | | self._datastore_updated_handler = \ |
119 | | datastore.connect_to_signal('Updated', |
120 | | self.__datastore_updated_cb) |
| 107 | model.created.connect(self.__model_created_cb) |
| 108 | model.updated.connect(self.__model_updated_cb) |
| 109 | model.deleted.connect(self.__model_deleted_cb) |
| 110 | |
| 111 | def __model_created_cb(self, sender, **kwargs): |
| 112 | self._set_dirty() |
| 113 | |
| 114 | def __model_updated_cb(self, sender, **kwargs): |
| 115 | self._set_dirty() |
121 | 116 | |
122 | | self._datastore_deleted_handler = \ |
123 | | datastore.connect_to_signal('Deleted', |
124 | | self.__datastore_deleted_cb) |
| 117 | def __model_deleted_cb(self, sender, **kwargs): |
| 118 | self._set_dirty() |
125 | 119 | |
126 | 120 | def __destroy_cb(self, widget): |
127 | 121 | self._datastore_created_handler.remove() |
… |
… |
class BaseListView(gtk.HBox): |
463 | 457 | if entry.get_visible(): |
464 | 458 | entry.update_date() |
465 | 459 | |
466 | | def __datastore_created_cb(self, uid): |
467 | | self._set_dirty() |
468 | | |
469 | | def __datastore_updated_cb(self, uid): |
470 | | self._set_dirty() |
471 | | |
472 | | def __datastore_deleted_cb(self, uid): |
473 | | self._set_dirty() |
474 | | |
475 | 460 | def _set_dirty(self): |
476 | 461 | if self._fully_obscured: |
477 | 462 | self._dirty = True |
diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
index 50e8dc1..f4186f0 100644
a
|
b
|
|
1 | | # Copyright (C) 2007-2008, One Laptop Per Child |
| 1 | # Copyright (C) 2007, 2008, 2010 One Laptop Per Child |
2 | 2 | # |
3 | 3 | # This program is free software; you can redistribute it and/or modify |
4 | 4 | # it under the terms of the GNU General Public License as published by |
… |
… |
def delete(object_id): |
460 | 460 | """ |
461 | 461 | if os.path.exists(object_id): |
462 | 462 | os.unlink(object_id) |
| 463 | deleted.send(None, object_id=object_id) |
463 | 464 | else: |
464 | 465 | _get_datastore().delete(object_id) |
465 | 466 | |
… |
… |
def write(metadata, file_path='', update_mtime=True, transfer_ownership=True): |
504 | 505 | destination_path = os.path.join(metadata['mountpoint'], file_name) |
505 | 506 | shutil.copy(file_path, destination_path) |
506 | 507 | object_id = destination_path |
| 508 | created.send(None, object_id=object_id) |
507 | 509 | |
508 | 510 | return object_id |
509 | 511 | |