[anjuta/system-db-refactor] libanjuta: Moved CppPackageScanner to libanjuta as AnjutaPkgScanner
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/system-db-refactor] libanjuta: Moved CppPackageScanner to libanjuta as AnjutaPkgScanner
- Date: Mon, 31 Jan 2011 22:01:18 +0000 (UTC)
commit 70abc5306a55e39aa6f37e15a3e28c106bb8aa26
Author: Johannes Schmid <jhs gnome org>
Date: Mon Jan 31 18:33:18 2011 +0100
libanjuta: Moved CppPackageScanner to libanjuta as AnjutaPkgScanner
libanjuta/Makefile.am | 9 +-
.../anjuta-pkg-scanner.c | 119 ++++++++++++-------
libanjuta/anjuta-pkg-scanner.h | 60 ++++++++++
plugins/language-support-cpp-java/Makefile.am | 4 +-
.../cpp-package-scanner.h | 62 ----------
plugins/language-support-cpp-java/cpp-packages.c | 16 ++--
6 files changed, 149 insertions(+), 121 deletions(-)
---
diff --git a/libanjuta/Makefile.am b/libanjuta/Makefile.am
index 6705212..f278a9f 100644
--- a/libanjuta/Makefile.am
+++ b/libanjuta/Makefile.am
@@ -117,6 +117,8 @@ libanjuta_3_la_SOURCES= \
anjuta-pkg-config-chooser.c \
anjuta-pkg-config.h \
anjuta-pkg-config.c \
+ anjuta-pkg-scanner.h \
+ anjuta-pkg-scanner.c \
anjuta-column-text-view.h \
anjuta-column-text-view.c \
anjuta-file-drop-entry.h \
@@ -187,13 +189,12 @@ libanjuta_include = \
anjuta-dock-pane.h \
anjuta-file-list.h \
anjuta-pkg-config-chooser.h \
- anjuta-pkg-config.h \
+ anjuta-pkg-config.h \
+ anjuta-pkg-scanner.h \
anjuta-column-text-view.h \
anjuta-file-drop-entry.h \
anjuta-entry.h
- anjuta-token.h \
- anjuta-pkg-config-chooser.h
-
+ anjuta-token.h
libanjutainclude_HEADERS = \
$(libanjuta_include) \
anjuta-enum-types.h \
diff --git a/plugins/language-support-cpp-java/cpp-package-scanner.c b/libanjuta/anjuta-pkg-scanner.c
similarity index 53%
rename from plugins/language-support-cpp-java/cpp-package-scanner.c
rename to libanjuta/anjuta-pkg-scanner.c
index cb10bd7..7fa38ca 100644
--- a/plugins/language-support-cpp-java/cpp-package-scanner.c
+++ b/libanjuta/anjuta-pkg-scanner.c
@@ -17,7 +17,18 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "cpp-package-scanner.h"
+/**
+ * SECTION: anjuta-pkg-scanner
+ * @short_description: Scan files contained by a library using pkg-config
+ * @see_also: #AnjutaAsyncCommand
+ * @include libanjuta/anjuta-pkg-scanner.h
+ *
+ * #AnjutaPkgScanner is an async command that can be used to query the list
+ * of files and the version of a package.
+ *
+ */
+
+#include <libanjuta/anjuta-pkg-scanner.h>
#include <libanjuta/anjuta-utils.h>
#include <libanjuta/anjuta-pkg-config.h>
#include <gio/gio.h>
@@ -26,44 +37,56 @@ enum
{
PROP_0,
PROP_PACKAGE,
- PROP_VERSION
+ PROP_VERSION
+};
+
+struct _AnjutaPkgScannerPrivate
+{
+ gchar* package;
+ gchar* version;
+ GList* files;
};
-G_DEFINE_TYPE (CppPackageScanner, cpp_package_scanner, ANJUTA_TYPE_ASYNC_COMMAND);
+G_DEFINE_TYPE (AnjutaPkgScanner, anjuta_pkg_scanner, ANJUTA_TYPE_ASYNC_COMMAND);
+
+
static void
-cpp_package_scanner_init (CppPackageScanner *object)
+anjuta_pkg_scanner_init (AnjutaPkgScanner *object)
{
- object->files = NULL;
+ object->priv = G_TYPE_INSTANCE_GET_PRIVATE (object,
+ ANJUTA_TYPE_PKG_SCANNER,
+ AnjutaPkgScannerPrivate);
+ object->priv->files = NULL;
}
static void
-cpp_package_scanner_finalize (GObject *object)
+anjuta_pkg_scanner_finalize (GObject *object)
{
- CppPackageScanner* scanner = CPP_PACKAGE_SCANNER (object);
- g_free (scanner->package);
- g_free (scanner->version);
- anjuta_util_glist_strings_free (scanner->files);
+ AnjutaPkgScanner* scanner = ANJUTA_PKG_SCANNER (object);
+ g_free (scanner->priv->package);
+ g_free (scanner->priv->version);
+ anjuta_util_glist_strings_free (scanner->priv->files);
- G_OBJECT_CLASS (cpp_package_scanner_parent_class)->finalize (object);
+ G_OBJECT_CLASS (anjuta_pkg_scanner_parent_class)->finalize (object);
}
static void
-cpp_package_scanner_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+anjuta_pkg_scanner_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
- CppPackageScanner* scanner;
+ AnjutaPkgScanner* scanner;
- g_return_if_fail (CPP_IS_PACKAGE_SCANNER (object));
+ g_return_if_fail (ANJUTA_IS_PKG_SCANNER (object));
- scanner = CPP_PACKAGE_SCANNER(object);
+ scanner = ANJUTA_PKG_SCANNER(object);
switch (prop_id)
{
case PROP_PACKAGE:
- scanner->package = g_value_dup_string (value);
+ scanner->priv->package = g_value_dup_string (value);
break;
case PROP_VERSION:
- scanner->version = g_value_dup_string (value);
+ scanner->priv->version = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -72,21 +95,21 @@ cpp_package_scanner_set_property (GObject *object, guint prop_id, const GValue *
}
static void
-cpp_package_scanner_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+anjuta_pkg_scanner_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
- CppPackageScanner* scanner;
+ AnjutaPkgScanner* scanner;
- g_return_if_fail (CPP_IS_PACKAGE_SCANNER (object));
+ g_return_if_fail (ANJUTA_IS_PKG_SCANNER (object));
- scanner = CPP_PACKAGE_SCANNER(object);
+ scanner = ANJUTA_PKG_SCANNER(object);
switch (prop_id)
{
case PROP_PACKAGE:
- g_value_set_string (value, scanner->package);
+ g_value_set_string (value, scanner->priv->package);
break;
case PROP_VERSION:
- g_value_set_string (value, scanner->version);
+ g_value_set_string (value, scanner->priv->version);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -95,7 +118,7 @@ cpp_package_scanner_get_property (GObject *object, guint prop_id, GValue *value,
}
static void
-cpp_package_scanner_list_files (GList **children, GFile *dir)
+anjuta_pkg_scanner_list_files (GList **children, GFile *dir)
{
GFileEnumerator *list;
@@ -120,7 +143,7 @@ cpp_package_scanner_list_files (GList **children, GFile *dir)
if (g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE, NULL) == G_FILE_TYPE_DIRECTORY)
{
- cpp_package_scanner_list_files (children, file);
+ anjuta_pkg_scanner_list_files (children, file);
}
else
{
@@ -135,32 +158,32 @@ cpp_package_scanner_list_files (GList **children, GFile *dir)
}
static guint
-cpp_package_scanner_run (AnjutaCommand* command)
+anjuta_pkg_scanner_run (AnjutaCommand* command)
{
- CppPackageScanner* scanner = CPP_PACKAGE_SCANNER (command);
- GList* dirs = anjuta_pkg_config_get_directories (scanner->package, TRUE, NULL);
+ AnjutaPkgScanner* scanner = ANJUTA_PKG_SCANNER (command);
+ GList* dirs = anjuta_pkg_config_get_directories (scanner->priv->package, TRUE, NULL);
GList* dir;
- g_message ("Scanning package: %s", scanner->package);
+ g_message ("Scanning package: %s", scanner->priv->package);
for (dir = dirs; dir != NULL; dir = g_list_next (dir))
{
GFile* file = g_file_new_for_path (dir->data);
- cpp_package_scanner_list_files (&scanner->files, file);
+ anjuta_pkg_scanner_list_files (&scanner->priv->files, file);
}
anjuta_util_glist_strings_free (dirs);
return 0;
}
static void
-cpp_package_scanner_class_init (CppPackageScannerClass *klass)
+anjuta_pkg_scanner_class_init (AnjutaPkgScannerClass *klass)
{
GObjectClass* object_class = G_OBJECT_CLASS (klass);
AnjutaCommandClass* command_class = ANJUTA_COMMAND_CLASS (klass);
- object_class->finalize = cpp_package_scanner_finalize;
- object_class->set_property = cpp_package_scanner_set_property;
- object_class->get_property = cpp_package_scanner_get_property;
+ object_class->finalize = anjuta_pkg_scanner_finalize;
+ object_class->set_property = anjuta_pkg_scanner_set_property;
+ object_class->get_property = anjuta_pkg_scanner_get_property;
g_object_class_install_property (object_class,
PROP_PACKAGE,
@@ -178,15 +201,23 @@ cpp_package_scanner_class_init (CppPackageScannerClass *klass)
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- command_class->run = cpp_package_scanner_run;
-}
+ command_class->run = anjuta_pkg_scanner_run;
+ g_type_class_add_private (klass, sizeof (AnjutaPkgScannerPrivate));
+}
+/*
+ * anjuta_pkg_scanner_new:
+ * @package: Name of the package to scan
+ * @version: Version of the package
+ *
+ * Returns: a new #AnjutaCommand to scan for files.
+ */
AnjutaCommand*
-cpp_package_scanner_new (const gchar* package, const gchar* version)
+anjuta_pkg_scanner_new (const gchar* package, const gchar* version)
{
GObject* object =
- g_object_new (CPP_TYPE_PACKAGE_SCANNER,
+ g_object_new (ANJUTA_TYPE_PKG_SCANNER,
"package", package,
"version", version,
NULL);
@@ -195,18 +226,18 @@ cpp_package_scanner_new (const gchar* package, const gchar* version)
}
const gchar*
-cpp_package_scanner_get_package (CppPackageScanner* scanner)
+anjuta_pkg_scanner_get_package (AnjutaPkgScanner* scanner)
{
- return scanner->package;
+ return scanner->priv->package;
}
const gchar*
-cpp_package_scanner_get_version (CppPackageScanner* scanner)
+anjuta_pkg_scanner_get_version (AnjutaPkgScanner* scanner)
{
- return scanner->version;
+ return scanner->priv->version;
}
GList*
-cpp_package_scanner_get_files (CppPackageScanner* scanner)
+anjuta_pkg_scanner_get_files (AnjutaPkgScanner* scanner)
{
- return scanner->files;
+ return scanner->priv->files;
}
diff --git a/libanjuta/anjuta-pkg-scanner.h b/libanjuta/anjuta-pkg-scanner.h
new file mode 100644
index 0000000..2e036f9
--- /dev/null
+++ b/libanjuta/anjuta-pkg-scanner.h
@@ -0,0 +1,60 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) Johannes Schmid 2011 <jhs Obelix>
+ *
+ * anjuta is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * anjuta 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _ANJUTA_PKG_SCANNER_H_
+#define _ANJUTA_PKG_SCANNER_H_
+
+#include <libanjuta/anjuta-async-command.h>
+
+G_BEGIN_DECLS
+
+#define ANJUTA_TYPE_PKG_SCANNER (anjuta_pkg_scanner_get_type ())
+#define ANJUTA_PKG_SCANNER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_PKG_SCANNER, AnjutaPkgScanner))
+#define ANJUTA_PKG_SCANNER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_PKG_SCANNER, AnjutaPkgScannerClass))
+#define ANJUTA_IS_PKG_SCANNER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_PKG_SCANNER))
+#define ANJUTA_IS_PKG_SCANNER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_PKG_SCANNER))
+#define ANJUTA_PKG_SCANNER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ANJUTA_TYPE_PKG_SCANNER, AnjutaPkgScannerClass))
+
+typedef struct _AnjutaPkgScannerClass AnjutaPkgScannerClass;
+typedef struct _AnjutaPkgScanner AnjutaPkgScanner;
+typedef struct _AnjutaPkgScannerPrivate AnjutaPkgScannerPrivate;
+
+struct _AnjutaPkgScannerClass
+{
+ AnjutaAsyncCommandClass parent_class;
+
+};
+
+struct _AnjutaPkgScanner
+{
+ AnjutaAsyncCommand parent_instance;
+
+ AnjutaPkgScannerPrivate* priv;
+};
+
+GType anjuta_pkg_scanner_get_type (void) G_GNUC_CONST;
+AnjutaCommand* anjuta_pkg_scanner_new (const gchar* package, const gchar* version);
+const gchar* anjuta_pkg_scanner_get_package (AnjutaPkgScanner* scanner);
+const gchar* anjuta_pkg_scanner_get_version (AnjutaPkgScanner* scanner);
+GList* anjuta_pkg_scanner_get_files (AnjutaPkgScanner* scanner);
+
+
+G_END_DECLS
+
+#endif /* _ANJUTA_PKG_SCANNER_H_ */
diff --git a/plugins/language-support-cpp-java/Makefile.am b/plugins/language-support-cpp-java/Makefile.am
index fe5024c..914429e 100644
--- a/plugins/language-support-cpp-java/Makefile.am
+++ b/plugins/language-support-cpp-java/Makefile.am
@@ -55,9 +55,7 @@ libanjuta_language_cpp_java_la_SOURCES = \
cpp-java-indentation.c \
cpp-java-indentation.h \
cpp-packages.c \
- cpp-packages.h \
- cpp-package-scanner.h \
- cpp-package-scanner.c
+ cpp-packages.h
libanjuta_language_cpp_java_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
diff --git a/plugins/language-support-cpp-java/cpp-packages.c b/plugins/language-support-cpp-java/cpp-packages.c
index 4ec75ee..970e149 100644
--- a/plugins/language-support-cpp-java/cpp-packages.c
+++ b/plugins/language-support-cpp-java/cpp-packages.c
@@ -18,11 +18,11 @@
*/
#include "cpp-packages.h"
-#include "cpp-package-scanner.h"
#include <libanjuta/interfaces/ianjuta-project-manager.h>
#include <libanjuta/interfaces/ianjuta-symbol-manager.h>
#include <libanjuta/anjuta-pkg-config.h>
+#include <libanjuta/anjuta-pkg-scanner.h>
#include <libanjuta/anjuta-debug.h>
enum
@@ -109,14 +109,14 @@ on_package_ready (AnjutaCommand* command,
gint return_code,
IAnjutaSymbolManager* sm)
{
- CppPackageScanner* scanner = CPP_PACKAGE_SCANNER (command);
- if (g_list_length (cpp_package_scanner_get_files (scanner)))
+ AnjutaPkgScanner* scanner = ANJUTA_PKG_SCANNER (command);
+ if (g_list_length (anjuta_pkg_scanner_get_files (scanner)))
{
- g_message ("Adding package: %s", cpp_package_scanner_get_package (scanner));
+ g_message ("Adding package: %s", anjuta_pkg_scanner_get_package (scanner));
ianjuta_symbol_manager_add_package (sm,
- cpp_package_scanner_get_package (scanner),
- cpp_package_scanner_get_version (scanner),
- cpp_package_scanner_get_files (scanner),
+ anjuta_pkg_scanner_get_package (scanner),
+ anjuta_pkg_scanner_get_version (scanner),
+ anjuta_pkg_scanner_get_files (scanner),
NULL);
}
g_object_unref (command);
@@ -144,7 +144,7 @@ cpp_packages_load_real (CppPackages* packages, GError* error, IAnjutaProjectMana
{
PackageData* pkg_data = pkg->data;
AnjutaCommand* command =
- cpp_package_scanner_new (pkg_data->pkg, pkg_data->version);
+ anjuta_pkg_scanner_new (pkg_data->pkg, pkg_data->version);
g_signal_connect (command, "command-finished",
G_CALLBACK (on_package_ready), sm);
anjuta_command_queue_push (packages->queue, command);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]