Debian Codegraph @

gtk/src/button.ccg

raw
1 /* Copyright (C) 1998-2002 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 #ifndef GTKMM_DISABLE_DEPRECATED
19 #include <gtkmm/stock.h>
20 #endif
21 #include <gtkmm/image.h>
22
23 namespace Gtk
24 {
25
26 Button::Button(const Glib::ustring& label, bool mnemonic)
27 :
28 _CONSTRUCT("label", label.c_str(), "use_underline", gboolean(mnemonic))
29 {}
30
31 #ifndef GTKMM_DISABLE_DEPRECATED
32 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
33 Button::Button(const StockID& stock_id)
34 :
35 _CONSTRUCT("use_stock", 1, "label", stock_id.get_c_str())
36 {}
37 G_GNUC_END_IGNORE_DEPRECATIONS
38 #endif //GTKMM_DISABLE_DEPRECATED
39
40 void Button::set_image_from_icon_name(const Glib::ustring& icon_name, IconSize size)
41 {
42 auto image = Gtk::manage(new Image());
43 image->set_from_icon_name(icon_name, size);
44 set_image(*image);
45 }
46
47 void Button::set_image_from_icon_name(const Glib::ustring& icon_name, IconSize size, bool use_fallback)
48 {
49 auto image = Gtk::manage(new Image());
50 image->set_from_icon_name(icon_name, size);
51 image->property_use_fallback() = use_fallback;
52 set_image(*image);
53 }
54
55 // GtkButton:focus-on-click has been removed from gtk+.
56 // TODO: At ABI-break, remove it from gtkmm.
57 #ifndef GTKMM_DISABLE_DEPRECATED
58 Glib::PropertyProxy< bool > Button::property_focus_on_click()
59 {
60 return Glib::PropertyProxy< bool >(this, "focus-on-click");
61 }
62
63 Glib::PropertyProxy_ReadOnly< bool > Button::property_focus_on_click() const
64 {
65 return Glib::PropertyProxy_ReadOnly< bool >(this, "focus-on-click");
66 }
67 #endif // GTKMM_DISABLE_DEPRECATED
68
69 } // namespace Gtk