[gnome-builder/wip/libide] libide: add IdeXmlLanguage



commit fdd0bfbe9be08ed345c1f7260d32e0acabfde593
Author: Christian Hergert <christian hergert me>
Date:   Wed Feb 18 01:11:10 2015 -0800

    libide: add IdeXmlLanguage

 libide/Makefile.am            |    3 +
 libide/ide.c                  |    5 ++
 libide/xml/ide-xml-language.c |   98 +++++++++++++++++++++++++++++++++++++++++
 libide/xml/ide-xml-language.h |   32 +++++++++++++
 4 files changed, 138 insertions(+), 0 deletions(-)
---
diff --git a/libide/Makefile.am b/libide/Makefile.am
index c4c86f7..ce6acee 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -144,6 +144,8 @@ libide_1_0_la_public_sources = \
        libide/python/ide-python-language.h \
        libide/xml/ide-xml-indenter.c \
        libide/xml/ide-xml-indenter.h \
+       libide/xml/ide-xml-language.c \
+       libide/xml/ide-xml-language.h \
        $(NULL)
 
 libide_1_0_la_SOURCES = \
@@ -193,6 +195,7 @@ libide_1_0_la_includes = \
        -I$(top_srcdir)/libide/local \
        -I$(top_srcdir)/libide/python \
        -I$(top_srcdir)/libide/tasks \
+       -I$(top_srcdir)/libide/xml \
        $(CLANG_CFLAGS) \
        $(NULL)
 
diff --git a/libide/ide.c b/libide/ide.c
index 3b8f902..a309b53 100644
--- a/libide/ide.c
+++ b/libide/ide.c
@@ -36,6 +36,7 @@
 #include "ide-gsettings-file-settings.h"
 #include "ide-python-language.h"
 #include "ide-search-provider.h"
+#include "ide-xml-language.h"
 
 static gboolean     gProgramNameRead;
 static const gchar *gProgramName = "libide";
@@ -101,6 +102,10 @@ ide_init_ctor (void)
                                   IDE_TYPE_PYTHON_LANGUAGE,
                                   IDE_LANGUAGE_EXTENSION_POINT".python",
                                   0);
+  g_io_extension_point_implement (IDE_LANGUAGE_EXTENSION_POINT,
+                                  IDE_TYPE_XML_LANGUAGE,
+                                  IDE_LANGUAGE_EXTENSION_POINT".xml",
+                                  0);
 
   g_io_extension_point_implement (IDE_SCRIPT_EXTENSION_POINT,
                                   IDE_TYPE_GJS_SCRIPT,
diff --git a/libide/xml/ide-xml-language.c b/libide/xml/ide-xml-language.c
new file mode 100644
index 0000000..97a4628
--- /dev/null
+++ b/libide/xml/ide-xml-language.c
@@ -0,0 +1,98 @@
+/* ide-xml-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/>.
+ */
+
+#include "ide-xml-language.h"
+#include "ide-xml-indenter.h"
+
+struct _IdeXmlLanguage
+{
+  IdeLanguage     parent_instance;
+  IdeXmlIndenter *indenter;
+};
+
+static void initable_iface_init (GInitableIface *iface);
+
+G_DEFINE_TYPE_EXTENDED (IdeXmlLanguage, ide_xml_language, IDE_TYPE_LANGUAGE, 0,
+                        G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
+                                               initable_iface_init))
+
+static IdeIndenter *
+ide_xml_language_get_indenter (IdeLanguage *language)
+{
+  IdeXmlLanguage *self = (IdeXmlLanguage *)language;
+
+  g_return_val_if_fail (IDE_IS_XML_LANGUAGE (self), NULL);
+
+  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_xml_language_finalize (GObject *object)
+{
+  IdeXmlLanguage *self = (IdeXmlLanguage *)object;
+
+  g_clear_object (&self->indenter);
+
+  G_OBJECT_CLASS (ide_xml_language_parent_class)->finalize (object);
+}
+
+static void
+ide_xml_language_class_init (IdeXmlLanguageClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  IdeLanguageClass *language_class = IDE_LANGUAGE_CLASS (klass);
+
+  object_class->finalize = ide_xml_language_finalize;
+
+  language_class->get_indenter = ide_xml_language_get_indenter;
+}
+
+static void
+ide_xml_language_init (IdeXmlLanguage *self)
+{
+}
+
+static gboolean
+ide_xml_language_initable_init (GInitable     *initable,
+                                GCancellable  *cancellable,
+                                GError       **error)
+{
+  const gchar *id;
+
+  g_return_val_if_fail (IDE_IS_XML_LANGUAGE (initable), FALSE);
+
+  id = ide_language_get_id (IDE_LANGUAGE (initable));
+
+  return (g_strcmp0 (id, "xml") == 0);
+}
+
+static void
+initable_iface_init (GInitableIface *iface)
+{
+  iface->init = ide_xml_language_initable_init;
+}
diff --git a/libide/xml/ide-xml-language.h b/libide/xml/ide-xml-language.h
new file mode 100644
index 0000000..7c54413
--- /dev/null
+++ b/libide/xml/ide-xml-language.h
@@ -0,0 +1,32 @@
+/* ide-xml-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_XML_LANGUAGE_H
+#define IDE_XML_LANGUAGE_H
+
+#include "ide-language.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_XML_LANGUAGE (ide_xml_language_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeXmlLanguage, ide_xml_language, IDE, XML_LANGUAGE, IdeLanguage)
+
+G_END_DECLS
+
+#endif /* IDE_XML_LANGUAGE_H */


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