source: trunk/packs/dotfiles/gnome-panel-1-to-2 @ 19254

Revision 19254, 23.9 KB checked in by ghudson, 21 years ago (diff)
gnome-launchers-1-to-2 isn't all that important to us (it translates launchers which run gnomecc or gnome-help-browser, neither of which are probably common in our environment) and wouldn't work for us without a fair amount of work. So punt it.
Line 
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.3 2003-04-22 15:34:32 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
25use POSIX;
26
27my $cwd = POSIX::getcwd();
28
29my $no_act = 0;
30foreach my $arg (@ARGV) {
31  if ($arg eq '-n') {
32    $no_act = 1;
33  }
34}
35
36sub log {
37  print "gnome-panel-1-to-2: " . join(' ', @_) . "\n";
38}
39
40my $panelconfigfile = ".gnome/panel.d/default/panel";
41my $appletconfigfile = ".gnome/panel.d/default/Applet_Config";
42
43open(F, $panelconfigfile) or die "Couldn't open $panelconfigfile\n: $!";
44my ($panel_count, $applet_count) = (0,0);
45while (<F>) {
46  /panel_count=(.+)$/ and $panel_count = $1;
47  /applet_count=(.+)$/ and $applet_count = $1;
48}
49close(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
54my %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
62my %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
67my %panel_align_map = (0 => "panel-alignment-left",
68                       2 => "panel-alignment-right");
69
70my %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
74my @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
80my %old_panel_edge_map = (0 => "panel-edge-top",
81                          1 => "panel-edge-right",
82                          2 => "panel-edge-bottom",
83                          3 => "panel-edge-left");
84
85sub sprintf_objid {
86  my $id = shift;
87  return sprintf("%08d", $id);
88}
89
90sub 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
97sub mysystem {
98  my @cmd = @_;
99  &log("running: " . join(' ', @_));
100  system_internal(@_);
101}
102
103sub gconftool {
104  my ($path, $type, $value) = @_;
105  my @cmd = ("gconftool-2", "-s", "$path", "-t", "$type", "--", "$value");
106  mysystem(@cmd);
107}
108
109sub 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
116open(F, $panelconfigfile) or die "Couldn't open $panelconfigfile\n: $!";
117my $line;
118@panel_id_list = ();
119$panel_id_count = 1;
120%panel_unique_id_map = ();
121while ($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}
190my $liststr = "[" . join(',', @panel_id_list) . "]";
191gconftool_list("/apps/panel/profiles/default/general/panel_id_list", "string", $liststr);
192 
193&log("finished reading panel config file");
194close(F);
195
196&log("converting .desktop files");
197my $gnome1dir = ".gnome/panel.d/default/launchers/";
198my $gnome2dir = ".gnome2/panel2.d/default/launchers/";
199if (-d $gnome1dir) {
200  &mysystem("mkdir", "-p", $gnome2dir);
201  opendir (DIR, $gnome1dir) or die "Couldn't open $gnome1dir: $!";
202  foreach my $entry (readdir(DIR)) {
203    if (not $entry =~ /^\.\.?$/) {
204      &mysystem("cp", "-p", $gnome1dir . $entry, $gnome2dir);
205    }
206  }
207  closedir(DIR);
208}
209
210# Create the applets and launchers.
211open(F, $appletconfigfile) or die "Couldn't open $appletconfigfile\n: $!";
212&log("Reading applet config file");
213
214my @applet_id_list = ();
215my $applet_id_count = 1;
216my @object_id_list = ();
217my $object_id_count = 1;
218LINE: while (defined ($line = <F>)) {
219  if ($line =~ /\[Applet_(\d+)\]/) {
220    my $appletnumber = $1;
221    &log("Reading applet/object id $appletnumber");
222    my $appletexternfile = ".gnome/panel.d/default/Applet_" . "$appletnumber" . "_Extern";
223    my @lines;
224    while (defined(($line = <F>)) and $line =~ /^\w+/) {
225      push(@lines, $line);
226    }
227    my ($appletid, $count, $scount, $type) = (undef, undef, undef, undef);
228    foreach my $line (@lines) {
229      if ($line =~ /^id=(.+)$/) {
230        $appletid = $1;
231        if ($appletid =~ /Extern/) {
232          $count = $applet_id_count;
233          $scount = sprintf_objid($count);
234          gconftool("/apps/panel/profiles/default/applets/$scount/object_type", "string", "bonobo-applet");
235          push @applet_id_list, sprintf_objid($applet_id_count);
236          $applet_id_count++;
237          $type = 'applets';
238        } elsif ($appletid =~ /Launcher/) {
239          $count = $object_id_count;
240          $scount = sprintf_objid($count);
241          gconftool("/apps/panel/profiles/default/objects/$scount/panel_right_stick", "boolean", "false");
242          gconftool("/apps/panel/profiles/default/objects/$scount/object_type", "string", "launcher-object");
243          push @object_id_list, sprintf_objid($object_id_count);
244          $count = $object_id_count;
245          $object_id_count++;
246          $type = 'objects';
247        } elsif ($appletid =~ /Menu/) {
248          $count = $object_id_count;
249          $scount = sprintf_objid($count);
250          # Athena local mod: in GNOME 1, we hacked the default menu
251          # path; in GNOME 2, we use a schemas file to set a path and
252          # custom icon and to turn off the main-menu flags.  We have
253          # to do the same in translation.
254          gconftool("/apps/panel/profiles/default/objects/$scount/path", "string", "file:///var/athena/menus");
255          gconftool("/apps/panel/profiles/default/objects/$scount/global-main", "boolean", "false");
256          gconftool("/apps/panel/profiles/default/objects/$scount/main-menu", "boolean", "false");
257          gconftool("/apps/panel/profiles/default/objects/$scount/object_type", "string", "menu-object");
258          gconftool("/apps/panel/profiles/default/objects/$scount/custom-icon", "boolean", "true");
259          gconftool("/apps/panel/profiles/default/objects/$scount/custom-icon-file", "string", "/usr/athena/share/gnome/athena/menu-icon");
260          push @object_id_list, sprintf_objid($object_id_count);
261          $count = $object_id_count;
262          $object_id_count++;
263          $type = 'objects';
264        } elsif ($appletid =~ /Logout/) {
265          # Athena local mod: understand the logout button.  Treat it
266          # in a very Athena-specific way; in our environment, the
267          # logout button needs to be a launcher which runs
268          # gathlogout, because we don't run a session manager.
269          $count = $object_id_count;
270          $scount = sprintf_objid($count);
271          gconftool("/apps/panel/profiles/default/objects/$scount/panel_right_stick", "boolean", "false");
272          gconftool("/apps/panel/profiles/default/objects/$scount/object_type", "string", "launcher-object");
273          gconftool("/apps/panel/profiles/default/objects/$scount/launcher_location", "string", "file:///usr/athena/share/gnome/athena/logout.desktop");
274          push @object_id_list, sprintf_objid($object_id_count);
275          $count = $object_id_count;
276          $object_id_count++;
277          $type = 'objects';
278        } else {
279          &log("warning: unknown Applet id=$appletid");
280          $appletid = undef;
281        }
282      }
283    }
284    if (not $appletid) {
285      &log("Skipping this applet: unknown appletid");
286      next LINE;
287    }
288    # Handle applets specially
289    if ($appletid =~ /Extern/) {
290      my $valid_goadid = 1;
291      my $goadid = "!unspecified!";
292      foreach my $line (@lines) {
293        if ($line =~ /goad_id=(.+)$/) {
294          $goadid = $1;
295          if ($goadid =~ /clock/i) {
296            gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_ClockApplet");
297            # FIXME: set up sane defaults for now; we shoudl really pick these from the old prefs
298            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/show_seconds", "boolean", "true");
299            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/show_tooltip", "boolean", "true");
300            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/gmt_time", "boolean", "false");
301            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/unix_time", "boolean", "false");
302            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/hour_format", "int", "24");
303            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/internet_time", "boolean", "false");
304            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/show_date", "boolean", "true");
305          } elsif ($goadid =~ /deskguide/i) {
306            gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_PagerApplet");
307            # FIXME: set up sane defaults for now; we shoudl really pick these from the old prefs
308            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/num_rows", "int", "1");
309            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/display_all_workspaces", "boolean", "true");
310            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/display_workspace_names", "boolean", "false");
311          } elsif ($goadid =~ /mixer/i) {
312            gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_MixerApplet");
313          } elsif ($goadid =~ /geyes/i) {
314            gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_GeyesApplet");
315            # Theme stuff doesn't appear to be compatible; just ignore...
316          } elsif ($goadid =~ /tasklist/i) {
317            gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_TasklistApplet");
318            my $group_windows = "auto";
319            my $display_all_workspaces = "false";
320            my $move_unminimized_windows = "true";
321            if (-f $appletexternfile) {
322              open(EXTFILE, $appletexternfile) or die "Couldn't open $appletexternfile\n: $!";
323              while (<EXTFILE>) {
324                if (/^enable_grouping=(.+)$/) {
325                  my $grouping =$1;
326                  if ($grouping =~ /false/) {
327                    $group_windows = "never";
328                  }
329                } elsif (/^all_desks_normal=(.+)$/) {
330                  $display_all_workspaces = $1;
331                } elsif (/^move_to_current=(.+)$/) {
332                  $move_unminimized_windows = $1;
333                }
334              }
335              close(EXTFILE);
336            }
337            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/group_windows", "string", $group_windows);
338            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/display_all_workspaces", "boolean", $display_all_workspaces);
339            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/move_unminimized_windows", "boolean", $move_unminimized_windows);
340            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/maximum_size", "int", "4096");
341            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/minimum_size", "int", "50");
342          } elsif ($goadid =~ /battery_applet/i) {
343            gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_BattstatApplet");
344            my $full_notify_enable = "false";
345            my $lowwarn_enable = "true";
346            my $low_charge_val = 25;
347            my $low_warn_val = 5;
348            if (-f $appletexternfile) {
349              open(EXTFILE, $appletexternfile) or die "Couldn't open $appletexternfile\n: $!";
350              while (<EXTFILE>) {
351                if (/^low_charge_val=(.+)$/) {
352                  $low_charge_val = $1;
353                } elsif (/^low_warn_val=(.+)$/) {
354                  $low_warn_val = $1;
355                } elsif (/^full_notify_enable=(.+)$/) {
356                  $full_notify_enable = $1;
357                } elsif (/^low_warn_enable=(.+)$/) {
358                  $low_warn_enable = $1;
359                }
360              }
361              close(EXTFILE);
362            }
363            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/full_battery_notification", "boolean", $full_notify_enable);
364            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/show_percent", "boolean", "false");
365            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/beep", "boolean", "false");
366            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/suspend_command", "string", "");
367            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/use_dock", "boolean", "false");
368            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/red_value", "int", $low_warn_val);
369            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/yellow_value", "int", "40");
370            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/orange_value", "int", $low_charge_val);
371            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/show_battery", "boolean", "true");
372            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/horizontal", "boolean", "true");
373            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/show_status", "boolean", "true");
374            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/low_battery_notification", "boolean", $low_warn_enable);
375            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/drain_from_top", "boolean", "false");
376          } elsif ($goadid =~ /fish_applet/i) {
377            gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_FishApplet");
378            my $fishname = "Wanda";
379            my $image = "fish/fishanim.png";
380            my $fishcommand = "fortune";
381            my $frames = 3;
382            my $speed = 1;
383            my $rotate = "true";
384            if (-f $appletexternfile) {
385              open(EXTFILE, $appletexternfile) or die "Couldn't open $appletexternfile\n: $!";
386              while (<EXTFILE>) {
387                if (/^name=(.+)$/) {
388                  $fishname = $1;
389                } elsif (/^image=(.+)$/) {
390                  # Get rid of any path prefix.
391                  s,^/usr/share/pixmaps/,,;
392                  $image = $1;
393                } elsif (/^command=(.+)$/) {
394                  $fishcommand = $1;
395                } elsif (/^frames=(.+)$/) {
396                  $frames = $1;
397                } elsif (/^speed=(.+)$/) {
398                  $speed = $1;
399                } elsif (/^rotate=(.+)$/) {
400                  $rotate = $1;
401                }
402              }
403              close(EXTFILE);
404            }
405            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/command", "string", $fishcommand);
406            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/image", "string", $image);
407            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/frames", "int", $frames);
408            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/speed", "int", $speed);
409            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/name", "string", $fishname);
410            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/rotate", "boolean", $rotate);
411          } elsif ($goadid =~ /multiload_(.+?)_applet/i) {
412            my $multiload_type = $1;
413            gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_MultiLoadApplet");
414            my $speed = "500";
415            my $size = "40";
416            # FIXME: we make no attempt at preserving colors.  It seems tricky at first glance.
417            if (-f $appletexternfile) {
418              open(EXTFILE, $appletexternfile) or die "Couldn't open $appletexternfile\n: $!";
419              while (<EXTFILE>) {
420                if (/^speed=(.+)$/) {
421                  $speed = $1;
422                } elsif (/^size=(.+)$/) {
423                  $size = $1;
424                }
425              }
426              close(EXTFILE);
427            }
428            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/view_loadavg", "boolean", "false");
429            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/view_memload", "boolean", "false");
430            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/view_netload", "boolean", "false");
431            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/view_cpuload", "boolean", "false");
432            if ($multiload_type =~ /netload/) {
433              gconftool("/apps/panel/profiles/default/$type/$scount/prefs/view_netload", "boolean", "true");
434            } elsif ($multiload_type =~ /cpuload/) {
435              gconftool("/apps/panel/profiles/default/$type/$scount/prefs/view_cpuload", "boolean", "true");
436            } elsif ($multiload_type =~ /memload/) {
437              gconftool("/apps/panel/profiles/default/$type/$scount/prefs/view_memload", "boolean", "true");
438            }
439
440            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/speed", "int", $speed);
441            gconftool("/apps/panel/profiles/default/$type/$scount/prefs/size", "int", $size);
442          } elsif ($goadid =~ /mailcheck/i) {
443            gconftool("/apps/panel/profiles/default/$type/$scount/bonobo_iid", "string", "OAFIID:GNOME_MailcheckApplet");
444            my $update_frequency = "120000";
445            my $exec_enabled = "false";
446            my $execcommand = "";
447            my $newmail_enabled = "false";
448            my $newmailcommand = "";
449            my $clicked_enabled = "false";
450            my $clickedcommand = "";
451            my $play_sound = "false";
452            my $mailbox_type = "0";
453            my $mail_file = "";
454            if (-f $appletexternfile) {
455              open(EXTFILE, $appletexternfile) or die "Couldn't open $appletexternfile\n: $!";
456              while (<EXTFILE>) {
457                if (/^update_frequency=(.+)$/) {
458                  $update_frequency = $1;
459                } elsif (/^exec_command=(.+)$/) {
460                  $execcommand = $1;
461                } elsif (/^exec_enabled=(.+)$/) {
462                  $exec_enabled = $1;
463                } elsif (/^newmail_command=(.+)$/) {
464                  $newmailcommand = $1;
465                } elsif (/^newmail_enabled=(.+)$/) {
466                  $newmail_enabled = $1;
467                } elsif (/^clicked_command=(.+)$/) {
468                  $clickedcommand = $1;
469                } elsif (/^clicked_enabled=(.+)$/) {
470                  $clicked_enabled = $1;
471                } elsif (/^play_sound=(.+)$/) {
472                  $play_sound = $1;
473                } elsif (/^mailbox_type=(.+)$/) {
474                  $mailbox_type = $1;
475                } elsif (/^mail_file=(.+)$/) {
476                  $mail_file = $1;
477                }
478              }
479              close(EXTFILE);
480              gconftool("/apps/panel/profiles/default/$type/$scount/prefs/update_frequency", "int", $update_frequency);
481              gconftool("/apps/panel/profiles/default/$type/$scount/prefs/exec_enabled", "boolean", $exec_enabled);
482              gconftool("/apps/panel/profiles/default/$type/$scount/prefs/exec_command", "string", $execcommand);
483              gconftool("/apps/panel/profiles/default/$type/$scount/prefs/newmail_enabled", "boolean", $newmail_enabled);
484              gconftool("/apps/panel/profiles/default/$type/$scount/prefs/newmail_command", "string", $newmailcommand);
485              gconftool("/apps/panel/profiles/default/$type/$scount/prefs/clicked_enabled", "boolean", $clicked_enabled);
486              gconftool("/apps/panel/profiles/default/$type/$scount/prefs/clicked_command", "string", $clickedcommand);
487              gconftool("/apps/panel/profiles/default/$type/$scount/prefs/play_sound", "boolean", $play_sound);
488              gconftool("/apps/panel/profiles/default/$type/$scount/prefs/mailbox_type", "int", $mailbox_type);
489              gconftool("/apps/panel/profiles/default/$type/$scount/prefs/mail_file", "string", $mail_file);
490            }
491          } else {
492            $valid_goadid = undef;
493          }
494        }
495      }
496      if (not $valid_goadid) {
497        &log("Skipping this applet: unknown goad_id=$goadid");
498        next LINE;
499      }
500    } elsif ($appletid =~ /Menu/) {
501      my $main_menu_flags = 0;
502      my $global_main = 'true';
503      foreach my $line (@lines) {
504        if ($line =~ /^main_menu_flags=(.+)$/) {
505          $main_menu_flags = $1;
506        } elsif ($line =~ /^global_main=(.+)$/) {
507          $global_main = $1;
508        }
509      }
510      gconftool("/apps/panel/profiles/default/$type/$scount/global-main", "boolean", $global_main);
511      gconftool("/apps/panel/profiles/default/$type/$scount/main-menu-flags", "int", $main_menu_flags);
512    }
513    foreach my $line (@lines) {
514      if ($line =~ /^right_stick=(.+)$/) {
515# Athena local mod: In GNOME 2, right_stick means to apply the position
516# from the right side of the screen, which isn't how GNOME 1 treats it.
517# Furthermore, the GNOME 2 panel always saves applets and objects with
518# right_stick false after recomputing the position from the left.
519# Since our position is already left-relative, we can just ignore it.
520#       gconftool("/apps/panel/profiles/default/$type/$scount/panel_right_stick", "boolean", $1);
521      } elsif ($line =~ /^position=(.+)$/) {
522        gconftool("/apps/panel/profiles/default/$type/$scount/position", "int", $1);
523      } elsif ($line =~ /^unique_panel_id=(.+)$/) {
524        my $uniqueid = $1;
525        my $realpanelid = $panel_unique_id_map{$uniqueid};
526        if (not defined $realpanelid) {
527          &log("warning: unknown unique panel id=$uniqueid, assuming first panel");
528          $realpanelid = 1;
529        }
530        gconftool("/apps/panel/profiles/default/$type/$scount/panel_id", "string", sprintf_objid($realpanelid));
531      } elsif ($line =~ /^base_location=(.+)$/) {
532        my $launcher = $1;
533        gconftool("/apps/panel/profiles/default/$type/$scount/launcher_location", "string", "file://$cwd/.gnome2/panel2.d/default/launchers/$1");
534      }
535    }
536  }
537}
538close(F);
539&log("done reading applet config file");
540$liststr = "[" . join(',', @applet_id_list) . "]";
541gconftool_list("/apps/panel/profiles/default/general/applet_id_list", "string", $liststr);
542$liststr = "[" . join(',', @object_id_list) . "]";
543gconftool_list("/apps/panel/profiles/default/general/object_id_list", "string", $liststr);
544
545# clean up cruft
546&mysystem("rm", "-rf", ".gnome2/panel.d");
547
548&log("Transition script complete");
549
550# Local Variables:
551# compile-command: "perl -c gnome-panel-1-to-2"
552# End:
553
Note: See TracBrowser for help on using the repository browser.