1 | Panel session/configuration handling |
---|
2 | ==================================== |
---|
3 | |
---|
4 | (Please read the session-management docs in porting-docs before |
---|
5 | reading this) |
---|
6 | |
---|
7 | Panel global configuration |
---|
8 | -------------------------- |
---|
9 | All the panel configuration options that are not per panel are stored |
---|
10 | in GConf in the /apps/panel/global folder. There is a schema for it, |
---|
11 | and sysadms can override the defaults by changing the defaults in the |
---|
12 | default database. |
---|
13 | |
---|
14 | It 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 | |
---|
20 | etc. |
---|
21 | |
---|
22 | Panel Profiles |
---|
23 | -------------- |
---|
24 | |
---|
25 | All 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 |
---|
27 | profile everything seems to the user just like profiles don't exist. |
---|
28 | The profiles contain all the per-panel settings and the per-applet |
---|
29 | settings. |
---|
30 | |
---|
31 | Each profile stores it's configuration in GConf in a separate prefix, |
---|
32 | like this: |
---|
33 | /apps/panel/profile/Default/ |
---|
34 | /apps/panel/profile/Work/ |
---|
35 | /apps/panel/profile/Home/ |
---|
36 | /apps/panel/profile/Laptop/ |
---|
37 | |
---|
38 | When a new profile is created it's content is copied from a default |
---|
39 | profile choosen depending on the screen size. The defaults are stored |
---|
40 | in /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 | |
---|
46 | These are delivered in a serialized fashion in gnome-core, and the (to |
---|
47 | be written by hp) gconf deserialization app is used to install |
---|
48 | them at make install/package install time. Then the sysadmin can |
---|
49 | change these as he sees fit. I can imagine a "make current profile be |
---|
50 | default" 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 | |
---|
65 | Per-Session Data |
---|
66 | ---------------- |
---|
67 | |
---|
68 | NOTE: This section only applies to alex version aboce. In _vicious_ |
---|
69 | version, there would be no real per-session data, just the session name. |
---|
70 | |
---|
71 | The only per-session data saved by the panel is which profile it |
---|
72 | uses. In general per-session data should only be trivial things that |
---|
73 | the user won't be mad when(if?) he loses. According to hp's |
---|
74 | session-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 | |
---|
84 | It seems unnecessary to store the panel per session data in GConf, so |
---|
85 | we would just store the command line saved to the session manager as |
---|
86 | "--profile=Laptop" (replace laptop by name of active profile). This |
---|
87 | way we won't have problems cleaning up GConf either. |
---|
88 | |
---|
89 | Per-Panel configuration |
---|
90 | ----------------------- |
---|
91 | |
---|
92 | The 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 | |
---|
104 | This means that the panel profile configuration data is a list |
---|
105 | of panels with unique ids, that has per panel settings, and a list of |
---|
106 | applets with unique ids (applets may move between panels, and need to |
---|
107 | keep their prefs, so they are not in the panel subfolder). |
---|
108 | |
---|
109 | Each applet folder also have a "prefs" folder |
---|
110 | (e.g. /apps/panel/profile/Laptop/applets/43234/prefs/) which is used by the |
---|
111 | applet to store it's per instance data. |
---|
112 | |
---|
113 | Applet Prefs |
---|
114 | ------------ |
---|
115 | |
---|
116 | An applet has two sorts of preferences, per-instance and global. The |
---|
117 | per-instace perferences are options that may be different for each |
---|
118 | instance of the applet (such as number of rows in the pager), while |
---|
119 | the global preferences are preferences that are shared by all running |
---|
120 | applets of that type (and even non-running ones in different |
---|
121 | profiles). Examples of global preferences may be tooltip timeouts, or |
---|
122 | in deskguide the number of windows in a class before grouping starts. |
---|
123 | |
---|
124 | It is important that the preferences ui for the applet separates the |
---|
125 | global and the per-instance settings in some way, so users do not get |
---|
126 | totally confused about what is applied to all instances and what is not. |
---|
127 | |
---|
128 | Global applet preferences are managed entierly by the applet, and is |
---|
129 | normally stored in GConf in a key such as: |
---|
130 | |
---|
131 | /apps/applet/deskguide/grouping_limit |
---|
132 | |
---|
133 | Global settings have normal GConf behaviour, and the applet should |
---|
134 | install a schema for them. |
---|
135 | |
---|
136 | Per-instance preferences are private to the applet. You should write |
---|
137 | schemas for them for good measure, but currently GConf doesn't handle |
---|
138 | dynamic keys well, so they will not be installed. In the future this |
---|
139 | will be fixed though. The keys are private anyway, so not having |
---|
140 | schemas does not matter that much, since other apps should not modify |
---|
141 | them (and can't find them since they are dynamic and prefixed with |
---|
142 | strange id's). |
---|
143 | |
---|
144 | When the panel instantiates an applet (first time or not) it will give |
---|
145 | the applet a GConf prefix (see above) for it to read and write it's |
---|
146 | per-instance configuration from. Since there is no way currently to |
---|
147 | have schemas for these dynamic prefixes there won't be any default |
---|
148 | values for the applet settings. Thus we have to hardcode the settings |
---|
149 | in the applet. |
---|
150 | |
---|
151 | So the way to read prefs changes slightly. You have to try reading, |
---|
152 | and if there is no data in gconf, use the default value. The way to |
---|
153 | use this is to call gconf_client_get(), which return NULL if the value |
---|
154 | is unset and has no default (this means it will automagically work |
---|
155 | whenever we implement dynamic prefix schemas). |
---|
156 | |
---|
157 | We should probably wrap the gconf calls in some utility functions like |
---|
158 | this: |
---|
159 | |
---|
160 | gint |
---|
161 | applet_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 | |
---|
196 | And 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 | |
---|
202 | It is important that we have actual defines for the defaults, so as to |
---|
203 | not repeat the problems we had previously, with different defaults in |
---|
204 | different places. |
---|
205 | |
---|
206 | Session Manager interaction |
---|
207 | --------------------------- |
---|
208 | |
---|
209 | [NOTE: Only applies to alex version, _vicious_ one doesn't even need this ] |
---|
210 | |
---|
211 | The panels responds to the SaveYourself request, but does not need to |
---|
212 | propagate this request to the applets, since the applet settings are |
---|
213 | stored per-instance-in-a-profile, and not in a session. This makes |
---|
214 | things robust (won't lose applet setup), and easier to understand for |
---|
215 | the user. |
---|
216 | |
---|
217 | The only thing the panel needs to do on SaveSetup is to pass the |
---|
218 | command line containing the active profile "--profile=Laptop" to the |
---|
219 | session manager. There are no GConf cleanup needed, or no session id |
---|
220 | thrown about at all. |
---|
221 | |
---|
222 | |
---|
223 | Full 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/ |
---|