[goocanvasmm] Table: Replace GtkAttachOptions with GtkPackOptions.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goocanvasmm] Table: Replace GtkAttachOptions with GtkPackOptions.
- Date: Fri, 16 Dec 2016 16:27:56 +0000 (UTC)
commit c26f6908b637f3a08f9e9450c221a27c66dc34d4
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Dec 16 17:15:42 2016 +0100
Table: Replace GtkAttachOptions with GtkPackOptions.
GtkAttachOptions was in the GtkTable API, which has been
removed from GTK+ 4. Gtk::PackOptions is from Gtk::Box
(not part of GtkBox). It seems to be a good match.
examples/table/examplewindow.cc | 2 +-
examples/tablemodel/examplewindow.cc | 2 +-
goocanvas/src/table.ccg | 14 +++++++-------
goocanvas/src/table.hg | 3 ++-
goocanvas/src/tablemodel.ccg | 14 +++++++-------
goocanvas/src/tablemodel.hg | 3 ++-
tests/child_properties/main.cc | 2 +-
7 files changed, 21 insertions(+), 19 deletions(-)
---
diff --git a/examples/table/examplewindow.cc b/examples/table/examplewindow.cc
index 78b5f4b..9304e4b 100644
--- a/examples/table/examplewindow.cc
+++ b/examples/table/examplewindow.cc
@@ -63,7 +63,7 @@ ExampleWindow::ExampleWindow()
void ExampleWindow::add_text_to_cell(const Glib::RefPtr<Goocanvas::Table>& table, const Glib::ustring& text,
guint row, guint col)
{
auto text_item = Goocanvas::Text::create(text);
- table->attach(text_item, col, col+1, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
+ table->attach(text_item, col, col+1, row, row+1, Gtk::PACK_EXPAND_WIDGET, Gtk::PACK_SHRINK);
}
bool
diff --git a/examples/tablemodel/examplewindow.cc b/examples/tablemodel/examplewindow.cc
index 159a264..705f4cc 100644
--- a/examples/tablemodel/examplewindow.cc
+++ b/examples/tablemodel/examplewindow.cc
@@ -74,6 +74,6 @@ ExampleWindow::ExampleWindow()
void ExampleWindow::add_text_to_cell(const Glib::RefPtr<Goocanvas::TableModel>& table, const Glib::ustring&
text, guint row, guint col)
{
auto text_item = Goocanvas::TextModel::create(text);
- table->attach(text_item, col, col+1, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
+ table->attach(text_item, col, col+1, row, row+1, Gtk::PACK_EXPAND_WIDGET, Gtk::PACK_SHRINK);
}
diff --git a/goocanvas/src/table.ccg b/goocanvas/src/table.ccg
index f6e111e..8a41168 100644
--- a/goocanvas/src/table.ccg
+++ b/goocanvas/src/table.ccg
@@ -23,14 +23,14 @@ _PINCLUDE(goocanvasmm/private/group_p.h)
namespace Goocanvas
{
-void Table::attach(const Glib::RefPtr<Item>& item, guint left_attach, guint right_attach, guint top_attach,
guint bottom_attach, Gtk::AttachOptions xoptions, Gtk::AttachOptions yoptions, double left_padding, double
right_padding, double top_padding, double bottom_padding)
+void Table::attach(const Glib::RefPtr<Item>& item, guint left_attach, guint right_attach, guint top_attach,
guint bottom_attach, Gtk::PackOptions xoptions, Gtk::PackOptions yoptions, double left_padding, double
right_padding, double top_padding, double bottom_padding)
{
- const gboolean x_expand = (xoptions & Gtk::EXPAND) != 0;
- const gboolean x_fill = (xoptions & Gtk::FILL) != 0;
- const gboolean x_shrink = (xoptions & Gtk::SHRINK) != 0;
- const gboolean y_expand = (yoptions & Gtk::EXPAND) != 0;
- const gboolean y_fill = (yoptions & Gtk::FILL) != 0;
- const gboolean y_shrink = (yoptions & Gtk::SHRINK) != 0;
+ const gboolean x_expand = (xoptions == Gtk::PACK_EXPAND_PADDING) || (xoptions == Gtk::PACK_EXPAND_WIDGET);
+ const gboolean x_fill = (xoptions == Gtk::PACK_EXPAND_WIDGET);
+ const gboolean x_shrink = !x_expand;
+ const gboolean y_expand = (yoptions == Gtk::PACK_EXPAND_PADDING) || (yoptions == Gtk::PACK_EXPAND_WIDGET);
+ const gboolean y_fill = (yoptions == Gtk::PACK_EXPAND_WIDGET);
+ const gboolean y_shrink = !y_expand;
add_child(item);
goo_canvas_item_set_child_properties(GOO_CANVAS_ITEM(gobj()), item->gobj(),
diff --git a/goocanvas/src/table.hg b/goocanvas/src/table.hg
index 0619e13..1e7a255 100644
--- a/goocanvas/src/table.hg
+++ b/goocanvas/src/table.hg
@@ -18,6 +18,7 @@
#include <goocanvasmm/group.h>
#include <gtkmm/enums.h>
+#include <gtkmm/box.h> // For Gtk::PackOptions.
_DEFS(goocanvasmm,libgoocanvas)
@@ -50,7 +51,7 @@ public:
* @param top_padding The padding at the top.
* @param bottom_padding The padding at the bottom.
*/
- void attach(const Glib::RefPtr<Item>& item, guint left_attach, guint right_attach, guint top_attach, guint
bottom_attach, Gtk::AttachOptions xoptions = Gtk::FILL | Gtk::EXPAND, Gtk::AttachOptions yoptions = Gtk::FILL
| Gtk::EXPAND, double left_padding = 0.0, double right_padding = 0.0, double top_padding = 0.0, double
bottom_padding = 0.0);
+ void attach(const Glib::RefPtr<Item>& item, guint left_attach, guint right_attach, guint top_attach, guint
bottom_attach, Gtk::PackOptions xoptions = Gtk::PACK_EXPAND_WIDGET, Gtk::PackOptions yoptions =
Gtk::PACK_EXPAND_WIDGET, double left_padding = 0.0, double right_padding = 0.0, double top_padding = 0.0,
double bottom_padding = 0.0);
// TODO: We should get rid of this overload with the next gtkmm API/ABI break.
// See http://bugzilla.gnome.org/show_bug.cgi?id=142849.
diff --git a/goocanvas/src/tablemodel.ccg b/goocanvas/src/tablemodel.ccg
index 35bb27a..e40451e 100644
--- a/goocanvas/src/tablemodel.ccg
+++ b/goocanvas/src/tablemodel.ccg
@@ -23,14 +23,14 @@ _PINCLUDE(goocanvasmm/private/groupmodel_p.h)
namespace Goocanvas
{
-void TableModel::attach(const Glib::RefPtr<ItemModel>& item, guint left_attach, guint right_attach, guint
top_attach, guint bottom_attach, Gtk::AttachOptions xoptions, Gtk::AttachOptions yoptions, double
left_padding, double right_padding, double top_padding, double bottom_padding)
+void TableModel::attach(const Glib::RefPtr<ItemModel>& item, guint left_attach, guint right_attach, guint
top_attach, guint bottom_attach, Gtk::PackOptions xoptions, Gtk::PackOptions yoptions, double left_padding,
double right_padding, double top_padding, double bottom_padding)
{
- const gboolean x_expand = (xoptions & Gtk::EXPAND) != 0;
- const gboolean x_fill = (xoptions & Gtk::FILL) != 0;
- const gboolean x_shrink = (xoptions & Gtk::SHRINK) != 0;
- const gboolean y_expand = (yoptions & Gtk::EXPAND) != 0;
- const gboolean y_fill = (yoptions & Gtk::FILL) != 0;
- const gboolean y_shrink = (yoptions & Gtk::SHRINK) != 0;
+ const gboolean x_expand = (xoptions == Gtk::PACK_EXPAND_PADDING) || (xoptions == Gtk::PACK_EXPAND_WIDGET);
+ const gboolean x_fill = (xoptions == Gtk::PACK_EXPAND_WIDGET);
+ const gboolean x_shrink = !x_expand;
+ const gboolean y_expand = (yoptions == Gtk::PACK_EXPAND_PADDING) || (yoptions == Gtk::PACK_EXPAND_WIDGET);
+ const gboolean y_fill = (yoptions == Gtk::PACK_EXPAND_WIDGET);
+ const gboolean y_shrink = !y_expand;
add_child(item);
goo_canvas_item_model_set_child_properties(GOO_CANVAS_ITEM_MODEL(gobj()), item->gobj(),
diff --git a/goocanvas/src/tablemodel.hg b/goocanvas/src/tablemodel.hg
index 7c2878b..2efb88e 100644
--- a/goocanvas/src/tablemodel.hg
+++ b/goocanvas/src/tablemodel.hg
@@ -18,6 +18,7 @@
#include <goocanvasmm/groupmodel.h>
#include <gtkmm/enums.h>
+#include <gtkmm/box.h> // For Gtk::PackOptions.
_DEFS(goocanvasmm,libgoocanvas)
@@ -35,7 +36,7 @@ public:
_WRAP_CREATE()
- void attach(const Glib::RefPtr<ItemModel>& item, guint left_attach, guint right_attach, guint top_attach,
guint bottom_attach, Gtk::AttachOptions xoptions = Gtk::FILL | Gtk::EXPAND, Gtk::AttachOptions yoptions =
Gtk::FILL | Gtk::EXPAND, double left_padding = 0.0, double right_padding = 0.0, double top_padding = 0.0,
double bottom_padding = 0.0);
+ void attach(const Glib::RefPtr<ItemModel>& item, guint left_attach, guint right_attach, guint top_attach,
guint bottom_attach, Gtk::PackOptions xoptions = Gtk::PACK_EXPAND_WIDGET, Gtk::PackOptions yoptions =
Gtk::PACK_EXPAND_WIDGET, double left_padding = 0.0, double right_padding = 0.0, double top_padding = 0.0,
double bottom_padding = 0.0);
void set_align(const Glib::RefPtr<ItemModel>& child, double xalign = 0.0, double yalign = 0.0);
void set_align(const Glib::RefPtr<ItemModel>& child, Gtk::Align xalign = Gtk::ALIGN_START, Gtk::Align
yalign = Gtk::ALIGN_START);
diff --git a/tests/child_properties/main.cc b/tests/child_properties/main.cc
index 3180421..8bbca3f 100644
--- a/tests/child_properties/main.cc
+++ b/tests/child_properties/main.cc
@@ -28,7 +28,7 @@ main()
//Add a child to the table:
auto child = Goocanvas::Text::create("test");
- table->attach(child, 2, 3, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
+ table->attach(child, 2, 3, 5, 6, Gtk::PACK_EXPAND_WIDGET, Gtk::PACK_SHRINK);
//Examine the child property:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]