1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                    Copyright (C) 2010, AdaCore                    -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- -- -- -- -- -- -- -- -- -- -- --
  22. ----------------------------------------------------------------------- 
  23.  
  24. --  <description> 
  25. --  The "system tray" or notification area is normally used for transient icons 
  26. --  that indicate some special state. For example, a system tray icon might 
  27. --  appear to tell the user that they have new mail, or have an incoming 
  28. --  instant message, or something along those lines. The basic idea is that 
  29. --  creating an icon in the notification area is less annoying than popping up 
  30. --  a dialog. 
  31. -- 
  32. --  A Gtk_Status_Icon object can be used to display an icon in a "system tray". 
  33. --  The icon can have a tooltip, and the user can interact with it by 
  34. --  activating it or popping up a context menu. Critical information should not 
  35. --  solely be displayed in a Gtk_Status_Icon, since it may not be visible 
  36. --  (e.g. when the user doesn't have a notification area on his panel). This 
  37. --  can be checked with Is_Embedded. 
  38. -- 
  39. --  On X11, the implementation follows the freedesktop.org "System Tray" 
  40. --  specification. Implementations of the "tray" side of this specification can 
  41. --  be found e.g. in the GNOME and KDE panel applications. 
  42. -- 
  43. --  Note that a Gtk_Status_Icon is not a widget, but just a GObject. Making it 
  44. --  a widget would be impractical, since the system tray on Win32 doesn't allow 
  45. --  to embed arbitrary widgets. 
  46. --  </description> 
  47. --  <c_version>2.16.6</c_version> 
  48.  
  49. with Glib.G_Icon; 
  50. with Glib.Object; 
  51. with Glib.Properties; 
  52. with Gdk.Pixbuf; 
  53. with Gdk.Rectangle; 
  54. with Gdk.Screen; 
  55. with Gtk.Enums; 
  56. with Gtk.Image; 
  57.  
  58. package Gtk.Status_Icon is 
  59.  
  60.    type Gtk_Status_Icon_Record is new Glib.Object.GObject_Record with private; 
  61.    type Gtk_Status_Icon is access all Gtk_Status_Icon_Record'Class; 
  62.  
  63.    function Get_Type return GType; 
  64.  
  65.    procedure Gtk_New (Widget : out Gtk_Status_Icon); 
  66.    procedure Initialize (Widget : access Gtk_Status_Icon_Record'Class); 
  67.    --  Creates an empty status icon object. 
  68.  
  69.    function Get_Storage_Type 
  70.      (Status_Icon : access Gtk_Status_Icon_Record) 
  71.       return Gtk.Image.Gtk_Image_Type; 
  72.    --  Gets the type of representation being used by the Gtk_Status_Icon 
  73.    --  to store image data. If the Gtk_Status_Icon has no image data, 
  74.    --  the return value will be Image_Empty. 
  75.  
  76.    function Is_Embedded 
  77.      (Status_Icon : access Gtk_Status_Icon_Record) return Boolean; 
  78.    --  Returns whether the status icon is embedded in a notification 
  79.    --  area. 
  80.  
  81.    ---------- 
  82.    -- File -- 
  83.    ---------- 
  84.  
  85.    procedure Gtk_New_From_File 
  86.      (Widget   : out Gtk_Status_Icon; 
  87.       Filename : String); 
  88.    procedure Initialize_From_File 
  89.      (Widget   : access Gtk_Status_Icon_Record'Class; 
  90.       Filename : String); 
  91.    --  Creates a status icon displaying the file Filename. 
  92.    -- 
  93.    --  The image will be scaled down to fit in the available 
  94.    --  space in the notification area, if necessary. 
  95.  
  96.    procedure Set_From_File 
  97.      (Status_Icon : access Gtk_Status_Icon_Record; 
  98.       Filename    : String); 
  99.    --  Makes Status_Icon display the file Filename. 
  100.    --  See Gtk_New_From_File for details. 
  101.  
  102.    ------------ 
  103.    -- G_Icon -- 
  104.    ------------ 
  105.  
  106.    procedure Gtk_New_From_Gicon 
  107.      (Widget : out Gtk_Status_Icon; 
  108.       Icon   : Glib.G_Icon.G_Icon); 
  109.    procedure Initialize_From_Gicon 
  110.      (Widget : access Gtk_Status_Icon_Record'Class; 
  111.       Icon   : Glib.G_Icon.G_Icon); 
  112.    --  Creates a status icon displaying a G_Icon. If the icon is a 
  113.    --  themed icon, it will be updated when the theme changes. 
  114.  
  115.    function Get_Gicon 
  116.      (Status_Icon : access Gtk_Status_Icon_Record) return Glib.G_Icon.G_Icon; 
  117.    --  Retrieves the G_Icon being displayed by the Gtk_Status_Icon. 
  118.    --  The storage type of the status icon must be Image_Empty or 
  119.    --  Image_Gicon (see Get_Storage_Type). 
  120.    --  The caller of this function does not own a reference to the 
  121.    --  returned G_Icon. 
  122.    -- 
  123.    --  Status_Icon is left unchanged if this function fails.  Returns 
  124.    --  null if the image is empty. 
  125.  
  126.    procedure Set_From_Gicon 
  127.      (Status_Icon : access Gtk_Status_Icon_Record; 
  128.       Icon        : Glib.G_Icon.G_Icon); 
  129.    --  Makes Status_Icon display the G_Icon. 
  130.    --  See Gtk_New_From_G_Icon for details. 
  131.  
  132.    --------------- 
  133.    -- Icon_Name -- 
  134.    --------------- 
  135.  
  136.    procedure Gtk_New_From_Icon_Name 
  137.      (Widget    : out Gtk_Status_Icon; 
  138.       Icon_Name : String); 
  139.    procedure Initialize_From_Icon_Name 
  140.      (Widget    : access Gtk_Status_Icon_Record'Class; 
  141.       Icon_Name : String); 
  142.    --  Creates a status icon displaying an icon from the current icon theme. 
  143.    --  If the current icon theme is changed, the icon will be updated 
  144.    --  appropriately. 
  145.  
  146.    function Get_Icon_Name 
  147.      (Status_Icon : access Gtk_Status_Icon_Record) return String; 
  148.    --  Gets the name of the icon being displayed by the Gtk_Status_Icon. 
  149.    --  The storage type of the status icon must be Image_Empty or 
  150.    --  Image_Icon_Name (see Get_Storage_Type).  Returns "" if the image 
  151.    --  is empty. 
  152.  
  153.    procedure Set_From_Icon_Name 
  154.      (Status_Icon : access Gtk_Status_Icon_Record; 
  155.       Icon_Name   : String); 
  156.    --  Makes Status_Icon display the icon named Icon_Name from the 
  157.    --  current icon theme. 
  158.    --  See Gtk_New_From_Icon_Name for details. 
  159.  
  160.    ------------ 
  161.    -- Pixbuf -- 
  162.    ------------ 
  163.  
  164.    procedure Gtk_New_From_Pixbuf 
  165.      (Widget : out Gtk_Status_Icon; 
  166.       Pixbuf : Gdk.Pixbuf.Gdk_Pixbuf); 
  167.    procedure Initialize_From_Pixbuf 
  168.      (Widget : access Gtk_Status_Icon_Record'Class; 
  169.       Pixbuf : Gdk.Pixbuf.Gdk_Pixbuf); 
  170.    --  Creates a status icon displaying Pixbuf. 
  171.    -- 
  172.    --  The image will be scaled down to fit in the available 
  173.    --  space in the notification area, if necessary. 
  174.  
  175.    function Get_Pixbuf 
  176.      (Status_Icon : access Gtk_Status_Icon_Record) 
  177.       return Gdk.Pixbuf.Gdk_Pixbuf; 
  178.    --  Gets the Gdk_Pixbuf being displayed by the Gtk_Status_Icon. 
  179.    --  The storage type of the status icon must be Gtk_Image_Empty 
  180.    --  (in which case this function will return null) or Gtk_Image_Pixbuf 
  181.    --  (see Get_Storage_Type).  The caller of this function does not own 
  182.    --  a reference to the returned pixbuf. 
  183.  
  184.    procedure Set_From_Pixbuf 
  185.      (Status_Icon : access Gtk_Status_Icon_Record; 
  186.       Pixbuf      : Gdk.Pixbuf.Gdk_Pixbuf); 
  187.    --  Makes Status_Icon display Pixbuf. 
  188.    --  See Gtk_New_From_Pixbuf for details. 
  189.  
  190.    ----------- 
  191.    -- Stock -- 
  192.    ----------- 
  193.  
  194.    procedure Gtk_New_From_Stock 
  195.      (Widget   : out Gtk_Status_Icon; 
  196.       Stock_Id : String); 
  197.    procedure Initialize_From_Stock 
  198.      (Widget   : access Gtk_Status_Icon_Record'Class; 
  199.       Stock_Id : String); 
  200.    --  Creates a status icon displaying a stock icon. Sample stock icon 
  201.    --  names are "GTK_STOCK_OPEN", "GTK_STOCK_QUIT". You can register your 
  202.    --  own stock icon names, see Gtk.Icon_Factory.Add_Default and 
  203.    --  Gtk.Icon_Factory.Add. 
  204.  
  205.    function Get_Stock 
  206.      (Status_Icon : access Gtk_Status_Icon_Record) return String; 
  207.    --  Gets the id of the stock icon being displayed by the Gtk_Status_Icon. 
  208.    --  The storage type of the status icon must be Image_Empty or 
  209.    --  Image_Stock (see Get_Storage_Type).  Returns "" if the image is empty. 
  210.  
  211.    procedure Set_From_Stock 
  212.      (Status_Icon : access Gtk_Status_Icon_Record; 
  213.       Stock_Id    : String); 
  214.    --  Makes Status_Icon display the stock icon with the id Stock_Id. 
  215.    --  See Gtk_New_From_Stock for details. 
  216.  
  217.    -------------- 
  218.    -- Tooltips -- 
  219.    -------------- 
  220.  
  221.    function Get_Has_Tooltip 
  222.      (Status_Icon : access Gtk_Status_Icon_Record) return Boolean; 
  223.    procedure Set_Has_Tooltip 
  224.      (Status_Icon : access Gtk_Status_Icon_Record; 
  225.       Has_Tooltip : Boolean); 
  226.    --  Gets/Sets the has-tooltip property on Status_Icon. 
  227.    --  See has-tooltip for more information. 
  228.  
  229.    function Get_Tooltip_Markup 
  230.      (Status_Icon : access Gtk_Status_Icon_Record) return String; 
  231.    procedure Set_Tooltip_Markup 
  232.      (Status_Icon : access Gtk_Status_Icon_Record; 
  233.       Markup      : String); 
  234.    --  Gets/Sets Markup as the contents of the tooltip, which is marked up with 
  235.    --  the Pango text markup language.  "" means no tooltip. 
  236.    -- 
  237.    --  Set_Tooltip_Markup function will take care of setting has-tooltip to 
  238.    --  True and of the default handler for the query-tooltip signal. 
  239.    -- 
  240.    --  See also the tooltip-markup property. 
  241.  
  242.    function Get_Tooltip_Text 
  243.      (Status_Icon : access Gtk_Status_Icon_Record) return String; 
  244.    procedure Set_Tooltip_Text 
  245.      (Status_Icon : access Gtk_Status_Icon_Record; 
  246.       Text        : String); 
  247.    --  Gets/Sets the contents of the tooltip.  "" means no tooltip. 
  248.    -- 
  249.    --  This function will take care of setting has-tooltip to 
  250.    --  True and of the default handler for the query-tooltip 
  251.    --  signal. 
  252.    -- 
  253.    --  See also the tooltip-text property. 
  254.  
  255.    ------------- 
  256.    -- Display -- 
  257.    ------------- 
  258.  
  259.    procedure Get_Geometry 
  260.      (Status_Icon : access Gtk_Status_Icon_Record; 
  261.       Screen      : in out Gdk.Screen.Gdk_Screen; 
  262.       Area        : out Gdk.Rectangle.Gdk_Rectangle; 
  263.       Orientation : out Gtk.Enums.Gtk_Orientation; 
  264.       Success     : out Boolean); 
  265.    --  Status_Icon: a Gtk_Status_Icon 
  266.    --  Screen:      a valid Gdk_Screen or null if the information is not needed 
  267.    --  Area:        area occupied by the status icon 
  268.    --  Orientation: the orientation of the panel in which the status icon is 
  269.    --               embedded. A panel at the top or bottom of the screen is 
  270.    --               horizontal, a panel at the left or right is vertical. 
  271.    --  Success:     True if the location information has been filled in. 
  272.    -- 
  273.    --  Obtains information about the location of the status icon 
  274.    --  on screen. This information can be used to e.g. position 
  275.    --  popups like notification bubbles. 
  276.    -- 
  277.    --  See Position_Menu for a more convenient alternative for positioning 
  278.    --  menus. 
  279.    -- 
  280.    --  Note that some platforms do not allow GTK+ to provide 
  281.    --  this information, and even on platforms that do allow it, 
  282.    --  the information is not reliable unless the status icon 
  283.    --  is embedded in a notification area, see Is_Embedded. 
  284.  
  285.    function Get_Blinking 
  286.      (Status_Icon : access Gtk_Status_Icon_Record) return Boolean; 
  287.    procedure Set_Blinking 
  288.      (Status_Icon : access Gtk_Status_Icon_Record; 
  289.       Blinking    : Boolean); 
  290.    --  Makes the status icon start or stop blinking. 
  291.    --  Note that blinking user interface elements may be problematic 
  292.    --  for some users, and thus may be turned off, in which case 
  293.    --  this setting has no effect. 
  294.  
  295.    function Get_Screen 
  296.      (Status_Icon : access Gtk_Status_Icon_Record) 
  297.       return Gdk.Screen.Gdk_Screen; 
  298.    procedure Set_Screen 
  299.      (Status_Icon : access Gtk_Status_Icon_Record; 
  300.       Screen      : access Gdk.Screen.Gdk_Screen_Record'Class); 
  301.    --  Gets/Sets the Gdk_Screen where Status_Icon is displayed.  When invoking 
  302.    --  Set_Screen, if the icon is already mapped, it will be unmapped, and then 
  303.    --  remapped on the new screen. 
  304.  
  305.    function Get_Size (Status_Icon : access Gtk_Status_Icon_Record) return Gint; 
  306.    --  Gets the size in pixels that is available for the image. 
  307.    --  Stock icons and named icons adapt their size automatically 
  308.    --  if the size of the notification area changes. For other 
  309.    --  storage types, the size-changed signal can be used to 
  310.    --  react to size changes. 
  311.    -- 
  312.    --  Note that the returned size is only meaningful while the 
  313.    --  status icon is embedded (see Is_Embedded). 
  314.  
  315.    function Get_Visible 
  316.      (Status_Icon : access Gtk_Status_Icon_Record) return Boolean; 
  317.    procedure Set_Visible 
  318.      (Status_Icon : access Gtk_Status_Icon_Record; 
  319.       Visible     : Boolean); 
  320.    --  Whether the status icon is visible or not. 
  321.    --  Note that being visible does not guarantee that 
  322.    --  the user can actually see the icon, see also 
  323.    --  Is_Embedded. 
  324.  
  325.    function Get_X11_Window_Id 
  326.      (Status_Icon : access Gtk_Status_Icon_Record) return Guint32; 
  327.    --  This function is only useful on the X11/freedesktop.org platform. 
  328.    --  It returns a window ID for the widget in the underlying 
  329.    --  status icon implementation.  This is useful for the Galago 
  330.    --  notification service, which can send a window ID in the protocol 
  331.    --  in order for the server to position notification windows 
  332.    --  pointing to a status icon reliably. 
  333.    -- 
  334.    --  This function is not intended for other use cases which are 
  335.    --  more likely to be met by one of the non-X11 specific methods, such 
  336.    --  as Position_Menu. 
  337.  
  338.    procedure Position_Menu 
  339.      (Menu        : System.Address; 
  340.       X           : out Gint; 
  341.       Y           : out Gint; 
  342.       Push_In     : out Gboolean; 
  343.       Status_Icon : System.Address); 
  344.    --  Menu positioning function to use with Gtk.Menu.Popup to position 
  345.    --  Menu aligned to Status_Icon.  Pass Get_Object (Your_Status_Icon) as 
  346.    --  User_Data when calling Gtk.Menu.Popup. 
  347.  
  348.    ----------------- 
  349.    -- Obsolescent -- 
  350.    ----------------- 
  351.  
  352.    procedure Set_Tooltip 
  353.      (Status_Icon  : access Gtk_Status_Icon_Record; 
  354.       Tooltip_Text : String); 
  355.    pragma Obsolescent; --  Set_Tooltip 
  356.    --  Sets the tooltip of the status icon. 
  357.    -- 
  358.    --  Deprecated: 2.16: Use Set_Tooltip_Text instead. 
  359.  
  360.    ---------------- 
  361.    -- Properties -- 
  362.    ---------------- 
  363.  
  364.    --  <properties> 
  365.    --  Name:  Blinking_Property 
  366.    --  Type:  Boolean 
  367.    --  Descr: Whether or not the status icon is blinking 
  368.    -- 
  369.    --  Name:  Embedded_Property 
  370.    --  Type:  Boolean 
  371.    --  Descr: Whether or not the status icon is embedded 
  372.    -- 
  373.    --  Name:  File_Property 
  374.    --  Type:  String 
  375.    --  Descr: Filename to load and display 
  376.    -- 
  377.    --  Name:  Gicon_Property 
  378.    --  Type:  Object 
  379.    --  Descr: The GIcon being displayed 
  380.    -- 
  381.    --  Name:  Has_Tooltip_Property 
  382.    --  Type:  Boolean 
  383.    --  Descr: Whether this tray icon has a tooltip 
  384.    -- 
  385.    --  Name:  Icon_Name_Property 
  386.    --  Type:  String 
  387.    --  Descr: The name of the icon from the icon theme 
  388.    -- 
  389.    --  Name:  Orientation_Property 
  390.    --  Type:  Enum 
  391.    --  Descr: The orientation of the tray 
  392.    -- 
  393.    --  Name:  Pixbuf_Property 
  394.    --  Type:  Object 
  395.    --  Descr: A Gdk_Pixbuf to display 
  396.    -- 
  397.    --  Name:  Screen_Property 
  398.    --  Type:  Object 
  399.    --  Descr: The screen where this status icon will be displayed 
  400.    -- 
  401.    --  Name:  Size_Property 
  402.    --  Type:  Int 
  403.    --  Descr: The size of the icon 
  404.    -- 
  405.    --  Name:  Stock_Property 
  406.    --  Type:  String 
  407.    --  Descr: Stock ID for a stock image to display 
  408.    -- 
  409.    --  Name:  Storage_Type_Property 
  410.    --  Type:  Enum 
  411.    --  Descr: The representation being used for image data 
  412.    -- 
  413.    --  Name:  Tooltip_Markup_Property 
  414.    --  Type:  String 
  415.    --  Descr: The contents of the tooltip for this tray icon 
  416.    -- 
  417.    --  Name:  Tooltip_Text_Property 
  418.    --  Type:  String 
  419.    --  Descr: The contents of the tooltip for this widget 
  420.    -- 
  421.    --  Name:  Visible_Property 
  422.    --  Type:  Boolean 
  423.    --  Descr: Whether or not the status icon is visible 
  424.    -- 
  425.    --  </properties> 
  426.  
  427.    Blinking_Property       : constant Glib.Properties.Property_Boolean; 
  428.    Embedded_Property       : constant Glib.Properties.Property_Boolean; 
  429.    File_Property           : constant Glib.Properties.Property_String; 
  430.    Gicon_Property          : constant Glib.Properties.Property_Object; 
  431.    Has_Tooltip_Property    : constant Glib.Properties.Property_Boolean; 
  432.    Icon_Name_Property      : constant Glib.Properties.Property_String; 
  433.    Orientation_Property    : constant Glib.Properties.Property_Enum; 
  434.    Pixbuf_Property         : constant Glib.Properties.Property_Object; 
  435.    Screen_Property         : constant Glib.Properties.Property_Object; 
  436.    Size_Property           : constant Glib.Properties.Property_Int; 
  437.    Stock_Property          : constant Glib.Properties.Property_String; 
  438.    Storage_Type_Property   : constant Glib.Properties.Property_Enum; 
  439.    Tooltip_Markup_Property : constant Glib.Properties.Property_String; 
  440.    Tooltip_Text_Property   : constant Glib.Properties.Property_String; 
  441.    Visible_Property        : constant Glib.Properties.Property_Boolean; 
  442.  
  443. private 
  444.  
  445.    type Gtk_Status_Icon_Record is 
  446.      new Glib.Object.GObject_Record with null record; 
  447.  
  448.    Blinking_Property : constant Glib.Properties.Property_Boolean := 
  449.      Glib.Properties.Build ("blinking"); 
  450.    Embedded_Property : constant Glib.Properties.Property_Boolean := 
  451.      Glib.Properties.Build ("embedded"); 
  452.    File_Property : constant Glib.Properties.Property_String := 
  453.      Glib.Properties.Build ("file"); 
  454.    Gicon_Property : constant Glib.Properties.Property_Object := 
  455.      Glib.Properties.Build ("gicon"); 
  456.    Has_Tooltip_Property : constant Glib.Properties.Property_Boolean := 
  457.      Glib.Properties.Build ("has-tooltip"); 
  458.    Icon_Name_Property : constant Glib.Properties.Property_String := 
  459.      Glib.Properties.Build ("icon-name"); 
  460.    Orientation_Property : constant Glib.Properties.Property_Enum := 
  461.      Glib.Properties.Build ("orientation"); 
  462.    Pixbuf_Property : constant Glib.Properties.Property_Object := 
  463.      Glib.Properties.Build ("pixbuf"); 
  464.    Screen_Property : constant Glib.Properties.Property_Object := 
  465.      Glib.Properties.Build ("screen"); 
  466.    Size_Property : constant Glib.Properties.Property_Int := 
  467.      Glib.Properties.Build ("size"); 
  468.    Stock_Property : constant Glib.Properties.Property_String := 
  469.      Glib.Properties.Build ("stock"); 
  470.    Storage_Type_Property : constant Glib.Properties.Property_Enum := 
  471.      Glib.Properties.Build ("storage-type"); 
  472.    Tooltip_Markup_Property : constant Glib.Properties.Property_String := 
  473.      Glib.Properties.Build ("tooltip-markup"); 
  474.    Tooltip_Text_Property : constant Glib.Properties.Property_String := 
  475.      Glib.Properties.Build ("tooltip-text"); 
  476.    Visible_Property : constant Glib.Properties.Property_Boolean := 
  477.      Glib.Properties.Build ("visible"); 
  478.  
  479.    pragma Import (C, Get_Type, "gtk_status_icon_get_type"); 
  480.    pragma Import (C, Position_Menu, "gtk_status_icon_position_menu"); 
  481.  
  482. end Gtk.Status_Icon;