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