[gtkmm] Gtk: Update for the latest gtk+4 (Remove Box::pack_start(), etc.)
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gtk: Update for the latest gtk+4 (Remove Box::pack_start(), etc.)
- Date: Mon, 4 Feb 2019 17:44:44 +0000 (UTC)
commit 75a8895dfea9f354184460cea78958da52846f78
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Mon Feb 4 18:37:14 2019 +0100
Gtk: Update for the latest gtk+4 (Remove Box::pack_start(), etc.)
* gtk/src/actionbar.hg: Remove child_property_position().
* gtk/src/bin.ccg: add_pixlabel(): pack_start() -> add().
* gtk/src/box.[ccg|hg]: Update the class documentation. Remove pack_start(),
pack_end(), reorder_child(), child_property_pack_type(),
child_property_position(), enum PackOptions. Add insert_child_after(),
insert_child_at_start(), reorder_child_after(), reorder_child_at_start().
* gtk/src/combobox.hg: Remove set/get/property_wrap_width(),
set/get/property_row_span_column(), set/get/property_column_span_column().
* gtk/src/headerbar.hg: Remove child_property_position().
* gtk/src/menu.hg: Remove attach(). Remove all child properties.
* gtk/src/widget.[ccg|hg]: Replace the insert_before/after() overloads without
a sibling parameter with insert_at_start() and insert_at_end().
Add set_expand().
gtk/src/actionbar.hg | 1 -
gtk/src/bin.ccg | 5 +--
gtk/src/box.ccg | 35 ++--------------
gtk/src/box.hg | 113 +++++++++++++++++++--------------------------------
gtk/src/combobox.hg | 12 ------
gtk/src/headerbar.hg | 2 -
gtk/src/menu.hg | 7 ----
gtk/src/widget.ccg | 16 +++++++-
gtk/src/widget.hg | 54 +++++++++++++++++++++++-
9 files changed, 115 insertions(+), 130 deletions(-)
---
diff --git a/gtk/src/actionbar.hg b/gtk/src/actionbar.hg
index 2d845e8f..bb3c432a 100644
--- a/gtk/src/actionbar.hg
+++ b/gtk/src/actionbar.hg
@@ -68,7 +68,6 @@ public:
_WRAP_PROPERTY("revealed", bool, newin "3,92")
_WRAP_CHILD_PROPERTY("pack-type", PackType, newin "3,92")
- _WRAP_CHILD_PROPERTY("position", int, newin "3,92")
// Gtk::ActionBar has no signals nor vfuncs as of 3.90.
};
diff --git a/gtk/src/bin.ccg b/gtk/src/bin.ccg
index 7004a85a..2ef4a083 100644
--- a/gtk/src/bin.ccg
+++ b/gtk/src/bin.ccg
@@ -39,7 +39,6 @@ Bin::add_label(const Glib::ustring& str, bool mnemonic,
{
auto label = manage(new Label(str, x_align, y_align, mnemonic));
add(*label);
- label->show();
}
void
@@ -53,8 +52,8 @@ Bin::add_pixlabel(const std::string& pixfile,
//Put them in a Box:
auto hbox = manage(new Box(Orientation::HORIZONTAL, 5));
- hbox->pack_start(*pmap, PackOptions::SHRINK);
- hbox->pack_start(*label);
+ hbox->add(*pmap);
+ hbox->add(*label);
//And put that Box in this:
add(*hbox);
diff --git a/gtk/src/box.ccg b/gtk/src/box.ccg
index 48624ebf..b72e3f33 100644
--- a/gtk/src/box.ccg
+++ b/gtk/src/box.ccg
@@ -22,41 +22,14 @@
namespace Gtk
{
-
-void Box::pack_start(Widget& child, PackOptions options)
+void Box::insert_child_at_start(Widget& child)
{
- // Avoid using our custom code in this case:
- if (options == PackOptions::SHRINK) {
- return pack_start(child);
- }
-
- const bool expand = (options == PackOptions::EXPAND_PADDING) || (options == PackOptions::EXPAND_WIDGET);
- const bool fill = (options == PackOptions::EXPAND_WIDGET);
-
- child.property_hexpand() = expand;
- child.property_vexpand() = expand;
- child.property_halign() = fill ? Gtk::Align::FILL : Gtk::Align::START;
- child.property_valign() = fill ? Gtk::Align::FILL : Gtk::Align::START;
-
- gtk_box_pack_start(gobj(), child.gobj());
+ gtk_box_insert_child_after(gobj(), child.gobj(), nullptr);
}
-void Box::pack_end(Widget& child, PackOptions options)
+void Box::reorder_child_at_start(Widget& child)
{
- // Avoid using our custom code in this case:
- if (options == PackOptions::SHRINK) {
- return pack_end(child);
- }
-
- const bool expand = (options == PackOptions::EXPAND_PADDING) || (options == PackOptions::EXPAND_WIDGET);
- const bool fill = (options == PackOptions::EXPAND_WIDGET);
-
- child.property_hexpand() = expand;
- child.property_vexpand() = expand;
- child.property_halign() = fill ? Gtk::Align::FILL : Gtk::Align::END;
- child.property_valign() = fill ? Gtk::Align::FILL : Gtk::Align::END;
-
- gtk_box_pack_end(gobj(), child.gobj());
+ gtk_box_reorder_child_after(gobj(), child.gobj(), nullptr);
}
} //namespace Gtk
diff --git a/gtk/src/box.hg b/gtk/src/box.hg
index ee803c8b..4d339f59 100644
--- a/gtk/src/box.hg
+++ b/gtk/src/box.hg
@@ -20,59 +20,32 @@ _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 class PackOptions
-{
- SHRINK, /**< Space is contracted to the child widget size. */
- EXPAND_PADDING, /**< Space is expanded, with extra space filled with padding. */
- 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
- * or a single column of child widgets depending upon the orientation.
- * Thus, all children of a Box are allocated one dimension in common,
- * which is the height of a row, or the width of a column.
+/** A container for packing widgets in a single row or column.
*
- * Gtk::Box uses a notion of packing. Packing refers to adding widgets with
- * reference to a particular position in a Gtk::Container. There are two
- * reference positions: the start and the end of the box. For a vertical Box, the start
- * is defined as the top of the box and the end is defined as the bottom. For
- * a horizontal Box the start is defined as the left side and the end is defined as the
- * right side. Use repeated calls to pack_start() to pack widgets into a
- * Gtk::Box from start to end. Use pack_end() to add widgets from end to start.
- * You may intersperse these calls and add widgets from both ends of the same
- * Gtk::Box. The last widget added with pack_start() will be placed just before
- * the last widget added with pack_end()
+ * The %Gtk::Box widget arranges child widgets into a single row or column,
+ * depending upon the value of its Gtk::Orientable::property_orientation() property.
+ * Within the other dimension, all children are allocated the same size. Of course,
+ * Gtk::Widget::set_halign() and Gtk::Widget::set_valign() can be used on
+ * the children to influence their allocation.
*
- * Because Gtk::Box is a Gtk::Container, you may also use Gtk::Container::add()
- * to insert widgets, and they will be packed as if with pack_start(). Use
- * Gtk::Container::remove() to remove widgets.
+ * Use repeated calls to Gtk::Container::add() to pack widgets into a
+ * %Gtk::Box from start to end. Use Gtk::Container::remove() to remove widgets
+ * from the %Gtk::Box. insert_child_after() and insert_child_at_start() can be used
+ * to add a child at a particular position.
*
- * Use set_homogeneous() to specify whether or not all children of the Gtk::Box
- * occupy the same amount of space.
+ * Use set_homogeneous() to specify whether or not all children
+ * of the %Gtk::Box are forced to get the same amount of space.
*
- * Use set_spacing() to determine the minimum
- * space placed between all children in the Gtk::Box. Note that
- * spacing is added between the children, while
- * padding added by pack_start() or pack_end() is added
- * on either side of the widget it belongs to.
+ * Use set_spacing() to determine how much space will be
+ * minimally placed between all children in the %Gtk::Box. Note that
+ * spacing is added between the children.
*
- * 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.
+ * Use reorder_child_after() and reorder_child_at_start() to move a child to
+ * a different place in the box.
*/
class Box
: public Container,
@@ -80,7 +53,6 @@ class Box
{
_CLASS_GTKOBJECT(Box,GtkBox,GTK_BOX,Gtk::Container,GtkContainer)
_IMPLEMENTS_INTERFACE(Orientable)
- _IGNORE(gtk_box_set_child_packing, gtk_box_query_child_packing)
public:
//Note that we try to use the same default parameter value as the default property value.
@@ -90,28 +62,6 @@ public:
*/
_WRAP_CTOR(Box(Orientation orientation = Orientation::HORIZONTAL, int spacing = 0), gtk_box_new)
- // Note: GtkWidget's halign default is GTK_ALIGN_FILL, and its hexpand default is false
- _WRAP_METHOD(void pack_start(Widget& child), gtk_box_pack_start)
-
- // TODO: Remove this. Its current implementation is not a complete replacement for the behavior in gtkmm 3.
- // It would be best for application code to port completely to use hexpand/vexpand/halign/valign.
- /** 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);
-
- // Note: GtkWidget's halign default is GTK_ALIGN_FILL, and its hexpand default is false
- _WRAP_METHOD(void pack_end(Widget& child), gtk_box_pack_end)
-
- // TODO: Remove this. Its current implementation is not a complete replacement for the behavior in gtkmm 3.
- // It would be best for application code to port completely to use hexpand/vexpand/halign/valign.
- /** 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);
-
_WRAP_METHOD(void set_homogeneous(bool homogeneous = true), gtk_box_set_homogeneous)
_WRAP_METHOD(bool get_homogeneous() const, gtk_box_get_homogeneous)
@@ -121,14 +71,35 @@ public:
_WRAP_METHOD(void set_baseline_position(BaselinePosition position), gtk_box_set_baseline_position)
_WRAP_METHOD(BaselinePosition get_baseline_position() const, gtk_box_get_baseline_position)
- _WRAP_METHOD(void reorder_child(Widget& child, int position), gtk_box_reorder_child)
+ /** Inserts @a child in the position after @a sibling in the list of children.
+ *
+ * @param child The Gtk::Widget to insert.
+ * @param sibling The sibling to move @a child after.
+ */
+ _WRAP_METHOD(void insert_child_after(Widget& child, const Widget& sibling), gtk_box_insert_child_after)
+
+ /** Inserts @a child in the first position in the list of children.
+ *
+ * @param child The Gtk::Widget to insert.
+ */
+ void insert_child_at_start(Widget& child);
+
+ /** Moves @a child to the position after @a sibling in the list of children.
+ *
+ * @param child The Gtk::Widget to move. Must be a child of the %Box.
+ * @param sibling The sibling to move @a child after.
+ */
+ _WRAP_METHOD(void reorder_child_after(Widget& child, const Widget& sibling), gtk_box_reorder_child_after)
+
+ /** Moves @a child to the first position in the list of children.
+ *
+ * @param child The Gtk::Widget to move. Must be a child of the %Box.
+ */
+ void reorder_child_at_start(Widget& child);
_WRAP_PROPERTY("spacing", int)
_WRAP_PROPERTY("homogeneous", bool)
_WRAP_PROPERTY("baseline-position", BaselinePosition)
-
- _WRAP_CHILD_PROPERTY("pack-type", PackType)
- _WRAP_CHILD_PROPERTY("position", int)
};
} // namespace Gtk
diff --git a/gtk/src/combobox.hg b/gtk/src/combobox.hg
index 7aa3342d..c0b79598 100644
--- a/gtk/src/combobox.hg
+++ b/gtk/src/combobox.hg
@@ -81,15 +81,6 @@ public:
_IGNORE(gtk_combo_box_new_with_model, gtk_combo_box_new_with_model_and_entry)
_IGNORE(gtk_combo_box_new)
- _WRAP_METHOD(void set_wrap_width(int width), gtk_combo_box_set_wrap_width)
- _WRAP_METHOD(int get_wrap_width() const, gtk_combo_box_get_wrap_width)
-
- _WRAP_METHOD(void set_row_span_column(int row_span), gtk_combo_box_set_row_span_column)
- _WRAP_METHOD(int get_row_span_column() const, gtk_combo_box_get_row_span_column)
-
- _WRAP_METHOD(void set_column_span_column(int column_span), gtk_combo_box_set_column_span_column)
- _WRAP_METHOD(int get_column_span_column() const, gtk_combo_box_get_column_span_column)
-
/* get/set active item */
_WRAP_METHOD(int get_active_row_number() const, gtk_combo_box_get_active)
@@ -194,9 +185,6 @@ public:
_WRAP_PROPERTY("model", Glib::RefPtr<TreeModel>)
- _WRAP_PROPERTY("wrap_width", int)
- _WRAP_PROPERTY("row_span_column", int)
- _WRAP_PROPERTY("column_span_column", int)
_WRAP_PROPERTY("active", int)
_WRAP_PROPERTY("has-frame", bool)
_WRAP_PROPERTY("popup-shown", bool)
diff --git a/gtk/src/headerbar.hg b/gtk/src/headerbar.hg
index 77ffdbdc..e517d55d 100644
--- a/gtk/src/headerbar.hg
+++ b/gtk/src/headerbar.hg
@@ -73,7 +73,6 @@ public:
_WRAP_METHOD(Glib::ustring get_decoration_layout() const, gtk_header_bar_get_decoration_layout)
-
_WRAP_PROPERTY("custom-title", Gtk::Widget*)
_WRAP_PROPERTY("show-title-buttons", bool)
_WRAP_PROPERTY("spacing", int)
@@ -84,7 +83,6 @@ public:
_WRAP_PROPERTY("has-subtitle", bool)
_WRAP_CHILD_PROPERTY("pack-type", PackType)
- _WRAP_CHILD_PROPERTY("position", int)
// Gtk::HeaderBar has no signals nor vfuncs as of 3.12.
};
diff --git a/gtk/src/menu.hg b/gtk/src/menu.hg
index d0b84c45..b268b29f 100644
--- a/gtk/src/menu.hg
+++ b/gtk/src/menu.hg
@@ -92,8 +92,6 @@ public:
_WRAP_METHOD(void set_display(const Glib::RefPtr<Gdk::Display>& display), gtk_menu_set_display)
- _WRAP_METHOD(void attach(Gtk::Widget& child, guint left_attach, guint right_attach, guint top_attach,
guint bottom_attach), gtk_menu_attach)
-
_WRAP_METHOD(void set_monitor(int monitor_num), gtk_menu_set_monitor)
_WRAP_METHOD(int get_monitor() const, gtk_menu_get_monitor)
_WRAP_METHOD(void place_on_monitor(const Glib::RefPtr<Gdk::Monitor>& monitor), gtk_menu_place_on_monitor)
@@ -130,11 +128,6 @@ public:
_WRAP_PROPERTY("rect-anchor-dy", int)
_WRAP_PROPERTY("menu-type-hint", Gdk::Surface::TypeHint)
- _WRAP_CHILD_PROPERTY("left-attach", int)
- _WRAP_CHILD_PROPERTY("right-attach", int)
- _WRAP_CHILD_PROPERTY("top-attach", int)
- _WRAP_CHILD_PROPERTY("bottom-attach", int)
-
protected:
//TODO: Remove this if it has never been used, at the next ABI break?
diff --git a/gtk/src/widget.ccg b/gtk/src/widget.ccg
index 749ababc..362a59e2 100644
--- a/gtk/src/widget.ccg
+++ b/gtk/src/widget.ccg
@@ -506,6 +506,11 @@ void Widget::set_margin(int margin)
property_margin() = margin;
}
+void Widget::set_expand(bool expand)
+{
+ property_expand() = expand;
+}
+
void Widget::add_controller(const Glib::RefPtr<EventController>& controller)
{
// gtk_widget_add_controller() does not take a ref.
@@ -514,7 +519,6 @@ void Widget::add_controller(const Glib::RefPtr<EventController>& controller)
gtk_widget_add_controller(gobj(), Glib::unwrap(controller));
}
-
guint Widget::add_tick_callback(const SlotTick& slot)
{
// Create a copy of the slot object. A pointer to this will be passed
@@ -526,4 +530,14 @@ guint Widget::add_tick_callback(const SlotTick& slot)
&Glib::destroy_notify_delete<SlotTick>);
}
+void Widget::insert_at_start(Widget& parent)
+{
+ gtk_widget_insert_after(gobj(), parent.gobj(), nullptr);
+}
+
+void Widget::insert_at_end(Widget& parent)
+{
+ gtk_widget_insert_before(gobj(), parent.gobj(), nullptr);
+}
+
} // namespace Gtk
diff --git a/gtk/src/widget.hg b/gtk/src/widget.hg
index 44aa3eaf..4d408daf 100644
--- a/gtk/src/widget.hg
+++ b/gtk/src/widget.hg
@@ -302,6 +302,13 @@ public:
_WRAP_METHOD(void queue_compute_expand(), gtk_widget_queue_compute_expand)
_WRAP_METHOD(bool compute_expand(Orientation orientation), gtk_widget_compute_expand)
+ /** Sets whether the widget would like any available extra space in both directions.
+ *
+ * @see set_hexpand() for more detail.
+ * @param expand Whether to expand in horizontal and vertical direction.
+ */
+ void set_expand(bool expand = true);
+
_WRAP_METHOD(bool get_support_multidevice() const, gtk_widget_get_support_multidevice)
_WRAP_METHOD(void set_support_multidevice(bool support_multidevice = true),
gtk_widget_set_support_multidevice)
@@ -576,8 +583,51 @@ public:
_WRAP_METHOD(Glib::RefPtr<Gio::ListModel> observe_controllers(), gtk_widget_observe_controllers)
_WRAP_METHOD(Glib::RefPtr<const Gio::ListModel> observe_controllers() const,
gtk_widget_observe_controllers, constversion)
- _WRAP_METHOD(void insert_after(Widget& parent, Widget& previous_sibling{?}), gtk_widget_insert_after)
- _WRAP_METHOD(void insert_before(Widget& parent, Widget& next_sibling{?}), gtk_widget_insert_before)
+ /** Inserts the %Widget into the child widget list of @a parent after @a previous_sibling.
+ *
+ * After calling this function, get_prev_sibling() will return @a previous_sibling.
+ *
+ * If @a parent is already set as the parent widget of the %Widget, this function can also be used
+ * to reorder the %Widget in the child widget list of @a parent.
+ *
+ * @param parent The parent Gtk::Widget to insert the %Widget into.
+ * @param previous_sibling The new previous sibling of the %Widget.
+ */
+ _WRAP_METHOD(void insert_after(Widget& parent, const Widget& previous_sibling), gtk_widget_insert_after)
+
+ /** Inserts the %Widget into the child widget list of @a parent before @a next_sibling.
+ *
+ * After calling this function, get_next_sibling() will return @a next_sibling.
+ *
+ * If @a parent is already set as the parent widget of the %Widget, this function can also be used
+ * to reorder the %Widget in the child widget list of @a parent.
+ *
+ * @param parent The parent Gtk::Widget to insert the %Widget into.
+ * @param next_sibling The new next sibling of the %Widget.
+ */
+ _WRAP_METHOD(void insert_before(Widget& parent, const Widget& next_sibling), gtk_widget_insert_before)
+
+ /** Inserts the %Widget at the beginning of the child widget list of @a parent.
+ *
+ * After calling this function, get_prev_sibling() will return <tt>nullptr</tt>.
+ *
+ * If @a parent is already set as the parent of the %Widget, this function can also be used
+ * to reorder the %Widget in the child widget list of @a parent.
+ *
+ * @param parent The parent Gtk::Widget to insert the %Widget into.
+ */
+ void insert_at_start(Widget& parent);
+
+ /** Inserts the %Widget at the end of the child widget list of @a parent.
+ *
+ * After calling this function, get_next_sibling() will return <tt>nullptr</tt>.
+ *
+ * If @a parent is already set as the parent of the %Widget, this function can also be used
+ * to reorder the %Widget in the child widget list of @a parent.
+ *
+ * @param parent The parent Gtk::Widget to insert the %Widget into.
+ */
+ void insert_at_end(Widget& parent);
//TODO: gtk_widget_set_focus_child() is not documented. Wrap or _IGNORE?
// 2017-06-06: The gtk+ API is not stable yet. See https://bugzilla.gnome.org/show_bug.cgi?id=783445#c2
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]