[goocanvasmm] Table/TableModel: attach(): Remove the GtkAttachOptions parameters.



commit 6c045a8cce20e50e6b507a76f191b29a3f2fcafe
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Dec 16 12:36:08 2016 +0100

    Table/TableModel: attach(): Remove the GtkAttachOptions parameters.
    
    GtkAttachOptions was part of the GtkTable API, which has been
    removed from GTK+ 4.
    We used this enum in the goocanvasmm API to make the goocanvas
    API friendlier. We need to find a new way to do that.

 examples/table/examplewindow.cc      |   11 ++++++++++-
 examples/tablemodel/examplewindow.cc |   10 +++++++++-
 goocanvas/src/table.ccg              |   16 ++--------------
 goocanvas/src/table.hg               |    5 ++---
 goocanvas/src/tablemodel.ccg         |   18 +++---------------
 goocanvas/src/tablemodel.hg          |    3 ++-
 tests/child_properties/main.cc       |   10 +++++++++-
 7 files changed, 37 insertions(+), 36 deletions(-)
---
diff --git a/examples/table/examplewindow.cc b/examples/table/examplewindow.cc
index 78b5f4b..7cfba90 100644
--- a/examples/table/examplewindow.cc
+++ b/examples/table/examplewindow.cc
@@ -63,7 +63,16 @@ 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);
+
+  goo_canvas_item_set_child_properties(GOO_CANVAS_ITEM(table->gobj()), GOO_CANVAS_ITEM(text_item->gobj()),
+    "x-fill", TRUE,
+    "x-expand", TRUE,
+    "x-shrink", FALSE,
+    "y-fill", FALSE,
+    "y-expand", FALSE,
+    "y-shrink", TRUE,
+    static_cast<void*>(0));
 }
 
 bool
diff --git a/examples/tablemodel/examplewindow.cc b/examples/tablemodel/examplewindow.cc
index 159a264..46bd788 100644
--- a/examples/tablemodel/examplewindow.cc
+++ b/examples/tablemodel/examplewindow.cc
@@ -74,6 +74,14 @@ 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);
+  goo_canvas_item_set_child_properties(GOO_CANVAS_ITEM(table->gobj()), GOO_CANVAS_ITEM(text_item->gobj()),
+    "x-fill", TRUE,
+    "x-expand", TRUE,
+    "x-shrink", FALSE,
+    "y-fill", FALSE,
+    "y-expand", FALSE,
+    "y-shrink", TRUE,
+    static_cast<void*>(0));
 }
 
diff --git a/goocanvas/src/table.ccg b/goocanvas/src/table.ccg
index f6e111e..8cdcd0c 100644
--- a/goocanvas/src/table.ccg
+++ b/goocanvas/src/table.ccg
@@ -23,27 +23,15 @@ _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,
+  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;
-
   add_child(item);
   goo_canvas_item_set_child_properties(GOO_CANVAS_ITEM(gobj()), item->gobj(),
                                        "column", left_attach,
                                        "columns", right_attach - left_attach,
                                        "row", top_attach,
                                        "rows", bottom_attach - top_attach,
-                                       "x-fill", x_fill,
-                                       "x-expand", x_expand,
-                                       "x-shrink", x_shrink,
-                                       "y-fill", y_fill,
-                                       "y-expand", y_expand,
-                                       "y-shrink", y_shrink,
                                        "left-padding", left_padding,
                                        "right-padding", right_padding,
                                        "top-padding", top_padding,
diff --git a/goocanvas/src/table.hg b/goocanvas/src/table.hg
index 0619e13..293df4d 100644
--- a/goocanvas/src/table.hg
+++ b/goocanvas/src/table.hg
@@ -43,14 +43,13 @@ public:
    * @param right_attach The right column to attach the item. Just use left_attach+1 for a single column.
    * @param top_attach The top column to attach the item.
    * @param bottom_attach The bottom column to attach the item. Just use top_attach+1 for a single column.
-   * @param xoptions Whether the item should expand or shrink.
-   * @param yoptions Whether the item should expand or shrink.
    * @param left_padding The padding at the left.
    * @param right_padding The padding at the right.
    * @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,
+    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..a4921fd 100644
--- a/goocanvas/src/tablemodel.ccg
+++ b/goocanvas/src/tablemodel.ccg
@@ -23,32 +23,20 @@ _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,
+  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;
-
   add_child(item);
   goo_canvas_item_model_set_child_properties(GOO_CANVAS_ITEM_MODEL(gobj()), item->gobj(),
                                              "column", left_attach,
                                              "columns", right_attach - left_attach,
                                              "row", top_attach,
                                              "rows", bottom_attach - top_attach,
-                                             "x-fill", x_fill,
-                                             "x-expand", x_expand,
-                                             "x-shrink", x_shrink,
-                                             "y-fill", y_fill,
-                                             "y-expand", y_expand,
-                                             "y-shrink", y_shrink,
                                              "left-padding", left_padding,
                                              "right-padding", right_padding,
                                              "top-padding", top_padding,
                                              "bottom-padding", bottom_padding,
-                                              static_cast<void*>(0));
+                                             static_cast<void*>(0));
 }
 
 void TableModel::set_align(const Glib::RefPtr<ItemModel>& child, double xalign, double yalign)
diff --git a/goocanvas/src/tablemodel.hg b/goocanvas/src/tablemodel.hg
index 7c2878b..1c4c23d 100644
--- a/goocanvas/src/tablemodel.hg
+++ b/goocanvas/src/tablemodel.hg
@@ -35,7 +35,8 @@ 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,
+    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..7fc1562 100644
--- a/tests/child_properties/main.cc
+++ b/tests/child_properties/main.cc
@@ -28,7 +28,15 @@ 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);
+  goo_canvas_item_set_child_properties(GOO_CANVAS_ITEM(table->gobj()), GOO_CANVAS_ITEM(child->gobj()),
+    "x-fill", TRUE,
+    "x-expand", TRUE,
+    "x-shrink", FALSE,
+    "y-fill", FALSE,
+    "y-expand", FALSE,
+    "y-shrink", TRUE,
+    static_cast<void*>(0));
 
   //Examine the child property:
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]