Re: [Evolution-hackers] [PATCH in Bugzilla] Abstraction in EMsgComposer



On Tue, 2005-10-11 at 22:38 +0200, Philip Van Hoof wrote:
> 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:

Why?  If there is a public data information, then there's no reason to
use an accessor.

> 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).
> 
> 
> 
> 
-- 
adfa(evolution-2.4:20087): gtkhtml-WARNING **: cannot find icon:
'stock_insert-url' in gnome 




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