From e7f66aa24d9924c4fbbbedb3d3a5b6c97920779d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sun, 20 Apr 2008 04:15:42 +0000 Subject: [PATCH] Present full names in the list instead of logins. Aw I should have slept tonight... zZzZ git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25074 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/login/LoginView.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/apps/login/LoginView.cpp b/src/apps/login/LoginView.cpp index e98dbed48b..91f40dadd3 100644 --- a/src/apps/login/LoginView.cpp +++ b/src/apps/login/LoginView.cpp @@ -7,10 +7,31 @@ #include "LoginApp.h" #include "LoginView.h" +#define LW 120 #define CSEP 15 #define BH 20 #define BW 60 +class PwdItem : public BStringItem { +public: + PwdItem(struct passwd *pwd, uint32 level = 0, + bool expanded = true) + : BStringItem("", level, expanded) + { + if (pwd) { + BString name(pwd->pw_gecos); + // TODO: truncate at first ; + fLogin = pwd->pw_name; + SetText(name.String()); + } + }; + virtual ~PwdItem() {}; + const char* Login() const { return fLogin.String(); }; +private: + BString fLogin; +}; + + LoginView::LoginView(BRect frame) : BView(frame, "LoginView", B_FOLLOW_ALL, B_PULSE_NEEDED) { @@ -19,7 +40,7 @@ LoginView::LoginView(BRect frame) SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLowColor(ViewColor()); BRect r; - r.Set(CSEP, CSEP, 90, Bounds().Height() - 3 * CSEP - BH); + r.Set(CSEP, CSEP, LW, Bounds().Height() - 3 * CSEP - BH); fUserList = new BListView(r, "users"); BScrollView *sv = new BScrollView("userssv", fUserList, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true); @@ -27,7 +48,7 @@ LoginView::LoginView(BRect frame) fUserList->SetSelectionMessage(new BMessage(kUserSelected)); fUserList->SetInvocationMessage(new BMessage(kUserInvoked)); - r.Set(140, Bounds().top + CSEP, + r.Set(LW + 30, Bounds().top + CSEP, Bounds().right - CSEP, Bounds().top + CSEP + CSEP); fLoginControl = new BTextControl(r, "login", "login:", "", new BMessage(kLoginEdited)); @@ -112,10 +133,10 @@ LoginView::MessageReceived(BMessage *message) { int32 selection = fUserList->CurrentSelection(); if (selection > -1) { - BStringItem *item = dynamic_cast( + PwdItem *item = dynamic_cast( fUserList->ItemAt(selection)); if (item) - fLoginControl->SetText(item->Text()); + fLoginControl->SetText(item->Login()); } break; } @@ -194,7 +215,7 @@ LoginView::AddNextUser() strcmp(pwd->pw_shell, "/bin/false") && strcmp(pwd->pw_shell, "/bin/true")) { // not disabled - BStringItem *item = new BStringItem(pwd->pw_name); + PwdItem *item = new PwdItem(pwd); fUserList->AddItem(item); } if (pwd)