xml_button-icon 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. #this generates xml code for a gtkdialog gui.
  3. #it is NOT a standalone window
  4. #
  5. #the reason for using this template is to control icon-height for all buttons in all apps by setting HEIGHT here
  6. #
  7. #usage :
  8. # xml_button-icon ICON SIZE
  9. #
  10. # ICON can either be a gtk stock icon, a normal raster/vector file or no icon. if no path is set, /usr/share/pixmaps/puppy/ is used
  11. # SIZE can be popup, mini, big or huge. Anything else sets size to buttonsize
  12. #
  13. #Sigmund Berglund, dec 2013
  14. #GPL
  15. #either use Puppy-stock icons (puppy) or Gtk-stock icons (gtk)
  16. STOCK=puppy
  17. #STOCK=gtk
  18. #define icon
  19. case $1 in
  20. /*svg)
  21. #icon from svg file
  22. ICON="<input file>${1}</input>"
  23. ;;
  24. *.svg)
  25. #icon from puppy stock
  26. ICON="<input file>/usr/share/pixmaps/puppy/${1}</input>"
  27. ;;
  28. /*)
  29. #icon from file
  30. ICON="<input file>${1}</input>"
  31. ;;
  32. 0|none|' '|'')
  33. ICON=""
  34. ;;
  35. *)
  36. #stock icon - use either Gtk-stock or Pyppy-stock
  37. if [ "$STOCK" = "puppy" ] && [ -s "/usr/share/pixmaps/puppy/${1}.svg" ]; then
  38. ICON="<input file>/usr/share/pixmaps/puppy/${1}.svg</input>"
  39. else
  40. ICON="<input file stock=\"gtk-${1}\"></input>"
  41. fi
  42. esac
  43. #read config if exist
  44. [ -s $HOME/.config/ptheme/gtkdialog_active ] && . $HOME/.config/ptheme/gtkdialog_active
  45. [ ! "$XML_BUTTON_ICON_HEIGHT_HUGE" ] && XML_BUTTON_ICON_HEIGHT_HUGE=60
  46. [ ! "$XML_BUTTON_ICON_HEIGHT_BIG" ] && XML_BUTTON_ICON_HEIGHT_BIG=35
  47. [ ! "$XML_BUTTON_ICON_HEIGHT_MINI" ] && XML_BUTTON_ICON_HEIGHT_MINI=16
  48. [ ! "$XML_BUTTON_ICON_HEIGHT_NORMAL" ] && XML_BUTTON_ICON_HEIGHT_NORMAL=20
  49. if [ "$ICON" ]; then
  50. case $2 in
  51. huge)
  52. HEIGHT="<height>${XML_BUTTON_ICON_HEIGHT_HUGE}</height>"
  53. ;;
  54. big)
  55. HEIGHT="<height>${XML_BUTTON_ICON_HEIGHT_BIG}</height>"
  56. ;;
  57. mini)
  58. HEIGHT="<height>${XML_BUTTON_ICON_HEIGHT_MINI}</height>"
  59. ;;
  60. *)
  61. HEIGHT="<height>${XML_BUTTON_ICON_HEIGHT_NORMAL}</height>"
  62. ;;
  63. esac
  64. fi
  65. #generate XML code
  66. echo "$ICON $HEIGHT"