[Xfce4-commits] <garcon:master> Always return a reffed version of the GFiles.

Nick Schermer nick at xfce.org
Sun Aug 16 19:02:01 CEST 2009


Updating branch refs/heads/master
         to 0d1df2d885a889fd974bdf01acec85a2018214f9 (commit)
       from 9d9b8994c5ffb0628b673a1c69ecd8af68c04062 (commit)

commit 0d1df2d885a889fd974bdf01acec85a2018214f9
Author: Nick Schermer <nick at xfce.org>
Date:   Sun Aug 16 19:01:49 2009 +0200

    Always return a reffed version of the GFiles.

 garcon/garcon-menu-directory.c  |   12 ++++++++++--
 garcon/garcon-menu-item-cache.c |    8 ++++++++
 garcon/garcon-menu-item.c       |   12 ++++++++++--
 garcon/garcon-menu.c            |   12 ++++++------
 4 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/garcon/garcon-menu-directory.c b/garcon/garcon-menu-directory.c
index 55a776b..ad54d8b 100644
--- a/garcon/garcon-menu-directory.c
+++ b/garcon/garcon-menu-directory.c
@@ -282,7 +282,7 @@ garcon_menu_directory_get_property (GObject    *object,
   switch (prop_id)
     {
     case PROP_FILE:
-      g_value_set_object (value, garcon_menu_directory_get_file (directory));
+      g_value_set_object (value, directory->priv->file);
       break;
 
     case PROP_NAME:
@@ -347,11 +347,19 @@ garcon_menu_directory_set_property (GObject      *object,
 
 
 
+/**
+ * garcon_menu_directory_get_file:
+ *
+ * Get the file for @directory.
+ * 
+ * Return value: a #GFile. The returned object 
+ * should be unreffed with g_object_unref() when no longer needed. 
+ */
 GFile *
 garcon_menu_directory_get_file (GarconMenuDirectory *directory)
 {
   g_return_val_if_fail (GARCON_IS_MENU_DIRECTORY (directory), NULL);
-  return directory->priv->file;
+  return g_object_ref (directory->priv->file);
 }
 
 
diff --git a/garcon/garcon-menu-item-cache.c b/garcon/garcon-menu-item-cache.c
index c8d4d24..26425af 100644
--- a/garcon/garcon-menu-item-cache.c
+++ b/garcon/garcon-menu-item-cache.c
@@ -138,6 +138,14 @@ garcon_menu_item_cache_init (GarconMenuItemCache *cache)
 
 
 
+/**
+ * garcon_menu_item_cache_get_default:
+ *
+ * Returns the default #GarconMenuItemCache.
+ * 
+ * Return value: the default #GarconMenuItemCache. The returned object 
+ * should be unreffed with g_object_unref() when no longer needed. 
+ */
 GarconMenuItemCache*
 garcon_menu_item_cache_get_default (void)
 {
diff --git a/garcon/garcon-menu-item.c b/garcon/garcon-menu-item.c
index ee9d15e..afce791 100644
--- a/garcon/garcon-menu-item.c
+++ b/garcon/garcon-menu-item.c
@@ -407,7 +407,7 @@ garcon_menu_item_get_property (GObject    *object,
   switch (prop_id)
     {
     case PROP_FILE:
-      g_value_set_object (value, garcon_menu_item_get_file (item));
+      g_value_set_object (value, item->priv->file);
       break;
 
     case PROP_DESKTOP_ID:
@@ -679,11 +679,19 @@ garcon_menu_item_new_for_uri (const gchar *uri)
 
 
 
+/**
+ * garcon_menu_item_get_file:
+ *
+ * Get the file for @item.
+ * 
+ * Return value: a #GFile. The returned object 
+ * should be unreffed with g_object_unref() when no longer needed. 
+ */
 GFile *
 garcon_menu_item_get_file (GarconMenuItem *item)
 {
   g_return_val_if_fail (GARCON_IS_MENU_ITEM (item), NULL);
-  return item->priv->file;
+  return g_object_ref (item->priv->file);
 }
 
 
diff --git a/garcon/garcon-menu.c b/garcon/garcon-menu.c
index b883353..851bf78 100644
--- a/garcon/garcon-menu.c
+++ b/garcon/garcon-menu.c
@@ -290,7 +290,7 @@ garcon_menu_get_property (GObject    *object,
       break;
 
     case PROP_DIRECTORY:
-      g_value_set_object (value, garcon_menu_get_directory (menu));
+      g_value_set_object (value, menu->priv->directory);
       break;
 
     default:
@@ -439,12 +439,11 @@ garcon_menu_new_applications (void)
  * garcon_menu_get_file:
  * @menu : a #GarconMenu.
  *
- * Returns the #GFile of @menu. It refers to the .menu file from which 
+ * Get the file for @menu. It refers to the .menu file from which 
  * @menu was or will be loaded.
- * The caller is responsible to free the returned object using
- * g_object_unref() when no longer needed.
  * 
- * Return value: the @GFile of @menu.
+ * Return value: a #GFile. The returned object 
+ * should be unreffed with g_object_unref() when no longer needed. 
  */
 GFile *
 garcon_menu_get_file (GarconMenu *menu)
@@ -476,7 +475,8 @@ garcon_menu_get_name (GarconMenu *menu)
  * should show up in etc.
  *
  * Return value: #GarconMenuDirectory of @menu or %NULL if
- *               @menu has no valid directory element.
+ *               @menu has no valid directory element. The returned object 
+ *               should be unreffed with g_object_unref() when no longer needed. 
  */
 GarconMenuDirectory*
 garcon_menu_get_directory (GarconMenu *menu)



More information about the Xfce4-commits mailing list