~elementary-os/elementaryos/os-patch-indicator-session-trusty

« back to all changes in this revision

Viewing changes to src/service.c

Merge in trunk and resolve conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
295
295
{
296
296
  const char * c;
297
297
 
298
 
  /* If blank or whitespace, use username instead */
299
 
  for (c = user->real_name; *c != '\0' && g_ascii_isspace (*c); c++);
300
 
  if (*c == '\0')
301
 
    return user->user_name;
302
 
 
303
 
  return user->real_name;
 
298
  /* if real_name exists and is printable, use it */
 
299
  c = user->real_name;
 
300
  if ((c != NULL) && g_utf8_validate(c, -1, NULL))
 
301
    {
 
302
      while (*c != '\0')
 
303
        {
 
304
          if (g_unichar_isgraph(g_utf8_get_char(c)))
 
305
            return user->real_name;
 
306
 
 
307
          c = g_utf8_next_char(c);
 
308
        }
 
309
    }
 
310
 
 
311
  /* otherwise, use this as a fallback */
 
312
  return user->user_name;
304
313
}
305
314
 
306
315
static const char *
674
683
}
675
684
 
676
685
static GMenuModel *
677
 
create_session_section (IndicatorSessionService * self)
 
686
create_session_section (IndicatorSessionService * self, int profile)
678
687
{
679
688
  GMenu * menu;
680
689
  const priv_t * const p = self->priv;
689
698
  if (indicator_session_actions_can_hibernate (p->backend_actions))
690
699
    g_menu_append (menu, _("Hibernate"), "indicator.hibernate");
691
700
 
692
 
  if (!g_settings_get_boolean (s, "suppress-shutdown-menuitem"))
 
701
  if (profile != PROFILE_LOCKSCREEN && 
 
702
    indicator_session_actions_can_reboot (p->backend_actions))
 
703
    {
 
704
      const char * label = ellipsis ? _("Restart…") : _("Restart");
 
705
      g_menu_append (menu, label, "indicator.reboot");
 
706
    }
 
707
 
 
708
  if (profile != PROFILE_LOCKSCREEN && 
 
709
    !g_settings_get_boolean (s, "suppress-shutdown-menuitem"))
693
710
    {
694
711
      const char * label = ellipsis ? _("Shut Down…") : _("Shut Down");
695
712
      g_menu_append (menu, label, "indicator.power-off");
717
734
      sections[n++] = create_settings_section (self);
718
735
      sections[n++] = create_switch_section (self, profile);
719
736
      sections[n++] = create_logout_section (self);
720
 
      sections[n++] = create_session_section (self);
 
737
      sections[n++] = create_session_section (self, profile);
721
738
    }
722
739
  else if (profile == PROFILE_GREETER)
723
740
    {
724
 
      sections[n++] = create_session_section (self);
 
741
      sections[n++] = create_session_section (self, profile);
725
742
    }
726
743
  else if (profile == PROFILE_LOCKSCREEN)
727
744
    {
728
745
      sections[n++] = create_switch_section (self, profile);
729
 
      sections[n++] = create_session_section (self);
 
746
      sections[n++] = create_session_section (self, profile);
730
747
    }
731
748
 
732
749
  /* add sections to the submenu */
973
990
 
974
991
  if (sections & SECTION_SESSION)
975
992
    {
976
 
      rebuild_section (desktop->submenu, 4, create_session_section(self));
977
 
      rebuild_section (greeter->submenu, 0, create_session_section(self));
978
 
      rebuild_section (lockscreen->submenu, 1, create_session_section(self));
 
993
      rebuild_section (desktop->submenu, 4, create_session_section(self, PROFILE_DESKTOP));
 
994
      rebuild_section (greeter->submenu, 0, create_session_section(self, PROFILE_GREETER));
 
995
      rebuild_section (lockscreen->submenu, 1, create_session_section(self, PROFILE_LOCKSCREEN));
979
996
    }
980
997
}
981
998