[gnome-builder] GbDocumentManager: add gb_document_manager_get_unsaved_documents()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] GbDocumentManager: add gb_document_manager_get_unsaved_documents()
- Date: Sat, 13 Dec 2014 00:34:55 +0000 (UTC)
commit 95dec1a533c1d54c7c8d8fabffca94e62a8f1dec
Author: Christian Hergert <christian hergert me>
Date: Fri Dec 12 16:26:50 2014 -0800
GbDocumentManager: add gb_document_manager_get_unsaved_documents()
src/documents/gb-document-manager.c | 30 ++++++++++++++++++++++++++++++
src/documents/gb-document-manager.h | 27 ++++++++++++++-------------
2 files changed, 44 insertions(+), 13 deletions(-)
---
diff --git a/src/documents/gb-document-manager.c b/src/documents/gb-document-manager.c
index 0bf71ed..44c2363 100644
--- a/src/documents/gb-document-manager.c
+++ b/src/documents/gb-document-manager.c
@@ -153,6 +153,36 @@ gb_document_manager_get_documents (GbDocumentManager *manager)
return list;
}
+/**
+ * gb_document_manager_get_unsaved_documents:
+ *
+ * Fetches a #GList of all the documents loaded by #GbDocumentManager for
+ * which have not been saved.
+ *
+ * Returns: (transfer container) (element-type GbDocument*): #GList of
+ * #GbDocument. Free list with g_list_free().
+ */
+GList *
+gb_document_manager_get_unsaved_documents (GbDocumentManager *manager)
+{
+ GList *list = NULL;
+ guint i;
+
+ g_return_val_if_fail (GB_IS_DOCUMENT_MANAGER (manager), NULL);
+
+ for (i = 0; i < manager->priv->documents->len; i++)
+ {
+ GbDocument *document;
+
+ document = g_ptr_array_index (manager->priv->documents, i);
+
+ if (gb_document_get_modified (document))
+ list = g_list_prepend (list, document);
+ }
+
+ return list;
+}
+
static void
gb_document_manager_document_modified (GbDocumentManager *manager,
GParamSpec *pspec,
diff --git a/src/documents/gb-document-manager.h b/src/documents/gb-document-manager.h
index b31d506..5f68c65 100644
--- a/src/documents/gb-document-manager.h
+++ b/src/documents/gb-document-manager.h
@@ -57,19 +57,20 @@ struct _GbDocumentManagerClass
GbDocument *document);
};
-GType gb_document_manager_get_type (void);
-GbDocumentManager *gb_document_manager_new (void);
-GbDocumentManager *gb_document_manager_get_default (void);
-void gb_document_manager_add (GbDocumentManager *manager,
- GbDocument *document);
-void gb_document_manager_remove (GbDocumentManager *manager,
- GbDocument *document);
-GList *gb_document_manager_get_documents (GbDocumentManager *manager);
-guint gb_document_manager_get_count (GbDocumentManager *manager);
-GbDocument *gb_document_manager_find_with_file (GbDocumentManager *manager,
- GFile *file);
-GbDocument *gb_document_manager_find_with_type (GbDocumentManager *manager,
- GType type);
+GType gb_document_manager_get_type (void);
+GbDocumentManager *gb_document_manager_new (void);
+GbDocumentManager *gb_document_manager_get_default (void);
+void gb_document_manager_add (GbDocumentManager *manager,
+ GbDocument *document);
+void gb_document_manager_remove (GbDocumentManager *manager,
+ GbDocument *document);
+GList *gb_document_manager_get_documents (GbDocumentManager *manager);
+GList *gb_document_manager_get_unsaved_documents (GbDocumentManager *manager);
+guint gb_document_manager_get_count (GbDocumentManager *manager);
+GbDocument *gb_document_manager_find_with_file (GbDocumentManager *manager,
+ GFile *file);
+GbDocument *gb_document_manager_find_with_type (GbDocumentManager *manager,
+ GType type);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]