diff --git a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy index 68367be4..b50e3365 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy @@ -13,6 +13,8 @@ import com.muwire.core.download.DownloadStartedEvent import com.muwire.core.download.UIDownloadEvent import com.muwire.core.search.QueryEvent import com.muwire.core.search.SearchEvent +import com.muwire.core.trust.TrustEvent +import com.muwire.core.trust.TrustLevel @ArtifactProviderFor(GriffonController) class MainFrameController { @@ -33,15 +35,31 @@ class MainFrameController { replyTo: core.me.destination, receivedOn: core.me.destination)) } - @ControllerAction - void download() { + private def selectedResult() { def resultsTable = builder.getVariable("results-table") int row = resultsTable.getSelectedRow() - def result = model.results[row] + model.results[row] + } + + @ControllerAction + void download() { + def result = selectedResult() def file = new File(application.context.get("muwire-settings").downloadLocation, result.name) core.eventBus.publish(new UIDownloadEvent(result : result, target : file)) } + @ControllerAction + void trust() { + def result = selectedResult() + core.eventBus.publish( new TrustEvent(destination : result.sender.destination, level : TrustLevel.TRUSTED)) + } + + @ControllerAction + void distrust() { + def result = selectedResult() + core.eventBus.publish( new TrustEvent(destination : result.sender.destination, level : TrustLevel.DISTRUSTED)) + } + void mvcGroupInit(Map args) { application.addPropertyChangeListener("core", {e-> core = e.getNewValue() diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index 409ad369..08720f62 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -75,8 +75,8 @@ class MainFrameView { } panel(constraints : BorderLayout.SOUTH) { button(text : "Download", downloadAction) - button(text : "Trust") - button(text : "Distrust") + button(text : "Trust", trustAction) + button(text : "Distrust", distrustAction) } } panel (constraints : JSplitPane.BOTTOM) {