[libpeas] Added peas_extension_set_foreach()



commit 0b0e4e0d1d2851864f38b3f8e2938d08feaba7bb
Author: Garrett Regier <alias301 gmail com>
Date:   Wed Jun 8 13:48:10 2011 -0700

    Added peas_extension_set_foreach()

 libpeas/peas-extension-set.c |   32 +++++++++++++++++++++++++++++++-
 libpeas/peas-extension-set.h |   21 +++++++++++++++++++++
 2 files changed, 52 insertions(+), 1 deletions(-)
---
diff --git a/libpeas/peas-extension-set.c b/libpeas/peas-extension-set.c
index b559fc0..fd58467 100644
--- a/libpeas/peas-extension-set.c
+++ b/libpeas/peas-extension-set.c
@@ -74,7 +74,9 @@
  *
  *   set = peas_extension_set_new (engine, PEAS_TYPE_ACTIVATABLE,
  *                                 "object", window, NULL);
- *   peas_extension_set_call (set, "activate");
+ *   peas_extension_set_foreach (set,
+ *                               (PeasExtensionSetForeachFunc) on_extension_added,
+ *                               NULL);
  *   g_signal_connect (set, "extension-added",
  *                     G_CALLBACK (on_extension_added), NULL);
  *   g_signal_connect (set, "extension-removed",
@@ -564,6 +566,34 @@ peas_extension_set_callv (PeasExtensionSet *set,
 }
 
 /**
+ * peas_extension_set_foreach:
+ * @set: A #PeasExtensionSet.
+ * @func: (scope call): A function call for each extension.
+ * @data: Optional data to be passed to the function or %NULL.
+ *
+ * Calls @func for each #PeasExtension.
+ *
+ * Since: 1.2
+ */
+void
+peas_extension_set_foreach (PeasExtensionSet            *set,
+                            PeasExtensionSetForeachFunc  func,
+                            gpointer                     data)
+{
+  GList *l;
+
+  g_return_if_fail (PEAS_IS_EXTENSION_SET (set));
+  g_return_if_fail (func != NULL);
+
+  for (l = set->priv->extensions; l; l = l->next)
+    {
+      ExtensionItem *item = (ExtensionItem *) l->data;
+
+      func (set, item->info, item->exten, data);
+    }
+}
+
+/**
  * peas_extension_set_newv:
  * @engine: (allow-none): A #PeasEngine, or %NULL.
  * @exten_type: the extension #GType.
diff --git a/libpeas/peas-extension-set.h b/libpeas/peas-extension-set.h
index 1f30206..e747c2e 100644
--- a/libpeas/peas-extension-set.h
+++ b/libpeas/peas-extension-set.h
@@ -72,6 +72,23 @@ struct _PeasExtensionSetClass {
   gpointer padding[8];
 };
 
+/**
+ * PeasExtensionSetForeachFunc:
+ * @set: A #PeasExtensionSet.
+ * @info: A #PeasPluginInfo.
+ * @exten: A #PeasExtension.
+ * @data: Optional data passed to the function.
+ *
+ * This function is passed to peas_extension_set_foreach() and
+ * will be called for each extension in @set.
+ *
+ * Since: 1.2
+ */
+typedef void (*PeasExtensionSetForeachFunc) (PeasExtensionSet *set,
+                                             PeasPluginInfo   *info,
+                                             PeasExtension    *exten,
+                                             gpointer          data);
+
 /*
  * Public methods
  */
@@ -87,6 +104,10 @@ gboolean           peas_extension_set_callv       (PeasExtensionSet *set,
                                                    const gchar      *method_name,
                                                    GIArgument       *args);
 
+void               peas_extension_set_foreach     (PeasExtensionSet *set,
+                                                   PeasExtensionSetForeachFunc func,
+                                                   gpointer          data);
+
 PeasExtension     *peas_extension_set_get_extension (PeasExtensionSet *set,
                                                      PeasPluginInfo   *info);
 



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