summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 785664a)
raw | patch | inline | side by side (parent: 785664a)
author | joncruz <joncruz@users.sourceforge.net> | |
Mon, 16 Feb 2009 23:56:03 +0000 (23:56 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Mon, 16 Feb 2009 23:56:03 +0000 (23:56 +0000) |
src/dialogs/eek-preview.cpp | patch | blob | history | |
src/dialogs/eek-preview.h | patch | blob | history | |
src/dialogs/swatches.cpp | patch | blob | history |
index b562c2af574bc21035cd02a165aa4660e229a864..e0d0fb4e2d98c145f44c51bd4c2d838bd0e9cb76 100644 (file)
#include <gtk/gtk.h>
#include "eek-preview.h"
-#include "path-prefix.h"
#define PRIME_BUTTON_MAGIC_NUMBER 1
}
+void eek_preview_set_pixbuf( EekPreview* preview, GdkPixbuf* pixbuf )
+{
+ preview->_previewPixbuf = pixbuf;
+
+ gtk_widget_queue_draw(GTK_WIDGET(preview));
+}
+
+
GType eek_preview_get_type(void)
{
static GType preview_type = 0;
}
}
- if (preview->_isRemove){
+ if ( preview->_previewPixbuf ) {
GtkDrawingArea* da = &(preview->drawing);
GdkDrawable* drawable = (GdkDrawable*) (((GtkWidget*)da)->window);
- gint w,h;
+ gint w = 0;
+ gint h = 0;
gdk_drawable_get_size(drawable, &w, &h);
- 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_at_scale(localFilename, w, h, FALSE, &error);
- gdk_draw_pixbuf(drawable, 0, pixbuf, 0, 0, 0, 0, w, h, GDK_RGB_DITHER_NONE, 0, 0);
- g_free(localFilename);
- g_free(filepath);
+ gdk_draw_pixbuf( drawable, 0, preview->_previewPixbuf, 0, 0, 0, 0, w, h, GDK_RGB_DITHER_NONE, 0, 0 );
}
preview->_hot = FALSE;
preview->_within = FALSE;
preview->_takesFocus = FALSE;
- preview->_isRemove = FALSE;
preview->_prevstyle = PREVIEW_STYLE_ICON;
preview->_view = VIEW_TYPE_LIST;
preview->_size = PREVIEW_SIZE_SMALL;
preview->_ratio = 100;
+ preview->_previewPixbuf = 0;
+
/*
GdkColor color = {0};
color.red = (255 << 8) | 255;
index e01472f1e79e7106ae12239b607a8649cf305f3f..e4d935ae92395266a16e06c4d051eee6fb1af78b 100644 (file)
#ifndef SEEN_EEK_PREVIEW_H
#define SEEN_EEK_PREVIEW_H
+#include <gdk/gdkpixbuf.h>
#include <gtk/gtkdrawingarea.h>
G_BEGIN_DECLS
gboolean _hot;
gboolean _within;
gboolean _takesFocus;
- gboolean _isRemove;
PreviewStyle _prevstyle;
ViewType _view;
PreviewSize _size;
guint _ratio;
guint _linked;
+ GdkPixbuf* _previewPixbuf;
};
struct _EekPreviewClass
void eek_preview_set_details( EekPreview* splat, PreviewStyle prevstyle, ViewType view, PreviewSize size, guint ratio );
void eek_preview_set_color( EekPreview* splat, int r, int g, int b );
+void eek_preview_set_pixbuf( EekPreview* splat, GdkPixbuf* pixbuf );
void eek_preview_set_linked( EekPreview* splat, LinkType link );
LinkType eek_preview_get_linked( EekPreview* splat );
index 7ab5c099bd9874e95e3c8945f6ba8b194394d56c..4546efe132e9ef43298bb362646bc178e8611477 100644 (file)
--- a/src/dialogs/swatches.cpp
+++ b/src/dialogs/swatches.cpp
@@ -577,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)