box_ok 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/bash
  2. #
  3. #This box shows one ok-button, one icon, and textstring(s)
  4. #markup/span is valid
  5. #
  6. #Usage :
  7. # box_ok HEADING MSG-TYPE|ICON "textstring1" "textstring2" "..."
  8. #
  9. # HEADING is a short description. Maybe the app-name of the sender.
  10. # MSG-TYPE sets icon of icon and window. one of the following: complete, info, error or warning
  11. # ICON is a svg file. If path is not defined, /usr/share/pixmaps/puppy/ will be used
  12. #
  13. #Example :
  14. # 3 sec timeout: /usr/lib/gtkdialog/box_ok "heading" complete "text" &; XPID=$!; sleep 3; pkill -P $XPID
  15. #
  16. #Sigmund Berglund, dec 2013
  17. #GPL
  18. export TEXTDOMAIN=libstardust
  19. export OUTPUT_CHARSET=UTF-8
  20. HEADING="$1"
  21. case $2 in
  22. complete)
  23. ICON=/usr/share/pixmaps/puppy/dialog-complete.svg
  24. ICON_WM=gtk-yes
  25. FRAME="$(gettext 'Complete')"
  26. ;;
  27. info)
  28. ICON=/usr/share/pixmaps/puppy/dialog-info.svg
  29. ICON_WM=gtk-info
  30. FRAME="$(gettext 'Info')"
  31. ;;
  32. error)
  33. ICON=/usr/share/pixmaps/puppy/dialog-error.svg
  34. ICON_WM=gtk-no
  35. FRAME="$(gettext 'Error')"
  36. ;;
  37. warning)
  38. ICON=/usr/share/pixmaps/puppy/dialog-warning.svg
  39. ICON_WM=gtk-no
  40. FRAME="$(gettext 'Warning')"
  41. ;;
  42. nb)
  43. ICON=/usr/share/pixmaps/puppy/nb.svg
  44. ICON_WM=gtk-no
  45. FRAME="$(gettext 'NB!')"
  46. ;;
  47. *)
  48. ICON="$2"
  49. ICON_WM=gtk-about
  50. FRAME=" "
  51. ;;
  52. esac
  53. S='
  54. <window title="'$HEADING'" icon-name="'$ICON_WM'">
  55. <vbox space-expand="true" space-fill="true">
  56. <frame '$FRAME'>
  57. <hbox homogeneous="true">
  58. '"`/usr/lib/gtkdialog/xml_pixmap "$ICON" popup`"'
  59. </hbox>
  60. <hbox border-width="10" homogeneous="true">
  61. <vbox space-expand="false" space-fill="false">'
  62. [ "$3" ] && S=$S'<text xalign="0" use-markup="true"><label>"'$3'"</label></text>'
  63. [ "$4" ] && S=$S'<text xalign="0" use-markup="true"><label>"'$4'"</label></text>'
  64. [ "$5" ] && S=$S'<text xalign="0" use-markup="true"><label>"'$5'"</label></text>'
  65. [ "$6" ] && S=$S'<text xalign="0" use-markup="true"><label>"'$6'"</label></text>'
  66. [ "$7" ] && S=$S'<text xalign="0" use-markup="true"><label>"'$7'"</label></text>'
  67. [ "$8" ] && S=$S'<text xalign="0" use-markup="true"><label>"'$8'"</label></text>'
  68. [ "$9" ] && S=$S'<text xalign="0" use-markup="true"><label>"'$9'"</label></text>'
  69. [ "${10}" ] && S=$S'<text xalign="0" use-markup="true"><label>"'${10}'"</label></text>'
  70. [ "${11}" ] && S=$S'<text xalign="0" use-markup="true"><label>"'${11}'"</label></text>'
  71. S=$S'</vbox>
  72. </hbox>
  73. </frame>
  74. <hbox space-expand="false" space-fill="false">
  75. <button>
  76. '"`/usr/lib/gtkdialog/xml_button-icon ok`"'
  77. <label>" '$(gettext 'Ok')' "</label>
  78. </button>
  79. </hbox>
  80. </vbox>
  81. </window>'
  82. export box_ok="$S"
  83. gtkdialog --center -p box_ok