summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2009-03-05 08:11:54 +0000
committerjoncruz <joncruz@users.sourceforge.net>2009-03-05 08:11:54 +0000
commit31c5e23a0b6c91c2765b9e111c29c6debf86004a (patch)
tree912bfd7c32a1556fca7f6f73cb1bff747b96a994 /src
parentControl when shift affects moving of handles. Applies patch from bug #245698. (diff)
downloadinkscape-31c5e23a0b6c91c2765b9e111c29c6debf86004a.tar.gz
inkscape-31c5e23a0b6c91c2765b9e111c29c6debf86004a.zip
Adding clear-color swatch to complement no-color.
(bzr r7422)
Diffstat (limited to 'src')
-rw-r--r--src/interface.cpp5
-rw-r--r--src/ui/dialog/swatches.cpp38
-rw-r--r--src/ui/dialog/swatches.h3
-rw-r--r--src/widgets/eek-color-def.cpp21
-rw-r--r--src/widgets/eek-color-def.h1
5 files changed, 56 insertions, 12 deletions
diff --git a/src/interface.cpp b/src/interface.cpp
index e7a3d6f28..f03df2917 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -77,7 +77,8 @@ typedef enum {
IMAGE_DATA,
APP_X_INKY_COLOR,
APP_X_COLOR,
- APP_X_NOCOLOR
+ APP_X_NOCOLOR,
+ APP_X_XCOLOR
} ui_drop_target_info;
static GtkTargetEntry ui_drop_target_entries [] = {
@@ -90,6 +91,7 @@ static GtkTargetEntry ui_drop_target_entries [] = {
{(gchar *)"application/x-inkscape-color", 0, APP_X_INKY_COLOR},
#endif // ENABLE_MAGIC_COLORS
{(gchar *)"application/x-inkscape-nocolor", 0, APP_X_NOCOLOR },
+ {(gchar *)"application/x-inkscape-xcolor", 0, APP_X_XCOLOR },
{(gchar *)"application/x-color", 0, APP_X_COLOR }
};
@@ -1236,6 +1238,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
break;
case APP_X_NOCOLOR:
+ case APP_X_XCOLOR:
{
gchar* c = g_strdup("none"); // temp
int destX = 0;
diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp
index 1a5ef8521..5cd357673 100644
--- a/src/ui/dialog/swatches.cpp
+++ b/src/ui/dialog/swatches.cpp
@@ -41,9 +41,8 @@ namespace Inkscape {
namespace UI {
namespace Dialogs {
-// create a None color swatch
-ColorItem::ColorItem() :
- def(),
+ColorItem::ColorItem(eek::ColorDef::ColorType type) :
+ def(type),
_isLive(false),
_linkIsTone(false),
_linkPercent(0),
@@ -106,6 +105,7 @@ typedef enum {
APP_X_INKY_COLOR = 0,
APP_X_COLOR,
APP_X_NOCOLOR,
+ APP_X_XCOLOR,
TEXT_DATA
} colorFlavorType;
@@ -130,6 +130,12 @@ static const GtkTargetEntry sourceNoColorEntries[] = {
{"text/plain", 0, TEXT_DATA},
};
+static const GtkTargetEntry sourceClearColorEntries[] = {
+ {"application/x-inkscape-xcolor", 0, APP_X_XCOLOR},
+ {"application/x-color", 0, APP_X_COLOR},
+ {"text/plain", 0, TEXT_DATA},
+};
+
void ColorItem::_dragGetColorData( GtkWidget */*widget*/,
GdkDragContext */*drag_context*/,
GtkSelectionData *data,
@@ -196,7 +202,7 @@ void ColorItem::_dragGetColorData( GtkWidget */*widget*/,
reinterpret_cast<const guchar*>(tmp),
itemCount * 2);
delete[] tmp;
- } else if ( info == APP_X_NOCOLOR ) {
+ } else if ( (info == APP_X_NOCOLOR) || (info == APP_X_XCOLOR) ) {
Glib::ustring paletteName;
// Find where this thing came from
@@ -445,6 +451,7 @@ void ColorItem::_dropDataIn( GtkWidget */*widget*/,
break;
}
case APP_X_NOCOLOR:
+ case APP_X_XCOLOR:
{
// g_message("APP_X_NOCOLOR dropping through to x-color");
}
@@ -695,9 +702,10 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewS
gtk_drag_source_set( GTK_WIDGET(newBlot->gobj()),
GDK_BUTTON1_MASK,
- (def.getType() != eek::ColorDef::RGB) ? sourceNoColorEntries :
- sourceColorEntries,
- (def.getType() != eek::ColorDef::RGB) ? G_N_ELEMENTS(sourceNoColorEntries) :
+ (def.getType() == eek::ColorDef::CLEAR) ? sourceClearColorEntries :
+ (def.getType() == eek::ColorDef::NONE) ? sourceNoColorEntries : sourceColorEntries,
+ (def.getType() == eek::ColorDef::CLEAR) ? G_N_ELEMENTS(sourceClearColorEntries) :
+ (def.getType() == eek::ColorDef::NONE) ? G_N_ELEMENTS(sourceNoColorEntries) :
G_N_ELEMENTS(sourceColorEntries),
GdkDragAction(GDK_ACTION_MOVE | GDK_ACTION_COPY) );
@@ -1154,7 +1162,8 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) :
{
Gtk::RadioMenuItem* hotItem = 0;
_holder = new PreviewHolder();
- _remove = new ColorItem();
+ _clear = new ColorItem( eek::ColorDef::CLEAR );
+ _remove = new ColorItem( eek::ColorDef::NONE );
loadEmUp();
if ( !possible.empty() ) {
JustForNow* first = 0;
@@ -1180,6 +1189,7 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) :
_holder->setColumnPref( first->_prefWidth );
}
_holder->freezeUpdates();
+ // TODO restore once 'clear' works _holder->addPreview(_clear);
_holder->addPreview(_remove);
for ( std::vector<ColorItem*>::iterator it = first->_colors.begin(); it != first->_colors.end(); it++ ) {
_holder->addPreview(*it);
@@ -1214,8 +1224,15 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) :
SwatchesPanel::~SwatchesPanel()
{
- if (_remove) delete _remove;
- if (_holder) delete _holder;
+ if ( _clear ) {
+ delete _clear;
+ }
+ if ( _remove ) {
+ delete _remove;
+ }
+ if ( _holder ) {
+ delete _holder;
+ }
}
void SwatchesPanel::setOrientation( Gtk::AnchorType how )
@@ -1247,6 +1264,7 @@ void SwatchesPanel::_handleAction( int setId, int itemId )
_holder->setColumnPref( curr->_prefWidth );
}
_holder->freezeUpdates();
+ _holder->addPreview(_clear);
_holder->addPreview(_remove);
for ( std::vector<ColorItem*>::iterator it = curr->_colors.begin(); it != curr->_colors.end(); it++ ) {
_holder->addPreview(*it);
diff --git a/src/ui/dialog/swatches.h b/src/ui/dialog/swatches.h
index 17081733d..560719ed2 100644
--- a/src/ui/dialog/swatches.h
+++ b/src/ui/dialog/swatches.h
@@ -31,7 +31,7 @@ class ColorItem : public Inkscape::UI::Previewable
{
friend void _loadPaletteFile( gchar const *filename );
public:
- ColorItem();
+ ColorItem( eek::ColorDef::ColorType type );
ColorItem( unsigned int r, unsigned int g, unsigned int b,
Glib::ustring& name );
virtual ~ColorItem();
@@ -101,6 +101,7 @@ private:
static SwatchesPanel* instance;
PreviewHolder* _holder;
+ ColorItem* _clear;
ColorItem* _remove;
};
diff --git a/src/widgets/eek-color-def.cpp b/src/widgets/eek-color-def.cpp
index d7cb41b38..6334061c2 100644
--- a/src/widgets/eek-color-def.cpp
+++ b/src/widgets/eek-color-def.cpp
@@ -62,6 +62,27 @@ ColorDef::ColorDef() :
{
}
+ColorDef::ColorDef( ColorType type ) :
+ descr(),
+ type(type),
+ r(0),
+ g(0),
+ b(0),
+ editable(false)
+{
+ switch (type) {
+ case CLEAR:
+ descr = _("remove");
+ break;
+ case NONE:
+ descr = _("none");
+ break;
+ case RGB:
+ descr = "";
+ break;
+ }
+}
+
ColorDef::ColorDef( unsigned int r, unsigned int g, unsigned int b, const std::string& description ) :
descr(description),
type(RGB),
diff --git a/src/widgets/eek-color-def.h b/src/widgets/eek-color-def.h
index 764a28b12..7e54182d6 100644
--- a/src/widgets/eek-color-def.h
+++ b/src/widgets/eek-color-def.h
@@ -55,6 +55,7 @@ public:
enum ColorType{CLEAR, NONE, RGB};
ColorDef();
+ ColorDef(ColorType type);
ColorDef( unsigned int r, unsigned int g, unsigned int b, const std::string& description );
virtual ~ColorDef();