| 1 |
/* Copyright (C) 2005 The gtkmm Development Team |
| 2 |
* |
| 3 |
* This library is free software; you can redistribute it and/or |
| 4 |
* modify it under the terms of the GNU Lesser General Public |
| 5 |
* License as published by the Free Software Foundation; either |
| 6 |
* version 2.1 of the License, or (at your option) any later version. |
| 7 |
* |
| 8 |
* This library is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
* Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public |
| 14 |
* License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
_CONFIGINCLUDE(gtkmmconfig.h) |
| 18 |
|
| 19 |
_DEFS(gtkmm,gtk) |
| 20 |
_PINCLUDE(glibmm/private/object_p.h) |
| 21 |
|
| 22 |
#m4 _PUSH(SECTION_CC_PRE_INCLUDES) |
| 23 |
#undef GTK_DISABLE_DEPRECATED |
| 24 |
#define GDK_DISABLE_DEPRECATION_WARNINGS 1 |
| 25 |
#m4 _POP() |
| 26 |
|
| 27 |
#include <gtkmm/image.h> |
| 28 |
//Deprecated: #include <gtkmm/stockid.h> |
| 29 |
#include <gtkmm/menu.h> |
| 30 |
#include <gdkmm/pixbuf.h> |
| 31 |
#include <gdkmm/types.h> |
| 32 |
#include <gtkmm/tooltip.h> |
| 33 |
|
| 34 |
_IS_DEPRECATED // This whole file is deprecated. |
| 35 |
|
| 36 |
namespace Gtk |
| 37 |
{ |
| 38 |
|
| 39 |
/** The "system tray" or notification area is normally used for transient icons that indicate some |
| 40 |
* special state. For example, a system tray icon might appear to tell the user that they have new |
| 41 |
* mail, or have an incoming instant message, or something along those lines. The basic idea is |
| 42 |
* that creating an icon in the notification area is less annoying than popping up a dialog. |
| 43 |
* |
| 44 |
* A StatusIcon object can be used to display an icon in a "system tray". The icon can have a |
| 45 |
* tooltip, and the user can interact with it by activating it or popping up a context menu. |
| 46 |
* Critical information should not solely be displayed in a StatusIcon, since it may not be |
| 47 |
* visible (e.g. when the user doesn't have a notification area on his panel). This can be checked |
| 48 |
* with is_embedded(). |
| 49 |
* |
| 50 |
* On X11, the implementation follows the freedesktop.org "System Tray" specification. |
| 51 |
* Implementations of the "tray" side of this specification can be found e.g. in the GNOME and KDE |
| 52 |
* panel applications. |
| 53 |
* |
| 54 |
* Note that a StatusIcon is not a widget, but just a Glib::Object. |
| 55 |
* Making it a widget would be impractical, since the system tray |
| 56 |
* on Win32 doesn’t allow to embed arbitrary widgets. |
| 57 |
* |
| 58 |
* @newin{2,10} |
| 59 |
* |
| 60 |
* @deprecated You should consider using notifications or more modern platform-specific APIs instead. |
| 61 |
*/ |
| 62 |
class GTKMM_API StatusIcon : public Glib::Object |
| 63 |
{ |
| 64 |
_CLASS_GOBJECT(StatusIcon, GtkStatusIcon, GTK_STATUS_ICON, Glib::Object, GObject, , , GTKMM_API) |
| 65 |
protected: |
| 66 |
_CTOR_DEFAULT |
| 67 |
_IGNORE(gtk_status_icon_new) |
| 68 |
_WRAP_CTOR(StatusIcon(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf), gtk_status_icon_new_from_pixbuf) |
| 69 |
|
| 70 |
// _WRAP_CTOR does not take a 'deprecated' parameter. |
| 71 |
// _WRAP_CTOR(StatusIcon(const StockID& stock), gtk_status_icon_new_from_stock) |
| 72 |
#ifndef GTKMM_DISABLE_DEPRECATED |
| 73 |
/** @deprecated Use the constructor with the @a icon_name parameter instead. |
| 74 |
*/ |
| 75 |
explicit StatusIcon(const StockID& stock); |
| 76 |
#endif // GTKMM_DISABLE_DEPRECATED |
| 77 |
|
| 78 |
_WRAP_CTOR(StatusIcon(const Glib::ustring& icon_name), gtk_status_icon_new_from_icon_name) |
| 79 |
_WRAP_CTOR(StatusIcon(const Glib::RefPtr<const Gio::Icon>& icon), gtk_status_icon_new_from_gicon) |
| 80 |
|
| 81 |
public: |
| 82 |
/** Creates a new Gtk::StatusIcon object. |
| 83 |
* @return A Glib::RefPtr<> to a newly created Gtk::StatusIcon object. |
| 84 |
*/ |
| 85 |
_WRAP_CREATE(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf) |
| 86 |
|
| 87 |
// _WRAP_CREATE does not take a 'deprecated' parameter. |
| 88 |
// _WRAP_CREATE(const StockID& stock_id) |
| 89 |
#ifndef GTKMM_DISABLE_DEPRECATED |
| 90 |
/** @deprecated Use create() with the @a icon_name parameter instead. |
| 91 |
*/ |
| 92 |
static Glib::RefPtr<StatusIcon> create(const StockID& stock_id); |
| 93 |
#endif // GTKMM_DISABLE_DEPRECATED |
| 94 |
|
| 95 |
_WRAP_CREATE(const Glib::ustring& icon_name) |
| 96 |
|
| 97 |
/** Creates a status icon displaying the file @a filename. |
| 98 |
* The image will be scaled down to fit in the available |
| 99 |
* space in the notification area, if necessary. |
| 100 |
* |
| 101 |
* @param filename A filename. |
| 102 |
* @result A new StatusIcon |
| 103 |
* |
| 104 |
* @newin{2,10} |
| 105 |
*/ |
| 106 |
static Glib::RefPtr<StatusIcon> create_from_file(const std::string& filename); |
| 107 |
_IGNORE(gtk_status_icon_new_from_file) |
| 108 |
|
| 109 |
_WRAP_METHOD(void set(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf), gtk_status_icon_set_from_pixbuf) |
| 110 |
_WRAP_METHOD(void set_from_file(const Glib::ustring& filename), gtk_status_icon_set_from_file) |
| 111 |
_WRAP_METHOD(void set(const StockID& stock_id), gtk_status_icon_set_from_stock, deprecated "Use the set() with the @a icon_name parameter instead.") |
| 112 |
_WRAP_METHOD(void set(const Glib::ustring& icon_name), gtk_status_icon_set_from_icon_name) |
| 113 |
_WRAP_METHOD(void set(const Glib::RefPtr<const Gio::Icon>& icon), gtk_status_icon_set_from_gicon) |
| 114 |
|
| 115 |
_WRAP_METHOD(ImageType get_storage_type() const, gtk_status_icon_get_storage_type) |
| 116 |
|
| 117 |
_WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> get_pixbuf(), gtk_status_icon_get_pixbuf) |
| 118 |
_WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> get_pixbuf() const, gtk_status_icon_get_pixbuf, constversion) |
| 119 |
|
| 120 |
_WRAP_METHOD(StockID get_stock() const, gtk_status_icon_get_stock, deprecated "Use the get_icon_name() instead.") |
| 121 |
_WRAP_METHOD(Glib::ustring get_icon_name() const, gtk_status_icon_get_icon_name) |
| 122 |
|
| 123 |
_WRAP_METHOD(Glib::RefPtr<Gio::Icon> get_icon(), gtk_status_icon_get_gicon, refreturn) |
| 124 |
_WRAP_METHOD(Glib::RefPtr<const Gio::Icon> get_icon() const, gtk_status_icon_get_gicon, refreturn, constversion) |
| 125 |
|
| 126 |
_WRAP_METHOD(int get_size() const, gtk_status_icon_get_size) |
| 127 |
|
| 128 |
_WRAP_METHOD(void set_screen(const Glib::RefPtr<Gdk::Screen>& screen), gtk_status_icon_set_screen) |
| 129 |
_WRAP_METHOD(Glib::RefPtr<Gdk::Screen> get_screen(), gtk_status_icon_get_screen, refreturn) |
| 130 |
_WRAP_METHOD(Glib::RefPtr<const Gdk::Screen> get_screen() const, gtk_status_icon_get_screen, refreturn, constversion) |
| 131 |
|
| 132 |
_WRAP_METHOD(void set_visible(bool visible = true), gtk_status_icon_set_visible) |
| 133 |
_WRAP_METHOD(bool get_visible() const, gtk_status_icon_get_visible) |
| 134 |
|
| 135 |
_WRAP_METHOD(bool is_embedded() const, gtk_status_icon_is_embedded) |
| 136 |
|
| 137 |
/** Displays a menu aligned to the status icon, and makes it available for selection. |
| 138 |
* Applications can use this function to display context-sensitive menus. |
| 139 |
* |
| 140 |
* This is equivalent to the gtk_status_icon_position_menu() helper callback in GTK+, |
| 141 |
* which can be provided to gtk_menu_popup(). |
| 142 |
* |
| 143 |
* See Gtk::Menu::popup() for more details. |
| 144 |
* |
| 145 |
* @param menu The menu to popup for the status icon. |
| 146 |
* @param button The mouse button which was pressed to initiate the event. |
| 147 |
* @param activate_time The time at which the activation event occurred. |
| 148 |
* |
| 149 |
* @newin{2,12} |
| 150 |
*/ |
| 151 |
void popup_menu_at_position(Menu& menu, guint button, guint32 activate_time); |
| 152 |
_IGNORE(gtk_status_icon_position_menu) |
| 153 |
//Note that gtk_status_icon_position_menu() is meant to be used as a helpful callback when calling gtk_menu_popup(). |
| 154 |
//We make it easier by just providing a popup method that uses it. |
| 155 |
|
| 156 |
//In gtk_status_icon_get_geometry(), any of the parameters may be NULL, |
| 157 |
//but we don't need 6 different overloads, with different parameters. |
| 158 |
//But we can add some if there are common cases. |
| 159 |
|
| 160 |
/** Obtains information about the location of the status icon |
| 161 |
* on screen. This information can be used to e.g. position |
| 162 |
* popups like notification bubbles. |
| 163 |
* See popup_menu_at_position() for a more convenient |
| 164 |
* alternative for positioning menus. |
| 165 |
* |
| 166 |
* Note that some platforms do not allow GTK+ to provide |
| 167 |
* this information. |
| 168 |
* |
| 169 |
* @param screen: The screen. |
| 170 |
* @param area The area occupied by the status icon. |
| 171 |
* @param orientation The orientation of the panel in which the status icon is embedded. A panel |
| 172 |
* at the top or bottom of the screen is horizontal, a panel at the left or right is vertical. |
| 173 |
* @result true if the location information has been filled in. |
| 174 |
* |
| 175 |
* @newin{2,10} |
| 176 |
*/ |
| 177 |
bool get_geometry(Glib::RefPtr<Gdk::Screen>& screen, Gdk::Rectangle& area, Orientation& orientation); |
| 178 |
_IGNORE(gtk_status_icon_get_geometry) |
| 179 |
|
| 180 |
_WRAP_METHOD(bool get_has_tooltip() const, gtk_status_icon_get_has_tooltip) |
| 181 |
_WRAP_METHOD(void set_has_tooltip(bool has_tooltip = true), gtk_status_icon_set_has_tooltip) |
| 182 |
_WRAP_METHOD(Glib::ustring get_tooltip_text() const, gtk_status_icon_get_tooltip_text) |
| 183 |
_WRAP_METHOD(void set_tooltip_text(const Glib::ustring& text), gtk_status_icon_set_tooltip_text) |
| 184 |
_WRAP_METHOD(Glib::ustring get_tooltip_markup() const, gtk_status_icon_get_tooltip_markup) |
| 185 |
_WRAP_METHOD(void set_tooltip_markup(const Glib::ustring& markup), gtk_status_icon_set_tooltip_markup) |
| 186 |
_WRAP_METHOD(void set_title(const Glib::ustring& title), gtk_status_icon_set_title) |
| 187 |
_WRAP_METHOD(Glib::ustring get_title() const, gtk_status_icon_get_title) |
| 188 |
_WRAP_METHOD(void set_name(const Glib::ustring& name), gtk_status_icon_set_name) |
| 189 |
|
| 190 |
_WRAP_METHOD(guint32 get_x11_window_id() const, gtk_status_icon_get_x11_window_id) |
| 191 |
|
| 192 |
_WRAP_PROPERTY("pixbuf", Glib::RefPtr<Gdk::Pixbuf>) |
| 193 |
_WRAP_PROPERTY("file", std::string) |
| 194 |
_WRAP_PROPERTY("stock", StockID, deprecated "Use property_icon_name() instead.") |
| 195 |
_WRAP_PROPERTY("icon-name", Glib::ustring) |
| 196 |
_WRAP_PROPERTY("gicon", Glib::RefPtr<Gio::Icon>) |
| 197 |
_WRAP_PROPERTY("storage-type", ImageType) |
| 198 |
_WRAP_PROPERTY("size", int) |
| 199 |
_WRAP_PROPERTY("screen", Glib::RefPtr<Gdk::Screen>) |
| 200 |
_WRAP_PROPERTY("visible", bool) |
| 201 |
_WRAP_PROPERTY("embedded", bool) |
| 202 |
_WRAP_PROPERTY("orientation", Orientation) |
| 203 |
_WRAP_PROPERTY("has-tooltip", bool) |
| 204 |
_WRAP_PROPERTY("tooltip-text", Glib::ustring) |
| 205 |
_WRAP_PROPERTY("tooltip-markup", Glib::ustring) |
| 206 |
_WRAP_PROPERTY("title", Glib::ustring) |
| 207 |
|
| 208 |
_WRAP_SIGNAL(bool size_changed(int size), size_changed) |
| 209 |
|
| 210 |
_WRAP_SIGNAL(void activate(), activate) |
| 211 |
_WRAP_SIGNAL(void popup_menu(guint button, guint32 activate_time), popup_menu) |
| 212 |
_WRAP_SIGNAL(bool button_press_event(GdkEventButton* event), button_press_event) |
| 213 |
_WRAP_SIGNAL(bool button_release_event(GdkEventButton* event), button_release_event) |
| 214 |
_WRAP_SIGNAL(bool scroll_event(GdkEventScroll* event), scroll_event) |
| 215 |
|
| 216 |
#m4 _CONVERSION(`GtkTooltip*',`const Glib::RefPtr<Tooltip>&',`Glib::wrap($3, true)') |
| 217 |
_WRAP_SIGNAL(bool query_tooltip(int x, int y, bool keyboard_mode, const Glib::RefPtr<Tooltip>& tooltip), query_tooltip) |
| 218 |
}; |
| 219 |
|
| 220 |
} // namespace Gtk |