### Copyright (C) 1995, 1996, 1997 Jeppe Buk (buk@imada.sdu.dk)
### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License as published by
### the Free Software Foundation; either version 2 of the License, or
### (at your option) any later version.
###
### This program is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
### GNU General Public License for more details.
###
### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
### Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

proc FvwmIconMan {} {
  # Modules / FvwmIconMan
  Desc "Configuration of the FvwmIconMan module"
  ShortDesc "FvwmIconMan"

  Header h -text "FvwmIconMan" -frame:relief flat \
      -help "On this page you configure the FvwmIconMan module. This"\
      "module is used for iconifying windows to instead of the root."\
      "You can have multiple icon managers active to manage different"\
      "types of windows."
  Line l
  CheckBox spawn -text "Spawn this module when Fvwm2 starts" \
      -help "If you check this option the module will be spawned from"\
      "the two functions 'InitFunction' and 'RestartFunction'. You will"\
      "not have to insert them yourself then."

  Line globL
  fvwmIconMan global 0
  Window globalW -text "Global settings" -entries global_frame \
      -help "In this window you specify global settings for all"\
      "FvwmIconMan windows." \
      -pageEnd {
	if {$global_GeoW != $global_GeoH &&
	    ($global_GeoW == "" || $global_GeoH == "")} {
	  error "You cannot specify only one of width or height in\
 global FvwmIconMan settings."
	}
	if {$global_GeoX == "-" || $global_GeoY == "-"} {
	  error "Invalid X or Y position in global FvwmIconMan settings"
	}
	if {$global_GeoX != $global_GeoY &&
	    ($global_GeoX == "" || $global_GeoY == "")} {
	  error "You cannot specify only one of X or Y position in\
 global FvwmIconMan settings."
	}
      }

  Line indL
  fvwmIconMan ind 1
  ExtEntry mans -text "Individual managers" -entries ind_frame \
      -count 1 \
      -help "For every manager you should specify which windows (not) to"\
      "display. Further more you might wish to overload some or all of"\
      "the global settings you have specified."

  PageEnd {
    forevery mans {
      if {$ind_GeoW != $ind_GeoH &&
	  ($ind_GeoW == "" || $ind_GeoH == "")} {
	error "You cannot specify only one of width or height in\
 individual FvwmIconMan settings."
      }
      if {$ind_GeoX == "-" || $ind_GeoY == "-"} {
	error "Invalid X or Y position in individual FvwmIconMan settings"
      }
      if {$ind_GeoX != $ind_GeoY &&
	  ($ind_GeoX == "" || $ind_GeoY == "")} {
	error "You cannot specify only one of X or Y position in\
 individual FvwmIconMan settings."
      }
    }
  }

  Save {
    set numMan 0
    forevery mans {
      incr numMan
    }
    if {$numMan > 1} {
      print "*FvwmIconMan*nummanagers\t$numMan"
    }
    fvwmIconManSave global -1
    set manNo 0
    forevery mans {
      fvwmIconManSave ind $manNo
      incr manNo
    }
    if {$spawn == 1} {
      print "AddToFunc InitFunction \"I\" Module FvwmIconMan"
      print "AddToFunc RestartFunction \"I\" Module FvwmIconMan"
    }
  }
}
