source: trunk/third/gnome-panel/doc/panel-session-handling.txt @ 18349

Revision 18349, 9.1 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18348, which included commits to RCS files with non-trunk default branches.
Line 
1Panel session/configuration handling
2====================================
3
4(Please read the session-management docs in porting-docs before
5reading this)
6
7Panel global configuration
8--------------------------
9All the panel configuration options that are not per panel are stored
10in GConf in the /apps/panel/global folder. There is a schema for it,
11and sysadms can override the defaults by changing the defaults in the
12default database.
13
14It will look like this
15
16 /apps/panel/global/run_dialog_key
17 /apps/panel/global/auto_hide_speed
18 /apps/panel/global/auto_hide_delay
19 
20etc.
21 
22Panel Profiles
23--------------
24
25All the per-panel setup is stored in named profiles. Initially the
26"Default" profile is created for you, and if you never create a new
27profile everything seems to the user just like profiles don't exist.
28The profiles contain all the per-panel settings and the per-applet
29settings.
30
31Each profile stores it's configuration in GConf in a separate prefix,
32like this:
33 /apps/panel/profile/Default/
34 /apps/panel/profile/Work/
35 /apps/panel/profile/Home/
36 /apps/panel/profile/Laptop/
37
38When a new profile is created it's content is copied from a default
39profile choosen depending on the screen size. The defaults are stored
40in /apps/panel/default-profiles, like this:
41
42 /apps/panel/default-profiles/small/
43 /apps/panel/default-profiles/medium/
44 /apps/panel/default-profiles/large/
45
46These are delivered in a serialized fashion in gnome-core, and the (to
47be written by hp) gconf deserialization app is used to install
48them at make install/package install time. Then the sysadmin can
49change these as he sees fit. I can imagine a "make current profile be
50default" button somewhere.
51
52[ This is a area where opinions differ.
53
54 alex:
55     The active profile can typically be changed by the user any time
56     using a popdown menu or suchlike. (Just imagine selecting a new
57     profile and all the panels will go swooosh and pop up in their
58     new places with different applets and stuff.)
59
60 _vicious_:
61     The name of the active profile is always the same as the current
62     gsm named session.
63]
64
65Per-Session Data
66----------------
67
68NOTE: This section only applies to alex version aboce. In _vicious_
69version, there would be no real per-session data, just the session name.
70
71The only per-session data saved by the panel is which profile it
72uses. In general per-session data should only be trivial things that
73the user won't be mad when(if?) he loses. According to hp's
74session-management docs in the porting-docs:
75
76       This can all be kind of a pain, so apps are encouraged to
77       save all their state as part of the command they pass to the
78       session manager, and avoid saving persistent files.  That is, it's
79       easier and more robust to have a command line option
80       --with-window-count=3 than it is to store the window count in GConf under
81       /apps/terminal/sessions/4543-3252345-6745/window_count
82       and provide a discard command to clear that key.
83
84It seems unnecessary to store the panel per session data in GConf, so
85we would just store the command line saved to the session manager as
86"--profile=Laptop" (replace laptop by name of active profile). This
87way we won't have problems cleaning up GConf either.
88
89Per-Panel configuration
90-----------------------
91
92The panel profile data would looks something like this:
93
94 /apps/panel/profile/Laptop/panels/12345/panel_type
95                                        /some_per-panel_setting
96                                        /which_applet_ids_are_in_this_panel 
97                                  /33214/ ...
98 /apps/panel/profile/Laptop/applets/43234/applet_type (oaf id?)
99                                         /some_applet_setting
100                                         /prefs/   <- This is where the applet itself
101                                                     stores it's per-instance prefs.
102                                   /56378/ ...
103                                                                   
104This means that the panel profile configuration data is a list
105of panels with unique ids, that has per panel settings, and a list of
106applets with unique ids (applets may move between panels, and need to
107keep their prefs, so they are not in the panel subfolder).
108
109Each applet folder also have a "prefs" folder
110(e.g. /apps/panel/profile/Laptop/applets/43234/prefs/) which is used by the
111applet to store it's per instance data.
112
113Applet Prefs
114------------
115
116An applet has two sorts of preferences, per-instance and global. The
117per-instace perferences are options that may be different for each
118instance of the applet (such as number of rows in the pager), while
119the global preferences are preferences that are shared by all running
120applets of that type (and even non-running ones in different
121profiles). Examples of global preferences may be tooltip timeouts, or
122in deskguide the number of windows in a class before grouping starts.
123
124It is important that the preferences ui for the applet separates the
125global and the per-instance settings in some way, so users do not get
126totally confused about what is applied to all instances and what is not.
127
128Global applet preferences are managed entierly by the applet, and is
129normally stored in GConf in a key such as:
130
131 /apps/applet/deskguide/grouping_limit
132
133Global settings have normal GConf behaviour, and the applet should
134install a schema for them.
135
136Per-instance preferences are private to the applet. You should write
137schemas for them for good measure, but currently GConf doesn't handle
138dynamic keys well, so they will not be installed. In the future this
139will be fixed though. The keys are private anyway, so not having
140schemas does not matter that much, since other apps should not modify
141them (and can't find them since they are dynamic and prefixed with
142strange id's).
143
144When the panel instantiates an applet (first time or not) it will give
145the applet a GConf prefix (see above) for it to read and write it's
146per-instance configuration from. Since there is no way currently to
147have schemas for these dynamic prefixes there won't be any default
148values for the applet settings. Thus we have to hardcode the settings
149in the applet.
150
151So the way to read prefs changes slightly. You have to try reading,
152and if there is no data in gconf, use the default value. The way to
153use this is to call gconf_client_get(), which return NULL if the value
154is unset and has no default (this means it will automagically work
155whenever we implement dynamic prefix schemas).
156
157We should probably wrap the gconf calls in some utility functions like
158this:
159
160gint
161applet_gconf_get_int_with_default (SomeAppletType *applet,
162                                   const gchar* key,
163                                   gint default,
164                                   GError** err)
165{
166  GError* error = NULL;
167  GConfValue* val;
168  GConfClient *client = panel_gconf_get_client ();
169  gchar *full_key;
170
171  g_return_val_if_fail(err == NULL || *err == NULL, 0);
172
173  full_key = applet_get_full_key (applet, key);
174  val = get(client, full_key, TRUE, NULL, NULL, &error);
175  g_free (full_key);
176
177  if (val != NULL)
178    {
179      gint retval = def;
180
181      g_assert(error == NULL);
182     
183      if (check_type(key, val, GCONF_VALUE_INT, &error))
184        retval = gconf_value_get_int(val);
185      else
186        handle_error(client, error, err);
187
188      gconf_value_free(val);
189
190      return retval;
191    }
192  else
193    return default;
194}
195
196And the applet would use this like this
197
198#define TOOLTIP_TIMEOUT_DEFAULT 100 /* msec */
199
200 timeout = applet_gconf_get_int_with_default ("tooltip_timeout", TOOLTIP_TIMEOUT_DEFAULT, NULL);
201
202It is important that we have actual defines for the defaults, so as to
203not repeat the problems we had previously, with different defaults in
204different places.
205
206Session Manager interaction
207---------------------------
208
209[NOTE: Only applies to alex version, _vicious_ one doesn't even need this ]
210
211The panels responds to the SaveYourself request, but does not need to
212propagate this request to the applets, since the applet settings are
213stored per-instance-in-a-profile, and not in a session. This makes
214things robust (won't lose applet setup), and easier to understand for
215the user.
216
217The only thing the panel needs to do on SaveSetup is to pass the
218command line containing the active profile "--profile=Laptop" to the
219session manager. There are no GConf cleanup needed, or no session id
220thrown about at all.
221
222
223Full example GConf tree
224-----------------------
225/apps/applet/deskguide/grouping_limit
226                       ...
227/apps/applet/clock/format
228                   ...
229/apps/panel/global/run_dialog_key
230/apps/panel/global/auto_hide_speed
231/apps/panel/global/auto_hide_delay
232                   ...
233/apps/panel/profile/Default/panels/12345/type
234                                         ...
235/apps/panel/profile/Default/panels/54543/type
236                                         ...
237/apps/panel/profile/Default/applets/62568/oaf_iid
238/apps/panel/profile/Default/applets/62568/prefs/ ...
239                                          ...
240/apps/panel/profile/Default/applets/43355/oaf_iid
241/apps/panel/profile/Default/applets/43355/prefs/ ...
242                                          ...
243/apps/panel/profile/Coding/ ...
244/apps/panel/profile/Gaming/ ..
245/apps/panel/default-profiles/small/ (panels and applets)
246/apps/panel/default-profiles/medium/ (panels and applets)
247/apps/panel/default-profiles/large/ (panels and applets)
248/schemas/apps/applet/deskguide/
249/schemas/apps/applet/clock/
250/schemas/apps/panel/global/
Note: See TracBrowser for help on using the repository browser.