Code

NR::Maybe => boost::optional
[inkscape.git] / src / dialogs / tiledialog.cpp
index 75311ddd03dc3fa3b837a9ea02ffe0fce9817240..f9bde3c0b18bf5cabd4aa5f9fe6e26ee489f0a75 100644 (file)
@@ -49,8 +49,8 @@ sp_compare_x_position(SPItem *first, SPItem *second)
     using NR::X;
     using NR::Y;
 
-    NR::Maybe<NR::Rect> a = first->getBounds(sp_item_i2doc_affine(first));
-    NR::Maybe<NR::Rect> b = second->getBounds(sp_item_i2doc_affine(second));
+    boost::optional<NR::Rect> a = first->getBounds(from_2geom(sp_item_i2doc_affine(first)));
+    boost::optional<NR::Rect> b = second->getBounds(from_2geom(sp_item_i2doc_affine(second)));
 
     if ( !a || !b ) {
         // FIXME?
@@ -89,8 +89,8 @@ sp_compare_x_position(SPItem *first, SPItem *second)
 int
 sp_compare_y_position(SPItem *first, SPItem *second)
 {
-    NR::Maybe<NR::Rect> a = first->getBounds(sp_item_i2doc_affine(first));
-    NR::Maybe<NR::Rect> b = second->getBounds(sp_item_i2doc_affine(second));
+    boost::optional<NR::Rect> a = first->getBounds(from_2geom(sp_item_i2doc_affine(first)));
+    boost::optional<NR::Rect> b = second->getBounds(from_2geom(sp_item_i2doc_affine(second)));
 
     if ( !a || !b ) {
         // FIXME?
@@ -161,7 +161,7 @@ void TileDialog::Grid_Arrange ()
     grid_left = 99999;
     grid_top = 99999;
 
-    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+    SPDesktop *desktop = getDesktop();
     sp_document_ensure_up_to_date(sp_desktop_document(desktop));
 
     Inkscape::Selection *selection = sp_desktop_selection (desktop);
@@ -169,7 +169,7 @@ void TileDialog::Grid_Arrange ()
     cnt=0;
     for (; items != NULL; items = items->next) {
         SPItem *item = SP_ITEM(items->data);
-        NR::Maybe<NR::Rect> b = item->getBounds(sp_item_i2doc_affine(item));
+        boost::optional<NR::Rect> b = item->getBounds(from_2geom(sp_item_i2doc_affine(item)));
         if (!b) {
             continue;
         }
@@ -211,7 +211,7 @@ void TileDialog::Grid_Arrange ()
         const GSList *sizes = sorted;
         for (; sizes != NULL; sizes = sizes->next) {
             SPItem *item = SP_ITEM(sizes->data);
-            NR::Maybe<NR::Rect> b = item->getBounds(sp_item_i2doc_affine(item));
+            boost::optional<NR::Rect> b = item->getBounds(from_2geom(sp_item_i2doc_affine(item)));
             if (b) {
                 width = b->dimensions()[NR::X];
                 height = b->dimensions()[NR::Y];
@@ -268,7 +268,7 @@ void TileDialog::Grid_Arrange ()
     }
 
 
-    NR::Maybe<NR::Rect> sel_bbox = selection->bounds();
+    boost::optional<NR::Rect> sel_bbox = selection->bounds();
     // Fit to bbox, calculate padding between rows accordingly.
     if ( sel_bbox && !SpaceManualRadioButton.get_active() ){
 #ifdef DEBUG_GRID_ARRANGE
@@ -318,7 +318,7 @@ g_print("\n row = %f     col = %f selection x= %f selection y = %f", total_row_h
              for (; current_row != NULL; current_row = current_row->next) {
                  SPItem *item=SP_ITEM(current_row->data);
                  Inkscape::XML::Node *repr = SP_OBJECT_REPR(item);
-                 NR::Maybe<NR::Rect> b = item->getBounds(sp_item_i2doc_affine(item));
+                 boost::optional<NR::Rect> b = item->getBounds(from_2geom(sp_item_i2doc_affine(item)));
                  NR::Point min;
                  if (b) {
                      width = b->dimensions()[NR::X];
@@ -338,9 +338,9 @@ g_print("\n row = %f     col = %f selection x= %f selection y = %f", total_row_h
                  // signs are inverted between x and y due to y inversion
                  NR::Point move = NR::Point(new_x - min[NR::X], min[NR::Y] - new_y);
                  NR::Matrix const &affine = NR::Matrix(NR::translate(move));
-                 sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * affine);
+                 sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * to_2geom(affine));
                  sp_item_write_transform(item, repr, item->transform,  NULL);
-                 SP_OBJECT (current_row->data)->updateRepr(repr, SP_OBJECT_WRITE_EXT);
+                 SP_OBJECT (current_row->data)->updateRepr();
                  cnt +=1;
              }
              g_slist_free (current_row);
@@ -378,7 +378,7 @@ void TileDialog::on_row_spinbutton_changed()
 
     // in turn, prevent listener from responding
     updating = true;
-    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+    SPDesktop *desktop = getDesktop();
 
     Inkscape::Selection *selection = sp_desktop_selection (desktop);
 
@@ -403,7 +403,7 @@ void TileDialog::on_col_spinbutton_changed()
 
     // in turn, prevent listener from responding
     updating = true;
-    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+    SPDesktop *desktop = getDesktop();
     Inkscape::Selection *selection = sp_desktop_selection (desktop);
 
     GSList const *items = selection->itemList();
@@ -565,7 +565,7 @@ void TileDialog::updateSelection()
     row_height=0;
     // in turn, prevent listener from responding
     updating = true;
-    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+    SPDesktop *desktop = getDesktop();
     Inkscape::Selection *selection = sp_desktop_selection (desktop);
     const GSList *items = selection->itemList();
     int selcount = g_slist_length((GSList *)items);
@@ -593,13 +593,11 @@ void TileDialog::updateSelection()
 
 
 
-
-
 /*##########################
 ## Experimental
 ##########################*/
 
-static void updateSelectionCallback(Inkscape::Application *inkscape, Inkscape::Selection *selection, TileDialog *dlg)
+static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, TileDialog *dlg)
 {
     TileDialog *tledlg = (TileDialog *) dlg;
     tledlg->updateSelection();
@@ -613,7 +611,7 @@ static void updateSelectionCallback(Inkscape::Application *inkscape, Inkscape::S
  * Constructor
  */
 TileDialog::TileDialog()
-    : Dialog ("dialogs.gridtiler", SP_VERB_SELECTION_GRIDTILE)
+    : UI::Widget::Panel("", "dialogs.gridtiler", SP_VERB_SELECTION_GRIDTILE)
 {
      // bool used by spin button callbacks to stop loops where they change each other.
     updating = false;
@@ -628,13 +626,13 @@ TileDialog::TileDialog()
         g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (updateSelectionCallback), this);
     }
 
-    Gtk::VBox *mainVBox = get_vbox();
+    Gtk::Box *contents = _getContents();
 
 #define MARGIN 2
 
     //##Set up the panel
 
-    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+    SPDesktop *desktop = getDesktop();
 
     Inkscape::Selection *selection = sp_desktop_selection (desktop);
     int selcount = 1;
@@ -851,7 +849,7 @@ TileDialog::TileDialog()
 
     TileBox.pack_start(SizesHBox, false, false, MARGIN);
 
-    mainVBox->pack_start(TileBox);
+    contents->pack_start(TileBox);
 
     double SpacingType = prefs_get_double_attribute ("dialogs.gridtiler", "SpacingType", 15);
     if (SpacingType>0) {
@@ -864,7 +862,7 @@ TileDialog::TileDialog()
     SizesHBox.set_sensitive (ManualSpacing);
 
     //## The OK button
-    TileOkButton     = add_button(Gtk::Stock::APPLY,   GTK_RESPONSE_APPLY);
+    TileOkButton = addResponseButton(_("Arrange"), GTK_RESPONSE_APPLY);
     tips.set_tip((*TileOkButton), _("Arrange selected objects"));
 
     show_all_children();