Code

Move app-specific logic and file operations up from the lower level.
[inkscape.git] / src / dialogs / swatches.cpp
index 1a0db9a8a1c0c571b9100c70824a2facf8b24bd4..4546efe132e9ef43298bb362646bc178e8611477 100644 (file)
@@ -100,6 +100,12 @@ typedef enum {
     TEXT_DATA
 } colorFlavorType;
 
+//TODO: warning: deprecated conversion from string constant to ‘gchar*’
+//
+//Turn out to be warnings that we should probably leave in place. The
+// pointers/types used need to be read-only. So until we correct the using
+// code, those warnings are actually desired. They say "Hey! Fix this". We
+// definitely don't want to hide/ignore them. --JonCruz
 static const GtkTargetEntry sourceColorEntries[] = {
 #if ENABLE_MAGIC_COLORS
 //    {"application/x-inkscape-color-id", GTK_TARGET_SAME_APP, APP_X_INKY_COLOR_ID},
@@ -347,6 +353,12 @@ static void dieDieDie( GtkObject *obj, gpointer user_data )
     g_message("die die die %p  %p", obj, user_data );
 }
 
+//TODO: warning: deprecated conversion from string constant to ‘gchar*’
+//
+//Turn out to be warnings that we should probably leave in place. The
+// pointers/types used need to be read-only. So until we correct the using
+// code, those warnings are actually desired. They say "Hey! Fix this". We
+// definitely don't want to hide/ignore them. --JonCruz
 static const GtkTargetEntry destColorTargets[] = {
 #if ENABLE_MAGIC_COLORS
 //    {"application/x-inkscape-color-id", GTK_TARGET_SAME_APP, APP_X_INKY_COLOR_ID},
@@ -565,7 +577,25 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewS
         Gtk::Widget* newBlot = Glib::wrap(eekWidget);
 
         eek_preview_set_color( preview, (def.getR() << 8) | def.getR(), (def.getG() << 8) | def.getG(), (def.getB() << 8) | def.getB());
-        preview->_isRemove = _isRemove;
+        if ( _isRemove ) {
+            GError *error = NULL;
+            gchar *filepath = (gchar *) g_strdup_printf("%s/remove-color.png", INKSCAPE_PIXMAPDIR);
+            gsize bytesRead = 0;
+            gsize bytesWritten = 0;
+            gchar *localFilename = g_filename_from_utf8( filepath,
+                                                 -1,
+                                                 &bytesRead,
+                                                 &bytesWritten,
+                                                 &error);
+            GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(localFilename, &error);
+            if (!pixbuf) {
+                g_warning("Null pixbuf for %p [%s]", localFilename, localFilename );
+            }
+            g_free(localFilename);
+            g_free(filepath);
+
+            eek_preview_set_pixbuf( preview, pixbuf );
+        }
 
         eek_preview_set_details( preview, (::PreviewStyle)style, (::ViewType)view, (::PreviewSize)size, ratio );
         eek_preview_set_linked( preview, (LinkType)((_linkSrc ? PREVIEW_LINK_IN:0)
@@ -710,7 +740,7 @@ static char* trim( char* str ) {
         str++;
     }
     str--;
-    while ( str > ret && ( *str == ' ' || *str == '\t' ) || *str == '\r' || *str == '\n' ) {
+    while ( str > ret && (( *str == ' ' || *str == '\t' ) || *str == '\r' || *str == '\n') ) {
         *str-- = 0;
     }
     return ret;