/src/wrappers/gtk/library/gtk_status_icon.e

http://github.com/tybor/Liberty · Specman e · 482 lines · 219 code · 86 blank · 177 comment · 4 complexity · 1f5cbff824bfc507bf05db40033776bd MD5 · raw file

  1. indexing
  2. description: "GtkStatusIcon — Display an icon in the system tray."
  3. copyright: "[
  4. Copyright (C) 2006 Paolo Redaelli, GTK+ team
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hopeOA that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. class GTK_STATUS_ICON
  19. --The "system tray" or notification area is normally used for
  20. -- transient icons that indicate some special state. For example, a
  21. -- system tray icon might appear to tell the user that they have
  22. -- new mail, or have an incoming instant message, or something
  23. -- along those lines. The basic idea is that creating an icon in
  24. -- the notification area is less annoying than popping up a dialog.
  25. -- A GtkStatusIcon object can be used to display an icon in a
  26. -- "system tray". The icon can have a tooltip, and the user can
  27. -- interact with it by activating it or popping up a context
  28. -- menu. Critical information should not solely be displayed in a
  29. -- GtkStatusIcon, since it may not be visible (e.g. when the user
  30. -- doesn't have a notification area on his panel). This can be
  31. -- checked with `is_embedded'.
  32. -- On X11, the implementation follows the freedesktop.org "System
  33. -- Tray" specification. Implementations of the "tray" side of this
  34. -- specification can be found e.g. in the GNOME and KDE panel
  35. -- applications.
  36. -- Note that a GtkStatusIcon is not a widget, but just a
  37. -- GObject. Making it a widget would be impractical, since the
  38. -- system tray on Win32 doesn't allow to embed arbitrary widgets.
  39. inherit G_OBJECT
  40. insert
  41. GTK_IMAGE_TYPE
  42. --GTK_STATUS_ICON_EXTERNALS
  43. creation
  44. make,
  45. make_from_pixbuf,
  46. make_from_file,
  47. make_from_stock,
  48. make_from_icon_name,
  49. from_external_pointer
  50. feature {} -- Creation
  51. make is
  52. -- Creates an empty status icon object.
  53. do
  54. from_external_pointer(gtk_status_icon_new)
  55. end
  56. make_from_pixbuf (a_pixbuf: GDK_PIXBUF) is
  57. -- Creates a status icon displaying `a_pixbuf'. The image
  58. -- will be scaled down to fit in the available space in the
  59. -- notification area, if necessary.
  60. require
  61. pixbuf_not_void: a_pixbuf /= Void
  62. do
  63. from_external_pointer(gtk_status_icon_new_from_pixbuf(a_pixbuf.handle))
  64. end
  65. make_from_file (a_filename: STRING) is
  66. -- Creates a status icon displaying the file
  67. -- `a_filename'. The image will be scaled down to fit in the
  68. -- available space in the notification area, if necessary.
  69. require
  70. filename_not_void: a_filename /= Void
  71. do
  72. from_external_pointer(gtk_status_icon_new_from_file(a_filename.to_external))
  73. end
  74. make_from_stock (a_stock_id: STRING) is
  75. -- Creates a status icon displaying a stock icon. Sample
  76. -- stock icon names are GTK_STOCK_OPEN, GTK_STOCK_QUIT. You
  77. -- can register your own stock icon names, see
  78. -- `GTK_ICON_FACTORY.add_default' and `GTK_ICON_FACTORY.add'.
  79. require stock_id_not_void: a_stock_id /= Void
  80. do
  81. from_external_pointer(gtk_status_icon_new_from_stock(a_stock_id.to_external))
  82. end
  83. make_from_icon_name (an_icon_name: STRING) is
  84. -- Creates a status icon displaying an icon from the current
  85. -- icon theme. If the current icon theme is changed, the icon
  86. -- will be updated appropriately.
  87. require icon_name_not_void: an_icon_name /= Void
  88. do
  89. from_external_pointer(gtk_status_icon_new_from_icon_name(an_icon_name.to_external))
  90. end
  91. feature
  92. set_from_pixbuf (a_pixbuf: GDK_PIXBUF) is
  93. -- Display `a_pixbuf' See `make_from_pixbuf' for details.
  94. require pixbuf_not_void: a_pixbuf /= Void
  95. do
  96. gtk_status_icon_set_from_pixbuf (handle, a_pixbuf.handle)
  97. end
  98. unset_pixbuf is
  99. do
  100. gtk_status_icon_set_from_pixbuf (handle, default_pointer)
  101. end
  102. set_from_file (a_file_name: STRING) is
  103. -- Makes Current status icon display the file
  104. -- `a_file_name'. See `make_from_file' for details.
  105. require filename_not_void: a_file_name /= Void
  106. do
  107. gtk_status_icon_set_from_file (handle, a_file_name.to_external)
  108. end
  109. set_from_stock (a_stock_id: STRING) is
  110. -- Makes status icon display `a_stock_icon'. See
  111. -- `make_from_stock' for details.
  112. require stock_not_void: a_stock_id /= Void
  113. do
  114. gtk_status_icon_set_from_stock (handle, a_stock_id.to_external)
  115. end
  116. set_from_icon_name (an_icon_name: STRING) is
  117. -- Makes status icon display the icon named `an_icon_name'
  118. -- from the current icon theme. See `make_from_icon_name' for
  119. -- details.
  120. require name_not_void: an_icon_name /= Void
  121. do
  122. gtk_status_icon_set_from_icon_name (handle, an_icon_name.to_external)
  123. end
  124. storage_type: INTEGER is
  125. -- the type of representation being used by the GtkStatusIcon
  126. -- to store image data. If the GtkStatusIcon has no image
  127. -- data, the return value will be `gtk_image_empty'.
  128. do
  129. Result := gtk_status_icon_get_storage_type (handle)
  130. ensure valid_type: is_valid_gtk_image_type (Result)
  131. end
  132. pixbuf: GDK_PIXBUF is
  133. -- the displayed pixbuf, or Void if the image is
  134. -- empty. `storage_type' of the status icon must be
  135. -- `gtk_image_empty' or `gtk_image_pixbuf' (see
  136. -- `storage_type').
  137. local ptr: POINTER
  138. do
  139. ptr:=gtk_status_icon_get_pixbuf(handle)
  140. -- The caller of this function does not own a reference to
  141. -- the returned pixbuf.
  142. end
  143. stock_id: STRING is
  144. -- the id of the stock icon being displayed by the status
  145. -- icon. Void if the image is empty.
  146. require
  147. valid_storage_type: ((storage_type = gtk_image_empty) or
  148. (storage_type = gtk_image_stock))
  149. local p: POINTER
  150. do
  151. p := gtk_status_icon_get_stock (handle)
  152. if p.is_not_null then
  153. create {CONST_STRING} Result.from_external(p)
  154. end
  155. end
  156. icon_name: STRING is
  157. -- the name of the icon being displayed by the status
  158. -- icon. Void if the image is empty.
  159. require
  160. valid_storage_type: ((storage_type = gtk_image_empty) or
  161. (storage_type = gtk_image_icon_name))
  162. local ptr: POINTER
  163. do
  164. ptr := gtk_status_icon_get_icon_name (handle)
  165. if ptr.is_not_null then
  166. create {CONST_STRING} Result.from_external(ptr)
  167. end
  168. end
  169. size: INTEGER is
  170. -- the size in pixels that is available for the image. Stock
  171. -- icons and named icons adapt their size automatically if
  172. -- the size of the notification area changes. For other
  173. -- storage types, the "size-changed" signal can be used to
  174. -- react to size changes.
  175. do
  176. Result := gtk_status_icon_get_size(handle)
  177. end
  178. set_tooltip (a_tooltip_text: STRING) is
  179. -- Sets the tooltip of the status icon.
  180. require text_not_void: a_tooltip_text /= Void
  181. do
  182. gtk_status_icon_set_tooltip (handle, a_tooltip_text.to_external)
  183. end
  184. unset_tooltip is
  185. -- Unsets the tooltip of the status icon.
  186. do
  187. gtk_status_icon_set_tooltip (handle, default_pointer)
  188. end
  189. set_visible (a_setting: INTEGER) is
  190. -- Shows or hides a status icon. `a_setting' is True to show
  191. -- the status icon, False to hide it
  192. do
  193. gtk_status_icon_set_visible (handle, a_setting)
  194. end
  195. is_visible: BOOLEAN is
  196. -- Is the status icon visible? Note that being visible does
  197. -- not guarantee that the user can actually see the icon, see
  198. -- also `is_embedded'.
  199. do
  200. Result:=gtk_status_icon_get_visible(handle).to_boolean
  201. end
  202. set_blinking (a_setting: BOOLEAN) is
  203. -- Makes the status icon start or stop blinking; `a_setting'
  204. -- is True to turn blinking on, False to turn it off. Note
  205. -- that blinking user interface elements may be problematic
  206. -- for some users, and thus may be turned off, in which case
  207. -- this setting has no effect.
  208. do
  209. gtk_status_icon_set_blinking (handle, a_setting.to_integer)
  210. end
  211. is_blinking: BOOLEAN is
  212. -- Is icon blinking? See also `set_blinking'.
  213. do
  214. Result := gtk_status_icon_get_blinking(handle).to_boolean
  215. end
  216. is_embedded: BOOLEAN is
  217. -- Is the status icon embedded in a notification area?
  218. do
  219. Result := gtk_status_icon_is_embedded(handle).to_boolean
  220. end
  221. -- TODO: menu_position: TUPLE [INTEGER,INTEGER,BOOLEAN] is local
  222. --an_x, an_y, a_push_in_bool: INTEGER do
  223. --gtk_status_icon_position_menu (GtkMenu *menu, gint *x, gint *y,
  224. --gboolean *push_in, gpointer user_data);
  225. -- Menu positioning function to use with gtk_menu_popup() to position menu aligned to the status icon user_data.
  226. -- menu : the GtkMenu x : return location for the x position y :
  227. -- return location for the y position push_in : return location for
  228. -- whether the menu should be pushed in to be completely inside the
  229. -- screen instead of just clamped to the size to the screen.
  230. -- user_data : the status icon to position the menu on
  231. -- TODO: gtk_status_icon_get_geometry ()
  232. -- gboolean gtk_status_icon_get_geometry (GtkStatusIcon
  233. -- *status_icon, GdkScreen **screen, GdkRectangle *area,
  234. -- GtkOrientation *orientation);
  235. -- Obtains information about the location of the status icon on
  236. -- screen. This information can be used to e.g. position popups
  237. -- like notification bubbles.
  238. -- See gtk_status_icon_position_menu() for a more convenient
  239. -- alternative for positioning menus.
  240. -- Note that some platforms do not allow GTK+ to provide this
  241. -- information, and even on platforms that do allow it, the
  242. -- information is not reliable unless the status icon is embedded
  243. -- in a notification area, see gtk_status_icon_is_embedded().
  244. -- status_icon : a GtkStatusIcon
  245. -- screen : return location for the screen, or NULL if the information is not needed
  246. -- area : return location for the area occupied by the status icon, or NULL
  247. -- orientation : return location for the orientation of the panel in which the status icon is embedded, or NULL. A panel at the top or bottom of the screen is horizontal, a panel at the left or right is vertical.
  248. -- Returns : TRUE if the location information has been filled in
  249. feature -- TODO: Signals
  250. -- The "activate" signal
  251. -- void user_function (GtkStatusIcon *status_icon,
  252. -- gpointer user_data) : Run first / Action
  253. -- Gets emitted when the user activates the status icon. If and how status icons can activated is platform-dependent.
  254. -- status_icon : the object which received the signal
  255. -- user_data : user data set when the signal handler was connected.
  256. -- Since 2.10
  257. -- The "popup-menu" signal
  258. -- void user_function (GtkStatusIcon *status_icon,
  259. -- guint button,
  260. -- guint activate_time,
  261. -- gpointer user_data) : Run first / Action
  262. -- Gets emitted when the user brings up the context menu of the status icon. Whether status icons can have context menus and how these are activated is platform-dependent.
  263. -- The button and activate_timeout parameters should be passed as the last to arguments to gtk_menu_popup().
  264. -- status_icon : the object which received the signal
  265. -- button : the button that was pressed, or 0 if the signal is not emitted in response to a button press event
  266. -- activate_time : the timestamp of the event that triggered the signal emission
  267. -- user_data : user data set when the signal handler was connected.
  268. -- Since 2.10
  269. -- The "size-changed" signal
  270. -- gboolean user_function (GtkStatusIcon *status_icon,
  271. -- gint size,
  272. -- gpointer user_data) : Run last
  273. -- Gets emitted when the size available for the image changes, e.g. because the notification area got resized.
  274. -- status_icon : the object which received the signal
  275. -- size : the new size
  276. -- user_data : user data set when the signal handler was connected.
  277. -- Returns : TRUE if the icon was updated for the new size. Otherwise, GTK+ will scale the icon as necessary.
  278. -- Properties
  279. -- "blinking" gboolean : Read / Write
  280. -- "file" gchararray : Write
  281. -- "icon-name" gchararray : Read / Write
  282. -- "pixbuf" GdkPixbuf : Read / Write
  283. -- "size" gint : Read
  284. -- "stock" gchararray : Read / Write
  285. -- "storage-type" GtkImageType : Read
  286. -- "visible" gboolean : Read / Write
  287. -- Signals
  288. -- "activate" void user_function (GtkStatusIcon *status_icon,
  289. -- gpointer user_data) : Run first / Action
  290. -- "popup-menu"
  291. -- void user_function (GtkStatusIcon *status_icon,
  292. -- guint button,
  293. -- guint activate_time,
  294. -- gpointer user_data) : Run first / Action
  295. -- "size-changed"
  296. -- gboolean user_function (GtkStatusIcon *status_icon,
  297. -- gint size,
  298. -- gpointer user_data) : Run last
  299. feature -- size
  300. struct_size: INTEGER is
  301. external "C inline use <gtk/gtk.h>"
  302. alias "sizeof(GtkStatusIcon)"
  303. end
  304. feature {} -- External calls
  305. gtk_status_icon_new: POINTER is
  306. -- GtkStatusIcon* gtk_status_icon_new (void);
  307. external "C use <gtk/gtk.h>"
  308. end
  309. gtk_status_icon_new_from_pixbuf (a_pixbuf: POINTER): POINTER is
  310. -- GtkStatusIcon* gtk_status_icon_new_from_pixbuf (GdkPixbuf *pixbuf)
  311. external "C use <gtk/gtk.h>"
  312. end
  313. gtk_status_icon_new_from_file (a_filename: POINTER): POINTER is
  314. -- GtkStatusIcon* gtk_status_icon_new_from_file (const gchar *filename)
  315. external "C use <gtk/gtk.h>"
  316. end
  317. gtk_status_icon_new_from_stock (a_stock_id: POINTER): POINTER is
  318. -- GtkStatusIcon* gtk_status_icon_new_from_stock (const gchar *stock_id)
  319. external "C use <gtk/gtk.h>"
  320. end
  321. gtk_status_icon_new_from_icon_name (an_icon_name: POINTER): POINTER is
  322. -- GtkStatusIcon* gtk_status_icon_new_from_icon_name (const gchar *icon_name)
  323. external "C use <gtk/gtk.h>"
  324. end
  325. gtk_status_icon_set_from_pixbuf (a_status_icon, a_pixbuf: POINTER) is
  326. -- void gtk_status_icon_set_from_pixbuf (GtkStatusIcon *status_icon, GdkPixbuf *pixbuf)
  327. external "C use <gtk/gtk.h>"
  328. end
  329. gtk_status_icon_set_from_file (a_status_icon, a_filename: POINTER) is
  330. -- void gtk_status_icon_set_from_file (GtkStatusIcon *status_icon, const gchar *filename)
  331. external "C use <gtk/gtk.h>"
  332. end
  333. gtk_status_icon_set_from_stock (a_status_icon, a_stock_id: POINTER) is
  334. -- void gtk_status_icon_set_from_stock (GtkStatusIcon *status_icon, const gchar *stock_id)
  335. external "C use <gtk/gtk.h>"
  336. end
  337. gtk_status_icon_set_from_icon_name (a_status_icon, an_icon_name: POINTER) is
  338. -- void gtk_status_icon_set_from_icon_name (GtkStatusIcon *status_icon, const gchar *icon_name)
  339. external "C use <gtk/gtk.h>"
  340. end
  341. gtk_status_icon_get_storage_type (a_status_icon: POINTER): INTEGER is
  342. -- GtkImageType gtk_status_icon_get_storage_type (GtkStatusIcon *status_icon)
  343. external "C use <gtk/gtk.h>"
  344. end
  345. gtk_status_icon_get_pixbuf (a_status_icon: POINTER): POINTER is
  346. -- GdkPixbuf* gtk_status_icon_get_pixbuf (GtkStatusIcon *status_icon)
  347. external "C use <gtk/gtk.h>"
  348. end
  349. gtk_status_icon_get_stock (a_status_icon: POINTER): POINTER is
  350. -- const gchar* gtk_status_icon_get_stock (GtkStatusIcon *status_icon)
  351. external "C use <gtk/gtk.h>"
  352. end
  353. gtk_status_icon_get_icon_name (a_status_icon: POINTER): POINTER is
  354. -- const gchar* gtk_status_icon_get_icon_name (GtkStatusIcon *status_icon)
  355. external "C use <gtk/gtk.h>"
  356. end
  357. gtk_status_icon_get_size (a_status_icon: POINTER): INTEGER is
  358. -- gint gtk_status_icon_get_size (GtkStatusIcon *status_icon)
  359. external "C use <gtk/gtk.h>"
  360. end
  361. gtk_status_icon_set_tooltip (a_status_icon, a_tooltip_text: POINTER) is
  362. -- void gtk_status_icon_set_tooltip (GtkStatusIcon *status_icon, const gchar *tooltip_text)
  363. external "C use <gtk/gtk.h>"
  364. end
  365. gtk_status_icon_set_visible (a_status_icon: POINTER; visible_bool: INTEGER) is
  366. -- void gtk_status_icon_set_visible (GtkStatusIcon *status_icon, gboolean visible)
  367. external "C use <gtk/gtk.h>"
  368. end
  369. gtk_status_icon_get_visible (a_status_icon: POINTER): INTEGER is
  370. -- gboolean gtk_status_icon_get_visible (GtkStatusIcon *status_icon)
  371. external "C use <gtk/gtk.h>"
  372. end
  373. gtk_status_icon_set_blinking (a_status_icon: POINTER; blinking_bool: INTEGER) is
  374. -- void gtk_status_icon_set_blinking (GtkStatusIcon *status_icon, gboolean blinking)
  375. external "C use <gtk/gtk.h>"
  376. end
  377. gtk_status_icon_get_blinking (a_status_icon: POINTER): INTEGER is
  378. -- gboolean gtk_status_icon_get_blinking (GtkStatusIcon *status_icon)
  379. external "C use <gtk/gtk.h>"
  380. end
  381. gtk_status_icon_is_embedded (a_status_icon: POINTER): INTEGER is
  382. -- gboolean gtk_status_icon_is_embedded (GtkStatusIcon *status_icon)
  383. external "C use <gtk/gtk.h>"
  384. end
  385. gtk_status_icon_position_menu (a_menu, an_x, a_y, a_push_in_bool, user_data: POINTER) is
  386. -- void gtk_status_icon_position_menu (GtkMenu *menu, gint
  387. -- *x, gint *y, gboolean *push_in, gpointer user_data)
  388. external "C use <gtk/gtk.h>"
  389. end
  390. gtk_status_icon_get_geometry (a_status_icon, a_screen_ref, a_gdkrectangle_area, a_gtk_orientation: POINTER): INTEGER is
  391. -- gboolean gtk_status_icon_get_geometry (GtkStatusIcon
  392. -- *status_icon, GdkScreen **screen, GdkRectangle *area,
  393. -- GtkOrientation *orientation)
  394. external "C use <gtk/gtk.h>"
  395. end
  396. end -- class GTK_STATUS_ICON