Re: GObject question.



On 6/7/07, David Nečas (Yeti) <yeti physics muni cz> wrote:
On Thu, Jun 07, 2007 at 07:17:42PM -0300, Alexandre Moreira wrote:
>
> So, just to check if I understand it right. What you're saying is that
> the best approach would be to have something like (in my file buffer
> case) a FileBuffer class which I could do something like:
>
> g_object_new(X_TYPE_FILE_BUFFER, /*any properties here*/ NULL);
>
> and only then load the resource as in something like
>
> x_file_buffer_load_from_file(file_name, &error);
>
> ... is that kind of thing you were saying or am I missing something ?

You can do it this way, but you can do it a way more
resembling your original description too.  I don't know what
your intended error reporting interface for other I/O errors
looks like, but if it can be querried after the fact, i.e.
it maintains something like errno, then

  buf = g_object_new(X_TYPE_FILE_BUFFER, "filename", "foo.txt", NULL);
  if (!buf) {
    ...
  }

can be done completely equivalently

  buf = g_object_new(X_TYPE_FILE_BUFFER, "filename", "foo.txt", NULL);
  if (x_file_buffer_error(buf)) {
    ...
    g_object_unref(buf);
  }

If not, the x_file_buffer_load_from_file() approach with
immediate error reporting makes more sense.


Thanks, I'll keep both ideas in mind. Although for this case the
GError based one will make more sense.

Thanks again,
Alexandre Moreira.

Yeti

--
http://gwyddion.net/
_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list



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