From 096f784d1ba5b5e85df90aa22fe1f10fb61a369e Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Fri, 31 May 2019 17:01:49 +0100 Subject: [PATCH] share files from UI --- README.md | 2 -- .../views/com/muwire/gui/MainFrameView.groovy | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index deeeed60..31dbb38d 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,6 @@ You need to have an I2P router up and running on the same machine. After you bu The first time you run MuWire it will ask you to select a nickname. This nickname will be displayed with search results, so that others can verify the file was shared by you. -To share files, edit $HOME/.MuWire/MuWire.properties and add the property "sharedFiles" with value a comma-separated list of absolute paths to shared files or folders. - At the moment there are very few nodes on the network, so you will see very few connections and search results. It is best to leave MuWire running all the time, just like I2P. diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index 2db6b32b..9e995e2e 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -7,10 +7,13 @@ import griffon.metadata.ArtifactProviderFor import javax.swing.BorderFactory import javax.swing.Box import javax.swing.BoxLayout +import javax.swing.JFileChooser import javax.swing.JSplitPane import javax.swing.SwingConstants import javax.swing.border.Border +import com.muwire.core.files.FileSharedEvent + import java.awt.BorderLayout import java.awt.CardLayout import java.awt.FlowLayout @@ -109,7 +112,9 @@ class MainFrameView { gridLayout(cols : 1, rows : 2) panel { borderLayout() - label(text : "Shared files", constraints: BorderLayout.NORTH) + panel (constraints : BorderLayout.NORTH) { + button(text : "Shared files", actionPerformed : shareFiles) + } scrollPane ( constraints : BorderLayout.CENTER) { table(id : "shared-files-table") { tableModel(list : model.shared) { @@ -161,4 +166,14 @@ class MainFrameView { def cardsPanel = builder.getVariable("cards-panel") cardsPanel.getLayout().show(cardsPanel, "uploads window") } + + def shareFiles = { + def chooser = new JFileChooser() + chooser.setDialogTitle("Select file or directory to share") + chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES) + int rv = chooser.showOpenDialog(null) + if (rv == JFileChooser.APPROVE_OPTION) { + model.core.eventBus.publish(new FileSharedEvent(file : chooser.getSelectedFile())) + } + } } \ No newline at end of file