[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA-user: [PCB] action context patch
On Mon, 23 Mar 2009, DJ Delorie wrote:
>
>> This was the simpler and more general change.
>
>Simpler and more general does not always mean better. To me, the more
>general solution is to be able to add/remove single actions, with
>their own context. Other functions can build on that. If the
>internals of that code need to be changed to support that, it's a
>change we need to now to avoid more work later.
>
>Creating a new API that will never be used in its full functionality
>seems wrong to me.
>
>> I don't say the GUI should know about context, but that, as the GTK
>> hid does, the GUI hid should not do this directly but call
>> hid_actionv() from hid/common/actions.c.
>
>Perhaps hid_find_action could set the global context pointer?
>
>> I have one more layer, which is not part of this patch but the
>> plugin, where I do this. My approach is doing the smallest but more
>> general patch to the core and do everything else in plugins.
>
>My approach is to create the best API in the core so that the least
>amount of code need be duplicated in plugins.
>
After polishing the API on irc, the final(?) version of the proposed API
is attached.
--- pcb.orig/src/hid.h 2009-02-21 18:51:54.000000000 +0100
+++ pcb/src/hid.h 2009-03-23 06:25:44.000000000 +0100
@@ -86,7 +86,21 @@
const char *syntax;
} HID_Action;
+ /* This global variable is always set to the action context,
+ before an action callback is called. Action context can
+ be specified when registering an action with hid_register_action() */
+ extern void *hid_action_context;
+
+ /* Register a singe action associated with an action context */
+ extern void hid_register_actions(HID_Action *, void *);
+
+ /* Deregister an action; returns 0 on success. Action context pointer is copied
+ in the 2nd argument if it's not NULL */
+ extern void hid_deregister_action(const char *, void **);
+
+ /* Register a list of actions without action context */
extern void hid_register_actions (HID_Action *, int);
+
#define REGISTER_ACTIONS(a) HIDCONCAT(void register_,a) ()\
{ hid_register_actions(a, sizeof(a)/sizeof(a[0])); }
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user