Re: [anjuta-devel] New project interface and introspection



Hi,

Here a new proposal for project API


* The IAnjutaProjectBackend interface which has to be implemented by all project backend plugin.

IAnjutaProject*
ianjuta_project_backend_new_project (
        IAnjutaProjectBackend *backend,
        GFile *file
        );

gint
ianjuta_project_backend_probe (
        GFile *file
        );

This is exactly the current interface. So comparing to my previous proposal, the difference is that the new_project function returns a project object and not a root node.

I have tried to remove this project object, but I haven't found a nice way to handle changed signal, so in the end I think it's better to keep it.
+ This project object is a nice place to have this changed signal.
+ The project object can own all nodes and you free you from allocation stuff.
+ It can be used to easily keep global configuration.
- One disadvantage is that you need one additional argument, the project pointer in all node functions.

I have though about using the root node as a project object, but it is a bit annoying: - A pointer on the root object is not always available (you have to go to the top of the parent list).




* The IAnjutaProject interface is implemented by the project object.

gboolean
ianjuta_project_load_node (
        IAnjutaProject *project,
        AnjutaProjectNode *node,
        GError *err
        );

gboolean
ianjuta_project_save_node (
        IAnjutaProject *project,
        AnjutaProjectNode *node,
        GError *err
        );

AnjutaProjectNode *
ianjuta_project_add_node_before (
        IAnjutaProject *project,
        AnjutaProjectNode *parent,
        AnjutaProjectNode *sibling,
        AnjutaProjectNodeType type,
        GFile *file,
        const gchar *name,
        GError *err
        );

AnjutaProjectNode *
ianjuta_project_add_node_after (
        IAnjutaProject *project,
        AnjutaProjectNode *parent,
        AnjutaProjectNode *sibling,
        AnjutaProjectNodeType type,
        GFile *file,
        const gchar *name,
        GError *err
        );

AnjutaProjectNode *
ianjuta_project_remove_node (
        IAnjutaProject *project,
        AnjutaProjectNode *parent,
        AnjutaProjectNode *sibling,
        AnjutaProjectNodeType type,
        GFile *file,
        const gchar *name,
        GError *err
        );

AnjutaProjectNode *
ianjuta_project_set_property (
        IAnjutaProject *project,
        AnjutaProjectNode *node,
        AnjutaProjectProperty *property,
        const gchar *value,
        GError *err
        );

AnjutaProjectNode *
ianjuta_project_remove_property (
        IAnjutaProject *project,
        AnjutaProjectNode *node,
        AnjutaProjectProperty *property,
        const gchar *value,
        GError *err
        );

Comparing to my previous proposals, I have done the following changes:

- Load and save function returns a boolean instead of a node. The returned node was not really useful and returning a pointer means that you have to define the kind of transfer. It's not a big problem, as all objects are own by the project, returned pointer are always of type <transfer none> but it's not needed neither.

- All functions need an additional project pointer. It's one additional argument but it allows you to easily have global data.

- I have replaced the new function by add_before and add_after. It's one additional function to write, but the code of both function is almost the same. The return value has the <transfer none> annotation, the node is owned by the project. The function can return NULL if the node cannot be added. After looking at my code again, I think it's not a problem if the node is created and added immediately because this is not done in a different thread.

- I have added remove_property and remove_node function. I think it's not necessary, we can have a common function that is just setting a REMOVE flag in the common part of node or property data. But, perhaps it is easier to use if the node or the property is really removed from the project tree. In this case, the function is necessary because the project object needs to keep these removed objects somewhere else in order to be able to remove them from the file when the save function is called. What do you think?

- I have removed the free function. As far as I know, it was your main concern about the old API. Freeing the node or the property can be done in the remove function. But I think it would be better to do it in the save function when the removed node or property is not needed anymore. It must be done if the project object is destroyed too.

- The AnjutaProjectNode object is working like AnjutaProjectProperty, so it doesn't need to be a GObject. I plan to keep it as a GObject at least until I implement the complete new interface and check that everything work fine. I think I should add anjuta_project_generic_node_new/anjuta_project_generic_node_free and anjuta_project_generic_property_new/anjuta_project_generic_property_free. Which are both taking on generic pointer to help you implementing a specific property and node in Python.

- This new interface is quite closer to the current one than my previous proposal. It doesn't require big changes in the current code. I think I could make all changes within one week.


What do you think about this?


Regards,

Sébastien



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