1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  An icon source contains a Gdk_Pixbuf (or image filename) that serves as 
  26. --  the base image for one or more of the icons in an icon set, along with a 
  27. --  specification for which icons in the icon set will be based on that pixbuf 
  28. --  or image file. An icon set contains a set of icons that represent "the 
  29. --  same" logical concept in different states, different global text 
  30. --  directions, and different sizes. 
  31. -- 
  32. --  So for example a web browser's "Back to Previous Page" icon might point in 
  33. --  a different direction in Hebrew and in English; it might look different 
  34. --  when insensitive; and it might change size depending on toolbar mode 
  35. --  (small/large icons). So a single icon set would contain all those variants 
  36. --  of the icon. An icon set contains a list of icon sources from which it can 
  37. --  derive specific icon variants in the set. 
  38. -- 
  39. --  In the simplest case, an icon set contains one source pixbuf from which it 
  40. --  derives all variants. 
  41. -- 
  42. --  If you want to use a different base pixbuf for different icon variants, 
  43. --  you create multiple icon sources, mark which variants they'll be used to 
  44. --  create, and add them to the icon set with Add_Source (see below). 
  45. -- 
  46. --  By default, the icon source has all parameters wildcarded. That is, the 
  47. --  icon source will be used as the base icon for any desired text direction, 
  48. --  widget state, or icon size. 
  49. -- 
  50. --  </description> 
  51. pragma Ada_2005; 
  52.  
  53. pragma Warnings (Off, "*is already use-visible*"); 
  54. with Gdk.Pixbuf; use Gdk.Pixbuf; 
  55. with Glib;       use Glib; 
  56. with Gtk.Enums;  use Gtk.Enums; 
  57.  
  58. package Gtk.Icon_Source is 
  59.  
  60.    type Gtk_Icon_Source is new Glib.C_Boxed with null record; 
  61.    Null_Gtk_Icon_Source : constant Gtk_Icon_Source; 
  62.  
  63.    function From_Object (Object : System.Address) return Gtk_Icon_Source; 
  64.    function From_Object_Free (B : access Gtk_Icon_Source'Class) return Gtk_Icon_Source; 
  65.    pragma Inline (From_Object_Free, From_Object); 
  66.  
  67.    ------------------ 
  68.    -- Constructors -- 
  69.    ------------------ 
  70.  
  71.    procedure Gtk_New (Self : out Gtk_Icon_Source); 
  72.    --  Creates a new Gtk.Icon_Source.Gtk_Icon_Source. A 
  73.    --  Gtk.Icon_Source.Gtk_Icon_Source contains a Gdk.Pixbuf.Gdk_Pixbuf (or 
  74.    --  image filename) that serves as the base image for one or more of the 
  75.    --  icons in a Gtk.Icon_Set.Gtk_Icon_Set, along with a specification for 
  76.    --  which icons in the icon set will be based on that pixbuf or image file. 
  77.    --  An icon set contains a set of icons that represent "the same" logical 
  78.    --  concept in different states, different global text directions, and 
  79.    --  different sizes. 
  80.    --  So for example a web browser's "Back to Previous Page" icon might point 
  81.    --  in a different direction in Hebrew and in English; it might look 
  82.    --  different when insensitive; and it might change size depending on 
  83.    --  toolbar mode (small/large icons). So a single icon set would contain all 
  84.    --  those variants of the icon. Gtk.Icon_Set.Gtk_Icon_Set contains a list of 
  85.    --  Gtk.Icon_Source.Gtk_Icon_Source from which it can derive specific icon 
  86.    --  variants in the set. 
  87.    --  In the simplest case, Gtk.Icon_Set.Gtk_Icon_Set contains one source 
  88.    --  pixbuf from which it derives all variants. The convenience function 
  89.    --  gtk_icon_set_new_from_pixbuf handles this case; if you only have one 
  90.    --  source pixbuf, just use that function. 
  91.    --  If you want to use a different base pixbuf for different icon variants, 
  92.    --  you create multiple icon sources, mark which variants they'll be used to 
  93.    --  create, and add them to the icon set with Gtk.Icon_Set.Add_Source. 
  94.    --  By default, the icon source has all parameters wildcarded. That is, the 
  95.    --  icon source will be used as the base icon for any desired text 
  96.    --  direction, widget state, or icon size. 
  97.  
  98.    function Gtk_Icon_Source_New return Gtk_Icon_Source; 
  99.    --  Creates a new Gtk.Icon_Source.Gtk_Icon_Source. A 
  100.    --  Gtk.Icon_Source.Gtk_Icon_Source contains a Gdk.Pixbuf.Gdk_Pixbuf (or 
  101.    --  image filename) that serves as the base image for one or more of the 
  102.    --  icons in a Gtk.Icon_Set.Gtk_Icon_Set, along with a specification for 
  103.    --  which icons in the icon set will be based on that pixbuf or image file. 
  104.    --  An icon set contains a set of icons that represent "the same" logical 
  105.    --  concept in different states, different global text directions, and 
  106.    --  different sizes. 
  107.    --  So for example a web browser's "Back to Previous Page" icon might point 
  108.    --  in a different direction in Hebrew and in English; it might look 
  109.    --  different when insensitive; and it might change size depending on 
  110.    --  toolbar mode (small/large icons). So a single icon set would contain all 
  111.    --  those variants of the icon. Gtk.Icon_Set.Gtk_Icon_Set contains a list of 
  112.    --  Gtk.Icon_Source.Gtk_Icon_Source from which it can derive specific icon 
  113.    --  variants in the set. 
  114.    --  In the simplest case, Gtk.Icon_Set.Gtk_Icon_Set contains one source 
  115.    --  pixbuf from which it derives all variants. The convenience function 
  116.    --  gtk_icon_set_new_from_pixbuf handles this case; if you only have one 
  117.    --  source pixbuf, just use that function. 
  118.    --  If you want to use a different base pixbuf for different icon variants, 
  119.    --  you create multiple icon sources, mark which variants they'll be used to 
  120.    --  create, and add them to the icon set with Gtk.Icon_Set.Add_Source. 
  121.    --  By default, the icon source has all parameters wildcarded. That is, the 
  122.    --  icon source will be used as the base icon for any desired text 
  123.    --  direction, widget state, or icon size. 
  124.  
  125.    function Get_Type return Glib.GType; 
  126.    pragma Import (C, Get_Type, "gtk_icon_source_get_type"); 
  127.  
  128.    ------------- 
  129.    -- Methods -- 
  130.    ------------- 
  131.  
  132.    function Copy (Self : Gtk_Icon_Source) return Gtk_Icon_Source; 
  133.    --  Creates a copy of Source; mostly useful for language bindings. 
  134.  
  135.    procedure Free (Self : Gtk_Icon_Source); 
  136.    --  Frees a dynamically-allocated icon source, along with its filename, 
  137.    --  size, and pixbuf fields if those are not null. 
  138.  
  139.    function Get_Direction 
  140.       (Self : Gtk_Icon_Source) return Gtk.Enums.Gtk_Text_Direction; 
  141.    --  Obtains the text direction this icon source applies to. The return 
  142.    --  value is only useful/meaningful if the text direction is *not* 
  143.    --  wildcarded. 
  144.  
  145.    procedure Set_Direction 
  146.       (Self      : Gtk_Icon_Source; 
  147.        Direction : Gtk.Enums.Gtk_Text_Direction); 
  148.    --  Sets the text direction this icon source is intended to be used with. 
  149.    --  Setting the text direction on an icon source makes no difference if the 
  150.    --  text direction is wildcarded. Therefore, you should usually call 
  151.    --  Gtk.Icon_Source.Set_Direction_Wildcarded to un-wildcard it in addition 
  152.    --  to calling this function. 
  153.    --  "direction": text direction this source applies to 
  154.  
  155.    function Get_Direction_Wildcarded (Self : Gtk_Icon_Source) return Boolean; 
  156.    --  Gets the value set by Gtk.Icon_Source.Set_Direction_Wildcarded. 
  157.  
  158.    procedure Set_Direction_Wildcarded 
  159.       (Self    : Gtk_Icon_Source; 
  160.        Setting : Boolean); 
  161.    --  If the text direction is wildcarded, this source can be used as the 
  162.    --  base image for an icon in any Gtk.Enums.Gtk_Text_Direction. If the text 
  163.    --  direction is not wildcarded, then the text direction the icon source 
  164.    --  applies to should be set with Gtk.Icon_Source.Set_Direction, and the 
  165.    --  icon source will only be used with that text direction. 
  166.    --  Gtk.Icon_Set.Gtk_Icon_Set prefers non-wildcarded sources (exact 
  167.    --  matches) over wildcarded sources, and will use an exact match when 
  168.    --  possible. 
  169.    --  "setting": True to wildcard the text direction 
  170.  
  171.    function Get_Filename (Self : Gtk_Icon_Source) return UTF8_String; 
  172.    --  Retrieves the source filename, or null if none is set. The filename is 
  173.    --  not a copy, and should not be modified or expected to persist beyond the 
  174.    --  lifetime of the icon source. 
  175.  
  176.    procedure Set_Filename (Self : Gtk_Icon_Source; Filename : UTF8_String); 
  177.    --  Sets the name of an image file to use as a base image when creating 
  178.    --  icon variants for Gtk.Icon_Set.Gtk_Icon_Set. The filename must be 
  179.    --  absolute. 
  180.    --  "filename": image file to use 
  181.  
  182.    function Get_Icon_Name (Self : Gtk_Icon_Source) return UTF8_String; 
  183.    --  Retrieves the source icon name, or null if none is set. The icon_name 
  184.    --  is not a copy, and should not be modified or expected to persist beyond 
  185.    --  the lifetime of the icon source. 
  186.  
  187.    procedure Set_Icon_Name 
  188.       (Self      : Gtk_Icon_Source; 
  189.        Icon_Name : UTF8_String := ""); 
  190.    --  Sets the name of an icon to look up in the current icon theme to use as 
  191.    --  a base image when creating icon variants for Gtk.Icon_Set.Gtk_Icon_Set. 
  192.    --  "icon_name": name of icon to use 
  193.  
  194.    function Get_Pixbuf (Self : Gtk_Icon_Source) return Gdk.Pixbuf.Gdk_Pixbuf; 
  195.    --  Retrieves the source pixbuf, or null if none is set. In addition, if a 
  196.    --  filename source is in use, this function in some cases will return the 
  197.    --  pixbuf from loaded from the filename. This is, for example, true for the 
  198.    --  GtkIconSource passed to the GtkStyle::render_icon virtual function. The 
  199.    --  reference count on the pixbuf is not incremented. 
  200.  
  201.    procedure Set_Pixbuf 
  202.       (Self   : Gtk_Icon_Source; 
  203.        Pixbuf : not null access Gdk.Pixbuf.Gdk_Pixbuf_Record'Class); 
  204.    --  Sets a pixbuf to use as a base image when creating icon variants for 
  205.    --  Gtk.Icon_Set.Gtk_Icon_Set. 
  206.    --  "pixbuf": pixbuf to use as a source 
  207.  
  208.    function Get_Size (Self : Gtk_Icon_Source) return Gtk.Enums.Gtk_Icon_Size; 
  209.    --  Obtains the icon size this source applies to. The return value is only 
  210.    --  useful/meaningful if the icon size is *not* wildcarded. 
  211.  
  212.    procedure Set_Size 
  213.       (Self : Gtk_Icon_Source; 
  214.        Size : Gtk.Enums.Gtk_Icon_Size); 
  215.    --  Sets the icon size this icon source is intended to be used with. 
  216.    --  Setting the icon size on an icon source makes no difference if the size 
  217.    --  is wildcarded. Therefore, you should usually call 
  218.    --  Gtk.Icon_Source.Set_Size_Wildcarded to un-wildcard it in addition to 
  219.    --  calling this function. 
  220.    --  "size": icon size this source applies to 
  221.  
  222.    function Get_Size_Wildcarded (Self : Gtk_Icon_Source) return Boolean; 
  223.    --  Gets the value set by Gtk.Icon_Source.Set_Size_Wildcarded. 
  224.  
  225.    procedure Set_Size_Wildcarded (Self : Gtk_Icon_Source; Setting : Boolean); 
  226.    --  If the icon size is wildcarded, this source can be used as the base 
  227.    --  image for an icon of any size. If the size is not wildcarded, then the 
  228.    --  size the source applies to should be set with Gtk.Icon_Source.Set_Size 
  229.    --  and the icon source will only be used with that specific size. 
  230.    --  Gtk.Icon_Set.Gtk_Icon_Set prefers non-wildcarded sources (exact 
  231.    --  matches) over wildcarded sources, and will use an exact match when 
  232.    --  possible. 
  233.    --  Gtk.Icon_Set.Gtk_Icon_Set will normally scale wildcarded source images 
  234.    --  to produce an appropriate icon at a given size, but will not change the 
  235.    --  size of source images that match exactly. 
  236.    --  "setting": True to wildcard the widget state 
  237.  
  238.    function Get_State 
  239.       (Self : Gtk_Icon_Source) return Gtk.Enums.Gtk_State_Type; 
  240.    --  Obtains the widget state this icon source applies to. The return value 
  241.    --  is only useful/meaningful if the widget state is *not* wildcarded. 
  242.  
  243.    procedure Set_State 
  244.       (Self  : Gtk_Icon_Source; 
  245.        State : Gtk.Enums.Gtk_State_Type); 
  246.    --  Sets the widget state this icon source is intended to be used with. 
  247.    --  Setting the widget state on an icon source makes no difference if the 
  248.    --  state is wildcarded. Therefore, you should usually call 
  249.    --  Gtk.Icon_Source.Set_State_Wildcarded to un-wildcard it in addition to 
  250.    --  calling this function. 
  251.    --  "state": widget state this source applies to 
  252.  
  253.    function Get_State_Wildcarded (Self : Gtk_Icon_Source) return Boolean; 
  254.    --  Gets the value set by Gtk.Icon_Source.Set_State_Wildcarded. 
  255.  
  256.    procedure Set_State_Wildcarded 
  257.       (Self    : Gtk_Icon_Source; 
  258.        Setting : Boolean); 
  259.    --  If the widget state is wildcarded, this source can be used as the base 
  260.    --  image for an icon in any Gtk.Enums.Gtk_State_Type. If the widget state 
  261.    --  is not wildcarded, then the state the source applies to should be set 
  262.    --  with Gtk.Icon_Source.Set_State and the icon source will only be used 
  263.    --  with that specific state. 
  264.    --  Gtk.Icon_Set.Gtk_Icon_Set prefers non-wildcarded sources (exact 
  265.    --  matches) over wildcarded sources, and will use an exact match when 
  266.    --  possible. 
  267.    --  Gtk.Icon_Set.Gtk_Icon_Set will normally transform wildcarded source 
  268.    --  images to produce an appropriate icon for a given state, for example 
  269.    --  lightening an image on prelight, but will not modify source images that 
  270.    --  match exactly. 
  271.    --  "setting": True to wildcard the widget state 
  272.  
  273. private 
  274.  
  275.    Null_Gtk_Icon_Source : constant Gtk_Icon_Source := (Glib.C_Boxed with null record); 
  276.  
  277. end Gtk.Icon_Source;