Display the full name instead (if available)
This commit is contained in:
parent
153909b557
commit
1f8a1e191e
|
@ -56,21 +56,22 @@ PanelAppletDefinition applet =
|
||||||
/* private */
|
/* private */
|
||||||
/* functions */
|
/* functions */
|
||||||
/* user_init */
|
/* user_init */
|
||||||
|
static String * _init_user(void);
|
||||||
|
|
||||||
static User * _user_init(PanelAppletHelper * helper, GtkWidget ** widget)
|
static User * _user_init(PanelAppletHelper * helper, GtkWidget ** widget)
|
||||||
{
|
{
|
||||||
User * user;
|
User * user;
|
||||||
struct passwd * pw;
|
|
||||||
PangoFontDescription * desc;
|
PangoFontDescription * desc;
|
||||||
|
String * name;
|
||||||
|
|
||||||
if((pw = getpwuid(getuid())) == NULL)
|
|
||||||
{
|
|
||||||
error_set("%s: %s", applet.name, strerror(errno));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if((user = object_new(sizeof(*user))) == NULL)
|
if((user = object_new(sizeof(*user))) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
user->helper = helper;
|
user->helper = helper;
|
||||||
user->widget = gtk_label_new(pw->pw_name);
|
if((name = _init_user()) != NULL)
|
||||||
|
user->widget = gtk_label_new(name);
|
||||||
|
else
|
||||||
|
user->widget = gtk_label_new("Unknown user");
|
||||||
|
string_delete(name);
|
||||||
desc = pango_font_description_new();
|
desc = pango_font_description_new();
|
||||||
pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
|
pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
|
||||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||||
|
@ -84,6 +85,26 @@ static User * _user_init(PanelAppletHelper * helper, GtkWidget ** widget)
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String * _init_user(void)
|
||||||
|
{
|
||||||
|
struct passwd * pw;
|
||||||
|
ssize_t len;
|
||||||
|
|
||||||
|
if((pw = getpwuid(getuid())) == NULL)
|
||||||
|
{
|
||||||
|
error_set("%s: %s", applet.name, strerror(errno));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if(pw->pw_gecos != NULL && strlen(pw->pw_gecos) > 0)
|
||||||
|
{
|
||||||
|
if((len = string_index(pw->pw_gecos, ",")) > 0)
|
||||||
|
return string_new_length(pw->pw_gecos, len);
|
||||||
|
else if(len != 0)
|
||||||
|
return string_new(pw->pw_gecos);
|
||||||
|
}
|
||||||
|
return string_new(pw->pw_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* user_destroy */
|
/* user_destroy */
|
||||||
static void _user_destroy(User * user)
|
static void _user_destroy(User * user)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user