diff options
| author | Alex Valavanis <valavanisalex@gmail.com> | 2012-12-09 13:57:31 +0000 |
|---|---|---|
| committer | Alex Valavanis <valavanisalex@gmail.com> | 2012-12-09 13:57:31 +0000 |
| commit | 73186b30e90fdca666af811ee63b385eeb9740b1 (patch) | |
| tree | 2b4214d6878d51ed7d695a921d7b7eaa3b2bc7b5 /src | |
| parent | Tidy up GTK/Glib deprecation flags and drop ancient pango support (<1.24) (diff) | |
| download | inkscape-73186b30e90fdca666af811ee63b385eeb9740b1.tar.gz inkscape-73186b30e90fdca666af811ee63b385eeb9740b1.zip | |
Migrate remaining stuff from GtkTable to GtkGrid
(bzr r11939)
Diffstat (limited to 'src')
| -rw-r--r-- | src/ui/dialog/clonetiler.cpp | 47 | ||||
| -rw-r--r-- | src/widgets/spw-utilities.cpp | 93 | ||||
| -rw-r--r-- | src/widgets/spw-utilities.h | 20 | ||||
| -rw-r--r-- | src/widgets/stroke-style.cpp | 45 | ||||
| -rw-r--r-- | src/widgets/stroke-style.h | 13 |
5 files changed, 198 insertions, 20 deletions
diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index f51470826..e971cfb09 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -815,9 +815,15 @@ CloneTiler::CloneTiler (void) : 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(); + 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); @@ -893,9 +899,16 @@ CloneTiler::CloneTiler (void) : 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(); + 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); { @@ -935,10 +948,15 @@ CloneTiler::CloneTiler (void) : 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(); + 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); { @@ -987,10 +1005,17 @@ CloneTiler::CloneTiler (void) : // Rows/columns, width/height { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *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_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); 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); { @@ -2807,15 +2832,29 @@ void CloneTiler::clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, fl { 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, (GtkAttachOptions)4, (GtkAttachOptions)0, 0, 0 ); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(table, GTK_ALIGN_FILL); + gtk_widget_set_valign(table, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(table), a, col, row, 1, 1); +#else + 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(); + 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_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); 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) diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index 8adc72cd7..ce8ce388d 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -19,7 +19,12 @@ #include <gtkmm/box.h> #include <gtkmm/label.h> + +#if GTK_CHECK_VERSION(3,0,0) +#include <gtkmm/grid.h> +#else #include <gtkmm/table.h> +#endif #include "selection.h" @@ -32,8 +37,11 @@ * Creates a label widget with the given text, at the given col, row * position in the table. */ -Gtk::Label * -spw_label(Gtk::Table *table, const gchar *label_text, int col, int row, Gtk::Widget* target) +#if GTK_CHECK_VERSION(3,0,0) +Gtk::Label * spw_label(Gtk::Grid *table, const gchar *label_text, int col, int row, Gtk::Widget* target) +#else +Gtk::Label * spw_label(Gtk::Table *table, const gchar *label_text, int col, int row, Gtk::Widget* target) +#endif { Gtk::Label *label_widget = new Gtk::Label(); g_assert(label_widget != NULL); @@ -48,7 +56,18 @@ spw_label(Gtk::Table *table, const gchar *label_text, int col, int row, Gtk::Wid } label_widget->set_alignment(1.0, 0.5); label_widget->show(); + +#if GTK_CHECK_VERSION(3,0,0) + label_widget->set_hexpand(); + label_widget->set_halign(Gtk::ALIGN_FILL); + label_widget->set_valign(Gtk::ALIGN_CENTER); + label_widget->set_margin_left(4); + label_widget->set_margin_right(4); + table->attach(*label_widget, col, row, 1, 1); +#else table->attach(*label_widget, col, col+1, row, row+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 4, 0); +#endif + return label_widget; } @@ -61,8 +80,19 @@ spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row) g_assert(label_widget != NULL); gtk_misc_set_alignment (GTK_MISC (label_widget), 1.0, 0.5); gtk_widget_show (label_widget); - gtk_table_attach (GTK_TABLE (table), label_widget, col, col+1, row, row+1, + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(label_widget, 4); + gtk_widget_set_margin_right(label_widget, 4); + gtk_widget_set_hexpand(label_widget, TRUE); + gtk_widget_set_halign(label_widget, GTK_ALIGN_FILL); + gtk_widget_set_valign(label_widget, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(table), label_widget, col, row, 1, 1); +#else + gtk_table_attach(GTK_TABLE (table), label_widget, col, col+1, row, row+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 4, 0); +#endif + return label_widget; } @@ -70,14 +100,26 @@ spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row) * Creates a horizontal layout manager with 4-pixel spacing between children * and space for 'width' columns. */ -Gtk::HBox * -spw_hbox(Gtk::Table * table, int width, int col, int row) +#if GTK_CHECK_VERSION(3,0,0) +Gtk::HBox * spw_hbox(Gtk::Grid * table, int width, int col, int row) +#else +Gtk::HBox * spw_hbox(Gtk::Table * table, int width, int col, int row) +#endif { /* Create a new hbox with a 4-pixel spacing between children */ Gtk::HBox *hb = new Gtk::HBox(false, 4); g_assert(hb != NULL); hb->show(); + +#if GTK_CHECK_VERSION(3,0,0) + hb->set_hexpand(); + hb->set_halign(Gtk::ALIGN_FILL); + hb->set_valign(Gtk::ALIGN_CENTER); + table->attach(*hb, col, row, width, 1); +#else table->attach(*hb, col, col+width, row, row+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0); +#endif + return hb; } @@ -117,16 +159,33 @@ spw_checkbutton(GtkWidget * dialog, GtkWidget * table, g_assert(dialog != NULL); g_assert(table != NULL); - GtkWidget *l = gtk_label_new (label); - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); - gtk_widget_show (l); + GtkWidget *l = gtk_label_new (label); + gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); + gtk_widget_show (l); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(l, GTK_ALIGN_FILL); + gtk_widget_set_hexpand(l, TRUE); + gtk_widget_set_valign(l, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(table), l, 0, row, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), l, 0, 1, row, row+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0); +#endif b = gtk_check_button_new (); gtk_widget_show (b); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(b, GTK_ALIGN_FILL); + gtk_widget_set_hexpand(b, TRUE); + gtk_widget_set_valign(b, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(table), b, 1, row, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), b, 1, 2, row, row+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0); +#endif + g_object_set_data (G_OBJECT (b), "key", key); g_object_set_data (G_OBJECT (dialog), key, b); g_signal_connect (G_OBJECT (b), "toggled", cb, dialog); @@ -153,8 +212,17 @@ spw_dropdown(GtkWidget * dialog, GtkWidget * table, spw_label_old(table, label_text, 0, row); gtk_widget_show (selector); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(selector, GTK_ALIGN_FILL); + gtk_widget_set_hexpand(selector, TRUE); + gtk_widget_set_valign(selector, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(table), selector, 1, row, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), selector, 1, 2, row, row+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0); +#endif + g_object_set_data (G_OBJECT (dialog), key, selector); return selector; } @@ -189,8 +257,17 @@ spw_unit_selector(GtkWidget * dialog, GtkWidget * table, GtkWidget * sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 4); g_assert(sb != NULL); gtk_widget_show (sb); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(sb, GTK_ALIGN_FILL); + gtk_widget_set_hexpand(sb, TRUE); + gtk_widget_set_valign(sb, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(table), sb, 1, row, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), sb, 1, 2, row, row+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0); +#endif + g_signal_connect (G_OBJECT (a), "value_changed", cb, dialog); return sb; } diff --git a/src/widgets/spw-utilities.h b/src/widgets/spw-utilities.h index 263abbcaf..fb8c04ebf 100644 --- a/src/widgets/spw-utilities.h +++ b/src/widgets/spw-utilities.h @@ -20,18 +20,26 @@ namespace Gtk { class Label; + +#if GTK_CHECK_VERSION(3,0,0) + class Grid; +#else class Table; +#endif + class HBox; class Widget; } -Gtk::Label * -spw_label(Gtk::Table *table, gchar const *label_text, int col, int row, Gtk::Widget *target); -GtkWidget * -spw_label_old(GtkWidget *table, gchar const *label_text, int col, int row); +#if GTK_CHECK_VERSION(3,0,0) +Gtk::Label * spw_label(Gtk::Grid *table, gchar const *label_text, int col, int row, Gtk::Widget *target); +Gtk::HBox * spw_hbox(Gtk::Grid *table, int width, int col, int row); +#else +Gtk::Label * spw_label(Gtk::Table *table, gchar const *label_text, int col, int row, Gtk::Widget *target); +Gtk::HBox * spw_hbox(Gtk::Table *table, int width, int col, int row); +#endif -Gtk::HBox * -spw_hbox(Gtk::Table *table, int width, int col, int row); +GtkWidget * spw_label_old(GtkWidget *table, gchar const *label_text, int col, int row); GtkWidget * spw_vbox_checkbutton(GtkWidget *dialog, GtkWidget *table, diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 4e8431454..7912b654a 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -122,10 +122,17 @@ StrokeStyle::StrokeStyle() : f->show(); add(*f); +#if WITH_GTKMM_3_0 + table = new Gtk::Grid(); + table->set_border_width(4); + table->set_row_spacing(4); +#else table = new Gtk::Table(3, 6, false); - table->show(); table->set_border_width(4); table->set_row_spacings(4); +#endif + + table->show(); f->add(*table); gint i = 0; @@ -282,7 +289,16 @@ StrokeStyle::StrokeStyle() : dashSelector = manage(new SPDashSelector); dashSelector->show(); + +#if WITH_GTKMM_3_0 + dashSelector->set_hexpand(); + dashSelector->set_halign(Gtk::ALIGN_FILL); + dashSelector->set_valign(Gtk::ALIGN_CENTER); + table->attach(*dashSelector, 1, i, 3, 1); +#else table->attach(*dashSelector, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0); +#endif + dashSelector->changed_signal.connect(sigc::mem_fun(*this, &StrokeStyle::lineDashChangedCB)); i++; @@ -298,7 +314,16 @@ StrokeStyle::StrokeStyle() : sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>( sigc::ptr_fun(&StrokeStyle::markerSelectCB), startMarkerCombo, this, SP_MARKER_LOC_START)); startMarkerCombo->show(); + +#if WITH_GTKMM_3_0 + startMarkerCombo->set_hexpand(); + startMarkerCombo->set_halign(Gtk::ALIGN_FILL); + startMarkerCombo->set_valign(Gtk::ALIGN_CENTER); + table->attach(*startMarkerCombo, 1, i, 3, 1); +#else table->attach(*startMarkerCombo, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0); +#endif + i++; midMarkerCombo = manage(new MarkerComboBox("marker-mid", SP_MARKER_LOC_MID)); @@ -308,7 +333,16 @@ StrokeStyle::StrokeStyle() : sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>( sigc::ptr_fun(&StrokeStyle::markerSelectCB), midMarkerCombo, this, SP_MARKER_LOC_MID)); midMarkerCombo->show(); + +#if WITH_GTKMM_3_0 + midMarkerCombo->set_hexpand(); + midMarkerCombo->set_halign(Gtk::ALIGN_FILL); + midMarkerCombo->set_valign(Gtk::ALIGN_CENTER); + table->attach(*midMarkerCombo, 1, i, 3, 1); +#else table->attach(*midMarkerCombo, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0); +#endif + i++; endMarkerCombo = manage(new MarkerComboBox("marker-end", SP_MARKER_LOC_END)); @@ -318,7 +352,16 @@ StrokeStyle::StrokeStyle() : sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>( sigc::ptr_fun(&StrokeStyle::markerSelectCB), endMarkerCombo, this, SP_MARKER_LOC_END)); endMarkerCombo->show(); + +#if WITH_GTKMM_3_0 + endMarkerCombo->set_hexpand(); + endMarkerCombo->set_halign(Gtk::ALIGN_FILL); + endMarkerCombo->set_valign(Gtk::ALIGN_CENTER); + table->attach(*endMarkerCombo, 1, i, 3, 1); +#else table->attach(*endMarkerCombo, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0); +#endif + i++; setDesktop(desktop); diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h index d437f7e12..5f05b97d1 100644 --- a/src/widgets/stroke-style.h +++ b/src/widgets/stroke-style.h @@ -15,9 +15,19 @@ #ifndef SEEN_DIALOGS_STROKE_STYLE_H #define SEEN_DIALOGS_STROKE_STYLE_H +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include "widgets/dash-selector.h" #include <gtkmm/radiobutton.h> + +#if WITH_GTKMM_3_0 +#include <gtkmm/grid.h> +#else #include <gtkmm/table.h> +#endif + #include <glibmm/i18n.h> #include "desktop.h" @@ -139,11 +149,12 @@ private: MarkerComboBox *startMarkerCombo; MarkerComboBox *midMarkerCombo; MarkerComboBox *endMarkerCombo; - Gtk::Table *table; #if WITH_GTKMM_3_0 + Gtk::Grid *table; Glib::RefPtr<Gtk::Adjustment> *widthAdj; Glib::RefPtr<Gtk::Adjustment> *miterLimitAdj; #else + Gtk::Table *table; Gtk::Adjustment *widthAdj; Gtk::Adjustment *miterLimitAdj; #endif |
