Add new timezone selection under F3

© Niall Walsh <niallwalsh@users.berlios.de>

--- /dev/null
+++ b/themes/openSUSE/src/dia_timezone.inc
@@ -0,0 +1,105 @@
+% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+%
+% timezone selection dialog.
+%
+% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+% Some global vars.
+%
+
+/timezone.setdefault {
+  xmenu.timezone .xm_current
+
+    0
+    timezones {
+      .tz.id get config.timezone.id eq { exit } if
+      1 add
+    } forall
+
+    dup timezones length ge { pop 0 } if
+
+  put
+
+} def
+
+% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+% Build menu list.
+%
+% ( ) ==> ( )
+%
+/timezone.init {
+  /xmenu.timezone .xm_size array def
+
+  /xmenu xmenu.timezone def
+
+  xmenu .xm_list [
+    timezones { .tz.name get } forall
+  ] put
+
+  xmenu .xm_title "Timezone" put
+
+  timezone.setdefault
+
+  % just once (see lang.init)
+  /timezone.init { } def
+} def
+
+
+% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+% Update timezone selection menu.
+%
+% ( ) ==> ( )
+%
+/timezone.update {
+  /xmenu xmenu.timezone def
+
+  timezones xmenu .xm_current get get .tz.id get settimezone
+
+  /window.action actRedrawPanel def
+} def
+
+
+% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+% Show timezone selection menu.
+%
+% ( ) => ( )
+%
+/panel.timezone {
+  % "keymap" help.setcontext
+
+  timezone.setdefault
+
+  window.xmenu
+  dup .xmenu xmenu.timezone put
+  dup .xmenu.update /timezone.update put
+  dup window.init
+      window.show
+} def
+
+
+% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+% Return width of panel entry.
+%
+% ( ) => ( width )
+%
+/panel.timezone.width {
+  /xmenu xmenu.timezone def
+
+  pmenu.width
+} def
+
+
+% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+% Redraw panel entry.
+%
+% ( panel ) => ( )
+%
+/panel.timezone.update {
+  /xmenu xmenu.timezone def
+
+  pmenu.panel.update
+} def
+
+
--- a/themes/openSUSE/src/main.bc
+++ b/themes/openSUSE/src/main.bc
@@ -23,9 +23,11 @@
 %% include dia_keymap.inc
 %% include dia_restore.inc
 %% include dia_net.inc
+%% include dia_timezone.inc
 %% include dia_otheropts.inc
 %% include panel.inc
 %% include keytables.inc
+%% include timezones.inc
 %% include locale.inc
 %% include speech.inc
 
--- /dev/null
+++ b/themes/openSUSE/src/timezones.inc
@@ -0,0 +1,79 @@
+% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+%
+% Timezones
+%
+% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+/.tz.name   0 def
+/.tz.id     1 def
+
+/timezones [
+    [ "Auto" "" ]
+    [ "UTC" "Etc/UTC utc" ]
+    %[ "GMT-12" "Etc/GMT-12" ] % Uninhabited
+    %[ "Pago Pago" "Pacific/Pago_Pago" ] % GMT-11 % _AS
+    [ "Honolulu" "Pacific/Honolulu" ] % GMT-10
+    %[ "Adak" "America/Adak" ] % GMT-10 DST
+    %[ "Gambier" "Pacific/Gambier" ] % GMT-10
+    %[ "Marquesas" "Pacific/Marquesas" ] % GMT-930
+    [ "Anchorage" "America/Anchorage" ] % GMT-9 DST
+    %[ "Pitcairn" "Pacific/Pitcairn" ] % GMT-8
+    [ "Los Angeles" "America/Los_Angeles" ] % GMT-8 DST
+    [ "Phoenix" "America/Phoenix" ] % GMT-7
+    [ "Denver" "America/Denver" ] % GMT-7 DST
+    [ "Managua" "America/Managua" ] % GMT-6
+    [ "Chicago" "America/Chicago" ] % GMT-6 DST
+    [ "Bogota" "America/Bogota" ] % GMT-5
+    [ "New York" "America/New_York" ] % GMT-5 DST % _CA, _CU, _BS also
+    %[ "Caracas" "America/Caracas" ] % GMT-430 % es_VE in locales
+    [ "La Paz" "America/La_Paz" ] % GMT-4
+    [ "Santiago" "America/Santiago" ] % GMT-4 DST
+    %[ "St Johns" "America/St_Johns" ] % GMT-3.5 DST
+    [ "Buenos Aires" "America/Argentina/Buenos_Aires" ] % GMT-3
+    [ "Sao Paulo" "America/Sao_Paulo" ] % GMT-3 DST
+    %[ "Noronha" "America/Noronha" ] % GMT-2
+    %[ "Cape Verde" "Atlantic/Cape_Verde" ] % GMT-1
+    %[ "Azores" "Atlantic/Azores" ] % GMT-1 DST
+    [ "Casablanca" "Africa/Casablanca" ] % GMT
+    [ "London" "Europe/London" ] % GMT DST
+    [ "Algiers" "Africa/Algiers" ] % GMT+1
+    [ "Berlin" "Europe/Berlin" ] % GMT+1 DST
+    [ "Johannesburg" "Africa/Johannesburg" ] % GMT+2
+    [ "Athens" "Europe/Athens" ] % GMT+2 DST
+    [ "Baghdad" "Asia/Baghdad" ] % GMT+3
+    [ "Moscow" "Europe/Moscow" ] % GMT+3 DST
+    [ "Tehran" "Asia/Tehran" ] % GMT+330 DST
+    [ "Dubai" "Asia/Dubai" ] % GMT+4
+    [ "Baku" "Asia/Baku" ] % GMT+4 DST
+    %[ "Kabul" "Asia/Kabul" ] % GMT+430
+    [ "Karachi" "Asia/Karachi" ] % GMT+5
+    [ "Yekaterinburg" "Asia/Yekaterinburg" ] % GMT+5 DST
+    [ "Kolkata" "Asia/Kolkata" ] % GMT+530 % _IN in locales
+    % [ "Kathmandu" "Asia/Kathmandu" ] % GMT+545
+    [ "Almaty" "Asia/Almaty" ] % GMT+6 % _BT, _KZ, _KG
+    [ "Dhaka" "Asia/Dhaka" ] % GMT+6 DST % _BD, _RU
+    % [ "Rangoon" "Asia/Rangoon" ] % GMT+630 % Burma
+    [ "Bangkok" "Asia/Bangkok" ] % GMT+7
+    [ "Krasnoyarsk" "Asia/Krasnoyarsk" ] % GMT+7 DST % _RU
+    [ "Beijing" "Asia/Shanghai" ] % GMT+8
+    [ "Irkutsk" "Asia/Irkutsk" ] % GMT+8 DST % _RU
+    %[ "Eucla" "Australia/Eucla" ] % GMT+845
+    [ "Tokyo" "Asia/Tokyo" ] % GMT+9
+    [ "Yakutsk" "Asia/Yakutsk" ] % GMT+9 DST % _RU
+    [ "Darwin" "Australia/Darwin" ] % GMT+930
+    [ "Adelaide" "Australia/Adelaide" ] % GMT+930 DST
+    [ "Brisbane" "Australia/Brisbane" ] % GMT+10
+    %[ "Vladivostok" "Asia/Vladivostok" ] % GMT+10 DST % _RU DST variant
+    [ "Sydney" "Australia/Sydney" ] % GMT+10 DST
+    %[ "Lord_Howe" "Australia/Lord_Howe" ] % GMT+1030 DST30
+    %[ "Ponape" "Pacific/Ponape" ] % GMT+11
+    %[ "Magadan" "Asia/Magadan" ] % GMT+11 DST % _RU
+    %[ "Norfolk" "Pacific/Norfolk" ] % GMT+1130
+    [ "Fiji" "Pacific/Fiji" ] % GMT+12
+    [ "Auckland" "Pacific/Auckland" ] % GMT+12 DST
+    %[ "Chatham" "Pacific/Chatham" ] % GMT+1245 DST
+    [ "Tongatapu" "Pacific/Tongatapu" ] % GMT+13
+    %[ "Kiritimati" "Pacific/Kiritimati" ] % GMT+14
+] def
+
--- a/themes/openSUSE/src/common.inc
+++ b/themes/openSUSE/src/common.inc
@@ -446,6 +446,12 @@
     } if
   } if
 
+  config.addopt.timezone {
+    config.timezone.id {
+      config.timezone.id "tz=%s " bc.cmd dup length add sprintf
+    } if
+  } if
+
   xmenu.dud {
     xmenu.dud .xm_current get .dud_url eq {
       input.edit.dud_url 0 get dup "" ne {
@@ -1657,8 +1663,11 @@ config.livecd {
 /panel.f-key.fg        "panel.f-key.fg"           black gfxconfig.set.int
 /keymap.submenu        "keymap.submenu"           false gfxconfig.set.bool
 /keymap.default        "keymap"                      "" gfxconfig.set.str
+/timezone.submenu      "timezone.submenu"         false gfxconfig.set.bool
+/timezone.default      "timezone"                    "" gfxconfig.set.str
 /config.addopt.lang    "addopt.lang"              false gfxconfig.set.bool
 /config.addopt.keytable "addopt.keytable"         false gfxconfig.set.bool
+/config.addopt.timezone "addopt.timezone"         false gfxconfig.set.bool
 
 /install.install       "install"                     "" gfxconfig.set.str
 /install.http.server   "install.http.server"         "" gfxconfig.set.str
--- a/themes/openSUSE/src/panel.inc
+++ b/themes/openSUSE/src/panel.inc
@@ -170,6 +170,7 @@
   dup "otheropts"  eq { pop [ /panel.otheropts /panel.otheropts.width /panel.otheropts.update /otheropts.init ] return } if
   dup "dud"        eq { pop [ /panel.dud /panel.dud.width /panel.dud.update /dud.init ] return } if
   dup "keymap"     eq { pop [ /panel.keymap /panel.keymap.width /panel.keymap.update /keymap.init ] return } if
+  dup "timezone"   eq { pop [ /panel.timezone /panel.timezone.width /panel.timezone.update /timezone.init ] return } if
 
   dup "bits"       eq { pop
     .undef
--- a/themes/openSUSE/src/locale.inc
+++ b/themes/openSUSE/src/locale.inc
@@ -72,6 +72,36 @@
   config.keymap.id .undef eq { /config.keymap.id "us" def } if
 } def
 
+% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+% Set timezone.
+%
+% ( timezone ) ==> ( )
+%
+% timezone may be .undef.
+%
+/settimezone {
+  /timezone.tmp exch def
+
+  config.timezone.id timezone.tmp eq { return } if
+
+  /config.timezone .undef def
+  /config.timezone.id .undef def
+
+  2 {
+    timezone.tmp .undef eq { exit } if
+
+    timezones {
+      dup .tz.id get timezone.tmp eq {
+        .tz.id get /config.timezone.id exch def
+      } { pop } ifelse
+    } forall
+
+    config.keymap.id .undef ne { exit } if
+
+  } repeat
+
+  config.timezone.id .undef eq { /config.timezone.id "Etc/UTC" def } if
+} def
 
 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 % Look up keymap in languale locale list.
