~unity8-desktop-session-team/indicator-session/indicator-session-using-upstart

« back to all changes in this revision

Viewing changes to src/service.c

  • Committer: Tarmac
  • Author(s): Robert Ancell
  • Date: 2014-01-22 15:14:22 UTC
  • mfrom: (424.1.1 blank-username)
  • Revision ID: tarmac-20140122151422-me3xs93bsdrbx202
Use username as label if the real name is empty or whitespace. Fixes: https://bugs.launchpad.net/bugs/872908.

Approved by Ted Gould, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
274
274
}
275
275
 
276
276
static const char *
 
277
get_user_label (const IndicatorSessionUser * user)
 
278
{
 
279
  const char * c;
 
280
 
 
281
  /* If blank or whitespace, use username instead */
 
282
  for (c = user->real_name; *c != '\0' && g_ascii_isspace (*c); c++);
 
283
  if (*c == '\0')
 
284
    return user->user_name;
 
285
 
 
286
  return user->real_name;
 
287
}
 
288
 
 
289
static const char *
277
290
get_current_real_name (IndicatorSessionService * self)
278
291
{
279
292
  GHashTableIter iter;
289
302
    {
290
303
      IndicatorSessionUser * user = value;
291
304
      if (user->is_current_user)
292
 
        return user->real_name;
 
305
        return get_user_label (user);
293
306
    }
294
307
 
295
308
  return "";
435
448
  const IndicatorSessionUser * a = *(const IndicatorSessionUser**)ga;
436
449
  const IndicatorSessionUser * b = *(const IndicatorSessionUser**)gb;
437
450
 
438
 
  if ((i = g_strcmp0 (a->real_name, b->real_name)))
 
451
  if ((i = g_strcmp0 (get_user_label (a), get_user_label (b))))
439
452
    return i;
440
453
 
441
454
  return g_strcmp0 (a->user_name, b->user_name);
536
549
      const IndicatorSessionUser * u = g_ptr_array_index (users, i);
537
550
      GVariant * serialized_icon;
538
551
 
539
 
      item = g_menu_item_new (u->real_name, NULL);
 
552
      item = g_menu_item_new (get_user_label (u), NULL);
540
553
      g_menu_item_set_action_and_target (item, "indicator.switch-to-user", "s", u->user_name);
541
554
      g_menu_item_set_attribute (item, "x-canonical-type", "s", "indicator.user-menu-item");
542
555