~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-02-05 18:27:30 UTC
  • mfrom: (428.1.1 logout-section)
  • Revision ID: tarmac-20140205182730-did9wh0yx112zvo1
Move logout into its own section to match design update in https://wiki.ubuntu.com/SystemMenu.

Approved by Charles Kerr, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
  SECTION_ADMIN     = (1<<1),
59
59
  SECTION_SETTINGS  = (1<<2),
60
60
  SECTION_SWITCH    = (1<<3),
61
 
  SECTION_SESSION   = (1<<4)
 
61
  SECTION_LOGOUT    = (1<<4),
 
62
  SECTION_SESSION   = (1<<5)
62
63
};
63
64
 
64
65
enum
133
134
  rebuild_soon (self, SECTION_SWITCH);
134
135
}
135
136
static inline void
 
137
rebuild_logout_section_soon (IndicatorSessionService * self)
 
138
{
 
139
  rebuild_soon (self, SECTION_LOGOUT);
 
140
}
 
141
static inline void
136
142
rebuild_session_section_soon (IndicatorSessionService * self)
137
143
{
138
144
  rebuild_soon (self, SECTION_SESSION);
569
575
}
570
576
 
571
577
static GMenuModel *
572
 
create_session_section (IndicatorSessionService * self, int profile)
 
578
create_logout_section (IndicatorSessionService * self)
573
579
{
574
580
  GMenu * menu;
575
581
  const priv_t * const p = self->priv;
576
 
  GSettings * const s = p->indicator_settings;
577
582
  const gboolean ellipsis = use_ellipsis (self);
578
583
 
579
584
  menu = g_menu_new ();
580
585
 
581
 
  if ((profile == PROFILE_DESKTOP) &&
582
 
      (indicator_session_actions_can_logout (p->backend_actions)))
 
586
  if (indicator_session_actions_can_logout (p->backend_actions))
583
587
    {
584
588
      const char * label = ellipsis ? _("Log Out…") : _("Log Out");
585
589
      g_menu_append (menu, label, "indicator.logout");
586
590
    }
587
591
 
 
592
  return G_MENU_MODEL (menu);
 
593
}
 
594
 
 
595
static GMenuModel *
 
596
create_session_section (IndicatorSessionService * self)
 
597
{
 
598
  GMenu * menu;
 
599
  const priv_t * const p = self->priv;
 
600
  GSettings * const s = p->indicator_settings;
 
601
  const gboolean ellipsis = use_ellipsis (self);
 
602
 
 
603
  menu = g_menu_new ();
 
604
 
588
605
  if (indicator_session_actions_can_suspend (p->backend_actions))
589
606
    g_menu_append (menu, _("Suspend"), "indicator.suspend");
590
607
 
624
641
      sections[n++] = create_admin_section ();
625
642
      sections[n++] = create_settings_section (self);
626
643
      sections[n++] = create_switch_section (self);
627
 
      sections[n++] = create_session_section (self, profile);
 
644
      sections[n++] = create_logout_section (self);
 
645
      sections[n++] = create_session_section (self);
628
646
    }
629
647
  else if (profile == PROFILE_GREETER)
630
648
    {
631
 
      sections[n++] = create_session_section (self, profile);
 
649
      sections[n++] = create_session_section (self);
632
650
    }
633
651
 
634
652
  /* add sections to the submenu */
866
884
      update_switch_actions (self);
867
885
    }
868
886
 
 
887
  if (sections & SECTION_LOGOUT)
 
888
    {
 
889
      rebuild_section (desktop->submenu, 3, create_logout_section(self));
 
890
    }
 
891
 
869
892
  if (sections & SECTION_SESSION)
870
893
    {
871
 
      rebuild_section (desktop->submenu, 3, create_session_section(self, PROFILE_DESKTOP));
872
 
      rebuild_section (greeter->submenu, 0, create_session_section(self, PROFILE_GREETER));
 
894
      rebuild_section (desktop->submenu, 4, create_session_section(self));
 
895
      rebuild_section (greeter->submenu, 0, create_session_section(self));
873
896
    }
874
897
}
875
898
 
1076
1099
  g_signal_connect_swapped (gp, "notify",
1077
1100
                            G_CALLBACK(rebuild_switch_section_soon), self);
1078
1101
  g_signal_connect_swapped (gp, "notify",
 
1102
                            G_CALLBACK(rebuild_logout_section_soon), self);
 
1103
  g_signal_connect_swapped (gp, "notify",
1079
1104
                            G_CALLBACK(rebuild_session_section_soon), self);
1080
1105
  g_signal_connect_swapped (gp, "notify::has-online-account-error",
1081
1106
                            G_CALLBACK(rebuild_header_soon), self);
1087
1112
  g_signal_connect_swapped (gp, "changed::suppress-logout-restart-shutdown",
1088
1113
                            G_CALLBACK(rebuild_switch_section_soon), self);
1089
1114
  g_signal_connect_swapped (gp, "changed::suppress-logout-restart-shutdown",
 
1115
                            G_CALLBACK(rebuild_logout_section_soon), self);
 
1116
  g_signal_connect_swapped (gp, "changed::suppress-logout-restart-shutdown",
1090
1117
                            G_CALLBACK(rebuild_session_section_soon), self);
1091
1118
  g_signal_connect_swapped (gp, "changed::suppress-shutdown-menuitem",
1092
1119
                            G_CALLBACK(rebuild_session_section_soon), self);