X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fdialogs%2Fswatches.cpp;h=3a41c1ec4a4629b096f828952bd921657a997711;hb=569ef8f6dbacc8a8b0b933d02a806c2e091ce02b;hp=dc9b6fdd6db8ec0f24441ad2e736055bd4acaa82;hpb=223dd8606cfef68f6cc762e7a8d02115c0141240;p=inkscape.git diff --git a/src/dialogs/swatches.cpp b/src/dialogs/swatches.cpp index dc9b6fdd6..3a41c1ec4 100644 --- a/src/dialogs/swatches.cpp +++ b/src/dialogs/swatches.cpp @@ -98,10 +98,10 @@ typedef enum { } colorFlavorType; static const GtkTargetEntry sourceColorEntries[] = { -#if ENABLE_LCMS +#if ENABLE_MAGIC_COLORS // {"application/x-inkscape-color-id", GTK_TARGET_SAME_APP, APP_X_INKY_COLOR_ID}, {"application/x-inkscape-color", 0, APP_X_INKY_COLOR}, -#endif // ENABLE_LCMS +#endif // ENABLE_MAGIC_COLORS {"application/x-color", 0, APP_X_COLOR}, {"text/plain", 0, TEXT_DATA}, }; @@ -113,6 +113,9 @@ void ColorItem::_dragGetColorData( GtkWidget *widget, guint time, gpointer user_data) { + (void)widget; + (void)drag_context; + (void)time; static GdkAtom typeXColor = gdk_atom_intern("application/x-color", FALSE); static GdkAtom typeText = gdk_atom_intern("text/plain", FALSE); @@ -188,6 +191,7 @@ void ColorItem::_dragGetColorData( GtkWidget *widget, static void dragBegin( GtkWidget *widget, GdkDragContext* dc, gpointer data ) { + (void)widget; ColorItem* item = reinterpret_cast(data); if ( item ) { @@ -214,18 +218,31 @@ static void dragBegin( GtkWidget *widget, GdkDragContext* dc, gpointer data ) // return TRUE; // } -static void bouncy( GtkWidget* widget, gpointer callback_data ) { - ColorItem* item = reinterpret_cast(callback_data); - if ( item ) { - item->buttonClicked(false); +static gboolean onButtonPressed (GtkWidget *widget, GdkEventButton *event, gpointer userdata) +{ + (void)widget; + /* single click with the right mouse button? */ + if(event->type == GDK_BUTTON_RELEASE) + { + ColorItem* item = reinterpret_cast(userdata); + if(item) + { + if (event->button == 1) + { + if(event->state & GDK_SHIFT_MASK) + item->buttonClicked(true); /* the button was pressed with shift held down. set the stroke */ + else item->buttonClicked(false); + return TRUE; /* we handled this */ + } + else if (event->button == 3) + { + item->buttonClicked(true); + return TRUE; /* we handled this */ + } + } } -} -static void bouncy2( GtkWidget* widget, gint arg1, gpointer callback_data ) { - ColorItem* item = reinterpret_cast(callback_data); - if ( item ) { - item->buttonClicked(true); - } + return FALSE; /* we did not handle this */ } static void dieDieDie( GtkObject *obj, gpointer user_data ) @@ -234,10 +251,10 @@ static void dieDieDie( GtkObject *obj, gpointer user_data ) } static const GtkTargetEntry destColorTargets[] = { -#if ENABLE_LCMS +#if ENABLE_MAGIC_COLORS // {"application/x-inkscape-color-id", GTK_TARGET_SAME_APP, APP_X_INKY_COLOR_ID}, {"application/x-inkscape-color", 0, APP_X_INKY_COLOR}, -#endif // ENABLE_LCMS +#endif // ENABLE_MAGIC_COLORS {"application/x-color", 0, APP_X_COLOR}, }; @@ -251,6 +268,11 @@ void ColorItem::_dropDataIn( GtkWidget *widget, guint event_time, gpointer user_data) { + (void)widget; + (void)drag_context; + (void)x; + (void)y; + (void)event_time; // g_message(" droppy droppy %d", info); switch (info) { case APP_X_INKY_COLOR: @@ -417,7 +439,8 @@ void ColorItem::_colorDefChanged(void* data) str = 0; if ( bruteForce( document, rroot, paletteName, item->def.getR(), item->def.getG(), item->def.getB() ) ) { - sp_document_done( document ); + sp_document_done( document , SP_VERB_DIALOG_SWATCHES, + _("Change color definition")); } } } @@ -478,15 +501,10 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Inkscape:: sigc::signal type_signal_something; */ g_signal_connect( G_OBJECT(newBlot->gobj()), - "clicked", - G_CALLBACK(bouncy), + "button-release-event", + G_CALLBACK(onButtonPressed), this); - - g_signal_connect( G_OBJECT(newBlot->gobj()), - "alt-clicked", - G_CALLBACK(bouncy2), - this); - + gtk_drag_source_set( GTK_WIDGET(newBlot->gobj()), GDK_BUTTON1_MASK, sourceColorEntries, @@ -551,7 +569,8 @@ void ColorItem::buttonClicked(bool secondary) sp_desktop_set_style(desktop, css); sp_repr_css_attr_unref(css); - sp_document_done (sp_desktop_document (desktop)); + sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_SWATCHES, + secondary? _("Set stroke color from swatch") : _("Set fill color from swatch")); } } @@ -594,12 +613,12 @@ bool parseNum( char*& str, int& val ) { static bool getBlock( std::string& dst, guchar ch, std::string const str ) { bool good = false; - size_t pos = str.find(ch); + std::string::size_type pos = str.find(ch); if ( pos != std::string::npos ) { - size_t pos2 = str.find( '(', pos ); + std::string::size_type pos2 = str.find( '(', pos ); if ( pos2 != std::string::npos ) { - size_t endPos = str.find( ')', pos2 ); + std::string::size_type endPos = str.find( ')', pos2 ); if ( endPos != std::string::npos ) { dst = str.substr( pos2 + 1, (endPos - pos2 - 1) ); good = true; @@ -612,7 +631,7 @@ static bool getBlock( std::string& dst, guchar ch, std::string const str ) static bool popVal( guint64& numVal, std::string& str ) { bool good = false; - size_t endPos = str.find(','); + std::string::size_type endPos = str.find(','); if ( endPos == std::string::npos ) { endPos = str.length(); } @@ -642,11 +661,11 @@ void ColorItem::_wireMagicColors( void* p ) { for ( std::vector::iterator it = onceMore->_colors.begin(); it != onceMore->_colors.end(); ++it ) { - size_t pos = (*it)->def.descr.find("*{"); + std::string::size_type pos = (*it)->def.descr.find("*{"); if ( pos != std::string::npos ) { std::string subby = (*it)->def.descr.substr( pos + 2 ); - size_t endPos = subby.find("}*"); + std::string::size_type endPos = subby.find("}*"); if ( endPos != std::string::npos ) { subby.erase( endPos ); @@ -837,7 +856,9 @@ void _loadPaletteFile( gchar const *filename ) } while ( result && !hasErr ); if ( !hasErr ) { possible.push_back(onceMore); +#if ENABLE_MAGIC_COLORS ColorItem::_wireMagicColors( onceMore ); +#endif // ENABLE_MAGIC_COLORS } else { delete onceMore; }