[gnome-builder: 51/139] libide-search: add libide-search static library



commit 38b937474d0673196830d87b8174e0171f8d0341
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 9 16:41:51 2019 -0800

    libide-search: add libide-search static library
    
    This adds a new libide-search static library with the components necessary
    for running the search engine.

 src/libide/search/ide-search-engine.h   |  6 ++--
 src/libide/search/ide-search-provider.c |  7 ++--
 src/libide/search/ide-search-provider.h |  6 ++--
 src/libide/search/ide-search-reducer.c  |  8 ++---
 src/libide/search/ide-search-reducer.h  |  8 +++--
 src/libide/search/ide-search-result.c   | 27 +++++++--------
 src/libide/search/ide-search-result.h   | 25 ++++++--------
 src/libide/search/libide-search.h       | 34 ++++++++++++++++++
 src/libide/search/meson.build           | 61 +++++++++++++++++++++++++++------
 9 files changed, 128 insertions(+), 54 deletions(-)
---
diff --git a/src/libide/search/ide-search-engine.h b/src/libide/search/ide-search-engine.h
index 960abef50..bb9ef1a73 100644
--- a/src/libide/search/ide-search-engine.h
+++ b/src/libide/search/ide-search-engine.h
@@ -20,9 +20,11 @@
 
 #pragma once
 
-#include "ide-version-macros.h"
+#if !defined (IDE_SEARCH_INSIDE) && !defined (IDE_SEARCH_COMPILATION)
+# error "Only <libide-search.h> can be included directly."
+#endif
 
-#include "ide-object.h"
+#include <libide-core.h>
 
 G_BEGIN_DECLS
 
diff --git a/src/libide/search/ide-search-provider.c b/src/libide/search/ide-search-provider.c
index 385620d97..95dd176a3 100644
--- a/src/libide/search/ide-search-provider.c
+++ b/src/libide/search/ide-search-provider.c
@@ -22,8 +22,9 @@
 
 #include "config.h"
 
-#include "search/ide-search-provider.h"
-#include "threading/ide-task.h"
+#include <libide-threading.h>
+
+#include "ide-search-provider.h"
 
 G_DEFINE_INTERFACE (IdeSearchProvider, ide_search_provider, IDE_TYPE_OBJECT)
 
@@ -88,7 +89,7 @@ ide_search_provider_search_async (IdeSearchProvider   *self,
  *
  * Completes a request to a search provider.
  *
- * Returns: (transfer full) (element-type Ide.SearchResult): a #GPtrArray
+ * Returns: (transfer full) (element-type IdeSearchResult): a #GPtrArray
  *    of #IdeSearchResult elements.
  *
  * Since: 3.32
diff --git a/src/libide/search/ide-search-provider.h b/src/libide/search/ide-search-provider.h
index 62a6f11d2..dee906538 100644
--- a/src/libide/search/ide-search-provider.h
+++ b/src/libide/search/ide-search-provider.h
@@ -20,9 +20,11 @@
 
 #pragma once
 
-#include "ide-version-macros.h"
+#if !defined (IDE_SEARCH_INSIDE) && !defined (IDE_SEARCH_COMPILATION)
+# error "Only <libide-search.h> can be included directly."
+#endif
 
-#include "ide-object.h"
+#include <libide-core.h>
 
 G_BEGIN_DECLS
 
diff --git a/src/libide/search/ide-search-reducer.c b/src/libide/search/ide-search-reducer.c
index 7a3adf90b..2ea4642e2 100644
--- a/src/libide/search/ide-search-reducer.c
+++ b/src/libide/search/ide-search-reducer.c
@@ -1,6 +1,6 @@
 /* ide-search-reducer.c
  *
- * Copyright 2015-2019 Christian Hergert <christian hergert me>
+ * Copyright 2015-2019 Christian Hergert <chergert redhat com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,8 +22,8 @@
 
 #include "config.h"
 
-#include "search/ide-search-reducer.h"
-#include "search/ide-search-result.h"
+#include "ide-search-reducer.h"
+#include "ide-search-result.h"
 
 /**
  * SECTION:ide-search-reducer
@@ -85,7 +85,7 @@ ide_search_reducer_destroy (IdeSearchReducer *reducer)
  * Frees all items associated with the result set, unless @free_results is
  * %FALSE and then the results are returned as an array.
  *
- * Returns: (nullable) (transfer container) (element-type Ide.SearchResult):
+ * Returns: (nullable) (transfer container) (element-type IdeSearchResult):
  *   An array of #IdeSearchResult unless @free_results is %TRUE, then
  *   %NULL is returned.
  *
diff --git a/src/libide/search/ide-search-reducer.h b/src/libide/search/ide-search-reducer.h
index ba2047ee1..9d3a2610c 100644
--- a/src/libide/search/ide-search-reducer.h
+++ b/src/libide/search/ide-search-reducer.h
@@ -20,9 +20,13 @@
 
 #pragma once
 
-#include "ide-version-macros.h"
+#if !defined (IDE_SEARCH_INSIDE) && !defined (IDE_SEARCH_COMPILATION)
+# error "Only <libide-search.h> can be included directly."
+#endif
 
-#include "ide-types.h"
+#include <libide-core.h>
+
+#include "ide-search-result.h"
 
 G_BEGIN_DECLS
 
diff --git a/src/libide/search/ide-search-result.c b/src/libide/search/ide-search-result.c
index 33c593827..3d6385b58 100644
--- a/src/libide/search/ide-search-result.c
+++ b/src/libide/search/ide-search-result.c
@@ -22,7 +22,7 @@
 
 #include "config.h"
 
-#include "search/ide-search-result.h"
+#include "ide-search-result.h"
 
 typedef struct
 {
@@ -231,27 +231,24 @@ ide_search_result_set_priority (IdeSearchResult *self,
 }
 
 /**
- * ide_search_result_get_source_location:
+ * ide_search_result_activate:
  * @self: a #IdeSearchResult
+ * @last_focus: a #GtkWidget of the last focus
  *
- * Gets the file associated with the search result if any.
- *
- * Many search providers ultimately just open a file, so this may
- * be used in lieu of handling the activate signal.
- *
- * Returns: (transfer full) (nullable): An #IdeUri
+ * Requests that @self activate. @last_focus is provided so that the search
+ * result may activate #GAction or other context-specific actions.
  *
  * Since: 3.32
  */
-IdeSourceLocation *
-ide_search_result_get_source_location (IdeSearchResult *self)
+void
+ide_search_result_activate (IdeSearchResult *self,
+                            GtkWidget       *last_focus)
 {
-  g_return_val_if_fail (IDE_IS_SEARCH_RESULT (self), NULL);
-
-  if (IDE_SEARCH_RESULT_GET_CLASS (self)->get_source_location != NULL)
-    return IDE_SEARCH_RESULT_GET_CLASS (self)->get_source_location (self);
+  g_return_if_fail (IDE_IS_SEARCH_RESULT (self));
+  g_return_if_fail (GTK_IS_WIDGET (last_focus));
 
-  return NULL;
+  if (IDE_SEARCH_RESULT_GET_CLASS (self)->activate)
+    IDE_SEARCH_RESULT_GET_CLASS (self)->activate (self, last_focus);
 }
 
 void
diff --git a/src/libide/search/ide-search-result.h b/src/libide/search/ide-search-result.h
index 240d30dcc..7f0b25237 100644
--- a/src/libide/search/ide-search-result.h
+++ b/src/libide/search/ide-search-result.h
@@ -20,12 +20,12 @@
 
 #pragma once
 
-#include <gio/gio.h>
-#include <dazzle.h>
-
-#include "ide-version-macros.h"
+#if !defined (IDE_SEARCH_INSIDE) && !defined (IDE_SEARCH_COMPILATION)
+# error "Only <libide-search.h> can be included directly."
+#endif
 
-#include "diagnostics/ide-source-location.h"
+#include <libide-core.h>
+#include <dazzle.h>
 
 G_BEGIN_DECLS
 
@@ -38,23 +38,18 @@ struct _IdeSearchResultClass
 {
   DzlSuggestionClass parent_class;
 
-  IdeSourceLocation *(*get_source_location) (IdeSearchResult *self);
+  void (*activate) (IdeSearchResult *self,
+                    GtkWidget       *last_focus);
 
   /*< private >*/
-  gpointer _reserved1;
-  gpointer _reserved2;
-  gpointer _reserved3;
-  gpointer _reserved4;
-  gpointer _reserved5;
-  gpointer _reserved6;
-  gpointer _reserved7;
-  gpointer _reserved8;
+  gpointer _reserved[8];
 };
 
 IDE_AVAILABLE_IN_3_32
 IdeSearchResult   *ide_search_result_new                 (void);
 IDE_AVAILABLE_IN_3_32
-IdeSourceLocation *ide_search_result_get_source_location (IdeSearchResult       *self);
+void               ide_search_result_activate            (IdeSearchResult       *self,
+                                                          GtkWidget             *last_focus);
 IDE_AVAILABLE_IN_3_32
 gint               ide_search_result_compare             (gconstpointer          a,
                                                           gconstpointer          b);
diff --git a/src/libide/search/libide-search.h b/src/libide/search/libide-search.h
new file mode 100644
index 000000000..e0c0df866
--- /dev/null
+++ b/src/libide/search/libide-search.h
@@ -0,0 +1,34 @@
+/* libide-search.h
+ *
+ * Copyright 2014-2019 Christian Hergert <chergert redhat com>
+ *
+ * This program 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.
+ *
+ * This program 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/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <dazzle.h>
+#include <libide-core.h>
+#include <libide-threading.h>
+
+#define IDE_SEARCH_INSIDE
+
+#include "ide-search-engine.h"
+#include "ide-search-provider.h"
+#include "ide-search-reducer.h"
+#include "ide-search-result.h"
+
+#undef IDE_SEARCH_INSIDE
diff --git a/src/libide/search/meson.build b/src/libide/search/meson.build
index 967ceacfd..e5b3b43ab 100644
--- a/src/libide/search/meson.build
+++ b/src/libide/search/meson.build
@@ -1,22 +1,61 @@
-search_headers = [
+libide_search_header_subdir = join_paths(libide_header_subdir, 'search')
+libide_include_directories += include_directories('.')
+
+#
+# Public API Headers
+#
+
+libide_search_public_headers = [
   'ide-search-engine.h',
-  'ide-search-entry.h',
   'ide-search-provider.h',
-  'ide-search-result.h',
   'ide-search-reducer.h',
-  'ide-tagged-entry.h',
+  'ide-search-result.h',
+  'libide-search.h',
 ]
 
-search_sources = [
+install_headers(libide_search_public_headers, subdir: libide_search_header_subdir)
+
+#
+# Sources
+#
+
+libide_search_public_sources = [
   'ide-search-engine.c',
-  'ide-search-entry.c',
   'ide-search-provider.c',
-  'ide-search-result.c',
   'ide-search-reducer.c',
-  'ide-tagged-entry.c',
+  'ide-search-result.c',
 ]
 
-libide_public_headers += files(search_headers)
-libide_public_sources += files(search_sources)
+libide_search_sources = libide_search_public_sources
+
+#
+# Dependencies
+#
+
+libide_search_deps = [
+  libgio_dep,
+  libdazzle_dep,
+  libpeas_dep,
+  libide_core_dep,
+  libide_threading_dep,
+]
+
+#
+# Library Definitions
+#
+
+libide_search = static_library('ide-search-' + libide_api_version, libide_search_sources,
+   dependencies: libide_search_deps,
+         c_args: libide_args + release_args + ['-DIDE_SEARCH_COMPILATION'],
+)
+
+libide_search_dep = declare_dependency(
+         dependencies: libide_search_deps,
+           link_whole: libide_search,
+  include_directories: include_directories('.'),
+)
 
-install_headers(search_headers, subdir: join_paths(libide_header_subdir, 'search'))
+gnome_builder_public_sources += files(libide_search_public_sources)
+gnome_builder_public_headers += files(libide_search_public_headers)
+gnome_builder_include_subdirs += libide_search_header_subdir
+gnome_builder_gir_extra_args += ['--c-include=libide-search.h', '-DIDE_SEARCH_COMPILATION']


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]