Ticket #1842: 0001-Journal-Error-alert-when-copying-to-devices-in-the.patch

File 0001-Journal-Error-alert-when-copying-to-devices-in-the.patch, 4.9 KB (added by erikos, 10 years ago)

Journal: Error alert when copying to devices in the detail view, Includes better error messages.

  • src/jarabe/journal/journalactivity.py

    From 9f55434a841b2132eb617f7a5d0eb1578acd43fe Mon Sep 17 00:00:00 2001
    From: Simon Schampijer <simon@schampijer.de>
    Date: Tue, 31 Aug 2010 15:39:04 +0200
    Subject: [PATCH] Journal: Error alert when copying to devices in the detail view #1842
    
    Includes better error messages.
    ---
     src/jarabe/journal/journalactivity.py |    7 ++++---
     src/jarabe/journal/journaltoolbox.py  |   21 ++++++++++++++++++++-
     src/jarabe/journal/volumestoolbar.py  |   13 +++++++------
     3 files changed, 31 insertions(+), 10 deletions(-)
    
    diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py
    index e278420..4c948c2 100644
    a b class JournalActivity(Window): 
    140140        self._critical_space_alert = None
    141141        self._check_available_space()
    142142
    143     def __alert_notify_cb(self, gobject, strerror, severity):
     143    def __volume_error_cb(self, gobject, strerror, severity):
    144144        alert = ErrorAlert(title=severity, msg=strerror)
    145145        alert.connect('response', self.__alert_response_cb)
    146146        self.add_alert(alert)
    class JournalActivity(Window): 
    172172        self._volumes_toolbar = VolumesToolbar()
    173173        self._volumes_toolbar.connect('volume-changed',
    174174                                      self.__volume_changed_cb)
    175         self._volumes_toolbar.connect('volume-error', self.__alert_notify_cb)
     175        self._volumes_toolbar.connect('volume-error', self.__volume_error_cb)
    176176        self._main_view.pack_start(self._volumes_toolbar, expand=False)
    177177
    178178        search_toolbar = self._main_toolbox.search_toolbar
    class JournalActivity(Window): 
    183183        self._secondary_view = gtk.VBox()
    184184
    185185        self._detail_toolbox = DetailToolbox()
    186         entry_toolbar = self._detail_toolbox.entry_toolbar
     186        self._detail_toolbox.entry_toolbar.connect('volume-error',
     187                                                   self.__volume_error_cb)
    187188
    188189        self._detail_view = DetailView()
    189190        self._detail_view.connect('go-back-clicked', self.__go_back_clicked_cb)
  • src/jarabe/journal/journaltoolbox.py

    diff --git a/src/jarabe/journal/journaltoolbox.py b/src/jarabe/journal/journaltoolbox.py
    index 75c6de5..f2946b9 100644
    a b class DetailToolbox(Toolbox): 
    363363        self.entry_toolbar.show()
    364364
    365365class EntryToolbar(gtk.Toolbar):
     366    __gsignals__ = {
     367        'volume-error': (gobject.SIGNAL_RUN_FIRST,
     368                         gobject.TYPE_NONE,
     369                         ([str, str]))
     370        }
    366371    def __init__(self):
    367372        gtk.Toolbar.__init__(self)
    368373
    class EntryToolbar(gtk.Toolbar): 
    432437        misc.resume(self._metadata, service_name)
    433438
    434439    def _copy_menu_item_activate_cb(self, menu_item, mount_point):
    435         model.copy(self._metadata, mount_point)
     440        file_path = model.get_file(self._metadata['uid'])
     441
     442        if not file_path or not os.path.exists(file_path):
     443            logging.warn('Entries without a file cannot be copied.')
     444            self.emit('volume-error',
     445                      _('Entries without a file cannot be copied.'),
     446                      _('Warning'))
     447            return
     448
     449        try:
     450            model.copy(self._metadata, mount.get_root().get_path())
     451        except IOError:
     452            logging.exception('Error while copying the file.')
     453            self.emit('volume-error', _('Error while copying the file.'),
     454                      _('Error'))
    436455
    437456    def _refresh_copy_palette(self):
    438457        palette = self._copy.get_palette()
  • src/jarabe/journal/volumestoolbar.py

    diff --git a/src/jarabe/journal/volumestoolbar.py b/src/jarabe/journal/volumestoolbar.py
    index 8b7786f..cb1b9c3 100644
    a b class BaseButton(RadioToolButton): 
    153153        metadata = model.get(object_id)
    154154        file_path = model.get_file(metadata['uid'])
    155155        if not file_path or not os.path.exists(file_path):
    156             logging.warn('File does not exist')
    157             self.emit('volume-error', _('Entries without a file cannot'
    158                 ' be copied'), _('Warning'))
     156            logging.warn('Entries without a file cannot be copied.')
     157            self.emit('volume-error',
     158                      _('Entries without a file cannot be copied.'),
     159                      _('Warning'))
    159160            return
    160161
    161162        try:
    162163            model.copy(metadata, self.mount_point)
    163164        except IOError:
    164             logging.exception('BaseButton._drag_data_received_cb: Error'
    165                 'while copying')
    166             self.emit('volume-error', _('Input/Output error'), _('Error'))
     165            logging.exception('Error while copying the file.')
     166            self.emit('volume-error', _('Error while copying the file.'),
     167                      _('Error'))
    167168
    168169class VolumeButton(BaseButton):
    169170    def __init__(self, mount):