[gtkmm] Button: Replace the icon_name ctor by set_image_from_icon_name().
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Button: Replace the icon_name ctor by set_image_from_icon_name().
- Date: Tue, 10 Sep 2013 14:54:53 +0000 (UTC)
commit 39bf0579e003becbbe0b0242989fd2bf0f961636
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Tue Sep 10 16:53:10 2013 +0200
Button: Replace the icon_name ctor by set_image_from_icon_name().
* gtk/src/button.[h|cc]: Remove the constructor that takes an icon_name.
Add set_image_from_icon_name(). Bug #707791.
gtk/src/button.ccg | 16 +++++++---------
gtk/src/button.hg | 32 ++++++++++++++++++++------------
2 files changed, 27 insertions(+), 21 deletions(-)
---
diff --git a/gtk/src/button.ccg b/gtk/src/button.ccg
index 6fd7255..e519342 100644
--- a/gtk/src/button.ccg
+++ b/gtk/src/button.ccg
@@ -28,15 +28,6 @@ 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)
:
@@ -44,5 +35,12 @@ Button::Button(const StockID& stock_id)
{}
#endif //GTKMM_DISABLE_DEPRECATED
+void Button::set_image_from_icon_name(const Glib::ustring& icon_name, IconSize size)
+{
+ Image* image = Gtk::manage(new Image());
+ image->set_from_icon_name(icon_name, size);
+ set_image(*image);
+}
+
} // namespace Gtk
diff --git a/gtk/src/button.hg b/gtk/src/button.hg
index 1788a9a..00e52d6 100644
--- a/gtk/src/button.hg
+++ b/gtk/src/button.hg
@@ -69,24 +69,15 @@ 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);
+ //We don't wrap gtk_button_new_from_icon_name() to avoid a clash with the label constructor.
+ //But set_image_from_icon_name() is a replacement.
_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.
* @param stock_id The stock item.
- * @deprecated Use the constructor that takes a Glib::ustring label instead because stock IDs are now
deprecated.
+ * @deprecated Use the constructor that takes a Glib::ustring label or set_image_from_icon_name() instead,
because stock IDs are now deprecated.
*/
explicit Button(const StockID& stock_id);
#endif //GTKMM_DISABLE_DEPRECATED
@@ -110,6 +101,23 @@ public:
_WRAP_METHOD(void set_alignment(float xalign, float yalign), gtk_button_set_alignment)
_WRAP_METHOD(void get_alignment(float& xalign, float& yalign), gtk_button_get_alignment)
+ /** Sets the image to 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.
+ * The icon will be displayed if there is no label text or if
+ * Gtk::Button::property_always_show_image() is <tt>true</tt>.
+ *
+ * This is a convenience wrapper around Gtk::Image::set_from_icon_name() and
+ * Gtk::Button:set_image().
+ *
+ * @param icon_name An icon name.
+ * @param size An icon size. Can be either an IconSize or a BuiltinIconSize.
+ *
+ * @newin{3,10}
+ */
+ void set_image_from_icon_name(const Glib::ustring& icon_name, IconSize size = ICON_SIZE_BUTTON);
+
_WRAP_METHOD(void set_image(Widget& image), gtk_button_set_image)
_WRAP_METHOD(Widget* get_image(), gtk_button_get_image)
_WRAP_METHOD(const Widget* get_image() const, gtk_button_get_image, constversion)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]