box_ok 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #Sigmund Berglund, dec 2013
  14. #GPL
  15. export TEXTDOMAIN=libstardust
  16. HEADING="$1"
  17. case $2 in
  18. complete)
  19. ICON=/usr/share/pixmaps/puppy/dialog-complete.svg
  20. ICON_WM=gtk-yes
  21. FRAME="$(gettext 'Complete')"
  22. ;;
  23. info)
  24. ICON=/usr/share/pixmaps/puppy/dialog-info.svg
  25. ICON_WM=gtk-info
  26. FRAME="$(gettext 'Info')"
  27. ;;
  28. error)
  29. ICON=/usr/share/pixmaps/puppy/dialog-error.svg
  30. ICON_WM=gtk-no
  31. FRAME="$(gettext 'Error')"
  32. ;;
  33. warning)
  34. ICON=/usr/share/pixmaps/puppy/dialog-warning.svg
  35. ICON_WM=gtk-no
  36. FRAME="$(gettext 'Warning')"
  37. ;;
  38. *)
  39. ICON="$2"
  40. ICON_WM=gtk-about
  41. FRAME=""
  42. ;;
  43. esac
  44. S='
  45. <window title="'$HEADING'" icon-name="'$ICON_WM'">
  46. <vbox space-expand="true" space-fill="true">
  47. <frame '$FRAME'>
  48. <hbox homogeneous="true">
  49. '"`/usr/lib/gtkdialog/xml_pixmap "$ICON" popup`"'
  50. </hbox>
  51. <hbox border-width="10" homogeneous="true">
  52. <vbox space-expand="false" space-fill="false">'
  53. [ "$3" ] && S=$S'<text xalign="0" use-markup="true"><label>"'$3'"</label></text>'
  54. [ "$4" ] && S=$S'<text xalign="0" use-markup="true"><label>"'$4'"</label></text>'
  55. [ "$5" ] && S=$S'<text xalign="0" use-markup="true"><label>"'$5'"</label></text>'
  56. [ "$6" ] && S=$S'<text xalign="0" use-markup="true"><label>"'$6'"</label></text>'
  57. [ "$7" ] && S=$S'<text xalign="0" use-markup="true"><label>"'$7'"</label></text>'
  58. [ "$8" ] && S=$S'<text xalign="0" use-markup="true"><label>"'$8'"</label></text>'
  59. [ "$9" ] && S=$S'<text xalign="0" use-markup="true"><label>"'$9'"</label></text>'
  60. [ "${10}" ] && S=$S'<text xalign="0" use-markup="true"><label>"'${10}'"</label></text>'
  61. [ "${11}" ] && S=$S'<text xalign="0" use-markup="true"><label>"'${11}'"</label></text>'
  62. S=$S'</vbox>
  63. </hbox>
  64. </frame>
  65. <hbox space-expand="false" space-fill="false">
  66. <button>
  67. '"`/usr/lib/gtkdialog/xml_button-icon ok`"'
  68. <label>" '$(gettext 'Ok')' "</label>
  69. </button>
  70. </hbox>
  71. </vbox>
  72. </window>'
  73. export box_ok="$S"
  74. gtkdialog --center -p box_ok