index a4b9a0d7d12ef2e3205e70b5e72208706d35df38..3a41c1ec4a4629b096f828952bd921657a997711 100644 (file)
--- a/src/dialogs/swatches.cpp
+++ b/src/dialogs/swatches.cpp
#include "path-prefix.h"
#include "swatches.h"
#include "sp-item.h"
#include "path-prefix.h"
#include "swatches.h"
#include "sp-item.h"
+#include "prefs-utils.h"
#include "eek-preview.h"
#include "eek-preview.h"
} colorFlavorType;
static const GtkTargetEntry sourceColorEntries[] = {
} 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},
// {"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},
};
{"application/x-color", 0, APP_X_COLOR},
{"text/plain", 0, TEXT_DATA},
};
guint time,
gpointer user_data)
{
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);
static GdkAtom typeXColor = gdk_atom_intern("application/x-color", FALSE);
static GdkAtom typeText = gdk_atom_intern("text/plain", FALSE);
static void dragBegin( GtkWidget *widget, GdkDragContext* dc, gpointer data )
{
static void dragBegin( GtkWidget *widget, GdkDragContext* dc, gpointer data )
{
+ (void)widget;
ColorItem* item = reinterpret_cast<ColorItem*>(data);
if ( item )
{
ColorItem* item = reinterpret_cast<ColorItem*>(data);
if ( item )
{
// return TRUE;
// }
// return TRUE;
// }
-static void bouncy( GtkWidget* widget, gpointer callback_data ) {
- ColorItem* item = reinterpret_cast<ColorItem*>(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<ColorItem*>(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<ColorItem*>(callback_data);
- if ( item ) {
- item->buttonClicked(true);
- }
+ return FALSE; /* we did not handle this */
}
static void dieDieDie( GtkObject *obj, gpointer user_data )
}
static void dieDieDie( GtkObject *obj, gpointer user_data )
}
static const GtkTargetEntry destColorTargets[] = {
}
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},
// {"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},
};
{"application/x-color", 0, APP_X_COLOR},
};
guint event_time,
gpointer user_data)
{
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:
// g_message(" droppy droppy %d", info);
switch (info) {
case APP_X_INKY_COLOR:
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if ( desktop ) {
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if ( desktop ) {
- SPDocument* document = SP_DT_DOCUMENT( desktop );
+ SPDocument* document = sp_desktop_document( desktop );
Inkscape::XML::Node *rroot = sp_document_repr_root( document );
if ( rroot ) {
Inkscape::XML::Node *rroot = sp_document_repr_root( document );
if ( rroot ) {
str = 0;
if ( bruteForce( document, rroot, paletteName, item->def.getR(), item->def.getG(), item->def.getB() ) ) {
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"));
}
}
}
}
}
}
}
}
-Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Gtk::BuiltinIconSize size)
+Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Inkscape::IconSize size)
{
Gtk::Widget* widget = 0;
if ( style == PREVIEW_STYLE_BLURB ) {
{
Gtk::Widget* widget = 0;
if ( style == PREVIEW_STYLE_BLURB ) {
@@ -435,7 +459,7 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Gtk::Built
widget = lbl;
} else {
Glib::ustring blank(" ");
widget = lbl;
} else {
Glib::ustring blank(" ");
- if ( size == Gtk::ICON_SIZE_MENU ) {
+ if ( size == Inkscape::ICON_SIZE_MENU || size == Inkscape::ICON_SIZE_DECORATION ) {
blank = " ";
}
blank = " ";
}
@@ -477,15 +501,10 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Gtk::Built
sigc::signal<void> type_signal_something;
*/
g_signal_connect( G_OBJECT(newBlot->gobj()),
sigc::signal<void> type_signal_something;
*/
g_signal_connect( G_OBJECT(newBlot->gobj()),
- "clicked",
- G_CALLBACK(bouncy),
- this);
-
- g_signal_connect( G_OBJECT(newBlot->gobj()),
- "alt-clicked",
- G_CALLBACK(bouncy2),
+ "button-release-event",
+ G_CALLBACK(onButtonPressed),
this);
this);
-
+
gtk_drag_source_set( GTK_WIDGET(newBlot->gobj()),
GDK_BUTTON1_MASK,
sourceColorEntries,
gtk_drag_source_set( GTK_WIDGET(newBlot->gobj()),
GDK_BUTTON1_MASK,
sourceColorEntries,
sp_desktop_set_style(desktop, css);
sp_repr_css_attr_unref(css);
sp_desktop_set_style(desktop, css);
sp_repr_css_attr_unref(css);
- sp_document_done (SP_DT_DOCUMENT (desktop));
+ sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_SWATCHES,
+ secondary? _("Set stroke color from swatch") : _("Set fill color from swatch"));
}
}
}
}
static bool getBlock( std::string& dst, guchar ch, std::string const str )
{
bool good = false;
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 )
{
if ( pos != std::string::npos )
{
- size_t pos2 = str.find( '(', pos );
+ std::string::size_type pos2 = str.find( '(', pos );
if ( pos2 != std::string::npos ) {
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;
if ( endPos != std::string::npos ) {
dst = str.substr( pos2 + 1, (endPos - pos2 - 1) );
good = true;
static bool popVal( guint64& numVal, std::string& str )
{
bool good = false;
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();
}
if ( endPos == std::string::npos ) {
endPos = str.length();
}
{
for ( std::vector<ColorItem*>::iterator it = onceMore->_colors.begin(); it != onceMore->_colors.end(); ++it )
{
{
for ( std::vector<ColorItem*>::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 );
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 );
if ( endPos != std::string::npos )
{
subby.erase( endPos );
} while ( result && !hasErr );
if ( !hasErr ) {
possible.push_back(onceMore);
} while ( result && !hasErr );
if ( !hasErr ) {
possible.push_back(onceMore);
+#if ENABLE_MAGIC_COLORS
ColorItem::_wireMagicColors( onceMore );
ColorItem::_wireMagicColors( onceMore );
+#endif // ENABLE_MAGIC_COLORS
} else {
delete onceMore;
}
} else {
delete onceMore;
}
std::list<gchar *> sources;
sources.push_back( profile_path("palettes") );
sources.push_back( g_strdup(INKSCAPE_PALETTESDIR) );
std::list<gchar *> sources;
sources.push_back( profile_path("palettes") );
sources.push_back( g_strdup(INKSCAPE_PALETTESDIR) );
+ sources.push_back( g_strdup(CREATE_PALETTESDIR) );
// Use this loop to iterate through a list of possible document locations.
while (!sources.empty()) {
// Use this loop to iterate through a list of possible document locations.
while (!sources.empty()) {
gchar *filename = 0;
while ((filename = (gchar *)g_dir_read_name(directory)) != NULL) {
gchar* lower = g_ascii_strdown( filename, -1 );
gchar *filename = 0;
while ((filename = (gchar *)g_dir_read_name(directory)) != NULL) {
gchar* lower = g_ascii_strdown( filename, -1 );
- if ( g_str_has_suffix(lower, ".gpl") ) {
+// if ( g_str_has_suffix(lower, ".gpl") ) {
gchar* full = g_build_filename(dirname, filename, NULL);
if ( !Inkscape::IO::file_test( full, (GFileTest)(G_FILE_TEST_IS_DIR ) ) ) {
_loadPaletteFile(full);
}
g_free(full);
gchar* full = g_build_filename(dirname, filename, NULL);
if ( !Inkscape::IO::file_test( full, (GFileTest)(G_FILE_TEST_IS_DIR ) ) ) {
_loadPaletteFile(full);
}
g_free(full);
- }
+// }
g_free(lower);
}
g_dir_close(directory);
g_free(lower);
}
g_dir_close(directory);
/**
* Constructor
*/
/**
* Constructor
*/
-SwatchesPanel::SwatchesPanel() :
- Inkscape::UI::Widget::Panel ("dialogs.swatches"),
+SwatchesPanel::SwatchesPanel(gchar const* prefsPath) :
+ Inkscape::UI::Widget::Panel( Glib::ustring(), prefsPath, true ),
_holder(0)
{
_holder(0)
{
+ Gtk::RadioMenuItem* hotItem = 0;
_holder = new PreviewHolder();
loadEmUp();
if ( !possible.empty() ) {
_holder = new PreviewHolder();
loadEmUp();
if ( !possible.empty() ) {
- JustForNow* first = possible.front();
+ JustForNow* first = 0;
+ gchar const* targetName = 0;
+ if ( _prefs_path ) {
+ targetName = prefs_get_string_attribute( _prefs_path, "palette" );
+ if ( targetName ) {
+ for ( std::vector<JustForNow*>::iterator iter = possible.begin(); iter != possible.end(); ++iter ) {
+ if ( (*iter)->_name == targetName ) {
+ first = *iter;
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !first ) {
+ first = possible.front();
+ }
+
if ( first->_prefWidth > 0 ) {
_holder->setColumnPref( first->_prefWidth );
}
if ( first->_prefWidth > 0 ) {
_holder->setColumnPref( first->_prefWidth );
}
for ( std::vector<JustForNow*>::iterator it = possible.begin(); it != possible.end(); it++ ) {
JustForNow* curr = *it;
Gtk::RadioMenuItem* single = manage(new Gtk::RadioMenuItem(groupOne, curr->_name));
for ( std::vector<JustForNow*>::iterator it = possible.begin(); it != possible.end(); it++ ) {
JustForNow* curr = *it;
Gtk::RadioMenuItem* single = manage(new Gtk::RadioMenuItem(groupOne, curr->_name));
+ if ( curr == first ) {
+ hotItem = single;
+ }
_regItem( single, 3, i );
i++;
}
_regItem( single, 3, i );
i++;
}
show_all_children();
restorePanelPrefs();
show_all_children();
restorePanelPrefs();
+ if ( hotItem ) {
+ hotItem->set_active();
+ }
}
SwatchesPanel::~SwatchesPanel()
}
SwatchesPanel::~SwatchesPanel()
if ( itemId >= 0 && itemId < static_cast<int>(possible.size()) ) {
_holder->clear();
JustForNow* curr = possible[itemId];
if ( itemId >= 0 && itemId < static_cast<int>(possible.size()) ) {
_holder->clear();
JustForNow* curr = possible[itemId];
+
+ if ( _prefs_path ) {
+ prefs_set_string_attribute( _prefs_path, "palette", curr->_name.c_str() );
+ }
+
if ( curr->_prefWidth > 0 ) {
_holder->setColumnPref( curr->_prefWidth );
}
if ( curr->_prefWidth > 0 ) {
_holder->setColumnPref( curr->_prefWidth );
}