[gnome-builder/wip/libide-merge] bring back html completion
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide-merge] bring back html completion
- Date: Thu, 19 Mar 2015 22:27:36 +0000 (UTC)
commit 973533a9ee94591f9732e68e3193f8f9c55b16b6
Author: Christian Hergert <christian hergert me>
Date: Thu Mar 19 15:27:29 2015 -0700
bring back html completion
libide/Makefile.am | 5 +
.../html/ide-html-completion-provider.c | 28 ++---
libide/html/ide-html-completion-provider.h | 55 ++++++++++
libide/html/ide-html-language.c | 115 ++++++++++++++++++++
libide/html/ide-html-language.h | 32 ++++++
libide/ide.c | 5 +
src/gnome-builder.mk | 2 -
src/html/gb-html-completion-provider.h | 56 ----------
8 files changed, 223 insertions(+), 75 deletions(-)
---
diff --git a/libide/Makefile.am b/libide/Makefile.am
index fb95204..52f0191 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -40,6 +40,10 @@ libide_1_0_la_public_sources = \
libide/gjs/ide-gjs-script.h \
libide/gsettings/ide-gsettings-file-settings.c \
libide/gsettings/ide-gsettings-file-settings.h \
+ libide/html/ide-html-language.c \
+ libide/html/ide-html-language.h \
+ libide/html/ide-html-completion-provider.c \
+ libide/html/ide-html-completion-provider.h \
libide/ide-back-forward-item.c \
libide/ide-back-forward-item.h \
libide/ide-back-forward-list.c \
@@ -274,6 +278,7 @@ libide_1_0_la_includes = \
-I$(top_srcdir)/libide/git \
-I$(top_srcdir)/libide/gjs \
-I$(top_srcdir)/libide/gsettings \
+ -I$(top_srcdir)/libide/html \
-I$(top_srcdir)/libide/local \
-I$(top_srcdir)/libide/modelines \
-I$(top_srcdir)/libide/pygobject \
diff --git a/src/html/gb-html-completion-provider.c b/libide/html/ide-html-completion-provider.c
similarity index 96%
rename from src/html/gb-html-completion-provider.c
rename to libide/html/ide-html-completion-provider.c
index dc27177..294ea26 100644
--- a/src/html/gb-html-completion-provider.c
+++ b/libide/html/ide-html-completion-provider.c
@@ -1,4 +1,4 @@
-/* gb-html-completion-provider.c
+/* ide-html-completion-provider.c
*
* Copyright (C) 2014 Christian Hergert <christian hergert me>
*
@@ -18,7 +18,7 @@
#include <string.h>
-#include "gb-html-completion-provider.h"
+#include "ide-html-completion-provider.h"
#include "trie.h"
static GHashTable *element_attrs;
@@ -42,19 +42,13 @@ typedef struct
static void completion_provider_init (GtkSourceCompletionProviderIface *);
-G_DEFINE_TYPE_EXTENDED (GbHtmlCompletionProvider,
- gb_html_completion_provider,
+G_DEFINE_TYPE_EXTENDED (IdeHtmlCompletionProvider,
+ ide_html_completion_provider,
G_TYPE_OBJECT,
0,
G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_COMPLETION_PROVIDER,
completion_provider_init))
-GtkSourceCompletionProvider *
-gb_html_completion_provider_new (void)
-{
- return g_object_new (GB_TYPE_HTML_COMPLETION_PROVIDER, NULL);
-}
-
static gchar *
get_word (GtkSourceCompletionContext *context)
{
@@ -353,7 +347,7 @@ sort_completion_items (gconstpointer a,
}
static void
-gb_html_completion_provider_populate (GtkSourceCompletionProvider *provider,
+ide_html_completion_provider_populate (GtkSourceCompletionProvider *provider,
GtkSourceCompletionContext *context)
{
SearchState state = { 0 };
@@ -361,7 +355,7 @@ gb_html_completion_provider_populate (GtkSourceCompletionProvider *provider,
gchar *word;
gint mode;
- g_return_if_fail (GB_IS_HTML_COMPLETION_PROVIDER (provider));
+ g_return_if_fail (IDE_IS_HTML_COMPLETION_PROVIDER (provider));
g_return_if_fail (GTK_SOURCE_IS_COMPLETION_CONTEXT (context));
mode = get_mode (context);
@@ -439,13 +433,13 @@ gb_html_completion_provider_populate (GtkSourceCompletionProvider *provider,
}
static GdkPixbuf *
-gb_html_completion_provider_get_icon (GtkSourceCompletionProvider *provider)
+ide_html_completion_provider_get_icon (GtkSourceCompletionProvider *provider)
{
return NULL;
}
static void
-gb_html_completion_provider_class_init (GbHtmlCompletionProviderClass *klass)
+ide_html_completion_provider_class_init (IdeHtmlCompletionProviderClass *klass)
{
elements = trie_new (NULL);
element_attrs = g_hash_table_new (g_str_hash, g_str_equal);
@@ -883,13 +877,13 @@ gb_html_completion_provider_class_init (GbHtmlCompletionProviderClass *klass)
}
static void
-gb_html_completion_provider_init (GbHtmlCompletionProvider *self)
+ide_html_completion_provider_init (IdeHtmlCompletionProvider *self)
{
}
static void
completion_provider_init (GtkSourceCompletionProviderIface *iface)
{
- iface->get_icon = gb_html_completion_provider_get_icon;
- iface->populate = gb_html_completion_provider_populate;
+ iface->get_icon = ide_html_completion_provider_get_icon;
+ iface->populate = ide_html_completion_provider_populate;
}
diff --git a/libide/html/ide-html-completion-provider.h b/libide/html/ide-html-completion-provider.h
new file mode 100644
index 0000000..cee3030
--- /dev/null
+++ b/libide/html/ide-html-completion-provider.h
@@ -0,0 +1,55 @@
+/* ide-html-completion-provider.h
+ *
+ * Copyright (C) 2014 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 IDE_HTML_COMPLETION_PROVIDER_H
+#define IDE_HTML_COMPLETION_PROVIDER_H
+
+#include <gtksourceview/gtksource.h>
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_HTML_COMPLETION_PROVIDER (ide_html_completion_provider_get_type())
+#define IDE_HTML_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_HTML_COMPLETION_PROVIDER, IdeHtmlCompletionProvider))
+#define IDE_HTML_COMPLETION_PROVIDER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_HTML_COMPLETION_PROVIDER, IdeHtmlCompletionProvider const))
+#define IDE_HTML_COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
IDE_TYPE_HTML_COMPLETION_PROVIDER, IdeHtmlCompletionProviderClass))
+#define IDE_IS_HTML_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
IDE_TYPE_HTML_COMPLETION_PROVIDER))
+#define IDE_IS_HTML_COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
IDE_TYPE_HTML_COMPLETION_PROVIDER))
+#define IDE_HTML_COMPLETION_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
IDE_TYPE_HTML_COMPLETION_PROVIDER, IdeHtmlCompletionProviderClass))
+
+typedef struct _IdeHtmlCompletionProvider IdeHtmlCompletionProvider;
+typedef struct _IdeHtmlCompletionProviderClass IdeHtmlCompletionProviderClass;
+typedef struct _IdeHtmlCompletionProviderPrivate IdeHtmlCompletionProviderPrivate;
+
+struct _IdeHtmlCompletionProvider
+{
+ GObject parent;
+
+ /*< private >*/
+ IdeHtmlCompletionProviderPrivate *priv;
+};
+
+struct _IdeHtmlCompletionProviderClass
+{
+ GObjectClass parent;
+};
+
+GType ide_html_completion_provider_get_type (void);
+
+G_END_DECLS
+
+#endif /* IDE_HTML_COMPLETION_PROVIDER_H */
diff --git a/libide/html/ide-html-language.c b/libide/html/ide-html-language.c
new file mode 100644
index 0000000..59a8eed
--- /dev/null
+++ b/libide/html/ide-html-language.c
@@ -0,0 +1,115 @@
+/* ide-html-language.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This file 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
+ * Lesser 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/>.
+ */
+
+#define G_LOG_DOMAIN "ide-html-language"
+
+#include "ide-html-completion-provider.h"
+#include "ide-html-language.h"
+#include "ide-xml-indenter.h"
+
+struct _IdeHtmlLanguage
+{
+ IdeLanguage parent_instance;
+
+ IdeXmlIndenter *indenter;
+};
+
+static void initable_iface_init (GInitableIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (IdeHtmlLanguage, ide_html_language, IDE_TYPE_LANGUAGE,
+ G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
+ initable_iface_init))
+
+static GList *
+ide_html_language_get_completion_providers (IdeLanguage *language)
+{
+ GList *list = NULL;
+
+ g_assert (IDE_IS_HTML_LANGUAGE (language));
+
+ list = g_list_append (list, g_object_new (IDE_TYPE_HTML_COMPLETION_PROVIDER, NULL));
+
+ return list;
+}
+
+static IdeIndenter *
+ide_html_language_get_indenter (IdeLanguage *language)
+{
+ IdeHtmlLanguage *self = (IdeHtmlLanguage *)language;
+
+ g_assert (IDE_IS_HTML_LANGUAGE (self));
+
+ if (!self->indenter)
+ {
+ IdeContext *context;
+
+ context = ide_object_get_context (IDE_OBJECT (language));
+ self->indenter = g_object_new (IDE_TYPE_XML_INDENTER,
+ "context", context,
+ NULL);
+ }
+
+ return IDE_INDENTER (self->indenter);
+}
+
+static void
+ide_html_language_finalize (GObject *object)
+{
+ IdeHtmlLanguage *self = (IdeHtmlLanguage *)object;
+
+ g_clear_object (&self->indenter);
+
+ G_OBJECT_CLASS (ide_html_language_parent_class)->finalize (object);
+}
+
+static void
+ide_html_language_class_init (IdeHtmlLanguageClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ IdeLanguageClass *language_class = IDE_LANGUAGE_CLASS (klass);
+
+ object_class->finalize = ide_html_language_finalize;
+
+ language_class->get_completion_providers = ide_html_language_get_completion_providers;
+ language_class->get_indenter = ide_html_language_get_indenter;
+}
+
+static void
+ide_html_language_init (IdeHtmlLanguage *self)
+{
+}
+
+static gboolean
+ide_html_language_initable_init (GInitable *initable,
+ GCancellable *cancellable,
+ GError **error)
+{
+ const gchar *id;
+
+ g_return_val_if_fail (IDE_IS_HTML_LANGUAGE (initable), FALSE);
+
+ id = ide_language_get_id (IDE_LANGUAGE (initable));
+
+ return (g_strcmp0 (id, "html") == 0);
+}
+
+static void
+initable_iface_init (GInitableIface *iface)
+{
+ iface->init = ide_html_language_initable_init;
+}
diff --git a/libide/html/ide-html-language.h b/libide/html/ide-html-language.h
new file mode 100644
index 0000000..352e8e2
--- /dev/null
+++ b/libide/html/ide-html-language.h
@@ -0,0 +1,32 @@
+/* ide-html-language.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This file 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
+ * Lesser 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 IDE_HTML_LANGUAGE_H
+#define IDE_HTML_LANGUAGE_H
+
+#include "ide-language.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_HTML_LANGUAGE (ide_html_language_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeHtmlLanguage, ide_html_language, IDE, HTML_LANGUAGE, IdeLanguage)
+
+G_END_DECLS
+
+#endif /* IDE_HTML_LANGUAGE_H */
diff --git a/libide/ide.c b/libide/ide.c
index 453c1b4..313d711 100644
--- a/libide/ide.c
+++ b/libide/ide.c
@@ -35,6 +35,7 @@
#include "ide-git-vcs.h"
#include "ide-gjs-script.h"
#include "ide-gsettings-file-settings.h"
+#include "ide-html-language.h"
#include "ide-pygobject-script.h"
#include "ide-python-language.h"
#include "ide-search-provider.h"
@@ -112,6 +113,10 @@ ide_init_ctor (void)
IDE_LANGUAGE_EXTENSION_POINT".c",
0);
g_io_extension_point_implement (IDE_LANGUAGE_EXTENSION_POINT,
+ IDE_TYPE_HTML_LANGUAGE,
+ IDE_LANGUAGE_EXTENSION_POINT".html",
+ 0);
+ g_io_extension_point_implement (IDE_LANGUAGE_EXTENSION_POINT,
IDE_TYPE_PYTHON_LANGUAGE,
IDE_LANGUAGE_EXTENSION_POINT".python",
0);
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index e4823d0..21cf689 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -153,8 +153,6 @@ disabled_files = \
src/editor/gb-source-formatter.h \
src/editor/gb-source-highlight-menu.c \
src/editor/gb-source-highlight-menu.h \
- src/html/gb-html-completion-provider.c \
- src/html/gb-html-completion-provider.h \
src/html/gb-html-document.c \
src/html/gb-html-document.h \
src/html/gb-html-view.c \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]