From ccbf23cfc7000b5aeba5030fb7e7cca066a1a315 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Thu, 12 Dec 2002 04:00:24 +0000 Subject: [PATCH] More work on images from merge data. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@214 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/src/label-image.c | 29 ++++++++++++++++++++++++----- glabels2/src/view-image.c | 2 ++ glabels2/src/wdgt-image-select.c | 32 +++++++++++++++++++++----------- 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/glabels2/src/label-image.c b/glabels2/src/label-image.c index 3976f882..8c43f82a 100644 --- a/glabels2/src/label-image.c +++ b/glabels2/src/label-image.c @@ -103,9 +103,10 @@ gl_label_image_instance_init (glLabelImage *limage) { limage->private = g_new0 (glLabelImagePrivate, 1); + limage->private->filename = g_new0 (glTextNode, 1); + limage->private->pixbuf = - gdk_pixbuf_new_from_xpm_data ((const char **) - checkerboard_xpm); + gdk_pixbuf_new_from_xpm_data ((const char **)checkerboard_xpm); } static void @@ -117,6 +118,8 @@ gl_label_image_finalize (GObject *object) limage = GL_LABEL_IMAGE (object); + gl_text_node_free (&limage->private->filename); + g_object_unref (G_OBJECT(limage->private->pixbuf)); g_free (limage->private); G_OBJECT_CLASS (parent_class)->finalize (object); @@ -174,7 +177,7 @@ gl_label_image_set_filename (glLabelImage *limage, g_return_if_fail (limage && GL_IS_LABEL_IMAGE (limage)); - if ( (filename == NULL) || filename->field_flag ) { + if ( (filename == NULL) || filename->field_flag || (filename->data == NULL) ) { gl_text_node_free (&limage->private->filename); limage->private->filename = gl_text_node_dup(filename); @@ -187,8 +190,24 @@ gl_label_image_set_filename (glLabelImage *limage, gl_label_object_emit_changed (GL_LABEL_OBJECT(limage)); } else { - if ( (limage->private->filename == NULL) || - (strcmp (limage->private->filename->data, filename->data) != 0) ) { + if ( limage->private->filename == NULL) { + + limage->private->filename = gl_text_node_dup (filename); + + pixbuf = gdk_pixbuf_new_from_file (filename->data, 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); + } + + gl_label_object_emit_changed (GL_LABEL_OBJECT(limage)); + + } else if ( (limage->private->filename->data == NULL) || + strcmp (limage->private->filename->data, filename->data) != 0) { gl_text_node_free (&limage->private->filename); limage->private->filename = gl_text_node_dup (filename); diff --git a/glabels2/src/view-image.c b/glabels2/src/view-image.c index 533e4ac8..89bf682c 100644 --- a/glabels2/src/view-image.c +++ b/glabels2/src/view-image.c @@ -534,6 +534,8 @@ update_dialog_cb (glLabelObject *object, (merge != NULL), filename); } + gl_wdgt_image_select_set_field_defs (GL_WDGT_IMAGE_SELECT(view_image->private->pixmap_entry), + merge); gl_wdgt_position_set_position (GL_WDGT_POSITION(view_image->private->position), x, y); gl_wdgt_size_set_size (GL_WDGT_SIZE(view_image->private->size), w, h); diff --git a/glabels2/src/wdgt-image-select.c b/glabels2/src/wdgt-image-select.c index bbef281f..9f2bb6f7 100644 --- a/glabels2/src/wdgt-image-select.c +++ b/glabels2/src/wdgt-image-select.c @@ -231,9 +231,9 @@ gl_wdgt_image_select_construct (glWdgtImageSelect *image_select, /* Otherwise, leave it in the last directory that we got an image. */ gnome_pixmap_entry_set_pixmap_subdir (GNOME_PIXMAP_ENTRY(image_select->file_entry), image_path); - g_signal_connect ( G_OBJECT(gnome_file_entry_gtk_entry - (GNOME_FILE_ENTRY (image_select->file_entry))), - "changed", G_CALLBACK (changed_cb), image_select); + g_signal_connect_swapped ( G_OBJECT(gnome_file_entry_gtk_entry + (GNOME_FILE_ENTRY (image_select->file_entry))), + "changed", G_CALLBACK (changed_cb), image_select); gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), image_select->file_entry); @@ -264,6 +264,11 @@ gl_wdgt_image_select_construct (glWdgtImageSelect *image_select, G_OBJECT (image_select)); gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), image_select->key_combo); + + gl_wdgt_image_select_set_data (image_select, + (merge != NULL), + text_node); + gl_debug (DEBUG_WDGT, "END"); } @@ -285,8 +290,8 @@ changed_cb (glWdgtImageSelect *image_select) /* PRIVATE. Callback to handle toggling of radio buttons */ /*--------------------------------------------------------------------------*/ static void -radio_toggled_cb (GtkToggleButton *togglebutton, - glWdgtImageSelect *image_select) +radio_toggled_cb (GtkToggleButton *togglebutton, + glWdgtImageSelect *image_select) { gl_debug (DEBUG_WDGT, "START"); @@ -310,7 +315,7 @@ radio_toggled_cb (GtkToggleButton *togglebutton, /****************************************************************************/ void gl_wdgt_image_select_set_field_defs (glWdgtImageSelect *image_select, - glMerge *merge) + glMerge *merge) { GList *keys; @@ -368,8 +373,8 @@ gl_wdgt_image_select_get_data (glWdgtImageSelect *image_select) /****************************************************************************/ void gl_wdgt_image_select_set_data (glWdgtImageSelect *image_select, - gboolean merge_flag, - glTextNode *text_node) + gboolean merge_flag, + glTextNode *text_node) { gint pos; @@ -385,8 +390,13 @@ gl_wdgt_image_select_set_data (glWdgtImageSelect *image_select, gtk_widget_set_sensitive (image_select->file_entry, TRUE); gtk_widget_set_sensitive (image_select->key_combo, FALSE); - gnome_file_entry_set_filename (GNOME_FILE_ENTRY(image_select->file_entry), - text_node->data); + if (text_node->data != NULL ) { + gnome_file_entry_set_filename (GNOME_FILE_ENTRY(image_select->file_entry), + text_node->data); + } else { + gnome_file_entry_set_filename (GNOME_FILE_ENTRY(image_select->file_entry), + ""); + } } else { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON @@ -421,7 +431,7 @@ gl_wdgt_image_select_set_data (glWdgtImageSelect *image_select, /****************************************************************************/ void gl_wdgt_image_select_set_label_size_group (glWdgtImageSelect *image_select, - GtkSizeGroup *label_size_group) + GtkSizeGroup *label_size_group) { gl_debug (DEBUG_WDGT, "START"); -- 2.39.5