[gtkmm] Revert "Gtk: Adapt Box, Container, Label to changes in gtk+"
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Revert "Gtk: Adapt Box, Container, Label to changes in gtk+"
- Date: Thu, 27 Apr 2017 10:22:13 +0000 (UTC)
commit 5041d463fe577608c07f4bd87a3652e5ddc06ebd
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Apr 27 12:19:24 2017 +0200
Revert "Gtk: Adapt Box, Container, Label to changes in gtk+"
This reverts commit 916c1596268cac9256c8162313e725476ad47754.
Because I would rather have the changes in smaller commits
(which I was preparing at the same time. Sorry) and because I would
like to keep our pack_start()/pack_end() convenience wrappers, at
least temporarily.
We will probably want to add some of this back later.
gtk/src/bin.ccg | 3 +--
gtk/src/box.ccg | 24 ++++++++++++++++++++++++
gtk/src/box.hg | 47 ++++++++++++++++++++++++++++++++++++++++++++---
gtk/src/container.ccg | 8 ++++----
gtk/src/container.hg | 13 +++++++------
gtk/src/label.hg | 3 +++
6 files changed, 83 insertions(+), 15 deletions(-)
---
diff --git a/gtk/src/bin.ccg b/gtk/src/bin.ccg
index 913d4ad..023c301 100644
--- a/gtk/src/bin.ccg
+++ b/gtk/src/bin.ccg
@@ -50,11 +50,10 @@ Bin::add_pixlabel(const std::string& pixfile,
//Create Image and Label widgets:
auto pmap = manage(new Image(pixfile));
auto label = manage(new Label(str, x_align, y_align));
- label->set_hexpand(true);
//Put them in a Box:
auto hbox = manage(new Box(Orientation::HORIZONTAL, 5));
- hbox->pack_start(*pmap);
+ hbox->pack_start(*pmap, PACK_SHRINK);
hbox->pack_start(*label);
//And put that Box in this:
diff --git a/gtk/src/box.ccg b/gtk/src/box.ccg
index ea8ab9e..4c78ba4 100644
--- a/gtk/src/box.ccg
+++ b/gtk/src/box.ccg
@@ -17,7 +17,31 @@
*/
#include <gtk/gtk.h>
+#include <glibmm/wrap.h>
+
namespace Gtk
{
+
+void Box::pack_start(Widget& child, PackOptions options)
+{
+ bool expand = (options == PACK_EXPAND_PADDING) || (options == PACK_EXPAND_WIDGET);
+ bool fill = (options == PACK_EXPAND_WIDGET);
+
+ gtk_box_pack_start(gobj(), child.gobj(), (gboolean)expand, (gboolean)fill);
+}
+
+void Box::pack_end(Widget& child, PackOptions options)
+{
+ bool expand = (options == PACK_EXPAND_PADDING) || (options == PACK_EXPAND_WIDGET);
+ bool fill = (options == PACK_EXPAND_WIDGET);
+
+ gtk_box_pack_end(gobj(), child.gobj(), (gboolean)expand, (gboolean)fill);
+}
+
+void Box::unset_center_widget()
+{
+ gtk_box_set_center_widget(gobj(), nullptr);
+}
+
} //namespace Gtk
diff --git a/gtk/src/box.hg b/gtk/src/box.hg
index aebdc45..e64e488 100644
--- a/gtk/src/box.hg
+++ b/gtk/src/box.hg
@@ -20,10 +20,22 @@ _PINCLUDE(gtkmm/private/container_p.h)
#include <gtkmm/container.h>
#include <gtkmm/orientable.h>
+#include <gtk/gtk.h> /* For _GtkBoxChild */
+
namespace Gtk
{
+/** Packing options for adding child widgets to a Box with pack_start() and pack_end().
+ * @ingroup gtkmmEnums
+ */
+enum PackOptions
+{
+ PACK_SHRINK, /**< Space is contracted to the child widget size. */
+ PACK_EXPAND_PADDING, /**< Space is expanded, with extra space filled with padding. */
+ PACK_EXPAND_WIDGET /**< Space is expanded, with extra space filled by increasing the child widget size. */
+};
+
/** The Box widget organizes child widgets into a rectangular area.
*
* The rectangular area of a Box is organized into either a single row
@@ -51,10 +63,16 @@ namespace Gtk
*
* Use set_spacing() to determine the minimum
* space placed between all children in the Gtk::Box. Note that
- * spacing is added between the children.
+ * spacing is added between the children, while
+ * padding added by gtk_box_pack_start() or gtk_box_pack_end() is added
+ * on either side of the widget it belongs to.
*
* Use reorder_child() to
* move a child widget to a different place in the box.
+ *
+ * Use
+ * set_child_packing() to reset the pack options and padding attributes of any
+ * Gtk::Box child. Use query_child_packing() to query these fields.
*/
class Box
: public Container,
@@ -72,9 +90,21 @@ public:
*/
_WRAP_CTOR(Box(Orientation orientation = Orientation::HORIZONTAL, int spacing = 0), gtk_box_new)
- _WRAP_METHOD(void pack_start(Widget& child), gtk_box_pack_start)
+ _WRAP_METHOD(void pack_start(Widget& child, bool expand, bool fill), gtk_box_pack_start)
- _WRAP_METHOD(void pack_end(Widget& child), gtk_box_pack_end)
+ /** Left side insert a widget to a box.
+ * @param child A Widget to be added to box.
+ * @param options Controls how the widget expands to fill space, and how the space around them is used.
+ */
+ void pack_start(Widget& child, PackOptions options = PACK_EXPAND_WIDGET);
+
+ _WRAP_METHOD(void pack_end(Widget& child, bool expand, bool fill), gtk_box_pack_end)
+
+ /** Right side insert a widget to a box.
+ * @param child A Widget to be added to box.
+ * @param options Controls how the widget expands to fill space, and how the space around them is used.
+ */
+ void pack_end(Widget& child, PackOptions options = PACK_EXPAND_WIDGET);
_WRAP_METHOD(void set_homogeneous(bool homogeneous = true), gtk_box_set_homogeneous)
_WRAP_METHOD(bool get_homogeneous() const, gtk_box_get_homogeneous)
@@ -87,10 +117,21 @@ public:
_WRAP_METHOD(void reorder_child(Widget& child, int position), gtk_box_reorder_child)
+ _WRAP_METHOD(void set_center_widget(Widget& widget), gtk_box_set_center_widget)
+
+ /** Unset the center_widget.
+ * See set_center_widget().
+ */
+ void unset_center_widget();
+ _WRAP_METHOD(Widget* get_center_widget(), gtk_box_get_center_widget) //transfer none
+ _WRAP_METHOD(const Widget* get_center_widget() const, gtk_box_get_center_widget, constversion) //transfer
none
+
_WRAP_PROPERTY("spacing", int)
_WRAP_PROPERTY("homogeneous", bool)
_WRAP_PROPERTY("baseline-position", BaselinePosition)
+ _WRAP_CHILD_PROPERTY("expand", bool)
+ _WRAP_CHILD_PROPERTY("fill", bool)
_WRAP_CHILD_PROPERTY("pack-type", PackType)
_WRAP_CHILD_PROPERTY("position", int)
};
diff --git a/gtk/src/container.ccg b/gtk/src/container.ccg
index b3ea4fe..1d525c7 100644
--- a/gtk/src/container.ccg
+++ b/gtk/src/container.ccg
@@ -169,7 +169,7 @@ void Container_Class::remove_callback(GtkContainer* self, GtkWidget* p0)
// Custom hand-coded callback:
void Container_Class::forall_vfunc_callback(GtkContainer* self,
- GtkCallback callback, gpointer callback_data)
+ gboolean include_internals, GtkCallback callback, gpointer callback_data)
{
const auto obj_base = static_cast<Glib::ObjectBase*>(
Glib::ObjectBase::_get_current_wrapper((GObject*)self));
@@ -194,7 +194,7 @@ void Container_Class::forall_vfunc_callback(GtkContainer* self,
const auto slot = static_cast<Container::ForeachSlot*>(callback_data);
// Call the virtual member method, which derived classes might override.
- obj->forall_vfunc(*slot);
+ obj->forall_vfunc(include_internals, *slot);
}
else
{
@@ -203,7 +203,7 @@ void Container_Class::forall_vfunc_callback(GtkContainer* self,
{ callback(widget.gobj(), callback_data); };
// Call the virtual member method, which derived classes might override.
- obj->forall_vfunc(slot);
+ obj->forall_vfunc(include_internals, slot);
}
return;
}
@@ -220,7 +220,7 @@ void Container_Class::forall_vfunc_callback(GtkContainer* self,
// Call the original underlying C function:
if(base && base->forall)
- (*base->forall)(self, callback, callback_data);
+ (*base->forall)(self, include_internals, callback, callback_data);
}
void Container::foreach(const Container::ForeachSlot& slot)
diff --git a/gtk/src/container.hg b/gtk/src/container.hg
index f13eaac..bc6a251 100644
--- a/gtk/src/container.hg
+++ b/gtk/src/container.hg
@@ -171,18 +171,19 @@ protected:
*/
_WRAP_VFUNC(GType child_type() const, child_type)
- /** Invokes a callback on all non-internal children of the container.
+ /** Invokes a callback on all children of the container.
*
- * "Internal" children generally weren't added by the user of the container,
- * but were added by the container implementation itself.
+ * The callback may optionally be invoked also on children that are considered
+ * "internal" (implementation details of the container). "Internal" children
+ * generally weren't added by the user of the container, but were added by the
+ * container implementation itself.
*
- * %forall_vfunc() resembles foreach(): They don't invokes the callback for
- * internal children. forall() invokes it for all kinds of children.
* Most applications should use foreach(), rather than forall().
*
+ * @param include_internals
* @param slot A slot to call for each child.
*/
- _WRAP_VFUNC(void forall(const ForeachSlot& slot{callback}), forall,
+ _WRAP_VFUNC(void forall(bool include_internals, const ForeachSlot& slot{callback}), forall,
custom_vfunc_callback, slot_name slot, slot_callback container_foreach_callback, no_slot_copy)
/** Sets a child property for this container and its child.
diff --git a/gtk/src/label.hg b/gtk/src/label.hg
index 8ba4360..d93391c 100644
--- a/gtk/src/label.hg
+++ b/gtk/src/label.hg
@@ -102,6 +102,8 @@ public:
_WRAP_METHOD(Pango::WrapMode get_line_wrap_mode() const, gtk_label_get_line_wrap_mode)
_WRAP_METHOD(void set_selectable(bool setting = true), gtk_label_set_selectable)
_WRAP_METHOD(bool get_selectable() const, gtk_label_get_selectable)
+ _WRAP_METHOD(void set_angle(double angle), gtk_label_set_angle)
+ _WRAP_METHOD(double get_angle() const, gtk_label_get_angle)
_WRAP_METHOD(void select_region(int start_offset, int end_offset), gtk_label_select_region)
/** Selects a range of characters in the label, from @a start_offset to the end,
@@ -158,6 +160,7 @@ public:
_WRAP_PROPERTY("ellipsize", Pango::EllipsizeMode)
_WRAP_PROPERTY("width-chars", int)
_WRAP_PROPERTY("single-line-mode", bool)
+ _WRAP_PROPERTY("angle", double)
_WRAP_PROPERTY("max_width_chars", int)
_WRAP_PROPERTY("track-visited-links", bool)
_WRAP_PROPERTY("lines", int)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]