[gnome-builder/wip/libide] libide: add IdePythonLanguage
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide] libide: add IdePythonLanguage
- Date: Wed, 18 Feb 2015 09:11:28 +0000 (UTC)
commit 7e95f27aecb6407666400b585c241b8d459bcae2
Author: Christian Hergert <christian hergert me>
Date: Wed Feb 18 01:01:02 2015 -0800
libide: add IdePythonLanguage
libide/Makefile.am | 3 +
libide/ide.c | 7 ++-
libide/python/ide-python-language.c | 103 +++++++++++++++++++++++++++++++++++
libide/python/ide-python-language.h | 32 +++++++++++
4 files changed, 144 insertions(+), 1 deletions(-)
---
diff --git a/libide/Makefile.am b/libide/Makefile.am
index cca8032..c4c86f7 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -140,6 +140,8 @@ libide_1_0_la_public_sources = \
libide/local/ide-local-device.h \
libide/python/ide-python-indenter.c \
libide/python/ide-python-indenter.h \
+ libide/python/ide-python-language.c \
+ libide/python/ide-python-language.h \
libide/xml/ide-xml-indenter.c \
libide/xml/ide-xml-indenter.h \
$(NULL)
@@ -189,6 +191,7 @@ libide_1_0_la_includes = \
-I$(top_srcdir)/libide/gjs \
-I$(top_srcdir)/libide/gsettings \
-I$(top_srcdir)/libide/local \
+ -I$(top_srcdir)/libide/python \
-I$(top_srcdir)/libide/tasks \
$(CLANG_CFLAGS) \
$(NULL)
diff --git a/libide/ide.c b/libide/ide.c
index dd12183..3b8f902 100644
--- a/libide/ide.c
+++ b/libide/ide.c
@@ -34,6 +34,7 @@
#include "ide-git-vcs.h"
#include "ide-gjs-script.h"
#include "ide-gsettings-file-settings.h"
+#include "ide-python-language.h"
#include "ide-search-provider.h"
static gboolean gProgramNameRead;
@@ -95,7 +96,11 @@ ide_init_ctor (void)
g_io_extension_point_implement (IDE_LANGUAGE_EXTENSION_POINT,
IDE_TYPE_C_LANGUAGE,
IDE_LANGUAGE_EXTENSION_POINT".c",
- -100);
+ 0);
+ g_io_extension_point_implement (IDE_LANGUAGE_EXTENSION_POINT,
+ IDE_TYPE_PYTHON_LANGUAGE,
+ IDE_LANGUAGE_EXTENSION_POINT".python",
+ 0);
g_io_extension_point_implement (IDE_SCRIPT_EXTENSION_POINT,
IDE_TYPE_GJS_SCRIPT,
diff --git a/libide/python/ide-python-language.c b/libide/python/ide-python-language.c
new file mode 100644
index 0000000..baa49ec
--- /dev/null
+++ b/libide/python/ide-python-language.c
@@ -0,0 +1,103 @@
+/* ide-python-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 <glib/gi18n.h>
+
+#include "ide-python-indenter.h"
+#include "ide-python-language.h"
+
+struct _IdePythonLanguage
+{
+ IdeLanguage parent_instance;
+ IdePythonIndenter *indenter;
+};
+
+static void initable_iface_init (GInitableIface *iface);
+
+G_DEFINE_TYPE_EXTENDED (IdePythonLanguage,
+ ide_python_language,
+ IDE_TYPE_LANGUAGE,
+ 0,
+ G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
+ initable_iface_init))
+
+static IdeIndenter *
+ide_python_language_get_indenter (IdeLanguage *language)
+{
+ IdePythonLanguage *self = (IdePythonLanguage *)language;
+
+ g_return_val_if_fail (IDE_IS_PYTHON_LANGUAGE (self), NULL);
+
+ if (!self->indenter)
+ {
+ IdeContext *context;
+
+ context = ide_object_get_context (IDE_OBJECT (language));
+ self->indenter = g_object_new (IDE_TYPE_PYTHON_INDENTER,
+ "context", context,
+ NULL);
+ }
+
+ return IDE_INDENTER (self->indenter);
+}
+
+static void
+ide_python_language_finalize (GObject *object)
+{
+ IdePythonLanguage *self = (IdePythonLanguage *)object;
+
+ g_clear_object (&self->indenter);
+
+ G_OBJECT_CLASS (ide_python_language_parent_class)->finalize (object);
+}
+
+static void
+ide_python_language_class_init (IdePythonLanguageClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ IdeLanguageClass *language_class = IDE_LANGUAGE_CLASS (klass);
+
+ object_class->finalize = ide_python_language_finalize;
+
+ language_class->get_indenter = ide_python_language_get_indenter;
+}
+
+static void
+ide_python_language_init (IdePythonLanguage *self)
+{
+}
+
+static gboolean
+ide_python_language_initable_init (GInitable *initable,
+ GCancellable *cancellable,
+ GError **error)
+{
+ const gchar *id;
+
+ g_return_val_if_fail (IDE_IS_PYTHON_LANGUAGE (initable), FALSE);
+
+ id = ide_language_get_id (IDE_LANGUAGE (initable));
+
+ return ((g_strcmp0 (id, "python") == 0) || (g_strcmp0 (id, "python3") == 0));
+}
+
+static void
+initable_iface_init (GInitableIface *iface)
+{
+ iface->init = ide_python_language_initable_init;
+}
diff --git a/libide/python/ide-python-language.h b/libide/python/ide-python-language.h
new file mode 100644
index 0000000..2f5008e
--- /dev/null
+++ b/libide/python/ide-python-language.h
@@ -0,0 +1,32 @@
+/* ide-python-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_PYTHON_LANGUAGE_H
+#define IDE_PYTHON_LANGUAGE_H
+
+#include "ide-language.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_PYTHON_LANGUAGE (ide_python_language_get_type())
+
+G_DECLARE_FINAL_TYPE (IdePythonLanguage, ide_python_language, IDE, PYTHON_LANGUAGE, IdeLanguage)
+
+G_END_DECLS
+
+#endif /* IDE_PYTHON_LANGUAGE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]