From 3c82e8251460b21c8046a418a9fefb700db0a164 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 4 Jun 2013 01:52:40 -0700 Subject: Correct to compile against recent gtkmm, including updated macports versions. Fixes bug #1179338. Fixed bugs: - https://launchpad.net/bugs/1179338 (bzr r12346.1.1) --- src/widgets/dash-selector.h | 2 ++ src/widgets/desktop-widget.h | 1 + src/widgets/fill-style.cpp | 2 ++ src/widgets/gradient-selector.h | 2 ++ src/widgets/gradient-vector.h | 2 ++ src/widgets/icon.cpp | 2 ++ src/widgets/icon.h | 1 + src/widgets/paint-selector.cpp | 1 + src/widgets/shrink-wrap-button.cpp | 2 ++ src/widgets/sp-attribute-widget.h | 2 ++ src/widgets/spw-utilities.cpp | 2 ++ src/widgets/stroke-marker-selector.h | 2 ++ src/widgets/swatch-selector.h | 2 ++ src/widgets/toolbox.cpp | 2 ++ 14 files changed, 25 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/dash-selector.h b/src/widgets/dash-selector.h index 0a572f4de..d3eab643a 100644 --- a/src/widgets/dash-selector.h +++ b/src/widgets/dash-selector.h @@ -10,6 +10,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include + #include #include #include diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 9188838b3..8e828ca94 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -12,6 +12,7 @@ * ? -2004 */ +#include #include #include "message.h" #include "ui/view/view-widget.h" diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index 60e115f54..6882e263e 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -22,6 +22,8 @@ # include "config.h" #endif +#include + #include #include diff --git a/src/widgets/gradient-selector.h b/src/widgets/gradient-selector.h index ea83ff819..2bca6a64f 100644 --- a/src/widgets/gradient-selector.h +++ b/src/widgets/gradient-selector.h @@ -15,6 +15,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include + #include #include diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h index 463d77912..9e3792c06 100644 --- a/src/widgets/gradient-vector.h +++ b/src/widgets/gradient-vector.h @@ -15,6 +15,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include + #include #include diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 7580d9602..c661ae41c 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -16,6 +16,8 @@ # include "config.h" #endif +#include + #include #include #include diff --git a/src/widgets/icon.h b/src/widgets/icon.h index 6bce2e330..3c4d91748 100644 --- a/src/widgets/icon.h +++ b/src/widgets/icon.h @@ -14,6 +14,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include #include #include "icon-size.h" diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 08058d60d..9084188b1 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -24,6 +24,7 @@ #include #include +#include #include "widgets/swatch-selector.h" #include "../sp-pattern.h" diff --git a/src/widgets/shrink-wrap-button.cpp b/src/widgets/shrink-wrap-button.cpp index 941a0466c..fed792adb 100644 --- a/src/widgets/shrink-wrap-button.cpp +++ b/src/widgets/shrink-wrap-button.cpp @@ -13,6 +13,8 @@ #include "config.h" #endif +#include + #include #include diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index d9b972201..a48d2643d 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -19,6 +19,8 @@ # include "config.h" #endif +#include + #include #include #include diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index 7fca56f56..c1a54c1ed 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -17,6 +17,8 @@ #include #include +#include + #include #include diff --git a/src/widgets/stroke-marker-selector.h b/src/widgets/stroke-marker-selector.h index 02038ea42..d855fab06 100644 --- a/src/widgets/stroke-marker-selector.h +++ b/src/widgets/stroke-marker-selector.h @@ -10,6 +10,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include + #include #include #include diff --git a/src/widgets/swatch-selector.h b/src/widgets/swatch-selector.h index 4b7aa483f..c2fd1255c 100644 --- a/src/widgets/swatch-selector.h +++ b/src/widgets/swatch-selector.h @@ -1,6 +1,8 @@ #ifndef SEEN_SP_SWATCH_SELECTOR_H #define SEEN_SP_SWATCH_SELECTOR_H +#include + #include class SPDocument; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index f03835e17..92fe8a1ff 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -29,6 +29,8 @@ # include "config.h" #endif +#include + #include #include #include -- cgit v1.2.3 From 72d8e897c6b67e46b2a613c4743ef9c13de25059 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 6 Jun 2013 06:44:11 -0700 Subject: Added configure/ifdef guards to only bring in the needed #include if glibmm has it. (bzr r12353) --- src/widgets/dash-selector.h | 2 ++ src/widgets/desktop-widget.h | 3 +++ src/widgets/fill-style.cpp | 2 ++ src/widgets/gradient-selector.h | 2 ++ src/widgets/gradient-vector.h | 2 ++ src/widgets/icon.cpp | 2 ++ src/widgets/icon.h | 3 +++ src/widgets/paint-selector.cpp | 2 ++ src/widgets/shrink-wrap-button.cpp | 2 ++ src/widgets/sp-attribute-widget.h | 2 ++ src/widgets/spw-utilities.cpp | 2 ++ src/widgets/stroke-marker-selector.h | 2 ++ src/widgets/swatch-selector.h | 2 ++ src/widgets/toolbox.cpp | 2 ++ 14 files changed, 30 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/dash-selector.h b/src/widgets/dash-selector.h index d3eab643a..4004d4089 100644 --- a/src/widgets/dash-selector.h +++ b/src/widgets/dash-selector.h @@ -10,7 +10,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include +#endif #include #include diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 8e828ca94..a93852803 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -12,7 +12,10 @@ * ? -2004 */ +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include +#endif + #include #include "message.h" #include "ui/view/view-widget.h" diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index 6882e263e..d9d62d3ec 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -22,7 +22,9 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include +#endif #include #include diff --git a/src/widgets/gradient-selector.h b/src/widgets/gradient-selector.h index 2bca6a64f..a5a9dcfc2 100644 --- a/src/widgets/gradient-selector.h +++ b/src/widgets/gradient-selector.h @@ -15,7 +15,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include +#endif #include #include diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h index 9e3792c06..e90dc9af3 100644 --- a/src/widgets/gradient-vector.h +++ b/src/widgets/gradient-vector.h @@ -15,7 +15,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include +#endif #include diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index c661ae41c..d613ca55d 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -16,7 +16,9 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include +#endif #include #include diff --git a/src/widgets/icon.h b/src/widgets/icon.h index 3c4d91748..123809a41 100644 --- a/src/widgets/icon.h +++ b/src/widgets/icon.h @@ -14,7 +14,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include +#endif + #include #include "icon-size.h" diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 9084188b1..40d2fb9f3 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -24,7 +24,9 @@ #include #include +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include +#endif #include "widgets/swatch-selector.h" #include "../sp-pattern.h" diff --git a/src/widgets/shrink-wrap-button.cpp b/src/widgets/shrink-wrap-button.cpp index fed792adb..3558780ed 100644 --- a/src/widgets/shrink-wrap-button.cpp +++ b/src/widgets/shrink-wrap-button.cpp @@ -13,7 +13,9 @@ #include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include +#endif #include #include diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index a48d2643d..4bd6c6959 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -19,7 +19,9 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include +#endif #include #include diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index c1a54c1ed..87ca80f2f 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -17,7 +17,9 @@ #include #include +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include +#endif #include #include diff --git a/src/widgets/stroke-marker-selector.h b/src/widgets/stroke-marker-selector.h index d855fab06..6f5ee56c4 100644 --- a/src/widgets/stroke-marker-selector.h +++ b/src/widgets/stroke-marker-selector.h @@ -10,7 +10,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include +#endif #include #include diff --git a/src/widgets/swatch-selector.h b/src/widgets/swatch-selector.h index c2fd1255c..45015593c 100644 --- a/src/widgets/swatch-selector.h +++ b/src/widgets/swatch-selector.h @@ -1,7 +1,9 @@ #ifndef SEEN_SP_SWATCH_SELECTOR_H #define SEEN_SP_SWATCH_SELECTOR_H +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include +#endif #include diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 92fe8a1ff..0fdf36d5f 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -29,7 +29,9 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include +#endif #include #include -- cgit v1.2.3 From 07dcea8f0ee2631331ed3475c9fc38db3e6df16f Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 6 Jun 2013 20:18:19 -0700 Subject: Adding inclusion of config.h where needed for threads.h check. (bzr r12355) --- src/widgets/dash-selector.h | 4 ++++ src/widgets/desktop-widget.h | 4 ++++ src/widgets/gradient-selector.h | 4 ++++ src/widgets/gradient-vector.h | 4 ++++ src/widgets/icon.h | 4 ++++ src/widgets/stroke-marker-selector.h | 4 ++++ src/widgets/swatch-selector.h | 4 ++++ 7 files changed, 28 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/dash-selector.h b/src/widgets/dash-selector.h index 4004d4089..faa667ac7 100644 --- a/src/widgets/dash-selector.h +++ b/src/widgets/dash-selector.h @@ -10,6 +10,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include +#endif + #if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include #endif diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index a93852803..9031ac854 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -12,6 +12,10 @@ * ? -2004 */ +#ifdef HAVE_CONFIG_H +# include +#endif + #if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include #endif diff --git a/src/widgets/gradient-selector.h b/src/widgets/gradient-selector.h index a5a9dcfc2..c88666b06 100644 --- a/src/widgets/gradient-selector.h +++ b/src/widgets/gradient-selector.h @@ -15,6 +15,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include +#endif + #if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include #endif diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h index e90dc9af3..64e40a35b 100644 --- a/src/widgets/gradient-vector.h +++ b/src/widgets/gradient-vector.h @@ -15,6 +15,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include #endif diff --git a/src/widgets/icon.h b/src/widgets/icon.h index 123809a41..87dd943c4 100644 --- a/src/widgets/icon.h +++ b/src/widgets/icon.h @@ -14,6 +14,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include #endif diff --git a/src/widgets/stroke-marker-selector.h b/src/widgets/stroke-marker-selector.h index 6f5ee56c4..d9732038e 100644 --- a/src/widgets/stroke-marker-selector.h +++ b/src/widgets/stroke-marker-selector.h @@ -10,6 +10,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include +#endif + #if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include #endif diff --git a/src/widgets/swatch-selector.h b/src/widgets/swatch-selector.h index 45015593c..c8c9983a6 100644 --- a/src/widgets/swatch-selector.h +++ b/src/widgets/swatch-selector.h @@ -1,6 +1,10 @@ #ifndef SEEN_SP_SWATCH_SELECTOR_H #define SEEN_SP_SWATCH_SELECTOR_H +#ifdef HAVE_CONFIG_H +# include +#endif + #if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include #endif -- cgit v1.2.3 From bfd18a3735059a4f308d540cd3d7d388ccb5d3ce Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Fri, 7 Jun 2013 00:52:11 -0700 Subject: Check for value in range before dereferencing. (bzr r12357) --- src/widgets/sp-color-notebook.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index f75521e2c..c709e9775 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -651,8 +651,11 @@ void ColorNotebook::_updateRgbaEntry( const SPColor& color, gfloat alpha ) void ColorNotebook::_setCurrentPage(int i) { - gtk_notebook_set_current_page (GTK_NOTEBOOK (_book), i); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(_buttons[i]), TRUE); + gtk_notebook_set_current_page(GTK_NOTEBOOK(_book), i); + + if (_buttons && _trackerList && (static_cast(i) < _trackerList->len) ) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_buttons[i]), TRUE); + } } void ColorNotebook::_buttonClicked(GtkWidget *widget, SPColorNotebook *colorbook) -- cgit v1.2.3 From c805d69e8c709f2348e1c6d9507a28ef03e22136 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Fri, 7 Jun 2013 01:10:07 -0700 Subject: C++ conversion of parallel arrays to vector of class instances. (bzr r12358) --- src/widgets/sp-color-icc-selector.cpp | 226 +++++++++++++++++++++------------- 1 file changed, 137 insertions(+), 89 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 69677257d..394b5cb28 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "../dialogs/dialog-events.h" @@ -73,9 +74,33 @@ static void sp_color_icc_selector_dispose(GObject *object); static void sp_color_icc_selector_show_all (GtkWidget *widget); static void sp_color_icc_selector_hide(GtkWidget *widget); - G_END_DECLS +/** + * Class containing the parts for a single color component's UI presence. + */ +class ComponentUI +{ +public: + ComponentUI() : + _adj(0), + _slider(0), + _btn(0), + _label(0), + _map(0) + { + } + + GtkAdjustment *_adj; // Component adjustment + GtkWidget *_slider; + GtkWidget *_btn; // spinbutton + GtkWidget *_label; // Label + guchar *_map; +}; + +/** + * Class that implements the internals of the selector. + */ class ColorICCSelectorImpl { public: @@ -109,13 +134,9 @@ public: GtkWidget* _fixupBtn; GtkWidget* _profileSel; - guint _fooCount; std::vector _fooScales; - GtkAdjustment** _fooAdj; - GtkWidget** _fooSlider; - GtkWidget** _fooBtn; - GtkWidget** _fooLabel; - guchar** _fooMap; + + std::vector _compUI; GtkAdjustment* _adj; // Channel adjustment GtkWidget* _slider; @@ -136,7 +157,23 @@ static SPColorSelectorClass *parent_class; #define XPAD 4 #define YPAD 1 -GType sp_color_icc_selector_get_type (void) +namespace +{ + +size_t maxColorspaceComponentCount = 0; + +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + +/** + * Internal variable to track all known colorspaces. + */ +std::set knownColorspaces; + +#endif + +} // namespace + +GType sp_color_icc_selector_get_type(void) { static GType type = 0; if (!type) { @@ -275,6 +312,12 @@ std::vector colorspace::getColorSpaceInfo( uint32_t space sets[cmsSigCmyData].push_back(Component(_("_C:"), _("Cyan"), 1)); // TYPE_CMY_16 sets[cmsSigCmyData].push_back(Component(_("_M:"), _("Magenta"), 1)); sets[cmsSigCmyData].push_back(Component(_("_Y:"), _("Yellow"), 1)); + + for (std::map >::iterator it = sets.begin(); it != sets.end(); ++it) + { + knownColorspaces.insert(it->first); + maxColorspaceComponentCount = std::max(maxColorspaceComponentCount, it->second.size()); + } } std::vector target; @@ -301,12 +344,8 @@ ColorICCSelectorImpl::ColorICCSelectorImpl(ColorICCSelector *owner) : _fixupNeeded(0), _fixupBtn(0), _profileSel(0), - _fooCount(4), - _fooAdj(new GtkAdjustment*[_fooCount]), - _fooSlider(new GtkWidget*[_fooCount]), - _fooBtn(new GtkWidget*[_fooCount]), - _fooLabel(new GtkWidget*[_fooCount]), - _fooMap(new guchar*[_fooCount]), + _fooScales(), + _compUI(), _adj(0), _slider(0), _sbtn(0), @@ -353,6 +392,7 @@ void ColorICCSelector::init() _impl->_fooScales.push_back(it->scale); } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + _impl->_compUI.clear(); // Create components row = 0; @@ -409,24 +449,32 @@ void ColorICCSelector::init() row++; - for ( guint i = 0; i < _impl->_fooCount; i++ ) { + // populate the data for colorspaces and channels: +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + colorspace::getColorSpaceInfo(cmsSigCmykData); +#endif + + for ( size_t i = 0; i < maxColorspaceComponentCount; i++ ) { + _impl->_compUI.push_back(ComponentUI()); + // Label #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - _impl->_fooLabel[i] = gtk_label_new_with_mnemonic( (i < things.size()) ? things[i].name.c_str() : "" ); + std::string labelStr = (i < things.size()) ? things[i].name.c_str() : ""; #else - _impl->_fooLabel[i] = gtk_label_new_with_mnemonic( "." ); + std::string labelStr = "."; #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gtk_misc_set_alignment( GTK_MISC (_impl->_fooLabel[i]), 1.0, 0.5 ); - gtk_widget_show( _impl->_fooLabel[i] ); + _impl->_compUI[i]._label = gtk_label_new_with_mnemonic( labelStr.c_str() ); + gtk_misc_set_alignment( GTK_MISC (_impl->_compUI[i]._label), 1.0, 0.5 ); + gtk_widget_show( _impl->_compUI[i]._label ); #if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_impl->_fooLabel[i], XPAD); - gtk_widget_set_margin_right(_impl->_fooLabel[i], XPAD); - gtk_widget_set_margin_top(_impl->_fooLabel[i], YPAD); - gtk_widget_set_margin_bottom(_impl->_fooLabel[i], YPAD); - gtk_grid_attach(GTK_GRID(t), _impl->_fooLabel[i], 0, row, 1, 1); + gtk_widget_set_margin_left(_impl->_compUI[i]._label, XPAD); + gtk_widget_set_margin_right(_impl->_compUI[i]._label, XPAD); + gtk_widget_set_margin_top(_impl->_compUI[i]._label, YPAD); + gtk_widget_set_margin_bottom(_impl->_compUI[i]._label, YPAD); + gtk_grid_attach(GTK_GRID(t), _impl->_compUI[i]._label, 0, row, 1, 1); #else - gtk_table_attach( GTK_TABLE (t), _impl->_fooLabel[i], 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); + gtk_table_attach( GTK_TABLE (t), _impl->_compUI[i]._label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); #endif // Adjustment @@ -434,60 +482,60 @@ void ColorICCSelector::init() gdouble step = static_cast(scaleValue) / 100.0; gdouble page = static_cast(scaleValue) / 10.0; gint digits = (step > 0.9) ? 0 : 2; - _impl->_fooAdj[i] = GTK_ADJUSTMENT( gtk_adjustment_new( 0.0, 0.0, scaleValue, step, page, page ) ); + _impl->_compUI[i]._adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0.0, 0.0, scaleValue, step, page, page ) ); // Slider - _impl->_fooSlider[i] = sp_color_slider_new( _impl->_fooAdj[i] ); + _impl->_compUI[i]._slider = sp_color_slider_new( _impl->_compUI[i]._adj ); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gtk_widget_set_tooltip_text( _impl->_fooSlider[i], (i < things.size()) ? things[i].tip.c_str() : "" ); + gtk_widget_set_tooltip_text( _impl->_compUI[i]._slider, (i < things.size()) ? things[i].tip.c_str() : "" ); #else - gtk_widget_set_tooltip_text( _impl->_fooSlider[i], "." ); + gtk_widget_set_tooltip_text( _impl->_compUI[i]._slider, "." ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gtk_widget_show( _impl->_fooSlider[i] ); + gtk_widget_show( _impl->_compUI[i]._slider ); #if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_impl->_fooSlider[i], XPAD); - gtk_widget_set_margin_right(_impl->_fooSlider[i], XPAD); - gtk_widget_set_margin_top(_impl->_fooSlider[i], YPAD); - gtk_widget_set_margin_bottom(_impl->_fooSlider[i], YPAD); - gtk_widget_set_hexpand(_impl->_fooSlider[i], TRUE); - gtk_grid_attach(GTK_GRID(t), _impl->_fooSlider[i], 1, row, 1, 1); + gtk_widget_set_margin_left(_impl->_compUI[i]._slider, XPAD); + gtk_widget_set_margin_right(_impl->_compUI[i]._slider, XPAD); + gtk_widget_set_margin_top(_impl->_compUI[i]._slider, YPAD); + gtk_widget_set_margin_bottom(_impl->_compUI[i]._slider, YPAD); + gtk_widget_set_hexpand(_impl->_compUI[i]._slider, TRUE); + gtk_grid_attach(GTK_GRID(t), _impl->_compUI[i]._slider, 1, row, 1, 1); #else - gtk_table_attach( GTK_TABLE (t), _impl->_fooSlider[i], 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD ); + gtk_table_attach( GTK_TABLE (t), _impl->_compUI[i]._slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD ); #endif - _impl->_fooBtn[i] = gtk_spin_button_new( _impl->_fooAdj[i], step, digits ); + _impl->_compUI[i]._btn = gtk_spin_button_new( _impl->_compUI[i]._adj, step, digits ); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gtk_widget_set_tooltip_text( _impl->_fooBtn[i], (i < things.size()) ? things[i].tip.c_str() : "" ); + gtk_widget_set_tooltip_text( _impl->_compUI[i]._btn, (i < things.size()) ? things[i].tip.c_str() : "" ); #else - gtk_widget_set_tooltip_text( _impl->_fooBtn[i], "." ); + gtk_widget_set_tooltip_text( _impl->_compUI[i]._btn, "." ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - sp_dialog_defocus_on_enter( _impl->_fooBtn[i] ); - gtk_label_set_mnemonic_widget( GTK_LABEL(_impl->_fooLabel[i]), _impl->_fooBtn[i] ); - gtk_widget_show( _impl->_fooBtn[i] ); + sp_dialog_defocus_on_enter( _impl->_compUI[i]._btn ); + gtk_label_set_mnemonic_widget( GTK_LABEL(_impl->_compUI[i]._label), _impl->_compUI[i]._btn ); + gtk_widget_show( _impl->_compUI[i]._btn ); #if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_impl->_fooBtn[i], XPAD); - gtk_widget_set_margin_right(_impl->_fooBtn[i], XPAD); - gtk_widget_set_margin_top(_impl->_fooBtn[i], YPAD); - gtk_widget_set_margin_bottom(_impl->_fooBtn[i], YPAD); - gtk_widget_set_halign(_impl->_fooBtn[i], GTK_ALIGN_CENTER); - gtk_widget_set_valign(_impl->_fooBtn[i], GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(t), _impl->_fooBtn[i], 2, row, 1, 1); + gtk_widget_set_margin_left(_impl->_compUI[i]._btn, XPAD); + gtk_widget_set_margin_right(_impl->_compUI[i]._btn, XPAD); + gtk_widget_set_margin_top(_impl->_compUI[i]._btn, YPAD); + gtk_widget_set_margin_bottom(_impl->_compUI[i]._btn, YPAD); + gtk_widget_set_halign(_impl->_compUI[i]._btn, GTK_ALIGN_CENTER); + gtk_widget_set_valign(_impl->_compUI[i]._btn, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(t), _impl->_compUI[i]._btn, 2, row, 1, 1); #else - gtk_table_attach( GTK_TABLE (t), _impl->_fooBtn[i], 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD ); + gtk_table_attach( GTK_TABLE (t), _impl->_compUI[i]._btn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD ); #endif - _impl->_fooMap[i] = g_new( guchar, 4 * 1024 ); - memset( _impl->_fooMap[i], 0x0ff, 1024 * 4 ); + _impl->_compUI[i]._map = g_new( guchar, 4 * 1024 ); + memset( _impl->_compUI[i]._map, 0x0ff, 1024 * 4 ); // Signals - g_signal_connect( G_OBJECT( _impl->_fooAdj[i] ), "value_changed", G_CALLBACK( ColorICCSelectorImpl::_adjustmentChanged ), _csel ); + g_signal_connect( G_OBJECT( _impl->_compUI[i]._adj ), "value_changed", G_CALLBACK( ColorICCSelectorImpl::_adjustmentChanged ), _csel ); - g_signal_connect( G_OBJECT( _impl->_fooSlider[i] ), "grabbed", G_CALLBACK( ColorICCSelectorImpl::_sliderGrabbed ), _csel ); - g_signal_connect( G_OBJECT( _impl->_fooSlider[i] ), "released", G_CALLBACK( ColorICCSelectorImpl::_sliderReleased ), _csel ); - g_signal_connect( G_OBJECT( _impl->_fooSlider[i] ), "changed", G_CALLBACK( ColorICCSelectorImpl::_sliderChanged ), _csel ); + g_signal_connect( G_OBJECT( _impl->_compUI[i]._slider ), "grabbed", G_CALLBACK( ColorICCSelectorImpl::_sliderGrabbed ), _csel ); + g_signal_connect( G_OBJECT( _impl->_compUI[i]._slider ), "released", G_CALLBACK( ColorICCSelectorImpl::_sliderReleased ), _csel ); + g_signal_connect( G_OBJECT( _impl->_compUI[i]._slider ), "changed", G_CALLBACK( ColorICCSelectorImpl::_sliderChanged ), _csel ); row++; } @@ -592,7 +640,7 @@ void ColorICCSelectorImpl::_fixupHit( GtkWidget* /*src*/, gpointer data ) { ColorICCSelectorImpl* self = reinterpret_cast(data); gtk_widget_set_sensitive( self->_fixupBtn, FALSE ); - self->_adjustmentChanged( self->_fooAdj[0], SP_COLOR_ICC_SELECTOR(self->_owner->_csel) ); + self->_adjustmentChanged( self->_compUI[0]._adj, SP_COLOR_ICC_SELECTOR(self->_owner->_csel) ); } #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -704,7 +752,7 @@ void ColorICCSelectorImpl::_switchToProfile( gchar const* name ) g_message("+ new color is [%s]", tmp.toString().c_str()); #endif // DEBUG_LCMS _setProfile( tmp.icc ); - //_adjustmentChanged( _fooAdj[0], SP_COLOR_ICC_SELECTOR(_csel) ); + //_adjustmentChanged( _compUI[0]._adj, SP_COLOR_ICC_SELECTOR(_csel) ); _owner->setColorAlpha( tmp, _owner->_alpha, true ); #ifdef DEBUG_LCMS g_message("+_________________"); @@ -840,10 +888,10 @@ void ColorICCSelectorImpl::_setProfile( SVGICCColor* profile ) profChanged = true; } - for ( guint i = 0; i < _fooCount; i++ ) { - gtk_widget_hide( _fooLabel[i] ); - gtk_widget_hide( _fooSlider[i] ); - gtk_widget_hide( _fooBtn[i] ); + for ( size_t i = 0; i < _compUI.size(); i++ ) { + gtk_widget_hide( _compUI[i]._label ); + gtk_widget_hide( _compUI[i]._slider ); + gtk_widget_hide( _compUI[i]._btn ); } if ( profile ) { @@ -862,33 +910,33 @@ void ColorICCSelectorImpl::_setProfile( SVGICCColor* profile ) } if ( profChanged ) { for ( guint i = 0; i < _profChannelCount; i++ ) { - gtk_label_set_text_with_mnemonic( GTK_LABEL(_fooLabel[i]), (i < things.size()) ? things[i].name.c_str() : ""); + gtk_label_set_text_with_mnemonic( GTK_LABEL(_compUI[i]._label), (i < things.size()) ? things[i].name.c_str() : ""); - gtk_widget_set_tooltip_text( _fooSlider[i], (i < things.size()) ? things[i].tip.c_str() : "" ); - gtk_widget_set_tooltip_text( _fooBtn[i], (i < things.size()) ? things[i].tip.c_str() : "" ); + gtk_widget_set_tooltip_text( _compUI[i]._slider, (i < things.size()) ? things[i].tip.c_str() : "" ); + gtk_widget_set_tooltip_text( _compUI[i]._btn, (i < things.size()) ? things[i].tip.c_str() : "" ); - sp_color_slider_set_colors( SP_COLOR_SLIDER(_fooSlider[i]), + sp_color_slider_set_colors( SP_COLOR_SLIDER(_compUI[i]._slider), SPColor(0.0, 0.0, 0.0).toRGBA32(0xff), SPColor(0.5, 0.5, 0.5).toRGBA32(0xff), SPColor(1.0, 1.0, 1.0).toRGBA32(0xff) ); /* - _fooAdj[i] = GTK_ADJUSTMENT( gtk_adjustment_new( val, 0.0, _fooScales[i], step, page, page ) ); - g_signal_connect( G_OBJECT( _fooAdj[i] ), "value_changed", G_CALLBACK( _adjustmentChanged ), _csel ); + _compUI[i]._adj = GTK_ADJUSTMENT( gtk_adjustment_new( val, 0.0, _fooScales[i], step, page, page ) ); + g_signal_connect( G_OBJECT( _compUI[i]._adj ), "value_changed", G_CALLBACK( _adjustmentChanged ), _csel ); - sp_color_slider_set_adjustment( SP_COLOR_SLIDER(_fooSlider[i]), _fooAdj[i] ); - gtk_spin_button_set_adjustment( GTK_SPIN_BUTTON(_fooBtn[i]), _fooAdj[i] ); - gtk_spin_button_set_digits( GTK_SPIN_BUTTON(_fooBtn[i]), digits ); + sp_color_slider_set_adjustment( SP_COLOR_SLIDER(_compUI[i]._slider), _compUI[i]._adj ); + gtk_spin_button_set_adjustment( GTK_SPIN_BUTTON(_compUI[i]._btn), _compUI[i]._adj ); + gtk_spin_button_set_digits( GTK_SPIN_BUTTON(_compUI[i]._btn), digits ); */ - gtk_widget_show( _fooLabel[i] ); - gtk_widget_show( _fooSlider[i] ); - gtk_widget_show( _fooBtn[i] ); - //gtk_adjustment_set_value( _fooAdj[i], 0.0 ); - //gtk_adjustment_set_value( _fooAdj[i], val ); + gtk_widget_show( _compUI[i]._label ); + gtk_widget_show( _compUI[i]._slider ); + gtk_widget_show( _compUI[i]._btn ); + //gtk_adjustment_set_value( _compUI[i]._adj, 0.0 ); + //gtk_adjustment_set_value( _compUI[i]._adj, val ); } - for ( guint i = _profChannelCount; i < _fooCount; i++ ) { - gtk_widget_hide( _fooLabel[i] ); - gtk_widget_hide( _fooSlider[i] ); - gtk_widget_hide( _fooBtn[i] ); + for ( size_t i = _profChannelCount; i < _compUI.size(); i++ ) { + gtk_widget_hide( _compUI[i]._label ); + gtk_widget_hide( _compUI[i]._slider ); + gtk_widget_hide( _compUI[i]._btn ); } } } else { @@ -917,7 +965,7 @@ void ColorICCSelectorImpl::_updateSliders( gint ignore ) val = _owner->_color.icc->colors[i] / static_cast(_fooScales[i]); } } - gtk_adjustment_set_value( _fooAdj[i], val ); + gtk_adjustment_set_value( _compUI[i]._adj, val ); } if ( _prof ) { @@ -927,7 +975,7 @@ void ColorICCSelectorImpl::_updateSliders( gint ignore ) cmsUInt16Number* scratch = getScratch(); cmsUInt16Number filler[4] = {0, 0, 0, 0}; for ( guint j = 0; j < _profChannelCount; j++ ) { - filler[j] = 0x0ffff * ColorScales::getScaled( _fooAdj[j] ); + filler[j] = 0x0ffff * ColorScales::getScaled( _compUI[j]._adj ); } cmsUInt16Number* p = scratch; @@ -943,8 +991,8 @@ void ColorICCSelectorImpl::_updateSliders( gint ignore ) cmsHTRANSFORM trans = _prof->getTransfToSRGB8(); if ( trans ) { - cmsDoTransform( trans, scratch, _fooMap[i], 1024 ); - sp_color_slider_set_map( SP_COLOR_SLIDER(_fooSlider[i]), _fooMap[i] ); + cmsDoTransform( trans, scratch, _compUI[i]._map, 1024 ); + sp_color_slider_set_map( SP_COLOR_SLIDER(_compUI[i]._slider), _compUI[i]._map ); } } } @@ -992,8 +1040,8 @@ void ColorICCSelectorImpl::_adjustmentChanged( GtkAdjustment *adjustment, SPColo #endif // DEBUG_LCMS } else { #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - for ( guint i = 0; i < iccSelector->_impl->_fooCount; i++ ) { - if ( iccSelector->_impl->_fooAdj[i] == adjustment ) { + for ( size_t i = 0; i < iccSelector->_impl->_compUI.size(); i++ ) { + if ( iccSelector->_impl->_compUI[i]._adj == adjustment ) { match = i; break; } @@ -1007,7 +1055,7 @@ void ColorICCSelectorImpl::_adjustmentChanged( GtkAdjustment *adjustment, SPColo cmsUInt16Number tmp[4]; for ( guint i = 0; i < 4; i++ ) { - tmp[i] = ColorScales::getScaled( iccSelector->_impl->_fooAdj[i] ) * 0x0ffff; + tmp[i] = ColorScales::getScaled( iccSelector->_impl->_compUI[i]._adj ) * 0x0ffff; } guchar post[4] = {0,0,0,0}; @@ -1033,7 +1081,7 @@ void ColorICCSelectorImpl::_adjustmentChanged( GtkAdjustment *adjustment, SPColo newColor = other; newColor.icc->colors.clear(); for ( guint i = 0; i < iccSelector->_impl->_profChannelCount; i++ ) { - gdouble val = ColorScales::getScaled( iccSelector->_impl->_fooAdj[i] ); + gdouble val = ColorScales::getScaled( iccSelector->_impl->_compUI[i]._adj ); if ( i < iccSelector->_impl->_fooScales.size() ) { val *= iccSelector->_impl->_fooScales[i]; if ( iccSelector->_impl->_fooScales[i] == 256 ) { -- cgit v1.2.3 From eb4ab15680b39638f368b681ffe8bee51291d9a3 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 9 Jun 2013 02:17:19 -0700 Subject: Replace multiple copies of GTK2/GTK3 #ifdef code with single helper function. (bzr r12360) --- src/widgets/sp-color-icc-selector.cpp | 130 ++++++++++++++-------------------- 1 file changed, 52 insertions(+), 78 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 394b5cb28..e999753d4 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -171,6 +171,50 @@ std::set knownColorspaces; #endif + +/** + * Simple helper to allow bitwise or on GtkAttachOptions. + */ +GtkAttachOptions operator|(GtkAttachOptions lhs, GtkAttachOptions rhs) +{ + return static_cast(static_cast(lhs) | static_cast(rhs)); +} + +/** + * Helper function to handle GTK2/GTK3 attachment #ifdef code. + */ +void attachToGridOrTable(GtkWidget *parent, + GtkWidget *child, + guint left, + guint top, + guint width, + guint height, + bool hexpand = false, + bool centered = false, + guint xpadding = XPAD, + guint ypadding = YPAD) +{ +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left( child, xpadding ); + gtk_widget_set_margin_right( child, xpadding ); + gtk_widget_set_margin_top( child, ypadding ); + gtk_widget_set_margin_bottom( child, ypadding ); + if (hexpand) { + gtk_widget_set_hexpand(child, TRUE); + } + if (centered) { + gtk_widget_set_halign( child, GTK_ALIGN_CENTER ); + gtk_widget_set_valign( child, GTK_ALIGN_CENTER ); + } + gtk_grid_attach( GTK_GRID(parent), child, left, top, width, height ); +#else + GtkAttachOptions xoptions = centered ? static_cast(0) : hexpand ? (GTK_EXPAND | GTK_FILL) : GTK_FILL; + GtkAttachOptions yoptions = centered ? static_cast(0) : GTK_FILL; + + gtk_table_attach( GTK_TABLE(parent), child, left, left + width, top, top + height, xoptions, yoptions, xpadding, ypadding ); +#endif +} + } // namespace GType sp_color_icc_selector_get_type(void) @@ -405,15 +449,7 @@ void ColorICCSelector::init() //gtk_misc_set_alignment( GTK_MISC (_impl->_fixupBtn), 1.0, 0.5 ); gtk_widget_show( _impl->_fixupBtn ); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_impl->_fixupBtn, XPAD); - gtk_widget_set_margin_right(_impl->_fixupBtn, XPAD); - gtk_widget_set_margin_top(_impl->_fixupBtn, YPAD); - gtk_widget_set_margin_bottom(_impl->_fixupBtn, YPAD); - gtk_grid_attach(GTK_GRID(t), _impl->_fixupBtn, 0, row, 1, 1); -#else - gtk_table_attach( GTK_TABLE (t), _impl->_fixupBtn, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); -#endif + attachToGridOrTable(t, _impl->_fixupBtn, 0, row, 1, 1); // Combobox and store with 2 columns : label (0) and full name (1) GtkListStore *store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); @@ -430,15 +466,7 @@ void ColorICCSelector::init() gtk_widget_show( _impl->_profileSel ); gtk_combo_box_set_active( GTK_COMBO_BOX(_impl->_profileSel), 0 ); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_impl->_profileSel, XPAD); - gtk_widget_set_margin_right(_impl->_profileSel, XPAD); - gtk_widget_set_margin_top(_impl->_profileSel, YPAD); - gtk_widget_set_margin_bottom(_impl->_profileSel, YPAD); - gtk_grid_attach(GTK_GRID(t), _impl->_profileSel, 1, row, 1, 1); -#else - gtk_table_attach( GTK_TABLE(t), _impl->_profileSel, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); -#endif + attachToGridOrTable(t, _impl->_profileSel, 1, row, 1, 1); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) _impl->_profChangedID = g_signal_connect( G_OBJECT(_impl->_profileSel), "changed", G_CALLBACK(ColorICCSelectorImpl::_profileSelected), (gpointer)_impl ); @@ -467,15 +495,7 @@ void ColorICCSelector::init() gtk_misc_set_alignment( GTK_MISC (_impl->_compUI[i]._label), 1.0, 0.5 ); gtk_widget_show( _impl->_compUI[i]._label ); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_impl->_compUI[i]._label, XPAD); - gtk_widget_set_margin_right(_impl->_compUI[i]._label, XPAD); - gtk_widget_set_margin_top(_impl->_compUI[i]._label, YPAD); - gtk_widget_set_margin_bottom(_impl->_compUI[i]._label, YPAD); - gtk_grid_attach(GTK_GRID(t), _impl->_compUI[i]._label, 0, row, 1, 1); -#else - gtk_table_attach( GTK_TABLE (t), _impl->_compUI[i]._label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); -#endif + attachToGridOrTable(t, _impl->_compUI[i]._label, 0, row, 1, 1); // Adjustment guint scaleValue = (i < _impl->_fooScales.size()) ? _impl->_fooScales[i] : 1; @@ -493,16 +513,7 @@ void ColorICCSelector::init() #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) gtk_widget_show( _impl->_compUI[i]._slider ); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_impl->_compUI[i]._slider, XPAD); - gtk_widget_set_margin_right(_impl->_compUI[i]._slider, XPAD); - gtk_widget_set_margin_top(_impl->_compUI[i]._slider, YPAD); - gtk_widget_set_margin_bottom(_impl->_compUI[i]._slider, YPAD); - gtk_widget_set_hexpand(_impl->_compUI[i]._slider, TRUE); - gtk_grid_attach(GTK_GRID(t), _impl->_compUI[i]._slider, 1, row, 1, 1); -#else - gtk_table_attach( GTK_TABLE (t), _impl->_compUI[i]._slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD ); -#endif + attachToGridOrTable(t, _impl->_compUI[i]._slider, 1, row, 1, 1, true); _impl->_compUI[i]._btn = gtk_spin_button_new( _impl->_compUI[i]._adj, step, digits ); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -514,17 +525,7 @@ void ColorICCSelector::init() gtk_label_set_mnemonic_widget( GTK_LABEL(_impl->_compUI[i]._label), _impl->_compUI[i]._btn ); gtk_widget_show( _impl->_compUI[i]._btn ); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_impl->_compUI[i]._btn, XPAD); - gtk_widget_set_margin_right(_impl->_compUI[i]._btn, XPAD); - gtk_widget_set_margin_top(_impl->_compUI[i]._btn, YPAD); - gtk_widget_set_margin_bottom(_impl->_compUI[i]._btn, YPAD); - gtk_widget_set_halign(_impl->_compUI[i]._btn, GTK_ALIGN_CENTER); - gtk_widget_set_valign(_impl->_compUI[i]._btn, GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(t), _impl->_compUI[i]._btn, 2, row, 1, 1); -#else - gtk_table_attach( GTK_TABLE (t), _impl->_compUI[i]._btn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD ); -#endif + attachToGridOrTable(t, _impl->_compUI[i]._btn, 2, row, 1, 1, false, true); _impl->_compUI[i]._map = g_new( guchar, 4 * 1024 ); memset( _impl->_compUI[i]._map, 0x0ff, 1024 * 4 ); @@ -545,15 +546,7 @@ void ColorICCSelector::init() gtk_misc_set_alignment(GTK_MISC(_impl->_label), 1.0, 0.5); gtk_widget_show(_impl->_label); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_impl->_label, XPAD); - gtk_widget_set_margin_right(_impl->_label, XPAD); - gtk_widget_set_margin_top(_impl->_label, YPAD); - gtk_widget_set_margin_bottom(_impl->_label, YPAD); - gtk_grid_attach(GTK_GRID(t), _impl->_label, 0, row, 1, 1); -#else - gtk_table_attach(GTK_TABLE (t), _impl->_label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); -#endif + attachToGridOrTable(t, _impl->_label, 0, row, 1, 1); // Adjustment _impl->_adj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 255.0, 1.0, 10.0, 10.0)); @@ -563,16 +556,7 @@ void ColorICCSelector::init() gtk_widget_set_tooltip_text(_impl->_slider, _("Alpha (opacity)")); gtk_widget_show(_impl->_slider); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_impl->_slider, XPAD); - gtk_widget_set_margin_right(_impl->_slider, XPAD); - gtk_widget_set_margin_top(_impl->_slider, YPAD); - gtk_widget_set_margin_bottom(_impl->_slider, YPAD); - gtk_widget_set_hexpand(_impl->_slider, TRUE); - gtk_grid_attach(GTK_GRID(t), _impl->_slider, 1, row, 1, 1); -#else - gtk_table_attach (GTK_TABLE (t), _impl->_slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD); -#endif + attachToGridOrTable(t, _impl->_slider, 1, row, 1, 1, true); sp_color_slider_set_colors( SP_COLOR_SLIDER( _impl->_slider ), SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 0.0 ), @@ -587,17 +571,7 @@ void ColorICCSelector::init() gtk_label_set_mnemonic_widget(GTK_LABEL(_impl->_label), _impl->_sbtn); gtk_widget_show(_impl->_sbtn); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_impl->_sbtn, XPAD); - gtk_widget_set_margin_right(_impl->_sbtn, XPAD); - gtk_widget_set_margin_top(_impl->_sbtn, YPAD); - gtk_widget_set_margin_bottom(_impl->_sbtn, YPAD); - gtk_widget_set_halign(_impl->_sbtn, GTK_ALIGN_CENTER); - gtk_widget_set_valign(_impl->_sbtn, GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(t), _impl->_sbtn, 2, row, 1, 1); -#else - gtk_table_attach(GTK_TABLE (t), _impl->_sbtn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD); -#endif + attachToGridOrTable(t, _impl->_sbtn, 2, row, 1, 1, false, true); // Signals g_signal_connect(G_OBJECT(_impl->_adj), "value_changed", G_CALLBACK(ColorICCSelectorImpl::_adjustmentChanged), _csel); -- cgit v1.2.3 From 7fade807fba73090abe970b940f13bee962133db Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 9 Jun 2013 12:26:39 -0700 Subject: Remove use of separate array for scale values. (bzr r12361) --- src/widgets/sp-color-icc-selector.cpp | 81 ++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 34 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index e999753d4..00b00ce38 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -83,6 +83,7 @@ class ComponentUI { public: ComponentUI() : + _component(), _adj(0), _slider(0), _btn(0), @@ -91,6 +92,17 @@ public: { } + ComponentUI(colorspace::Component const &component) : + _component(component), + _adj(0), + _slider(0), + _btn(0), + _label(0), + _map(0) + { + } + + colorspace::Component _component; GtkAdjustment *_adj; // Component adjustment GtkWidget *_slider; GtkWidget *_btn; // spinbutton @@ -134,8 +146,6 @@ public: GtkWidget* _fixupBtn; GtkWidget* _profileSel; - std::vector _fooScales; - std::vector _compUI; GtkAdjustment* _adj; // Channel adjustment @@ -304,6 +314,13 @@ static cmsUInt16Number* getScratch() { return scritch; } +colorspace::Component::Component() : + name(), + tip(), + scale(1) +{ +} + colorspace::Component::Component(std::string const &name, std::string const &tip, guint scale) : name(name), tip(tip), @@ -388,7 +405,6 @@ ColorICCSelectorImpl::ColorICCSelectorImpl(ColorICCSelector *owner) : _fixupNeeded(0), _fixupBtn(0), _profileSel(0), - _fooScales(), _compUI(), _adj(0), _slider(0), @@ -428,14 +444,6 @@ void ColorICCSelector::init() gtk_widget_show (t); gtk_box_pack_start (GTK_BOX (_csel), t, TRUE, TRUE, 4); -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - //guint partCount = _cmsChannelsOf( icSigRgbData ); - std::vector things = colorspace::getColorSpaceInfo( cmsSigRgbData ); - _impl->_fooScales.clear(); - for (std::vector::iterator it = things.begin(); it != things.end(); ++it) { - _impl->_fooScales.push_back(it->scale); - } -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) _impl->_compUI.clear(); // Create components @@ -479,18 +487,24 @@ void ColorICCSelector::init() // populate the data for colorspaces and channels: #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - colorspace::getColorSpaceInfo(cmsSigCmykData); -#endif + std::vector things = colorspace::getColorSpaceInfo( cmsSigRgbData ); +#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) for ( size_t i = 0; i < maxColorspaceComponentCount; i++ ) { - _impl->_compUI.push_back(ComponentUI()); - - // Label #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + if (i < things.size()) { + _impl->_compUI.push_back(ComponentUI(things[i])); + } else { + _impl->_compUI.push_back(ComponentUI()); + } + std::string labelStr = (i < things.size()) ? things[i].name.c_str() : ""; #else + _impl->_compUI.push_back(ComponentUI()); + std::string labelStr = "."; -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif + _impl->_compUI[i]._label = gtk_label_new_with_mnemonic( labelStr.c_str() ); gtk_misc_set_alignment( GTK_MISC (_impl->_compUI[i]._label), 1.0, 0.5 ); gtk_widget_show( _impl->_compUI[i]._label ); @@ -498,7 +512,7 @@ void ColorICCSelector::init() attachToGridOrTable(t, _impl->_compUI[i]._label, 0, row, 1, 1); // Adjustment - guint scaleValue = (i < _impl->_fooScales.size()) ? _impl->_fooScales[i] : 1; + guint scaleValue = _impl->_compUI[i]._component.scale; gdouble step = static_cast(scaleValue) / 100.0; gdouble page = static_cast(scaleValue) / 10.0; gint digits = (step > 0.9) ? 0 : 2; @@ -808,10 +822,10 @@ void ColorICCSelector::_colorChanged() for ( guint i = 0; i < _impl->_profChannelCount; i++ ) { gdouble val = 0.0; if ( _color.icc->colors.size() > i ) { - if ( _impl->_fooScales[i] == 256 ) { - val = (_color.icc->colors[i] + 128.0) / static_cast(_impl->_fooScales[i]); + if ( _impl->_compUI[i]._component.scale == 256 ) { + val = (_color.icc->colors[i] + 128.0) / static_cast(_impl->_compUI[i]._component.scale); } else { - val = _color.icc->colors[i] / static_cast(_impl->_fooScales[i]); + val = _color.icc->colors[i] / static_cast(_impl->_compUI[i]._component.scale); } } tmp[i] = val * 0x0ffff; @@ -877,12 +891,13 @@ void ColorICCSelectorImpl::_setProfile( SVGICCColor* profile ) _profChannelCount = cmsChannelsOf( asICColorSpaceSig(_prof->getColorSpace()) ); #endif - std::vector things = colorspace::getColorSpaceInfo(asICColorSpaceSig(_prof->getColorSpace())); - _fooScales.clear(); - for (std::vector::iterator it = things.begin(); it != things.end(); ++it) { - _fooScales.push_back(it->scale); - } if ( profChanged ) { + std::vector things = colorspace::getColorSpaceInfo(asICColorSpaceSig(_prof->getColorSpace())); + for (size_t i = 0; (i < things.size()) && (i < _profChannelCount); ++i) + { + _compUI[i]._component = things[i]; + } + for ( guint i = 0; i < _profChannelCount; i++ ) { gtk_label_set_text_with_mnemonic( GTK_LABEL(_compUI[i]._label), (i < things.size()) ? things[i].name.c_str() : ""); @@ -933,10 +948,10 @@ void ColorICCSelectorImpl::_updateSliders( gint ignore ) for ( guint i = 0; i < _profChannelCount; i++ ) { gdouble val = 0.0; if ( _owner->_color.icc->colors.size() > i ) { - if ( _fooScales[i] == 256 ) { - val = (_owner->_color.icc->colors[i] + 128.0) / static_cast(_fooScales[i]); + if ( _compUI[i]._component.scale == 256 ) { + val = (_owner->_color.icc->colors[i] + 128.0) / static_cast(_compUI[i]._component.scale); } else { - val = _owner->_color.icc->colors[i] / static_cast(_fooScales[i]); + val = _owner->_color.icc->colors[i] / static_cast(_compUI[i]._component.scale); } } gtk_adjustment_set_value( _compUI[i]._adj, val ); @@ -1056,11 +1071,9 @@ void ColorICCSelectorImpl::_adjustmentChanged( GtkAdjustment *adjustment, SPColo newColor.icc->colors.clear(); for ( guint i = 0; i < iccSelector->_impl->_profChannelCount; i++ ) { gdouble val = ColorScales::getScaled( iccSelector->_impl->_compUI[i]._adj ); - if ( i < iccSelector->_impl->_fooScales.size() ) { - val *= iccSelector->_impl->_fooScales[i]; - if ( iccSelector->_impl->_fooScales[i] == 256 ) { - val -= 128; - } + val *= iccSelector->_impl->_compUI[i]._component.scale; + if ( iccSelector->_impl->_compUI[i]._component.scale == 256 ) { + val -= 128; } newColor.icc->colors.push_back( val ); } -- cgit v1.2.3 From 00904e48823b29873f52854d95b5c2f83b15108b Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Tue, 11 Jun 2013 11:49:46 -0400 Subject: Change marker layout in stroke-widget so they are all on one line. (bzr r12363) --- src/widgets/stroke-marker-selector.cpp | 10 --------- src/widgets/stroke-marker-selector.h | 2 -- src/widgets/stroke-style.cpp | 41 +++++++--------------------------- 3 files changed, 8 insertions(+), 45 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index 62fa47603..5ac6d5f34 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -56,10 +56,6 @@ MarkerComboBox::MarkerComboBox(gchar const *id, int l) : marker_store = Gtk::ListStore::create(marker_columns); set_model(marker_store); pack_start(image_renderer, false); - pack_end(label_renderer, true); - label_renderer.set_padding(2, 0); - image_renderer.set_padding(2, 0); - set_cell_data_func(label_renderer, sigc::mem_fun(*this, &MarkerComboBox::prepareLabelRenderer)); set_cell_data_func(image_renderer, sigc::mem_fun(*this, &MarkerComboBox::prepareImageRenderer)); gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(gobj()), MarkerComboBox::separator_cb, NULL, NULL); @@ -559,12 +555,6 @@ MarkerComboBox::create_marker_image(unsigned psize, gchar const *mname, return pb; } -void MarkerComboBox::prepareLabelRenderer( Gtk::TreeModel::const_iterator const &row ) { - Glib::ustring name=(*row)[marker_columns.label]; - label_renderer.property_markup() = name.c_str(); - label_renderer.property_scale() = 0.8; -} - void MarkerComboBox::prepareImageRenderer( Gtk::TreeModel::const_iterator const &row ) { Gtk::Image *image = (*row)[marker_columns.image]; diff --git a/src/widgets/stroke-marker-selector.h b/src/widgets/stroke-marker-selector.h index d9732038e..27ac76d6f 100644 --- a/src/widgets/stroke-marker-selector.h +++ b/src/widgets/stroke-marker-selector.h @@ -68,7 +68,6 @@ private: SPDocument *doc; SPDocument *sandbox; Gtk::Image *empty_image; - Gtk::CellRendererText label_renderer; Gtk::CellRendererPixbuf image_renderer; class MarkerColumns : public Gtk::TreeModel::ColumnRecord { @@ -99,7 +98,6 @@ private: /* * Callbacks for drawing the combo box */ - void prepareLabelRenderer( Gtk::TreeModel::const_iterator const &row ); void prepareImageRenderer( Gtk::TreeModel::const_iterator const &row ); static gboolean separator_cb (GtkTreeModel *model, GtkTreeIter *iter, gpointer data); diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index c6934f0a6..0a5b3781b 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -342,62 +342,37 @@ StrokeStyle::StrokeStyle() : // TRANSLATORS: Path markers are an SVG feature that allows you to attach arbitrary shapes // (arrowheads, bullets, faces, whatever) to the start, end, or middle nodes of a path. + spw_label(table, _("Markers:"), 0, i, NULL); + + hb = spw_hbox(table, 1, 1, i); + i++; + startMarkerCombo = manage(new MarkerComboBox("marker-start", SP_MARKER_LOC_START)); - spw_label(table, _("_Start Markers:"), 0, i, startMarkerCombo); startMarkerCombo->set_tooltip_text(_("Start Markers are drawn on the first node of a path or shape")); startMarkerConn = startMarkerCombo->signal_changed().connect( sigc::bind( 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(0), 0, 0); -#endif - - i++; + hb->pack_start(*startMarkerCombo, true, true, 0); midMarkerCombo = manage(new MarkerComboBox("marker-mid", SP_MARKER_LOC_MID)); - spw_label(table, _("_Mid Markers:"), 0, i, midMarkerCombo); midMarkerCombo->set_tooltip_text(_("Mid Markers are drawn on every node of a path or shape except the first and last nodes")); midMarkerConn = midMarkerCombo->signal_changed().connect( sigc::bind( 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(0), 0, 0); -#endif - - i++; + hb->pack_start(*midMarkerCombo, true, true, 0); endMarkerCombo = manage(new MarkerComboBox("marker-end", SP_MARKER_LOC_END)); - spw_label(table, _("_End Markers:"), 0, i, endMarkerCombo); endMarkerCombo->set_tooltip_text(_("End Markers are drawn on the last node of a path or shape")); endMarkerConn = endMarkerCombo->signal_changed().connect( sigc::bind( 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(0), 0, 0); -#endif - - i++; + hb->pack_start(*endMarkerCombo, true, true, 0); setDesktop(desktop); updateLine(); -- cgit v1.2.3 From 0dbd19748a058c88f9a693ed08ddabf223d0524d Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Tue, 11 Jun 2013 16:14:43 -0400 Subject: Fix new bug with No-Marker having no icon, use Stock GTK::Remove icon for No-Marker. (bzr r12364) --- src/widgets/stroke-marker-selector.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index 5ac6d5f34..dd00ed703 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -38,6 +38,7 @@ #include "helper/stock-items.h" #include "gradient-vector.h" +#include #include #include "ui/widget/spinbutton.h" #include "stroke-style.h" @@ -151,7 +152,8 @@ MarkerComboBox::init_combo() Gtk::TreeModel::Row row = *(marker_store->append()); row[marker_columns.label] = _("No document selected"); row[marker_columns.marker] = g_strdup("None"); - row[marker_columns.image] = NULL; + Glib::RefPtr iconTheme = Gtk::IconTheme::get_default(); + row[marker_columns.image] = new Gtk::Image( iconTheme->load_icon("gtk-remove", 22) ); row[marker_columns.stock] = false; row[marker_columns.history] = false; row[marker_columns.separator] = false; @@ -386,7 +388,8 @@ void MarkerComboBox::add_markers (GSList *marker_list, SPDocument *source, gbool row[marker_columns.label] = _("None"); row[marker_columns.stock] = false; row[marker_columns.marker] = g_strdup("None"); - row[marker_columns.image] = NULL; + Glib::RefPtr iconTheme = Gtk::IconTheme::get_default(); + row[marker_columns.image] = new Gtk::Image( iconTheme->load_icon("gtk-remove", 22) ); row[marker_columns.history] = true; row[marker_columns.separator] = false; } -- cgit v1.2.3 From 2f7a1c5a360c192e60fa25adcb8b838fd33c4d40 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Tue, 11 Jun 2013 18:55:31 -0400 Subject: Change back to using NULL and fix windows theme error by checking (bzr r12367) --- src/widgets/stroke-marker-selector.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index dd00ed703..82cd81e9f 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -60,7 +60,12 @@ MarkerComboBox::MarkerComboBox(gchar const *id, int l) : set_cell_data_func(image_renderer, sigc::mem_fun(*this, &MarkerComboBox::prepareImageRenderer)); gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(gobj()), MarkerComboBox::separator_cb, NULL, NULL); - empty_image = new Gtk::Image(); + Glib::RefPtr iconTheme = Gtk::IconTheme::get_default(); + if(iconTheme->has_icon("gtk-remove")) { + empty_image = new Gtk::Image( iconTheme->load_icon("gtk-remove", 22) ); + } else { + empty_image = new Gtk::Image(); + } sandbox = ink_markers_preview_doc (); desktop = inkscape_active_desktop(); @@ -152,8 +157,7 @@ MarkerComboBox::init_combo() Gtk::TreeModel::Row row = *(marker_store->append()); row[marker_columns.label] = _("No document selected"); row[marker_columns.marker] = g_strdup("None"); - Glib::RefPtr iconTheme = Gtk::IconTheme::get_default(); - row[marker_columns.image] = new Gtk::Image( iconTheme->load_icon("gtk-remove", 22) ); + row[marker_columns.image] = NULL; row[marker_columns.stock] = false; row[marker_columns.history] = false; row[marker_columns.separator] = false; @@ -388,8 +392,7 @@ void MarkerComboBox::add_markers (GSList *marker_list, SPDocument *source, gbool row[marker_columns.label] = _("None"); row[marker_columns.stock] = false; row[marker_columns.marker] = g_strdup("None"); - Glib::RefPtr iconTheme = Gtk::IconTheme::get_default(); - row[marker_columns.image] = new Gtk::Image( iconTheme->load_icon("gtk-remove", 22) ); + row[marker_columns.image] = NULL; row[marker_columns.history] = true; row[marker_columns.separator] = false; } -- cgit v1.2.3 From 295d11627ae7750369d72022e63c8d7ce761ef8a Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Tue, 11 Jun 2013 20:04:45 -0400 Subject: Use 'remove' instead of 'gtk-remove' for theme. Fixed bugs: - https://launchpad.net/bugs/1190072 (bzr r12369) --- src/widgets/stroke-marker-selector.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index 82cd81e9f..8e252f5e1 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -61,8 +61,8 @@ MarkerComboBox::MarkerComboBox(gchar const *id, int l) : gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(gobj()), MarkerComboBox::separator_cb, NULL, NULL); Glib::RefPtr iconTheme = Gtk::IconTheme::get_default(); - if(iconTheme->has_icon("gtk-remove")) { - empty_image = new Gtk::Image( iconTheme->load_icon("gtk-remove", 22) ); + if(iconTheme->has_icon("remove")) { + empty_image = new Gtk::Image( iconTheme->load_icon("remove", 22) ); } else { empty_image = new Gtk::Image(); } -- cgit v1.2.3 From 384c21c3bccef3a2f8f50236f87b87df29aa9e95 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 12 Jun 2013 11:14:48 -0400 Subject: Use fixed inkscape icon for 'no-marker' instead of gtk theme icon (bzr r12371) --- src/widgets/icon.cpp | 7 +++++++ src/widgets/icon.h | 2 +- src/widgets/stroke-marker-selector.cpp | 8 ++------ 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index d613ca55d..dda453bc4 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -867,6 +867,13 @@ GtkWidget *sp_icon_new( Inkscape::IconSize lsize, gchar const *name ) return IconImpl::newFull( lsize, name ); } +// PUBLIC CALL for when you REALLY need a pixbuf +GdkPixbuf *sp_pixbuf_new( Inkscape::IconSize lsize, gchar const *name ) +{ + int psize = IconImpl::getPhysSize(lsize); + return IconImpl::renderup(name, lsize, psize); +} + // PUBLIC CALL: Gtk::Widget *sp_icon_get_icon( Glib::ustring const &oid, Inkscape::IconSize size ) { diff --git a/src/widgets/icon.h b/src/widgets/icon.h index 87dd943c4..e1dae0d6a 100644 --- a/src/widgets/icon.h +++ b/src/widgets/icon.h @@ -53,7 +53,7 @@ struct SPIcon { GtkWidget *sp_icon_new( Inkscape::IconSize size, const gchar *name ); - +GdkPixbuf *sp_pixbuf_new( Inkscape::IconSize size, const gchar *name ); // Might return a wrapped SPIcon, or Gtk::Image Gtk::Widget *sp_icon_get_icon( const Glib::ustring &oid, Inkscape::IconSize size = Inkscape::ICON_SIZE_BUTTON ); diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index 8e252f5e1..2d1c932d3 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -60,12 +60,8 @@ MarkerComboBox::MarkerComboBox(gchar const *id, int l) : set_cell_data_func(image_renderer, sigc::mem_fun(*this, &MarkerComboBox::prepareImageRenderer)); gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(gobj()), MarkerComboBox::separator_cb, NULL, NULL); - Glib::RefPtr iconTheme = Gtk::IconTheme::get_default(); - if(iconTheme->has_icon("remove")) { - empty_image = new Gtk::Image( iconTheme->load_icon("remove", 22) ); - } else { - empty_image = new Gtk::Image(); - } + empty_image = new Gtk::Image( Glib::wrap( + sp_pixbuf_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("no-marker") ) ) ); sandbox = ink_markers_preview_doc (); desktop = inkscape_active_desktop(); -- cgit v1.2.3 From 61dbeecfd62c733fc3f59dfa8e767b986a08caf3 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 16 Jun 2013 08:18:48 +0900 Subject: Revert Fix for 600285 : Zoom slider (bzr r12377) --- src/widgets/desktop-widget.cpp | 20 ++++++-------------- src/widgets/widget-sizes.h | 2 +- 2 files changed, 7 insertions(+), 15 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 6c62a8f0d..1584ccde1 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -55,7 +55,6 @@ #include "ui/widget/dock.h" #include "ui/widget/layer-selector.h" #include "ui/widget/selected-style.h" -#include "ui/widget/gimpspinscale.h" #include "ui/uxmanager.h" #include "util/ege-appear-time-tracker.h" #include "sp-root.h" @@ -628,14 +627,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_box_pack_end (GTK_BOX (dtw->statusbar), statusbar_tail, FALSE, FALSE, 0); // zoom status spinbutton -#if WITH_GTKMM_3_0 - Glib::RefPtr _adjustment = Gtk::Adjustment::create(100.0, log(SP_DESKTOP_ZOOM_MIN)/log(2), log(SP_DESKTOP_ZOOM_MAX)/log(2), 0.1, 1.0); -#else - Gtk::Adjustment *_adjustment = new Gtk::Adjustment(100.0, log(SP_DESKTOP_ZOOM_MIN)/log(2), log(SP_DESKTOP_ZOOM_MAX)/log(2), 0.1, 1.0); -#endif - dtw->zoom_status = gimp_spin_scale_new (_adjustment->gobj(), _("Zoom"), 1); - - //dtw->zoom_status = gtk_spin_button_new_with_range (log(SP_DESKTOP_ZOOM_MIN)/log(2), log(SP_DESKTOP_ZOOM_MAX)/log(2), 0.1); + dtw->zoom_status = gtk_spin_button_new_with_range (log(SP_DESKTOP_ZOOM_MIN)/log(2), log(SP_DESKTOP_ZOOM_MAX)/log(2), 0.1); gtk_widget_set_tooltip_text (dtw->zoom_status, _("Zoom")); gtk_widget_set_size_request (dtw->zoom_status, STATUS_ZOOM_WIDTH, -1); gtk_entry_set_width_chars (GTK_ENTRY (dtw->zoom_status), 6); @@ -696,18 +688,18 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->coord_status_y = gtk_label_new(NULL); gtk_label_set_markup( GTK_LABEL(dtw->coord_status_y), " 0.00 " ); gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_y), 1.0, 0.5); - //GtkWidget* label_z = gtk_label_new(_("Z:")); + GtkWidget* label_z = gtk_label_new(_("Z:")); #if GTK_CHECK_VERSION(3,0,0) gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_x, 2, 0, 1, 1); gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_y, 2, 1, 1, 1); - //gtk_grid_attach(GTK_GRID(dtw->coord_status), label_z, 3, 0, 1, 2); - gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->zoom_status, 3, 0, 1, 2); + gtk_grid_attach(GTK_GRID(dtw->coord_status), label_z, 3, 0, 1, 2); + gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->zoom_status, 4, 0, 1, 2); #else gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_x, 2,3, 0,1, GTK_FILL, GTK_FILL, 0, 0); gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_y, 2,3, 1,2, GTK_FILL, GTK_FILL, 0, 0); - //gtk_table_attach(GTK_TABLE(dtw->coord_status), label_z, 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0); - gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->zoom_status, 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0); + gtk_table_attach(GTK_TABLE(dtw->coord_status), label_z, 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0); + gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->zoom_status, 4,5, 0,2, GTK_FILL, GTK_FILL, 0, 0); #endif sp_set_font_size_smaller (dtw->coord_status); diff --git a/src/widgets/widget-sizes.h b/src/widgets/widget-sizes.h index 8db036734..87c7ca2e0 100644 --- a/src/widgets/widget-sizes.h +++ b/src/widgets/widget-sizes.h @@ -27,7 +27,7 @@ #define STATUS_BAR_FONT_SIZE 10000 -#define STATUS_ZOOM_WIDTH 100 +#define STATUS_ZOOM_WIDTH 57 #define SELECTED_STYLE_SB_WIDTH 48 #define SELECTED_STYLE_WIDTH 190 -- cgit v1.2.3 From 11b8456422decef853e6bb46f4d8e16c5ce6d645 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 16 Jun 2013 09:08:17 +0900 Subject: Fix for 1184408 : Additional zoom levels in zoom context menu (bzr r12378) --- src/widgets/desktop-widget.cpp | 113 ++++++++++++++++++++++++++++------------- 1 file changed, 78 insertions(+), 35 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 1584ccde1..814298041 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -1885,6 +1885,67 @@ sp_dtw_zoom_value_changed (GtkSpinButton *spin, gpointer data) spinbutton_defocus (GTK_WIDGET(spin)); } + +static void +sp_dtw_zoom_10 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast(data), 0.1); +} + +static void +sp_dtw_zoom_25 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast(data), 0.25); +} + +static void +sp_dtw_zoom_50 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast(data), 0.5); +} + +static void +sp_dtw_zoom_100 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast(data), 1.0); +} + +static void +sp_dtw_zoom_200 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast(data), 2.0); +} + +static void +sp_dtw_zoom_500 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast(data), 5.0); +} + +static void +sp_dtw_zoom_1000 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast(data), 10.0); +} + +static void +sp_dtw_zoom_page (GtkMenuItem */*item*/, gpointer data) +{ + static_cast(data)->zoom_page(); +} + +static void +sp_dtw_zoom_drawing (GtkMenuItem */*item*/, gpointer data) +{ + static_cast(data)->zoom_drawing(); +} + +static void +sp_dtw_zoom_selection (GtkMenuItem */*item*/, gpointer data) +{ + static_cast(data)->zoom_selection(); +} + static void sp_dtw_zoom_populate_popup (GtkEntry */*entry*/, GtkMenu *menu, gpointer data) { @@ -1898,6 +1959,14 @@ sp_dtw_zoom_populate_popup (GtkEntry */*entry*/, GtkMenu *menu, gpointer data) } g_list_free (children); + item = gtk_menu_item_new_with_label ("1000%"); + g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_zoom_1000), dt); + gtk_widget_show (item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + item = gtk_menu_item_new_with_label ("500%"); + g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_zoom_500), dt); + gtk_widget_show (item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); item = gtk_menu_item_new_with_label ("200%"); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_zoom_200), dt); gtk_widget_show (item); @@ -1909,6 +1978,15 @@ sp_dtw_zoom_populate_popup (GtkEntry */*entry*/, GtkMenu *menu, gpointer data) item = gtk_menu_item_new_with_label ("50%"); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_zoom_50), dt); gtk_widget_show (item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + item = gtk_menu_item_new_with_label ("25%"); + g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_zoom_25), dt); + gtk_widget_show (item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + item = gtk_menu_item_new_with_label ("10%"); + g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_zoom_10), dt); + gtk_widget_show (item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); item = gtk_separator_menu_item_new (); @@ -1936,41 +2014,6 @@ sp_dtw_zoom_menu_handler (SPDesktop *dt, gdouble factor) dt->zoom_absolute(d.midpoint()[Geom::X], d.midpoint()[Geom::Y], factor); } -static void -sp_dtw_zoom_50 (GtkMenuItem */*item*/, gpointer data) -{ - sp_dtw_zoom_menu_handler (static_cast(data), 0.5); -} - -static void -sp_dtw_zoom_100 (GtkMenuItem */*item*/, gpointer data) -{ - sp_dtw_zoom_menu_handler (static_cast(data), 1.0); -} - -static void -sp_dtw_zoom_200 (GtkMenuItem */*item*/, gpointer data) -{ - sp_dtw_zoom_menu_handler (static_cast(data), 2.0); -} - -static void -sp_dtw_zoom_page (GtkMenuItem */*item*/, gpointer data) -{ - static_cast(data)->zoom_page(); -} - -static void -sp_dtw_zoom_drawing (GtkMenuItem */*item*/, gpointer data) -{ - static_cast(data)->zoom_drawing(); -} - -static void -sp_dtw_zoom_selection (GtkMenuItem */*item*/, gpointer data) -{ - static_cast(data)->zoom_selection(); -} static void sp_dtw_sticky_zoom_toggled (GtkMenuItem *, gpointer data) -- cgit v1.2.3 From 80174b60033b8439eb06256f7ce9a51a26c6f7ed Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 21 Jun 2013 22:44:07 +0200 Subject: cppcheck (bzr r12382) --- src/widgets/sp-color-icc-selector.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 00b00ce38..53e73dd57 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -272,7 +272,8 @@ static void sp_color_icc_selector_class_init(SPColorICCSelectorClass *klass) ColorICCSelector::ColorICCSelector( SPColorSelector* csel ) - : ColorSelector( csel ) + : ColorSelector( csel ), + _impl(NULL) { } @@ -429,7 +430,8 @@ ColorICCSelectorImpl::~ColorICCSelectorImpl() void ColorICCSelector::init() { - _impl = new ColorICCSelectorImpl(this); + if (_impl) delete(_impl); + _impl = new ColorICCSelectorImpl(this); gint row = 0; _impl->_updating = FALSE; -- cgit v1.2.3