[Xfce4-commits] <garcon:jannis/basic-monitoring> Lookup relative filenames with garcon_config_build_paths().

Jannis Pohlmann noreply at xfce.org
Sun Sep 5 15:56:01 CEST 2010


Updating branch refs/heads/jannis/basic-monitoring
         to 186d64776a647e7b924c20ae3d01ff24aaac18e5 (commit)
       from 8c25a7b68c86175c99c56848bc8ab54477bc5902 (commit)

commit 186d64776a647e7b924c20ae3d01ff24aaac18e5
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Sun Sep 5 15:47:12 2010 +0200

    Lookup relative filenames with garcon_config_build_paths().

 garcon/garcon-config.c                         |   31 ++++++++++++++++++++---
 garcon/{garcon-config.h.in => garcon-config.h} |   32 ++++++++++++------------
 2 files changed, 43 insertions(+), 20 deletions(-)

diff --git a/garcon/garcon-config.c b/garcon/garcon-config.c
index 56fef3d..1aee68d 100644
--- a/garcon/garcon-config.c
+++ b/garcon/garcon-config.c
@@ -1,6 +1,6 @@
 /* vi:set et ai sw=2 sts=2 ts=2: */
 /*-
- * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2009-2010 Jannis Pohlmann <jannis at xfce.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -9,11 +9,11 @@
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  * GNU Library General Public License for more details.
  *
- * You should have received a copy of the GNU Library General
- * Public License along with this library; if not, write to the
+ * You should have received a copy of the GNU Library General 
+ * Public License along with this library; if not, write to the 
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301, USA.
  */
@@ -122,6 +122,29 @@ garcon_check_version (guint required_major,
 
 
 
+gchar **
+garcon_config_build_paths (const gchar *filename)
+{
+  const gchar * const *dirs;
+  gchar              **paths;
+  guint                n;
+
+  g_return_val_if_fail (filename != NULL && *filename != '\0', NULL);
+
+  dirs = g_get_system_config_dirs ();
+
+  paths = g_new0 (gchar *, 1 + g_strv_length ((gchar **)dirs) + 1);
+  
+  paths[0] = g_build_filename (g_get_user_config_dir (), filename, NULL);
+  for (n = 1; dirs[n-1] != NULL; ++n)
+    paths[n] = g_build_filename (dirs[n-1], filename, NULL);
+  paths[n] = NULL;
+
+  return paths;
+}
+
+
+
 /**
  * garcon_config_lookup:
  * @filename : relative filename of the config resource.
diff --git a/garcon/garcon-config.h.in b/garcon/garcon-config.h
similarity index 72%
copy from garcon/garcon-config.h.in
copy to garcon/garcon-config.h
index baae3b8..0419d29 100644
--- a/garcon/garcon-config.h.in
+++ b/garcon/garcon-config.h
@@ -1,7 +1,6 @@
-/* $Id$ */
-/* vi:set expandtab sw=2 sts=2: */
+/* vi:set et ai sw=2 sts=2 ts=2: */
 /*-
- * Copyright (c) 2008 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2008-2010 Jannis Pohlmann <jannis at xfce.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -10,13 +9,13 @@
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * GNU Library General Public License for more details.
  *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Library General 
+ * Public License along with this library; if not, write to the 
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 #if !defined (GARCON_INSIDE_GARCON_H) && !defined (GARCON_COMPILATION)
@@ -38,7 +37,7 @@ G_BEGIN_DECLS
  * application compile time, rather than from the library
  * linked against at application run time.
  **/
-#define GARCON_MAJOR_VERSION @GARCON_VERSION_MAJOR@
+#define GARCON_MAJOR_VERSION 0
 
 /**
  * GARCON_MINOR_VERSION:
@@ -48,7 +47,7 @@ G_BEGIN_DECLS
  * application compile time, rather than from the library
  * linked against at application run time.
  **/
-#define GARCON_MINOR_VERSION @GARCON_VERSION_MINOR@
+#define GARCON_MINOR_VERSION 1
 
 /**
  * GARCON_MICRO_VERSION:
@@ -58,7 +57,7 @@ G_BEGIN_DECLS
  * application compile time, rather than from the library
  * linked against at application run time.
  **/
-#define GARCON_MICRO_VERSION @GARCON_VERSION_MICRO@
+#define GARCON_MICRO_VERSION 1
 
 /**
  * GARCON_CHECK_VERSION:
@@ -83,11 +82,12 @@ extern const guint garcon_major_version;
 extern const guint garcon_minor_version;
 extern const guint garcon_micro_version;
 
-const gchar *garcon_check_version (guint required_major,
-                                   guint required_minor,
-                                   guint required_micro);
+const gchar *garcon_check_version      (guint required_major,
+                                        guint required_minor,
+                                        guint required_micro);
 
-gchar       *garcon_config_lookup (const gchar *filename) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+gchar       *garcon_config_lookup      (const gchar *filename) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+gchar      **garcon_config_build_paths (const gchar *filename) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 
 G_END_DECLS
 



More information about the Xfce4-commits mailing list