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



commit 5f1e3596a4a400e1a72e2cd0b65d33475e3c518e
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Dec 16 16:58:34 2016 +0100

    Revert "Table/TableModel: attach(): Remove the GtkAttachOptions parameters."
    
    This reverts commit 6c045a8cce20e50e6b507a76f191b29a3f2fcafe.

 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, 36 insertions(+), 37 deletions(-)
---
diff --git a/examples/table/examplewindow.cc b/examples/table/examplewindow.cc
index 7cfba90..78b5f4b 100644
--- a/examples/table/examplewindow.cc
+++ b/examples/table/examplewindow.cc
@@ -63,16 +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);
-
-  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));
+  table->attach(text_item, col, col+1, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
 }
 
 bool
diff --git a/examples/tablemodel/examplewindow.cc b/examples/tablemodel/examplewindow.cc
index 46bd788..159a264 100644
--- a/examples/tablemodel/examplewindow.cc
+++ b/examples/tablemodel/examplewindow.cc
@@ -74,14 +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);
-  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));
+  table->attach(text_item, col, col+1, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
 }
 
diff --git a/goocanvas/src/table.ccg b/goocanvas/src/table.ccg
index 8cdcd0c..f6e111e 100644
--- a/goocanvas/src/table.ccg
+++ b/goocanvas/src/table.ccg
@@ -23,15 +23,27 @@ _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,
-  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::AttachOptions xoptions, Gtk::AttachOptions 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;
+
   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 293df4d..0619e13 100644
--- a/goocanvas/src/table.hg
+++ b/goocanvas/src/table.hg
@@ -43,13 +43,14 @@ 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,
-    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::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);
 
   // 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 a4921fd..35bb27a 100644
--- a/goocanvas/src/tablemodel.ccg
+++ b/goocanvas/src/tablemodel.ccg
@@ -23,20 +23,32 @@ _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,
-  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::AttachOptions xoptions, Gtk::AttachOptions 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;
+
   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 1c4c23d..7c2878b 100644
--- a/goocanvas/src/tablemodel.hg
+++ b/goocanvas/src/tablemodel.hg
@@ -35,8 +35,7 @@ public:
 
   _WRAP_CREATE()
 
-  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 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 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 7fc1562..3180421 100644
--- a/tests/child_properties/main.cc
+++ b/tests/child_properties/main.cc
@@ -28,15 +28,7 @@ main()
 
   //Add a child to the table:
   auto child = Goocanvas::Text::create("test");
-  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));
+  table->attach(child, 2, 3, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
 
   //Examine the child property:
 


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