Hi guys! Richard and me was talking this afternoon about how we are going to implement the system to give a unique id to every object in planner so we can use it in the undo/redo system. In the patch is the first approach to it. After reviewing it and commit, we will have done a great step in order to finish the undo/redo system. Cheers and good night -- Alvaro
Index: libplanner/mrp-application.c =================================================================== RCS file: /cvs/gnome/planner/libplanner/mrp-application.c,v retrieving revision 1.1.1.1 diff -u -b -B -p -r1.1.1.1 mrp-application.c --- libplanner/mrp-application.c 1 Dec 2003 17:36:21 -0000 1.1.1.1 +++ libplanner/mrp-application.c 28 Jan 2004 19:59:05 -0000 @@ -42,6 +42,7 @@ static void application_init_gettext static void application_init_file_modules (MrpApplication *app); static GObjectClass *parent_class; +static gulong last_used_id = 0; GType mrp_application_get_type (void) @@ -190,3 +191,15 @@ mrp_application_new (void) return g_object_new (MRP_TYPE_APPLICATION, NULL); } +/** + * mrp_application_get_unique_id: + * + * Returns a unique identifier in the #MrpApplication namespace. + * + * Return value: the unique id + **/ +gulong +mrp_application_get_unique_id (void) +{ + return ++last_used_id; +} Index: libplanner/mrp-application.h =================================================================== RCS file: /cvs/gnome/planner/libplanner/mrp-application.h,v retrieving revision 1.1.1.1 diff -u -b -B -p -r1.1.1.1 mrp-application.h --- libplanner/mrp-application.h 1 Dec 2003 17:36:21 -0000 1.1.1.1 +++ libplanner/mrp-application.h 28 Jan 2004 19:59:05 -0000 @@ -53,5 +53,6 @@ struct _MrpApplicationClass { GType mrp_application_get_type (void) G_GNUC_CONST; MrpApplication * mrp_application_new (void); +gulong mrp_application_get_unique_id (void); #endif /* __MRP_APPLICATION_H__ */ Index: libplanner/mrp-object.c =================================================================== RCS file: /cvs/gnome/planner/libplanner/mrp-object.c,v retrieving revision 1.2 diff -u -b -B -p -r1.2 mrp-object.c --- libplanner/mrp-object.c 14 Dec 2003 11:57:07 -0000 1.2 +++ libplanner/mrp-object.c 28 Jan 2004 19:59:07 -0000 @@ -27,6 +27,7 @@ #include "mrp-marshal.h" #include "mrp-project.h" +#include "mrp-application.h" #include "mrp-private.h" #include "mrp-object.h" @@ -149,6 +150,8 @@ object_init (MrpObject *object) priv = g_new0 (MrpObjectPriv, 1); object->priv = priv; + priv->id = mrp_application_get_unique_id (); + priv->property_hash = g_hash_table_new (NULL, NULL); } Index: libplanner/mrp-project.c =================================================================== RCS file: /cvs/gnome/planner/libplanner/mrp-project.c,v retrieving revision 1.3 diff -u -b -B -p -r1.3 mrp-project.c --- libplanner/mrp-project.c 14 Dec 2003 11:57:07 -0000 1.3 +++ libplanner/mrp-project.c 28 Jan 2004 19:59:11 -0000 @@ -72,8 +72,6 @@ struct _MrpProjectPriv { /* Project phases */ GList *phases; gchar *phase; - - guint last_used_id; }; /* Properties */ @@ -2215,15 +2213,3 @@ project_set_calendar (MrpProject *proje mrp_task_manager_recalc (priv->task_manager, TRUE); } - -guint -imrp_task_get_unique_id (MrpProject *project) -{ - MrpProjectPriv *priv; - - g_return_val_if_fail (MRP_IS_PROJECT (project), 0); - - priv = project->priv; - - return ++priv->last_used_id; -} Index: src/planner-resource-view.c =================================================================== RCS file: /cvs/gnome/planner/src/planner-resource-view.c,v retrieving revision 1.8 diff -u -b -B -p -r1.8 planner-resource-view.c --- src/planner-resource-view.c 28 Jan 2004 16:55:24 -0000 1.8 +++ src/planner-resource-view.c 28 Jan 2004 19:59:15 -0000 @@ -270,9 +270,12 @@ typedef struct { PlannerCmd base; MrpProject *project; + guint project_id; const gchar *name; MrpResource *resource; + guint resource_id; MrpGroup *group; + guint group_id; } ResourceCmdRemove; typedef struct { @@ -868,9 +871,14 @@ static void resource_cmd_remove_do (PlannerCmd *cmd_base) { ResourceCmdRemove *cmd; + guint resource_removed_id; cmd = (ResourceCmdRemove*) cmd_base; + resource_removed_id = mrp_object_get_id (MRP_OBJECT(cmd->resource)); + + cmd->resource_id = resource_removed_id; + mrp_project_remove_resource (cmd->project, cmd->resource); cmd->resource = NULL; @@ -888,6 +896,8 @@ resource_cmd_remove_undo (PlannerCmd *cm mrp_object_set (resource, "name", cmd->name, NULL); + mrp_object_set_id (MRP_OBJECT (resource), cmd->resource_id); + mrp_project_add_resource (cmd->project, resource); cmd->resource = resource;
Attachment:
signature.asc
Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada digitalmente