[gnome-builder] wip: start on file-search



commit baf46617fb0e920da773cbdacfc786f8ddee633b
Author: Christian Hergert <christian hergert me>
Date:   Fri Jun 12 16:51:03 2015 -0700

    wip: start on file-search

 configure.ac                                     |    1 +
 plugins/Makefile.am                              |    1 +
 plugins/file-search/Makefile.am                  |   43 +++++++
 plugins/file-search/gb-file-search-index.c       |  129 ++++++++++++++++++++++
 plugins/file-search/gb-file-search-index.h       |   32 ++++++
 plugins/file-search/gb-file-search-plugin.c      |   28 +++++
 plugins/file-search/gb-file-search-provider.c    |   79 +++++++++++++
 plugins/file-search/gb-file-search-provider.h    |   33 ++++++
 plugins/file-search/gb-file-search-result.h      |   34 ++++++
 plugins/file-search/gb-file-search.gresource.xml |    6 +
 plugins/file-search/gb-file-search.plugin        |    6 +
 src/Makefile.am                                  |    1 +
 src/editor/gb-editor-map-bin.c                   |    2 +
 13 files changed, 395 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 07648c5..f32b0c0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -385,6 +385,7 @@ AC_CONFIG_FILES([
        plugins/Makefile
        plugins/command-bar/Makefile
        plugins/devhelp/Makefile
+       plugins/file-search/Makefile
        plugins/symbol-tree/Makefile
        plugins/sysmon/Makefile
        plugins/terminal/Makefile
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 79f0d54..9355d8a 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,6 +1,7 @@
 SUBDIRS = \
        command-bar \
        devhelp \
+       file-search \
        symbol-tree \
        sysmon \
        terminal \
diff --git a/plugins/file-search/Makefile.am b/plugins/file-search/Makefile.am
new file mode 100644
index 0000000..f7d5091
--- /dev/null
+++ b/plugins/file-search/Makefile.am
@@ -0,0 +1,43 @@
+DISTCLEANFILES =
+BUILT_SOURCES =
+CLEANFILES =
+EXTRA_DIST =
+
+noinst_LTLIBRARIES = libfile-search.la
+
+libfile_search_la_SOURCES = \
+       gb-file-search-plugin.c \
+       gb-file-search-provider.c \
+       gb-file-search-provider.h \
+       gb-file-search-result.c \
+       gb-file-search-result.h \
+       gb-file-search-index.c \
+       gb-file-search-index.h \
+       $(NULL)
+
+nodist_libfile_search_la_SOURCES = \
+       gb-file-search-resources.c \
+       gb-file-search-resources.h \
+       $(NULL)
+
+libfile_search_la_CFLAGS = \
+       $(BUILDER_CFLAGS) \
+       -I$(top_srcdir)/libide \
+       -I$(top_srcdir)/src \
+       -I$(top_srcdir)/contrib/search \
+       $(NULL)
+
+libfile_search_la_LIBADD = \
+       $(BUILDER_LIBS) \
+       $(top_builddir)/contrib/search/libsearch.la \
+       $(NULL)
+
+libfile_search_la_LDFLAGS = -module
+
+glib_resources_c = gb-file-search-resources.c
+glib_resources_h = gb-file-search-resources.h
+glib_resources_xml = gb-file-search.gresource.xml
+glib_resources_namespace = gb_file_search
+include $(top_srcdir)/build/autotools/Makefile.am.gresources
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/file-search/gb-file-search-index.c b/plugins/file-search/gb-file-search-index.c
new file mode 100644
index 0000000..46a2c34
--- /dev/null
+++ b/plugins/file-search/gb-file-search-index.c
@@ -0,0 +1,129 @@
+/* gb-file-search-index.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * 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/>.
+ */
+
+#include <fuzzy.h>
+#include <glib/gi18n.h>
+
+#include "gb-file-search-index.h"
+
+struct _GbFileSearchIndex
+{
+  GObject       parent_instance;
+
+  GFile        *root_directory;
+  GFileMonitor *file_monitor;
+  Fuzzy        *fuzzy;
+};
+
+G_DEFINE_TYPE (GbFileSearchIndex, gb_file_search_index, G_TYPE_OBJECT)
+
+enum {
+  PROP_0,
+  PROP_ROOT_DIRECTORY,
+  LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+static void
+gb_file_search_index_set_root_directory (GbFileSearchIndex *self,
+                                         GFile             *root_directory)
+{
+  g_return_if_fail (GB_IS_FILE_SEARCH_INDEX (self));
+  g_return_if_fail (!root_directory || G_IS_FILE (root_directory));
+
+  if (g_set_object (&self->root_directory, root_directory))
+    {
+      g_clear_pointer (&self->fuzzy, fuzzy_unref);
+
+      g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_ROOT_DIRECTORY]);
+    }
+}
+
+static void
+gb_file_search_index_finalize (GObject *object)
+{
+  GbFileSearchIndex *self = (GbFileSearchIndex *)object;
+
+  g_clear_object (&self->root_directory);
+  g_clear_object (&self->file_monitor);
+
+  G_OBJECT_CLASS (gb_file_search_index_parent_class)->finalize (object);
+}
+
+static void
+gb_file_search_index_get_property (GObject    *object,
+                                   guint       prop_id,
+                                   GValue     *value,
+                                   GParamSpec *pspec)
+{
+  GbFileSearchIndex *self = GB_FILE_SEARCH_INDEX (object);
+
+  switch (prop_id)
+    {
+    case PROP_ROOT_DIRECTORY:
+      g_value_set_object (value, self->root_directory);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_file_search_index_set_property (GObject      *object,
+                                   guint         prop_id,
+                                   const GValue *value,
+                                   GParamSpec   *pspec)
+{
+  GbFileSearchIndex *self = GB_FILE_SEARCH_INDEX (object);
+
+  switch (prop_id)
+    {
+    case PROP_ROOT_DIRECTORY:
+      gb_file_search_index_set_root_directory (self, g_value_get_object (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_file_search_index_class_init (GbFileSearchIndexClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gb_file_search_index_finalize;
+  object_class->get_property = gb_file_search_index_get_property;
+  object_class->set_property = gb_file_search_index_set_property;
+
+  gParamSpecs [PROP_ROOT_DIRECTORY] =
+    g_param_spec_object ("root-directory",
+                         _("Root Directory"),
+                         _("Root Directory"),
+                         G_TYPE_FILE,
+                         (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, LAST_PROP, gParamSpecs);
+}
+
+static void
+gb_file_search_index_init (GbFileSearchIndex *self)
+{
+}
diff --git a/plugins/file-search/gb-file-search-index.h b/plugins/file-search/gb-file-search-index.h
new file mode 100644
index 0000000..97a881d
--- /dev/null
+++ b/plugins/file-search/gb-file-search-index.h
@@ -0,0 +1,32 @@
+/* gb-file-search-index.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * 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/>.
+ */
+
+#ifndef GB_FILE_SEARCH_INDEX_H
+#define GB_FILE_SEARCH_INDEX_H
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_FILE_SEARCH_INDEX (gb_file_search_index_get_type())
+
+G_DECLARE_FINAL_TYPE (GbFileSearchIndex, gb_file_search_index, GB, FILE_SEARCH_INDEX, GObject)
+
+G_END_DECLS
+
+#endif /* GB_FILE_SEARCH_INDEX_H */
diff --git a/plugins/file-search/gb-file-search-plugin.c b/plugins/file-search/gb-file-search-plugin.c
new file mode 100644
index 0000000..a818e49
--- /dev/null
+++ b/plugins/file-search/gb-file-search-plugin.c
@@ -0,0 +1,28 @@
+/* gb-file-search-plugin.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * 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/>.
+ */
+
+#include <ide.h>
+
+#include "gb-plugins.h"
+#include "gb-file-search-provider.h"
+#include "gb-file-search-resources.h"
+
+GB_DEFINE_EMBEDDED_PLUGIN (gb_file_search,
+                           gb_file_search_get_resource (),
+                           "resource:///org/gnome/builder/plugins/file-search/gb-file-search.plugin",
+                           GB_DEFINE_PLUGIN_TYPE (IDE_TYPE_SEARCH_PROVIDER, GB_TYPE_FILE_SEARCH_PROVIDER))
diff --git a/plugins/file-search/gb-file-search-provider.c b/plugins/file-search/gb-file-search-provider.c
new file mode 100644
index 0000000..22cd514
--- /dev/null
+++ b/plugins/file-search/gb-file-search-provider.c
@@ -0,0 +1,79 @@
+/* gb-file-search-provider.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * 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/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "gb-file-search-provider.h"
+
+struct _GbFileSearchProvider
+{
+  IdeObject parent_instance;
+};
+
+static void search_provider_iface_init (IdeSearchProviderInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GbFileSearchProvider, gb_file_search_provider, IDE_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (IDE_TYPE_SEARCH_PROVIDER,
+                                                search_provider_iface_init))
+
+static const gchar *
+gb_file_search_provider_get_verb (IdeSearchProvider *provider)
+{
+  return _("Switch To");
+}
+
+static void
+gb_file_search_provider_populate (IdeSearchProvider *provider,
+                                  IdeSearchContext  *context,
+                                  const gchar       *search_terms,
+                                  gsize              max_results,
+                                  GCancellable      *cancellable)
+{
+  g_assert (IDE_IS_SEARCH_PROVIDER (provider));
+  g_assert (IDE_IS_SEARCH_CONTEXT (context));
+  g_assert (search_terms != NULL);
+  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+  ide_search_context_provider_completed (context, provider);
+}
+
+static void
+gb_file_search_provider_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (gb_file_search_provider_parent_class)->finalize (object);
+}
+
+static void
+gb_file_search_provider_class_init (GbFileSearchProviderClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gb_file_search_provider_finalize;
+}
+
+static void
+gb_file_search_provider_init (GbFileSearchProvider *self)
+{
+}
+
+static void
+search_provider_iface_init (IdeSearchProviderInterface *iface)
+{
+  iface->populate = gb_file_search_provider_populate;
+  iface->get_verb = gb_file_search_provider_get_verb;
+}
diff --git a/plugins/file-search/gb-file-search-provider.h b/plugins/file-search/gb-file-search-provider.h
new file mode 100644
index 0000000..cddad57
--- /dev/null
+++ b/plugins/file-search/gb-file-search-provider.h
@@ -0,0 +1,33 @@
+/* gb-file-search-provider.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * 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/>.
+ */
+
+#ifndef GB_FILE_SEARCH_PROVIDER_H
+#define GB_FILE_SEARCH_PROVIDER_H
+
+#include <ide.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_FILE_SEARCH_PROVIDER (gb_file_search_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbFileSearchProvider, gb_file_search_provider,
+                      GB, FILE_SEARCH_PROVIDER, IdeObject)
+
+G_END_DECLS
+
+#endif /* GB_FILE_SEARCH_PROVIDER_H */
diff --git a/plugins/file-search/gb-file-search-result.c b/plugins/file-search/gb-file-search-result.c
new file mode 100644
index 0000000..e69de29
diff --git a/plugins/file-search/gb-file-search-result.h b/plugins/file-search/gb-file-search-result.h
new file mode 100644
index 0000000..34aac13
--- /dev/null
+++ b/plugins/file-search/gb-file-search-result.h
@@ -0,0 +1,34 @@
+/* gb-file-search-result.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * 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/>.
+ */
+
+#ifndef GB_FILE_SEARCH_RESULT_H
+#define GB_FILE_SEARCH_RESULT_H
+
+#include "ide-search-result.h"
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_FILE_SEARCH_RESULT (gb_file_search_result_get_type())
+
+G_DECLARE_FINAL_TYPE (GbFileSearchResult, gb_file_search_result,
+                      GB, FILE_SEARCH_RESULT,
+                      IdeSearchResult)
+
+G_END_DECLS
+
+#endif /* GB_FILE_SEARCH_RESULT_H */
diff --git a/plugins/file-search/gb-file-search.gresource.xml 
b/plugins/file-search/gb-file-search.gresource.xml
new file mode 100644
index 0000000..5aa0a51
--- /dev/null
+++ b/plugins/file-search/gb-file-search.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/builder/plugins/file-search">
+    <file>gb-file-search.plugin</file>
+  </gresource>
+</gresources>
diff --git a/plugins/file-search/gb-file-search.plugin b/plugins/file-search/gb-file-search.plugin
new file mode 100644
index 0000000..9df0b1b
--- /dev/null
+++ b/plugins/file-search/gb-file-search.plugin
@@ -0,0 +1,6 @@
+[Plugin]
+Module=file-search
+Name=File Search
+Description=Search for files in the global search bar.
+Authors=Christian Hergert <christian hergert me>
+Copyright=Copyright © 2015 Christian Hergert
diff --git a/src/Makefile.am b/src/Makefile.am
index cf44ab4..8253d8b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -212,6 +212,7 @@ define_plugin = -Wl,--whole-archive,$(top_builddir)/plugins/$1/.libs/lib$1.a,--n
 gnome_builder_PLUGINS = \
        devhelp \
        command-bar \
+       file-search \
        symbol-tree \
        sysmon \
        terminal \
diff --git a/src/editor/gb-editor-map-bin.c b/src/editor/gb-editor-map-bin.c
index bfbf7ff..f139638 100644
--- a/src/editor/gb-editor-map-bin.c
+++ b/src/editor/gb-editor-map-bin.c
@@ -95,6 +95,8 @@ gb_editor_map_bin_size_allocate (GtkWidget     *widget,
 
   alloc->height -= self->cached_height;
 
+  g_print ("Size Allocate\n");
+
   GTK_WIDGET_CLASS (gb_editor_map_bin_parent_class)->size_allocate (widget, alloc);
 }
 


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