#! /bin/sh #---------------------------------------------------------------------------- # /var/install/include/ecelib - script interface for edit-conf.cui # # Creation: 2007-11-01 dv # Last update: $Id$ # # Copyright (c) 2001-2007 the eisfair team, team(at)eisfair(dot)org # # 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. #---------------------------------------------------------------------------- ECE_API_GETVALUE=1000 value="" #---------------------------------------------------------------------------- # Get variable within current configuration loaded in editor # Expects: $1 <-- MainWin : Window Handle # $2 <-- Variable-Name : String (something like "FOO_2_NAME") # Returns: $p2 --> Value : String #---------------------------------------------------------------------------- ece_get_value() { echo "C${SEP}$ECE_API_GETVALUE${SEP}$1${SEP}$2" >&8 cui_wait_ack return $? } #---------------------------------------------------------------------------- # setdata # ece --> preinitialize value before the dialog is opened #---------------------------------------------------------------------------- setdata() { value="$p2" cui_return "" } #---------------------------------------------------------------------------- # getdata # ece --> request modified value after the dialog has been closed with IDOK #---------------------------------------------------------------------------- getdata() { cui_return "$value" } #---------------------------------------------------------------------------- # SELECT LIST DIALOG BEGIN #---------------------------------------------------------------------------- ECE_SELECT_LIST_DLG_IDC_COLORS=10 ECE_SELECT_LIST_DLG_IDC_OK=11 ECE_SELECT_LIST_DLG_IDC_CANCEL=12 #---------------------------------------------------------------------------- # ece_select_list_dlg_ok_button # OK button clicked callback #---------------------------------------------------------------------------- ece_select_list_dlg_ok_button() { win="$p2" if cui_window_getctrl "$win" "${ECE_SELECT_LIST_DLG_IDC_COLORS}" then ctrl="$p2" if cui_listbox_getsel "$ctrl" then sel="$p2" cui_listbox_get "$ctrl" "$sel" value="$p2" fi fi cui_window_close "$win" "${IDOK}" cui_return "" } #---------------------------------------------------------------------------- # ece_select_list_dlg_cancel_button # Cancel button clicked callback #---------------------------------------------------------------------------- ece_select_list_dlg_cancel_button() { win="$p2" cui_window_close "$win" "${IDCANCEL}" cui_return "" } #---------------------------------------------------------------------------- # ece_select_list_dlg - Select an item from a single list box # Expects: $1 <-- Parent window : Window Handle # $2 <-- Title : String # $3 <-- SelList : String ("Value1,Value2,Value3") # Returns: Nothing #---------------------------------------------------------------------------- ece_select_list_dlg() { win="$1" title="$2" selectlist="$3" result="$IDCANCEL" if cui_window_new "$win" 0 0 34 13 $[$CWS_POPUP + $CWS_BORDER + $CWS_CENTERED] then dlg="$p2" cui_window_setcolors "$dlg" "DIALOG" cui_window_settext "$dlg" "$title" cui_window_create "$dlg" # create and fill list box if cui_listbox_new "$dlg" "" 2 1 28 7 ${ECE_SELECT_LIST_DLG_IDC_COLORS} $CWS_NONE $CWS_BORDER then myctrl="$p2" cui_window_setcolors "$myctrl" "MENU" cui_window_create "$myctrl" count="0" LOCAL_OLD_IFS="$IFS" IFS="," for sel in $sellist do cui_listbox_add "$myctrl" "$sel" count=$[$count + 1] done IFS="$LOCAL_OLD_IFS" if [ "$count" -gt 7 ] then count=7 fi cui_window_move "$myctrl" 2 1 28 $count cui_listbox_select "$myctrl" "$value" fi # create buttons if cui_button_new "$dlg" "&OK" 5 "$[$count + 2]" 10 1 ${ECE_SELECT_LIST_DLG_IDC_OK} $CWS_DEFOK $CWS_NONE then myctrl="$p2" cui_button_callback "$myctrl" "$BUTTON_CLICKED" "$dlg" "ece_select_list_dlg_ok_button" cui_window_create "$myctrl" fi if cui_button_new "$dlg" "&Cancel" 17 "$[$count + 2]" 10 1 ${ECE_SELECT_LIST_DLG_IDC_CANCEL} $CWS_DEFCANCEL $CWS_NONE then myctrl="$p2" cui_button_callback "$myctrl" "$BUTTON_CLICKED" "$dlg" "ece_select_list_dlg_cancel_button" cui_window_create "$myctrl" fi # move the window if cui_getwindowrect "$dlg" then wx="$p2" wy="$p3" ww="$p4" wh="$p5" delta="$[7 - $count]" cui_window_move "$dlg" "$wx" "$[$wy + $delta / 2]" 34 "$[13 - $delta]" fi # execute dialog cui_window_modal "$dlg" result="$p2" cui_window_destroy "$dlg" fi cui_return $result } #---------------------------------------------------------------------------- # SELECT LIST DIALOG END #----------------------------------------------------------------------------