/*========================================================*/
struct _glLabelImagePrivate {
- gchar *filename;
+ glTextNode *filename;
GdkPixbuf *pixbuf;
};
{
glLabelImage *limage = (glLabelImage *)src_object;
glLabelImage *new_limage = (glLabelImage *)dst_object;
- gchar *filename;
+ glTextNode *filename;
gl_debug (DEBUG_LABEL, "START");
filename = gl_label_image_get_filename (limage);
gl_label_image_set_filename (new_limage, filename);
- g_free (filename);
+ gl_text_node_free (&filename);
gl_debug (DEBUG_LABEL, "END");
}
/*****************************************************************************/
void
gl_label_image_set_filename (glLabelImage *limage,
- const gchar *filename)
+ glTextNode *filename)
{
GdkPixbuf *pixbuf;
g_return_if_fail (limage && GL_IS_LABEL_IMAGE (limage));
- if ( filename == NULL ) {
+ if ( (filename == NULL) || filename->field_flag ) {
- g_free (limage->private->filename);
- limage->private->filename = NULL;
+ gl_text_node_free (&limage->private->filename);
+ limage->private->filename = gl_text_node_dup(filename);
g_object_unref (limage->private->pixbuf);
limage->private->pixbuf =
} else {
if ( (limage->private->filename == NULL) ||
- (strcmp (limage->private->filename, filename) != 0) ) {
+ (strcmp (limage->private->filename->data, filename->data) != 0) ) {
- g_free (limage->private->filename);
- limage->private->filename = g_strdup (filename);
+ gl_text_node_free (&limage->private->filename);
+ limage->private->filename = gl_text_node_dup (filename);
- pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
+ pixbuf = gdk_pixbuf_new_from_file (filename->data, NULL);
g_object_unref (limage->private->pixbuf);
if ( pixbuf != NULL ) {
limage->private->pixbuf = pixbuf;
/*****************************************************************************/
/* Get object params. */
/*****************************************************************************/
-gchar *
+glTextNode *
gl_label_image_get_filename (glLabelImage *limage)
{
g_return_val_if_fail (limage && GL_IS_LABEL_IMAGE (limage), NULL);
- return g_strdup (limage->private->filename);
+ return gl_text_node_dup (limage->private->filename);
}
const GdkPixbuf *
-gl_label_image_get_pixbuf (glLabelImage *limage)
+gl_label_image_get_pixbuf (glLabelImage *limage,
+ glMergeRecord *record)
{
+ GdkPixbuf *pixbuf = NULL;
+ gchar *real_filename;
+
g_return_val_if_fail (limage && GL_IS_LABEL_IMAGE (limage), NULL);
+ if ((record != NULL) && limage->private->filename->field_flag) {
+
+ /* Indirect filename, re-evaluate for given record. */
+
+ real_filename = gl_merge_eval_key (record,
+ limage->private->filename->data);
+
+ if (real_filename != NULL) {
+ pixbuf = gdk_pixbuf_new_from_file (real_filename, NULL);
+ }
+ g_object_unref (limage->private->pixbuf);
+ if ( pixbuf != NULL ) {
+ limage->private->pixbuf = pixbuf;
+ } else {
+ limage->private->pixbuf =
+ gdk_pixbuf_new_from_xpm_data ((const char **)
+ checkerboard_xpm);
+ }
+
+ }
+
return limage->private->pixbuf;
}
#define __LABEL_IMAGE_H__
#include "label-object.h"
+#include "text-node.h"
+#include "merge.h"
#include "gdk-pixbuf/gdk-pixbuf.h"
G_BEGIN_DECLS
GType gl_label_image_get_type (void);
-GObject *gl_label_image_new (glLabel *label);
+GObject *gl_label_image_new (glLabel *label);
-void gl_label_image_set_filename (glLabelImage *limage,
- const gchar *filename);
+void gl_label_image_set_filename (glLabelImage *limage,
+ glTextNode *filename);
-gchar *gl_label_image_get_filename (glLabelImage *limage);
+glTextNode *gl_label_image_get_filename (glLabelImage *limage);
-const GdkPixbuf *gl_label_image_get_pixbuf (glLabelImage *limage);
+const GdkPixbuf *gl_label_image_get_pixbuf (glLabelImage *limage,
+ glMergeRecord *record);
G_END_DECLS
glLabelEllipse *object);
static void draw_image_object (PrintInfo *pi,
- glLabelImage *object);
+ glLabelImage *object,
+ glMergeRecord *record);
static void draw_barcode_object (PrintInfo *pi,
glLabelBarcode *object,
} else if (GL_IS_LABEL_ELLIPSE(object)) {
draw_ellipse_object (pi, GL_LABEL_ELLIPSE(object));
} else if (GL_IS_LABEL_IMAGE(object)) {
- draw_image_object (pi, GL_LABEL_IMAGE(object));
+ draw_image_object (pi, GL_LABEL_IMAGE(object), record);
} else if (GL_IS_LABEL_BARCODE(object)) {
- draw_barcode_object (pi, GL_LABEL_BARCODE(object),
- record);
+ draw_barcode_object (pi, GL_LABEL_BARCODE(object), record);
}
gnome_print_grestore (pi->pc);
/* PRIVATE. Draw image object. */
/*---------------------------------------------------------------------------*/
static void
-draw_image_object (PrintInfo *pi,
- glLabelImage *object)
+draw_image_object (PrintInfo *pi,
+ glLabelImage *object,
+ glMergeRecord *record)
{
gdouble w, h;
const GdkPixbuf *pixbuf;
gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h);
- pixbuf = gl_label_image_get_pixbuf (object);
+ pixbuf = gl_label_image_get_pixbuf (object, record);
image_data = gdk_pixbuf_get_pixels (pixbuf);
image_w = gdk_pixbuf_get_width (pixbuf);
image_h = gdk_pixbuf_get_height (pixbuf);
{
glTextNode *dst;
+ if ( src == NULL ) return NULL;
+
dst = g_new0 (glTextNode, 1);
dst->field_flag = src->field_flag;
#include "view-highlight.h"
+#include "wdgt-image-select.h"
#include "wdgt-line.h"
#include "wdgt-fill.h"
#include "wdgt-size.h"
/* Query properties of object. */
gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h);
- pixbuf = gl_label_image_get_pixbuf(object);
+ pixbuf = gl_label_image_get_pixbuf(object, NULL);
/* Create analogous canvas item. */
view_image->private->item =
/* Query properties of object. */
gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h);
- pixbuf = gl_label_image_get_pixbuf (GL_LABEL_IMAGE(object));
+ pixbuf = gl_label_image_get_pixbuf (GL_LABEL_IMAGE(object), NULL);
/* Adjust appearance of analogous canvas item. */
gnome_canvas_item_set (view_image->private->item,
GtkWidget *dialog, *wsection, *wbutton;
glLabelObject *object;
gdouble x, y, w, h, label_width, label_height;
- gchar *filename;
+ glTextNode *filename;
+ glMerge *merge;
GtkSizeGroup *label_size_group;
GtkWidget *window;
filename = gl_label_image_get_filename (GL_LABEL_IMAGE(object));
gl_label_get_size (GL_LABEL(object->parent),
&label_width, &label_height);
+ merge = gl_label_get_merge (GL_LABEL(object->parent));
/*-----------------------------------------------------------------*/
/* Build dialog. */
/*---------------------------*/
wsection = gl_hig_category_new (_("Image"));
gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection);
- view_image->private->pixmap_entry =
- gnome_pixmap_entry_new ("image", "Load image", TRUE);
- gnome_pixmap_entry_set_preview_size (GNOME_PIXMAP_ENTRY
- (view_image->private->pixmap_entry),
- 128, 128);
-
- /* Set default path for image entry */
- if (filename != NULL) {
- /* Set default path to the directory containing image. */
- if (image_path != NULL)
- g_free (image_path);
- image_path = g_path_get_dirname (filename);
- if (image_path != NULL) {
- image_path = g_strconcat (image_path, "/", NULL);
- }
- } else if (image_path == NULL) {
- /* First time, set it to our CWD. */
- image_path = g_get_current_dir ();
- }
+ view_image->private->pixmap_entry =
+ gl_wdgt_image_select_new (merge, filename);
gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection),
view_image->private->pixmap_entry);
- g_signal_connect ( G_OBJECT(gnome_file_entry_gtk_entry
- (GNOME_FILE_ENTRY (view_image->private->pixmap_entry))),
- "changed", G_CALLBACK (file_changed_cb),
- view_image);
+ g_signal_connect ( G_OBJECT(view_image->private->pixmap_entry), "changed",
+ G_CALLBACK (file_changed_cb), view_image);
/*----------------------------*/
glViewImage *view_image)
{
glLabelObject *object;
- gchar *filename;
+ glTextNode *filename;
gl_debug (DEBUG_VIEW, "START");
object = gl_view_object_get_object (GL_VIEW_OBJECT(view_image));
- filename = gnome_pixmap_entry_get_filename (GNOME_PIXMAP_ENTRY(view_image->private->pixmap_entry));
- gl_debug (DEBUG_VIEW, "filename = %s", filename);
+ filename = gl_wdgt_image_select_get_data (GL_WDGT_IMAGE_SELECT(view_image->private->pixmap_entry));
+ gl_debug (DEBUG_VIEW, "filename = %s", filename->data);
g_signal_handlers_block_by_func (G_OBJECT(object),
update_dialog_cb, view_image);
g_signal_handlers_unblock_by_func (G_OBJECT(object),
update_dialog_cb, view_image);
- g_free (filename);
+ gl_text_node_free (&filename);
gl_debug (DEBUG_VIEW, "END");
}
gl_debug (DEBUG_VIEW, "START");
object = gl_view_object_get_object (GL_VIEW_OBJECT(view_image));
- pixbuf = gl_label_image_get_pixbuf (GL_LABEL_IMAGE(object));
+ pixbuf = gl_label_image_get_pixbuf (GL_LABEL_IMAGE(object), NULL);
image_w = gdk_pixbuf_get_width (pixbuf);
image_h = gdk_pixbuf_get_height (pixbuf);
update_dialog_cb (glLabelObject *object,
glViewImage *view_image)
{
- gchar *filename;
+ glTextNode *filename;
gdouble x, y, w, h;
+ glMerge *merge;
gl_debug (DEBUG_VIEW, "START");
gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h);
filename = gl_label_image_get_filename (GL_LABEL_IMAGE(object));
+ merge = gl_label_get_merge (GL_LABEL(object->parent));
/* Block widget handlers to prevent recursion */
g_signal_handlers_block_by_func (G_OBJECT(view_image->private->pixmap_entry),
/* Update widgets in property dialog */
if ( filename != NULL ) {
- gnome_file_entry_set_filename (GNOME_FILE_ENTRY (view_image->private->pixmap_entry),
+ gl_wdgt_image_select_set_data (GL_WDGT_IMAGE_SELECT(view_image->private->pixmap_entry),
+ (merge != NULL),
filename);
}
gl_wdgt_position_set_position (GL_WDGT_POSITION(view_image->private->position),
glLabelImage *object)
{
gdouble w, h;
- gchar *filename;
+ glTextNode *filename;
gl_debug (DEBUG_XML, "START");
h = g_strtod (xmlGetProp (node, "h"), NULL);
gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h);
- filename = xmlGetProp (node, "filename");
+ filename = g_new0 (glTextNode, 1);
+ filename->field_flag = FALSE;
+ filename->data = xmlGetProp (node, "filename");
gl_label_image_set_filename (object, filename);
- g_free (filename);
+ gl_text_node_free (&filename);
gl_debug (DEBUG_XML, "END");
}
xml_parse_image_props (xmlNodePtr node,
glLabel *label)
{
- GObject *object;
- gdouble w, h;
- gchar *filename;
+ GObject *object;
+ xmlNodePtr child;
+ gdouble w, h;
+ glTextNode *filename;
gl_debug (DEBUG_XML, "START");
w = g_strtod (xmlGetProp (node, "w"), NULL);
h = g_strtod (xmlGetProp (node, "h"), NULL);
- filename = xmlNodeGetContent (node);
+ child = node->xmlChildrenNode;
+ filename = g_new0 (glTextNode, 1);
+ if (g_strcasecmp (child->name, "Field") == 0) {
+ filename->field_flag = TRUE;
+ filename->data = xmlGetProp (child, "name");
+ } else if (xmlNodeIsText (child)) {
+ filename->field_flag = FALSE;
+ filename->data = xmlNodeGetContent (child);
+ } else {
+ g_warning ("Unexpected Image child: \"%s\"", child->name);
+ }
gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h);
gl_label_image_set_filename (GL_LABEL_IMAGE(object), filename);
- g_free (filename);
+ gl_text_node_free (&filename);
gl_debug (DEBUG_XML, "END");
xml_parse_barcode_props (xmlNodePtr node,
glLabel *label)
{
- GObject *object;
- xmlNodePtr child;
- glTextNode *text_node;
+ GObject *object;
+ xmlNodePtr child;
+ glTextNode *text_node;
glBarcodeStyle style;
gboolean text_flag;
guint color;
xmlNsPtr ns,
glLabelObject * object)
{
- gchar *string;
- gdouble w, h;
- gchar *filename;
+ gchar *string;
+ gdouble w, h;
+ glTextNode *filename;
+ xmlNodePtr child;
gl_debug (DEBUG_XML, "START");
xmlSetProp (object_node, "h", string);
g_free (string);
- xmlNodeSetContent (object_node, filename);
+ if (filename->field_flag) {
+ child = xmlNewChild (object_node, ns, "Field", NULL);
+ xmlSetProp (child, "name", filename->data);
+ } else {
+ xmlNodeSetContent (object_node, filename->data);
+ }
- g_free (filename);
+ gl_text_node_free (&filename);
gl_debug (DEBUG_XML, "END");
}
gboolean text_flag;
guint color;
gdouble scale;
- xmlNodePtr child;
- gchar *string;
+ xmlNodePtr child;
+ gchar *string;
gl_debug (DEBUG_XML, "START");