Add option to select tag icon from file (Bug 461447)



Hi,

I'm just looking at this bug and am trying to work out what to do with the the image filepath once I have gotten it from the user. FYI, I'm new to Pixbuf and friends...

Here is my dodgy work in progress code (warts and all)

----------------------------------------------------------------------------------------
  private void HandleExternalFileSelectionChanged (object sender, EventArgs args)
                {
                        // FIXME: Declan asks, Is the following needed?
                         //if (args.ResponseId != Gtk.ResponseType.Ok) {
                                // FIXME this is to work around a bug in gtk+ where
                                // the filesystem events are still listened to when
                                // a FileChooserButton is destroyed but not finalized
                                // and an event comes in that wants to update the child widgets.
                         //       Dialog.Destroy ();
                         //       external_photo_chooser.Dispose ();
                         //       external_photo_chooser = null;
                         //       return;
                        //}

                        if (external_photo_chooser.Uri != null) {
                                Gnome.Vfs.Uri dest = new Gnome.Vfs.Uri (external_photo_chooser.Uri);
                                Console.WriteLine (external_photo_chooser.Uri);

//START OF COPY AND PASTED CODE FROM HandleSelectionChanged
                                int x, y, width, height;
                                Gdk.Pixbuf tmp = null;

                                image_view.GetSelection (out x, out y, out width, out height);

                                if (image_view.Pixbuf != null) {
                                        if (width > 0 && height > 0) {
                                                //tmp = new Gdk.Pixbuf (image_view.Pixbuf, x, y, width, height);
                                                tmp = new Gdk.Pixbuf(external_photo_chooser.Uri, x, y, width, height);

                                                PreviewPixbuf = PixbufUtils.TagIconFromPixbuf (tmp);

                                                tmp.Dispose ();
                                        } else {
                                                PreviewPixbuf = PixbufUtils.TagIconFromPixbuf (image_view.Pixbuf);
                                        }
                                }
//END OF COPY AND PASTED CODE

                        }
                        Console.WriteLine ("Happy talk like a pirate day!");
                }
----------------------------------------------------------------------------------------

I select a photo and ok the Edit Icon dialog and nothing much happens. Then I ok the Edit Tag dialog (which opened the Edit Icon dialog) and get the error

---------------------------------------------------------------------------------------
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixdata_from_pixbuf: assertion `GDK_IS_PIXBUF (pixbuf)' failed

(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixdata_serialize: assertion `pixdata->magic == GDK_PIXBUF_MAGIC_NUMBER' failed
error System.ArgumentNullException: Argument cannot be null.
  at <0x00000> <unknown method>
  at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal:copy_from_unmanaged (intptr,int,System.Array,int)
  at System.Runtime.InteropServices.Marshal.Copy (IntPtr source, System.Byte[] destination, Int32 startIndex, Int32 length) [0x00000] 
  at PixbufSerializer.Serialize (Gdk.Pixbuf pixbuf) [0x00000] 
  at TagStore.GetIconString (.Tag tag) [0x00000] 
  at TagStore.Commit (.DbItem item, Boolean update_xmp) [0x00000] 
  at TagCommands+Edit.Execute (.Tag t) [0x00000] 

(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_width: assertion `pixbuf != NULL' failed
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_height: assertion `pixbuf != NULL' failed
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_width: assertion `pixbuf != NULL' failed
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_height: assertion `pixbuf != NULL' failed
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_width: assertion `pixbuf != NULL' failed
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_height: assertion `pixbuf != NULL' failed
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_width: assertion `pixbuf != NULL' failed
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_height: assertion `pixbuf != NULL' failed
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_width: assertion `pixbuf != NULL' failed
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_height: assertion `pixbuf != NULL' failed
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_width: assertion `pixbuf != NULL' failed
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_height: assertion `pixbuf != NULL' failed
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_width: assertion `pixbuf != NULL' failed
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_height: assertion `pixbuf != NULL' failed
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_width: assertion `pixbuf != NULL' failed
(f-spot:20102): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_height: assertion `pixbuf != NULL' failed

-------------------------------------------------------------------------------------

Why isn't an icon being generated from the file the user entered? Also, any tips on getting the preview image to change in the Edit Icon dialog?

All the best,
Declan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]