Re: gtk_image_new*() and GTK_IMAGE_EMPTY

James Henstridge wrote:

> On Fri, 27 Apr 2001, Vitaly Tishkov wrote:
> > Hi,
> >
> > I have a suggestion about changing the behavior of gtk_image_new*() and
> > gtk_image_get_storage_type() functions.
> >
> > As far as I understand if an image can't be created right way (eg if passed
> > wrong path to gtk_image_new_from_file (char* filename)) the image is created
> > with GTK_IMAGE_EMPTY as GtkImageType.
> >
> > I don't think it's a good idea to return a faulty image created and I don't
> > think that it's good even to create such images. I assume that it's better to
> > return NULL if a new GtkImage can't be created and rid off GTK_IMAGE_EMPTY at
> > all.
> >
> > As far as I can see GTK_IMAGE_EMPTY is used in gtk_image_new*() and
> > gtk_image_get_storage_type(GtkImage *image) functions only.
> >
> > I assume that GTK_IMAGE_EMPTY incorrectly used in gtk_image_get_storage_type().
> > GTK_IMAGE_EMPTY is returned by gtk_image_get_storage_type() if a parameter
> > passed to the function is not an GtkImage or it's type is GTK_IMAGE_EMPTY. So,
> > the same value is returned for valid and invalid GtkImage's.
> >
> > So, I propose;
> > 1) rid off GTK_IMAGE_EMPTY;
> > 2) make gtk_image_new*() return NULL if a valid GtkImage can't be created;
> > 3) add GTK_IMAGE_INVALID and make gtk_image_get_storage_type() return it if
> > incorrect parameter to the function passed.
> On the other hand, GTK_IMAGE_EMPTY is the only sane value to return from
> the following function call:
>   widget = g_object_new(GTK_TYPE_IMAGE, NULL);
> Whether the state should be called GTK_IMAGE_EMPTY or GTK_IMAGE_INVALID
> seems to be a matter of taste.

If you try to create a GtkWindow object by this call

    widget = gtk_window_new (99); /* 99 is incorrect parameter */

widget is NULL, i.e. gtk_window_new() returns NULL if incorrect parameter passed to
it and you can't create faulty GtkWindow object but can create a faulty GtkImage
one. I think that Gtk+ behaviour when creating widgets should be the same for all
the widgets: if a valid widget can't be created it should't be created.


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