annotate src/libeggsmclient/README @ 4853:4beca46cb92b

there was an 'a' here. how did that get there
author William Pitcock <nenolod@atheme.org>
date Tue, 14 Apr 2009 16:26:12 -0500
parents c942eaef7bc6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4315
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
1 This is a draft of a replacement for GnomeClient. See also
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
2 http://live.gnome.org/SessionManagement and
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
3 http://bugzilla.gnome.org/show_bug.cgi?id=79285.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
4
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
5 The eventual target of this code is gtk, gdk, glib, or some
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
6 combination of them. Having it entirely in gtk/gdk may not be the best
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
7 option, because non-GUI apps like beagled want a chance to exit
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
8 cleanly when the session ends too. OTOH, making glib depend on libSM
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
9 would obviously suck. Using dlopen may be a good solution.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
10
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
11 EggDesktopItem is proposed gtk-level rewrite of GnomeDesktopItem. See
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
12 http://bugzilla.gnome.org/show_bug.cgi?id=415070
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
13
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
14
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
15 Building your app with EggSMClient
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
16 ----------------------------------
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
17
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
18 If you are using libgnomeui:
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
19
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
20 Link to libeggsmclient-gnome.la, #include
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
21 "eggsmclient-libgnomeui.h" in your main .c file (and
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
22 "eggsmclient.h" elsewhere).
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
23
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
24 If you are using plain gtk:
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
25
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
26 Link to libeggsmclient.la, and #include "eggsmclient.h".
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
27
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
28 If you are building on Windows:
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
29
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
30 You need to make sure to link your application as a Windows
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
31 GUI binary. (If using GNU tools, use "-mwindows".) If you
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
32 build it as a console binary, Windows won't send it the
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
33 WM_QUERYENDSESSION (quit_requested) and WM_ENDSESSION (quit)
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
34 messages.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
35
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
36 You need to call g_thread_null(NULL) to initialize threads.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
37
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
38
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
39 Using EggSMClient
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
40 -----------------
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
41
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
42 Initialization with libgnomeui and GnomeProgram:
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
43
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
44 Change the gnome_program_new() invocation to use
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
45 EGG_SM_CLIENT_LIBGNOMEUI_MODULE instead of LIBGNOMEUI_MODULE.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
46 If you haven't yet switched from popt to GOption for option
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
47 parsing, you have to do that now.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
48
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
49 You should also add an EGG_SM_CLIENT_PARAM_DESKTOP_FILE
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
50 parameter to the gnome_program_new() invocation, and pass it
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
51 the path to your application's installed .desktop file. (This
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
52 will be used for some SM-related purposes and will also be
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
53 used to initialize your application's localized name and
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
54 default window icon. If you are currently calling
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
55 g_set_application_name(), gtk_window_set_default_icon(), or
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
56 gtk_window_set_default_icon_name(), you can remove those
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
57 calls.)
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
58
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
59 If you only want to use the logout notification/cancellation
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
60 API, and don't want to participate in session saving, you can
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
61 pass the EGGSMCLIENT_PARAM_MODE parameter as well, with the
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
62 value EGG_SM_CLIENT_MODE_NO_RESTART.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
63
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
64 Initialization with plain gtk:
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
65
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
66 Add the GOptionGroup returned by
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
67 egg_sm_client_get_option_group() to your GOptionContext when
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
68 parsing command line arguments. (If you were previously just
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
69 using gtk_init() or the like, you will have to create your own
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
70 option context now and also add the group returned by
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
71 gtk_get_option_group() to it. See egg-session-end.c for an
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
72 example.)
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
73
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
74 You should also call egg_set_desktop_file() (in
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
75 "eggdesktopfile.h"), passing it the path to your application's
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
76 installed .desktop file. (This will be used for some
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
77 SM-related purposes and will also be used to initialize your
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
78 application's localized name and default window icon. If you
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
79 are currently calling g_set_application_name(),
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
80 gtk_window_set_default_icon(), or
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
81 gtk_window_set_default_icon_name(), you can remove those
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
82 calls.)
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
83
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
84 If you only want to use the logout notification/cancellation
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
85 API, and don't want to participate in session saving, you can
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
86 call egg_sm_client_set_mode(EGG_SM_CLIENT_MODE_NO_RESTART).
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
87
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
88 After parsing the command-line arguments, call
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
89 egg_sm_client_get() to get the EggSMClient object.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
90
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
91 Use egg_sm_client_is_resumed() on the EggSMClient to see if you need
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
92 to resume a saved state, and egg_sm_client_get_state_file() to find
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
93 that saved state.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
94
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
95 Connect to the client's "save_state" signal if you want to be able to
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
96 save your state and be resumed in future sessions. Connect to
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
97 "quit_requested" if you want to get a chance to save files before
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
98 shutdown (and/or cancel shutting down).
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
99
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
100 See the gtk-doc comments in eggsmclient.c for more details.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
101
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
102
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
103 Notes on porting from GnomeClient or raw libSM
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
104 ----------------------------------------------
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
105
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
106 There's no way to manually set most of the XSMP properties using
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
107 EggSMClient (and no need to). Program, ProcessID, and UserID are set
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
108 automatically. RestartCommand and CloneCommand are set from the
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
109 .desktop file (or from a call to egg_sm_client_set_restart_command),
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
110 and DiscardCommand is set automatically as needed after save_state is
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
111 emitted.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
112
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
113 RestartStyleHint is set automatically based on a few things:
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
114
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
115 - SmRestartNever if you set the mode to
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
116 EGG_SM_CLIENT_MODE_NO_RESTART
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
117
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
118 - SmRestartImmediately if you initialize with a desktop file
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
119 containing the entry "X-GNOME-AutoRestart=true"
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
120
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
121 - SmRestartIfRunning if you initialize with no desktop_file,
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
122 or with a desktop_file that doesn't set
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
123 "X-GNOME-AutoRestart=true". (This is the normal case.)
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
124
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
125 There's no way to set the restart style hint to SmRestartAnyway
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
126 ("restart the client in the resumed session even if it wasn't running
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
127 in the saved session"). FDO Autostart is a much better solution for
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
128 that class of program. If your program is configured to do autostart,
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
129 you don't need to also register for XSMP restart (unless you want to
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
130 have it save and resume its state as well).
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
131
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
132 CurrentDirectory and Environment are never set. GnomeClient sets
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
133 CurrentDirectory, but KDE doesn't restore either of those properties
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
134 when resuming a saved session, so it's better for apps to not depend
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
135 on them. (If the application must have its working directory restored,
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
136 it can just save and restore it itself.)
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
137
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
138 (There probably needs to be a way to set _GSM_Priority, for
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
139 compatibility with the current gnome-session; this will probably be
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
140 done via another .desktop key.)
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
141
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
142 The "save_yourself" signal/callback is split into two signals in
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
143 EggSMClient: save_state and quit_requested. Most GnomeClient-based
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
144 apps only implement the state-saving functionality currently, so they
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
145 would only connect to "save_state" in EggSMClient, not
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
146 "quit_requested".
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
147
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
148 When saving state, EggSMClient provides you with a GKeyFile to store
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
149 data in. If you write any data to the key file, EggSMClient will save
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
150 it to disk and set an XSMP DiscardCommand to make sure that the
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
151 session manager deletes it when it is no longer needed. If you can
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
152 record your entire state on the command line, you can use
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
153 egg_sm_client_set_restart_command() instead, to set the command that
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
154 will be used to restart the app.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
155
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
156 If you implement the "quit_requested" side of the functionality as
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
157 well, you don't need to "request interaction" like in
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
158 GnomeClient/libSM. You can just start interacting with the user right
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
159 away when the signal is emitted. Note that the argument to
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
160 egg_sm_client_will_quit() is TRUE if you're willing to quit, and FALSE
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
161 if not, which is the opposite of gnome_interaction_key_return() /
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
162 SmcInteractDone().
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
163
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
164 quit_requested is only for saving user files and preparing to quit. DO
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
165 NOT save the current state from the quit_requested signal. If the user
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
166 chooses the "save current session" option when logging out,
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
167 EggSMClient will emit quit_requested, let you deal with all of that,
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
168 and *then* after you're done, it will emit save_state to give you a
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
169 chance to deal with saving the state as well.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
170
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
171 There are a bunch of other bits of GnomeClient API with no analogs:
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
172
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
173 - GNOME_CLIENT_IS_CONNECTED - Is this really ever needed?
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
174
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
175 - gnome_client_request_phase_2 - This is only needed by window
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
176 managers... if someone really wanted it, it could be added
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
177 as an EggSMClientXSMP-specific call. (You'd just call it
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
178 once, at startup time, to register the fact that you were a
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
179 phase2 client, and then when EggSMClientXSMP got a
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
180 SaveYourself, it would automatically respond with a
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
181 SaveYourselfPhase2Request, and it wouldn't emit the
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
182 quit_requested/save_state signals until phase 2.)
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
183
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
184 - gnome_client_request_save - Shutdown saves are now done via
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
185 egg_sm_client_end_session. There is no way to request a
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
186 non-shutdown save, either for yourself, or for the whole
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
187 session. (Requesting a local SaveYourself for yourself won't
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
188 actually have any effect under most session managers, and
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
189 requesting it for the whole session is something that only a
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
190 program directly associated with the session manager ought
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
191 to do, so there doesn't seem to be a need for a public API
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
192 for this.)
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
193
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
194 - gnome_client_flush - In most cases this is a no-op. Where
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
195 it's not, EggSMClientXSMP should do it automatically
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
196 whenever you change anything. (FIXME!)
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
197
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
198 - gnome_client_get_id - Why would you need to know?
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
199
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
200
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
201 More notes
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
202 ----------
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
203
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
204 Assuming you provide a .desktop file to gnome_program_init() or
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
205 egg_set_desktop_file(), the state file that gets saved when you save
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
206 the application state will actually be a copy of that .desktop file,
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
207 with the state information appended to the end, and the Exec key
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
208 adjusted to include "--sm-client-state-file %k" (where "%k" means "the
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
209 path to this .desktop file"). So if you want to, you can move the
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
210 state file out of ~/.config/session-state/ and use it directly as a
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
211 launcher to restart the application with that saved state.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
212
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
213 Set EGG_SM_CLIENT_DEBUG=1 to debug
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
214
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
215 Example code:
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
216
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
217 - egg-session-end.c: A replacement for gnome-session-save.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
218 (Well, actually only for "gnome-session-save --kill".)
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
219 Yes, the --reboot and --shutdown arguments are only there to
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
220 tease you.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
221
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
222 - logout-test.c: Sits around waiting for you to try to log
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
223 out, and then asks "are you sure", to test
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
224 quit_requested/will_quit handling.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
225
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
226 - gedit.diff: A patch to SVN gedit to make it use EggSMClient
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
227 instead of GnomeClient.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
228
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
229 Non-functional backends:
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
230
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
231 - OS X: eggsmclient-osx.c is not quite a proof-of-concept.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
232 It's more of a handwave-of-concept. I don't have a working
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
233 OS X machine at the moment, so I can't test/finish this.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
234
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
235 See http://developer.apple.com/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/BootProcess.html#//apple_ref/doc/uid/20002130-114618
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
236 and other URLs linked from it for more info on the OS X
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
237 logout process.
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
238
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
239 - D-Bus: There are a few references in the code to a
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
240 non-existent D-Bus session management client. The idea is
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
241 that once we have a session manager that implements that,
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
242 EggSMClient will pick between the (sane) D-Bus and (nasty)
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
243 XSMP backends at runtime depending on what session manager
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
244 is running. Or in special environments, it could be compiled
c942eaef7bc6 Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
diff changeset
245 with just XSMP or just D-Bus.