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

« back to all changes in this revision

Viewing changes to src/service.c

  • Committer: Stephen M. Webb
  • Date: 2014-03-23 21:32:27 UTC
  • Revision ID: stephen.webb@canonical.com-20140323213227-l4ibsge0sd7xfhav
removed tests that assume gnome-session

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
 
  gchar * str;
486
487
  GMenu * menu;
487
488
  GMenuItem * item;
 
489
  gboolean want_accel;
488
490
  guint i;
489
491
  gpointer guser;
490
492
  GHashTableIter iter;
499
501
    {
500
502
      const char * action = "indicator.switch-to-screensaver";
501
503
      item = g_menu_item_new (_("Start Screen Saver"), action);
 
504
      want_accel = TRUE;
502
505
    }
503
 
  else if (indicator_session_guest_is_active (p->backend_guest))
 
506
  else if (profile == PROFILE_LOCKSCREEN ||
 
507
           indicator_session_guest_is_active (p->backend_guest))
504
508
    {
505
509
      const char * action = "indicator.switch-to-greeter";
506
510
      item = g_menu_item_new (ellipsis ? _("Switch Account…")
507
511
                                       : _("Switch Account"), action);
 
512
      want_accel = FALSE;
508
513
    }
509
514
  else
510
515
    {
515
520
      else
516
521
        item = g_menu_item_new (ellipsis ? _("Lock/Switch Account…")
517
522
                                         : _("Lock/Switch Account"), action);
518
 
    }
519
 
  str = g_settings_get_string (p->keybinding_settings, "screensaver");
520
 
  g_menu_item_set_attribute (item, "accel", "s", str);
521
 
  g_free (str);
 
523
 
 
524
      want_accel = TRUE;
 
525
    }
 
526
 
 
527
  if (want_accel)
 
528
    {
 
529
      gchar * str = g_settings_get_string (p->keybinding_settings, "screensaver");
 
530
      g_menu_item_set_attribute (item, "accel", "s", str);
 
531
      g_free (str);
 
532
    }
 
533
 
522
534
  g_menu_append_item (menu, item);
523
535
  g_object_unref (item);
524
 
 
 
536
 
525
537
  if (indicator_session_guest_is_allowed (p->backend_guest))
526
538
    {
527
539
      GMenuItem *item;
555
567
      const IndicatorSessionUser * u = g_ptr_array_index (users, i);
556
568
      GVariant * serialized_icon;
557
569
 
 
570
      if (profile == PROFILE_LOCKSCREEN && u->is_current_user)
 
571
        continue;
 
572
 
558
573
      item = g_menu_item_new (get_user_label (u), NULL);
559
574
      g_menu_item_set_action_and_target (item, "indicator.switch-to-user", "s", u->user_name);
560
575
      g_menu_item_set_attribute (item, "x-canonical-type", "s", "indicator.user-menu-item");
640
655
    {
641
656
      sections[n++] = create_admin_section ();
642
657
      sections[n++] = create_settings_section (self);
643
 
      sections[n++] = create_switch_section (self);
 
658
      sections[n++] = create_switch_section (self, profile);
644
659
      sections[n++] = create_logout_section (self);
645
660
      sections[n++] = create_session_section (self);
646
661
    }
648
663
    {
649
664
      sections[n++] = create_session_section (self);
650
665
    }
 
666
  else if (profile == PROFILE_LOCKSCREEN)
 
667
    {
 
668
      sections[n++] = create_switch_section (self, profile);
 
669
      sections[n++] = create_session_section (self);
 
670
    }
651
671
 
652
672
  /* add sections to the submenu */
653
673
  submenu = g_menu_new ();
862
882
  priv_t * p = self->priv;
863
883
  struct ProfileMenuInfo * desktop = &p->menus[PROFILE_DESKTOP];
864
884
  struct ProfileMenuInfo * greeter = &p->menus[PROFILE_GREETER];
 
885
  struct ProfileMenuInfo * lockscreen = &p->menus[PROFILE_LOCKSCREEN];
865
886
 
866
887
  if (sections & SECTION_HEADER)
867
888
    {
880
901
 
881
902
  if (sections & SECTION_SWITCH)
882
903
    {
883
 
      rebuild_section (desktop->submenu, 2, create_switch_section(self));
 
904
      rebuild_section (desktop->submenu, 2, create_switch_section(self, PROFILE_DESKTOP));
 
905
      rebuild_section (lockscreen->submenu, 0, create_switch_section(self, PROFILE_LOCKSCREEN));
884
906
      update_switch_actions (self);
885
907
    }
886
908
 
893
915
    {
894
916
      rebuild_section (desktop->submenu, 4, create_session_section(self));
895
917
      rebuild_section (greeter->submenu, 0, create_session_section(self));
 
918
      rebuild_section (lockscreen->submenu, 1, create_session_section(self));
896
919
    }
897
920
}
898
921