From 1636c1dd1651780d01759676b194312529f211f7 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Sat, 25 Jun 2016 22:24:26 +0200 Subject: Moved next functions, added namespace, renamed range functions (bzr r14954.1.10) --- src/ui/dialog/clonetiler.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ui/dialog/clonetiler.cpp') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index b727c87ee..7ce937de7 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1376,7 +1376,7 @@ void CloneTiler::clonetiler_change_selection(Inkscape::Selection *selection, Gtk return; } - if (selection->itemList().size() > 1) { + if (selection->items().size() > 1) { gtk_widget_set_sensitive (buttons, FALSE); gtk_label_set_markup (GTK_LABEL(status), _("More than one object selected.")); return; @@ -2113,7 +2113,7 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) Inkscape::Selection *selection = desktop->getSelection(); // check if something is selected - if (selection->isEmpty() || selection->itemList().size() > 1) { + if (selection->isEmpty() || selection->items().size() > 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select one object whose tiled clones to unclump.")); return; } @@ -2162,7 +2162,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d Inkscape::Selection *selection = desktop->getSelection(); // check if something is selected - if (selection->isEmpty() || selection->itemList().size() > 1) { + if (selection->isEmpty() || selection->items().size() > 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select one object whose tiled clones to remove.")); return; } @@ -2240,7 +2240,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) } // Check if more than one object is selected. - if (selection->itemList().size() > 1) { + if (selection->items().size() > 1) { desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, group them and clone the group.")); return; } -- cgit v1.2.3 From d1947e768272c703674129d5c583204ff2b59251 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 13 Jul 2016 13:36:19 +0200 Subject: Second part of new SPObject children list (bzr r14954.1.19) --- src/ui/dialog/clonetiler.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/ui/dialog/clonetiler.cpp') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 87c90c460..11af02e3c 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -2042,12 +2042,12 @@ void CloneTiler::clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) if (!trace_drawing) return; - for (SPObject *o = from->firstChild(); o != NULL; o = o->next) { - SPItem *item = dynamic_cast(o); - if (item && clonetiler_is_a_clone_of(o, NULL)) { + for (auto& o: from->_children) { + SPItem *item = dynamic_cast(&o); + if (item && clonetiler_is_a_clone_of(&o, NULL)) { item->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too! } - clonetiler_trace_hide_tiled_clones_recursively (o); + clonetiler_trace_hide_tiled_clones_recursively (&o); } } @@ -2123,9 +2123,9 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) std::vector to_unclump; // not including the original - for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { - if (clonetiler_is_a_clone_of (child, obj)) { - to_unclump.push_back((SPItem*)child); + for (auto& child: parent->_children) { + if (clonetiler_is_a_clone_of (&child, obj)) { + to_unclump.push_back((SPItem*)&child); } } @@ -2143,8 +2143,8 @@ guint CloneTiler::clonetiler_number_of_clones(SPObject *obj) guint n = 0; - for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { - if (clonetiler_is_a_clone_of (child, obj)) { + for (auto& child: parent->_children) { + if (clonetiler_is_a_clone_of (&child, obj)) { n ++; } } @@ -2172,9 +2172,9 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d // remove old tiling GSList *to_delete = NULL; - for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { - if (clonetiler_is_a_clone_of (child, obj)) { - to_delete = g_slist_prepend (to_delete, child); + for (auto& child: parent->_children) { + if (clonetiler_is_a_clone_of (&child, obj)) { + to_delete = g_slist_prepend (to_delete, &child); } } for (GSList *i = to_delete; i; i = i->next) { -- cgit v1.2.3 From 24d3f50003ca3cec6a03a7f5267cc4fe5588c69f Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 14 Jul 2016 13:17:21 +0200 Subject: Renamed children list in SPObject (bzr r14954.1.21) --- src/ui/dialog/clonetiler.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ui/dialog/clonetiler.cpp') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 11af02e3c..1e8ca4405 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -2042,7 +2042,7 @@ void CloneTiler::clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) if (!trace_drawing) return; - for (auto& o: from->_children) { + for (auto& o: from->children) { SPItem *item = dynamic_cast(&o); if (item && clonetiler_is_a_clone_of(&o, NULL)) { item->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too! @@ -2123,7 +2123,7 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) std::vector to_unclump; // not including the original - for (auto& child: parent->_children) { + for (auto& child: parent->children) { if (clonetiler_is_a_clone_of (&child, obj)) { to_unclump.push_back((SPItem*)&child); } @@ -2143,7 +2143,7 @@ guint CloneTiler::clonetiler_number_of_clones(SPObject *obj) guint n = 0; - for (auto& child: parent->_children) { + for (auto& child: parent->children) { if (clonetiler_is_a_clone_of (&child, obj)) { n ++; } @@ -2172,7 +2172,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d // remove old tiling GSList *to_delete = NULL; - for (auto& child: parent->_children) { + for (auto& child: parent->children) { if (clonetiler_is_a_clone_of (&child, obj)) { to_delete = g_slist_prepend (to_delete, &child); } -- cgit v1.2.3 From dcd91f59f597ab4af07cee5929ce0e2e1f9104d5 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 28 Jul 2016 16:16:18 +0100 Subject: Drop remaining GTKMM 2 fallback support (bzr r15023.2.7) --- src/ui/dialog/clonetiler.cpp | 217 ++++++------------------------------------- 1 file changed, 28 insertions(+), 189 deletions(-) (limited to 'src/ui/dialog/clonetiler.cpp') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index b727c87ee..da00b7b00 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -91,12 +91,8 @@ CloneTiler::CloneTiler () : dlg = GTK_WIDGET(gobj()); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + auto mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); gtk_box_set_homogeneous(GTK_BOX(mainbox), FALSE); -#else - GtkWidget *mainbox = gtk_vbox_new(FALSE, 4); -#endif gtk_container_set_border_width (GTK_CONTAINER (mainbox), 6); contents->pack_start (*Gtk::manage(Glib::wrap(mainbox)), true, true, 0); @@ -651,12 +647,8 @@ CloneTiler::CloneTiler () : GtkWidget *vb = clonetiler_new_tab (nb, _("Co_lor")); { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new (FALSE, 0); -#endif GtkWidget *l = gtk_label_new (_("Initial color: ")); gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); @@ -777,12 +769,8 @@ CloneTiler::CloneTiler () : { GtkWidget *vb = clonetiler_new_tab (nb, _("_Trace")); { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); b = gtk_check_button_new_with_label (_("Trace the drawing under the clones/sprayed items")); @@ -797,12 +785,8 @@ CloneTiler::CloneTiler () : } { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *vvb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + auto vvb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous(GTK_BOX(vvb), FALSE); -#else - GtkWidget *vvb = gtk_vbox_new (FALSE, 0); -#endif gtk_box_pack_start (GTK_BOX (vb), vvb, FALSE, FALSE, 0); g_object_set_data (G_OBJECT(dlg), "dotrace", (gpointer) vvb); @@ -811,15 +795,9 @@ CloneTiler::CloneTiler () : GtkWidget *frame = gtk_frame_new (_("1. Pick from the drawing:")); gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *table = gtk_grid_new(); + auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 4); gtk_grid_set_column_spacing(GTK_GRID(table), 6); -#else - GtkWidget *table = gtk_table_new (3, 3, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); -#endif gtk_container_add(GTK_CONTAINER(frame), table); @@ -895,15 +873,9 @@ CloneTiler::CloneTiler () : GtkWidget *frame = gtk_frame_new (_("2. Tweak the picked value:")); gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, VB_MARGIN); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *table = gtk_grid_new(); + auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 4); gtk_grid_set_column_spacing(GTK_GRID(table), 6); -#else - GtkWidget *table = gtk_table_new (4, 2, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); -#endif gtk_container_add(GTK_CONTAINER(frame), table); @@ -944,15 +916,9 @@ CloneTiler::CloneTiler () : GtkWidget *frame = gtk_frame_new (_("3. Apply the value to the clones':")); gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *table = gtk_grid_new(); + auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 4); gtk_grid_set_column_spacing(GTK_GRID(table), 6); -#else - GtkWidget *table = gtk_table_new (2, 2, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); -#endif gtk_container_add(GTK_CONTAINER(frame), table); { @@ -1000,12 +966,8 @@ CloneTiler::CloneTiler () : } { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); GtkWidget *l = gtk_label_new(_("")); gtk_label_set_markup (GTK_LABEL(l), _("Apply to tiled clones:")); @@ -1013,42 +975,24 @@ CloneTiler::CloneTiler () : } // Rows/columns, width/height { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *table = gtk_grid_new(); + auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 4); gtk_grid_set_column_spacing(GTK_GRID(table), 6); -#else - GtkWidget *table = gtk_table_new (2, 2, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); -#endif gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); gtk_box_pack_start (GTK_BOX (mainbox), table, FALSE, FALSE, 0); { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif g_object_set_data (G_OBJECT(dlg), "rowscols", (gpointer) hb); { -#if WITH_GTKMM_3_0 - Glib::RefPtra = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); -#else - Gtk::Adjustment *a = new Gtk::Adjustment (0.0, 1, 500, 1, 10, 0); -#endif + auto a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); int value = prefs->getInt(prefs_path + "jmax", 2); a->set_value (value); -#if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); -#else - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 0); -#endif + auto sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); sb->set_tooltip_text (_("How many rows in the tiling")); sb->set_width_chars (7); gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0); @@ -1061,28 +1005,16 @@ CloneTiler::CloneTiler () : { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), "×"); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(l, GTK_ALIGN_END); -#else - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); -#endif gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); } { -#if WITH_GTKMM_3_0 - Glib::RefPtr a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); -#else - Gtk::Adjustment *a = new Gtk::Adjustment (0.0, 1, 500, 1, 10, 0); -#endif + auto a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); int value = prefs->getInt(prefs_path + "imax", 2); a->set_value (value); -#if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); -#else - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 0); -#endif + auto sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); sb->set_tooltip_text (_("How many columns in the tiling")); sb->set_width_chars (7); gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0); @@ -1096,12 +1028,8 @@ CloneTiler::CloneTiler () : } { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif g_object_set_data (G_OBJECT(dlg), "widthheight", (gpointer) hb); // unitmenu @@ -1112,59 +1040,39 @@ CloneTiler::CloneTiler () : { // Width spinbutton -#if WITH_GTKMM_3_0 fill_width = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0); -#else - fill_width = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); -#endif double value = prefs->getDouble(prefs_path + "fillwidth", 50.0); Inkscape::Util::Unit const *unit = unit_menu->getUnit(); gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); fill_width->set_value (units); -#if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(fill_width, 1.0, 2); -#else - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*fill_width, 1.0, 2); -#endif + auto e = new Inkscape::UI::Widget::SpinButton(fill_width, 1.0, 2); e->set_tooltip_text (_("Width of the rectangle to be filled")); e->set_width_chars (7); e->set_digits (4); gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); // TODO: C++ification - g_signal_connect(G_OBJECT(fill_width->gobj()), "value_changed", + g_signal_connect(G_OBJECT(fill_width->gobj()), "value_changed", G_CALLBACK(clonetiler_fill_width_changed), unit_menu); } { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), "×"); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(l, GTK_ALIGN_END); -#else - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); -#endif gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); } { // Height spinbutton -#if WITH_GTKMM_3_0 fill_height = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0); -#else - fill_height = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); -#endif double value = prefs->getDouble(prefs_path + "fillheight", 50.0); Inkscape::Util::Unit const *unit = unit_menu->getUnit(); gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); fill_height->set_value (units); -#if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(fill_height, 1.0, 2); -#else - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*fill_height, 1.0, 2); -#endif + auto e = new Inkscape::UI::Widget::SpinButton(fill_height, 1.0, 2); e->set_tooltip_text (_("Height of the rectangle to be filled")); e->set_width_chars (7); e->set_digits (4); @@ -1206,12 +1114,8 @@ CloneTiler::CloneTiler () : // Use saved pos { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); GtkWidget *b = gtk_check_button_new_with_label (_("Use saved size and position of the tile")); @@ -1226,12 +1130,8 @@ CloneTiler::CloneTiler () : // Statusbar { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif gtk_box_pack_end (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); GtkWidget *l = gtk_label_new(""); g_object_set_data (G_OBJECT(dlg), "status", (gpointer) l); @@ -1240,12 +1140,8 @@ CloneTiler::CloneTiler () : // Buttons { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); { @@ -1259,12 +1155,8 @@ CloneTiler::CloneTiler () : } { // buttons which are enabled only when there are tiled clones -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *sb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto sb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(sb), FALSE); -#else - GtkWidget *sb = gtk_hbox_new(FALSE, 0); -#endif gtk_box_pack_end (GTK_BOX (hb), sb, FALSE, FALSE, 0); g_object_set_data (G_OBJECT(dlg), "buttons_on_tiles", (gpointer) sb); { @@ -2673,12 +2565,8 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) GtkWidget * CloneTiler::clonetiler_new_tab(GtkWidget *nb, const gchar *label) { GtkWidget *l = gtk_label_new_with_mnemonic (label); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, VB_MARGIN); + auto vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(vb), FALSE); -#else - GtkWidget *vb = gtk_vbox_new (FALSE, VB_MARGIN); -#endif gtk_container_set_border_width (GTK_CONTAINER (vb), VB_MARGIN); gtk_notebook_append_page (GTK_NOTEBOOK (nb), vb, l); return vb; @@ -2693,12 +2581,8 @@ void CloneTiler::clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data GtkWidget * CloneTiler::clonetiler_checkbox(const char *tip, const char *attr) { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif GtkWidget *b = gtk_check_button_new (); gtk_widget_set_tooltip_text (b, tip); @@ -2725,44 +2609,23 @@ void CloneTiler::clonetiler_value_changed(GtkAdjustment *adj, gpointer data) GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent/* = false*/) { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, 0); -#endif { -#if WITH_GTKMM_3_0 Glib::RefPtr a; if (exponent) { a = Gtk::Adjustment::create(1.0, lower, upper, 0.01, 0.05, 0); } else { a = Gtk::Adjustment::create(0.0, lower, upper, 0.1, 0.5, 0); } -#else - Gtk::Adjustment *a; - if (exponent) { - a = new Gtk::Adjustment (1.0, lower, upper, 0.01, 0.05, 0); - } else { - a = new Gtk::Adjustment (0.0, lower, upper, 0.1, 0.5, 0); - } -#endif Inkscape::UI::Widget::SpinButton *sb; -#if WITH_GTKMM_3_0 if (exponent) { sb = new Inkscape::UI::Widget::SpinButton(a, 0.01, 2); } else { sb = new Inkscape::UI::Widget::SpinButton(a, 0.1, 1); } -#else - if (exponent) { - sb = new Inkscape::UI::Widget::SpinButton (*a, 0.01, 2); - } else { - sb = new Inkscape::UI::Widget::SpinButton (*a, 0.1, 1); - } -#endif sb->set_tooltip_text (tip); sb->set_width_chars (5); @@ -2786,12 +2649,8 @@ GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, do { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), suffix); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(l, GTK_ALIGN_END); gtk_widget_set_valign(l, GTK_ALIGN_START); -#else - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0); -#endif gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); } @@ -2867,38 +2726,22 @@ void CloneTiler::clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg) void CloneTiler::clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col) { -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(widget, GTK_ALIGN_FILL); gtk_widget_set_valign(widget, GTK_ALIGN_START); gtk_grid_attach(GTK_GRID(table), widget, col, row, 1, 1); -#else - GtkWidget *a = gtk_alignment_new (align, 0, 0, 0); - gtk_container_add(GTK_CONTAINER(a), widget); - gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, GTK_FILL, (GtkAttachOptions)0, 0, 0 ); -#endif } GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *table = gtk_grid_new(); + auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 6); gtk_grid_set_column_spacing(GTK_GRID(table), 8); -#else - GtkWidget *table = gtk_table_new (values + 2, 5, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 6); - gtk_table_set_col_spacings (GTK_TABLE (table), 8); -#endif gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new (FALSE, 0); -#endif GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-rows")); gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2); @@ -2911,12 +2754,8 @@ GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) } { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new (FALSE, 0); -#endif GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-columns")); gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2); -- cgit v1.2.3 From 860883afa75a3a2f60ed5ffc299447409138736f Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 10 Aug 2016 11:39:55 +0100 Subject: CloneTiler: C++ify (bzr r15050) --- src/ui/dialog/clonetiler.cpp | 116 ++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 72 deletions(-) (limited to 'src/ui/dialog/clonetiler.cpp') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 1fa7a6c71..eb55e06c6 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -66,7 +66,6 @@ static SPDocument *trace_doc = NULL; CloneTiler::CloneTiler () : UI::Widget::Panel ("", "/dialogs/clonetiler/", SP_VERB_DIALOG_CLONETILER), - dlg(NULL), desktop(NULL), deskTrack(), table_row_labels(NULL) @@ -75,9 +74,7 @@ CloneTiler::CloneTiler () : contents->set_spacing(0); { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - - dlg = GTK_WIDGET(gobj()); + auto prefs = Inkscape::Preferences::get(); auto mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); gtk_box_set_homogeneous(GTK_BOX(mainbox), FALSE); @@ -769,15 +766,14 @@ CloneTiler::CloneTiler () : gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_do_pick_toggled), (gpointer)dlg); + G_CALLBACK(clonetiler_do_pick_toggled), (gpointer)this); } { auto vvb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous(GTK_BOX(vvb), FALSE); gtk_box_pack_start (GTK_BOX (vb), vvb, FALSE, FALSE, 0); - g_object_set_data (G_OBJECT(dlg), "dotrace", (gpointer) vvb); - + _dotrace = vvb; { GtkWidget *frame = gtk_frame_new (_("1. Pick from the drawing:")); @@ -973,7 +969,7 @@ CloneTiler::CloneTiler () : { auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); - g_object_set_data (G_OBJECT(dlg), "rowscols", (gpointer) hb); + _rowscols = hb; { auto a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); @@ -1018,7 +1014,7 @@ CloneTiler::CloneTiler () : { auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); - g_object_set_data (G_OBJECT(dlg), "widthheight", (gpointer) hb); + _widthheight = hb; // unitmenu unit_menu = new Inkscape::UI::Widget::UnitMenu(); @@ -1081,7 +1077,7 @@ CloneTiler::CloneTiler () : radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: ")); gtk_widget_set_tooltip_text (radio, _("Create the specified number of rows and columns")); clonetiler_table_attach (table, radio, 0.0, 1, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_create), (gpointer) dlg); + g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_create), (gpointer) this); } if (!prefs->getBool(prefs_path + "fillrect")) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); @@ -1091,7 +1087,7 @@ CloneTiler::CloneTiler () : radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Width, height: ")); gtk_widget_set_tooltip_text (radio, _("Fill the specified width and height with the tiling")); clonetiler_table_attach (table, radio, 0.0, 2, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_fill), (gpointer) dlg); + g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_fill), (gpointer) this); } if (prefs->getBool(prefs_path + "fillrect")) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); @@ -1122,7 +1118,7 @@ CloneTiler::CloneTiler () : gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); gtk_box_pack_end (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); GtkWidget *l = gtk_label_new(""); - g_object_set_data (G_OBJECT(dlg), "status", (gpointer) l); + _status = l; gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); } @@ -1133,20 +1129,20 @@ CloneTiler::CloneTiler () : gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); { - GtkWidget *b = gtk_button_new (); - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup_with_mnemonic (GTK_LABEL(l), _(" _Create ")); - gtk_container_add (GTK_CONTAINER(b), l); - gtk_widget_set_tooltip_text (b, _("Create and tile the clones of the selection")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_apply), dlg); - gtk_box_pack_end (GTK_BOX (hb), b, FALSE, FALSE, 0); + auto b = Gtk::manage(new Gtk::Button()); + auto l = Gtk::manage(new Gtk::Label("")); + l->set_markup_with_mnemonic(_(" _Create ")); + b->add(*l); + b->set_tooltip_text(_("Create and tile the clones of the selection")); + b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::apply)); + gtk_box_pack_end (GTK_BOX (hb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0); } { // buttons which are enabled only when there are tiled clones auto sb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(sb), FALSE); gtk_box_pack_end (GTK_BOX (hb), sb, FALSE, FALSE, 0); - g_object_set_data (G_OBJECT(dlg), "buttons_on_tiles", (gpointer) sb); + _buttons_on_tiles = sb; { // TRANSLATORS: if a group of objects are "clumped" together, then they // are unevenly spread in the given amount of space - as shown in the @@ -1160,28 +1156,26 @@ CloneTiler::CloneTiler () : } { - GtkWidget *b = gtk_button_new_with_mnemonic (_(" Re_move ")); - gtk_widget_set_tooltip_text (b, _("Remove existing tiled clones of the selected object (siblings only)")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_remove), gpointer(dlg)); - gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); + auto b = Gtk::manage(new Gtk::Button(_(" Re_move "), true)); + b->set_tooltip_text(_("Remove existing tiled clones of the selected object (siblings only)")); + b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::on_remove_button_clicked)); + gtk_box_pack_end (GTK_BOX (sb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0); } // connect to global selection changed signal (so we can change desktops) and // external_change (so we're not fooled by undo) - selectChangedConn = INKSCAPE.signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_change_selection), dlg)); - externChangedConn = INKSCAPE.signal_external_change.connect (sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_external_change), dlg)); - - g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), this); + selectChangedConn = INKSCAPE.signal_selection_changed.connect(sigc::mem_fun(*this, &CloneTiler::change_selection)); + externChangedConn = INKSCAPE.signal_external_change.connect(sigc::mem_fun(*this, &CloneTiler::external_change)); // update now - clonetiler_change_selection (SP_ACTIVE_DESKTOP->getSelection(), dlg); + change_selection(SP_ACTIVE_DESKTOP->getSelection()); } { GtkWidget *b = gtk_button_new_with_mnemonic (_(" R_eset ")); // TRANSLATORS: "change" is a noun here gtk_widget_set_tooltip_text (b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_reset), dlg); + g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_reset), this); gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); } } @@ -1199,8 +1193,9 @@ CloneTiler::CloneTiler () : CloneTiler::~CloneTiler (void) { //subselChangedConn.disconnect(); - //selectChangedConn.disconnect(); //selectModifiedConn.disconnect(); + selectChangedConn.disconnect(); + externChangedConn.disconnect(); desktopChangeConn.disconnect(); deskTrack.disconnect(); color_changed_connection.disconnect(); @@ -1215,17 +1210,7 @@ void CloneTiler::setDesktop(SPDesktop *desktop) void CloneTiler::setTargetDesktop(SPDesktop *desktop) { if (this->desktop != desktop) { - if (this->desktop) { - //selectModifiedConn.disconnect(); - //subselChangedConn.disconnect(); - //selectChangedConn.disconnect(); - } this->desktop = desktop; - if (desktop && desktop->selection) { - //selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection))); - //subselChangedConn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection))); - //selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection))); - } } } @@ -1245,47 +1230,35 @@ void CloneTiler::on_picker_color_changed(guint rgba) is_updating = false; } -void CloneTiler::clonetiler_change_selection(Inkscape::Selection *selection, GtkWidget *dlg) +void CloneTiler::change_selection(Inkscape::Selection *selection) { - GtkWidget *buttons = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "buttons_on_tiles")); - GtkWidget *status = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "status")); - if (selection->isEmpty()) { - gtk_widget_set_sensitive (buttons, FALSE); - gtk_label_set_markup (GTK_LABEL(status), _("Nothing selected.")); + gtk_widget_set_sensitive (_buttons_on_tiles, FALSE); + gtk_label_set_markup (GTK_LABEL(_status), _("Nothing selected.")); return; } if (boost::distance(selection->items()) > 1) { - gtk_widget_set_sensitive (buttons, FALSE); - gtk_label_set_markup (GTK_LABEL(status), _("More than one object selected.")); + gtk_widget_set_sensitive (_buttons_on_tiles, FALSE); + gtk_label_set_markup (GTK_LABEL(_status), _("More than one object selected.")); return; } guint n = clonetiler_number_of_clones(selection->singleItem()); if (n > 0) { - gtk_widget_set_sensitive (buttons, TRUE); + gtk_widget_set_sensitive (_buttons_on_tiles, TRUE); gchar *sta = g_strdup_printf (_("Object has %d tiled clones."), n); - gtk_label_set_markup (GTK_LABEL(status), sta); + gtk_label_set_markup (GTK_LABEL(_status), sta); g_free (sta); } else { - gtk_widget_set_sensitive (buttons, FALSE); - gtk_label_set_markup (GTK_LABEL(status), _("Object has no tiled clones.")); + gtk_widget_set_sensitive (_buttons_on_tiles, FALSE); + gtk_label_set_markup (GTK_LABEL(_status), _("Object has no tiled clones.")); } } -void CloneTiler::clonetiler_external_change(GtkWidget *dlg) -{ - clonetiler_change_selection (SP_ACTIVE_DESKTOP->getSelection(), dlg); -} - -void CloneTiler::clonetiler_disconnect_gsignal(GObject *, gpointer source) +void CloneTiler::external_change() { - g_return_if_fail(source != NULL); - - CloneTiler* dlg = reinterpret_cast(source); - dlg->selectChangedConn.disconnect(); - dlg->externChangedConn.disconnect(); + change_selection(SP_ACTIVE_DESKTOP->getSelection()); } Geom::Affine CloneTiler::clonetiler_get_transform( @@ -2032,7 +2005,7 @@ guint CloneTiler::clonetiler_number_of_clones(SPObject *obj) return n; } -void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool do_undo/* = true*/) +void CloneTiler::remove(bool do_undo/* = true*/) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) { @@ -2064,7 +2037,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d } g_slist_free (to_delete); - clonetiler_change_selection (selection, dlg); + change_selection (selection); if (do_undo) { DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_CLONETILER, @@ -2104,7 +2077,7 @@ double CloneTiler::randomize01(double val, double rand) } -void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) +void CloneTiler::apply() { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) { @@ -2129,9 +2102,8 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) desktop->setWaitingCursor(); // set statusbar text - GtkWidget *status = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "status")); - gtk_label_set_markup (GTK_LABEL(status), _("Creating tiled clones...")); - gtk_widget_queue_draw(GTK_WIDGET(status)); + gtk_label_set_markup (GTK_LABEL(_status), _("Creating tiled clones...")); + gtk_widget_queue_draw(GTK_WIDGET(_status)); gdk_window_process_all_updates(); SPObject *obj = selection->singleItem(); @@ -2144,7 +2116,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) const char *id_href = g_strdup_printf("#%s", obj_repr->attribute("id")); SPObject *parent = obj->parent; - clonetiler_remove (NULL, dlg, false); + remove(false); Geom::Scale scale = desktop->getDocument()->getDocumentScale().inverse(); double scale_units = scale[Geom::X]; // Use just x direction.... @@ -2542,7 +2514,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) clonetiler_trace_finish (); } - clonetiler_change_selection (selection, dlg); + change_selection(selection); desktop->clearWaitingCursor(); -- cgit v1.2.3 From 349e2e3bc0b11c89a0a791e7feedfc9e0c457e5d Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 10 Aug 2016 12:39:30 +0100 Subject: CloneTiler: Further C++ification (bzr r15051) --- src/ui/dialog/clonetiler.cpp | 511 ++++++++++++++++++++++--------------------- 1 file changed, 256 insertions(+), 255 deletions(-) (limited to 'src/ui/dialog/clonetiler.cpp') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index eb55e06c6..8bd5cd5f6 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -22,7 +22,9 @@ #include #include <2geom/transforms.h> + #include +#include #include "desktop.h" @@ -88,7 +90,7 @@ CloneTiler::CloneTiler () : // Symmetry { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Symmetry")); + GtkWidget *vb = new_tab (nb, _("_Symmetry")); /* TRANSLATORS: For the following 17 symmetry groups, see * http://www.bib.ulb.ac.be/coursmath/doc/17.htm (visual examples); @@ -149,16 +151,16 @@ CloneTiler::CloneTiler () : gtk_combo_box_set_active (GTK_COMBO_BOX (combo), current); g_signal_connect(G_OBJECT(combo), "changed", - G_CALLBACK(clonetiler_symgroup_changed), NULL); + G_CALLBACK(symgroup_changed), NULL); } table_row_labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); // Shift { - GtkWidget *vb = clonetiler_new_tab (nb, _("S_hift")); + GtkWidget *vb = new_tab (nb, _("S_hift")); - GtkWidget *table = clonetiler_table_x_y_rand (3); + GtkWidget *table = table_x_y_rand (3); gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); // X @@ -168,29 +170,29 @@ CloneTiler::CloneTiler () : // xgettext:no-c-format gtk_label_set_markup (GTK_LABEL(l), _("Shift X:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); + table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Horizontal shift per row (in % of tile width)"), "shiftx_per_j", -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); + table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Horizontal shift per column (in % of tile width)"), "shiftx_per_i", -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); + table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand", + GtkWidget *l = spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand", 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); + table_attach (table, l, 0, 2, 4); } // Y @@ -200,30 +202,30 @@ CloneTiler::CloneTiler () : // xgettext:no-c-format gtk_label_set_markup (GTK_LABEL(l), _("Shift Y:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); + table_attach (table, l, 1, 3, 1); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Vertical shift per row (in % of tile height)"), "shifty_per_j", -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 3, 2); + table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Vertical shift per column (in % of tile height)"), "shifty_per_i", -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 3, 3); + table_attach (table, l, 0, 3, 3); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( _("Randomize the vertical shift by this percentage"), "shifty_rand", 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 4); + table_attach (table, l, 0, 3, 4); } // Exponent @@ -231,21 +233,21 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Exponent:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); + table_attach (table, l, 1, 4, 1); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( _("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "shifty_exp", 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 2); + table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( _("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "shiftx_exp", 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 3); + table_attach (table, l, 0, 4, 3); } { // alternates @@ -253,17 +255,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Alternate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Alternate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); + table_attach (table, l, 1, 5, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate"); - clonetiler_table_attach (table, l, 0, 5, 2); + GtkWidget *l = checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate"); + table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate"); - clonetiler_table_attach (table, l, 0, 5, 3); + GtkWidget *l = checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate"); + table_attach (table, l, 0, 5, 3); } { // Cumulate @@ -271,17 +273,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Cumulate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Cumulate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 6, 1); + table_attach (table, l, 1, 6, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate"); - clonetiler_table_attach (table, l, 0, 6, 2); + GtkWidget *l = checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate"); + table_attach (table, l, 0, 6, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate"); - clonetiler_table_attach (table, l, 0, 6, 3); + GtkWidget *l = checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate"); + table_attach (table, l, 0, 6, 3); } { // Exclude tile width and height in shift @@ -289,17 +291,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Cumulate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Exclude tile:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 7, 1); + table_attach (table, l, 1, 7, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Exclude tile height in shift"), "shifty_excludeh"); - clonetiler_table_attach (table, l, 0, 7, 2); + GtkWidget *l = checkbox (_("Exclude tile height in shift"), "shifty_excludeh"); + table_attach (table, l, 0, 7, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Exclude tile width in shift"), "shiftx_excludew"); - clonetiler_table_attach (table, l, 0, 7, 3); + GtkWidget *l = checkbox (_("Exclude tile width in shift"), "shiftx_excludew"); + table_attach (table, l, 0, 7, 3); } } @@ -307,9 +309,9 @@ CloneTiler::CloneTiler () : // Scale { - GtkWidget *vb = clonetiler_new_tab (nb, _("Sc_ale")); + GtkWidget *vb = new_tab (nb, _("Sc_ale")); - GtkWidget *table = clonetiler_table_x_y_rand (2); + GtkWidget *table = table_x_y_rand (2); gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); // X @@ -317,29 +319,29 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Scale X:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); + table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Horizontal scale per row (in % of tile width)"), "scalex_per_j", -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); + table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Horizontal scale per column (in % of tile width)"), "scalex_per_i", -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); + table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand", + GtkWidget *l = spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand", 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); + table_attach (table, l, 0, 2, 4); } // Y @@ -347,29 +349,29 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Scale Y:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); + table_attach (table, l, 1, 3, 1); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Vertical scale per row (in % of tile height)"), "scaley_per_j", -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 2); + table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Vertical scale per column (in % of tile height)"), "scaley_per_i", -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 3); + table_attach (table, l, 0, 3, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand", + GtkWidget *l = spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand", 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 4); + table_attach (table, l, 0, 3, 4); } // Exponent @@ -377,19 +379,19 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Exponent:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); + table_attach (table, l, 1, 4, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp", + GtkWidget *l = spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp", 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 2); + table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp", + GtkWidget *l = spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp", 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 3); + table_attach (table, l, 0, 4, 3); } // Logarithmic (as in logarithmic spiral) @@ -397,19 +399,19 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Base:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); + table_attach (table, l, 1, 5, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log", + GtkWidget *l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log", 0, 10, "", false); - clonetiler_table_attach (table, l, 0, 5, 2); + table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log", + GtkWidget *l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log", 0, 10, "", false); - clonetiler_table_attach (table, l, 0, 5, 3); + table_attach (table, l, 0, 5, 3); } { // alternates @@ -417,17 +419,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Alternate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Alternate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 6, 1); + table_attach (table, l, 1, 6, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate"); - clonetiler_table_attach (table, l, 0, 6, 2); + GtkWidget *l = checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate"); + table_attach (table, l, 0, 6, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate"); - clonetiler_table_attach (table, l, 0, 6, 3); + GtkWidget *l = checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate"); + table_attach (table, l, 0, 6, 3); } { // Cumulate @@ -435,17 +437,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Cumulate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Cumulate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 7, 1); + table_attach (table, l, 1, 7, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each row"), "scaley_cumulate"); - clonetiler_table_attach (table, l, 0, 7, 2); + GtkWidget *l = checkbox (_("Cumulate the scales for each row"), "scaley_cumulate"); + table_attach (table, l, 0, 7, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each column"), "scalex_cumulate"); - clonetiler_table_attach (table, l, 0, 7, 3); + GtkWidget *l = checkbox (_("Cumulate the scales for each column"), "scalex_cumulate"); + table_attach (table, l, 0, 7, 3); } } @@ -453,9 +455,9 @@ CloneTiler::CloneTiler () : // Rotation { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Rotation")); + GtkWidget *vb = new_tab (nb, _("_Rotation")); - GtkWidget *table = clonetiler_table_x_y_rand (1); + GtkWidget *table = table_x_y_rand (1); gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); // Angle @@ -463,29 +465,29 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Angle:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); + table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Rotate tiles by this angle for each row"), "rotate_per_j", -180, 180, "°"); - clonetiler_table_attach (table, l, 0, 2, 2); + table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Rotate tiles by this angle for each column"), "rotate_per_i", -180, 180, "°"); - clonetiler_table_attach (table, l, 0, 2, 3); + table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand", + GtkWidget *l = spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); + table_attach (table, l, 0, 2, 4); } { // alternates @@ -493,17 +495,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Alternate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Alternate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); + table_attach (table, l, 1, 3, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej"); - clonetiler_table_attach (table, l, 0, 3, 2); + GtkWidget *l = checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej"); + table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei"); - clonetiler_table_attach (table, l, 0, 3, 3); + GtkWidget *l = checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei"); + table_attach (table, l, 0, 3, 3); } { // Cumulate @@ -511,17 +513,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Cumulate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Cumulate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); + table_attach (table, l, 1, 4, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the rotation for each row"), "rotate_cumulatej"); - clonetiler_table_attach (table, l, 0, 4, 2); + GtkWidget *l = checkbox (_("Cumulate the rotation for each row"), "rotate_cumulatej"); + table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei"); - clonetiler_table_attach (table, l, 0, 4, 3); + GtkWidget *l = checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei"); + table_attach (table, l, 0, 4, 3); } } @@ -529,9 +531,9 @@ CloneTiler::CloneTiler () : // Blur and opacity { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Blur & opacity")); + GtkWidget *vb = new_tab (nb, _("_Blur & opacity")); - GtkWidget *table = clonetiler_table_x_y_rand (1); + GtkWidget *table = table_x_y_rand (1); gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); @@ -540,25 +542,25 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Blur:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); + table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Blur tiles by this percentage for each row"), "blur_per_j", + GtkWidget *l = spinbox (_("Blur tiles by this percentage for each row"), "blur_per_j", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); + table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i", + GtkWidget *l = spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); + table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the tile blur by this percentage"), "blur_rand", + GtkWidget *l = spinbox (_("Randomize the tile blur by this percentage"), "blur_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); + table_attach (table, l, 0, 2, 4); } { // alternates @@ -566,17 +568,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Alternate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Alternate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); + table_attach (table, l, 1, 3, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej"); - clonetiler_table_attach (table, l, 0, 3, 2); + GtkWidget *l = checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej"); + table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei"); - clonetiler_table_attach (table, l, 0, 3, 3); + GtkWidget *l = checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei"); + table_attach (table, l, 0, 3, 3); } @@ -586,25 +588,25 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Opacity:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); + table_attach (table, l, 1, 4, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j", + GtkWidget *l = spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 2); + table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i", + GtkWidget *l = spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 3); + table_attach (table, l, 0, 4, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand", + GtkWidget *l = spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 4); + table_attach (table, l, 0, 4, 4); } { // alternates @@ -612,24 +614,24 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Alternate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Alternate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); + table_attach (table, l, 1, 5, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej"); - clonetiler_table_attach (table, l, 0, 5, 2); + GtkWidget *l = checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej"); + table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei"); - clonetiler_table_attach (table, l, 0, 5, 3); + GtkWidget *l = checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei"); + table_attach (table, l, 0, 5, 3); } } // Color { - GtkWidget *vb = clonetiler_new_tab (nb, _("Co_lor")); + GtkWidget *vb = new_tab (nb, _("Co_lor")); { auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); @@ -648,7 +650,7 @@ CloneTiler::CloneTiler () : } - GtkWidget *table = clonetiler_table_x_y_rand (3); + GtkWidget *table = table_x_y_rand (3); gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); // Hue @@ -656,25 +658,25 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("H:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); + table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j", + GtkWidget *l = spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); + table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i", + GtkWidget *l = spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); + table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the tile hue by this percentage"), "hue_rand", + GtkWidget *l = spinbox (_("Randomize the tile hue by this percentage"), "hue_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); + table_attach (table, l, 0, 2, 4); } @@ -683,25 +685,25 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("S:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); + table_attach (table, l, 1, 3, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j", + GtkWidget *l = spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 3, 2); + table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i", + GtkWidget *l = spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 3, 3); + table_attach (table, l, 0, 3, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand", + GtkWidget *l = spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 3, 4); + table_attach (table, l, 0, 3, 4); } // Lightness @@ -709,25 +711,25 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("L:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); + table_attach (table, l, 1, 4, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j", + GtkWidget *l = spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 2); + table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i", + GtkWidget *l = spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 3); + table_attach (table, l, 0, 4, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand", + GtkWidget *l = spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 4); + table_attach (table, l, 0, 4, 4); } @@ -735,38 +737,36 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Alternate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); + table_attach (table, l, 1, 5, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej"); - clonetiler_table_attach (table, l, 0, 5, 2); + GtkWidget *l = checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej"); + table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei"); - clonetiler_table_attach (table, l, 0, 5, 3); + GtkWidget *l = checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei"); + table_attach (table, l, 0, 5, 3); } } // Trace { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Trace")); + GtkWidget *vb = new_tab (nb, _("_Trace")); { auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); - b = gtk_check_button_new_with_label (_("Trace the drawing under the clones/sprayed items")); - g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE)); + _b = Gtk::manage(new Gtk::CheckButton(_("Trace the drawing under the clones/sprayed items"))); + _b->set_data("uncheckable", GINT_TO_POINTER(TRUE)); bool old = prefs->getBool(prefs_path + "dotrace"); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("For each clone/sprayed item, pick a value from the drawing in its location and apply it")); - gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); - - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_do_pick_toggled), (gpointer)this); + _b->set_active(old); + _b->set_tooltip_text(_("For each clone/sprayed item, pick a value from the drawing in its location and apply it")); + gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(_b->gobj()), FALSE, FALSE, 0); + _b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::do_pick_toggled),_b)); } { @@ -789,65 +789,65 @@ CloneTiler::CloneTiler () : { radio = gtk_radio_button_new_with_label (NULL, _("Color")); gtk_widget_set_tooltip_text (radio, _("Pick the visible color and opacity")); - clonetiler_table_attach (table, radio, 0.0, 1, 1); + table_attach (table, radio, 0.0, 1, 1); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_COLOR)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_COLOR)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Opacity")); gtk_widget_set_tooltip_text (radio, _("Pick the total accumulated opacity")); - clonetiler_table_attach (table, radio, 0.0, 2, 1); + table_attach (table, radio, 0.0, 2, 1); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_OPACITY)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_OPACITY)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("R")); gtk_widget_set_tooltip_text (radio, _("Pick the Red component of the color")); - clonetiler_table_attach (table, radio, 0.0, 1, 2); + table_attach (table, radio, 0.0, 1, 2); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_R)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_R)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_R); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("G")); gtk_widget_set_tooltip_text (radio, _("Pick the Green component of the color")); - clonetiler_table_attach (table, radio, 0.0, 2, 2); + table_attach (table, radio, 0.0, 2, 2); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_G)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_G)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_G); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("B")); gtk_widget_set_tooltip_text (radio, _("Pick the Blue component of the color")); - clonetiler_table_attach (table, radio, 0.0, 3, 2); + table_attach (table, radio, 0.0, 3, 2); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_B)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_B)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_B); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H")); gtk_widget_set_tooltip_text (radio, _("Pick the hue of the color")); - clonetiler_table_attach (table, radio, 0.0, 1, 3); + table_attach (table, radio, 0.0, 1, 3); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_H)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_H)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_H); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S")); gtk_widget_set_tooltip_text (radio, _("Pick the saturation of the color")); - clonetiler_table_attach (table, radio, 0.0, 2, 3); + table_attach (table, radio, 0.0, 2, 3); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_S)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_S)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_S); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L")); gtk_widget_set_tooltip_text (radio, _("Pick the lightness of the color")); - clonetiler_table_attach (table, radio, 0.0, 3, 3); + table_attach (table, radio, 0.0, 3, 3); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_L)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_L)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_L); } @@ -866,33 +866,33 @@ CloneTiler::CloneTiler () : { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Gamma-correct:")); - clonetiler_table_attach (table, l, 1.0, 1, 1); + table_attach (table, l, 1.0, 1, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked", + GtkWidget *l = spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked", -10, 10, ""); - clonetiler_table_attach (table, l, 0.0, 1, 2); + table_attach (table, l, 0.0, 1, 2); } { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Randomize:")); - clonetiler_table_attach (table, l, 1.0, 1, 3); + table_attach (table, l, 1.0, 1, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the picked value by this percentage"), "rand_picked", + GtkWidget *l = spinbox (_("Randomize the picked value by this percentage"), "rand_picked", 0, 100, "%"); - clonetiler_table_attach (table, l, 0.0, 1, 4); + table_attach (table, l, 0.0, 1, 4); } { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Invert:")); - clonetiler_table_attach (table, l, 1.0, 2, 1); + table_attach (table, l, 1.0, 2, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Invert the picked value"), "invert_picked"); - clonetiler_table_attach (table, l, 0.0, 2, 2); + GtkWidget *l = checkbox (_("Invert the picked value"), "invert_picked"); + table_attach (table, l, 0.0, 2, 2); } } @@ -910,9 +910,9 @@ CloneTiler::CloneTiler () : bool old = prefs->getBool(prefs_path + "pick_to_presence", true); gtk_toggle_button_set_active ((GtkToggleButton *) b, old); gtk_widget_set_tooltip_text (b, _("Each clone is created with the probability determined by the picked value in that point")); - clonetiler_table_attach (table, b, 0.0, 1, 1); + table_attach (table, b, 0.0, 1, 1); g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_presence"); + G_CALLBACK(pick_to), (gpointer) "pick_to_presence"); } { @@ -920,9 +920,9 @@ CloneTiler::CloneTiler () : bool old = prefs->getBool(prefs_path + "pick_to_size"); gtk_toggle_button_set_active ((GtkToggleButton *) b, old); gtk_widget_set_tooltip_text (b, _("Each clone's size is determined by the picked value in that point")); - clonetiler_table_attach (table, b, 0.0, 2, 1); + table_attach (table, b, 0.0, 2, 1); g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_size"); + G_CALLBACK(pick_to), (gpointer) "pick_to_size"); } { @@ -930,9 +930,9 @@ CloneTiler::CloneTiler () : bool old = prefs->getBool(prefs_path + "pick_to_color", 0); gtk_toggle_button_set_active ((GtkToggleButton *) b, old); gtk_widget_set_tooltip_text (b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)")); - clonetiler_table_attach (table, b, 0.0, 1, 2); + table_attach (table, b, 0.0, 1, 2); g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_color"); + G_CALLBACK(pick_to), (gpointer) "pick_to_color"); } { @@ -940,9 +940,9 @@ CloneTiler::CloneTiler () : bool old = prefs->getBool(prefs_path + "pick_to_opacity", 0); gtk_toggle_button_set_active ((GtkToggleButton *) b, old); gtk_widget_set_tooltip_text (b, _("Each clone's opacity is determined by the picked value in that point")); - clonetiler_table_attach (table, b, 0.0, 2, 2); + table_attach (table, b, 0.0, 2, 2); g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_opacity"); + G_CALLBACK(pick_to), (gpointer) "pick_to_opacity"); } } gtk_widget_set_sensitive (vvb, prefs->getBool(prefs_path + "dotrace")); @@ -983,7 +983,7 @@ CloneTiler::CloneTiler () : // TODO: C++ification g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(clonetiler_xy_changed), (gpointer) "jmax"); + G_CALLBACK(xy_changed), (gpointer) "jmax"); } { @@ -1005,10 +1005,10 @@ CloneTiler::CloneTiler () : // TODO: C++ification g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(clonetiler_xy_changed), (gpointer) "imax"); + G_CALLBACK(xy_changed), (gpointer) "imax"); } - clonetiler_table_attach (table, hb, 0.0, 1, 2); + table_attach (table, hb, 0.0, 1, 2); } { @@ -1020,7 +1020,7 @@ CloneTiler::CloneTiler () : unit_menu = new Inkscape::UI::Widget::UnitMenu(); unit_menu->setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR); unit_menu->setUnit(SP_ACTIVE_DESKTOP->getNamedView()->display_units->abbr); - unitChangedConn = unit_menu->signal_changed().connect(sigc::mem_fun(*this, &CloneTiler::clonetiler_unit_changed)); + unitChangedConn = unit_menu->signal_changed().connect(sigc::mem_fun(*this, &CloneTiler::unit_changed)); { // Width spinbutton @@ -1038,7 +1038,7 @@ CloneTiler::CloneTiler () : gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); // TODO: C++ification g_signal_connect(G_OBJECT(fill_width->gobj()), "value_changed", - G_CALLBACK(clonetiler_fill_width_changed), unit_menu); + G_CALLBACK(fill_width_changed), unit_menu); } { GtkWidget *l = gtk_label_new (""); @@ -1063,11 +1063,11 @@ CloneTiler::CloneTiler () : gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); // TODO: C++ification g_signal_connect(G_OBJECT(fill_height->gobj()), "value_changed", - G_CALLBACK(clonetiler_fill_height_changed), unit_menu); + G_CALLBACK(fill_height_changed), unit_menu); } gtk_box_pack_start (GTK_BOX (hb), (GtkWidget*) unit_menu->gobj(), TRUE, TRUE, 0); - clonetiler_table_attach (table, hb, 0.0, 2, 2); + table_attach (table, hb, 0.0, 2, 2); } @@ -1076,8 +1076,8 @@ CloneTiler::CloneTiler () : { radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: ")); gtk_widget_set_tooltip_text (radio, _("Create the specified number of rows and columns")); - clonetiler_table_attach (table, radio, 0.0, 1, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_create), (gpointer) this); + table_attach (table, radio, 0.0, 1, 1); + g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (switch_to_create), (gpointer) this); } if (!prefs->getBool(prefs_path + "fillrect")) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); @@ -1086,8 +1086,8 @@ CloneTiler::CloneTiler () : { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Width, height: ")); gtk_widget_set_tooltip_text (radio, _("Fill the specified width and height with the tiling")); - clonetiler_table_attach (table, radio, 0.0, 2, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_fill), (gpointer) this); + table_attach (table, radio, 0.0, 2, 1); + g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (switch_to_fill), (gpointer) this); } if (prefs->getBool(prefs_path + "fillrect")) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); @@ -1109,7 +1109,7 @@ CloneTiler::CloneTiler () : gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_keep_bbox_toggled), NULL); + G_CALLBACK(keep_bbox_toggled), NULL); } // Statusbar @@ -1151,7 +1151,7 @@ CloneTiler::CloneTiler () : // So unclumping is the process of spreading a number of objects out more evenly. GtkWidget *b = gtk_button_new_with_mnemonic (_(" _Unclump ")); gtk_widget_set_tooltip_text (b, _("Spread out clones to reduce clumping; can be applied repeatedly")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_unclump), NULL); + g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (unclump), NULL); gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); } @@ -1175,7 +1175,7 @@ CloneTiler::CloneTiler () : GtkWidget *b = gtk_button_new_with_mnemonic (_(" R_eset ")); // TRANSLATORS: "change" is a noun here gtk_widget_set_tooltip_text (b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_reset), this); + g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (reset), this); gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); } } @@ -1244,7 +1244,7 @@ void CloneTiler::change_selection(Inkscape::Selection *selection) return; } - guint n = clonetiler_number_of_clones(selection->singleItem()); + guint n = number_of_clones(selection->singleItem()); if (n > 0) { gtk_widget_set_sensitive (_buttons_on_tiles, TRUE); gchar *sta = g_strdup_printf (_("Object has %d tiled clones."), n); @@ -1261,7 +1261,7 @@ void CloneTiler::external_change() change_selection(SP_ACTIVE_DESKTOP->getSelection()); } -Geom::Affine CloneTiler::clonetiler_get_transform( +Geom::Affine CloneTiler::get_transform( // symmetry group int type, @@ -1863,7 +1863,7 @@ Geom::Affine CloneTiler::clonetiler_get_transform( return Geom::identity(); } -bool CloneTiler::clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj) +bool CloneTiler::is_a_clone_of(SPObject *tile, SPObject *obj) { bool result = false; char *id_href = NULL; @@ -1890,21 +1890,21 @@ bool CloneTiler::clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj) return result; } -void CloneTiler::clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) +void CloneTiler::trace_hide_tiled_clones_recursively(SPObject *from) { if (!trace_drawing) return; for (auto& o: from->children) { SPItem *item = dynamic_cast(&o); - if (item && clonetiler_is_a_clone_of(&o, NULL)) { + if (item && is_a_clone_of(&o, NULL)) { item->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too! } - clonetiler_trace_hide_tiled_clones_recursively (&o); + trace_hide_tiled_clones_recursively (&o); } } -void CloneTiler::clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *original) +void CloneTiler::trace_setup(SPDocument *doc, gdouble zoom, SPItem *original) { trace_drawing = new Inkscape::Drawing(); /* Create ArenaItem and set transform */ @@ -1914,7 +1914,7 @@ void CloneTiler::clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *o // hide the (current) original and any tiled clones, we only want to pick the background original->invoke_hide(trace_visionkey); - clonetiler_trace_hide_tiled_clones_recursively(trace_doc->getRoot()); + trace_hide_tiled_clones_recursively(trace_doc->getRoot()); trace_doc->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); trace_doc->ensureUpToDate(); @@ -1922,7 +1922,7 @@ void CloneTiler::clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *o trace_zoom = zoom; } -guint32 CloneTiler::clonetiler_trace_pick(Geom::Rect box) +guint32 CloneTiler::trace_pick(Geom::Rect box) { if (!trace_drawing) { return 0; @@ -1946,7 +1946,7 @@ guint32 CloneTiler::clonetiler_trace_pick(Geom::Rect box) return SP_RGBA32_F_COMPOSE (R, G, B, A); } -void CloneTiler::clonetiler_trace_finish() +void CloneTiler::trace_finish() { if (trace_doc) { trace_doc->getRoot()->invoke_hide(trace_visionkey); @@ -1956,7 +1956,7 @@ void CloneTiler::clonetiler_trace_finish() } } -void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) +void CloneTiler::unclump(GtkWidget */*widget*/, void *) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) { @@ -1977,27 +1977,27 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) std::vector to_unclump; // not including the original for (auto& child: parent->children) { - if (clonetiler_is_a_clone_of (&child, obj)) { + if (is_a_clone_of (&child, obj)) { to_unclump.push_back((SPItem*)&child); } } desktop->getDocument()->ensureUpToDate(); reverse(to_unclump.begin(),to_unclump.end()); - unclump (to_unclump); + ::unclump (to_unclump); DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_CLONETILER, _("Unclump tiled clones")); } -guint CloneTiler::clonetiler_number_of_clones(SPObject *obj) +guint CloneTiler::number_of_clones(SPObject *obj) { SPObject *parent = obj->parent; guint n = 0; for (auto& child: parent->children) { - if (clonetiler_is_a_clone_of (&child, obj)) { + if (is_a_clone_of (&child, obj)) { n ++; } } @@ -2026,7 +2026,7 @@ void CloneTiler::remove(bool do_undo/* = true*/) // remove old tiling GSList *to_delete = NULL; for (auto& child: parent->children) { - if (clonetiler_is_a_clone_of (&child, obj)) { + if (is_a_clone_of (&child, obj)) { to_delete = g_slist_prepend (to_delete, &child); } } @@ -2205,7 +2205,7 @@ void CloneTiler::apply() SPItem *item = dynamic_cast(obj); if (dotrace) { - clonetiler_trace_setup (desktop->getDocument(), 1.0, item); + trace_setup (desktop->getDocument(), 1.0, item); } Geom::Point center; @@ -2277,7 +2277,7 @@ void CloneTiler::apply() // Note: We create a clone at 0,0 too, right over the original, in case our clones are colored // Get transform from symmetry, shift, scale, rotation - Geom::Affine orig_t = clonetiler_get_transform (type, i, j, center[Geom::X], center[Geom::Y], w, h, + Geom::Affine orig_t = get_transform (type, i, j, center[Geom::X], center[Geom::Y], w, h, shiftx_per_i, shifty_per_i, shiftx_per_j, shifty_per_j, shiftx_rand, shifty_rand, @@ -2351,7 +2351,7 @@ void CloneTiler::apply() if (dotrace) { Geom::Rect bbox_t = transform_rect (bbox_original, t*Geom::Scale(1.0/scale_units)); - guint32 rgba = clonetiler_trace_pick (bbox_t); + guint32 rgba = trace_pick (bbox_t); float r = SP_RGBA32_R_F(rgba); float g = SP_RGBA32_G_F(rgba); float b = SP_RGBA32_B_F(rgba); @@ -2511,7 +2511,7 @@ void CloneTiler::apply() } if (dotrace) { - clonetiler_trace_finish (); + trace_finish (); } change_selection(selection); @@ -2522,7 +2522,7 @@ void CloneTiler::apply() _("Create tiled clones")); } -GtkWidget * CloneTiler::clonetiler_new_tab(GtkWidget *nb, const gchar *label) +GtkWidget * CloneTiler::new_tab(GtkWidget *nb, const gchar *label) { GtkWidget *l = gtk_label_new_with_mnemonic (label); auto vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, VB_MARGIN); @@ -2532,14 +2532,14 @@ GtkWidget * CloneTiler::clonetiler_new_tab(GtkWidget *nb, const gchar *label) return vb; } -void CloneTiler::clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data) +void CloneTiler::checkbox_toggled(GtkToggleButton *tb, gpointer *data) { const gchar *attr = (const gchar *) data; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + attr, gtk_toggle_button_get_active(tb)); } -GtkWidget * CloneTiler::clonetiler_checkbox(const char *tip, const char *attr) +GtkWidget * CloneTiler::checkbox(const char *tip, const char *attr) { auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); @@ -2553,21 +2553,21 @@ GtkWidget * CloneTiler::clonetiler_checkbox(const char *tip, const char *attr) gtk_box_pack_end (GTK_BOX (hb), b, FALSE, TRUE, 0); g_signal_connect ( G_OBJECT (b), "clicked", - G_CALLBACK (clonetiler_checkbox_toggled), (gpointer) attr); + G_CALLBACK (checkbox_toggled), (gpointer) attr); g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE)); return hb; } -void CloneTiler::clonetiler_value_changed(GtkAdjustment *adj, gpointer data) +void CloneTiler::value_changed(GtkAdjustment *adj, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); const gchar *pref = (const gchar *) data; prefs->setDouble(prefs_path + pref, gtk_adjustment_get_value (adj)); } -GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent/* = false*/) +GtkWidget * CloneTiler::spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent/* = false*/) { auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); @@ -2597,7 +2597,7 @@ GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, do a->set_value (value); // TODO: C++ification g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(clonetiler_value_changed), (gpointer) attr); + G_CALLBACK(value_changed), (gpointer) attr); if (exponent) { sb->set_data ("oneable", GINT_TO_POINTER(TRUE)); @@ -2617,27 +2617,27 @@ GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, do return hb; } -void CloneTiler::clonetiler_symgroup_changed(GtkComboBox *cb, gpointer /*data*/) +void CloneTiler::symgroup_changed(GtkComboBox *cb, gpointer /*data*/) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gint group_new = gtk_combo_box_get_active (cb); prefs->setInt(prefs_path + "symmetrygroup", group_new); } -void CloneTiler::clonetiler_xy_changed(GtkAdjustment *adj, gpointer data) +void CloneTiler::xy_changed(GtkAdjustment *adj, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); const gchar *pref = (const gchar *) data; prefs->setInt(prefs_path + pref, (int) floor(gtk_adjustment_get_value (adj) + 0.5)); } -void CloneTiler::clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/) +void CloneTiler::keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + "keepbbox", gtk_toggle_button_get_active(tb)); } -void CloneTiler::clonetiler_pick_to(GtkToggleButton *tb, gpointer data) +void CloneTiler::pick_to(GtkToggleButton *tb, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); const gchar *pref = (const gchar *) data; @@ -2645,7 +2645,7 @@ void CloneTiler::clonetiler_pick_to(GtkToggleButton *tb, gpointer data) } -void CloneTiler::clonetiler_reset_recursive(GtkWidget *w) +void CloneTiler::reset_recursive(GtkWidget *w) { if (w && G_IS_OBJECT(w)) { { @@ -2673,25 +2673,25 @@ void CloneTiler::clonetiler_reset_recursive(GtkWidget *w) if (GTK_IS_CONTAINER(w)) { GList *ch = gtk_container_get_children (GTK_CONTAINER(w)); for (GList *i = ch; i != NULL; i = i->next) { - clonetiler_reset_recursive (GTK_WIDGET(i->data)); + reset_recursive (GTK_WIDGET(i->data)); } g_list_free (ch); } } -void CloneTiler::clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg) +void CloneTiler::reset(GtkWidget */*widget*/, GtkWidget *dlg) { - clonetiler_reset_recursive (dlg); + reset_recursive (dlg); } -void CloneTiler::clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col) +void CloneTiler::table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col) { gtk_widget_set_halign(widget, GTK_ALIGN_FILL); gtk_widget_set_valign(widget, GTK_ALIGN_START); gtk_grid_attach(GTK_GRID(table), widget, col, row, 1, 1); } -GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) +GtkWidget * CloneTiler::table_x_y_rand(int values) { auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 6); @@ -2710,7 +2710,7 @@ GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) gtk_label_set_markup (GTK_LABEL(l), _("Per row:")); gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 2); - clonetiler_table_attach (table, hb, 0, 1, 2); + table_attach (table, hb, 0, 1, 2); } { @@ -2724,19 +2724,19 @@ GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) gtk_label_set_markup (GTK_LABEL(l), _("Per column:")); gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 2); - clonetiler_table_attach (table, hb, 0, 1, 3); + table_attach (table, hb, 0, 1, 3); } { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Randomize:")); - clonetiler_table_attach (table, l, 0, 1, 4); + table_attach (table, l, 0, 1, 4); } return table; } -void CloneTiler::clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data) +void CloneTiler::pick_switched(GtkToggleButton */*tb*/, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint v = GPOINTER_TO_INT (data); @@ -2744,7 +2744,7 @@ void CloneTiler::clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data } -void CloneTiler::clonetiler_switch_to_create(GtkToggleButton * /*tb*/, GtkWidget *dlg) +void CloneTiler::switch_to_create(GtkToggleButton * /*tb*/, GtkWidget *dlg) { GtkWidget *rowscols = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "rowscols")); GtkWidget *widthheight = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "widthheight")); @@ -2761,7 +2761,7 @@ void CloneTiler::clonetiler_switch_to_create(GtkToggleButton * /*tb*/, GtkWidget } -void CloneTiler::clonetiler_switch_to_fill(GtkToggleButton * /*tb*/, GtkWidget *dlg) +void CloneTiler::switch_to_fill(GtkToggleButton * /*tb*/, GtkWidget *dlg) { GtkWidget *rowscols = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "rowscols")); GtkWidget *widthheight = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "widthheight")); @@ -2780,7 +2780,7 @@ void CloneTiler::clonetiler_switch_to_fill(GtkToggleButton * /*tb*/, GtkWidget * -void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) +void CloneTiler::fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) { gdouble const raw_dist = gtk_adjustment_get_value (adj); Inkscape::Util::Unit const *unit = u->getUnit(); @@ -2790,7 +2790,7 @@ void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI: prefs->setDouble(prefs_path + "fillwidth", pixels); } -void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) +void CloneTiler::fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) { gdouble const raw_dist = gtk_adjustment_get_value (adj); Inkscape::Util::Unit const *unit = u->getUnit(); @@ -2800,7 +2800,7 @@ void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI prefs->setDouble(prefs_path + "fillheight", pixels); } -void CloneTiler::clonetiler_unit_changed() +void CloneTiler::unit_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble width_pixels = prefs->getDouble(prefs_path + "fillwidth"); @@ -2814,22 +2814,23 @@ void CloneTiler::clonetiler_unit_changed() gtk_adjustment_set_value(fill_height->gobj(), height_value); } -void CloneTiler::clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg) +void CloneTiler::do_pick_toggled(Gtk::ToggleButton *tb) { - GtkWidget *vvb = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "dotrace")); + GtkWidget *vvb = GTK_WIDGET(_dotrace); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setBool(prefs_path + "dotrace", gtk_toggle_button_get_active (tb)); + auto prefs = Inkscape::Preferences::get(); + auto active = tb->get_active(); + prefs->setBool(prefs_path + "dotrace", active); if (vvb) { - gtk_widget_set_sensitive (vvb, gtk_toggle_button_get_active (tb)); + gtk_widget_set_sensitive (vvb, active); } } void CloneTiler::show_page_trace() { gtk_notebook_set_current_page(GTK_NOTEBOOK(nb),6); - gtk_toggle_button_set_active ((GtkToggleButton *) b, false); + _b->set_active(false); } -- cgit v1.2.3 From 93a6d057d8b8dac9e4d81d84511dbae60a958788 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 12 Aug 2016 00:31:53 +0100 Subject: CloneTiler: Further C++ification (bzr r15052) --- src/ui/dialog/clonetiler.cpp | 177 +++++++++++++++++++------------------------ 1 file changed, 79 insertions(+), 98 deletions(-) (limited to 'src/ui/dialog/clonetiler.cpp') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 8bd5cd5f6..a9bec8227 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -25,6 +25,7 @@ #include #include +#include #include "desktop.h" @@ -766,7 +767,7 @@ CloneTiler::CloneTiler () : _b->set_active(old); _b->set_tooltip_text(_("For each clone/sprayed item, pick a value from the drawing in its location and apply it")); gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(_b->gobj()), FALSE, FALSE, 0); - _b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::do_pick_toggled),_b)); + _b->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::do_pick_toggled)); } { @@ -967,9 +968,7 @@ CloneTiler::CloneTiler () : gtk_box_pack_start (GTK_BOX (mainbox), table, FALSE, FALSE, 0); { - auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); - _rowscols = hb; + _rowscols = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN)); { auto a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); @@ -979,7 +978,7 @@ CloneTiler::CloneTiler () : auto sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); sb->set_tooltip_text (_("How many rows in the tiling")); sb->set_width_chars (7); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0); + _rowscols->pack_start(*sb, true, true, 0); // TODO: C++ification g_signal_connect(G_OBJECT(a->gobj()), "value_changed", @@ -987,10 +986,10 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), "×"); - gtk_widget_set_halign(l, GTK_ALIGN_END); - gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); + auto l = Gtk::manage(new Gtk::Label("")); + l->set_markup("×"); + l->set_halign(Gtk::ALIGN_END); + _rowscols->pack_start(*l, true, true, 0); } { @@ -1001,20 +1000,18 @@ CloneTiler::CloneTiler () : auto sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); sb->set_tooltip_text (_("How many columns in the tiling")); sb->set_width_chars (7); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0); + _rowscols->pack_start(*sb, true, true, 0); // TODO: C++ification g_signal_connect(G_OBJECT(a->gobj()), "value_changed", G_CALLBACK(xy_changed), (gpointer) "imax"); } - table_attach (table, hb, 0.0, 1, 2); + table_attach (table, GTK_WIDGET(_rowscols->gobj()), 0.0, 1, 2); } { - auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); - _widthheight = hb; + _widthheight = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN)); // unitmenu unit_menu = new Inkscape::UI::Widget::UnitMenu(); @@ -1035,16 +1032,14 @@ CloneTiler::CloneTiler () : e->set_tooltip_text (_("Width of the rectangle to be filled")); e->set_width_chars (7); e->set_digits (4); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); - // TODO: C++ification - g_signal_connect(G_OBJECT(fill_width->gobj()), "value_changed", - G_CALLBACK(fill_width_changed), unit_menu); + _widthheight->pack_start(*e, true, true, 0); + fill_width->signal_value_changed().connect(sigc::mem_fun(*this, &CloneTiler::fill_width_changed)); } { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), "×"); - gtk_widget_set_halign(l, GTK_ALIGN_END); - gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); + auto l = Gtk::manage(new Gtk::Label("")); + l->set_markup("×"); + l->set_halign(Gtk::ALIGN_END); + _widthheight->pack_start(*l, true, true, 0); } { @@ -1060,56 +1055,53 @@ CloneTiler::CloneTiler () : e->set_tooltip_text (_("Height of the rectangle to be filled")); e->set_width_chars (7); e->set_digits (4); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); - // TODO: C++ification - g_signal_connect(G_OBJECT(fill_height->gobj()), "value_changed", - G_CALLBACK(fill_height_changed), unit_menu); + _widthheight->pack_start(*e, true, true, 0); + fill_height->signal_value_changed().connect(sigc::mem_fun(*this, &CloneTiler::fill_height_changed)); } - gtk_box_pack_start (GTK_BOX (hb), (GtkWidget*) unit_menu->gobj(), TRUE, TRUE, 0); - table_attach (table, hb, 0.0, 2, 2); + _widthheight->pack_start(*unit_menu, true, true, 0); + table_attach (table, GTK_WIDGET(_widthheight->gobj()), 0.0, 2, 2); } // Switch - GtkWidget* radio; + Gtk::RadioButtonGroup rb_group; { - radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: ")); - gtk_widget_set_tooltip_text (radio, _("Create the specified number of rows and columns")); - table_attach (table, radio, 0.0, 1, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (switch_to_create), (gpointer) this); - } - if (!prefs->getBool(prefs_path + "fillrect")) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); - gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio)); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Rows, columns: "))); + radio->set_tooltip_text(_("Create the specified number of rows and columns")); + table_attach (table, GTK_WIDGET(radio->gobj()), 0.0, 1, 1); + radio->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::switch_to_create)); + + if (!prefs->getBool(prefs_path + "fillrect")) { + radio->set_active(true); + } } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Width, height: ")); - gtk_widget_set_tooltip_text (radio, _("Fill the specified width and height with the tiling")); - table_attach (table, radio, 0.0, 2, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (switch_to_fill), (gpointer) this); - } - if (prefs->getBool(prefs_path + "fillrect")) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); - gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio)); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Width, height: "))); + radio->set_tooltip_text(_("Fill the specified width and height with the tiling")); + table_attach (table, GTK_WIDGET(radio->gobj()), 0.0, 2, 1); + radio->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::switch_to_fill)); + + if (prefs->getBool(prefs_path + "fillrect")) { + radio->set_active(true); + } } } // Use saved pos { - auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); - gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); - - GtkWidget *b = gtk_check_button_new_with_label (_("Use saved size and position of the tile")); - bool keepbbox = prefs->getBool(prefs_path + "keepbbox", true); - gtk_toggle_button_set_active ((GtkToggleButton *) b, keepbbox); - gtk_widget_set_tooltip_text (b, _("Pretend that the size and position of the tile are the same as the last time you tiled it (if any), instead of using the current size")); - gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); - - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(keep_bbox_toggled), NULL); + auto hb = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN)); + gtk_box_pack_start (GTK_BOX (mainbox), GTK_WIDGET(hb->gobj()), FALSE, FALSE, 0); + + _cb_keep_bbox = Gtk::manage(new Gtk::CheckButton(_("Use saved size and position of the tile"))); + auto keepbbox = prefs->getBool(prefs_path + "keepbbox", true); + _cb_keep_bbox->set_active(keepbbox); + _cb_keep_bbox->set_tooltip_text(_("Pretend that the size and position of the tile are the same " + "as the last time you tiled it (if any), instead of using the " + "current size")); + hb->pack_start(*_cb_keep_bbox, false, false, 0); + _cb_keep_bbox->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::keep_bbox_toggled)); } // Statusbar @@ -2631,10 +2623,10 @@ void CloneTiler::xy_changed(GtkAdjustment *adj, gpointer data) prefs->setInt(prefs_path + pref, (int) floor(gtk_adjustment_get_value (adj) + 0.5)); } -void CloneTiler::keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/) +void CloneTiler::keep_bbox_toggled() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setBool(prefs_path + "keepbbox", gtk_toggle_button_get_active(tb)); + auto prefs = Inkscape::Preferences::get(); + prefs->setBool(prefs_path + "keepbbox", _cb_keep_bbox->get_active()); } void CloneTiler::pick_to(GtkToggleButton *tb, gpointer data) @@ -2744,59 +2736,50 @@ void CloneTiler::pick_switched(GtkToggleButton */*tb*/, gpointer data) } -void CloneTiler::switch_to_create(GtkToggleButton * /*tb*/, GtkWidget *dlg) +void CloneTiler::switch_to_create() { - GtkWidget *rowscols = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "rowscols")); - GtkWidget *widthheight = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "widthheight")); - - if (rowscols) { - gtk_widget_set_sensitive (rowscols, TRUE); + if (_rowscols) { + _rowscols->set_sensitive(true); } - if (widthheight) { - gtk_widget_set_sensitive (widthheight, FALSE); + if (_widthheight) { + _widthheight->set_sensitive(false); } - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + auto prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + "fillrect", false); } -void CloneTiler::switch_to_fill(GtkToggleButton * /*tb*/, GtkWidget *dlg) +void CloneTiler::switch_to_fill() { - GtkWidget *rowscols = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "rowscols")); - GtkWidget *widthheight = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "widthheight")); - - if (rowscols) { - gtk_widget_set_sensitive (rowscols, FALSE); + if (_rowscols) { + _rowscols->set_sensitive(false); } - if (widthheight) { - gtk_widget_set_sensitive (widthheight, TRUE); + if (_widthheight) { + _widthheight->set_sensitive(true); } - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + auto prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + "fillrect", true); } - - - -void CloneTiler::fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) +void CloneTiler::fill_width_changed() { - gdouble const raw_dist = gtk_adjustment_get_value (adj); - Inkscape::Util::Unit const *unit = u->getUnit(); - gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); + auto const raw_dist = fill_width->get_value(); + auto const unit = unit_menu->getUnit(); + auto const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + auto prefs = Inkscape::Preferences::get(); prefs->setDouble(prefs_path + "fillwidth", pixels); } -void CloneTiler::fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) +void CloneTiler::fill_height_changed() { - gdouble const raw_dist = gtk_adjustment_get_value (adj); - Inkscape::Util::Unit const *unit = u->getUnit(); - gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); + auto const raw_dist = fill_height->get_value(); + auto const unit = unit_menu->getUnit(); + auto const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + auto prefs = Inkscape::Preferences::get(); prefs->setDouble(prefs_path + "fillheight", pixels); } @@ -2814,16 +2797,14 @@ void CloneTiler::unit_changed() gtk_adjustment_set_value(fill_height->gobj(), height_value); } -void CloneTiler::do_pick_toggled(Gtk::ToggleButton *tb) +void CloneTiler::do_pick_toggled() { - GtkWidget *vvb = GTK_WIDGET(_dotrace); - - auto prefs = Inkscape::Preferences::get(); - auto active = tb->get_active(); + auto prefs = Inkscape::Preferences::get(); + auto active = _b->get_active(); prefs->setBool(prefs_path + "dotrace", active); - if (vvb) { - gtk_widget_set_sensitive (vvb, active); + if (_dotrace) { + gtk_widget_set_sensitive (_dotrace, active); } } -- cgit v1.2.3 From ded71e7f2330ae5abbb0b09e12f89a8fefc2820a Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 12 Aug 2016 00:45:47 +0100 Subject: CloneTiler: Further C++ification (bzr r15053) --- src/ui/dialog/clonetiler.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/ui/dialog/clonetiler.cpp') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index a9bec8227..c27d5d35a 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1141,10 +1141,10 @@ CloneTiler::CloneTiler () : // diagrams on the left in the following screenshot: // http://www.inkscape.org/screenshots/gallery/inkscape-0.42-CVS-tiles-unclump.png // So unclumping is the process of spreading a number of objects out more evenly. - GtkWidget *b = gtk_button_new_with_mnemonic (_(" _Unclump ")); - gtk_widget_set_tooltip_text (b, _("Spread out clones to reduce clumping; can be applied repeatedly")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (unclump), NULL); - gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); + auto b = Gtk::manage(new Gtk::Button(_(" _Unclump "), true)); + b->set_tooltip_text(_("Spread out clones to reduce clumping; can be applied repeatedly")); + b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::unclump)); + gtk_box_pack_end (GTK_BOX (sb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0); } { @@ -1948,14 +1948,14 @@ void CloneTiler::trace_finish() } } -void CloneTiler::unclump(GtkWidget */*widget*/, void *) +void CloneTiler::unclump() { - SPDesktop *desktop = SP_ACTIVE_DESKTOP; + auto desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) { return; } - Inkscape::Selection *selection = desktop->getSelection(); + auto selection = desktop->getSelection(); // check if something is selected if (selection->isEmpty() || boost::distance(selection->items()) > 1) { @@ -1963,8 +1963,8 @@ void CloneTiler::unclump(GtkWidget */*widget*/, void *) return; } - SPObject *obj = selection->singleItem(); - SPObject *parent = obj->parent; + auto obj = selection->singleItem(); + auto parent = obj->parent; std::vector to_unclump; // not including the original -- cgit v1.2.3 From dffaf2ab2ab1cd1ca21c0ff9e9cc9f077faf17f1 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 12 Aug 2016 21:10:12 +0100 Subject: CloneTiler: Replace all remaining g_signal usage (bzr r15055) --- src/ui/dialog/clonetiler.cpp | 425 +++++++++++++++++++++---------------------- 1 file changed, 203 insertions(+), 222 deletions(-) (limited to 'src/ui/dialog/clonetiler.cpp') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index c27d5d35a..8e9d3dbbf 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -25,6 +25,8 @@ #include #include +#include +#include #include #include "desktop.h" @@ -66,7 +68,6 @@ static unsigned trace_visionkey; static gdouble trace_zoom; static SPDocument *trace_doc = NULL; - CloneTiler::CloneTiler () : UI::Widget::Panel ("", "/dialogs/clonetiler/", SP_VERB_DIALOG_CLONETILER), desktop(NULL), @@ -100,7 +101,7 @@ CloneTiler::CloneTiler () : */ struct SymGroups { gint group; - gchar const *label; + Glib::ustring label; } const sym_groups[] = { // TRANSLATORS: "translation" means "shift" / "displacement" here. {TILE_P1, _("P1: simple translation")}, @@ -126,33 +127,27 @@ CloneTiler::CloneTiler () : gint current = prefs->getInt(prefs_path + "symmetrygroup", 0); - // Create a list structure containing all the data to be displayed in - // the symmetry group combo box. - GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING); - GtkTreeIter iter; - - for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) { - SymGroups const &sg = sym_groups[j]; + // Add a new combo box widget with the list of symmetry groups to the vbox + auto combo = Gtk::manage(new Gtk::ComboBoxText()); + combo->set_tooltip_text(_("Select one of the 17 symmetry groups for the tiling")); - // Add the description of the symgroup to a new row - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, 0, sg.label, -1); - } + // Hack to add markup support + auto cell_list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(combo->gobj())); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo->gobj()), + GTK_CELL_RENDERER(cell_list->data), + "markup", 0, NULL); - // Add a new combo box widget with the list of symmetry groups to the vbox - GtkWidget *combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); - gtk_widget_set_tooltip_text (combo, _("Select one of the 17 symmetry groups for the tiling")); - gtk_box_pack_start (GTK_BOX (vb), combo, FALSE, FALSE, SB_MARGIN); + for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) { + SymGroups const &sg = sym_groups[j]; - // Specify the rendering of data from the list in a combo box cell - GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "markup", 0, NULL); + // Add the description of the symgroup to a new row + combo->append(sg.label); + } - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), current); + gtk_box_pack_start (GTK_BOX (vb), GTK_WIDGET(combo->gobj()), FALSE, FALSE, SB_MARGIN); - g_signal_connect(G_OBJECT(combo), "changed", - G_CALLBACK(symgroup_changed), NULL); + combo->set_active(current); + combo->signal_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::symgroup_changed), combo)); } table_row_labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); @@ -175,7 +170,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Horizontal shift per row (in % of tile width)"), "shiftx_per_j", -10000, 10000, "%"); @@ -183,7 +178,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Horizontal shift per column (in % of tile width)"), "shiftx_per_i", -10000, 10000, "%"); @@ -191,7 +186,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand", + auto l = spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand", 0, 1000, "%"); table_attach (table, l, 0, 2, 4); } @@ -207,7 +202,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Vertical shift per row (in % of tile height)"), "shifty_per_j", -10000, 10000, "%"); @@ -215,7 +210,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Vertical shift per column (in % of tile height)"), "shifty_per_i", -10000, 10000, "%"); @@ -223,7 +218,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( _("Randomize the vertical shift by this percentage"), "shifty_rand", 0, 1000, "%"); table_attach (table, l, 0, 3, 4); @@ -238,14 +233,14 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( _("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "shifty_exp", 0, 10, "", true); table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = spinbox ( + auto l = spinbox ( _("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "shiftx_exp", 0, 10, "", true); table_attach (table, l, 0, 4, 3); @@ -260,12 +255,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate"); + auto l = checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate"); table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate"); + auto l = checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate"); table_attach (table, l, 0, 5, 3); } @@ -278,12 +273,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate"); + auto l = checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate"); table_attach (table, l, 0, 6, 2); } { - GtkWidget *l = checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate"); + auto l = checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate"); table_attach (table, l, 0, 6, 3); } @@ -296,12 +291,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Exclude tile height in shift"), "shifty_excludeh"); + auto l = checkbox (_("Exclude tile height in shift"), "shifty_excludeh"); table_attach (table, l, 0, 7, 2); } { - GtkWidget *l = checkbox (_("Exclude tile width in shift"), "shiftx_excludew"); + auto l = checkbox (_("Exclude tile width in shift"), "shiftx_excludew"); table_attach (table, l, 0, 7, 3); } @@ -324,7 +319,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Horizontal scale per row (in % of tile width)"), "scalex_per_j", -100, 1000, "%"); @@ -332,7 +327,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Horizontal scale per column (in % of tile width)"), "scalex_per_i", -100, 1000, "%"); @@ -340,7 +335,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand", + auto l = spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand", 0, 1000, "%"); table_attach (table, l, 0, 2, 4); } @@ -354,7 +349,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Vertical scale per row (in % of tile height)"), "scaley_per_j", -100, 1000, "%"); @@ -362,7 +357,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Vertical scale per column (in % of tile height)"), "scaley_per_i", -100, 1000, "%"); @@ -370,7 +365,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand", + auto l = spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand", 0, 1000, "%"); table_attach (table, l, 0, 3, 4); } @@ -384,13 +379,13 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp", + auto l = spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp", 0, 10, "", true); table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp", + auto l = spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp", 0, 10, "", true); table_attach (table, l, 0, 4, 3); } @@ -404,13 +399,13 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log", + auto l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log", 0, 10, "", false); table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log", + auto l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log", 0, 10, "", false); table_attach (table, l, 0, 5, 3); } @@ -424,12 +419,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate"); + auto l = checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate"); table_attach (table, l, 0, 6, 2); } { - GtkWidget *l = checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate"); + auto l = checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate"); table_attach (table, l, 0, 6, 3); } @@ -442,12 +437,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Cumulate the scales for each row"), "scaley_cumulate"); + auto l = checkbox (_("Cumulate the scales for each row"), "scaley_cumulate"); table_attach (table, l, 0, 7, 2); } { - GtkWidget *l = checkbox (_("Cumulate the scales for each column"), "scalex_cumulate"); + auto l = checkbox (_("Cumulate the scales for each column"), "scalex_cumulate"); table_attach (table, l, 0, 7, 3); } @@ -470,7 +465,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Rotate tiles by this angle for each row"), "rotate_per_j", -180, 180, "°"); @@ -478,7 +473,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Rotate tiles by this angle for each column"), "rotate_per_i", -180, 180, "°"); @@ -486,7 +481,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand", + auto l = spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand", 0, 100, "%"); table_attach (table, l, 0, 2, 4); } @@ -500,12 +495,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej"); + auto l = checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej"); table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei"); + auto l = checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei"); table_attach (table, l, 0, 3, 3); } @@ -518,12 +513,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Cumulate the rotation for each row"), "rotate_cumulatej"); + auto l = checkbox (_("Cumulate the rotation for each row"), "rotate_cumulatej"); table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei"); + auto l = checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei"); table_attach (table, l, 0, 4, 3); } @@ -547,19 +542,19 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Blur tiles by this percentage for each row"), "blur_per_j", + auto l = spinbox (_("Blur tiles by this percentage for each row"), "blur_per_j", 0, 100, "%"); table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i", + auto l = spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i", 0, 100, "%"); table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = spinbox (_("Randomize the tile blur by this percentage"), "blur_rand", + auto l = spinbox (_("Randomize the tile blur by this percentage"), "blur_rand", 0, 100, "%"); table_attach (table, l, 0, 2, 4); } @@ -573,12 +568,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej"); + auto l = checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej"); table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei"); + auto l = checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei"); table_attach (table, l, 0, 3, 3); } @@ -593,19 +588,19 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j", + auto l = spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j", 0, 100, "%"); table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i", + auto l = spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i", 0, 100, "%"); table_attach (table, l, 0, 4, 3); } { - GtkWidget *l = spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand", + auto l = spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand", 0, 100, "%"); table_attach (table, l, 0, 4, 4); } @@ -619,12 +614,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej"); + auto l = checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej"); table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei"); + auto l = checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei"); table_attach (table, l, 0, 5, 3); } } @@ -643,7 +638,7 @@ CloneTiler::CloneTiler () : guint32 rgba = 0x000000ff | sp_svg_read_color (prefs->getString(prefs_path + "initial_color").data(), 0x000000ff); color_picker = new Inkscape::UI::Widget::ColorPicker (*new Glib::ustring(_("Initial color of tiled clones")), *new Glib::ustring(_("Initial color for clones (works only if the original has unset fill or stroke or on spray tool in copy mode)")), rgba, false); - color_changed_connection = color_picker->connectChanged (sigc::ptr_fun(on_picker_color_changed)); + color_changed_connection = color_picker->connectChanged(sigc::mem_fun(*this, &CloneTiler::on_picker_color_changed)); gtk_box_pack_start (GTK_BOX (hb), reinterpret_cast(color_picker->gobj()), FALSE, FALSE, 0); @@ -663,19 +658,19 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j", + auto l = spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j", -100, 100, "%"); table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i", + auto l = spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i", -100, 100, "%"); table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = spinbox (_("Randomize the tile hue by this percentage"), "hue_rand", + auto l = spinbox (_("Randomize the tile hue by this percentage"), "hue_rand", 0, 100, "%"); table_attach (table, l, 0, 2, 4); } @@ -690,19 +685,19 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j", + auto l = spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j", -100, 100, "%"); table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i", + auto l = spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i", -100, 100, "%"); table_attach (table, l, 0, 3, 3); } { - GtkWidget *l = spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand", + auto l = spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand", 0, 100, "%"); table_attach (table, l, 0, 3, 4); } @@ -716,19 +711,19 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j", + auto l = spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j", -100, 100, "%"); table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i", + auto l = spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i", -100, 100, "%"); table_attach (table, l, 0, 4, 3); } { - GtkWidget *l = spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand", + auto l = spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand", 0, 100, "%"); table_attach (table, l, 0, 4, 4); } @@ -742,12 +737,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej"); + auto l = checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej"); table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei"); + auto l = checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei"); table_attach (table, l, 0, 5, 3); } @@ -785,71 +780,62 @@ CloneTiler::CloneTiler () : gtk_grid_set_column_spacing(GTK_GRID(table), 6); gtk_container_add(GTK_CONTAINER(frame), table); - - GtkWidget* radio; + Gtk::RadioButtonGroup rb_group; { - radio = gtk_radio_button_new_with_label (NULL, _("Color")); - gtk_widget_set_tooltip_text (radio, _("Pick the visible color and opacity")); - table_attach (table, radio, 0.0, 1, 1); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_COLOR)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Color"))); + radio->set_tooltip_text(_("Pick the visible color and opacity")); + table_attach(table, radio, 0.0, 1, 1); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_COLOR)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Opacity")); - gtk_widget_set_tooltip_text (radio, _("Pick the total accumulated opacity")); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Opacity"))); + radio->set_tooltip_text(_("Pick the total accumulated opacity")); table_attach (table, radio, 0.0, 2, 1); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_OPACITY)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_OPACITY)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("R")); - gtk_widget_set_tooltip_text (radio, _("Pick the Red component of the color")); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("R"))); + radio->set_tooltip_text(_("Pick the Red component of the color")); table_attach (table, radio, 0.0, 1, 2); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_R)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_R); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_R)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_R); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("G")); - gtk_widget_set_tooltip_text (radio, _("Pick the Green component of the color")); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("G"))); + radio->set_tooltip_text(_("Pick the Green component of the color")); table_attach (table, radio, 0.0, 2, 2); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_G)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_G); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_G)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_G); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("B")); - gtk_widget_set_tooltip_text (radio, _("Pick the Blue component of the color")); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("B"))); + radio->set_tooltip_text(_("Pick the Blue component of the color")); table_attach (table, radio, 0.0, 3, 2); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_B)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_B); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_B)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_B); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H")); - gtk_widget_set_tooltip_text (radio, _("Pick the hue of the color")); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, C_("Clonetiler color hue", "H"))); + radio->set_tooltip_text(_("Pick the hue of the color")); table_attach (table, radio, 0.0, 1, 3); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_H)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_H); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_H)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_H); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S")); - gtk_widget_set_tooltip_text (radio, _("Pick the saturation of the color")); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, C_("Clonetiler color saturation", "S"))); + radio->set_tooltip_text(_("Pick the saturation of the color")); table_attach (table, radio, 0.0, 2, 3); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_S)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_S); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_S)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_S); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L")); - gtk_widget_set_tooltip_text (radio, _("Pick the lightness of the color")); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, C_("Clonetiler color lightness", "L"))); + radio->set_tooltip_text(_("Pick the lightness of the color")); table_attach (table, radio, 0.0, 3, 3); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_L)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_L); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_L)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_L); } } @@ -870,7 +856,7 @@ CloneTiler::CloneTiler () : table_attach (table, l, 1.0, 1, 1); } { - GtkWidget *l = spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked", + auto l = spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked", -10, 10, ""); table_attach (table, l, 0.0, 1, 2); } @@ -881,7 +867,7 @@ CloneTiler::CloneTiler () : table_attach (table, l, 1.0, 1, 3); } { - GtkWidget *l = spinbox (_("Randomize the picked value by this percentage"), "rand_picked", + auto l = spinbox (_("Randomize the picked value by this percentage"), "rand_picked", 0, 100, "%"); table_attach (table, l, 0.0, 1, 4); } @@ -892,7 +878,7 @@ CloneTiler::CloneTiler () : table_attach (table, l, 1.0, 2, 1); } { - GtkWidget *l = checkbox (_("Invert the picked value"), "invert_picked"); + auto l = checkbox (_("Invert the picked value"), "invert_picked"); table_attach (table, l, 0.0, 2, 2); } } @@ -907,43 +893,39 @@ CloneTiler::CloneTiler () : gtk_container_add(GTK_CONTAINER(frame), table); { - GtkWidget *b = gtk_check_button_new_with_label (_("Presence")); + auto b = Gtk::manage(new Gtk::CheckButton(_("Presence"))); bool old = prefs->getBool(prefs_path + "pick_to_presence", true); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone is created with the probability determined by the picked value in that point")); + b->set_active(old); + b->set_tooltip_text(_("Each clone is created with the probability determined by the picked value in that point")); table_attach (table, b, 0.0, 1, 1); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(pick_to), (gpointer) "pick_to_presence"); + b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_presence")); } { - GtkWidget *b = gtk_check_button_new_with_label (_("Size")); + auto b = Gtk::manage(new Gtk::CheckButton(_("Size"))); bool old = prefs->getBool(prefs_path + "pick_to_size"); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone's size is determined by the picked value in that point")); + b->set_active(old); + b->set_tooltip_text(_("Each clone's size is determined by the picked value in that point")); table_attach (table, b, 0.0, 2, 1); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(pick_to), (gpointer) "pick_to_size"); + b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_size")); } { - GtkWidget *b = gtk_check_button_new_with_label (_("Color")); + auto b = Gtk::manage(new Gtk::CheckButton(_("Color"))); bool old = prefs->getBool(prefs_path + "pick_to_color", 0); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)")); + b->set_active(old); + b->set_tooltip_text(_("Each clone is painted by the picked color (the original must have unset fill or stroke)")); table_attach (table, b, 0.0, 1, 2); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(pick_to), (gpointer) "pick_to_color"); + b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_color")); } { - GtkWidget *b = gtk_check_button_new_with_label (_("Opacity")); + auto b = Gtk::manage(new Gtk::CheckButton(_("Opacity"))); bool old = prefs->getBool(prefs_path + "pick_to_opacity", 0); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone's opacity is determined by the picked value in that point")); + b->set_active(old); + b->set_tooltip_text(_("Each clone's opacity is determined by the picked value in that point")); table_attach (table, b, 0.0, 2, 2); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(pick_to), (gpointer) "pick_to_opacity"); + b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_opacity")); } } gtk_widget_set_sensitive (vvb, prefs->getBool(prefs_path + "dotrace")); @@ -980,9 +962,7 @@ CloneTiler::CloneTiler () : sb->set_width_chars (7); _rowscols->pack_start(*sb, true, true, 0); - // TODO: C++ification - g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(xy_changed), (gpointer) "jmax"); + a->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::xy_changed), a, "jmax")); } { @@ -1002,9 +982,7 @@ CloneTiler::CloneTiler () : sb->set_width_chars (7); _rowscols->pack_start(*sb, true, true, 0); - // TODO: C++ification - g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(xy_changed), (gpointer) "imax"); + a->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::xy_changed), a, "imax")); } table_attach (table, GTK_WIDGET(_rowscols->gobj()), 0.0, 1, 2); @@ -1164,11 +1142,11 @@ CloneTiler::CloneTiler () : } { - GtkWidget *b = gtk_button_new_with_mnemonic (_(" R_eset ")); + auto b = Gtk::manage(new Gtk::Button(_(" R_eset "), true)); // TRANSLATORS: "change" is a noun here - gtk_widget_set_tooltip_text (b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (reset), this); - gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); + b->set_tooltip_text(_("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero")); + b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::reset)); + gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0); } } @@ -2197,7 +2175,7 @@ void CloneTiler::apply() SPItem *item = dynamic_cast(obj); if (dotrace) { - trace_setup (desktop->getDocument(), 1.0, item); + trace_setup(desktop->getDocument(), 1.0, item); } Geom::Point center; @@ -2524,72 +2502,74 @@ GtkWidget * CloneTiler::new_tab(GtkWidget *nb, const gchar *label) return vb; } -void CloneTiler::checkbox_toggled(GtkToggleButton *tb, gpointer *data) +void CloneTiler::checkbox_toggled(Gtk::ToggleButton *tb, + const Glib::ustring &attr) { - const gchar *attr = (const gchar *) data; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setBool(prefs_path + attr, gtk_toggle_button_get_active(tb)); + auto prefs = Inkscape::Preferences::get(); + prefs->setBool(prefs_path + attr, tb->get_active()); } -GtkWidget * CloneTiler::checkbox(const char *tip, const char *attr) +Gtk::Widget * CloneTiler::checkbox(const char *tip, + const Glib::ustring &attr) { - auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); - - GtkWidget *b = gtk_check_button_new (); - gtk_widget_set_tooltip_text (b, tip); + auto hb = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN)); + auto b = Gtk::manage(new Gtk::CheckButton()); + b->set_tooltip_text(tip); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool value = prefs->getBool(prefs_path + attr); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(b), value); + auto const prefs = Inkscape::Preferences::get(); + auto const value = prefs->getBool(prefs_path + attr); + b->set_active(value); - gtk_box_pack_end (GTK_BOX (hb), b, FALSE, TRUE, 0); - g_signal_connect ( G_OBJECT (b), "clicked", - G_CALLBACK (checkbox_toggled), (gpointer) attr); + hb->pack_end(*b, false, true); + b->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::checkbox_toggled), b, attr)); - g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE)); + b->set_data("uncheckable", GINT_TO_POINTER(true)); return hb; } -void CloneTiler::value_changed(GtkAdjustment *adj, gpointer data) +void CloneTiler::value_changed(Glib::RefPtr &adj, + Glib::ustring const &pref) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - const gchar *pref = (const gchar *) data; - prefs->setDouble(prefs_path + pref, gtk_adjustment_get_value (adj)); + auto prefs = Inkscape::Preferences::get(); + prefs->setDouble(prefs_path + pref, adj->get_value()); } -GtkWidget * CloneTiler::spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent/* = false*/) +Gtk::Widget * CloneTiler::spinbox(const char *tip, + const Glib::ustring &attr, + double lower, + double upper, + const gchar *suffix, + bool exponent/* = false*/) { - auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); + auto hb = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 0)); { - Glib::RefPtr a; - if (exponent) { - a = Gtk::Adjustment::create(1.0, lower, upper, 0.01, 0.05, 0); - } else { - a = Gtk::Adjustment::create(0.0, lower, upper, 0.1, 0.5, 0); - } + // Parameters for adjustment + auto const initial_value = (exponent ? 1.0 : 0.0); + auto const step_increment = (exponent ? 0.01 : 0.1); + auto const page_increment = (exponent ? 0.05 : 0.4); - Inkscape::UI::Widget::SpinButton *sb; - if (exponent) { - sb = new Inkscape::UI::Widget::SpinButton(a, 0.01, 2); - } else { - sb = new Inkscape::UI::Widget::SpinButton(a, 0.1, 1); - } + auto a = Gtk::Adjustment::create(initial_value, + lower, + upper, + step_increment, + page_increment); + + auto const climb_rate = (exponent ? 0.01 : 0.1); + auto const digits = (exponent ? 2 : 1); + + auto sb = new Inkscape::UI::Widget::SpinButton(a, climb_rate, digits); sb->set_tooltip_text (tip); sb->set_width_chars (5); sb->set_digits(3); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), FALSE, FALSE, SB_MARGIN); + hb->pack_start(*sb, false, false, SB_MARGIN); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double value = prefs->getDoubleLimited(prefs_path + attr, exponent? 1.0 : 0.0, lower, upper); + auto prefs = Inkscape::Preferences::get(); + auto value = prefs->getDoubleLimited(prefs_path + attr, exponent? 1.0 : 0.0, lower, upper); a->set_value (value); - // TODO: C++ification - g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(value_changed), (gpointer) attr); + a->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::value_changed), a, attr)); if (exponent) { sb->set_data ("oneable", GINT_TO_POINTER(TRUE)); @@ -2599,28 +2579,27 @@ GtkWidget * CloneTiler::spinbox(const char *tip, const char *attr, double lower, } { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), suffix); - gtk_widget_set_halign(l, GTK_ALIGN_END); - gtk_widget_set_valign(l, GTK_ALIGN_START); - gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); + auto l = Gtk::manage(new Gtk::Label("")); + l->set_markup(suffix); + l->set_halign(Gtk::ALIGN_END); + l->set_valign(Gtk::ALIGN_START); + hb->pack_start(*l); } return hb; } -void CloneTiler::symgroup_changed(GtkComboBox *cb, gpointer /*data*/) +void CloneTiler::symgroup_changed(Gtk::ComboBox *cb) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gint group_new = gtk_combo_box_get_active (cb); + auto prefs = Inkscape::Preferences::get(); + auto group_new = cb->get_active_row_number(); prefs->setInt(prefs_path + "symmetrygroup", group_new); } -void CloneTiler::xy_changed(GtkAdjustment *adj, gpointer data) +void CloneTiler::xy_changed(Glib::RefPtr &adj, Glib::ustring const &pref) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - const gchar *pref = (const gchar *) data; - prefs->setInt(prefs_path + pref, (int) floor(gtk_adjustment_get_value (adj) + 0.5)); + auto prefs = Inkscape::Preferences::get(); + prefs->setInt(prefs_path + pref, (int) floor(adj->get_value() + 0.5)); } void CloneTiler::keep_bbox_toggled() @@ -2629,11 +2608,10 @@ void CloneTiler::keep_bbox_toggled() prefs->setBool(prefs_path + "keepbbox", _cb_keep_bbox->get_active()); } -void CloneTiler::pick_to(GtkToggleButton *tb, gpointer data) +void CloneTiler::pick_to(Gtk::ToggleButton *tb, Glib::ustring const &pref) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - const gchar *pref = (const gchar *) data; - prefs->setBool(prefs_path + pref, gtk_toggle_button_get_active(tb)); + auto prefs = Inkscape::Preferences::get(); + prefs->setBool(prefs_path + pref, tb->get_active()); } @@ -2671,9 +2649,14 @@ void CloneTiler::reset_recursive(GtkWidget *w) } } -void CloneTiler::reset(GtkWidget */*widget*/, GtkWidget *dlg) +void CloneTiler::reset() +{ + reset_recursive(GTK_WIDGET(this->gobj())); +} + +void CloneTiler::table_attach(GtkWidget *table, Gtk::Widget *widget, float align, int row, int col) { - reset_recursive (dlg); + table_attach(table, GTK_WIDGET(widget->gobj()), align, row, col); } void CloneTiler::table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col) @@ -2728,14 +2711,12 @@ GtkWidget * CloneTiler::table_x_y_rand(int values) return table; } -void CloneTiler::pick_switched(GtkToggleButton */*tb*/, gpointer data) +void CloneTiler::pick_switched(PickType v) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - guint v = GPOINTER_TO_INT (data); + auto prefs = Inkscape::Preferences::get(); prefs->setInt(prefs_path + "pick", v); } - void CloneTiler::switch_to_create() { if (_rowscols) { -- cgit v1.2.3