Re: bonobo comments/questions



On Thu, Oct 07, 1999 at 10:04:32AM -0500, Miguel de Icaza wrote:
> Well, you can go from the CORBA object to the servant, and from the
> servant to the actual GnomeObject.
How would I do the first step?
> 
> Of course, you could also keep track of what you are implementing.
I can in objects I define, but not in existing ones.

> Where are you planning on using this?
In the bonobo object for Desktop::Editor. It supports several view-types,
so when I get a call to GNOME_Embeddable_new_view, I have to get the
factory for the default view-type from the DesktopEditor object.

> If you want, I can add a gnome_object_query_interface_xxx that would
> return the GnomeObject.
IMHO the best solution is to have gnome_object_query_interface
to return a GnomeObject, and to have an extra
gnome_object_client_query_interface which returns a CORBA_Object

> > 2) Wouldn't it be a good idea to hide all CORBA from the user?  So 
> >    there would be more -client.[ch] files which would encapsulate
> >    more CORBA details, like query_interface (maybe even caching
> >    results of previous query_interface calls in a list in
> >    GnomeObjectClient?)
> 
> Well, it is not about hiding CORBA all over the place, Bonobo is a
> framework that makes building this sort of applications easier.
Yes, but by hiding more of the CORBA stuff, you have to do less 
tedious work, thus making it easier.

> Do you have specific examples of things you would like to hide?

For example in gnumeric you have:

gboolean
sheet_object_bonobo_load_from_file (SheetObjectBonobo *sob, const char *fname)
{
        CORBA_Environment ev;
        GNOME_PersistFile pf;
        GNOME_PersistStream ps;
        
        CORBA_exception_init (&ev);

        pf = GNOME_Unknown_query_interface (
                gnome_object_corba_objref (GNOME_OBJECT (sob->object_server)),
                "IDL:GNOME/PersistFile:1.0", &ev);

        if (ev._major == CORBA_NO_EXCEPTION && pf != CORBA_OBJECT_NIL){
                char *file;

                if (!fname)
                        file = get_file_name ();
                else
                        file = g_strdup (fname);
                if (file)
                        GNOME_PersistFile_load (pf, file, &ev);

                GNOME_Unknown_unref ((GNOME_Unknown) pf, &ev);
                CORBA_Object_release (pf, &ev);
                g_free (file);

                goto finish;
        } 
		  ....
}

I was thinking that if GnomeObjectClient had a hashtable for every
interface that had been requested, you could have something like:

gint
gnome_persist_file_client_load (GnomeObjectClient *pfile, gchar *file)
{
  CORBA_Environment ev;
  GNOME_PersistFile ret;

  CORBA_exception_init (&ev);
  ret = (GNOME_PersistFile) g_hash_table_lookup (pfile->ifs,
                                                 "IDL:GNOME/PersistFile:1.0");
  if (!ret) {
    ret = (GNOME_PersistFile)
		/* this would also add the interface to the hash */
	 	gnome_object_client_query_interface (pfile, 
                                           "IDL:GNOME/PersistFile:1.0", &ev);
    if (pfile->ev._major != CORBA_NO_EXCEPTION || ret == CORBA_OBJECT_NIL) {
      return FALSE;
    }
  }
  GNOME_PersistFile_load (ret, file, &ev);
  CORBA_exception_free (&ev);
  return TRUE;
}

and the code in gnumeric would be reduced to

gboolean
sheet_object_bonobo_load_from_file (SheetObjectBonobo *sob, const char *fname)
{
  if (!fname)
    file = get_file_name ();
  else
    file = g_strdup (fname);
  if (file && gnome_persist_file_client_load (pfile, file))
    goto finish;
  else
    return FALSE;
  ....
}

This means there's a lot less code for developers to make errors in.


Martijn

-- 
Martijn van Beers  <martijn@earthling.net>

'Don't worry if it sounds odd. Believe me, you are talking to
someone who has seen a lot of stuff that is odd. And I don't
mean biscuits.' --- Arthur Dent



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