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

« back to all changes in this revision

Viewing changes to src/service.c

  • Committer: Marco Trevisan (Treviño)
  • Date: 2014-03-11 14:02:31 UTC
  • mto: This revision was merged to the branch mainline in revision 434.
  • Revision ID: mail@3v1n0.net-20140311140231-gjpfd6n9wb0gizr5
IndicatorSessionService: add desktop_lockscreen mode, show users and switch to account items

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
{
67
67
  PROFILE_DESKTOP,
68
68
  PROFILE_GREETER,
 
69
  PROFILE_LOCKSCREEN,
69
70
  N_PROFILES
70
71
};
71
72
 
72
73
static const char * const menu_names[N_PROFILES] =
73
74
{
74
75
  "desktop",
75
 
  "desktop_greeter"
 
76
  "desktop_greeter",
 
77
  "desktop_lockscreen"
76
78
};
77
79
 
78
80
struct ProfileMenuInfo
229
231
****  USERS
230
232
***/
231
233
 
232
 
static GMenuModel * create_switch_section (IndicatorSessionService * self);
 
234
static GMenuModel * create_switch_section (IndicatorSessionService * self, int profile);
233
235
 
234
236
static void
235
237
add_user (IndicatorSessionService * self, guint uid)
480
482
}
481
483
 
482
484
static GMenuModel *
483
 
create_switch_section (IndicatorSessionService * self)
 
485
create_switch_section (IndicatorSessionService * self, int profile)
484
486
{
485
487
  gchar * str;
486
488
  GMenu * menu;
500
502
      const char * action = "indicator.switch-to-screensaver";
501
503
      item = g_menu_item_new (_("Start Screen Saver"), action);
502
504
    }
503
 
  else if (indicator_session_guest_is_active (p->backend_guest))
 
505
  else if (profile == PROFILE_LOCKSCREEN ||
 
506
           indicator_session_guest_is_active (p->backend_guest))
504
507
    {
505
508
      const char * action = "indicator.switch-to-greeter";
506
509
      item = g_menu_item_new (ellipsis ? _("Switch Account…")
516
519
        item = g_menu_item_new (ellipsis ? _("Lock/Switch Account…")
517
520
                                         : _("Lock/Switch Account"), action);
518
521
    }
519
 
  str = g_settings_get_string (p->keybinding_settings, "screensaver");
520
 
  g_menu_item_set_attribute (item, "accel", "s", str);
521
 
  g_free (str);
 
522
 
 
523
  if (profile != PROFILE_LOCKSCREEN)
 
524
    {
 
525
      str = g_settings_get_string (p->keybinding_settings, "screensaver");
 
526
      g_menu_item_set_attribute (item, "accel", "s", str);
 
527
      g_free (str);
 
528
    }
 
529
 
522
530
  g_menu_append_item (menu, item);
523
531
  g_object_unref (item);
524
 
 
 
532
 
525
533
  if (indicator_session_guest_is_allowed (p->backend_guest))
526
534
    {
527
535
      GMenuItem *item;
555
563
      const IndicatorSessionUser * u = g_ptr_array_index (users, i);
556
564
      GVariant * serialized_icon;
557
565
 
 
566
      if (profile == PROFILE_LOCKSCREEN && u->is_current_user)
 
567
        continue;
 
568
 
558
569
      item = g_menu_item_new (get_user_label (u), NULL);
559
570
      g_menu_item_set_action_and_target (item, "indicator.switch-to-user", "s", u->user_name);
560
571
      g_menu_item_set_attribute (item, "x-canonical-type", "s", "indicator.user-menu-item");
640
651
    {
641
652
      sections[n++] = create_admin_section ();
642
653
      sections[n++] = create_settings_section (self);
643
 
      sections[n++] = create_switch_section (self);
 
654
      sections[n++] = create_switch_section (self, profile);
644
655
      sections[n++] = create_logout_section (self);
645
656
      sections[n++] = create_session_section (self);
646
657
    }
648
659
    {
649
660
      sections[n++] = create_session_section (self);
650
661
    }
 
662
  else if (profile == PROFILE_LOCKSCREEN)
 
663
    {
 
664
      sections[n++] = create_switch_section (self, profile);
 
665
      sections[n++] = create_session_section (self);
 
666
    }
651
667
 
652
668
  /* add sections to the submenu */
653
669
  submenu = g_menu_new ();
862
878
  priv_t * p = self->priv;
863
879
  struct ProfileMenuInfo * desktop = &p->menus[PROFILE_DESKTOP];
864
880
  struct ProfileMenuInfo * greeter = &p->menus[PROFILE_GREETER];
 
881
  struct ProfileMenuInfo * lockscreen = &p->menus[PROFILE_LOCKSCREEN];
865
882
 
866
883
  if (sections & SECTION_HEADER)
867
884
    {
880
897
 
881
898
  if (sections & SECTION_SWITCH)
882
899
    {
883
 
      rebuild_section (desktop->submenu, 2, create_switch_section(self));
 
900
      rebuild_section (desktop->submenu, 2, create_switch_section(self, PROFILE_DESKTOP));
 
901
      rebuild_section (lockscreen->submenu, 0, create_switch_section(self, PROFILE_LOCKSCREEN));
884
902
      update_switch_actions (self);
885
903
    }
886
904
 
893
911
    {
894
912
      rebuild_section (desktop->submenu, 4, create_session_section(self));
895
913
      rebuild_section (greeter->submenu, 0, create_session_section(self));
 
914
      rebuild_section (lockscreen->submenu, 1, create_session_section(self));
896
915
    }
897
916
}
898
917