1 | #!/usr/athena/bin/perl -w |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | # Convert GNOME 1 panel settings and applets → GNOME 2 GConf keys |
---|
4 | # Copyright © 2002 Colin Walters <walters@verbum.org> |
---|
5 | # $Id: gnome-panel-1-to-2,v 1.4 2003-07-17 20:57:48 ghudson Exp $ |
---|
6 | |
---|
7 | # This program is free software; you can redistribute it and/or modify |
---|
8 | # it under the terms of the GNU General Public License as published by |
---|
9 | # the Free Software Foundation; either version 2 of the License, or |
---|
10 | # (at your option) any later version. |
---|
11 | |
---|
12 | # This program is distributed in the hope that it will be useful, |
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | # GNU General Public License for more details. |
---|
16 | |
---|
17 | # You should have received a copy of the GNU General Public License |
---|
18 | # along with this program; if not, write to the Free Software |
---|
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
20 | |
---|
21 | ###### #### ### ## # # # |
---|
22 | # NOTE: This script should be run in the user's home directory. |
---|
23 | ###### #### ### ## # # # |
---|
24 | |
---|
25 | use POSIX; |
---|
26 | |
---|
27 | my $cwd = POSIX::getcwd(); |
---|
28 | |
---|
29 | my $no_act = 0; |
---|
30 | foreach my $arg (@ARGV) { |
---|
31 | if ($arg eq '-n') { |
---|
32 | $no_act = 1; |
---|
33 | } |
---|
34 | } |
---|
35 | |
---|
36 | sub log { |
---|
37 | print "gnome-panel-1-to-2: " . join(' ', @_) . "\n"; |
---|
38 | } |
---|
39 | |
---|
40 | my $panelconfigfile = ".gnome/panel.d/default/panel"; |
---|
41 | my $appletconfigfile = ".gnome/panel.d/default/Applet_Config"; |
---|
42 | |
---|
43 | open(F, $panelconfigfile) or die "Couldn't open $panelconfigfile\n: $!"; |
---|
44 | my ($panel_count, $applet_count) = (0,0); |
---|
45 | while (<F>) { |
---|
46 | /panel_count=(.+)$/ and $panel_count = $1; |
---|
47 | /applet_count=(.+)$/ and $applet_count = $1; |
---|
48 | } |
---|
49 | close(F); |
---|
50 | &log("panel_count: $panel_count"); |
---|
51 | &log("applet_count: $applet_count\n"); |
---|
52 | |
---|
53 | # From gnome-panel-2.0.10/gnome-panel/panel.c, line 101 |
---|
54 | my %panel_type_map = (0 => "edge-panel", |
---|
55 | 1 => "drawer-panel", |
---|
56 | 2 => "aligned-panel", |
---|
57 | 3 => "sliding-panel", |
---|
58 | 4 => "floating-panel", |
---|
59 | 5 => "menu-panel"); |
---|
60 | |
---|
61 | # From gnome-core-1.4.0.6/panel/session.c, line 1357 |
---|
62 | my %old_panel_size_map = (0 => "panel-size-xx-small", |
---|
63 | 1 => "panel-size-medium", |
---|
64 | 2 => "panel-size-large", |
---|
65 | 3 => "panel-size-x-large"); |
---|
66 | |
---|
67 | my %panel_align_map = (0 => "panel-alignment-left", |
---|
68 | 2 => "panel-alignment-right"); |
---|
69 | |
---|
70 | my %panel_anchor_map = (0 => "panel-anchor-left", |
---|
71 | 1 => "panel-anchor-right"); |
---|
72 | |
---|
73 | # From gnome-core-1.4.0.6/panel/panel-types.h, line 15 |
---|
74 | my @panel_size_associations = ([12, "panel-size-xx-small"], [24, "panel-size-x-small"], |
---|
75 | [36, "panel-size-small"], [48, "panel-size-medium"], |
---|
76 | [64, "panel-size-large"], , [80, "panel-size-x-large"], |
---|
77 | [128, "panel-size-xx-large"]); |
---|
78 | |
---|
79 | # From gnome-core-1.4.0.6/panel/panel-types.h, line 52 |
---|
80 | my %old_panel_edge_map = (0 => "panel-edge-top", |
---|
81 | 1 => "panel-edge-right", |
---|
82 | 2 => "panel-edge-bottom", |
---|
83 | 3 => "panel-edge-left"); |
---|
84 | |
---|
85 | sub sprintf_objid { |
---|
86 | my $id = shift; |
---|
87 | return sprintf("%08d", $id); |
---|
88 | } |
---|
89 | |
---|
90 | sub system_internal { |
---|
91 | my @cmd = @_; |
---|
92 | if (not $no_act) { |
---|
93 | system(@cmd) == 0 or die "Command \"" . join(' ', @cmd) . "\" exited with an error: $?"; |
---|
94 | } |
---|
95 | } |
---|
96 | |
---|
97 | sub mysystem { |
---|
98 | my @cmd = @_; |
---|
99 | &log("running: " . join(' ', @_)); |
---|
100 | system_internal(@_); |
---|
101 | } |
---|
102 | |
---|
103 | sub gconftool { |
---|
104 | my ($path, $type, $value) = @_; |
---|
105 | my @cmd = ("gconftool-2", "-s", "$path", "-t", "$type", "--", "$value"); |
---|
106 | mysystem(@cmd); |
---|
107 | } |
---|
108 | |
---|
109 | sub gconftool_list { |
---|
110 | my ($path, $subtype, $value) = @_; |
---|
111 | my @cmd = ("gconftool-2", "-s", "$path", "--type=list", "--list-type=$subtype", "--", "$value"); |
---|
112 | mysystem(@cmd); |
---|
113 | } |
---|
114 | |
---|
115 | # Create the panels |
---|
116 | open(F, $panelconfigfile) or die "Couldn't open $panelconfigfile\n: $!"; |
---|
117 | my $line; |
---|
118 | @panel_id_list = (); |
---|
119 | $panel_id_count = 1; |
---|
120 | %panel_unique_id_map = (); |
---|
121 | while ($line = <F>) { |
---|
122 | if ($line =~ /\[Panel_(\d+)\]/) { |
---|
123 | my $current_panelid = $1; |
---|
124 | &log("reading panel entry $current_panelid"); |
---|
125 | # skip unused panels |
---|
126 | if ($current_panelid > $panel_count) { |
---|
127 | &log("skipping panel id $current_panelid (> $panel_count)"); |
---|
128 | next; |
---|
129 | } |
---|
130 | push @panel_id_list, sprintf_objid($panel_id_count); |
---|
131 | my $scount = sprintf_objid($panel_id_count); |
---|
132 | # set up some sane defaults |
---|
133 | gconftool("/apps/panel/profiles/default/panels/$scount/panel_background_pixmap_stretch", "boolean", "false"); |
---|
134 | gconftool("/apps/panel/profiles/default/panels/$scount/panel_background_pixmap_fit", "boolean", "true"); |
---|
135 | gconftool("/apps/panel/profiles/default/panels/$scount/panel_background_pixmap_rotate", "boolean", "true"); |
---|
136 | gconftool("/apps/panel/profiles/default/panels/$scount/hide_buttons_enabled", "boolean", "false"); |
---|
137 | gconftool("/apps/panel/profiles/default/panels/$scount/panel_background_type", "string", "no-background"); |
---|
138 | gconftool("/apps/panel/profiles/default/panels/$scount/panel_background_color", "string", "#000000"); |
---|
139 | gconftool("/apps/panel/profiles/default/panels/$scount/panel_background_pixmap", "string", ""); |
---|
140 | gconftool("/apps/panel/profiles/default/panels/$scount/panel_type", "string", "edge-panel"); |
---|
141 | while (defined(($line = <F>)) and $line =~ /^\w+/) { |
---|
142 | if ($line =~ /^hidebuttons_enabled=(.+)$/) { |
---|
143 | gconftool("/apps/panel/profiles/default/panels/$scount/hide_buttons_enabled", "boolean", $1); |
---|
144 | } elsif ($line =~ /^screen=(.+)$/) { |
---|
145 | gconftool("/apps/panel/profiles/default/panels/$scount/screen_id", "int", $1); |
---|
146 | } elsif ($line =~ /^type=(.+)$/) { |
---|
147 | my $mappedtype = $panel_type_map{$1}; |
---|
148 | if ($mappedtype =~ /edge-panel/) { |
---|
149 | gconftool("/apps/panel/profiles/default/panels/$scount/panel_hide_mode", "int", "0"); |
---|
150 | gconftool("/apps/panel/profiles/default/panels/$scount/panel_hide_state", "int", "0"); |
---|
151 | } |
---|
152 | gconftool("/apps/panel/profiles/default/panels/$scount/panel_type", "string", $mappedtype); |
---|
153 | } elsif ($line =~ /^edge=(.+)$/) { |
---|
154 | gconftool("/apps/panel/profiles/default/panels/$scount/screen_edge", "string", $old_panel_edge_map{$1}) |
---|
155 | } elsif ($line =~ /^align=(.+)$/) { |
---|
156 | my $align = $1; |
---|
157 | if (not $panel_align_map{$align}) { |
---|
158 | &log("Unknown panel alignment $align") |
---|
159 | } |
---|
160 | gconftool("/apps/panel/profiles/default/panels/$scount/panel_align", "string", $panel_align_map{$align} || "panel-alignment-left") |
---|
161 | } elsif ($line =~ /^anchor=(.+)$/) { |
---|
162 | my $anchor = $1; |
---|
163 | if (not $panel_anchor_map{$anchor}) { |
---|
164 | &log("Unknown panel anchor $anchor") |
---|
165 | } |
---|
166 | gconftool("/apps/panel/profiles/default/panels/$scount/panel_anchor", "string", $panel_anchor_map{$anchor} || "panel-anchor-left") |
---|
167 | } elsif ($line =~ /^unique_id=(.+)$/) { |
---|
168 | my $uniqueid = $1; |
---|
169 | &log("making entry in unique id map: $uniqueid => $panel_id_count"); |
---|
170 | # Store this unique ID; it's used later when figuring out |
---|
171 | # which applets go to which panel. |
---|
172 | $panel_unique_id_map{$uniqueid} = $panel_id_count; |
---|
173 | } elsif ($line =~ /^sz=(.+)$/) { |
---|
174 | my $size = $1; |
---|
175 | my $found = 0; |
---|
176 | foreach my $entry (@panel_size_associations) { |
---|
177 | if ((not $found) and $size <= $entry->[0]) { |
---|
178 | gconftool("/apps/panel/profiles/default/panels/$scount/panel_size", "string", $entry->[1]); |
---|
179 | $found = 1; |
---|
180 | } |
---|
181 | } |
---|
182 | if (not $found) { |
---|
183 | gconftool("/apps/panel/profiles/default/panels/$scount/panel_size", "string", "panel-size-medium"); |
---|
184 | } |
---|
185 | } |
---|
186 | } |
---|
187 | $panel_id_count++; |
---|
188 | } |
---|
189 | } |
---|
190 | if (scalar @panel_id_list == 0) { |
---|
191 | die "No GNOME 1 panels found, giving up."; |
---|
192 | } |
---|
193 | my $liststr = "[" . join(',', @panel_id_list) . "]"; |
---|
194 | gconftool_list("/apps/panel/profiles/default/general/panel_id_list", "string", $liststr); |
---|
195 | |
---|
196 | &log("finished reading panel config file"); |
---|
197 | close(F); |
---|
198 | |
---|
199 | &log("converting .desktop files"); |
---|
200 | my $gnome1dir = ".gnome/panel.d/default/launchers/"; |
---|
201 | my $gnome2dir = ".gnome2/panel2.d/default/launchers/"; |
---|
202 | if (-d $gnome1dir) { |
---|
203 | &mysystem("mkdir", "-p", $gnome2dir); |
---|
204 | opendir (DIR, $gnome1dir) or die "Couldn't open $gnome1dir: $!"; |
---|
205 | foreach my $entry (readdir(DIR)) { |
---|
206 | if (not $entry =~ /^\.\.?$/) { |
---|
207 | &mysystem("cp", "-p", $gnome1dir . $entry, $gnome2dir); |
---|
208 | } |
---|
209 | } |
---|
210 | closedir(DIR); |
---|
211 | } |
---|
212 | |
---|
213 | # Create the applets and launchers. |
---|
214 | open(F, $appletconfigfile) or die "Couldn't open $appletconfigfile\n: $!"; |
---|
215 | &log("Reading applet config file"); |
---|
216 | |
---|
217 | my @applet_id_list = (); |
---|
218 | my $applet_id_count = 1; |
---|
219 | my @object_id_list = (); |
---|
220 | my $object_id_count = 1; |
---|
221 | LINE: while (defined ($line = <F>)) { |
---|
222 | if ($line =~ /\[Applet_(\d+)\]/) { |
---|
223 | my $appletnumber = $1; |
---|
224 | &log("Reading applet/object id $appletnumber"); |
---|
225 | my $appletexternfile = ".gnome/panel.d/default/Applet_" . "$appletnumber" . "_Extern"; |
---|
226 | my @lines; |
---|
227 | while (defined(($line = <F>)) and $line =~ /^\w+/) { |
---|
228 | push(@lines, $line); |
---|
229 | } |
---|
230 | my ($appletid, $count, $scount, $type) = (undef, undef, undef, undef); |
---|
231 | foreach my $line (@lines) { |
---|
232 | if ($line =~ /^id=(.+)$/) { |
---|
233 | $appletid = $1; |
---|
234 | if ($appletid =~ /Extern/) { |
---|
235 | $count = $applet_id_count; |
---|
236 | $scount = sprintf_objid($count); |
---|
237 | gconftool("/apps/panel/profiles/default/applets/$scount/object_type", "string", "bonobo-applet"); |
---|
238 | push @applet_id_list, sprintf_objid($applet_id_count); |
---|
239 | $applet_id_count++; |
---|
240 | $type = 'applets'; |
---|
241 | } elsif ($appletid =~ /Launcher/) { |
---|
242 | $count = $object_id_count; |
---|
243 | $scount = sprintf_objid($count); |
---|
244 | gconftool("/apps/panel/profiles/default/objects/$scount/panel_right_stick", "boolean", "false"); |
---|
245 | gconftool("/apps/panel/profiles/default/objects/$scount/object_type", "string", "launcher-object"); |
---|
246 | push @object_id_list, sprintf_objid($object_id_count); |
---|
247 | $count = $object_id_count; |
---|
248 | $object_id_count++; |
---|
249 | $type = 'objects'; |
---|
250 | } elsif ($appletid =~ /Menu/) { |
---|
251 | $count = $object_id_count; |
---|
252 | $scount = sprintf_objid($count); |
---|
253 | # Athena local mod: in GNOME 1, we hacked the default menu |
---|
254 | # path; in GNOME 2, we use a schemas file to set a path and |
---|
255 | # custom icon and to turn off the main-menu flags. We have |
---|
256 | # to do the same in translation. |
---|
257 | gconftool("/apps/panel/profiles/default/objects/$scount/path", "string", "file:///var/athena/menus"); |
---|
258 | gconftool("/apps/panel/profiles/default/objects/$scount/global-main", "boolean", "false"); |
---|
259 | gconftool("/apps/panel/profiles/default/objects/$scount/main-menu", "boolean", "false"); |
---|
260 | gconftool("/apps/panel/profiles/default/objects/$scount/object_type", "string", "menu-object"); |
---|
261 | gconftool("/apps/panel/profiles/default/objects/$scount/custom-icon", "boolean", "true"); |
---|
262 | gconftool("/apps/panel/profiles/default/objects/$scount/custom-icon-file", "string", "/usr/athena/share/gnome/athena/menu-icon"); |
---|
263 | push @object_id_list, sprintf_objid($object_id_count); |
---|
264 | $count = $object_id_count; |
---|
265 | $object_id_count++; |
---|
266 | $type = 'objects'; |
---|
267 | } elsif ($appletid =~ /Logout/) { |
---|
268 | # Athena local mod: understand the logout button. Treat it |
---|
269 | # in a very Athena-specific way; in our environment, the |
---|
270 | # logout button needs to be a launcher which runs |
---|
271 | # gathlogout, because we don't run a session manager. |
---|
272 | $count = $object_id_count; |
---|
273 | $scount = sprintf_objid($count); |
---|
274 | gconftool("/apps/panel/profiles/default/objects/$scount/panel_right_stick", "boolean", "false"); |
---|
275 | gconftool("/apps/panel/profiles/default/objects/$scount/object_type", "string", "launcher-object"); |
---|
276 | gconftool("/apps/panel/profiles/default/objects/$scount/launcher_location", "string", "file:///usr/athena/share/gnome/athena/logout.desktop"); |
---|
277 | push @object_id_list, sprintf_objid($object_id_count); |
---|
278 | $count = $object_id_count; |
---|
279 | $object_id_count++; |
---|
280 | $type = 'objects'; |
---|
281 | } else { |
---|
282 | &log("warning: unknown Applet id=$appletid"); |
---|
283 | $appletid = undef; |
---|
284 | } |
---|
285 | } |
---|
286 | } |
---|
287 | if (not $appletid) { |
---|
288 | &log("Skipping this applet: unknown appletid"); |
---|
289 | next LINE; |
---|
290 | } |
---|
291 | # Handle applets specially |
---|
292 | if ($appletid =~ /Extern/) { |
---|
293 | my $valid_goadid = 1; |
---|
294 | my $goadid = "!unspecified!"; |
---|
295 | foreach my $line (@lines) { |
---|
296 | if ($line =~ /goad_id=(.+)$/) { |
---|
297 | $goadid = $1; |
---|
298 | if ($goadid =~ /clock/i) { |
---|
299 | gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_ClockApplet"); |
---|
300 | # FIXME: set up sane defaults for now; we shoudl really pick these from the old prefs |
---|
301 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/show_seconds", "boolean", "true"); |
---|
302 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/show_tooltip", "boolean", "true"); |
---|
303 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/gmt_time", "boolean", "false"); |
---|
304 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/unix_time", "boolean", "false"); |
---|
305 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/hour_format", "int", "24"); |
---|
306 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/internet_time", "boolean", "false"); |
---|
307 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/show_date", "boolean", "true"); |
---|
308 | } elsif ($goadid =~ /deskguide/i) { |
---|
309 | gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_PagerApplet"); |
---|
310 | # FIXME: set up sane defaults for now; we shoudl really pick these from the old prefs |
---|
311 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/num_rows", "int", "1"); |
---|
312 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/display_all_workspaces", "boolean", "true"); |
---|
313 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/display_workspace_names", "boolean", "false"); |
---|
314 | } elsif ($goadid =~ /mixer/i) { |
---|
315 | gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_MixerApplet"); |
---|
316 | } elsif ($goadid =~ /geyes/i) { |
---|
317 | gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_GeyesApplet"); |
---|
318 | # Theme stuff doesn't appear to be compatible; just ignore... |
---|
319 | } elsif ($goadid =~ /tasklist/i) { |
---|
320 | gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_TasklistApplet"); |
---|
321 | my $group_windows = "auto"; |
---|
322 | my $display_all_workspaces = "false"; |
---|
323 | my $move_unminimized_windows = "true"; |
---|
324 | if (-f $appletexternfile) { |
---|
325 | open(EXTFILE, $appletexternfile) or die "Couldn't open $appletexternfile\n: $!"; |
---|
326 | while (<EXTFILE>) { |
---|
327 | if (/^enable_grouping=(.+)$/) { |
---|
328 | my $grouping =$1; |
---|
329 | if ($grouping =~ /false/) { |
---|
330 | $group_windows = "never"; |
---|
331 | } |
---|
332 | } elsif (/^all_desks_normal=(.+)$/) { |
---|
333 | $display_all_workspaces = $1; |
---|
334 | } elsif (/^move_to_current=(.+)$/) { |
---|
335 | $move_unminimized_windows = $1; |
---|
336 | } |
---|
337 | } |
---|
338 | close(EXTFILE); |
---|
339 | } |
---|
340 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/group_windows", "string", $group_windows); |
---|
341 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/display_all_workspaces", "boolean", $display_all_workspaces); |
---|
342 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/move_unminimized_windows", "boolean", $move_unminimized_windows); |
---|
343 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/maximum_size", "int", "4096"); |
---|
344 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/minimum_size", "int", "50"); |
---|
345 | } elsif ($goadid =~ /battery_applet/i) { |
---|
346 | gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_BattstatApplet"); |
---|
347 | my $full_notify_enable = "false"; |
---|
348 | my $lowwarn_enable = "true"; |
---|
349 | my $low_charge_val = 25; |
---|
350 | my $low_warn_val = 5; |
---|
351 | if (-f $appletexternfile) { |
---|
352 | open(EXTFILE, $appletexternfile) or die "Couldn't open $appletexternfile\n: $!"; |
---|
353 | while (<EXTFILE>) { |
---|
354 | if (/^low_charge_val=(.+)$/) { |
---|
355 | $low_charge_val = $1; |
---|
356 | } elsif (/^low_warn_val=(.+)$/) { |
---|
357 | $low_warn_val = $1; |
---|
358 | } elsif (/^full_notify_enable=(.+)$/) { |
---|
359 | $full_notify_enable = $1; |
---|
360 | } elsif (/^low_warn_enable=(.+)$/) { |
---|
361 | $low_warn_enable = $1; |
---|
362 | } |
---|
363 | } |
---|
364 | close(EXTFILE); |
---|
365 | } |
---|
366 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/full_battery_notification", "boolean", $full_notify_enable); |
---|
367 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/show_percent", "boolean", "false"); |
---|
368 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/beep", "boolean", "false"); |
---|
369 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/suspend_command", "string", ""); |
---|
370 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/use_dock", "boolean", "false"); |
---|
371 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/red_value", "int", $low_warn_val); |
---|
372 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/yellow_value", "int", "40"); |
---|
373 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/orange_value", "int", $low_charge_val); |
---|
374 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/show_battery", "boolean", "true"); |
---|
375 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/horizontal", "boolean", "true"); |
---|
376 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/show_status", "boolean", "true"); |
---|
377 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/low_battery_notification", "boolean", $low_warn_enable); |
---|
378 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/drain_from_top", "boolean", "false"); |
---|
379 | } elsif ($goadid =~ /fish_applet/i) { |
---|
380 | gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_FishApplet"); |
---|
381 | my $fishname = "Wanda"; |
---|
382 | my $image = "fish/fishanim.png"; |
---|
383 | my $fishcommand = "fortune"; |
---|
384 | my $frames = 3; |
---|
385 | my $speed = 1; |
---|
386 | my $rotate = "true"; |
---|
387 | if (-f $appletexternfile) { |
---|
388 | open(EXTFILE, $appletexternfile) or die "Couldn't open $appletexternfile\n: $!"; |
---|
389 | while (<EXTFILE>) { |
---|
390 | if (/^name=(.+)$/) { |
---|
391 | $fishname = $1; |
---|
392 | } elsif (/^image=(.+)$/) { |
---|
393 | # Get rid of any path prefix. |
---|
394 | s,^/usr/share/pixmaps/,,; |
---|
395 | $image = $1; |
---|
396 | } elsif (/^command=(.+)$/) { |
---|
397 | $fishcommand = $1; |
---|
398 | } elsif (/^frames=(.+)$/) { |
---|
399 | $frames = $1; |
---|
400 | } elsif (/^speed=(.+)$/) { |
---|
401 | $speed = $1; |
---|
402 | } elsif (/^rotate=(.+)$/) { |
---|
403 | $rotate = $1; |
---|
404 | } |
---|
405 | } |
---|
406 | close(EXTFILE); |
---|
407 | } |
---|
408 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/command", "string", $fishcommand); |
---|
409 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/image", "string", $image); |
---|
410 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/frames", "int", $frames); |
---|
411 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/speed", "int", $speed); |
---|
412 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/name", "string", $fishname); |
---|
413 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/rotate", "boolean", $rotate); |
---|
414 | } elsif ($goadid =~ /multiload_(.+?)_applet/i) { |
---|
415 | my $multiload_type = $1; |
---|
416 | gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_MultiLoadApplet"); |
---|
417 | my $speed = "500"; |
---|
418 | my $size = "40"; |
---|
419 | # FIXME: we make no attempt at preserving colors. It seems tricky at first glance. |
---|
420 | if (-f $appletexternfile) { |
---|
421 | open(EXTFILE, $appletexternfile) or die "Couldn't open $appletexternfile\n: $!"; |
---|
422 | while (<EXTFILE>) { |
---|
423 | if (/^speed=(.+)$/) { |
---|
424 | $speed = $1; |
---|
425 | } elsif (/^size=(.+)$/) { |
---|
426 | $size = $1; |
---|
427 | } |
---|
428 | } |
---|
429 | close(EXTFILE); |
---|
430 | } |
---|
431 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/view_loadavg", "boolean", "false"); |
---|
432 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/view_memload", "boolean", "false"); |
---|
433 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/view_netload", "boolean", "false"); |
---|
434 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/view_cpuload", "boolean", "false"); |
---|
435 | if ($multiload_type =~ /netload/) { |
---|
436 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/view_netload", "boolean", "true"); |
---|
437 | } elsif ($multiload_type =~ /cpuload/) { |
---|
438 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/view_cpuload", "boolean", "true"); |
---|
439 | } elsif ($multiload_type =~ /memload/) { |
---|
440 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/view_memload", "boolean", "true"); |
---|
441 | } |
---|
442 | |
---|
443 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/speed", "int", $speed); |
---|
444 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/size", "int", $size); |
---|
445 | } elsif ($goadid =~ /mailcheck/i) { |
---|
446 | gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_MailcheckApplet"); |
---|
447 | my $update_frequency = "120000"; |
---|
448 | my $exec_enabled = "false"; |
---|
449 | my $execcommand = ""; |
---|
450 | my $newmail_enabled = "false"; |
---|
451 | my $newmailcommand = ""; |
---|
452 | my $clicked_enabled = "false"; |
---|
453 | my $clickedcommand = ""; |
---|
454 | my $play_sound = "false"; |
---|
455 | my $mailbox_type = "0"; |
---|
456 | my $mail_file = ""; |
---|
457 | if (-f $appletexternfile) { |
---|
458 | open(EXTFILE, $appletexternfile) or die "Couldn't open $appletexternfile\n: $!"; |
---|
459 | while (<EXTFILE>) { |
---|
460 | if (/^update_frequency=(.+)$/) { |
---|
461 | $update_frequency = $1; |
---|
462 | } elsif (/^exec_command=(.+)$/) { |
---|
463 | $execcommand = $1; |
---|
464 | } elsif (/^exec_enabled=(.+)$/) { |
---|
465 | $exec_enabled = $1; |
---|
466 | } elsif (/^newmail_command=(.+)$/) { |
---|
467 | $newmailcommand = $1; |
---|
468 | } elsif (/^newmail_enabled=(.+)$/) { |
---|
469 | $newmail_enabled = $1; |
---|
470 | } elsif (/^clicked_command=(.+)$/) { |
---|
471 | $clickedcommand = $1; |
---|
472 | } elsif (/^clicked_enabled=(.+)$/) { |
---|
473 | $clicked_enabled = $1; |
---|
474 | } elsif (/^play_sound=(.+)$/) { |
---|
475 | $play_sound = $1; |
---|
476 | } elsif (/^mailbox_type=(.+)$/) { |
---|
477 | $mailbox_type = $1; |
---|
478 | } elsif (/^mail_file=(.+)$/) { |
---|
479 | $mail_file = $1; |
---|
480 | } |
---|
481 | } |
---|
482 | close(EXTFILE); |
---|
483 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/update_frequency", "int", $update_frequency); |
---|
484 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/exec_enabled", "boolean", $exec_enabled); |
---|
485 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/exec_command", "string", $execcommand); |
---|
486 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/newmail_enabled", "boolean", $newmail_enabled); |
---|
487 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/newmail_command", "string", $newmailcommand); |
---|
488 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/clicked_enabled", "boolean", $clicked_enabled); |
---|
489 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/clicked_command", "string", $clickedcommand); |
---|
490 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/play_sound", "boolean", $play_sound); |
---|
491 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/mailbox_type", "int", $mailbox_type); |
---|
492 | gconftool("/apps/panel/profiles/default/$type/$scount/prefs/mail_file", "string", $mail_file); |
---|
493 | } |
---|
494 | } else { |
---|
495 | $valid_goadid = undef; |
---|
496 | } |
---|
497 | } |
---|
498 | } |
---|
499 | if (not $valid_goadid) { |
---|
500 | &log("Skipping this applet: unknown goad_id=$goadid"); |
---|
501 | next LINE; |
---|
502 | } |
---|
503 | } elsif ($appletid =~ /Menu/) { |
---|
504 | my $main_menu_flags = 0; |
---|
505 | my $global_main = 'true'; |
---|
506 | foreach my $line (@lines) { |
---|
507 | if ($line =~ /^main_menu_flags=(.+)$/) { |
---|
508 | $main_menu_flags = $1; |
---|
509 | } elsif ($line =~ /^global_main=(.+)$/) { |
---|
510 | $global_main = $1; |
---|
511 | } |
---|
512 | } |
---|
513 | gconftool("/apps/panel/profiles/default/$type/$scount/global-main", "boolean", $global_main); |
---|
514 | gconftool("/apps/panel/profiles/default/$type/$scount/main-menu-flags", "int", $main_menu_flags); |
---|
515 | } |
---|
516 | foreach my $line (@lines) { |
---|
517 | if ($line =~ /^right_stick=(.+)$/) { |
---|
518 | # Athena local mod: In GNOME 2, right_stick means to apply the position |
---|
519 | # from the right side of the screen, which isn't how GNOME 1 treats it. |
---|
520 | # Furthermore, the GNOME 2 panel always saves applets and objects with |
---|
521 | # right_stick false after recomputing the position from the left. |
---|
522 | # Since our position is already left-relative, we can just ignore it. |
---|
523 | # gconftool("/apps/panel/profiles/default/$type/$scount/panel_right_stick", "boolean", $1); |
---|
524 | } elsif ($line =~ /^position=(.+)$/) { |
---|
525 | gconftool("/apps/panel/profiles/default/$type/$scount/position", "int", $1); |
---|
526 | } elsif ($line =~ /^unique_panel_id=(.+)$/) { |
---|
527 | my $uniqueid = $1; |
---|
528 | my $realpanelid = $panel_unique_id_map{$uniqueid}; |
---|
529 | if (not defined $realpanelid) { |
---|
530 | &log("warning: unknown unique panel id=$uniqueid, assuming first panel"); |
---|
531 | $realpanelid = 1; |
---|
532 | } |
---|
533 | gconftool("/apps/panel/profiles/default/$type/$scount/panel_id", "string", sprintf_objid($realpanelid)); |
---|
534 | } elsif ($line =~ /^base_location=(.+)$/) { |
---|
535 | my $launcher = $1; |
---|
536 | gconftool("/apps/panel/profiles/default/$type/$scount/launcher_location", "string", "file://$cwd/.gnome2/panel2.d/default/launchers/$1"); |
---|
537 | } |
---|
538 | } |
---|
539 | } |
---|
540 | } |
---|
541 | close(F); |
---|
542 | &log("done reading applet config file"); |
---|
543 | $liststr = "[" . join(',', @applet_id_list) . "]"; |
---|
544 | gconftool_list("/apps/panel/profiles/default/general/applet_id_list", "string", $liststr); |
---|
545 | $liststr = "[" . join(',', @object_id_list) . "]"; |
---|
546 | gconftool_list("/apps/panel/profiles/default/general/object_id_list", "string", $liststr); |
---|
547 | |
---|
548 | # clean up cruft |
---|
549 | &mysystem("rm", "-rf", ".gnome2/panel.d"); |
---|
550 | |
---|
551 | &log("Transition script complete"); |
---|
552 | |
---|
553 | # Local Variables: |
---|
554 | # compile-command: "perl -c gnome-panel-1-to-2" |
---|
555 | # End: |
---|
556 | |
---|