diff options
| author | Alex Valavanis <valavanisalex@gmail.com> | 2013-03-08 01:22:57 +0000 |
|---|---|---|
| committer | Alex Valavanis <valavanisalex@gmail.com> | 2013-03-08 01:22:57 +0000 |
| commit | 9af3b480980742e04a220fb2dd37ee8b55df62c4 (patch) | |
| tree | 12183cd4a7ce025a744a40329ea12c1b85eeb7b1 /src | |
| parent | Switch to orientable Scale widgets in Gtkmm 3 (diff) | |
| download | inkscape-9af3b480980742e04a220fb2dd37ee8b55df62c4.tar.gz inkscape-9af3b480980742e04a220fb2dd37ee8b55df62c4.zip | |
Drop more Gtk::Table usage
(bzr r12180)
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/canvas-axonomgrid.cpp | 54 | ||||
| -rw-r--r-- | src/display/canvas-grid.cpp | 57 | ||||
| -rw-r--r-- | src/extension/extension.cpp | 26 | ||||
| -rw-r--r-- | src/extension/extension.h | 10 | ||||
| -rw-r--r-- | src/ui/widget/dock.cpp | 12 |
5 files changed, 143 insertions, 16 deletions
diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index bfc6f27c4..170684328 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -12,11 +12,20 @@ * smaller than 90 degrees (measured from horizontal, 0 degrees being a line extending * to the right). The x-axis will always have an angle between 0 and 90 degrees. */ - + +#if HAVE_CONFIG_H +# include "config.h" +#endif #include <gtkmm/box.h> #include <gtkmm/label.h> -#include <gtkmm/table.h> + +#if WITH_GTKMM_3_0 +# include <gtkmm/grid.h> +#else +# include <gtkmm/table.h> +#endif + #include <glibmm/i18n.h> #include "display/canvas-axonomgrid.h" @@ -83,28 +92,60 @@ namespace Inkscape { #define SPACE_SIZE_X 15 #define SPACE_SIZE_Y 10 static inline void +#if WITH_GTKMM_3_0 +attach_all(Gtk::Grid &table, Gtk::Widget const *const arr[], unsigned size, int start = 0) +#else attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int start = 0) +#endif { for (unsigned i=0, r=start; i<size/sizeof(Gtk::Widget*); i+=2) { if (arr[i] && arr[i+1]) { +#if WITH_GTKMM_3_0 + (const_cast<Gtk::Widget&>(*arr[i])).set_hexpand(); + (const_cast<Gtk::Widget&>(*arr[i])).set_valign(Gtk::ALIGN_CENTER); + table.attach(const_cast<Gtk::Widget&>(*arr[i]), 1, r, 1, 1); + + (const_cast<Gtk::Widget&>(*arr[i+1])).set_hexpand(); + (const_cast<Gtk::Widget&>(*arr[i+1])).set_valign(Gtk::ALIGN_CENTER); + table.attach(const_cast<Gtk::Widget&>(*arr[i+1]), 2, r, 1, 1); +#else table.attach (const_cast<Gtk::Widget&>(*arr[i]), 1, 2, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 2, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); +#endif } else { if (arr[i+1]) { +#if WITH_GTKMM_3_0 + (const_cast<Gtk::Widget&>(*arr[i+1])).set_hexpand(); + (const_cast<Gtk::Widget&>(*arr[i+1])).set_valign(Gtk::ALIGN_CENTER); + table.attach(const_cast<Gtk::Widget&>(*arr[i+1]), 1, r, 2, 1); +#else table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); +#endif } else if (arr[i]) { Gtk::Label& label = reinterpret_cast<Gtk::Label&> (const_cast<Gtk::Widget&>(*arr[i])); label.set_alignment (0.0); +#if WITH_GTKMM_3_0 + label.set_hexpand(); + label.set_valign(Gtk::ALIGN_CENTER); + table.attach(label, 0, r, 3, 1); +#else table.attach (label, 0, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); +#endif } else { Gtk::HBox *space = manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); +#if WITH_GTKMM_3_0 + space->set_halign(Gtk::ALIGN_CENTER); + space->set_valign(Gtk::ALIGN_CENTER); + table.attach(*space, 0, r, 1, 1); +#else table.attach (*space, 0, 1, r, r+1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0); +#endif } } ++r; @@ -306,14 +347,17 @@ CanvasAxonomGrid::onReprAttrChanged(Inkscape::XML::Node */*repr*/, gchar const * updateWidgets(); } - - - Gtk::Widget * CanvasAxonomGrid::newSpecificWidget() { +#if WITH_GTKMM_3_0 + Gtk::Grid *table = Gtk::manage(new Gtk::Grid()); + table->set_row_spacing(2); + table->set_column_spacing(2); +#else Gtk::Table * table = Gtk::manage( new Gtk::Table(1,1) ); table->set_spacings(2); +#endif _wr.setUpdating (true); diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 51a6dd89b..c53890f9f 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -13,10 +13,19 @@ * Don't be shy to correct things. */ +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include <glibmm/i18n.h> #include <gtkmm/box.h> #include <gtkmm/label.h> -#include <gtkmm/table.h> + +#if WITH_GTKMM_3_0 +# include <gtkmm/grid.h> +#else +# include <gtkmm/table.h> +#endif #include "ui/widget/registered-widget.h" #include "desktop.h" @@ -410,29 +419,60 @@ void CanvasGrid::setOrigin(Geom::Point const &origin_px) **/ #define SPACE_SIZE_X 15 #define SPACE_SIZE_Y 10 -static inline void -attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int start = 0) +#if WITH_GTKMM_3_0 +static inline void attach_all(Gtk::Grid &table, Gtk::Widget const *const arr[], unsigned size, int start = 0) +#else +static inline void attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int start = 0) +#endif { for (unsigned i=0, r=start; i<size/sizeof(Gtk::Widget*); i+=2) { if (arr[i] && arr[i+1]) { +#if WITH_GTKMM_3_0 + (const_cast<Gtk::Widget&>(*arr[i])).set_hexpand(); + (const_cast<Gtk::Widget&>(*arr[i])).set_valign(Gtk::ALIGN_CENTER); + table.attach(const_cast<Gtk::Widget&>(*arr[i]), 1, r, 1, 1); + + (const_cast<Gtk::Widget&>(*arr[i+1])).set_hexpand(); + (const_cast<Gtk::Widget&>(*arr[i+1])).set_valign(Gtk::ALIGN_CENTER); + table.attach(const_cast<Gtk::Widget&>(*arr[i+1]), 2, r, 1, 1); +#else table.attach (const_cast<Gtk::Widget&>(*arr[i]), 1, 2, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 2, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); +#endif } else { if (arr[i+1]) { +#if WITH_GTKMM_3_0 + (const_cast<Gtk::Widget&>(*arr[i+1])).set_hexpand(); + (const_cast<Gtk::Widget&>(*arr[i+1])).set_valign(Gtk::ALIGN_CENTER); + table.attach(const_cast<Gtk::Widget&>(*arr[i+1]), 1, r, 2, 1); +#else table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); +#endif } else if (arr[i]) { Gtk::Label& label = reinterpret_cast<Gtk::Label&> (const_cast<Gtk::Widget&>(*arr[i])); label.set_alignment (0.0); +#if WITH_GTKMM_3_0 + label.set_hexpand(); + label.set_valign(Gtk::ALIGN_CENTER); + table.attach(label, 0, r, 3, 1); +#else table.attach (label, 0, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); +#endif } else { Gtk::HBox *space = manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); +#if WITH_GTKMM_3_0 + space->set_halign(Gtk::ALIGN_CENTER); + space->set_valign(Gtk::ALIGN_CENTER); + table.attach(*space, 0, r, 1, 1); +#else table.attach (*space, 0, 1, r, r+1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0); +#endif } } ++r; @@ -688,7 +728,14 @@ CanvasXYGrid::onReprAttrChanged(Inkscape::XML::Node */*repr*/, gchar const */*ke Gtk::Widget * CanvasXYGrid::newSpecificWidget() { +#if WITH_GTKMM_3_0 + Gtk::Grid * table = Gtk::manage( new Gtk::Grid() ); + table->set_row_spacing(2); + table->set_column_spacing(2); +#else Gtk::Table * table = Gtk::manage( new Gtk::Table(1,1) ); + table->set_spacings(2); +#endif Inkscape::UI::Widget::RegisteredUnitMenu *_rumg = Gtk::manage( new Inkscape::UI::Widget::RegisteredUnitMenu( _("Grid _units:"), "units", _wr, repr, doc) ); @@ -715,9 +762,7 @@ CanvasXYGrid::newSpecificWidget() Inkscape::UI::Widget::RegisteredSuffixedInteger *_rsi = Gtk::manage( new Inkscape::UI::Widget::RegisteredSuffixedInteger( _("_Major grid line every:"), "", _("lines"), "empspacing", _wr, repr, doc) ); - table->set_spacings(2); - -_wr.setUpdating (true); + _wr.setUpdating (true); _rsu_ox->setDigits(5); _rsu_ox->setIncrements(0.1, 1.0); diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index 4e2c5b9e4..28f556e75 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -19,12 +19,16 @@ # include "config.h" #endif - #include <glibmm/i18n.h> #include <gtkmm/box.h> #include <gtkmm/label.h> #include <gtkmm/frame.h> -#include <gtkmm/table.h> + +#if WITH_GTKMM_3_0 +# include <gtkmm/grid.h> +#else +# include <gtkmm/table.h> +#endif #include "inkscape.h" #include "extension/implementation/implementation.h" @@ -720,7 +724,12 @@ Extension::get_info_widget(void) Gtk::Frame * info = Gtk::manage(new Gtk::Frame("General Extension Information")); retval->pack_start(*info, true, true, 5); +#if WITH_GTKMM_3_0 + Gtk::Grid * table = Gtk::manage(new Gtk::Grid()); +#else Gtk::Table * table = Gtk::manage(new Gtk::Table()); +#endif + info->add(*table); int row = 0; @@ -733,8 +742,11 @@ Extension::get_info_widget(void) return retval; } -void -Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Table * table, int * row) +#if WITH_GTKMM_3_0 +void Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Grid * table, int * row) +#else +void Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Table * table, int * row) +#endif { Gtk::Label * label; Gtk::Label * value; @@ -742,8 +754,14 @@ Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Table * (*row)++; label = Gtk::manage(new Gtk::Label(labelstr)); value = Gtk::manage(new Gtk::Label(valuestr)); + +#if WITH_GTKMM_3_0 + table->attach(*label, 0, (*row) - 1, 1, 1); + table->attach(*value, 1, (*row) - 1, 1, 1); +#else table->attach(*label, 0, 1, (*row) - 1, *row); table->attach(*value, 1, 2, (*row) - 1, *row); +#endif label->show(); value->show(); diff --git a/src/extension/extension.h b/src/extension/extension.h index 78999631a..dcabb3df7 100644 --- a/src/extension/extension.h +++ b/src/extension/extension.h @@ -22,7 +22,12 @@ #include <sigc++/signal.h> namespace Gtk { +#if WITH_GTKMM_3_0 + class Grid; +#else class Table; +#endif + class VBox; class Widget; } @@ -285,8 +290,11 @@ public: Gtk::VBox * get_help_widget(void); Gtk::VBox * get_params_widget(void); protected: +#if WITH_GTKMM_3_0 + inline static void add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Grid * table, int * row); +#else inline static void add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Table * table, int * row); - +#endif }; diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index a38a93fb1..2bfc7e0df 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -54,6 +54,17 @@ Dock::Dock(Gtk::Orientation orientation) { gdl_dock_bar_set_orientation(_gdl_dock_bar, static_cast<GtkOrientation>(orientation)); +#if WITH_GTKMM_3_0 + switch(orientation) { + case Gtk::ORIENTATION_VERTICAL: + _dock_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); + break; + case Gtk::ORIENTATION_HORIZONTAL: + _dock_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); + } + + _paned = Gtk::manage(new Gtk::Paned(orientation)); +#else switch (orientation) { case Gtk::ORIENTATION_VERTICAL: _dock_box = Gtk::manage(new Gtk::HBox()); @@ -63,6 +74,7 @@ Dock::Dock(Gtk::Orientation orientation) _dock_box = Gtk::manage(new Gtk::VBox()); _paned = Gtk::manage(new Gtk::HPaned()); } +#endif _scrolled_window->add(*_dock_box); _scrolled_window->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); |
