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

Rob Hoelz rob at hoelz.ro
Tue Jan 9 14:49:06 CET 2018


On Mon, 8 Jan 2018 17:22:52 +0100
Andrej Kacian <ticho at claws-mail.org> wrote:

> 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. :)

This would be my preferred way going forward as well - when I was working on
my patch, it's not entirely obvious what the prefixed plus character is doing.
Something more explicit as to what's going on would be helpful!

-Rob



More information about the Users mailing list