[evolution-patches] [PATCH in Bugzilla] Abstraction in EMsgComposer



Hi there,


First of all:
http://bugzilla.gnome.org/show_bug.cgi?id=318611
http://bugzilla.gnome.org/attachment.cgi?id=53342&action=view


I know it's unavoidable in projects like Evolution, yet it's always nice
to go over code and fix the occurrences of unavoidable mistakes.

One such mistake (well, it's not really a mistake but makes replacing
the GtkHtml widget a lot more difficult) is violation of data hiding.

For example:


  <mystruct.h>

  typedef struct {
	int hidden_a;
  } MyStruct;

  int mystruct_get_a (MyStruct *instance);


  <myprogram.c>

  #include <mystruct.h>

  int test (MyStruct *struc)
  {
	printf ("It has %d\n", struc->hidden_a);
  }

Of course should the programmer here have used this:

int test (MyStruct *struc) 
{
	printf ("It has %d\n", mystruct_get_a (struc));
}

What can be done about this (I know most Evolution developers know this,
but I'm repeating it to illustrate what I did in this patch):

  <mystruct.h>

  typedef struct _MyStructPrivate MyStructPrivate;
  typedef struct {
	MyStructPrivate *priv;
  } MyStruct;

  int mystruct_get_a (MyStruct *instance);

  <mystruct.c>
  struct _MyStructPrivate {
    int hidden_a;
  };

  int mystruct_get_a (MyStruct *instance)
  {
     return instance->priv->hidden_a;
  }


That is basically what I did with e-msg-composer.c and e-msg-composer.h


The reason why I also like this to get accepted (and tested) is because
this will be the basis of replacing the GtkHtml widget with a
GtkMozEmbed widget.

You see, if I'm sure that NOBODY used anything else but the agreed
EMsgComposer API as defined in e-msg-composer.h, then I can securely
replace the internals of e-msg-composer.c.

I can then for example replace the Bonobo/CORBA stuff with normal method
calls on a GObject/GtkWidget. And then also replace the GtkHtml widget
with a GtkMozEmbed that has been set editable (check our go-evolution
wiki for more information about that).




-- 
Philip Van Hoof, software developer at x-tend
home: me at pvanhoof dot be
gnome: pvanhoof at gnome dot org
work: vanhoof at x-tend dot be
http://www.pvanhoof.be - http://www.x-tend.be




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