gustav/source/ProfileWIndow.d

66 lines
1.6 KiB
D
Raw Permalink Normal View History

2020-10-21 07:00:33 +00:00
/**
* Profile window
*
* User profile window
*/
import Connection;
import gtk.Window;
import gtk.Label;
import gtk.Image;
import std.conv;
2020-10-26 08:23:35 +00:00
import gtk.Box;
2020-10-21 07:00:33 +00:00
public final class ProfileWindow
{
private Connection connection;
private string username;
this(Connection connection, string username)
{
this.connection = connection;
this.username = username;
showWindow();
}
private void showWindow()
{
2020-10-26 08:23:35 +00:00
/* Create the window with the username as the title */
2020-10-21 07:00:33 +00:00
Window profileWindow = new Window(username);
2020-10-26 08:23:35 +00:00
/* Create a Box for contents */
Box profileBox = new Box(GtkOrientation.VERTICAL, 1);
2021-01-28 09:30:43 +00:00
/* Create a Image for the profile picture */
Image profileImage = new Image("/home/deavmi/Downloads/logo.png");
profileBox.add(profileImage);
// profileImage.
2020-10-26 08:23:35 +00:00
/* Create the username label */
Label usernameTitle = new Label("");
2020-10-28 06:19:33 +00:00
usernameTitle.setMarkup("<span size=\"20000\">"~username~"</span>");
2020-10-26 08:23:35 +00:00
profileBox.add(usernameTitle);
2020-10-21 07:00:33 +00:00
2021-01-28 09:30:43 +00:00
/* Display all props (keys) */
2020-10-21 07:00:33 +00:00
string[] props = connection.getClient().getProperties(username);
2020-10-26 08:23:35 +00:00
profileBox.add(new Label(to!(string)(props)));
2020-10-21 07:00:33 +00:00
2021-01-28 09:30:56 +00:00
/* Display all props (values) */
2021-01-28 09:30:43 +00:00
string[] propValues;
foreach(string property; props)
{
propValues ~= connection.getClient().getProperty(username, property);
}
profileBox.add(new Label(to!(string)(propValues)));
2020-10-26 08:23:35 +00:00
profileWindow.add(profileBox);
2020-10-21 07:00:33 +00:00
profileWindow.showAll();
2021-01-28 09:30:43 +00:00
// profileWindow.unmaximize();
// profileWindow.setAttachedTo()
2020-10-21 07:00:33 +00:00
}
}