GdlStock.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2004 Todd Berman <tberman@off.net>
  5. * Copyright (C) 2004 Jeroen Zwartepoorte <jeroen@xs4all.nl>
  6. * Copyright (C) 2005 John Luke <john.luke@gmail.com>
  7. *
  8. * based on work by:
  9. * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place - Suite 330,
  24. * Boston, MA 02111-1307, USA.
  25. */
  26. using System;
  27. using Gtk;
  28. namespace Gdl
  29. {
  30. public class GdlStock
  31. {
  32. static Gtk.IconFactory stock = new Gtk.IconFactory ();
  33. public static string Close {
  34. get { return "gdl-close"; }
  35. }
  36. public static string MenuLeft {
  37. get { return "gdl-menu-left"; }
  38. }
  39. public static string MenuRight {
  40. get { return "gdl-menu-right"; }
  41. }
  42. static GdlStock ()
  43. {
  44. AddIcon ("gdl-close", "stock-close-12.png");
  45. AddIcon ("gdl-menu-left", "stock-menu-left-12.png");
  46. AddIcon ("gdl-menu-right", "stock-menu-right-12.png");
  47. stock.AddDefault ();
  48. }
  49. static void AddIcon (string stockid, string resource)
  50. {
  51. Gtk.IconSet iconset = stock.Lookup (stockid);
  52. if (iconset == null) {
  53. iconset = new Gtk.IconSet ();
  54. Gdk.Pixbuf img = Gdk.Pixbuf.LoadFromResource (resource);
  55. IconSource source = new IconSource ();
  56. source.Size = Gtk.IconSize.Menu;
  57. source.SizeWildcarded = false;
  58. source.Pixbuf = img;
  59. iconset.AddSource (source);
  60. stock.Add (stockid, iconset);
  61. }
  62. }
  63. }
  64. }