22
22
public class UnityGreeter
24
static bool show_version = false;
25
public static bool test_mode = false;
26
public static const OptionEntry[] options =
28
{ "version", 'v', 0, OptionArg.NONE, ref show_version,
29
/* Help string for command line --version flag */
30
N_("Show release version"), null },
31
{ "test-mode", 0, 0, OptionArg.NONE, ref test_mode,
32
/* Help string for command line --test-mode flag */
33
N_("Run in test mode"), null },
37
private static Timer log_timer;
39
private static string state_file;
40
private static KeyFile state;
42
private static Cairo.XlibSurface background_surface;
24
public static UnityGreeter singleton;
26
public signal void show_message (string text, LightDM.MessageType type);
27
public signal void show_prompt (string text, LightDM.PromptType type);
28
public signal void authentication_complete ();
30
public bool test_mode = false;
32
private string state_file;
33
private KeyFile state;
35
private Cairo.XlibSurface background_surface;
44
37
private SettingsDaemon settings_daemon;
46
private static MainWindow main_window;
39
private MainWindow main_window;
48
public static LightDM.Greeter greeter;
41
private LightDM.Greeter greeter;
50
43
private Canberra.Context canberra_context;
52
public UnityGreeter ()
45
private static Timer log_timer;
47
private UnityGreeter (bool test_mode_)
50
test_mode = test_mode_;
52
/* Prepare to set the background */
53
debug ("Creating background surface");
54
background_surface = create_root_surface (Gdk.Screen.get_default ());
54
56
greeter = new LightDM.Greeter ();
57
greeter.show_message.connect ((text, type) => { show_message (text, type); });
58
greeter.show_prompt.connect ((text, type) => { show_prompt (text, type); });
59
greeter.authentication_complete.connect (() => { authentication_complete (); });
55
60
var connected = false;
106
public static void set_state (string key, string value)
111
public void set_state (string key, string value)
108
113
state.set_value ("greeter", key, value);
109
114
var data = state.to_data ();
192
197
main_window.set_keyboard_state ();
195
private static Gdk.FilterReturn focus_upon_map (Gdk.XEvent gxevent, Gdk.Event event)
200
public bool is_authenticated ()
202
return greeter.is_authenticated;
205
public void authenticate (string? userid = null)
207
greeter.authenticate (userid);
210
public void authenticate_as_guest ()
212
greeter.authenticate_as_guest ();
215
public void authenticate_remote (string? session, string? userid)
217
UnityGreeter.singleton.greeter.authenticate_remote (session, userid);
220
public void cancel_authentication ()
222
greeter.cancel_authentication ();
225
public void respond (string response)
227
greeter.respond (response);
230
public string authentication_user ()
232
return greeter.authentication_user;
235
public string default_session_hint ()
237
return greeter.default_session_hint;
240
public string select_user_hint ()
242
return greeter.select_user_hint;
245
public bool show_manual_login_hint ()
247
return greeter.show_manual_login_hint;
250
public bool hide_users_hint ()
252
return greeter.hide_users_hint;
255
public bool has_guest_account_hint ()
257
return greeter.has_guest_account_hint;
260
private Gdk.FilterReturn focus_upon_map (Gdk.XEvent gxevent, Gdk.Event event)
197
262
var xevent = (X.Event*)gxevent;
198
263
if (xevent.type == X.EventType.MapNotify)
238
303
var pixmap = X.CreatePixmap (display,
239
304
Gdk.X11Window.get_xid (screen.get_root_window ()),
306
screen.get_height (),
242
307
visual.get_depth ());
244
309
/* Convert into a Cairo surface */
245
310
var surface = new Cairo.XlibSurface (display,
247
312
Gdk.X11Visual.get_xvisual (visual),
248
screen.width (), screen.height ());
313
screen.get_width (), screen.get_height ());
344
409
debug ("Setting cursor");
345
410
Gdk.get_default_root_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.LEFT_PTR));
347
/* Prepare to set the background */
348
debug ("Creating background surface");
349
background_surface = create_root_surface (Gdk.Screen.get_default ());
412
bool do_show_version = false;
413
bool do_test_mode = false;
414
OptionEntry versionOption = { "version", 'v', 0, OptionArg.NONE, ref do_show_version,
415
/* Help string for command line --version flag */
416
N_("Show release version"), null };
417
OptionEntry testOption = { "test-mode", 0, 0, OptionArg.NONE, ref do_test_mode,
418
/* Help string for command line --test-mode flag */
419
N_("Run in test mode"), null };
420
OptionEntry nullOption = { null };
421
OptionEntry[] options = { versionOption, testOption, nullOption };
351
423
debug ("Loading command line options");
352
424
var c = new OptionContext (/* Arguments and description for --help text */
365
437
stderr.printf ("\n");
366
438
return Posix.EXIT_FAILURE;
370
442
/* Note, not translated so can be easily parsed */
371
443
stderr.printf ("unity-greeter %s\n", Config.VERSION);
372
444
return Posix.EXIT_SUCCESS;
376
448
debug ("Running in test mode");
380
452
/* Make nm-applet hide items the user does not have permissions to interact with */
381
453
Environment.set_variable ("NM_APPLET_HIDE_POLICY_ITEMS", "1", true);
415
487
settings.set ("gtk-xft-rgba", value, null);
417
489
debug ("Creating Unity Greeter");
418
var greeter = new UnityGreeter ();
490
var greeter = new UnityGreeter (do_test_mode);
420
492
debug ("Showing greeter");