def remove_objects(self, objects, confirm=True, undolist=None):
        """
        Remove the given objects (datasets or plots) from the current
        Project. Returns nothing.
        """
        if undolist is None:
            undolist = self.journal

        # if you add an option confirm, make sure that it is False
        # when GtkApplication calls it.
        ul = UndoList()
        
        datasets = list()
        plots = list()
        for obj in objects:                       
            if isinstance(obj, Dataset):
                datasets.append(obj)
            elif isinstance(obj, Plot):
                plots.append(obj)

        if len(datasets) > 0:
            self.remove_datasets(datasets, undolist=ul)            
        if len(plots) > 0:
            self.remove_plots(plots, undolist=ul)

        if len(ul) > 2:
            ul.describe("Remove objects")            
        
        undolist.append(ul)
        
        return None
    def add_plots(self, plots, undolist=None):
        if undolist is None:
            undolist = self.journal

        if len(plots) == 0:
            undolist.append(NullUndo())

        ul = UndoList()
        ul.describe("Append Plots to Project")

        for plot in plots:
            new_key = pdict.unique_key(self.plots, plot.key)
            if new_key != plot.key:
                uwrap.set(plot, 'key', new_key, undolist=ul)
            ulist.append(self.plots, plot, undolist=ul)

        undolist.append(ul)

        cli_logger.info("Added %d plot(s)." % len(plots) )
    def add_datasets(self, datasets, undolist=None):
        if undolist is None:
            undolist = self.journal

        if len(datasets) == 0:
            undolist.append(NullUndo())
            return
        
        ul = UndoList()
        ul.describe("Append Dataset to Project")

        for dataset in datasets:
            new_key = pdict.unique_key(self.datasets, dataset.key)
            if new_key != dataset.key:
                uwrap.set(dataset, 'key', new_key, undolist=ul)
            ulist.append( self.datasets, dataset, undolist=ul )

        undolist.append(ul)
        
        cli_logger.info("Added %d dataset(s)." % len(datasets) )
            continue
        except error.UserCancel:
            app.error_msg("Import aborted by user")
            continue

        root, ext = os.path.splitext(os.path.basename(filename))
        ds.key = utils.encode_as_key(root)

        new_datasets.append(ds)
        n+=1
        app.progress(n/N)

    app.progress(1.0)

    if len(new_datasets) > 0:
        ul = UndoList()
        if len(new_datasets) == 1:
            ul.describe("Import Dataset")
        else:
            ul.describe("Import %d Datasets" % len(new_datasets) )

        project.add_datasets(new_datasets, undolist=ul)
        undolist.append(ul)
        #msg = "Import of %d datasets finished." % len(new_datasets)
    else:
        undolist.append(NullUndo())
        #msg = "Nothing imported."

    app.progress(-1)
    #app.status_message(msg)