Callback cleverness in window-main.c or just old cruft?

Dave Peticolas dave@krondo.com
Tue, 28 Nov 2000 22:13:35 -0800


Robert Graham Merkel writes:
> Is there something incredibly clever going on here that I'm not
> understanding, or is this code just crufty:
> 
> src/gnome/window-main.c:
> 
> static void
> gnc_account_cb(GNCMainWinAccountList *tree, Account *account, gpointer
> data)
> /* why the extra argument */
> {
>   gboolean sensitive;
> 
>   account = gnc_mainwin_account_list_get_current_account(tree);
>   sensitive = account != NULL;
> 
>   gnc_account_set_sensititives(gnc_get_main_info(), sensitive);
> }
> 
> void 
> mainWindow()
> {
>  . . . 
> gtk_signal_connect(GTK_OBJECT(main_info->account_tree), "unselect_account",
>                      GTK_SIGNAL_FUNC(gnc_account_cb), NULL);
> /* cast required here because of it */
> . . . 
> }
> 
> 
> src/gnome/account-tree.c (gnc_account_tree_init):
> 
> 
> account_tree_signals[ACTIVATE_ACCOUNT] =
>     gtk_signal_new("activate_account",
> 		   GTK_RUN_FIRST,
> 		   object_class->type,
> 		   GTK_SIGNAL_OFFSET(GNCAccountTreeClass,
> 				     activate_account),
> 		   gtk_marshal_NONE__POINTER,
> 		   GTK_TYPE_NONE, 1,
> 		   GTK_TYPE_POINTER);

gtk callbacks always have at least two arguments: the object itelf,
and the user_data pointer. These two arguments don't need to be declared
when the signal is defined.

dave