From 015521082ecd5cba34000f3ae1cc33a589ed6181 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Mon, 26 Oct 2020 10:23:35 +0200 Subject: [PATCH] Added TODO --- source/ProfileWIndow.d | 13 ++++++++++++- source/UserNode.d | 30 +++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/source/ProfileWIndow.d b/source/ProfileWIndow.d index 22be82b..9f4d3d0 100644 --- a/source/ProfileWIndow.d +++ b/source/ProfileWIndow.d @@ -9,6 +9,7 @@ import gtk.Window; import gtk.Label; import gtk.Image; import std.conv; +import gtk.Box; public final class ProfileWindow { @@ -25,16 +26,26 @@ public final class ProfileWindow private void showWindow() { + /* Create the window with the username as the title */ Window profileWindow = new Window(username); + /* Create a Box for contents */ + Box profileBox = new Box(GtkOrientation.VERTICAL, 1); + + /* Create the username label */ + Label usernameTitle = new Label(""); + usernameTitle.setMarkup(""~username~""); + profileBox.add(usernameTitle); Image profileImage = new Image("/home/deavmi/Downloads/5207740.jpg"); //profileWindow.add(profileImage); + /* TODO: Fix server to ACTUALLY take in the username as a parameter */ string[] props = connection.getClient().getProperties(username); - profileWindow.add(new Label(to!(string)(props))); + profileBox.add(new Label(to!(string)(props))); + profileWindow.add(profileBox); profileWindow.showAll(); } } \ No newline at end of file diff --git a/source/UserNode.d b/source/UserNode.d index bb9ff43..eb0abb6 100644 --- a/source/UserNode.d +++ b/source/UserNode.d @@ -9,6 +9,7 @@ import gtk.Label; import gtk.Tooltip; import gtk.Widget; import std.string; +import ProfileWIndow; public final class UserNode { @@ -25,14 +26,41 @@ public final class UserNode initBox(); } + private final class UserButton : Button + { + private string username; + + this(string username) + { + this.username = username; + } + + public string getUsername() + { + return username; + } + } + + private void userButtonClick(Button e) + { + /* The Button will only ever be a UserButton */ + UserButton button = cast(UserButton)e; + + /* Create a new ProfileWindow */ + ProfileWindow profileWindow = new ProfileWindow(connection, button.getUsername()); + } + private void initBox() { box = new Box(GtkOrientation.HORIZONTAL, 10); /* Layout [Button (Prescence Icon)] - Label */ - Button userButton = new Button(); + UserButton userButton = new UserButton(username); Image userButtonImg = new Image("user-available", GtkIconSize.BUTTON); userButton.setImage(userButtonImg); + + /* Set the handler for on click */ + userButton.addOnClicked(&userButtonClick); /* Create a label */ Label userLabel = new Label(username);