Re: GObject question.



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.

Yeti

--
http://gwyddion.net/



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