Debian Codegraph @

gtk/src/statusicon.ccg

raw
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 #include <gtk/gtk.h>
18
19
20 namespace Gtk
21 {
22
23 #ifndef GTKMM_DISABLE_DEPRECATED
24 StatusIcon::StatusIcon(const StockID& stock)
25 :
26 // Mark this class as non-derived to allow C++ vfuncs to be skipped.
27 Glib::ObjectBase(nullptr),
28 Glib::Object(Glib::ConstructParams(statusicon_class_.init(), "stock", (stock).get_c_str(), nullptr))
29 {}
30 #endif // GTKMM_DISABLE_DEPRECATED
31
32 #ifndef GTKMM_DISABLE_DEPRECATED
33 Glib::RefPtr<StatusIcon> StatusIcon::create(const StockID& stock_id)
34 {
35 return Glib::RefPtr<StatusIcon>( new StatusIcon(stock_id) );
36 }
37 #endif // GTKMM_DISABLE_DEPRECATED
38
39 Glib::RefPtr<StatusIcon> StatusIcon::create_from_file(const std::string& filename)
40 {
41 Glib::RefPtr<StatusIcon> status_icon( new StatusIcon() );
42 status_icon->set_from_file(Glib::ustring(filename));
43 return status_icon;
44 }
45
46 bool StatusIcon::get_geometry(Glib::RefPtr<Gdk::Screen>& screen, Gdk::Rectangle& area, Orientation& orientation)
47 {
48 GdkScreen* cscreen = nullptr;
49 GdkRectangle carea;
50 const bool result = gtk_status_icon_get_geometry(const_cast<GtkStatusIcon*>(gobj()), &cscreen, &carea, (GtkOrientation*)(&orientation));
51
52 if(cscreen)
53 {
54 screen = Glib::wrap(cscreen);
55 screen->reference();
56 }
57
58 *(area.gobj()) = carea;
59
60 return result;
61 }
62
63 void StatusIcon::popup_menu_at_position(Menu& menu, guint button, guint32 activate_time)
64 {
65 gtk_menu_popup(menu.gobj(), nullptr, nullptr,
66 gtk_status_icon_position_menu, gobj() /* user_data, passed to gtk_status_icon_position_menu()/ */,
67 button, activate_time);
68 }
69
70 } // namespace Gtk