[anjuta/system-db-refactor: 8/12] libanjuta: Add a method to query the version to anjuta-pkg-config
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/system-db-refactor: 8/12] libanjuta: Add a method to query the version to anjuta-pkg-config
- Date: Wed, 26 Jan 2011 23:22:01 +0000 (UTC)
commit 881797b90af069e504bcbe9611df9543923e65d8
Author: Johannes Schmid <jhs gnome org>
Date: Thu Jan 27 00:19:16 2011 +0100
libanjuta: Add a method to query the version to anjuta-pkg-config
libanjuta/anjuta-pkg-config.c | 44 +++++++++++++++++++++++++++++++++++++++-
libanjuta/anjuta-pkg-config.h | 4 ++-
2 files changed, 45 insertions(+), 3 deletions(-)
---
diff --git a/libanjuta/anjuta-pkg-config.c b/libanjuta/anjuta-pkg-config.c
index 6a663df..a77c48e 100644
--- a/libanjuta/anjuta-pkg-config.c
+++ b/libanjuta/anjuta-pkg-config.c
@@ -22,6 +22,7 @@
#include <libanjuta/anjuta-pkg-config.h>
#include <libanjuta/anjuta-utils.h>
+#include <libanjuta/anjuta-debug.h>
/* Blacklist for packages that shouldn't be parsed. Those packages
* usually contain the same include paths as their top-level package
@@ -152,7 +153,7 @@ anjuta_pkg_config_get_directories (const gchar* pkg_name, gboolean no_deps, GErr
}
/*
- * anjuta_pkg_config_ignore_package
+ * anjuta_pkg_config_ignore_package:
* @name: Name of the package to ignore
*
* Returns: TRUE if the package does not contain
@@ -169,4 +170,43 @@ anjuta_pkg_config_ignore_package (const gchar* name)
return TRUE;
}
return FALSE;
-}
\ No newline at end of file
+}
+
+/*
+ * anjuta_pkg_config_get_version:
+ * @package: Name of the package
+ *
+ * This does sync io, call from a thread if necessary
+ *
+ * Returns: (transfer full) the version of the package or NULL
+ */
+gchar* anjuta_pkg_config_get_version (const gchar* package)
+{
+ gchar *cmd;
+ gchar *err;
+ gchar *out;
+ gint status;
+ GError* error;
+
+ cmd = g_strdup_printf ("pkg-config --modversion %s", package);
+
+ if (g_spawn_command_line_sync (cmd, &out, &err, &status, &error))
+ {
+ g_free (err);
+ g_free (cmd);
+ return out;
+ }
+ else
+ {
+ g_free (out);
+ g_free (err);
+ g_free (cmd);
+ if (error)
+ {
+ DEBUG_PRINT ("Could query package version: %s", error->message);
+ g_error_free (error);
+ }
+ return NULL;
+ }
+}
+
diff --git a/libanjuta/anjuta-pkg-config.h b/libanjuta/anjuta-pkg-config.h
index 693c484..72ab573 100644
--- a/libanjuta/anjuta-pkg-config.h
+++ b/libanjuta/anjuta-pkg-config.h
@@ -24,4 +24,6 @@ GList* anjuta_pkg_config_list_dependencies (const gchar* package,
GList* anjuta_pkg_config_get_directories (const gchar* pkg_name,
gboolean no_deps,
GError** error);
-gboolean anjuta_pkg_config_ignore_package (const gchar* name);
\ No newline at end of file
+gboolean anjuta_pkg_config_ignore_package (const gchar* name);
+
+gchar* anjuta_pkg_config_get_version (const gchar* package);
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]