~ubuntu-multiseat/ubuntu/saucy/unity-greeter/bug1201122

« back to all changes in this revision

Viewing changes to src/greeter-list.vala

Tags: upstream-12.10.3
ImportĀ upstreamĀ versionĀ 12.10.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
        get
86
86
        {
87
87
            /* First, get grid row number as if menubar weren't there */
88
 
            var row = (MenuBar.HEIGHT + get_allocated_height ()) / grid_size;
 
88
            var row = (MainWindow.MENUBAR_HEIGHT + get_allocated_height ()) / grid_size;
89
89
            row = row - DEFAULT_BOX_HEIGHT; /* and no default dash box */
90
90
            row = row / 2; /* and in the middle */
91
91
            /* Now calculate y pixel spot keeping in mind menubar's allocation */
92
 
            return row * grid_size - MenuBar.HEIGHT;
 
92
            return row * grid_size - MainWindow.MENUBAR_HEIGHT;
93
93
        }
94
94
    }
95
95
 
176
176
 
177
177
    public void cancel_authentication ()
178
178
    {
179
 
        UnityGreeter.greeter.cancel_authentication ();
 
179
        UnityGreeter.singleton.cancel_authentication ();
180
180
        entry_selected (selected_entry.id);
181
181
    }
182
182
 
436
436
 
437
437
    protected virtual int get_position_y (double position)
438
438
    {
439
 
        double grid_number = position;
440
 
 
441
 
        if (position >= 0.0 && position < 1.0)
442
 
        {
443
 
            var grids = get_greeter_box_height_grids ();
444
 
            grid_number = position * grids; /* scaled to height of greeter box */
445
 
        }
446
 
        else if (position >= 1.0)
447
 
        {
448
 
            var grids = get_greeter_box_height_grids ();
449
 
            grid_number = position + grids - 1.0;
450
 
        }
451
 
 
452
 
        return get_greeter_box_y () + (int)(grid_number * grid_size);
 
439
        // Most position heights are just the grid height.  Except for the one
 
440
        // right above the greeter box and the greeter box itself.  The greeter
 
441
        // box is some number of grids to start with.  And it is smaller by a
 
442
        // bit, while the one above it is larger by the same amount, in order
 
443
        // to line up names outside the greeter box in the middle of their
 
444
        // grid, while the name inside the box is near the bottom of its first
 
445
        // box.
 
446
        int one_above_height = grid_size + PromptBox.NAME_MARGIN_TOP;
 
447
        int box_height = get_greeter_box_height_grids () * grid_size -
 
448
                         PromptBox.NAME_MARGIN_TOP;
 
449
        double offset;
 
450
 
 
451
        if (position < -1)
 
452
            offset = (position + 1) * grid_size - one_above_height;
 
453
        else if (position < 0)
 
454
            offset = position * one_above_height;
 
455
        else if (position < 1)
 
456
            offset = position * box_height;
 
457
        else
 
458
            offset = (position - 1) * grid_size + box_height;
 
459
 
 
460
        return get_greeter_box_y () + (int)offset;
453
461
    }
454
462
 
455
463
    private void move_entry (PromptBox entry, double position)
464
472
        /* Some entry types may care where they are (e.g. wifi prompt) */
465
473
        entry.position = position;
466
474
 
 
475
        Gtk.Allocation allocation;
 
476
        get_allocation (out allocation);
 
477
 
467
478
        var child_allocation = Gtk.Allocation ();
468
479
        child_allocation.width = grid_size * BOX_WIDTH - BORDER * 2;
469
480
        entry.get_preferred_height_for_width (child_allocation.width, null, out child_allocation.height);
470
 
        child_allocation.x = get_greeter_box_x ();
471
 
        child_allocation.y = get_position_y (position);
 
481
        child_allocation.x = allocation.x + get_greeter_box_x ();
 
482
        child_allocation.y = allocation.y + get_position_y (position);
472
483
        fixed.move (entry, child_allocation.x, child_allocation.y);
473
484
        entry.size_allocate (child_allocation);
474
485
        entry.show ();
642
653
            return;
643
654
 
644
655
        allocate_greeter_box ();
 
656
        move_names ();
645
657
    }
646
658
 
647
659
    public override bool draw (Cairo.Context c)
699
711
 
700
712
    protected void connect_to_lightdm ()
701
713
    {
702
 
        UnityGreeter.greeter.show_message.connect (show_message_cb);
703
 
        UnityGreeter.greeter.show_prompt.connect (show_prompt_cb);
704
 
        UnityGreeter.greeter.authentication_complete.connect (authentication_complete_cb);
 
714
        UnityGreeter.singleton.show_message.connect (show_message_cb);
 
715
        UnityGreeter.singleton.show_prompt.connect (show_prompt_cb);
 
716
        UnityGreeter.singleton.authentication_complete.connect (authentication_complete_cb);
705
717
    }
706
718
 
707
719
    protected void show_message_cb (string text, LightDM.MessageType type)
714
726
        /* Notify the greeter on what user has been logged */
715
727
        if (get_selected_id () == "*other" && manual_name == null)
716
728
        {
717
 
            if (UnityGreeter.test_mode)
 
729
            if (UnityGreeter.singleton.test_mode)
718
730
                manual_name = test_username;
719
731
            else
720
 
                manual_name = UnityGreeter.greeter.authentication_user;
 
732
                manual_name = UnityGreeter.singleton.authentication_user();
721
733
        }
722
734
 
723
735
        prompted = true;
743
755
            return;
744
756
 
745
757
        bool is_authenticated;
746
 
        if (UnityGreeter.test_mode)
 
758
        if (UnityGreeter.singleton.test_mode)
747
759
            is_authenticated = test_is_authenticated;
748
760
        else
749
 
            is_authenticated = UnityGreeter.greeter.is_authenticated;
 
761
            is_authenticated = UnityGreeter.singleton.is_authenticated();
750
762
 
751
763
        if (is_authenticated)
752
764
        {
754
766
            if (prompted)
755
767
            {
756
768
                login_complete ();
757
 
                if (UnityGreeter.test_mode)
 
769
                if (UnityGreeter.singleton.test_mode)
758
770
                    start_session ();
759
771
                else
760
772
                {
806
818
 
807
819
        greeter_authenticating_user = get_selected_id ();
808
820
 
809
 
        if (UnityGreeter.test_mode)
 
821
        if (UnityGreeter.singleton.test_mode)
810
822
            test_start_authentication ();
811
823
        else
812
824
        {
813
825
            if (get_selected_id () == "*other")
814
 
                UnityGreeter.greeter.authenticate ();
 
826
                UnityGreeter.singleton.authenticate ();
815
827
            else if (get_selected_id () == "*guest")
816
 
                UnityGreeter.greeter.authenticate_as_guest ();
 
828
                UnityGreeter.singleton.authenticate_as_guest ();
817
829
            else
818
 
                UnityGreeter.greeter.authenticate (get_selected_id ());
 
830
                UnityGreeter.singleton.authenticate (get_selected_id ());
819
831
        }
820
832
    }
821
833
 
834
846
        background.draw_grid = false;
835
847
        background.queue_draw ();
836
848
 
837
 
        UnityGreeter.start_session (get_lightdm_session ());
 
849
        UnityGreeter.singleton.start_session (get_lightdm_session ());
838
850
    }
839
851
 
840
852
    public void login_complete ()