]> git.sur5r.net Git - glabels/commitdiff
More work on images from merge data.
authorJim Evins <evins@snaught.com>
Thu, 12 Dec 2002 04:00:24 +0000 (04:00 +0000)
committerJim Evins <evins@snaught.com>
Thu, 12 Dec 2002 04:00:24 +0000 (04:00 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@214 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/label-image.c
glabels2/src/view-image.c
glabels2/src/wdgt-image-select.c

index 3976f88217f13a6b675be64cdb00fefeb5afffa5..8c43f82ac145513f861a6e04a268af6e4cceaf79 100644 (file)
@@ -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);
index 533e4ac86dde4d48940e5617b8727956d2d1f172..89bf682cc7499502d2ee9ea1eada304ebfcb92e9 100644 (file)
@@ -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);
index bbef281f0402497cea9ea1c6752d06e67924c737..9f2bb6f77ad6d9866a8afe9d4cf11a56f5fecadf 100644 (file)
@@ -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");