diff options
| author | su_v <suv-sf@users.sourceforge.net> | 2013-06-19 17:21:34 +0000 |
|---|---|---|
| committer | ~suv <suv-sf@users.sourceforge.net> | 2013-06-19 17:21:34 +0000 |
| commit | a3fb899bc1ae08cac5050791c9958437184b55e0 (patch) | |
| tree | 444647a2e316a13162f20041634fce7f4bf7f674 /src/widgets | |
| parent | changes_2013_05_22a.patch: (diff) | |
| parent | Fix my own mis-credit and some symbols labels (diff) | |
| download | inkscape-a3fb899bc1ae08cac5050791c9958437184b55e0.tar.gz inkscape-a3fb899bc1ae08cac5050791c9958437184b55e0.zip | |
merge from trunk (r12380)
(bzr r11668.1.72)
Diffstat (limited to 'src/widgets')
| -rw-r--r-- | src/widgets/dash-selector.h | 8 | ||||
| -rw-r--r-- | src/widgets/desktop-widget.cpp | 133 | ||||
| -rw-r--r-- | src/widgets/desktop-widget.h | 8 | ||||
| -rw-r--r-- | src/widgets/fill-style.cpp | 4 | ||||
| -rw-r--r-- | src/widgets/gradient-selector.h | 8 | ||||
| -rw-r--r-- | src/widgets/gradient-vector.h | 8 | ||||
| -rw-r--r-- | src/widgets/icon.cpp | 11 | ||||
| -rw-r--r-- | src/widgets/icon.h | 10 | ||||
| -rw-r--r-- | src/widgets/paint-selector.cpp | 3 | ||||
| -rw-r--r-- | src/widgets/shrink-wrap-button.cpp | 4 | ||||
| -rw-r--r-- | src/widgets/sp-attribute-widget.h | 4 | ||||
| -rw-r--r-- | src/widgets/sp-color-icc-selector.cpp | 521 | ||||
| -rw-r--r-- | src/widgets/sp-color-notebook.cpp | 7 | ||||
| -rw-r--r-- | src/widgets/spw-utilities.cpp | 4 | ||||
| -rw-r--r-- | src/widgets/stroke-marker-selector.cpp | 14 | ||||
| -rw-r--r-- | src/widgets/stroke-marker-selector.h | 10 | ||||
| -rw-r--r-- | src/widgets/stroke-style.cpp | 41 | ||||
| -rw-r--r-- | src/widgets/swatch-selector.h | 8 | ||||
| -rw-r--r-- | src/widgets/toolbox.cpp | 4 | ||||
| -rw-r--r-- | src/widgets/widget-sizes.h | 2 |
20 files changed, 467 insertions, 345 deletions
diff --git a/src/widgets/dash-selector.h b/src/widgets/dash-selector.h index ef828783e..5b9ebfa2b 100644 --- a/src/widgets/dash-selector.h +++ b/src/widgets/dash-selector.h @@ -10,6 +10,14 @@ * 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 <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/combobox.h> #include <gtkmm/liststore.h> diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 6c62a8f0d..814298041 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<Gtk::Adjustment> _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), "<tt> 0.00 </tt>" ); 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); @@ -1893,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<SPDesktop*>(data), 0.1); +} + +static void +sp_dtw_zoom_25 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 0.25); +} + +static void +sp_dtw_zoom_50 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 0.5); +} + +static void +sp_dtw_zoom_100 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 1.0); +} + +static void +sp_dtw_zoom_200 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 2.0); +} + +static void +sp_dtw_zoom_500 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 5.0); +} + +static void +sp_dtw_zoom_1000 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 10.0); +} + +static void +sp_dtw_zoom_page (GtkMenuItem */*item*/, gpointer data) +{ + static_cast<SPDesktop*>(data)->zoom_page(); +} + +static void +sp_dtw_zoom_drawing (GtkMenuItem */*item*/, gpointer data) +{ + static_cast<SPDesktop*>(data)->zoom_drawing(); +} + +static void +sp_dtw_zoom_selection (GtkMenuItem */*item*/, gpointer data) +{ + static_cast<SPDesktop*>(data)->zoom_selection(); +} + static void sp_dtw_zoom_populate_popup (GtkEntry */*entry*/, GtkMenu *menu, gpointer data) { @@ -1906,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); @@ -1918,6 +1979,15 @@ sp_dtw_zoom_populate_popup (GtkEntry */*entry*/, GtkMenu *menu, gpointer data) 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 (); gtk_widget_show (item); @@ -1944,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<SPDesktop*>(data), 0.5); -} - -static void -sp_dtw_zoom_100 (GtkMenuItem */*item*/, gpointer data) -{ - sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 1.0); -} - -static void -sp_dtw_zoom_200 (GtkMenuItem */*item*/, gpointer data) -{ - sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 2.0); -} - -static void -sp_dtw_zoom_page (GtkMenuItem */*item*/, gpointer data) -{ - static_cast<SPDesktop*>(data)->zoom_page(); -} - -static void -sp_dtw_zoom_drawing (GtkMenuItem */*item*/, gpointer data) -{ - static_cast<SPDesktop*>(data)->zoom_drawing(); -} - -static void -sp_dtw_zoom_selection (GtkMenuItem */*item*/, gpointer data) -{ - static_cast<SPDesktop*>(data)->zoom_selection(); -} static void sp_dtw_sticky_zoom_toggled (GtkMenuItem *, gpointer data) diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 9188838b3..9031ac854 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -12,6 +12,14 @@ * ? -2004 */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/window.h> #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..d9d62d3ec 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -22,6 +22,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <glibmm/i18n.h> diff --git a/src/widgets/gradient-selector.h b/src/widgets/gradient-selector.h index ea83ff819..c88666b06 100644 --- a/src/widgets/gradient-selector.h +++ b/src/widgets/gradient-selector.h @@ -15,6 +15,14 @@ * 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 <glibmm/threads.h> +#endif + #include <glib.h> #include <gtk/gtk.h> diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h index 463d77912..64e40a35b 100644 --- a/src/widgets/gradient-vector.h +++ b/src/widgets/gradient-vector.h @@ -15,6 +15,14 @@ * 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 <glibmm/threads.h> +#endif + #include <gtkmm/liststore.h> #include <stddef.h> diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 7580d9602..dda453bc4 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -16,6 +16,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/icontheme.h> #include <cstring> #include <glib.h> @@ -863,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 6bce2e330..e1dae0d6a 100644 --- a/src/widgets/icon.h +++ b/src/widgets/icon.h @@ -14,6 +14,14 @@ * 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 <glibmm/threads.h> +#endif + #include <gtkmm/widget.h> #include "icon-size.h" @@ -45,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/paint-selector.cpp b/src/widgets/paint-selector.cpp index 08058d60d..40d2fb9f3 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -24,6 +24,9 @@ #include <cstring> #include <string> +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#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 941a0466c..3558780ed 100644 --- a/src/widgets/shrink-wrap-button.cpp +++ b/src/widgets/shrink-wrap-button.cpp @@ -13,6 +13,10 @@ #include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/button.h> #include <gtk/gtk.h> diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index d9b972201..4bd6c6959 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -19,6 +19,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/widget.h> #include <stddef.h> #include <sigc++/connection.h> diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 08cd7264f..00b00ce38 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -6,11 +6,16 @@ #include <math.h> #include <gtk/gtk.h> #include <glibmm/i18n.h> +#include <map> +#include <set> +#include <vector> + #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" @@ -69,9 +74,45 @@ 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() : + _component(), + _adj(0), + _slider(0), + _btn(0), + _label(0), + _map(0) + { + } + + 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 + GtkWidget *_label; // Label + guchar *_map; +}; + +/** + * Class that implements the internals of the selector. + */ class ColorICCSelectorImpl { public: @@ -105,13 +146,7 @@ public: GtkWidget* _fixupBtn; GtkWidget* _profileSel; - guint _fooCount; - guint const* _fooScales; - GtkAdjustment** _fooAdj; - GtkWidget** _fooSlider; - GtkWidget** _fooBtn; - GtkWidget** _fooLabel; - guchar** _fooMap; + std::vector<ComponentUI> _compUI; GtkAdjustment* _adj; // Channel adjustment GtkWidget* _slider; @@ -132,7 +167,67 @@ 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<cmsUInt32Number> knownColorspaces; + +#endif + + +/** + * Simple helper to allow bitwise or on GtkAttachOptions. + */ +GtkAttachOptions operator|(GtkAttachOptions lhs, GtkAttachOptions rhs) +{ + return static_cast<GtkAttachOptions>(static_cast<int>(lhs) | static_cast<int>(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<GtkAttachOptions>(0) : hexpand ? (GTK_EXPAND | GTK_FILL) : GTK_FILL; + GtkAttachOptions yoptions = centered ? static_cast<GtkAttachOptions>(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) { static GType type = 0; if (!type) { @@ -219,84 +314,86 @@ static cmsUInt16Number* getScratch() { return scritch; } -struct MapMap { - cmsUInt32Number space; - cmsUInt32Number inForm; -}; +colorspace::Component::Component() : + name(), + tip(), + scale(1) +{ +} + +colorspace::Component::Component(std::string const &name, std::string const &tip, guint scale) : + name(name), + tip(tip), + scale(scale) +{ +} + +std::vector<colorspace::Component> colorspace::getColorSpaceInfo( uint32_t space ) +{ + static std::map<cmsUInt32Number, std::vector<Component> > 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)); + + for (std::map<cmsUInt32Number, std::vector<Component> >::iterator it = sets.begin(); it != sets.end(); ++it) + { + knownColorspaces.insert(it->first); + maxColorspaceComponentCount = std::max(maxColorspaceComponentCount, it->second.size()); } } - namers = names[index]; - tippies = tips[index]; - scalies = scales[index]; + std::vector<Component> 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::Component> colorspace::getColorSpaceInfo( Inkscape::ColorProfile *prof ) +{ + return getColorSpaceInfo( asICColorSpaceSig(prof->getColorSpace()) ); } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -308,12 +405,7 @@ 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]), + _compUI(), _adj(0), _slider(0), _sbtn(0), @@ -352,12 +444,7 @@ 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 ); - gchar const** names = 0; - gchar const** tips = 0; - getThings( cmsSigRgbData, names, tips, _impl->_fooScales ); -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + _impl->_compUI.clear(); // Create components row = 0; @@ -370,15 +457,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); @@ -395,15 +474,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 ); @@ -414,84 +485,72 @@ void ColorICCSelector::init() row++; - for ( guint i = 0; i < _impl->_fooCount; i++ ) { - // Label + // populate the data for colorspaces and channels: #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - _impl->_fooLabel[i] = gtk_label_new_with_mnemonic( names[i] ); -#else - _impl->_fooLabel[i] = gtk_label_new_with_mnemonic( "." ); + std::vector<colorspace::Component> things = colorspace::getColorSpaceInfo( cmsSigRgbData ); #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] ); -#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); + for ( size_t i = 0; i < maxColorspaceComponentCount; i++ ) { +#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 - gtk_table_attach( GTK_TABLE (t), _impl->_fooLabel[i], 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); + _impl->_compUI.push_back(ComponentUI()); + + std::string labelStr = "."; #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 ); + + attachToGridOrTable(t, _impl->_compUI[i]._label, 0, row, 1, 1); + // Adjustment - gdouble step = static_cast<gdouble>(_impl->_fooScales[i]) / 100.0; - gdouble page = static_cast<gdouble>(_impl->_fooScales[i]) / 10.0; + guint scaleValue = _impl->_compUI[i]._component.scale; + gdouble step = static_cast<gdouble>(scaleValue) / 100.0; + gdouble page = static_cast<gdouble>(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->_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], tips[i] ); + 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); -#else - gtk_table_attach( GTK_TABLE (t), _impl->_fooSlider[i], 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->_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], tips[i] ); + 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); -#else - gtk_table_attach( GTK_TABLE (t), _impl->_fooBtn[i], 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->_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++; } @@ -501,15 +560,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)); @@ -519,16 +570,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 ), @@ -543,17 +585,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); @@ -596,7 +628,7 @@ void ColorICCSelectorImpl::_fixupHit( GtkWidget* /*src*/, gpointer data ) { ColorICCSelectorImpl* self = reinterpret_cast<ColorICCSelectorImpl*>(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) @@ -665,15 +697,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<colorspace::Component> 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); } @@ -711,7 +740,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("+_________________"); @@ -793,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<gdouble>(_impl->_fooScales[i]); + if ( _impl->_compUI[i]._component.scale == 256 ) { + val = (_color.icc->colors[i] + 128.0) / static_cast<gdouble>(_impl->_compUI[i]._component.scale); } else { - val = _color.icc->colors[i] / static_cast<gdouble>(_impl->_fooScales[i]); + val = _color.icc->colors[i] / static_cast<gdouble>(_impl->_compUI[i]._component.scale); } } tmp[i] = val * 0x0ffff; @@ -847,10 +876,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,39 +891,41 @@ 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 ); - if ( profChanged ) { + std::vector<colorspace::Component> 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(_fooLabel[i]), names[i]); + 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], tips[i] ); - gtk_widget_set_tooltip_text( _fooBtn[i], tips[i] ); + 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,13 +948,13 @@ 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<gdouble>(_fooScales[i]); + if ( _compUI[i]._component.scale == 256 ) { + val = (_owner->_color.icc->colors[i] + 128.0) / static_cast<gdouble>(_compUI[i]._component.scale); } else { - val = _owner->_color.icc->colors[i] / static_cast<gdouble>(_fooScales[i]); + val = _owner->_color.icc->colors[i] / static_cast<gdouble>(_compUI[i]._component.scale); } } - gtk_adjustment_set_value( _fooAdj[i], val ); + gtk_adjustment_set_value( _compUI[i]._adj, val ); } if ( _prof ) { @@ -933,7 +964,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; @@ -949,8 +980,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 ); } } } @@ -998,8 +1029,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; } @@ -1013,7 +1044,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}; @@ -1039,12 +1070,10 @@ 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] ); - if ( iccSelector->_impl->_fooScales ) { - val *= iccSelector->_impl->_fooScales[i]; - if ( iccSelector->_impl->_fooScales[i] == 256 ) { - val -= 128; - } + gdouble val = ColorScales::getScaled( iccSelector->_impl->_compUI[i]._adj ); + val *= iccSelector->_impl->_compUI[i]._component.scale; + if ( iccSelector->_impl->_compUI[i]._component.scale == 256 ) { + val -= 128; } newColor.icc->colors.push_back( val ); } 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<size_t>(i) < _trackerList->len) ) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_buttons[i]), TRUE); + } } void ColorNotebook::_buttonClicked(GtkWidget *widget, SPColorNotebook *colorbook) diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index 7fca56f56..87ca80f2f 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -17,6 +17,10 @@ #include <cstring> #include <string> +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/label.h> diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index 62fa47603..2d1c932d3 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 <gtkmm/icontheme.h> #include <gtkmm/adjustment.h> #include "ui/widget/spinbutton.h" #include "stroke-style.h" @@ -56,14 +57,11 @@ 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); - 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(); @@ -559,12 +557,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 02038ea42..27ac76d6f 100644 --- a/src/widgets/stroke-marker-selector.h +++ b/src/widgets/stroke-marker-selector.h @@ -10,6 +10,14 @@ * 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 <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/combobox.h> #include <gtkmm/liststore.h> @@ -60,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 { @@ -91,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<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>( sigc::ptr_fun(&StrokeStyle::markerSelectCB), startMarkerCombo, this, SP_MARKER_LOC_START)); startMarkerCombo->show(); -#if WITH_GTKMM_3_0 - startMarkerCombo->set_hexpand(); - startMarkerCombo->set_halign(Gtk::ALIGN_FILL); - startMarkerCombo->set_valign(Gtk::ALIGN_CENTER); - table->attach(*startMarkerCombo, 1, i, 3, 1); -#else - table->attach(*startMarkerCombo, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0); -#endif - - i++; + 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<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>( sigc::ptr_fun(&StrokeStyle::markerSelectCB), midMarkerCombo, this, SP_MARKER_LOC_MID)); midMarkerCombo->show(); -#if WITH_GTKMM_3_0 - midMarkerCombo->set_hexpand(); - midMarkerCombo->set_halign(Gtk::ALIGN_FILL); - midMarkerCombo->set_valign(Gtk::ALIGN_CENTER); - table->attach(*midMarkerCombo, 1, i, 3, 1); -#else - table->attach(*midMarkerCombo, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0); -#endif - - i++; + 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<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>( sigc::ptr_fun(&StrokeStyle::markerSelectCB), endMarkerCombo, this, SP_MARKER_LOC_END)); endMarkerCombo->show(); -#if WITH_GTKMM_3_0 - endMarkerCombo->set_hexpand(); - endMarkerCombo->set_halign(Gtk::ALIGN_FILL); - endMarkerCombo->set_valign(Gtk::ALIGN_CENTER); - table->attach(*endMarkerCombo, 1, i, 3, 1); -#else - table->attach(*endMarkerCombo, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0); -#endif - - i++; + hb->pack_start(*endMarkerCombo, true, true, 0); setDesktop(desktop); updateLine(); diff --git a/src/widgets/swatch-selector.h b/src/widgets/swatch-selector.h index 4b7aa483f..c8c9983a6 100644 --- a/src/widgets/swatch-selector.h +++ b/src/widgets/swatch-selector.h @@ -1,6 +1,14 @@ #ifndef SEEN_SP_SWATCH_SELECTOR_H #define SEEN_SP_SWATCH_SELECTOR_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> class SPDocument; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index f03835e17..0fdf36d5f 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -29,6 +29,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/action.h> #include <gtkmm/actiongroup.h> 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 |
