def delete_button_press_event_cb(self, entry, event, col, id):

        i = 0
        tv = self.tv_journal[col]
        model = tv.get_model()
        iter = self.ls_journal[col].get_iter_first()

        while (i < id):
            iter = self.ls_journal[col].iter_next(iter)
            i += 1

        if not iter == None:
            jobject = model.get_value(iter, COLUMN_JOBJECT)
            self.ls_journal[col].remove(iter)

            if col == 0:
                datastore.delete(jobject.get_object_id())

            else:
                try:
                    os.remove(jobject.get_file_path())
                    print 'Deleted %s' % (jobject.get_file_path())
                except OSError:
                    print 'Cannot delete %s' % (jobject.get_file_path())

            self.remove_image(col, id)
            self.tv_journal[col].grab_focus()
            self.last_col = col
Ejemplo n.º 2
0
 def __notify_state_cb(self, file_transfer, pspec):
     if file_transfer.props.state == filetransfer.FT_STATE_OPEN:
         logging.debug('__notify_state_cb OPEN')
         self._ds_object.metadata['title'] = file_transfer.title
         self._ds_object.metadata['description'] = file_transfer.description
         self._ds_object.metadata['progress'] = '0'
         self._ds_object.metadata['keep'] = '0'
         self._ds_object.metadata['buddies'] = ''
         self._ds_object.metadata['preview'] = ''
         self._ds_object.metadata['icon-color'] = \
             file_transfer.buddy.props.color.to_string()
         self._ds_object.metadata['mime_type'] = file_transfer.mime_type
     elif file_transfer.props.state == filetransfer.FT_STATE_COMPLETED:
         logging.debug('__notify_state_cb COMPLETED')
         self._ds_object.metadata['progress'] = '100'
         self._ds_object.file_path = file_transfer.destination_path
         datastore.write(self._ds_object, transfer_ownership=True,
                         reply_handler=self.__reply_handler_cb,
                         error_handler=self.__error_handler_cb)
     elif file_transfer.props.state == filetransfer.FT_STATE_CANCELLED:
         logging.debug('__notify_state_cb CANCELLED')
         object_id = self._ds_object.object_id
         if object_id is not None:
             self._ds_object.destroy()
             datastore.delete(object_id)
             self._ds_object = None
Ejemplo n.º 3
0
 def __notify_state_cb(self, file_transfer, pspec):
     if file_transfer.props.state == filetransfer.FT_STATE_OPEN:
         logging.debug("__notify_state_cb OPEN")
         self._ds_object.metadata["title"] = file_transfer.title
         self._ds_object.metadata["description"] = file_transfer.description
         self._ds_object.metadata["progress"] = "0"
         self._ds_object.metadata["keep"] = "0"
         self._ds_object.metadata["buddies"] = ""
         self._ds_object.metadata["preview"] = ""
         self._ds_object.metadata["icon-color"] = file_transfer.buddy.props.color.to_string()
         self._ds_object.metadata["mime_type"] = file_transfer.mime_type
     elif file_transfer.props.state == filetransfer.FT_STATE_COMPLETED:
         logging.debug("__notify_state_cb COMPLETED")
         self._ds_object.metadata["progress"] = "100"
         self._ds_object.file_path = file_transfer.destination_path
         datastore.write(
             self._ds_object,
             transfer_ownership=True,
             reply_handler=self.__reply_handler_cb,
             error_handler=self.__error_handler_cb,
         )
     elif file_transfer.props.state == filetransfer.FT_STATE_CANCELLED:
         logging.debug("__notify_state_cb CANCELLED")
         object_id = self._ds_object.object_id
         if object_id is not None:
             self._ds_object.destroy()
             datastore.delete(object_id)
             self._ds_object = None
Ejemplo n.º 4
0
    def __start_response_cb(self, alert, response_id):
        if response_id is Gtk.ResponseType.CANCEL:
            logging.debug('Download Canceled')
            self.cancel()
            try:
                datastore.delete(self._object_id)
            except Exception, e:
                logging.warning('Object has been deleted already %s' % e)

            self.cleanup()
            if self._stop_alert is not None:
                self._activity.remove_alert(self._stop_alert)
Ejemplo n.º 5
0
    def __start_response_cb(self, alert, response_id):
        if response_id is Gtk.ResponseType.CANCEL:
            logging.debug('Download Canceled')
            self.cancel()
            try:
                datastore.delete(self._object_id)
            except Exception, e:
                logging.warning('Object has been deleted already %s' % e)

            self.cleanup()
            if self._stop_alert is not None:
                self._activity.remove_alert(self._stop_alert)
Ejemplo n.º 6
0
    def __project_chooser_response_cb(self, project_chooser, response_value,
                                      metadata_to_send):
        if response_value == Gtk.ResponseType.DELETE_EVENT:
            project_chooser.destroy()
            return

        object_id = project_chooser.get_selected_object_id()
        metadata = model.get(object_id)
        jobject_to_send = datastore.get(metadata_to_send['uid'])
        datastore.delete(metadata_to_send['uid'])
        jobject_to_send.metadata['project_id'] = metadata['uid']
        datastore.write(jobject_to_send)
        project_chooser.destroy()
Ejemplo n.º 7
0
    def __project_chooser_response_cb(self, project_chooser, response_value,
                                      metadata_to_send):
        if response_value == Gtk.ResponseType.DELETE_EVENT:
            project_chooser.destroy()
            return

        object_id = project_chooser.get_selected_object_id()
        metadata = model.get(object_id)
        jobject_to_send = datastore.get(metadata_to_send['uid'])
        datastore.delete(metadata_to_send['uid'])
        jobject_to_send.metadata['project_id'] = metadata['uid']
        datastore.write(jobject_to_send)
        project_chooser.destroy()
Ejemplo n.º 8
0
def removeMediaFromDatastore(recd):
    # before this method is called, the media are removed from the file
    if not recd.datastoreId or not recd.datastoreOb:
        return

    try:
        recd.datastoreOb.destroy()
        datastore.delete(recd.datastoreId)

        recd.datastoreId = None
        recd.datastoreOb = None
    finally:
        # todo: add error message here
        pass
Ejemplo n.º 9
0
def remove_all_downloads():
    for download in _active_downloads:
        download.cancel()
        if download.dl_jobject is not None:
            datastore.delete(download.dl_jobject.object_id)
        download.cleanup()
Ejemplo n.º 10
0
def remove_all_downloads():
    for download in _active_downloads:
        download.cancel()
        if download.dl_jobject is not None:
            datastore.delete(download.dl_jobject.object_id)
        download.cleanup()
Ejemplo n.º 11
0
 def delete_button_press_event_cb(self, entry, event):
     datastore.delete(self.selected_journal_entry.object_id)
Ejemplo n.º 12
0
 def delete_button_press_event_cb(self, entry, event):
     datastore.delete(self.selected_journal_entry.object_id)