rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=c0d6e70ac8ec57a20486550b8720122abe663a0b

commit c0d6e70ac8ec57a20486550b8720122abe663a0b
Author: Andrii Kroitor <[email protected]>
Date:   Wed Jun 1 11:41:48 2016 +0300

    move resource management to separate module
---
 src/bin/Makefile.am                        |   2 +
 src/bin/project_manager/project_manager.h  | 251 +----------------------------
 src/bin/project_manager/resource_manager.c | 117 ++++++++++++++
 src/bin/project_manager/resource_manager.h | 199 +++++++++++++++++++++++
 4 files changed, 319 insertions(+), 250 deletions(-)

diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 919b652..47c76a5 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -27,6 +27,7 @@ includesub_HEADERS = \
        logger/logger.h \
        project_manager/group_manager.h \
        project_manager/project_manager.h \
+       project_manager/resource_manager.h \
        ui/cursor.h \
        ui/history_ui.h \
        ui/main_window.h \
@@ -62,6 +63,7 @@ libete_a_SOURCES = \
 ../../src/bin/common/widget_list.c \
 ../../src/bin/project_manager/group_manager.c \
 ../../src/bin/project_manager/project_manager.c \
+../../src/bin/project_manager/resource_manager.c \
 ../../src/bin/logger/logger.c \
 ../../src/bin/config/config.c \
 ../../src/bin/external/syntax_color.c \
diff --git a/src/bin/project_manager/project_manager.h 
b/src/bin/project_manager/project_manager.h
index 6301102..a9e43de 100644
--- a/src/bin/project_manager/project_manager.h
+++ b/src/bin/project_manager/project_manager.h
@@ -35,6 +35,7 @@
 
 #include "eflete.h"
 #include "group_manager.h"
+#include "resource_manager.h"
 
 /* don't forget to update on major changes */
 #define PROJECT_FILE_VERSION 4
@@ -534,254 +535,4 @@ pm_project_enventor_save(Project *project,
 Eina_Bool
 pm_lock_check(const char *path) EINA_ARG_NONNULL(1);
 
-/**
- * @struct _Resource
- *
- * Common structure for resources that can be used somewhere (images, sounds,
- * states etc.)
- *
- * @ingroup ProjectManager
- */
-struct _Resource
-{
-   Eina_Stringshare *name;
-   Eina_List *used_in;
-};
-
-/**
- * @struct _External_Resource
- *
- * Common structure for resources that can be used somewhere (images, sounds,
- * states etc.)
- *
- * @ingroup ProjectManager
- */
-struct _External_Resource
-{
-   Eina_Stringshare *name;
-   Eina_List *used_in;
-   Eina_Stringshare *source;
-};
-
-/**
- * @struct _Tone_Resource
- *
- * Common structure for resources that can be used somewhere (images, sounds,
- * states etc.)
- *
- * @ingroup ProjectManager
- */
-struct _Tone_Resource
-{
-   Eina_Stringshare *name;
-   Eina_List *used_in;
-   int freq;
-};
-
-/**
- * @struct _Colorclass_Resource
- *
- * Common structure for resources that can be used somewhere (images, sounds,
- * states etc.)
- *
- * @ingroup ProjectManager
- */
-struct _Colorclass_Resource
-{
-   Eina_Stringshare *name;
-   Eina_List *used_in;
-
-   struct {
-      int r,g,b,a;
-   } color1;
-   struct {
-      int r,g,b,a;
-   } color2;
-   struct {
-      int r,g,b,a;
-   } color3;
-};
-
-/**
- * @typedef Colorclass_Resource
- * @ingroup ProjectManager
- */
-typedef struct _Colorclass_Resource Colorclass_Resource;
-
-
-/**
- * @typedef Tone_Resource
- * @ingroup ProjectManager
- */
-typedef struct _Tone_Resource Tone_Resource;
-
-
-/**
- * @typedef External_Resource
- * @ingroup ProjectManager
- */
-typedef struct _External_Resource External_Resource;
-
-
-static int
-resource_cmp(Resource *res1, Resource *res2)
-{
-   return strcmp(res1->name, res2->name);
-}
-
-/**
- * Find resource in sorted list by its name.
- *
- * @param list Resources list
- * @param name Name of the resource to be found
- *
- * @return pointer to resource or NULL if it was not found
- *
- * @ingroup ProjectManager.
- */
-static inline void*
-pm_resource_get(Eina_List *list, Eina_Stringshare *name)
-{
-   Resource res;
-   res.name = name;
-   return eina_list_search_sorted(list, (Eina_Compare_Cb)resource_cmp, &res);
-}
-
-/**
- * Find resource in not sorted list by its name.
- *
- * @param list Resources list
- * @param name Name of the resource to be found
- *
- * @return pointer to resource or NULL if it was not found
- *
- * @ingroup ProjectManager.
- */
-static inline void*
-pm_resource_unsorted_get(Eina_List *list, Eina_Stringshare *name)
-{
-   Resource res;
-   res.name = name;
-   return eina_list_search_unsorted(list, (Eina_Compare_Cb)resource_cmp, &res);
-}
-
-
-/**
- * Add reference to resource with info where it is used (i.e. part for images)
- *
- * @param list Resources list
- * @param name Name of the resource. Must be in the list.
- * @param usage_data Place where resource is used
- *
- * @ingroup ProjectManager.
- */
-static inline Eina_Bool
-pm_resource_usage_add(Eina_List *list, Eina_Stringshare *name, void 
*usage_data)
-{
-   Resource *res = (Resource *) pm_resource_get(list, name);
-
-   if (!res)
-      return false;
-
-   res->used_in = eina_list_sorted_insert(res->used_in, 
(Eina_Compare_Cb)resource_cmp, usage_data);
-   return true;
-}
-
-/**
- * Add reference to resource with info where it is used (i.e. part for images)
- *
- * @param list Resources list
- * @param name Name of the resource. Must be in the list.
- * @param usage_data Place where resource is used
- *
- * @ingroup ProjectManager.
- */
-static inline Eina_Bool
-pm_resource_usage_unsorted_add(Eina_List *list, Eina_Stringshare *name, void 
*usage_data)
-{
-   Resource *res = (Resource *) pm_resource_unsorted_get(list, name);
-
-   if (!res)
-      return false;
-
-   res->used_in = eina_list_sorted_insert(res->used_in, 
(Eina_Compare_Cb)resource_cmp, usage_data);
-   return true;
-}
-
-/**
- * Remove resource.
- *
- * @param list Resources list
- * @param res Resource structure
- *
- * @ingroup ProjectManager.
- */
-static inline Eina_List *
-pm_resource_del(Eina_List *list, void *res)
-{
-   assert(res != NULL);
-   assert(list != NULL);
-   list = eina_list_remove(list, res);
-   return list;
-}
-
-/**
- * Remove reference to resource.
- *
- * @param list Resources list
- * @param name Name of the resource. Must be in the list.
- * @param usage_data Place where resource is used. Must be added to usage list.
- *
- * @ingroup ProjectManager.
- */
-static inline void
-pm_resource_usage_del(Eina_List *list, Eina_Stringshare *name, void 
*usage_data)
-{
-   Resource *res = (Resource *) pm_resource_get(list, name);
-   Eina_List *l_del;
-
-   assert(res != NULL);
-
-   l_del = eina_list_search_sorted_list(res->used_in, 
(Eina_Compare_Cb)resource_cmp, usage_data);
-
-   TODO("remove this after fixing resource managment");
-   if (!l_del)
-     {
-        ERR("Can't delete resource \"%s\"", name);
-        return;
-     }
-   assert(l_del);
-
-   res->used_in = eina_list_remove_list(res->used_in, l_del);
-}
-
-/**
- * Remove reference to resource.
- *
- * @param list Resources list
- * @param name Name of the resource. Must be in the list.
- * @param usage_data Place where resource is used. Must be added to usage list.
- *
- * @ingroup ProjectManager.
- */
-static inline void
-pm_resource_usage_unsorted_del(Eina_List *list, Eina_Stringshare *name, void 
*usage_data)
-{
-   Resource *res = (Resource *) pm_resource_unsorted_get(list, name);
-   Eina_List *l_del;
-
-   assert(res != NULL);
-
-   l_del = eina_list_search_sorted_list(res->used_in, 
(Eina_Compare_Cb)resource_cmp, usage_data);
-
-   TODO("remove this after fixing resource managment");
-   if (!l_del)
-     {
-        ERR("Can't delete resource \"%s\"", name);
-        return;
-     }
-   assert(l_del);
-
-   res->used_in = eina_list_remove_list(res->used_in, l_del);
-}
 #endif /* PROJECT_MANAGER_H */
diff --git a/src/bin/project_manager/resource_manager.c 
b/src/bin/project_manager/resource_manager.c
new file mode 100644
index 0000000..ee6f787
--- /dev/null
+++ b/src/bin/project_manager/resource_manager.c
@@ -0,0 +1,117 @@
+/*
+ * Edje Theme Editor
+ * Copyright (C) 2013-2016 Samsung Electronics.
+ *
+ * This file is part of Edje Theme Editor.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; If not, see www.gnu.org/licenses/lgpl.html.
+ */
+
+#include "resource_manager.h"
+
+int
+resource_cmp(Resource *res1, Resource *res2)
+{
+   return strcmp(res1->name, res2->name);
+}
+
+void *
+pm_resource_get(Eina_List *list, Eina_Stringshare *name)
+{
+   Resource res;
+   res.name = name;
+   return eina_list_search_sorted(list, (Eina_Compare_Cb)resource_cmp, &res);
+}
+
+void *
+pm_resource_unsorted_get(Eina_List *list, Eina_Stringshare *name)
+{
+   Resource res;
+   res.name = name;
+   return eina_list_search_unsorted(list, (Eina_Compare_Cb)resource_cmp, &res);
+}
+
+Eina_Bool
+pm_resource_usage_add(Eina_List *list, Eina_Stringshare *name, void 
*usage_data)
+{
+   Resource *res = (Resource *) pm_resource_get(list, name);
+
+   if (!res)
+      return false;
+
+   res->used_in = eina_list_sorted_insert(res->used_in, 
(Eina_Compare_Cb)resource_cmp, usage_data);
+   return true;
+}
+
+Eina_Bool
+pm_resource_usage_unsorted_add(Eina_List *list, Eina_Stringshare *name, void 
*usage_data)
+{
+   Resource *res = (Resource *) pm_resource_unsorted_get(list, name);
+
+   if (!res)
+      return false;
+
+   res->used_in = eina_list_sorted_insert(res->used_in, 
(Eina_Compare_Cb)resource_cmp, usage_data);
+   return true;
+}
+
+Eina_List *
+pm_resource_del(Eina_List *list, void *res)
+{
+   assert(res != NULL);
+   assert(list != NULL);
+   list = eina_list_remove(list, res);
+   return list;
+}
+
+void
+pm_resource_usage_del(Eina_List *list, Eina_Stringshare *name, void 
*usage_data)
+{
+   Resource *res = (Resource *) pm_resource_get(list, name);
+   Eina_List *l_del;
+
+   assert(res != NULL);
+
+   l_del = eina_list_search_sorted_list(res->used_in, 
(Eina_Compare_Cb)resource_cmp, usage_data);
+
+   TODO("remove this after fixing resource managment");
+   if (!l_del)
+     {
+        ERR("Can't delete resource \"%s\"", name);
+        return;
+     }
+   assert(l_del);
+
+   res->used_in = eina_list_remove_list(res->used_in, l_del);
+}
+
+void
+pm_resource_usage_unsorted_del(Eina_List *list, Eina_Stringshare *name, void 
*usage_data)
+{
+   Resource *res = (Resource *) pm_resource_unsorted_get(list, name);
+   Eina_List *l_del;
+
+   assert(res != NULL);
+
+   l_del = eina_list_search_sorted_list(res->used_in, 
(Eina_Compare_Cb)resource_cmp, usage_data);
+
+   TODO("remove this after fixing resource managment");
+   if (!l_del)
+     {
+        ERR("Can't delete resource \"%s\"", name);
+        return;
+     }
+   assert(l_del);
+
+   res->used_in = eina_list_remove_list(res->used_in, l_del);
+}
diff --git a/src/bin/project_manager/resource_manager.h 
b/src/bin/project_manager/resource_manager.h
new file mode 100644
index 0000000..6e44cc2
--- /dev/null
+++ b/src/bin/project_manager/resource_manager.h
@@ -0,0 +1,199 @@
+/*
+ * Edje Theme Editor
+ * Copyright (C) 2013-2016 Samsung Electronics.
+ *
+ * This file is part of Edje Theme Editor.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; If not, see www.gnu.org/licenses/lgpl.html.
+ */
+
+#ifndef RESOURCE_MANAGER_H
+#define RESOURCE_MANAGER_H
+
+#include "eflete.h"
+
+/**
+ * @struct _Resource
+ *
+ * Common structure for resources that can be used somewhere (images, sounds,
+ * states etc.)
+ *
+ * @ingroup ProjectManager
+ */
+struct _Resource
+{
+   Eina_Stringshare *name;
+   Eina_List *used_in;
+};
+
+/**
+ * @struct _External_Resource
+ *
+ * Common structure for resources that can be used somewhere (images, sounds,
+ * states etc.)
+ *
+ * @ingroup ProjectManager
+ */
+struct _External_Resource
+{
+   Eina_Stringshare *name;
+   Eina_List *used_in;
+   Eina_Stringshare *source;
+};
+
+/**
+ * @struct _Tone_Resource
+ *
+ * Common structure for resources that can be used somewhere (images, sounds,
+ * states etc.)
+ *
+ * @ingroup ProjectManager
+ */
+struct _Tone_Resource
+{
+   Eina_Stringshare *name;
+   Eina_List *used_in;
+   int freq;
+};
+
+/**
+ * @struct _Colorclass_Resource
+ *
+ * Common structure for resources that can be used somewhere (images, sounds,
+ * states etc.)
+ *
+ * @ingroup ProjectManager
+ */
+struct _Colorclass_Resource
+{
+   Eina_Stringshare *name;
+   Eina_List *used_in;
+
+   struct {
+      int r,g,b,a;
+   } color1;
+   struct {
+      int r,g,b,a;
+   } color2;
+   struct {
+      int r,g,b,a;
+   } color3;
+};
+
+/**
+ * @typedef Colorclass_Resource
+ * @ingroup ProjectManager
+ */
+typedef struct _Colorclass_Resource Colorclass_Resource;
+
+/**
+ * @typedef Tone_Resource
+ * @ingroup ProjectManager
+ */
+typedef struct _Tone_Resource Tone_Resource;
+
+/**
+ * @typedef External_Resource
+ * @ingroup ProjectManager
+ */
+typedef struct _External_Resource External_Resource;
+
+int
+resource_cmp(Resource *res1, Resource *res2);
+
+/**
+ * Find resource in sorted list by its name.
+ *
+ * @param list Resources list
+ * @param name Name of the resource to be found
+ *
+ * @return pointer to resource or NULL if it was not found
+ *
+ * @ingroup ProjectManager.
+ */
+void *
+pm_resource_get(Eina_List *list, Eina_Stringshare *name);
+
+/**
+ * Find resource in not sorted list by its name.
+ *
+ * @param list Resources list
+ * @param name Name of the resource to be found
+ *
+ * @return pointer to resource or NULL if it was not found
+ *
+ * @ingroup ProjectManager.
+ */
+void *
+pm_resource_unsorted_get(Eina_List *list, Eina_Stringshare *name);
+
+/**
+ * Add reference to resource with info where it is used (i.e. part for images)
+ *
+ * @param list Resources list
+ * @param name Name of the resource. Must be in the list.
+ * @param usage_data Place where resource is used
+ *
+ * @ingroup ProjectManager.
+ */
+Eina_Bool
+pm_resource_usage_add(Eina_List *list, Eina_Stringshare *name, void 
*usage_data);
+
+/**
+ * Add reference to resource with info where it is used (i.e. part for images)
+ *
+ * @param list Resources list
+ * @param name Name of the resource. Must be in the list.
+ * @param usage_data Place where resource is used
+ *
+ * @ingroup ProjectManager.
+ */
+Eina_Bool
+pm_resource_usage_unsorted_add(Eina_List *list, Eina_Stringshare *name, void 
*usage_data);
+
+/**
+ * Remove resource.
+ *
+ * @param list Resources list
+ * @param res Resource structure
+ *
+ * @ingroup ProjectManager.
+ */
+Eina_List *
+pm_resource_del(Eina_List *list, void *res);
+
+/**
+ * Remove reference to resource.
+ *
+ * @param list Resources list
+ * @param name Name of the resource. Must be in the list.
+ * @param usage_data Place where resource is used. Must be added to usage list.
+ *
+ * @ingroup ProjectManager.
+ */
+void
+pm_resource_usage_del(Eina_List *list, Eina_Stringshare *name, void 
*usage_data);
+
+/**
+ * Remove reference to resource.
+ *
+ * @param list Resources list
+ * @param name Name of the resource. Must be in the list.
+ * @param usage_data Place where resource is used. Must be added to usage list.
+ *
+ * @ingroup ProjectManager.
+ */
+void
+pm_resource_usage_unsorted_del(Eina_List *list, Eina_Stringshare *name, void 
*usage_data);
+
+#endif /* RESOURCE_MANAGER_H */

-- 


Reply via email to