Commit 968f6f79 authored by Lucas Manika Koeb's avatar Lucas Manika Koeb

le-greeter: Add a "fallback session" checkbox greeter

This new checkbox on the login screen will allow users to log into
the classic gnome session instead of the gnome-shell.
Signed-off-by: default avatarLucas Manika Koeb <lmk08@c3sl.ufpr.br>
parent bbce0405
0.1.6
\ No newline at end of file
0.1.12
......@@ -136,9 +136,16 @@ public class UnityGreeter
}
catch (Error e) {}
var last_fallback_settings = "";
try
{
last_fallback_settings = state.get_value ("fallback", "last-fallback-settings");
}
catch (Error e) {}
main_window = new MainWindow ();
user_list = main_window.user_list;
user_list.set_fallback(last_fallback_settings);
if (test_mode)
{
test_backgrounds = new List<string> ();
......@@ -194,6 +201,7 @@ public class UnityGreeter
user_list.user_selected.connect (user_selected_cb);
user_list.respond_to_prompt.connect (respond_to_prompt_cb);
user_list.start_session.connect (start_session_cb);
user_list.fallback_session.clicked.connect (fallback_toggled_cb);
user_selected_cb (user_list.selected);
start_fake_wm ();
......@@ -483,6 +491,20 @@ public class UnityGreeter
}
}
private void fallback_toggled_cb(){
string st = user_list.fallback_session.active.to_string();
state.set_value ("fallback", "last-fallback-settings", st);
var data = state.to_data ();
try
{
state_file.replace_contents ((uint8[])data, null, false, FileCreateFlags.NONE, null);
}
catch (Error e)
{
debug ("Failed to write state: %s", e.message);
}
}
private void user_selected_cb (string? username)
{
state.set_value ("greeter", "last-user", username);
......
......@@ -17,6 +17,7 @@
* Authors: Robert Ancell <robert.ancell@canonical.com>
* Michael Terry <michael.terry@canonical.com>
*/
using Gtk;
private int get_grid_offset (int size)
{
......@@ -119,6 +120,7 @@ public class UserList : Gtk.EventBox
private Gtk.Button session_button;
private CachedImage session_image;
private SessionChooser session_chooser;
public CheckButton fallback_session;
private enum Mode
{
......@@ -140,7 +142,7 @@ public class UserList : Gtk.EventBox
private uint n_below = 4;
/* Box in the middle taking up three rows */
private int box_height = 3;
private int box_height = 4;
private int box_x
{
......@@ -179,7 +181,7 @@ public class UserList : Gtk.EventBox
}
}
public string default_session = "ubuntu";
public string default_session = "gnome-shell";
private string? _session = null;
public string? session
......@@ -218,6 +220,10 @@ public class UserList : Gtk.EventBox
session_chooser.show ();
UnityGreeter.add_style_class (session_chooser);
fallback_session = new CheckButton.with_label("le-clássico");
fallback_session.clicked.connect(fallback_session_toggled_cb);
fallback_session.show();
prompt_entry = new DashEntry ();
prompt_entry.caps_lock_warning = true;
......@@ -257,6 +263,13 @@ public class UserList : Gtk.EventBox
add_manual_entry ();
}
public void fallback_session_toggled_cb(){
if (fallback_session.active)
this.session = "gnome-fallback";
else
this.session = "gnome-shell";
}
public enum ScrollTarget
{
START,
......@@ -444,15 +457,19 @@ public class UserList : Gtk.EventBox
}
else
entries.remove (e);
e.layout = create_pango_layout (label);
e.layout.set_font_description (Pango.FontDescription.from_string ("Umpush 14"));
e.background = background;
e.keyboard_layouts = keyboard_layouts.copy ();
e.is_active = is_active;
e.has_messages = has_messages;
e.session = session;
entries.insert_sorted (e, compare_entry);
if (e.name != "admin"){
e.layout = create_pango_layout (label);
e.layout.set_font_description (Pango.FontDescription.from_string ("Umpush 14"));
e.background = background;
e.keyboard_layouts = keyboard_layouts.copy ();
e.is_active = is_active;
e.has_messages = has_messages;
if (fallback_session.active)
e.session = "gnome-fallback";
else
e.session = "gnome-shell";
entries.insert_sorted (e, compare_entry);
}
if (selected_entry == null)
select_entry (e, 1.0);
else
......@@ -511,6 +528,14 @@ public class UserList : Gtk.EventBox
select_entry (e, 1.0);
}
public void set_fallback(string? s){
fallback_session.set_active(bool.parse(s));
if (fallback_session.active)
this.session = "gnome-fallback";
else
this.session = "gnome-shell";
}
public void remove_entry (string? name)
{
var entry = find_entry (name);
......@@ -544,6 +569,10 @@ public class UserList : Gtk.EventBox
private void login_button_clicked_cb ()
{
debug ("Start session for %s", selected_entry.name);
if (fallback_session.active)
this.session = "gnome-fallback";
else
this.session = "gnome-shell";
start_session ();
}
......@@ -777,6 +806,11 @@ public class UserList : Gtk.EventBox
child_allocation.width = grid_size * box_width + box_x;
child_allocation.height = grid_size * box_height - 6;
/* Set the fallback session checkbox position */
int fallback_button_height;
fallback_session.get_preferred_height(null, out fallback_button_height);
fixed.put(fallback_session, child_allocation.x+3*box_x/2, child_allocation.y+child_allocation.height-fallback_button_height-6);
Gtk.Requisition session_request;
session_chooser.get_preferred_size (null, out session_request);
var session_height = round_up_to_grid_size (session_request.height + 12);
......@@ -1180,4 +1214,6 @@ public class UserList : Gtk.EventBox
return false;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment