From 16ac2bbcaba3dde76484f5161a433b39f8a31a12 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sun, 28 Apr 2013 13:06:53 +0200 Subject: minor cppcheck stuff (bzr r12307) --- src/widgets/gradient-vector.cpp | 4 +--- src/widgets/paint-selector.cpp | 6 +++--- src/widgets/sp-attribute-widget.cpp | 4 +--- src/widgets/sp-color-notebook.cpp | 4 +--- src/widgets/sp-color-slider.cpp | 7 +++---- src/widgets/spw-utilities.cpp | 3 +-- 6 files changed, 10 insertions(+), 18 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index e15f81e0f..118d8a68a 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -1001,8 +1001,6 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s GtkWidget * sp_gradient_vector_editor_new(SPGradient *gradient, SPStop *stop) { - GtkWidget *wid; - if (dlg == NULL) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1044,7 +1042,7 @@ GtkWidget * sp_gradient_vector_editor_new(SPGradient *gradient, SPStop *stop) gtk_container_set_border_width(GTK_CONTAINER(dlg), PAD); - wid = static_cast(sp_gradient_vector_widget_new(gradient, stop)); + GtkWidget *wid = static_cast(sp_gradient_vector_widget_new(gradient, stop)); g_object_set_data(G_OBJECT(dlg), "gradient-vector-widget", wid); /* Connect signals */ gtk_widget_show(wid); diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index b0738b6a6..08058d60d 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -1138,14 +1138,14 @@ static void sp_paint_selector_set_mode_swatch(SPPaintSelector *psel, SPPaintSele gtk_widget_set_sensitive(psel->style, TRUE); - SwatchSelector *swatchsel = 0; + SwatchSelector *swatchsel = NULL; if (psel->mode == SPPaintSelector::MODE_SWATCH){ - swatchsel = static_cast(g_object_get_data(G_OBJECT(psel->selector), "swatch-selector")); + // swatchsel = static_cast(g_object_get_data(G_OBJECT(psel->selector), "swatch-selector")); } else { sp_paint_selector_clear_frame(psel); // Create new gradient selector - SwatchSelector *swatchsel = new SwatchSelector(); + swatchsel = new SwatchSelector(); swatchsel->show(); swatchsel->connectGrabbedHandler( G_CALLBACK(sp_paint_selector_gradient_grabbed), psel ); diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index 1f0fcd94e..4196e62bf 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -101,14 +101,12 @@ SPAttributeTable::~SPAttributeTable () void SPAttributeTable::clear(void) { - Gtk::Widget *w; - if (table) { std::vector ch = table->get_children(); for (int i = (ch.size())-1; i >=0 ; i--) { - w = ch[i]; + Gtk::Widget *w = ch[i]; ch.pop_back(); if (w != NULL) { diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 588221a7c..89c5ed76a 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -165,9 +165,7 @@ gint ColorNotebook::menuHandler( GdkEvent* event ) static void sp_color_notebook_menuitem_response (GtkMenuItem *menuitem, gpointer user_data) { - gboolean active = FALSE; - - active = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menuitem)); + gboolean active = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menuitem)); SPColorNotebookTracker *entry = reinterpret_cast< SPColorNotebookTracker* > (user_data); if ( entry ) { diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 471ee3852..9b13ba1c5 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -729,7 +729,7 @@ sp_color_slider_render_map (gint x0, gint y0, gint width, gint height, { static guchar *buf = NULL; static gint bs = 0; - guchar *dp, *sp; + guchar *dp; gint x, y; if (buf && (bs < width * height)) { @@ -744,13 +744,12 @@ sp_color_slider_render_map (gint x0, gint y0, gint width, gint height, dp = buf; for (x = x0; x < x0 + width; x++) { gint cr, cg, cb, ca; - guchar *d; - sp = map + 4 * (start >> 16); + guchar *d = dp; + guchar *sp = map + 4 * (start >> 16); cr = *sp++; cg = *sp++; cb = *sp++; ca = *sp++; - d = dp; for (y = y0; y < y0 + height; y++) { guint bg, fc; /* Background value */ diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index ce8ce388d..7fca56f56 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -333,7 +333,6 @@ gpointer sp_search_by_data_recursive(GtkWidget *w, gpointer key) GtkWidget *sp_search_by_value_recursive(GtkWidget *w, gchar *key, gchar *value) { gchar *r = NULL; - GtkWidget *child; if (w && G_IS_OBJECT(w)) { r = (gchar *) g_object_get_data(G_OBJECT(w), key); @@ -343,7 +342,7 @@ GtkWidget *sp_search_by_value_recursive(GtkWidget *w, gchar *key, gchar *value) if (GTK_IS_CONTAINER(w)) { GList *ch = gtk_container_get_children (GTK_CONTAINER(w)); for (GList *i = ch; i != NULL; i = i->next) { - child = sp_search_by_value_recursive(GTK_WIDGET(i->data), key, value); + GtkWidget *child = sp_search_by_value_recursive(GTK_WIDGET(i->data), key, value); if (child) return child; } } -- cgit v1.2.3 From 33db29c8296508ff2fa50e619831cebf6f4d85cc Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 28 Apr 2013 11:38:55 -0700 Subject: Warning cleanup. (bzr r12309) --- src/widgets/desktop-widget.cpp | 9 ++++----- src/widgets/font-selector.cpp | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index ca76cb568..6c62a8f0d 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -315,13 +315,12 @@ sp_desktop_widget_class_init (SPDesktopWidgetClass *klass) * This adjusts the range of the rulers when the dock container is adjusted * (fixes lp:950552) */ -static void -canvas_tbl_size_allocate(GtkWidget *widget, - GdkRectangle *allocation, - gpointer data) +static void canvas_tbl_size_allocate(GtkWidget * /*widget*/, + GdkRectangle * /*allocation*/, + gpointer data) { SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(data); - sp_desktop_widget_update_rulers (dtw); + sp_desktop_widget_update_rulers(dtw); } /** diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 453ef683f..7fa848f1e 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -332,7 +332,7 @@ static void sp_font_selector_family_select_row(GtkTreeSelection *selection, } // Callback when row changed -static void sp_font_selector_style_select_row (GtkTreeSelection *selection, +static void sp_font_selector_style_select_row (GtkTreeSelection * /*selection*/, SPFontSelector *fsel) { if (!fsel->block_emit) -- cgit v1.2.3 From c317c1f79519f0ee961842ffb9feac4494af5377 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 28 Apr 2013 17:51:29 -0700 Subject: Fixed logic error confusing bitwise and with logical and. Whitespace cleanup to make the issue easier to spot. (bzr r12311) --- src/widgets/sp-attribute-widget.cpp | 4 ++-- src/widgets/sp-color-notebook.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index 4196e62bf..fb7eb1420 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -259,7 +259,7 @@ static void sp_attribute_table_object_modified ( SPObject */*object*/, guint flags, SPAttributeTable *spat ) { - if (flags && SP_OBJECT_MODIFIED_FLAG) + if (flags & SP_OBJECT_MODIFIED_FLAG) { std::vector attributes = spat->get_attributes(); std::vector entries = spat->get_entries(); @@ -270,7 +270,7 @@ static void sp_attribute_table_object_modified ( SPObject */*object*/, text = e->get_text (); if (val || !text.empty()) { if (text != val) { - /* We are different */ + // We are different spat->blocked = true; e->set_text (val ? val : (const gchar *) ""); spat->blocked = false; diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 89c5ed76a..f75521e2c 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -129,7 +129,7 @@ void ColorNotebook::switchPage(GtkNotebook*, csel->base->getColorAlpha(_color, _alpha); } widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (_book), page_num); - if ( widget && SP_IS_COLOR_SELECTOR (widget) ) + if ( widget && SP_IS_COLOR_SELECTOR(widget) ) { csel = SP_COLOR_SELECTOR (widget); csel->base->setColorAlpha( _color, _alpha ); @@ -232,7 +232,7 @@ void ColorNotebook::init() { guint howmany = 1; gpointer klass = g_type_class_ref (selector_types[i]); - if ( klass && SP_IS_COLOR_SELECTOR_CLASS (klass) ) + if ( klass && SP_IS_COLOR_SELECTOR_CLASS(klass) ) { SPColorSelectorClass *ck = SP_COLOR_SELECTOR_CLASS (klass); howmany = MAX (1, ck->submode_count); -- cgit v1.2.3 From 36ff3c99e291af9ca9ba05099282c4afb143f8f4 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 12 May 2013 22:49:17 -0700 Subject: Moved icc selector members to internal helper. (bzr r12332) --- src/widgets/sp-color-icc-selector.cpp | 532 +++++++++++++++++++--------------- src/widgets/sp-color-icc-selector.h | 62 +--- 2 files changed, 306 insertions(+), 288 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index ce9323311..08cd7264f 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -9,6 +9,7 @@ #include "../dialogs/dialog-events.h" #include "sp-color-icc-selector.h" #include "sp-color-scales.h" +#include "sp-color-slider.h" #include "svg/svg-icc-color.h" #include "document.h" #include "inkscape.h" @@ -71,27 +72,81 @@ static void sp_color_icc_selector_hide(GtkWidget *widget); G_END_DECLS +class ColorICCSelectorImpl +{ +public: + + ColorICCSelectorImpl( ColorICCSelector *owner); + + ~ColorICCSelectorImpl(); + + static void _adjustmentChanged ( GtkAdjustment *adjustment, SPColorICCSelector *cs ); + + static void _sliderGrabbed( SPColorSlider *slider, SPColorICCSelector *cs ); + static void _sliderReleased( SPColorSlider *slider, SPColorICCSelector *cs ); + static void _sliderChanged( SPColorSlider *slider, SPColorICCSelector *cs ); + + static void _profileSelected( GtkWidget* src, gpointer data ); + static void _fixupHit( GtkWidget* src, gpointer data ); + +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + void _setProfile( SVGICCColor* profile ); + void _switchToProfile( gchar const* name ); +#endif + void _updateSliders( gint ignore ); + void _profilesChanged( std::string const & name ); + + ColorICCSelector *_owner; + + gboolean _updating : 1; + gboolean _dragging : 1; + + guint32 _fixupNeeded; + GtkWidget* _fixupBtn; + GtkWidget* _profileSel; + + guint _fooCount; + guint const* _fooScales; + GtkAdjustment** _fooAdj; + GtkWidget** _fooSlider; + GtkWidget** _fooBtn; + GtkWidget** _fooLabel; + guchar** _fooMap; + + GtkAdjustment* _adj; // Channel adjustment + GtkWidget* _slider; + GtkWidget* _sbtn; // Spinbutton + GtkWidget* _label; // Label + +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + std::string _profileName; + Inkscape::ColorProfile* _prof; + guint _profChannelCount; + gulong _profChangedID; +#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +}; + + static SPColorSelectorClass *parent_class; #define XPAD 4 #define YPAD 1 -GType -sp_color_icc_selector_get_type (void) +GType sp_color_icc_selector_get_type (void) { static GType type = 0; if (!type) { static const GTypeInfo info = { sizeof (SPColorICCSelectorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ + NULL, // base_init + NULL, // base_finalize (GClassInitFunc) sp_color_icc_selector_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ + NULL, // class_finalize + NULL, // class_data sizeof (SPColorICCSelector), - 0, /* n_preallocs */ + 0, // n_preallocs (GInstanceInitFunc) sp_color_icc_selector_init, - 0, /* value_table */ + 0, // value_table }; type = g_type_register_static (SP_TYPE_COLOR_SELECTOR, @@ -122,41 +177,20 @@ static void sp_color_icc_selector_class_init(SPColorICCSelectorClass *klass) ColorICCSelector::ColorICCSelector( SPColorSelector* csel ) - : ColorSelector( csel ), - _updating( FALSE ), - _dragging( FALSE ), - _fixupNeeded(0), - _fixupBtn(0), - _profileSel(0), - _fooCount(0), - _fooScales(0), - _fooAdj(0), - _fooSlider(0), - _fooBtn(0), - _fooLabel(0), - _fooMap(0), - _adj(0), - _slider(0), - _sbtn(0), - _label(0) -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - , - _profileName(""), - _prof(), - _profChannelCount(0), - _profChangedID(0) -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + : ColorSelector( csel ) { } ColorICCSelector::~ColorICCSelector() { - _adj = 0; - _sbtn = 0; - _label = 0; + if (_impl) + { + delete _impl; + _impl = 0; + } } -void sp_color_icc_selector_init (SPColorICCSelector *cs) +void sp_color_icc_selector_init(SPColorICCSelector *cs) { SP_COLOR_SELECTOR(cs)->base = new ColorICCSelector( SP_COLOR_SELECTOR(cs) ); @@ -267,13 +301,47 @@ void getThings( Inkscape::ColorProfile *prof, gchar const**& namers, gchar const #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +ColorICCSelectorImpl::ColorICCSelectorImpl(ColorICCSelector *owner) : + _owner(owner), + _updating( FALSE ), + _dragging( FALSE ), + _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]), + _adj(0), + _slider(0), + _sbtn(0), + _label(0) +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + , + _profileName(), + _prof(0), + _profChannelCount(0), + _profChangedID(0) +#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +{ +} + +ColorICCSelectorImpl::~ColorICCSelectorImpl() +{ + _adj = 0; + _sbtn = 0; + _label = 0; +} void ColorICCSelector::init() { + _impl = new ColorICCSelectorImpl(this); gint row = 0; - _updating = FALSE; - _dragging = FALSE; + _impl->_updating = FALSE; + _impl->_dragging = FALSE; #if GTK_CHECK_VERSION(3,0,0) GtkWidget *t = gtk_grid_new(); @@ -288,228 +356,218 @@ void ColorICCSelector::init() //guint partCount = _cmsChannelsOf( icSigRgbData ); gchar const** names = 0; gchar const** tips = 0; - getThings( cmsSigRgbData, names, tips, _fooScales ); + getThings( cmsSigRgbData, names, tips, _impl->_fooScales ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - /* Create components */ + // Create components row = 0; - _fixupBtn = gtk_button_new_with_label(_("Fix")); - g_signal_connect( G_OBJECT(_fixupBtn), "clicked", G_CALLBACK(_fixupHit), (gpointer)this ); - gtk_widget_set_sensitive( _fixupBtn, FALSE ); - gtk_widget_set_tooltip_text( _fixupBtn, _("Fix RGB fallback to match icc-color() value.") ); - //gtk_misc_set_alignment( GTK_MISC (_fixupBtn), 1.0, 0.5 ); - gtk_widget_show( _fixupBtn ); + _impl->_fixupBtn = gtk_button_new_with_label(_("Fix")); + g_signal_connect( G_OBJECT(_impl->_fixupBtn), "clicked", G_CALLBACK(ColorICCSelectorImpl::_fixupHit), (gpointer)_impl ); + gtk_widget_set_sensitive( _impl->_fixupBtn, FALSE ); + gtk_widget_set_tooltip_text( _impl->_fixupBtn, _("Fix RGB fallback to match icc-color() value.") ); + //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(_fixupBtn, XPAD); - gtk_widget_set_margin_right(_fixupBtn, XPAD); - gtk_widget_set_margin_top(_fixupBtn, YPAD); - gtk_widget_set_margin_bottom(_fixupBtn, YPAD); - gtk_grid_attach(GTK_GRID(t), _fixupBtn, 0, row, 1, 1); + 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), _fixupBtn, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); + gtk_table_attach( GTK_TABLE (t), _impl->_fixupBtn, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); #endif // 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); - _profileSel = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); + _impl->_profileSel = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (_profileSel), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (_profileSel), renderer, "text", 0, NULL); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(_impl->_profileSel), renderer, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(_impl->_profileSel), renderer, "text", 0, NULL); GtkTreeIter iter; gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, _(""), 1, _(""), -1); - gtk_widget_show( _profileSel ); - gtk_combo_box_set_active( GTK_COMBO_BOX(_profileSel), 0 ); + 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(_profileSel, XPAD); - gtk_widget_set_margin_right(_profileSel, XPAD); - gtk_widget_set_margin_top(_profileSel, YPAD); - gtk_widget_set_margin_bottom(_profileSel, YPAD); - gtk_grid_attach(GTK_GRID(t), _profileSel, 1, row, 1, 1); + 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), _profileSel, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); + gtk_table_attach( GTK_TABLE(t), _impl->_profileSel, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); #endif #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - _profChangedID = g_signal_connect( G_OBJECT(_profileSel), "changed", G_CALLBACK(_profileSelected), (gpointer)this ); + _impl->_profChangedID = g_signal_connect( G_OBJECT(_impl->_profileSel), "changed", G_CALLBACK(ColorICCSelectorImpl::_profileSelected), (gpointer)_impl ); #else - gtk_widget_set_sensitive( _profileSel, false ); + gtk_widget_set_sensitive( _impl->_profileSel, false ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) row++; - _fooCount = 4; - _fooAdj = new GtkAdjustment*[_fooCount]; - _fooSlider = new GtkWidget*[_fooCount]; - _fooBtn = new GtkWidget*[_fooCount]; - _fooLabel = new GtkWidget*[_fooCount]; - _fooMap = new guchar*[_fooCount]; - - for ( guint i = 0; i < _fooCount; i++ ) { - /* Label */ + for ( guint i = 0; i < _impl->_fooCount; i++ ) { + // Label #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - _fooLabel[i] = gtk_label_new_with_mnemonic( names[i] ); + _impl->_fooLabel[i] = gtk_label_new_with_mnemonic( names[i] ); #else - _fooLabel[i] = gtk_label_new_with_mnemonic( "." ); + _impl->_fooLabel[i] = gtk_label_new_with_mnemonic( "." ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gtk_misc_set_alignment( GTK_MISC (_fooLabel[i]), 1.0, 0.5 ); - gtk_widget_show( _fooLabel[i] ); + gtk_misc_set_alignment( GTK_MISC (_impl->_fooLabel[i]), 1.0, 0.5 ); + gtk_widget_show( _impl->_fooLabel[i] ); #if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_fooLabel[i], XPAD); - gtk_widget_set_margin_right(_fooLabel[i], XPAD); - gtk_widget_set_margin_top(_fooLabel[i], YPAD); - gtk_widget_set_margin_bottom(_fooLabel[i], YPAD); - gtk_grid_attach(GTK_GRID(t), _fooLabel[i], 0, row, 1, 1); + 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); #else - gtk_table_attach( GTK_TABLE (t), _fooLabel[i], 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); + gtk_table_attach( GTK_TABLE (t), _impl->_fooLabel[i], 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); #endif - /* Adjustment */ - gdouble step = static_cast(_fooScales[i]) / 100.0; - gdouble page = static_cast(_fooScales[i]) / 10.0; + // Adjustment + gdouble step = static_cast(_impl->_fooScales[i]) / 100.0; + gdouble page = static_cast(_impl->_fooScales[i]) / 10.0; gint digits = (step > 0.9) ? 0 : 2; - _fooAdj[i] = GTK_ADJUSTMENT( gtk_adjustment_new( 0.0, 0.0, _fooScales[i], step, page, page ) ); + _impl->_fooAdj[i] = GTK_ADJUSTMENT( gtk_adjustment_new( 0.0, 0.0, _impl->_fooScales[i], step, page, page ) ); - /* Slider */ - _fooSlider[i] = sp_color_slider_new( _fooAdj[i] ); + // Slider + _impl->_fooSlider[i] = sp_color_slider_new( _impl->_fooAdj[i] ); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gtk_widget_set_tooltip_text( _fooSlider[i], tips[i] ); + gtk_widget_set_tooltip_text( _impl->_fooSlider[i], tips[i] ); #else - gtk_widget_set_tooltip_text( _fooSlider[i], "." ); + gtk_widget_set_tooltip_text( _impl->_fooSlider[i], "." ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gtk_widget_show( _fooSlider[i] ); + gtk_widget_show( _impl->_fooSlider[i] ); #if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_fooSlider[i], XPAD); - gtk_widget_set_margin_right(_fooSlider[i], XPAD); - gtk_widget_set_margin_top(_fooSlider[i], YPAD); - gtk_widget_set_margin_bottom(_fooSlider[i], YPAD); - gtk_widget_set_hexpand(_fooSlider[i], TRUE); - gtk_grid_attach(GTK_GRID(t), _fooSlider[i], 1, row, 1, 1); + 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); #else - gtk_table_attach( GTK_TABLE (t), _fooSlider[i], 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD ); + gtk_table_attach( GTK_TABLE (t), _impl->_fooSlider[i], 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD ); #endif - _fooBtn[i] = gtk_spin_button_new( _fooAdj[i], step, digits ); + _impl->_fooBtn[i] = gtk_spin_button_new( _impl->_fooAdj[i], step, digits ); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gtk_widget_set_tooltip_text( _fooBtn[i], tips[i] ); + gtk_widget_set_tooltip_text( _impl->_fooBtn[i], tips[i] ); #else - gtk_widget_set_tooltip_text( _fooBtn[i], "." ); + gtk_widget_set_tooltip_text( _impl->_fooBtn[i], "." ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - sp_dialog_defocus_on_enter( _fooBtn[i] ); - gtk_label_set_mnemonic_widget( GTK_LABEL(_fooLabel[i]), _fooBtn[i] ); - gtk_widget_show( _fooBtn[i] ); + 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] ); #if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_fooBtn[i], XPAD); - gtk_widget_set_margin_right(_fooBtn[i], XPAD); - gtk_widget_set_margin_top(_fooBtn[i], YPAD); - gtk_widget_set_margin_bottom(_fooBtn[i], YPAD); - gtk_widget_set_halign(_fooBtn[i], GTK_ALIGN_CENTER); - gtk_widget_set_valign(_fooBtn[i], GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(t), _fooBtn[i], 2, row, 1, 1); + 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); #else - gtk_table_attach( GTK_TABLE (t), _fooBtn[i], 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD ); + gtk_table_attach( GTK_TABLE (t), _impl->_fooBtn[i], 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD ); #endif - _fooMap[i] = g_new( guchar, 4 * 1024 ); - memset( _fooMap[i], 0x0ff, 1024 * 4 ); + _impl->_fooMap[i] = g_new( guchar, 4 * 1024 ); + memset( _impl->_fooMap[i], 0x0ff, 1024 * 4 ); - /* Signals */ - g_signal_connect( G_OBJECT( _fooAdj[i] ), "value_changed", G_CALLBACK( _adjustmentChanged ), _csel ); + // Signals + g_signal_connect( G_OBJECT( _impl->_fooAdj[i] ), "value_changed", G_CALLBACK( ColorICCSelectorImpl::_adjustmentChanged ), _csel ); - g_signal_connect( G_OBJECT( _fooSlider[i] ), "grabbed", G_CALLBACK( _sliderGrabbed ), _csel ); - g_signal_connect( G_OBJECT( _fooSlider[i] ), "released", G_CALLBACK( _sliderReleased ), _csel ); - g_signal_connect( G_OBJECT( _fooSlider[i] ), "changed", G_CALLBACK( _sliderChanged ), _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 ); row++; } - /* Label */ - _label = gtk_label_new_with_mnemonic (_("_A:")); - gtk_misc_set_alignment (GTK_MISC (_label), 1.0, 0.5); - gtk_widget_show (_label); + // Label + _impl->_label = gtk_label_new_with_mnemonic(_("_A:")); + 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(_label, XPAD); - gtk_widget_set_margin_right(_label, XPAD); - gtk_widget_set_margin_top(_label, YPAD); - gtk_widget_set_margin_bottom(_label, YPAD); - gtk_grid_attach(GTK_GRID(t), _label, 0, row, 1, 1); + 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), _label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); + gtk_table_attach(GTK_TABLE (t), _impl->_label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); #endif - /* Adjustment */ - _adj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 255.0, 1.0, 10.0, 10.0)); + // Adjustment + _impl->_adj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 255.0, 1.0, 10.0, 10.0)); - /* Slider */ - _slider = sp_color_slider_new (_adj); - gtk_widget_set_tooltip_text (_slider, _("Alpha (opacity)")); - gtk_widget_show (_slider); + // Slider + _impl->_slider = sp_color_slider_new(_impl->_adj); + 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(_slider, XPAD); - gtk_widget_set_margin_right(_slider, XPAD); - gtk_widget_set_margin_top(_slider, YPAD); - gtk_widget_set_margin_bottom(_slider, YPAD); - gtk_widget_set_hexpand(_slider, TRUE); - gtk_grid_attach(GTK_GRID(t), _slider, 1, row, 1, 1); + 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), _slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD); + gtk_table_attach (GTK_TABLE (t), _impl->_slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD); #endif - sp_color_slider_set_colors( SP_COLOR_SLIDER( _slider ), + sp_color_slider_set_colors( SP_COLOR_SLIDER( _impl->_slider ), SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 0.0 ), SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 0.5 ), SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 1.0 ) ); - /* Spinbutton */ - _sbtn = gtk_spin_button_new (GTK_ADJUSTMENT (_adj), 1.0, 0); - gtk_widget_set_tooltip_text (_sbtn, _("Alpha (opacity)")); - sp_dialog_defocus_on_enter (_sbtn); - gtk_label_set_mnemonic_widget (GTK_LABEL(_label), _sbtn); - gtk_widget_show (_sbtn); + // Spinbutton + _impl->_sbtn = gtk_spin_button_new(GTK_ADJUSTMENT(_impl->_adj), 1.0, 0); + gtk_widget_set_tooltip_text(_impl->_sbtn, _("Alpha (opacity)")); + sp_dialog_defocus_on_enter(_impl->_sbtn); + 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(_sbtn, XPAD); - gtk_widget_set_margin_right(_sbtn, XPAD); - gtk_widget_set_margin_top(_sbtn, YPAD); - gtk_widget_set_margin_bottom(_sbtn, YPAD); - gtk_widget_set_halign(_sbtn, GTK_ALIGN_CENTER); - gtk_widget_set_valign(_sbtn, GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(t), _sbtn, 2, row, 1, 1); + 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), _sbtn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD); + gtk_table_attach(GTK_TABLE (t), _impl->_sbtn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD); #endif - /* Signals */ - g_signal_connect (G_OBJECT (_adj), "value_changed", - G_CALLBACK (_adjustmentChanged), _csel); + // Signals + g_signal_connect(G_OBJECT(_impl->_adj), "value_changed", G_CALLBACK(ColorICCSelectorImpl::_adjustmentChanged), _csel); - g_signal_connect (G_OBJECT (_slider), "grabbed", - G_CALLBACK (_sliderGrabbed), _csel); - g_signal_connect (G_OBJECT (_slider), "released", - G_CALLBACK (_sliderReleased), _csel); - g_signal_connect (G_OBJECT (_slider), "changed", - G_CALLBACK (_sliderChanged), _csel); + g_signal_connect(G_OBJECT(_impl->_slider), "grabbed", G_CALLBACK(ColorICCSelectorImpl::_sliderGrabbed), _csel); + g_signal_connect(G_OBJECT(_impl->_slider), "released", G_CALLBACK(ColorICCSelectorImpl::_sliderReleased), _csel); + g_signal_connect(G_OBJECT(_impl->_slider), "changed", G_CALLBACK(ColorICCSelectorImpl::_sliderChanged), _csel); } static void sp_color_icc_selector_dispose(GObject *object) { - if ((G_OBJECT_CLASS(parent_class))->dispose) + if ((G_OBJECT_CLASS(parent_class))->dispose) { (* (G_OBJECT_CLASS(parent_class))->dispose)(object); + } } static void @@ -534,24 +592,24 @@ sp_color_icc_selector_new (void) } -void ColorICCSelector::_fixupHit( GtkWidget* /*src*/, gpointer data ) +void ColorICCSelectorImpl::_fixupHit( GtkWidget* /*src*/, gpointer data ) { - ColorICCSelector* self = reinterpret_cast(data); + ColorICCSelectorImpl* self = reinterpret_cast(data); gtk_widget_set_sensitive( self->_fixupBtn, FALSE ); - self->_adjustmentChanged( self->_fooAdj[0], SP_COLOR_ICC_SELECTOR(self->_csel) ); + self->_adjustmentChanged( self->_fooAdj[0], SP_COLOR_ICC_SELECTOR(self->_owner->_csel) ); } #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -void ColorICCSelector::_profileSelected( GtkWidget* /*src*/, gpointer data ) +void ColorICCSelectorImpl::_profileSelected( GtkWidget* /*src*/, gpointer data ) { - ColorICCSelector* self = reinterpret_cast(data); + ColorICCSelectorImpl* self = reinterpret_cast(data); GtkTreeIter iter; - if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX(self->_profileSel), &iter)) { - GtkTreeModel *store = gtk_combo_box_get_model (GTK_COMBO_BOX(self->_profileSel)); + if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(self->_profileSel), &iter)) { + GtkTreeModel *store = gtk_combo_box_get_model(GTK_COMBO_BOX(self->_profileSel)); gchar* name = 0; - gtk_tree_model_get (store, &iter, 1, &name, -1); + gtk_tree_model_get(store, &iter, 1, &name, -1); self->_switchToProfile( name ); gtk_widget_set_tooltip_text(self->_profileSel, name ); @@ -559,15 +617,14 @@ void ColorICCSelector::_profileSelected( GtkWidget* /*src*/, gpointer data ) g_free( name ); } } - } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -void ColorICCSelector::_switchToProfile( gchar const* name ) +void ColorICCSelectorImpl::_switchToProfile( gchar const* name ) { bool dirty = false; - SPColor tmp( _color ); + SPColor tmp( _owner->_color ); if ( name ) { if ( tmp.icc && tmp.icc->colorProfile == name ) { @@ -588,7 +645,7 @@ void ColorICCSelector::_switchToProfile( gchar const* name ) if ( newProf ) { cmsHTRANSFORM trans = newProf->getTransfFromSRGB8(); if ( trans ) { - guint32 val = _color.toRGBA32(0); + guint32 val = _owner->_color.toRGBA32(0); guchar pre[4] = { static_cast(SP_RGBA32_R_U(val)), static_cast(SP_RGBA32_G_U(val)), @@ -655,7 +712,7 @@ void ColorICCSelector::_switchToProfile( gchar const* name ) #endif // DEBUG_LCMS _setProfile( tmp.icc ); //_adjustmentChanged( _fooAdj[0], SP_COLOR_ICC_SELECTOR(_csel) ); - setColorAlpha( tmp, _alpha, true ); + _owner->setColorAlpha( tmp, _owner->_alpha, true ); #ifdef DEBUG_LCMS g_message("+_________________"); #endif // DEBUG_LCMS @@ -664,7 +721,7 @@ void ColorICCSelector::_switchToProfile( gchar const* name ) #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -void ColorICCSelector::_profilesChanged( std::string const & name ) +void ColorICCSelectorImpl::_profilesChanged( std::string const & name ) { GtkComboBox* combo = GTK_COMBO_BOX(_profileSel); @@ -675,7 +732,7 @@ void ColorICCSelector::_profilesChanged( std::string const & name ) GtkTreeIter iter; gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, _(""), 1, _(""), -1); + gtk_list_store_set(store, &iter, 0, _(""), 1, _(""), -1); gtk_combo_box_set_active( combo, 0 ); @@ -686,7 +743,7 @@ void ColorICCSelector::_profilesChanged( std::string const & name ) Inkscape::ColorProfile* prof = reinterpret_cast(obj); gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, gr_ellipsize_text(prof->name, 25).c_str(), 1, prof->name, -1); + gtk_list_store_set(store, &iter, 0, gr_ellipsize_text(prof->name, 25).c_str(), 1, prof->name, -1); if ( name == prof->name ) { gtk_combo_box_set_active( combo, index ); @@ -700,16 +757,16 @@ void ColorICCSelector::_profilesChanged( std::string const & name ) g_signal_handler_unblock( G_OBJECT(_profileSel), _profChangedID ); } #else -void ColorICCSelector::_profilesChanged( std::string const & /*name*/ ) +void ColorICCSelectorImpl::_profilesChanged( std::string const & /*name*/ ) { } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -/* Helpers for setting color value */ +// Helpers for setting color value void ColorICCSelector::_colorChanged() { - _updating = TRUE; + _impl->_updating = TRUE; //sp_color_icc_set_color( SP_COLOR_ICC( _icc ), &color ); #ifdef DEBUG_LCMS @@ -722,36 +779,36 @@ void ColorICCSelector::_colorChanged() g_message("FLIPPIES!!!! %p '%s'", _color.icc, (_color.icc ? _color.icc->colorProfile.c_str():"")); #endif // DEBUG_LCMS - _profilesChanged( (_color.icc) ? _color.icc->colorProfile : std::string("") ); - ColorScales::setScaled( _adj, _alpha ); + _impl->_profilesChanged( (_color.icc) ? _color.icc->colorProfile : std::string("") ); + ColorScales::setScaled( _impl->_adj, _alpha ); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - _setProfile( _color.icc ); - _fixupNeeded = 0; - gtk_widget_set_sensitive( _fixupBtn, FALSE ); + _impl->_setProfile( _color.icc ); + _impl->_fixupNeeded = 0; + gtk_widget_set_sensitive( _impl->_fixupBtn, FALSE ); - if (_prof) { - if (_prof->getTransfToSRGB8() ) { + if (_impl->_prof) { + if (_impl->_prof->getTransfToSRGB8() ) { cmsUInt16Number tmp[4]; - for ( guint i = 0; i < _profChannelCount; i++ ) { + for ( guint i = 0; i < _impl->_profChannelCount; i++ ) { gdouble val = 0.0; if ( _color.icc->colors.size() > i ) { - if ( _fooScales[i] == 256 ) { - val = (_color.icc->colors[i] + 128.0) / static_cast(_fooScales[i]); + if ( _impl->_fooScales[i] == 256 ) { + val = (_color.icc->colors[i] + 128.0) / static_cast(_impl->_fooScales[i]); } else { - val = _color.icc->colors[i] / static_cast(_fooScales[i]); + val = _color.icc->colors[i] / static_cast(_impl->_fooScales[i]); } } tmp[i] = val * 0x0ffff; } guchar post[4] = {0,0,0,0}; - cmsHTRANSFORM trans = _prof->getTransfToSRGB8(); + cmsHTRANSFORM trans = _impl->_prof->getTransfToSRGB8(); if ( trans ) { cmsDoTransform( trans, tmp, post, 1 ); guint32 other = SP_RGBA32_U_COMPOSE(post[0], post[1], post[2], 255 ); if ( other != _color.toRGBA32(255) ) { - _fixupNeeded = other; - gtk_widget_set_sensitive( _fixupBtn, TRUE ); + _impl->_fixupNeeded = other; + gtk_widget_set_sensitive( _impl->_fixupBtn, TRUE ); #ifdef DEBUG_LCMS g_message("Color needs to change 0x%06x to 0x%06x", _color.toRGBA32(255) >> 8, other >> 8 ); #endif // DEBUG_LCMS @@ -762,17 +819,17 @@ void ColorICCSelector::_colorChanged() #else //(void)color; #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - _updateSliders( -1 ); + _impl->_updateSliders( -1 ); - _updating = FALSE; + _impl->_updating = FALSE; #ifdef DEBUG_LCMS g_message( "\\_________ %p::_colorChanged()", this ); #endif // DEBUG_LCMS } #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -void ColorICCSelector::_setProfile( SVGICCColor* profile ) +void ColorICCSelectorImpl::_setProfile( SVGICCColor* profile ) { #ifdef DEBUG_LCMS g_message( "/^^^^^^^^^ %p::_setProfile(%s)", this, @@ -852,25 +909,25 @@ void ColorICCSelector::_setProfile( SVGICCColor* profile ) } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -void ColorICCSelector::_updateSliders( gint ignore ) +void ColorICCSelectorImpl::_updateSliders( gint ignore ) { #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - if ( _color.icc ) + if ( _owner->_color.icc ) { for ( guint i = 0; i < _profChannelCount; i++ ) { gdouble val = 0.0; - if ( _color.icc->colors.size() > i ) { + if ( _owner->_color.icc->colors.size() > i ) { if ( _fooScales[i] == 256 ) { - val = (_color.icc->colors[i] + 128.0) / static_cast(_fooScales[i]); + val = (_owner->_color.icc->colors[i] + 128.0) / static_cast(_fooScales[i]); } else { - val = _color.icc->colors[i] / static_cast(_fooScales[i]); + val = _owner->_color.icc->colors[i] / static_cast(_fooScales[i]); } } gtk_adjustment_set_value( _fooAdj[i], val ); } - if ( _prof) { - if (_prof->getTransfToSRGB8() ) { + if ( _prof ) { + if ( _prof->getTransfToSRGB8() ) { for ( guint i = 0; i < _profChannelCount; i++ ) { if ( static_cast(i) != ignore ) { cmsUInt16Number* scratch = getScratch(); @@ -904,16 +961,15 @@ void ColorICCSelector::_updateSliders( gint ignore ) (void)ignore; #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - guint32 start = _color.toRGBA32( 0x00 ); - guint32 mid = _color.toRGBA32( 0x7f ); - guint32 end = _color.toRGBA32( 0xff ); + guint32 start = _owner->_color.toRGBA32( 0x00 ); + guint32 mid = _owner->_color.toRGBA32( 0x7f ); + guint32 end = _owner->_color.toRGBA32( 0xff ); sp_color_slider_set_colors( SP_COLOR_SLIDER(_slider), start, mid, end ); - } -void ColorICCSelector::_adjustmentChanged( GtkAdjustment *adjustment, SPColorICCSelector *cs ) +void ColorICCSelectorImpl::_adjustmentChanged( GtkAdjustment *adjustment, SPColorICCSelector *cs ) { // // TODO check this. It looks questionable: // // if a value is entered between 0 and 1 exclusive, normalize it to (int) 0..255 or 0..100 @@ -926,24 +982,24 @@ void ColorICCSelector::_adjustmentChanged( GtkAdjustment *adjustment, SPColorICC #endif // DEBUG_LCMS ColorICCSelector* iccSelector = static_cast(SP_COLOR_SELECTOR(cs)->base); - if (iccSelector->_updating) { + if (iccSelector->_impl->_updating) { return; } - iccSelector->_updating = TRUE; + iccSelector->_impl->_updating = TRUE; gint match = -1; SPColor newColor( iccSelector->_color ); - gfloat scaled = ColorScales::getScaled( iccSelector->_adj ); - if ( iccSelector->_adj == adjustment ) { + gfloat scaled = ColorScales::getScaled( iccSelector->_impl->_adj ); + if ( iccSelector->_impl->_adj == adjustment ) { #ifdef DEBUG_LCMS g_message("ALPHA"); #endif // DEBUG_LCMS } else { #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - for ( guint i = 0; i < iccSelector->_fooCount; i++ ) { - if ( iccSelector->_fooAdj[i] == adjustment ) { + for ( guint i = 0; i < iccSelector->_impl->_fooCount; i++ ) { + if ( iccSelector->_impl->_fooAdj[i] == adjustment ) { match = i; break; } @@ -957,11 +1013,11 @@ void ColorICCSelector::_adjustmentChanged( GtkAdjustment *adjustment, SPColorICC cmsUInt16Number tmp[4]; for ( guint i = 0; i < 4; i++ ) { - tmp[i] = ColorScales::getScaled( iccSelector->_fooAdj[i] ) * 0x0ffff; + tmp[i] = ColorScales::getScaled( iccSelector->_impl->_fooAdj[i] ) * 0x0ffff; } guchar post[4] = {0,0,0,0}; - cmsHTRANSFORM trans = iccSelector->_prof->getTransfToSRGB8(); + cmsHTRANSFORM trans = iccSelector->_impl->_prof->getTransfToSRGB8(); if ( trans ) { cmsDoTransform( trans, tmp, post, 1 ); } @@ -982,11 +1038,11 @@ void ColorICCSelector::_adjustmentChanged( GtkAdjustment *adjustment, SPColorICC #endif // DEBUG_LCMS newColor = other; newColor.icc->colors.clear(); - for ( guint i = 0; i < iccSelector->_profChannelCount; i++ ) { - gdouble val = ColorScales::getScaled( iccSelector->_fooAdj[i] ); - if ( iccSelector->_fooScales ) { - val *= iccSelector->_fooScales[i]; - if ( iccSelector->_fooScales[i] == 256 ) { + for ( guint i = 0; i < iccSelector->_impl->_profChannelCount; i++ ) { + gdouble val = ColorScales::getScaled( iccSelector->_impl->_fooAdj[i] ); + if ( iccSelector->_impl->_fooScales ) { + val *= iccSelector->_impl->_fooScales[i]; + if ( iccSelector->_impl->_fooScales[i] == 256 ) { val -= 128; } } @@ -995,26 +1051,26 @@ void ColorICCSelector::_adjustmentChanged( GtkAdjustment *adjustment, SPColorICC } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) } - iccSelector->_updateInternals( newColor, scaled, iccSelector->_dragging ); - iccSelector->_updateSliders( match ); + iccSelector->_updateInternals( newColor, scaled, iccSelector->_impl->_dragging ); + iccSelector->_impl->_updateSliders( match ); - iccSelector->_updating = FALSE; + iccSelector->_impl->_updating = FALSE; #ifdef DEBUG_LCMS g_message( "\\_________ %p::_adjustmentChanged()", cs ); #endif // DEBUG_LCMS } -void ColorICCSelector::_sliderGrabbed( SPColorSlider */*slider*/, SPColorICCSelector */*cs*/ ) +void ColorICCSelectorImpl::_sliderGrabbed( SPColorSlider * /*slider*/, SPColorICCSelector * /*cs*/ ) { // ColorICCSelector* iccSelector = dynamic_cast(SP_COLOR_SELECTOR(cs)->base); // if (!iccSelector->_dragging) { // iccSelector->_dragging = TRUE; // iccSelector->_grabbed(); -// iccSelector->_updateInternals( iccSelector->_color, ColorScales::getScaled( iccSelector->_adj ), iccSelector->_dragging ); +// iccSelector->_updateInternals( iccSelector->_color, ColorScales::getScaled( iccSelector->_impl->_adj ), iccSelector->_dragging ); // } } -void ColorICCSelector::_sliderReleased( SPColorSlider */*slider*/, SPColorICCSelector */*cs*/ ) +void ColorICCSelectorImpl::_sliderReleased( SPColorSlider * /*slider*/, SPColorICCSelector * /*cs*/ ) { // ColorICCSelector* iccSelector = dynamic_cast(SP_COLOR_SELECTOR(cs)->base); // if (iccSelector->_dragging) { @@ -1025,9 +1081,9 @@ void ColorICCSelector::_sliderReleased( SPColorSlider */*slider*/, SPColorICCSel } #ifdef DEBUG_LCMS -void ColorICCSelector::_sliderChanged( SPColorSlider *slider, SPColorICCSelector *cs ) +void ColorICCSelectorImpl::_sliderChanged( SPColorSlider *slider, SPColorICCSelector *cs ) #else -void ColorICCSelector::_sliderChanged( SPColorSlider */*slider*/, SPColorICCSelector */*cs*/ ) +void ColorICCSelectorImpl::_sliderChanged( SPColorSlider * /*slider*/, SPColorICCSelector * /*cs*/ ) #endif // DEBUG_LCMS { #ifdef DEBUG_LCMS diff --git a/src/widgets/sp-color-icc-selector.h b/src/widgets/sp-color-icc-selector.h index 67fedf590..404bc7265 100644 --- a/src/widgets/sp-color-icc-selector.h +++ b/src/widgets/sp-color-icc-selector.h @@ -5,7 +5,6 @@ #include #include "../color.h" -#include "sp-color-slider.h" #include "sp-color-selector.h" namespace Inkscape { @@ -15,6 +14,7 @@ struct ColorProfile; struct SPColorICCSelector; struct SPColorICCSelectorClass; +class ColorICCSelectorImpl; class ColorICCSelector: public ColorSelector { @@ -27,63 +27,25 @@ public: protected: virtual void _colorChanged(); - static void _adjustmentChanged ( GtkAdjustment *adjustment, SPColorICCSelector *cs ); - - static void _sliderGrabbed( SPColorSlider *slider, SPColorICCSelector *cs ); - static void _sliderReleased( SPColorSlider *slider, SPColorICCSelector *cs ); - static void _sliderChanged( SPColorSlider *slider, SPColorICCSelector *cs ); - - static void _fixupHit( GtkWidget* src, gpointer data ); - static void _profileSelected( GtkWidget* src, gpointer data ); - void _recalcColor( gboolean changing ); -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - void _setProfile( SVGICCColor* profile ); - void _switchToProfile( gchar const* name ); -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - void _updateSliders( gint ignore ); - void _profilesChanged( std::string const & name ); - - gboolean _updating : 1; - gboolean _dragging : 1; - - guint32 _fixupNeeded; - GtkWidget* _fixupBtn; - GtkWidget* _profileSel; - - guint _fooCount; - guint const* _fooScales; - GtkAdjustment** _fooAdj; - GtkWidget** _fooSlider; - GtkWidget** _fooBtn; - GtkWidget** _fooLabel; - guchar** _fooMap; - - GtkAdjustment* _adj; /* Channel adjustment */ - GtkWidget* _slider; - GtkWidget* _sbtn; /* Spinbutton */ - GtkWidget* _label; /* Label */ - -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - std::string _profileName; - Inkscape::ColorProfile* _prof; - guint _profChannelCount; - gulong _profChangedID; -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) private: + friend class ColorICCSelectorImpl; + // By default, disallow copy constructor and assignment operator ColorICCSelector( const ColorICCSelector& obj ); ColorICCSelector& operator=( const ColorICCSelector& obj ); + + ColorICCSelectorImpl *_impl; }; -#define SP_TYPE_COLOR_ICC_SELECTOR (sp_color_icc_selector_get_type ()) -#define SP_COLOR_ICC_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_COLOR_ICC_SELECTOR, SPColorICCSelector)) -#define SP_COLOR_ICC_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_ICC_SELECTOR, SPColorICCSelectorClass)) -#define SP_IS_COLOR_ICC_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_COLOR_ICC_SELECTOR)) -#define SP_IS_COLOR_ICC_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_ICC_SELECTOR)) +#define SP_TYPE_COLOR_ICC_SELECTOR (sp_color_icc_selector_get_type()) +#define SP_COLOR_ICC_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_COLOR_ICC_SELECTOR, SPColorICCSelector)) +#define SP_COLOR_ICC_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_COLOR_ICC_SELECTOR, SPColorICCSelectorClass)) +#define SP_IS_COLOR_ICC_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_COLOR_ICC_SELECTOR)) +#define SP_IS_COLOR_ICC_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_COLOR_ICC_SELECTOR)) struct SPColorICCSelector { SPColorSelector parent; @@ -93,9 +55,9 @@ struct SPColorICCSelectorClass { SPColorSelectorClass parent_class; }; -GType sp_color_icc_selector_get_type (void); +GType sp_color_icc_selector_get_type(void); -GtkWidget *sp_color_icc_selector_new (void); +GtkWidget *sp_color_icc_selector_new(void); -- cgit v1.2.3 From 617fc534d1c9aa7b10524687da44e60a4decc476 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 18 May 2013 00:08:13 -0700 Subject: Refactored internals to use a vector of structs instead of several parallel arrays. (bzr r12339) --- src/widgets/sp-color-icc-selector.cpp | 184 ++++++++++++++++------------------ 1 file changed, 89 insertions(+), 95 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 08cd7264f..69677257d 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -6,11 +6,15 @@ #include #include #include +#include +#include + #include "../dialogs/dialog-events.h" #include "sp-color-icc-selector.h" #include "sp-color-scales.h" #include "sp-color-slider.h" #include "svg/svg-icc-color.h" +#include "colorspace.h" #include "document.h" #include "inkscape.h" #include "profile-manager.h" @@ -106,7 +110,7 @@ public: GtkWidget* _profileSel; guint _fooCount; - guint const* _fooScales; + std::vector _fooScales; GtkAdjustment** _fooAdj; GtkWidget** _fooSlider; GtkWidget** _fooBtn; @@ -219,84 +223,73 @@ static cmsUInt16Number* getScratch() { return scritch; } -struct MapMap { - cmsUInt32Number space; - cmsUInt32Number inForm; -}; +colorspace::Component::Component(std::string const &name, std::string const &tip, guint scale) : + name(name), + tip(tip), + scale(scale) +{ +} + +std::vector colorspace::getColorSpaceInfo( uint32_t space ) +{ + static std::map > sets; + if (sets.empty()) + { + sets[cmsSigXYZData].push_back(Component("_X", "X", 2)); // TYPE_XYZ_16 + sets[cmsSigXYZData].push_back(Component("_Y", "Y", 1)); + sets[cmsSigXYZData].push_back(Component("_Z", "Z", 2)); + + sets[cmsSigLabData].push_back(Component("_L", "L", 100)); // TYPE_Lab_16 + sets[cmsSigLabData].push_back(Component("_a", "a", 256)); + sets[cmsSigLabData].push_back(Component("_b", "b", 256)); -void getThings( cmsUInt32Number space, gchar const**& namers, gchar const**& tippies, guint const*& scalies ) { - MapMap possible[] = { - {cmsSigXYZData, TYPE_XYZ_16}, - {cmsSigLabData, TYPE_Lab_16}, //cmsSigLuvData - {cmsSigYCbCrData, TYPE_YCbCr_16}, - {cmsSigYxyData, TYPE_Yxy_16}, - {cmsSigRgbData, TYPE_RGB_16}, - {cmsSigGrayData, TYPE_GRAY_16}, - {cmsSigHsvData, TYPE_HSV_16}, - {cmsSigHlsData, TYPE_HLS_16}, - {cmsSigCmykData, TYPE_CMYK_16}, - {cmsSigCmyData, TYPE_CMY_16}, - }; - - static gchar const *names[][6] = { - {"_X", "_Y", "_Z", "", "", ""}, - {"_L", "_a", "_b", "", "", ""}, - // - {"_Y", "C_b", "C_r", "", "", ""}, - {"_Y", "_x", "y", "", "", ""}, - {_("_R:"), _("_G:"), _("_B:"), "", "", ""}, - {_("_G:"), "", "", "", "", ""}, - {_("_H:"), _("_S:"), "_V:", "", "", ""}, - {_("_H:"), _("_L:"), _("_S:"), "", "", ""}, - {_("_C:"), _("_M:"), _("_Y:"), _("_K:"), "", ""}, - {_("_C:"), _("_M:"), _("_Y:"), "", "", ""}, - }; - - static gchar const *tips[][6] = { - {"X", "Y", "Z", "", "", ""}, - {"L", "a", "b", "", "", ""}, - // - {"Y", "Cb", "Cr", "", "", ""}, - {"Y", "x", "y", "", "", ""}, - {_("Red"), _("Green"), _("Blue"), "", "", ""}, - {_("Gray"), "", "", "", "", ""}, - {_("Hue"), _("Saturation"), "Value", "", "", ""}, - {_("Hue"), _("Lightness"), _("Saturation"), "", "", ""}, - {_("Cyan"), _("Magenta"), _("Yellow"), _("Black"), "", ""}, - {_("Cyan"), _("Magenta"), _("Yellow"), "", "", ""}, - }; - - static guint scales[][6] = { - {2, 1, 2, 1, 1, 1}, - {100, 256, 256, 1, 1, 1}, - // - {1, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1}, - {360, 1, 1, 1, 1, 1}, - {360, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1}, - }; - - int index = 0; - for ( guint i = 0; i < G_N_ELEMENTS(possible); i++ ) { - if ( possible[i].space == space ) { - index = i; - break; - } + + sets[cmsSigYCbCrData].push_back(Component("_Y", "Y", 1)); // TYPE_YCbCr_16 + sets[cmsSigYCbCrData].push_back(Component("C_b", "Cb", 1)); + sets[cmsSigYCbCrData].push_back(Component("C_r", "Cr", 1)); + + sets[cmsSigYxyData].push_back(Component("_Y", "Y", 1)); // TYPE_Yxy_16 + sets[cmsSigYxyData].push_back(Component("_x", "x", 1)); + sets[cmsSigYxyData].push_back(Component("y", "y", 1)); + + sets[cmsSigRgbData].push_back(Component(_("_R:"), _("Red"), 1)); // TYPE_RGB_16 + sets[cmsSigRgbData].push_back(Component(_("_G:"), _("Green"), 1)); + sets[cmsSigRgbData].push_back(Component(_("_B:"), _("Blue"), 1)); + + sets[cmsSigGrayData].push_back(Component(_("G:"), _("Gray"), 1)); // TYPE_GRAY_16 + + sets[cmsSigHsvData].push_back(Component(_("_H:"), _("Hue"), 360)); // TYPE_HSV_16 + sets[cmsSigHsvData].push_back(Component(_("_S:"), _("Saturation"), 1)); + sets[cmsSigHsvData].push_back(Component("_V:", "Value", 1)); + + sets[cmsSigHlsData].push_back(Component(_("_H:"), _("Hue"), 360)); // TYPE_HLS_16 + sets[cmsSigHlsData].push_back(Component(_("_L:"), _("Lightness"), 1)); + sets[cmsSigHlsData].push_back(Component(_("_S:"), _("Saturation"), 1)); + + sets[cmsSigCmykData].push_back(Component(_("_C:"), _("Cyan"), 1)); // TYPE_CMYK_16 + sets[cmsSigCmykData].push_back(Component(_("_M:"), _("Magenta"), 1)); + sets[cmsSigCmykData].push_back(Component(_("_Y:"), _("Yellow"), 1)); + sets[cmsSigCmykData].push_back(Component(_("_K:"), _("Black"), 1)); + + 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)); } - namers = names[index]; - tippies = tips[index]; - scalies = scales[index]; + std::vector target; + + if (sets.find(space) != sets.end()) + { + target = sets[space]; + } + return target; } -void getThings( Inkscape::ColorProfile *prof, gchar const**& namers, gchar const**& tippies, guint const*& scalies ) { - getThings( asICColorSpaceSig(prof->getColorSpace()), namers, tippies, scalies ); +std::vector colorspace::getColorSpaceInfo( Inkscape::ColorProfile *prof ) +{ + return getColorSpaceInfo( asICColorSpaceSig(prof->getColorSpace()) ); } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -354,9 +347,11 @@ void ColorICCSelector::init() #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) //guint partCount = _cmsChannelsOf( icSigRgbData ); - gchar const** names = 0; - gchar const** tips = 0; - getThings( cmsSigRgbData, names, tips, _impl->_fooScales ); + 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) // Create components @@ -417,7 +412,7 @@ void ColorICCSelector::init() for ( guint i = 0; i < _impl->_fooCount; i++ ) { // Label #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - _impl->_fooLabel[i] = gtk_label_new_with_mnemonic( names[i] ); + _impl->_fooLabel[i] = gtk_label_new_with_mnemonic( (i < things.size()) ? things[i].name.c_str() : "" ); #else _impl->_fooLabel[i] = gtk_label_new_with_mnemonic( "." ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -435,15 +430,16 @@ void ColorICCSelector::init() #endif // Adjustment - gdouble step = static_cast(_impl->_fooScales[i]) / 100.0; - gdouble page = static_cast(_impl->_fooScales[i]) / 10.0; + guint scaleValue = (i < _impl->_fooScales.size()) ? _impl->_fooScales[i] : 1; + 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, _impl->_fooScales[i], step, page, page ) ); + _impl->_fooAdj[i] = GTK_ADJUSTMENT( gtk_adjustment_new( 0.0, 0.0, scaleValue, step, page, page ) ); // Slider _impl->_fooSlider[i] = sp_color_slider_new( _impl->_fooAdj[i] ); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gtk_widget_set_tooltip_text( _impl->_fooSlider[i], tips[i] ); + gtk_widget_set_tooltip_text( _impl->_fooSlider[i], (i < things.size()) ? things[i].tip.c_str() : "" ); #else gtk_widget_set_tooltip_text( _impl->_fooSlider[i], "." ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -462,7 +458,7 @@ void ColorICCSelector::init() _impl->_fooBtn[i] = gtk_spin_button_new( _impl->_fooAdj[i], step, digits ); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gtk_widget_set_tooltip_text( _impl->_fooBtn[i], tips[i] ); + gtk_widget_set_tooltip_text( _impl->_fooBtn[i], (i < things.size()) ? things[i].tip.c_str() : "" ); #else gtk_widget_set_tooltip_text( _impl->_fooBtn[i], "." ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -665,15 +661,12 @@ void ColorICCSelectorImpl::_switchToProfile( gchar const* name ) guint count = cmsChannelsOf( asICColorSpaceSig(newProf->getColorSpace()) ); #endif - gchar const** names = 0; - gchar const** tips = 0; - guint const* scales = 0; - getThings( asICColorSpaceSig(newProf->getColorSpace()), names, tips, scales ); + std::vector things = colorspace::getColorSpaceInfo(asICColorSpaceSig(newProf->getColorSpace())); for ( guint i = 0; i < count; i++ ) { - gdouble val = (((gdouble)post[i])/65535.0) * (gdouble)scales[i]; + gdouble val = (((gdouble)post[i])/65535.0) * (gdouble)((i < things.size()) ? things[i].scale : 1); #ifdef DEBUG_LCMS - g_message(" scaled %d by %d to be %f", i, scales[i], val); + g_message(" scaled %d by %d to be %f", i, ((i < things.size()) ? things[i].scale : 1), val); #endif // DEBUG_LCMS tmp.icc->colors.push_back(val); } @@ -862,16 +855,17 @@ void ColorICCSelectorImpl::_setProfile( SVGICCColor* profile ) _profChannelCount = cmsChannelsOf( asICColorSpaceSig(_prof->getColorSpace()) ); #endif - gchar const** names = 0; - gchar const** tips = 0; - getThings( asICColorSpaceSig(_prof->getColorSpace()), names, tips, _fooScales ); - + 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 ) { for ( guint i = 0; i < _profChannelCount; i++ ) { - gtk_label_set_text_with_mnemonic( GTK_LABEL(_fooLabel[i]), names[i]); + gtk_label_set_text_with_mnemonic( GTK_LABEL(_fooLabel[i]), (i < things.size()) ? things[i].name.c_str() : ""); - gtk_widget_set_tooltip_text( _fooSlider[i], tips[i] ); - gtk_widget_set_tooltip_text( _fooBtn[i], tips[i] ); + 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() : "" ); sp_color_slider_set_colors( SP_COLOR_SLIDER(_fooSlider[i]), SPColor(0.0, 0.0, 0.0).toRGBA32(0xff), @@ -1040,7 +1034,7 @@ 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->_fooAdj[i] ); - if ( iccSelector->_impl->_fooScales ) { + if ( i < iccSelector->_impl->_fooScales.size() ) { val *= iccSelector->_impl->_fooScales[i]; if ( iccSelector->_impl->_fooScales[i] == 256 ) { val -= 128; -- cgit v1.2.3 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 From c3a160589a9cb41c70a56e5e7b66a65857a0d10e Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Mon, 1 Jul 2013 21:04:32 +0100 Subject: Factored layer model out into new Inkscape::LayerModel class. This allows Inkscape::Selection to use a LayerModel that is not associated with a UI. Changed the interface of verbs (SPAction) to use a new ActionContext rather than UI::View::View, again so that verbs may be used in a console mode. Modified boolean operation verbs to work in console-only mode. Fixed up DESKTOP_IS_ACTIVE macro to work in the case of no desktops. Modified main.cpp to process selections and verbs in no-GUI mode. Other changes are all consequences of the SPDesktop, Selection and LayerModel interface changes. (bzr r12387.1.1) --- src/widgets/button.cpp | 3 ++- src/widgets/desktop-widget.cpp | 6 ++++-- src/widgets/gradient-selector.cpp | 3 ++- src/widgets/lpe-toolbar.cpp | 4 +++- src/widgets/select-toolbar.cpp | 4 +++- src/widgets/toolbox.cpp | 14 ++++++++------ 6 files changed, 22 insertions(+), 12 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 467f0d70e..a1bd9b792 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -20,6 +20,7 @@ #include "icon.h" #include "shortcuts.h" #include "interface.h" +#include "helper/action-context.h" #include @@ -309,7 +310,7 @@ sp_button_new_from_data( Inkscape::IconSize size, const gchar *tip ) { GtkWidget *button; - SPAction *action=sp_action_new(view, name, name, tip, name, 0); + SPAction *action=sp_action_new(Inkscape::ActionContext(view), name, name, tip, name, 0); button = sp_button_new (size, type, action, NULL); g_object_unref(action); return button; diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 814298041..c1214c1a4 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -41,6 +41,8 @@ #include "ege-select-one-action.h" #include #include "file.h" +#include "helper/action.h" +#include "helper/action-context.h" #include "helper/units.h" #include "helper/unit-tracker.h" #include "inkscape-private.h" @@ -485,7 +487,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gchar const* tip = ""; Inkscape::Verb* verb = Inkscape::Verb::get( SP_VERB_VIEW_CMS_TOGGLE ); if ( verb ) { - SPAction *act = verb->get_action( dtw->viewwidget.view ); + SPAction *act = verb->get_action( Inkscape::ActionContext( dtw->viewwidget.view ) ); if ( act && act->tip ) { tip = act->tip; } @@ -1060,7 +1062,7 @@ void cms_adjust_set_sensitive( SPDesktopWidget *dtw, bool enabled ) { Inkscape::Verb* verb = Inkscape::Verb::get( SP_VERB_VIEW_CMS_TOGGLE ); if ( verb ) { - SPAction *act = verb->get_action( dtw->viewwidget.view ); + SPAction *act = verb->get_action( Inkscape::ActionContext( dtw->viewwidget.view ) ); if ( act ) { sp_action_set_sensitive( act, enabled ); } diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 7a7f0d8ff..5ac994509 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -26,6 +26,7 @@ #include "inkscape.h" #include "verbs.h" #include "helper/action.h" +#include "helper/action-context.h" #include "preferences.h" #include @@ -535,7 +536,7 @@ sp_gradient_selector_edit_vector_clicked (GtkWidget */*w*/, SPGradientSelector * // Invoke the gradient tool Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_CONTEXT_GRADIENT ); if ( verb ) { - SPAction *action = verb->get_action( ( Inkscape::UI::View::View * ) SP_ACTIVE_DESKTOP); + SPAction *action = verb->get_action( Inkscape::ActionContext( ( Inkscape::UI::View::View * ) SP_ACTIVE_DESKTOP ) ); if ( action ) { sp_action_perform( action, NULL ); } diff --git a/src/widgets/lpe-toolbar.cpp b/src/widgets/lpe-toolbar.cpp index 3126175b3..c7659ab42 100644 --- a/src/widgets/lpe-toolbar.cpp +++ b/src/widgets/lpe-toolbar.cpp @@ -55,6 +55,8 @@ #include "../xml/repr.h" #include "ui/uxmanager.h" #include "../ui/icon-names.h" +#include "../helper/action.h" +#include "../helper/action-context.h" #include "../helper/unit-menu.h" #include "../helper/units.h" #include "../helper/unit-tracker.h" @@ -286,7 +288,7 @@ static void lpetool_open_lpe_dialog(GtkToggleAction *act, gpointer data) SPDesktop *desktop = static_cast(data); if (tools_isactive(desktop, TOOLS_LPETOOL)) { - sp_action_perform(Inkscape::Verb::get(SP_VERB_DIALOG_LIVE_PATH_EFFECT)->get_action(desktop), NULL); + sp_action_perform(Inkscape::Verb::get(SP_VERB_DIALOG_LIVE_PATH_EFFECT)->get_action(Inkscape::ActionContext(desktop)), NULL); } gtk_toggle_action_set_active(act, false); } diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 549581610..1bfc841e3 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -37,6 +37,8 @@ #include "sp-namedview.h" #include "toolbox.h" #include +#include "helper/action.h" +#include "helper/action-context.h" #include "helper/unit-menu.h" #include "helper/units.h" #include "inkscape.h" @@ -413,7 +415,7 @@ static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::Vi { GtkAction* act = 0; - SPAction* targetAction = verb->get_action(view); + SPAction* targetAction = verb->get_action(Inkscape::ActionContext(view)); InkAction* inky = ink_action_new( verb->get_id(), verb->get_name(), verb->get_tip(), verb->get_image(), size ); act = GTK_ACTION(inky); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 0fdf36d5f..ca593976f 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -47,6 +47,8 @@ #include "../ege-output-action.h" #include "../ege-select-one-action.h" #include "../graphlayout.h" +#include "../helper/action.h" +#include "../helper/action-context.h" #include "../helper/unit-menu.h" #include "../helper/units.h" #include "../helper/unit-tracker.h" @@ -591,9 +593,9 @@ private: Glib::RefPtr VerbAction::create(Inkscape::Verb* verb, Inkscape::Verb* verb2, Inkscape::UI::View::View *view) { Glib::RefPtr result; - SPAction *action = verb->get_action(view); + SPAction *action = verb->get_action(Inkscape::ActionContext(view)); if ( action ) { - //SPAction* action2 = verb2 ? verb2->get_action(view) : 0; + //SPAction* action2 = verb2 ? verb2->get_action(Inkscape::ActionContext(view)) : 0; result = Glib::RefPtr(new VerbAction(verb, verb2, view)); } @@ -680,7 +682,7 @@ void VerbAction::set_active(bool active) void VerbAction::on_activate() { if ( verb ) { - SPAction *action = verb->get_action(view); + SPAction *action = verb->get_action(Inkscape::ActionContext(view)); if ( action ) { sp_action_perform(action, 0); } @@ -770,14 +772,14 @@ GtkToolItem * sp_toolbox_button_item_new_from_verb_with_doubleclick(GtkWidget *t Inkscape::Verb *verb, Inkscape::Verb *doubleclick_verb, Inkscape::UI::View::View *view) { - SPAction *action = verb->get_action(view); + SPAction *action = verb->get_action(Inkscape::ActionContext(view)); if (!action) { return NULL; } SPAction *doubleclick_action; if (doubleclick_verb) { - doubleclick_action = doubleclick_verb->get_action(view); + doubleclick_action = doubleclick_verb->get_action(Inkscape::ActionContext(view)); } else { doubleclick_action = NULL; } @@ -822,7 +824,7 @@ static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::Vi { GtkAction* act = 0; - SPAction* targetAction = verb->get_action(view); + SPAction* targetAction = verb->get_action(Inkscape::ActionContext(view)); InkAction* inky = ink_action_new( verb->get_id(), _(verb->get_name()), verb->get_tip(), verb->get_image(), size ); act = GTK_ACTION(inky); gtk_action_set_sensitive( act, targetAction->sensitive ); -- cgit v1.2.3