[Xfce4-commits] <garcon:master> Add garcon_menu_item_pool_lookup_file() to lookup items by GFiles.

Jannis Pohlmann noreply at xfce.org
Sun Sep 5 21:42:12 CEST 2010


Updating branch refs/heads/master
         to 04256aea7dacea084af219c190e8c2925e513464 (commit)
       from 2bfeb08bfb7f24cc075e22d15cc5405a13cf8456 (commit)

commit 04256aea7dacea084af219c190e8c2925e513464
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Sun Sep 5 19:08:12 2010 +0200

    Add garcon_menu_item_pool_lookup_file() to lookup items by GFiles.

 garcon/garcon-menu-item-pool.c |   28 ++++++++++++++++++++++++++++
 garcon/garcon-menu-item-pool.h |    2 ++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/garcon/garcon-menu-item-pool.c b/garcon/garcon-menu-item-pool.c
index b91b6af..e56043e 100644
--- a/garcon/garcon-menu-item-pool.c
+++ b/garcon/garcon-menu-item-pool.c
@@ -134,6 +134,34 @@ garcon_menu_item_pool_lookup (GarconMenuItemPool *pool,
 
 
 
+GarconMenuItem *
+garcon_menu_item_pool_lookup_file (GarconMenuItemPool *pool,
+                                   GFile              *file)
+{
+  GarconMenuItem *result = NULL;
+  GHashTableIter  iter;
+  gpointer        item;
+  GFile          *item_file;
+
+  g_return_val_if_fail (GARCON_IS_MENU_ITEM_POOL (pool), NULL);
+  g_return_val_if_fail (G_IS_FILE (file), NULL);
+
+  g_hash_table_iter_init (&iter, pool->priv->items);
+  while (result == NULL && g_hash_table_iter_next (&iter, NULL, &item))
+    {
+      item_file = garcon_menu_item_get_file (item);
+
+      if (g_file_equal (item_file, file))
+        result = item;
+
+      g_object_unref (item_file);
+    }
+
+  return result;
+}
+
+
+
 void
 garcon_menu_item_pool_foreach (GarconMenuItemPool *pool,
                                GHFunc              func,
diff --git a/garcon/garcon-menu-item-pool.h b/garcon/garcon-menu-item-pool.h
index 10fcfa4..36bd369 100644
--- a/garcon/garcon-menu-item-pool.h
+++ b/garcon/garcon-menu-item-pool.h
@@ -49,6 +49,8 @@ void                garcon_menu_item_pool_insert             (GarconMenuItemPool
                                                               GarconMenuItem     *item);
 GarconMenuItem     *garcon_menu_item_pool_lookup             (GarconMenuItemPool *pool,
                                                               const gchar        *desktop_id);
+GarconMenuItem     *garcon_menu_item_pool_lookup_file        (GarconMenuItemPool *pool,
+                                                              GFile              *file);
 void                garcon_menu_item_pool_foreach            (GarconMenuItemPool *pool,
                                                               GHFunc              func,
                                                               gpointer            user_data);



More information about the Xfce4-commits mailing list