[gimp: 6/27] app: Add file_procedure_in_group()
- From: Martin Nordholts <martinn src gnome org>
- To: svn-commits-list gnome org
- Subject: [gimp: 6/27] app: Add file_procedure_in_group()
- Date: Sat, 16 May 2009 07:24:52 -0400 (EDT)
commit e9ed9ce6cba3892ac2f69195e534482f94aee782
Author: Martin Nordholts <martinn src gnome org>
Date: Sat Apr 25 15:28:08 2009 +0200
app: Add file_procedure_in_group()
Add file_procedure_in_group() which is a helper function to determine
if a file procedure is in the Open, Save or Export group.
---
app/file/file-procedure.c | 35 +++++++++++++++++++++++++++++++++++
app/file/file-procedure.h | 25 ++++++++++++++++++-------
2 files changed, 53 insertions(+), 7 deletions(-)
diff --git a/app/file/file-procedure.c b/app/file/file-procedure.c
index f80a697..d32eec5 100644
--- a/app/file/file-procedure.c
+++ b/app/file/file-procedure.c
@@ -219,6 +219,41 @@ file_procedure_find_by_extension (GSList *procs,
return file_proc_find_by_extension (procs, uri, FALSE);
}
+gboolean
+file_procedure_in_group (GimpPlugInProcedure *file_proc,
+ FileProcedureGroup group)
+{
+ const gchar *name = gimp_object_get_name (GIMP_OBJECT (file_proc));
+ gboolean is_xcf_save = FALSE;
+ gboolean is_filter = FALSE;
+
+ is_xcf_save = (strcmp (name, "gimp-xcf-save") == 0);
+
+ is_filter = (strcmp (name, "file-gz-save") == 0 ||
+ strcmp (name, "file-bz2-save") == 0);
+
+ switch (group)
+ {
+ case FILE_PROCEDURE_GROUP_SAVE:
+ /* Only .xcf shall pass */
+ /* FIXME: Handle .gz and .bz2 properly */
+ return is_xcf_save || is_filter;
+
+ case FILE_PROCEDURE_GROUP_EXPORT:
+ /* Anything but .xcf shall pass */
+ /* FIXME: Handle .gz and .bz2 properly */
+ return ! is_xcf_save || is_filter;
+
+ case FILE_PROCEDURE_GROUP_OPEN:
+ /* No filter applied for Open */
+ return TRUE;
+
+ default:
+ case FILE_PROCEDURE_GROUP_ANY:
+ return TRUE;
+ }
+}
+
/* private functions */
diff --git a/app/file/file-procedure.h b/app/file/file-procedure.h
index 1dd0841..7df1c2e 100644
--- a/app/file/file-procedure.h
+++ b/app/file/file-procedure.h
@@ -21,13 +21,24 @@
#define __FILE_PROCEDURE_H__
-GimpPlugInProcedure * file_procedure_find (GSList *procs,
- const gchar *filename,
- GError **error);
-GimpPlugInProcedure * file_procedure_find_by_prefix (GSList *procs,
- const gchar *uri);
-GimpPlugInProcedure * file_procedure_find_by_extension (GSList *procs,
- const gchar *uri);
+typedef enum
+{
+ FILE_PROCEDURE_GROUP_ANY,
+ FILE_PROCEDURE_GROUP_OPEN,
+ FILE_PROCEDURE_GROUP_SAVE,
+ FILE_PROCEDURE_GROUP_EXPORT
+} FileProcedureGroup;
+
+
+GimpPlugInProcedure *file_procedure_find (GSList *procs,
+ const gchar *filename,
+ GError **error);
+GimpPlugInProcedure *file_procedure_find_by_prefix (GSList *procs,
+ const gchar *uri);
+GimpPlugInProcedure *file_procedure_find_by_extension (GSList *procs,
+ const gchar *uri);
+gboolean file_procedure_in_group (GimpPlugInProcedure *file_proc,
+ FileProcedureGroup group);
#endif /* __FILE_PROCEDURE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]