[gtkmm] Button: Add constructor that takes an icon_name and size.



commit c1c9b12d757ea033e300a837456f3cf25c66667f
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Aug 28 12:55:05 2013 +0200

    Button: Add constructor that takes an icon_name and size.
    
    * gtk/src/button.[hg|ccg]: Reimplement to match the new
      gtk_button_new_from_icon_name() function.

 gtk/src/button.ccg |    9 +++++++++
 gtk/src/button.hg  |   13 +++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/gtk/src/button.ccg b/gtk/src/button.ccg
index 8ae770e..6fd7255 100644
--- a/gtk/src/button.ccg
+++ b/gtk/src/button.ccg
@@ -28,6 +28,15 @@ Button::Button(const Glib::ustring& label, bool mnemonic)
   _CONSTRUCT("label", label.c_str(), "use_underline", gboolean(mnemonic))
 {}
 
+Button::Button(const Glib::ustring& icon_name, IconSize size)
+:
+  _CONSTRUCT()
+{
+  Image* image = Gtk::manage(new Image());
+  image->set_from_icon_name(icon_name, size);
+  set_image(*image);
+}
+
 #ifndef GTKMM_DISABLE_DEPRECATED
 Button::Button(const StockID& stock_id)
 :
diff --git a/gtk/src/button.hg b/gtk/src/button.hg
index 0479115..1788a9a 100644
--- a/gtk/src/button.hg
+++ b/gtk/src/button.hg
@@ -69,6 +69,19 @@ public:
    */
   explicit Button(const Glib::ustring& label, bool mnemonic = false);
 
+  /** Creates a Button containing an icon from the current icon theme.
+   * If the icon name isn't known, a "broken image" icon will be
+   * displayed instead. If the current icon theme is changed, the icon
+   * will be updated appropriately.
+   *
+   * This is a convenience wrapper around Gtk::Button() and
+   * Gtk::Button:set_image().
+   *
+   * @newin{3,10}
+   */
+  explicit Button(const Glib::ustring& icon_name, IconSize size);
+  _IGNORE(gtk_button_new_from_icon_name)
+
 #ifndef GTKMM_DISABLE_DEPRECATED
   /** Creates a new Button containing the image and text from a stock item.
    * Stock ids have identifiers like Gtk::Stock::OK and Gtk::Stock::APPLY.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]