[Users] [GTK3] What to do about GtkStock and GTK_STOCK_YES?

Andrej Kacian ticho at claws-mail.org
Mon Jan 8 17:22:52 CET 2018


On Sun, 7 Jan 2018 16:05:57 -0600
Rob Hoelz <rob at hoelz.ro> wrote:

> Hi claws-mail devs,
> 
> When I was working on getting Claws Mail 3.16 to compile against GTK3, one of the most common errors I found was with code like this:
> 
> > "+" GTK_STOCK_YES  
> 
> It appears that pre-GTK3, GTK_STOCK_YES and co. were simply string constants, so this would just prepend a plus character to that string,
> which Claws Mail uses in alertpane_create to set up some custom behavior for the corresponding labels.
> 
> In GTK3, however, those constants are GtkStock* (just casted from string constants, but this still makes the compiler unhappy).  In my patch,
> I just expanded GTK_STOCK_YES and co. to the underlying string constant where needed to get claws to compile.  Obviously this isn't really viable
> going forward, so I was wondering how this change should be made instead.  Should we set up our own CM_STOCK_* constants?

I would opt for scrapping this whole "+" prefix thing in alertpanel.c,
and just change the alertpanel API to indicate which button should be
focused by default in a different way - perhaps a simple extra integer
parameter which could have values 1, 2, 3 or 0 (no button has focus).

It would also simplify the alertpanel_create() code somewhat, and less
string manipulation in C is always a good idea. :)

Regards,
-- 
Andrej



More information about the Users mailing list