mirror of https://github.com/deavminet/gustav.git
Connection assistant now moved to its own object and can now spawn new connections
This commit is contained in:
parent
6ca88b2717
commit
8d5be66f2b
|
@ -0,0 +1,108 @@
|
|||
module ConnectionAssistant;
|
||||
|
||||
/**
|
||||
* ConnectionAssistant
|
||||
*
|
||||
* This provides a graphical utility for
|
||||
* configuring new connections
|
||||
*/
|
||||
|
||||
import gtk.Assistant;
|
||||
import gtk.Label;
|
||||
import gtk.Box;
|
||||
import gtk.Entry;
|
||||
import gui;
|
||||
import std.conv;
|
||||
|
||||
public final class ConnectionAssistant : Assistant
|
||||
{
|
||||
/* Associated GUI instance */
|
||||
private GUI gui;
|
||||
|
||||
Entry serverAddress;
|
||||
Entry serverPort;
|
||||
Entry username;
|
||||
Entry password;
|
||||
|
||||
|
||||
this(GUI gui)
|
||||
{
|
||||
this.gui = gui;
|
||||
|
||||
initWindow();
|
||||
}
|
||||
|
||||
private void initWindow()
|
||||
{
|
||||
Assistant connectionAssistant = new Assistant();
|
||||
|
||||
Label hello = new Label("");
|
||||
hello.setMarkup("<span size=\"15000\">Welcome to the connection setup</span>");
|
||||
connectionAssistant.insertPage(hello, 0);
|
||||
connectionAssistant.setPageTitle(hello, "Welcome");
|
||||
|
||||
/* Configure a server */
|
||||
Box serverBox = new Box(GtkOrientation.VERTICAL, 1);
|
||||
Label serverBoxTitle = new Label("");
|
||||
serverBoxTitle.setMarkup("<span size=\"15000\">Server details</span>");
|
||||
serverBox.packStart(serverBoxTitle,0,0,30);
|
||||
serverAddress = new Entry();
|
||||
serverBox.add(serverAddress);
|
||||
serverAddress.setPlaceholderText("DNET server address");
|
||||
serverPort = new Entry();
|
||||
serverBox.add(serverPort);
|
||||
serverPort.setPlaceholderText("DNET server port");
|
||||
|
||||
|
||||
connectionAssistant.insertPage(serverBox, 1);
|
||||
connectionAssistant.setPageTitle(serverBox, "Network");
|
||||
|
||||
/* Configure your profile details */
|
||||
Box profileBox = new Box(GtkOrientation.VERTICAL, 1);
|
||||
Label profileBoxTitle = new Label("");
|
||||
profileBoxTitle.setMarkup("<span size=\"15000\">Account details</span>");
|
||||
profileBox.packStart(profileBoxTitle,0,0,30);
|
||||
username = new Entry();
|
||||
profileBox.add(username);
|
||||
username.setPlaceholderText("username");
|
||||
password = new Entry();
|
||||
profileBox.add(password);
|
||||
password.setPlaceholderText("password");
|
||||
|
||||
connectionAssistant.insertPage(profileBox, 2);
|
||||
connectionAssistant.setPageTitle(profileBox, "Account");
|
||||
|
||||
/* TODO: We should actually verify inputs before doing this */
|
||||
connectionAssistant.setPageComplete(hello, true);
|
||||
connectionAssistant.setPageComplete(serverBox, true);
|
||||
connectionAssistant.setPageComplete(profileBox, true);
|
||||
|
||||
|
||||
/* Summary */
|
||||
Box summaryBox = new Box(GtkOrientation.VERTICAL, 1);
|
||||
Label summaryBoxTitle = new Label("");
|
||||
summaryBoxTitle.setMarkup("<span size=\"15000\">Summary</span>");
|
||||
summaryBox.packStart(summaryBoxTitle,0,0,30);
|
||||
connectionAssistant.insertPage(summaryBox, 4);
|
||||
connectionAssistant.setPageType(summaryBox, GtkAssistantPageType.SUMMARY);
|
||||
|
||||
|
||||
connectionAssistant.showAll();
|
||||
|
||||
|
||||
connectionAssistant.addOnClose(&assistentComplete);
|
||||
}
|
||||
|
||||
private void assistentComplete(Assistant e)
|
||||
{
|
||||
/* Get the server details */
|
||||
string serverAddress = serverAddress.getBuffer().getText();
|
||||
string serverPort = serverPort.getBuffer().getText();
|
||||
|
||||
/* Get the account details */
|
||||
string accountUsername = username.getBuffer().getText();
|
||||
string accountPassword = password.getBuffer().getText();
|
||||
|
||||
gui.connectServer(serverAddress, to!(ushort)(serverPort), [accountUsername, accountPassword]);
|
||||
}
|
||||
}
|
61
source/gui.d
61
source/gui.d
|
@ -128,7 +128,7 @@ public class GUI : Thread
|
|||
|
||||
private bool welcomeGenesisLabelClick(string, Label)
|
||||
{
|
||||
connectServer("0.0.0.0", 7777);
|
||||
connectServer("0.0.0.0", 7777, ["testGustav"~to!(string)(connections.length), "bruh"]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -469,60 +469,11 @@ public class GUI : Thread
|
|||
|
||||
private bool conifgureConnectionsAssistant(string, Label)
|
||||
{
|
||||
setupConnection();
|
||||
import ConnectionAssistant;
|
||||
ConnectionAssistant ass = new ConnectionAssistant(this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
private void setupConnection()
|
||||
{
|
||||
import gtk.Assistant;
|
||||
Assistant connectionAssistant = new Assistant();
|
||||
|
||||
Label hello = new Label("");
|
||||
hello.setMarkup("<span size=\"15000\">Welcome to the connection setup</span>");
|
||||
connectionAssistant.insertPage(hello, 0);
|
||||
connectionAssistant.setPageTitle(hello, "Welcome");
|
||||
|
||||
/* Configure a server */
|
||||
Box serverBox = new Box(GtkOrientation.VERTICAL, 1);
|
||||
Label serverBoxTitle = new Label("");
|
||||
serverBoxTitle.setMarkup("<span size=\"15000\">Server details</span>");
|
||||
serverBox.packStart(serverBoxTitle,0,0,30);
|
||||
Entry serverAddress = new Entry();
|
||||
serverBox.add(serverAddress);
|
||||
serverAddress.setPlaceholderText("DNET server address");
|
||||
Entry serverPort = new Entry();
|
||||
serverBox.add(serverPort);
|
||||
serverPort.setPlaceholderText("DNET server port");
|
||||
|
||||
|
||||
connectionAssistant.insertPage(serverBox, 1);
|
||||
connectionAssistant.setPageTitle(serverBox, "Network");
|
||||
|
||||
/* Configure your profile details */
|
||||
Box profileBox = new Box(GtkOrientation.VERTICAL, 1);
|
||||
Label profileBoxTitle = new Label("");
|
||||
profileBoxTitle.setMarkup("<span size=\"15000\">Account details</span>");
|
||||
profileBox.packStart(profileBoxTitle,0,0,30);
|
||||
Entry username = new Entry();
|
||||
profileBox.add(username);
|
||||
username.setPlaceholderText("username");
|
||||
Entry password = new Entry();
|
||||
profileBox.add(password);
|
||||
password.setPlaceholderText("password");
|
||||
|
||||
connectionAssistant.insertPage(profileBox, 2);
|
||||
connectionAssistant.setPageTitle(profileBox, "Account");
|
||||
|
||||
connectionAssistant.setPageComplete(hello, true);
|
||||
connectionAssistant.setPageComplete(serverBox, true);
|
||||
|
||||
|
||||
connectionAssistant.showAll();
|
||||
}
|
||||
|
||||
|
||||
private void setStatus(ToolButton x)
|
||||
{
|
||||
/* If there are any available connections */
|
||||
|
@ -620,7 +571,7 @@ public class GUI : Thread
|
|||
|
||||
private void connectButton(MenuItem)
|
||||
{
|
||||
connectServer("0.0.0.0", 7777);
|
||||
connectServer("0.0.0.0", 7777, ["testGustav"~to!(string)(connections.length), "bruh"]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -630,7 +581,7 @@ public class GUI : Thread
|
|||
* NOTE: To be called only by a GTK signal
|
||||
* handler
|
||||
*/
|
||||
private void connectServer(string address, ushort port)
|
||||
public void connectServer(string address, ushort port, string[] authDetails)
|
||||
{
|
||||
/**
|
||||
* If this is our first connection then
|
||||
|
@ -649,7 +600,7 @@ public class GUI : Thread
|
|||
}
|
||||
|
||||
/* Create the new Connection */
|
||||
Connection newConnection = new Connection(this, parseAddress(address, port), ["testGustav"~to!(string)(connections.length), "bruh"]);
|
||||
Connection newConnection = new Connection(this, parseAddress(address, port), authDetails);
|
||||
connections ~= newConnection;
|
||||
|
||||
// import UserDirectory;
|
||||
|
|
Loading…
Reference in New Issue