[Xfce4-commits] <garcon:master> Some cleanups in GarconMenuDirectory.

Nick Schermer nick at xfce.org
Mon Aug 17 18:16:01 CEST 2009


Updating branch refs/heads/master
         to 5e86ee0b43af1449e6fb25dcfd29b8f8caa5eeca (commit)
       from 5fd39acafa47ba6591b265b2aa14f297cec005b6 (commit)

commit 5e86ee0b43af1449e6fb25dcfd29b8f8caa5eeca
Author: Nick Schermer <nick at xfce.org>
Date:   Mon Aug 17 17:16:36 2009 +0200

    Some cleanups in GarconMenuDirectory.

 garcon/garcon-menu-directory.c |  157 +++++++++++++++-------------------------
 garcon/garcon-menu-directory.h |   20 ++++--
 garcon/garcon.c                |    7 --
 3 files changed, 74 insertions(+), 110 deletions(-)

diff --git a/garcon/garcon-menu-directory.c b/garcon/garcon-menu-directory.c
index 2a3e057..15ccabf 100644
--- a/garcon/garcon-menu-directory.c
+++ b/garcon/garcon-menu-directory.c
@@ -30,20 +30,6 @@
 
 
 
-void
-_garcon_menu_directory_init (void)
-{
-}
-
-
-
-void
-_garcon_menu_directory_shutdown (void)
-{
-}
-
-
-
 #define GARCON_MENU_DIRECTORY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GARCON_TYPE_MENU_DIRECTORY, GarconMenuDirectoryPrivate))
 
 
@@ -89,7 +75,6 @@ static void garcon_menu_directory_set_property (GObject                  *object
                                                 guint                     prop_id,
                                                 const GValue             *value,
                                                 GParamSpec               *pspec);
-static void garcon_menu_directory_free_private (GarconMenuDirectory      *directory);
 static void garcon_menu_directory_load         (GarconMenuDirectory      *directory);
 
 
@@ -121,19 +106,6 @@ struct _GarconMenuDirectoryPrivate
   guint   no_display : 1;
 };
 
-struct _GarconMenuDirectoryClass
-{
-  GObjectClass __parent__;
-};
-
-struct _GarconMenuDirectory
-{
-  GObject                        __parent__;
-
-  /* < private > */
-  GarconMenuDirectoryPrivate *priv;
-};
-
 
 
 G_DEFINE_TYPE (GarconMenuDirectory, garcon_menu_directory, G_TYPE_OBJECT)
@@ -260,8 +232,18 @@ garcon_menu_directory_finalize (GObject *object)
 {
   GarconMenuDirectory *directory = GARCON_MENU_DIRECTORY (object);
 
-  /* Free private data */
-  garcon_menu_directory_free_private (directory);
+  /* Free name */
+  g_free (directory->priv->name);
+
+  /* Free comment */
+  g_free (directory->priv->comment);
+
+  /* Free icon */
+  g_free (directory->priv->icon);
+
+  /* Free environment lists */
+  g_strfreev (directory->priv->only_show_in);
+  g_strfreev (directory->priv->not_show_in);
 
   /* Free file */
   g_object_unref (directory->priv->file);
@@ -347,6 +329,53 @@ garcon_menu_directory_set_property (GObject      *object,
 
 
 
+static void
+garcon_menu_directory_load (GarconMenuDirectory *directory)
+{
+  GKeyFile    *entry;
+  GError      *error = NULL;
+  const gchar *name;
+  const gchar *comment;
+  const gchar *icon;
+  gchar       *filename;
+
+  g_return_if_fail (GARCON_IS_MENU_DIRECTORY (directory));
+
+  /* TODO: Use get_uri() here, together with g_file_read() and
+   * g_key_file_load_from_data() */
+
+  filename = g_file_get_path (directory->priv->file);
+  entry = g_key_file_new ();
+  g_key_file_load_from_file (entry, filename, G_KEY_FILE_NONE, &error);
+  g_free (filename);
+
+  if (G_UNLIKELY (error != NULL))
+    {
+      g_error_free (error);
+      return;
+    }
+
+  /* Read directory information */
+  name = g_key_file_get_locale_string (entry, "Desktop Entry", "Name", NULL, NULL);
+  comment = g_key_file_get_locale_string (entry, "Desktop Entry", "Comment", NULL, NULL);
+  icon = g_key_file_get_locale_string (entry, "Desktop Entry", "Icon", NULL, NULL);
+
+  /* Pass data to the directory */
+  garcon_menu_directory_set_name (directory, name);
+  garcon_menu_directory_set_comment (directory, comment);
+  garcon_menu_directory_set_icon (directory, icon);
+  garcon_menu_directory_set_no_display (directory, g_key_file_get_boolean (entry, "Desktop Entry", "NoDisplay", NULL));
+
+  /* Set rest of the private data directly */
+  directory->priv->only_show_in = g_key_file_get_string_list (entry, "Desktop Entry", "OnlyShowIn", NULL, NULL);
+  directory->priv->not_show_in = g_key_file_get_string_list (entry, "Desktop Entry", "NotShowIn", NULL, NULL);
+  directory->priv->hidden = g_key_file_get_boolean (entry, "Desktop Entry", "Hidden", NULL);
+
+  g_key_file_free (entry);
+}
+
+
+
 /**
  * garcon_menu_directory_get_file:
  *
@@ -476,74 +505,6 @@ garcon_menu_directory_set_no_display (GarconMenuDirectory *directory,
 
 
 
-static void
-garcon_menu_directory_free_private (GarconMenuDirectory *directory)
-{
-  g_return_if_fail (GARCON_IS_MENU_DIRECTORY (directory));
-
-  /* Free name */
-  g_free (directory->priv->name);
-
-  /* Free comment */
-  g_free (directory->priv->comment);
-
-  /* Free icon */
-  g_free (directory->priv->icon);
-
-  /* Free environment lists */
-  g_strfreev (directory->priv->only_show_in);
-  g_strfreev (directory->priv->not_show_in);
-}
-
-
-
-static void
-garcon_menu_directory_load (GarconMenuDirectory *directory)
-{
-  GKeyFile    *entry;
-  GError      *error = NULL;
-  const gchar *name;
-  const gchar *comment;
-  const gchar *icon;
-  gchar       *filename;
-
-  g_return_if_fail (GARCON_IS_MENU_DIRECTORY (directory));
-
-  /* TODO: Use get_uri() here, together with g_file_read() and
-   * g_key_file_load_from_data() */
-
-  filename = g_file_get_path (directory->priv->file);
-  entry = g_key_file_new ();
-  g_key_file_load_from_file (entry, filename, G_KEY_FILE_NONE, &error);
-  g_free (filename);
-
-  if (G_UNLIKELY (error != NULL))
-    {
-      g_error_free (error);
-      return;
-    }
-
-  /* Read directory information */
-  name = g_key_file_get_locale_string (entry, "Desktop Entry", "Name", NULL, NULL);
-  comment = g_key_file_get_locale_string (entry, "Desktop Entry", "Comment", NULL, NULL);
-  icon = g_key_file_get_locale_string (entry, "Desktop Entry", "Icon", NULL, NULL);
-
-  /* Pass data to the directory */
-  garcon_menu_directory_set_name (directory, name);
-  garcon_menu_directory_set_comment (directory, comment);
-  garcon_menu_directory_set_icon (directory, icon);
-  garcon_menu_directory_set_no_display (directory, g_key_file_get_boolean (entry, "Desktop Entry", "NoDisplay", NULL));
-
-  /* Set rest of the private data directly */
-  directory->priv->only_show_in = g_key_file_get_string_list (entry, "Desktop Entry", "OnlyShowIn", NULL, NULL);
-  directory->priv->not_show_in = g_key_file_get_string_list (entry, "Desktop Entry", "NotShowIn", NULL, NULL);
-  directory->priv->hidden = g_key_file_get_boolean (entry, "Desktop Entry", "Hidden", NULL);
-
-  g_key_file_free (entry);
-}
-
-
-
 gboolean
 garcon_menu_directory_get_hidden (GarconMenuDirectory *directory)
 {
diff --git a/garcon/garcon-menu-directory.h b/garcon/garcon-menu-directory.h
index 8d01c96..6c8e7fc 100644
--- a/garcon/garcon-menu-directory.h
+++ b/garcon/garcon-menu-directory.h
@@ -40,6 +40,21 @@ typedef struct _GarconMenuDirectoryPrivate GarconMenuDirectoryPrivate;
 typedef struct _GarconMenuDirectoryClass   GarconMenuDirectoryClass;
 typedef struct _GarconMenuDirectory        GarconMenuDirectory;
 
+struct _GarconMenuDirectoryClass
+{
+  GObjectClass __parent__;
+};
+
+struct _GarconMenuDirectory
+{
+  GObject __parent__;
+
+  /* < private > */
+  GarconMenuDirectoryPrivate *priv;
+};
+
+
+
 GType        garcon_menu_directory_get_type                (void) G_GNUC_CONST;
 
 GFile       *garcon_menu_directory_get_file                (GarconMenuDirectory *directory);
@@ -61,11 +76,6 @@ gboolean     garcon_menu_directory_get_visible             (GarconMenuDirectory
 gboolean     garcon_menu_directory_equal                   (GarconMenuDirectory *directory,
                                                             GarconMenuDirectory *other);
 
-#if defined(GARCON_COMPILATION)
-void _garcon_menu_directory_init     (void) G_GNUC_INTERNAL;
-void _garcon_menu_directory_shutdown (void) G_GNUC_INTERNAL;
-#endif
-
 G_END_DECLS
 
 #endif /* !__GARCON_MENU_DIRECTORY_H__ */
diff --git a/garcon/garcon.c b/garcon/garcon.c
index 1ac73a4..d1a646c 100644
--- a/garcon/garcon.c
+++ b/garcon/garcon.c
@@ -27,7 +27,6 @@
 #include <garcon/garcon.h>
 #include <garcon/garcon-environment.h>
 #include <garcon/garcon-menu-item-cache.h>
-#include <garcon/garcon-menu-directory.h>
 #include <garcon/garcon-menu-separator.h>
 
 
@@ -73,9 +72,6 @@ garcon_init (const gchar *env)
       /* Initialize the menu item cache */
       _garcon_menu_item_cache_init ();
 
-      /* Initialize the directory module */
-      _garcon_menu_directory_init ();
-
       /* Creates the menu separator */
       _garcon_menu_separator_init ();
    }
@@ -99,9 +95,6 @@ garcon_shutdown (void)
       /* Destroys the menu separator */
       _garcon_menu_separator_shutdown ();
 
-      /* Shutdown the directory module */
-      _garcon_menu_directory_shutdown ();
-
       /* Shutdown the menu item cache */
       _garcon_menu_item_cache_shutdown ();
     }



More information about the Xfce4-commits mailing list