[gtkmm] Gtk::Misc: Deprecate all methods and properties
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gtk::Misc: Deprecate all methods and properties
- Date: Mon, 26 May 2014 15:07:06 +0000 (UTC)
commit 204812de0ba258e5bee9322081bd0301509b5680
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Mon May 26 16:49:32 2014 +0200
Gtk::Misc: Deprecate all methods and properties
* demos/gtk-demo/example_change_display.cc:
* demos/gtk-demo/example_sizegroup.cc: Don't use deprecated Misc methods.
* gtk/src/bin.[ccg|hg]: Deprecate add_label(const Glib::ustring& label,
bool mnemonic, double x_align, double y_align) and
add_pixlabel(const std::string& pixfile, const Glib::ustring& label,
double x_align, double y_align). Add add_pixlabel(const std::string& pixfile,
const Glib::ustring& label, Align x_align, Align y_align).
* gtk/src/label.[ccg|hg]: Deprecate Label(const Glib::ustring& label,
float xalign, float yalign, bool mnemonic).
* gtk/src/menuitem.ccg: Don't use deprecated Misc property.
* gtk/src/misc.hg: Deprecate all methods and properties. GtkMisc is deprecated,
but we can't deprecate Gtk::Misc completely, because it's a base class of
Arrow, Label and Image. Label and Image are not deprecated.
demos/gtk-demo/example_change_display.cc | 2 +-
demos/gtk-demo/example_sizegroup.cc | 3 +-
gtk/src/bin.ccg | 28 +++++++++++++++++++--
gtk/src/bin.hg | 39 ++++++++++++++++++++++++++++-
gtk/src/label.ccg | 5 +++-
gtk/src/label.hg | 7 ++++-
gtk/src/menuitem.ccg | 4 +-
gtk/src/misc.hg | 18 +++++++-------
8 files changed, 85 insertions(+), 21 deletions(-)
---
diff --git a/demos/gtk-demo/example_change_display.cc b/demos/gtk-demo/example_change_display.cc
index 81c2e7c..4e1b571 100644
--- a/demos/gtk-demo/example_change_display.cc
+++ b/demos/gtk-demo/example_change_display.cc
@@ -386,7 +386,7 @@ Popup::Popup(const Glib::RefPtr<Gdk::Screen>& screen, const Glib::ustring& promp
m_Frame.set_shadow_type(Gtk::SHADOW_OUT);
add(m_Frame);
- m_Label.set_padding(10, 10);
+ m_Label.property_margin() = 10;
m_Frame.add(m_Label);
show_all_children();
diff --git a/demos/gtk-demo/example_sizegroup.cc b/demos/gtk-demo/example_sizegroup.cc
index 4d4e11f..4bb14cb 100644
--- a/demos/gtk-demo/example_sizegroup.cc
+++ b/demos/gtk-demo/example_sizegroup.cc
@@ -133,8 +133,7 @@ void Example_SizeGroup::add_row(Gtk::Grid& grid, int row,
const Glib::ustring& label_text,
const std::list<Glib::ustring>& options)
{
- Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(label_text, true));
- pLabel->set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_END);
+ Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(label_text, Gtk::ALIGN_START, Gtk::ALIGN_END, true));
grid.attach(*pLabel, 0, row, 1, 1);
pLabel->set_hexpand();
diff --git a/gtk/src/bin.ccg b/gtk/src/bin.ccg
index 114348b..a1a68c0 100644
--- a/gtk/src/bin.ccg
+++ b/gtk/src/bin.ccg
@@ -48,6 +48,7 @@ Bin::remove()
}
}
+_DEPRECATE_IFDEF_START
void
Bin::add_label(const Glib::ustring& str, bool mnemonic /* = false */,
double x_align /* = 0.5 */, double y_align /* = 0.5 */)
@@ -62,16 +63,18 @@ Bin::add_label(const Glib::ustring& str, bool mnemonic /* = false */,
label->show();
}
+_DEPRECATE_IFDEF_END
void
Bin::add_label(const Glib::ustring& str, bool mnemonic,
Align x_align, Align y_align /* = ALIGN_CENTER */)
{
- add_label(str, mnemonic,
- _gtkmm_align_float_from_enum(x_align),
- _gtkmm_align_float_from_enum(y_align));
+ Label* label = manage(new Label(str, x_align, y_align, mnemonic));
+ add(*label);
+ label->show();
}
+_DEPRECATE_IFDEF_START
void
Bin::add_pixlabel(const std::string& pixfile,
const Glib::ustring& str,
@@ -91,6 +94,25 @@ Bin::add_pixlabel(const std::string& pixfile,
//And put that Box in this:
add(*hbox);
}
+_DEPRECATE_IFDEF_END
+
+void
+Bin::add_pixlabel(const std::string& pixfile,
+ const Glib::ustring& str,
+ Align x_align, Align y_align /* = ALIGN_CENTER */)
+{
+ //Create Image and Label widgets:
+ Image* pmap = manage(new Image(pixfile));
+ Label* label = manage(new Label(str, x_align, y_align));
+ //Put them in a Box:
+ Box* hbox = manage(new Box(ORIENTATION_HORIZONTAL, 5));
+ hbox->pack_start(*pmap, PACK_SHRINK);
+ hbox->pack_start(*label);
+ hbox->show_all();
+
+ //And put that Box in this:
+ add(*hbox);
+}
} //namespace Gtk
diff --git a/gtk/src/bin.hg b/gtk/src/bin.hg
index dee93e5..c7f6f42 100644
--- a/gtk/src/bin.hg
+++ b/gtk/src/bin.hg
@@ -59,6 +59,7 @@ public:
//Convenience methods that don't correspond to GTK+ functions:
+_DEPRECATE_IFDEF_START
/** Add a Label object.
* This does not correspond to any GTK+ function and is provided purely for
* convenience.
@@ -69,9 +70,12 @@ public:
* 0.0 (left aligned) to 1.0 (right aligned).
* @param y_align The vertical alignment of the text. This ranges from
* 0.0 (top aligned) to 1.0 (bottom aligned).
+ *
+ * @deprecated Use the other add_label().
*/
void add_label(const Glib::ustring& label, bool mnemonic = false,
double x_align = 0.5, double y_align = 0.5);
+_DEPRECATE_IFDEF_END
/** Add a Label object.
* This does not correspond to any GTK+ function and is provided purely for
@@ -84,8 +88,13 @@ public:
* @param y_align The vertical alignment of the text. For possible
* values, see Gtk::Align.
*/
+_DEPRECATE_IFDEF_START
void add_label(const Glib::ustring& label, bool mnemonic,
- Align x_align, Align y_align = ALIGN_CENTER);
+ Align x_align, Align y_align = ALIGN_CENTER);
+#else
+ void add_label(const Glib::ustring& label, bool mnemonic = false,
+ Align x_align = ALIGN_CENTER, Align y_align = ALIGN_CENTER);
+_DEPRECATE_IFDEF_END
//TODO: Change this to Pixbuf?
/* Add Image and Label objects.
@@ -103,9 +112,10 @@ public:
void add_pixlabel(const Glib::RefPtr<Gdk::Pixmap>& pixmap,
const Glib::RefPtr<Gdk::Bitmap>& mask,
const Glib::ustring& label,
- double x_align = 0.5, double y_align = 0.5);
+ Align x_align = ALIGN_CENTER, Align y_align = ALIGN_CENTER);
*/
+_DEPRECATE_IFDEF_START
/** Add Image and Label objects.
* This does not correspond to any GTK+ function and is provided purely for
* convenience.
@@ -115,10 +125,35 @@ public:
* @param label The text for the label.
* @param x_align The horizontal alignment of the text in the label.
* @param y_align The vertical alignment of the text in the label.
+ *
+ * @deprecated Use the other add_pixlabel().
*/
void add_pixlabel(const std::string& pixfile,
const Glib::ustring& label,
double x_align = 0.5, double y_align = 0.5);
+_DEPRECATE_IFDEF_END
+
+ /** Add Image and Label objects.
+ * This does not correspond to any GTK+ function and is provided purely for
+ * convenience.
+ * This will create, manage, add, and show a new Image and Label (within a
+ * horizontal Box) to this Bin.
+ * @param pixfile The path to a file to be displayed.
+ * @param label The text for the label.
+ * @param x_align The horizontal alignment of the text in the label.
+ * @param y_align The vertical alignment of the text in the label.
+ *
+ * @newin{3,14}
+ */
+_DEPRECATE_IFDEF_START
+ void add_pixlabel(const std::string& pixfile,
+ const Glib::ustring& label,
+ Align x_align, Align y_align = ALIGN_CENTER);
+#else
+ void add_pixlabel(const std::string& pixfile,
+ const Glib::ustring& label,
+ Align x_align = ALIGN_CENTER, Align y_align = ALIGN_CENTER);
+_DEPRECATE_IFDEF_END
};
} //namespace Gtk
diff --git a/gtk/src/label.ccg b/gtk/src/label.ccg
index 1b383a0..55f9772 100644
--- a/gtk/src/label.ccg
+++ b/gtk/src/label.ccg
@@ -31,18 +31,21 @@ Label::Label(const Glib::ustring& label, bool mnemonic)
_CONSTRUCT("label", label.c_str(), "use_underline", gboolean(mnemonic))
{}
+_DEPRECATE_IFDEF_START
Label::Label(const Glib::ustring& label, float xalign, float yalign, bool mnemonic)
:
_CONSTRUCT("label", label.c_str(), "use_underline", gboolean(mnemonic))
{
set_alignment(xalign, yalign);
}
+_DEPRECATE_IFDEF_END
Label::Label(const Glib::ustring& label, Align xalign, Align yalign, bool mnemonic)
:
_CONSTRUCT("label", label.c_str(), "use_underline", gboolean(mnemonic))
{
- set_alignment(xalign, yalign);
+ set_halign(xalign);
+ set_valign(yalign);
}
void Label::select_region(int start_offset)
diff --git a/gtk/src/label.hg b/gtk/src/label.hg
index e456678..2810977 100644
--- a/gtk/src/label.hg
+++ b/gtk/src/label.hg
@@ -45,6 +45,7 @@ public:
Label();
explicit Label(const Glib::ustring& label, bool mnemonic = false);
+_DEPRECATE_IFDEF_START
/** This constructor is a shortcut for often used code
* when you want to create a label with alignment different
* than default one.
@@ -56,8 +57,11 @@ public:
* Gtk::Label label(text, mnemonic);
* label.set_alignment(x, y);
* @endcode
+ *
+ * @deprecated Use another constructor.
*/
Label(const Glib::ustring& label, float xalign, float yalign, bool mnemonic = false);
+_DEPRECATE_IFDEF_END
/** This constructor is a shortcut for often used code
* when you want to create a label with alignment different
@@ -68,7 +72,8 @@ public:
* is equivalent to:
* @code
* Gtk::Label label(text, mnemonic);
- * label.set_alignment(x, y);
+ * label.set_halign(x);
+ * label.set_valign(y);
* @endcode
*/
Label(const Glib::ustring& label, Align xalign, Align yalign = ALIGN_CENTER, bool mnemonic = false);
diff --git a/gtk/src/menuitem.ccg b/gtk/src/menuitem.ccg
index 62b7156..eaab318 100644
--- a/gtk/src/menuitem.ccg
+++ b/gtk/src/menuitem.ccg
@@ -49,9 +49,9 @@ MenuItem::MenuItem(const Glib::ustring& label, bool mnemonic)
void MenuItem::add_accel_label(const Glib::ustring& label, bool mnemonic)
{
AccelLabel* pLabel = manage(new AccelLabel(label, mnemonic));
- //Labels are centered by default, but in menus they should be left-aligned.
- pLabel->property_xalign() = 0.0;
+ //Labels are centered by default, but in menus they should be left-aligned.
+ pLabel->set_halign(ALIGN_START);
add(*pLabel);
diff --git a/gtk/src/misc.hg b/gtk/src/misc.hg
index 777e0df..cb0db80 100644
--- a/gtk/src/misc.hg
+++ b/gtk/src/misc.hg
@@ -52,18 +52,18 @@ protected:
_CTOR_DEFAULT
public:
- _WRAP_METHOD(void set_alignment(float xalign = 0.0, float yalign = 0.5), gtk_misc_set_alignment)
- _WRAP_METHOD(void set_alignment(Align xalign = Gtk::ALIGN_START, Align yalign = Gtk::ALIGN_CENTER),
gtk_misc_set_alignment)
+ _WRAP_METHOD(void set_alignment(float xalign = 0.0, float yalign = 0.5), gtk_misc_set_alignment,
deprecated "Use Widget::set_halign() and Widget::set_valign() instead.")
+ _WRAP_METHOD(void set_alignment(Align xalign = Gtk::ALIGN_START, Align yalign = Gtk::ALIGN_CENTER),
gtk_misc_set_alignment, deprecated "Use Widget::set_halign() and Widget::set_valign() instead.")
- _WRAP_METHOD(void get_alignment(float& xalign, float& yalign) const, gtk_misc_get_alignment)
+ _WRAP_METHOD(void get_alignment(float& xalign, float& yalign) const, gtk_misc_get_alignment, deprecated
"Use Widget::get_halign() and Widget::get_valign() instead.")
- _WRAP_METHOD(void set_padding(int xpad, int ypad), gtk_misc_set_padding)
- _WRAP_METHOD(void get_padding(int& xpad, int& ypad) const, gtk_misc_get_padding)
+ _WRAP_METHOD(void set_padding(int xpad, int ypad), gtk_misc_set_padding, deprecated "Use
Widget::set_margin_left(), Widget::set_margin_right(), Widget::set_margin_top(), Widget::set_margin_bottom()
instead.")
+ _WRAP_METHOD(void get_padding(int& xpad, int& ypad) const, gtk_misc_get_padding, deprecated "Use
Widget::get_margin_left(), Widget::get_margin_right(), Widget::get_margin_top(), Widget::get_margin_bottom()
instead.")
- _WRAP_PROPERTY("xalign", float)
- _WRAP_PROPERTY("yalign", float)
- _WRAP_PROPERTY("xpad", int)
- _WRAP_PROPERTY("ypad", int)
+ _WRAP_PROPERTY("xalign", float, deprecated "Use Widget::property_halign() instead.")
+ _WRAP_PROPERTY("yalign", float, deprecated "Use Widget::property_valign() instead.")
+ _WRAP_PROPERTY("xpad", int, deprecated "Use Widget::property_margin_left(),
Widget::property_margin_right(), Widget::property_margin() instead.")
+ _WRAP_PROPERTY("ypad", int, deprecated "Use Widget::property_margin_top(),
Widget::property_margin_bottom(), Widget::property_margin() instead.")
};
} //namespace Gtk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]