[anjuta] split language-support-cpp-java and language-support-python plugin in an indentation part and a new
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] split language-support-cpp-java and language-support-python plugin in an indentation part and a new
- Date: Wed, 23 May 2012 18:50:32 +0000 (UTC)
commit 5945a9ea3f040d777dd17104b64fc9f60649fd12
Author: Moritz LÃdecke <ritze skweez net>
Date: Fri May 18 15:26:35 2012 +0200
split language-support-cpp-java and language-support-python plugin in an indentation part and a new language-support part
configure.ac | 2 +
libanjuta/anjuta-utils.c | 56 +
libanjuta/anjuta-utils.h | 4 +
plugins/Makefile.am | 2 +
plugins/indentation-c-style/Makefile.am | 71 +
.../anjuta-indentation-c-style-auto-16.png | Bin 0 -> 823 bytes
.../anjuta-indentation-c-style-auto-24.png | Bin 0 -> 1207 bytes
.../anjuta-indentation-c-style-auto.svg | 448 ++++
.../anjuta-indentation-c-style-plugin.png | Bin 0 -> 4218 bytes
.../anjuta-indentation-c-style.plugin.in | 11 +
.../anjuta-indentation-c-style.ui | 340 +++
.../anjuta-indentation-c-style.xml} | 2 -
.../indentation.c} | 40 +-
.../indentation.h} | 8 +-
...rg.gnome.anjuta.plugins.indent-c.gschema.xml.in | 31 +
plugins/indentation-c-style/plugin.c | 651 ++++++
plugins/indentation-c-style/plugin.h | 69 +
plugins/indentation-python-style/Makefile.am | 59 +
.../anjuta-indentation-python-style-plugin.png} | Bin 2946 -> 2946 bytes
.../anjuta-indentation-python-style.plugin | 11 +
.../anjuta-indentation-python-style.plugin.in | 11 +
.../anjuta-indentation-python-style.ui | 169 ++
.../anjuta-indentation-python-style.xml} | 2 -
...ome.anjuta.plugins.indent-python.gschema.xml.in | 13 +
plugins/indentation-python-style/plugin.c | 371 ++++
plugins/indentation-python-style/plugin.h | 79 +
.../python-indentation.c | 22 +-
.../python-indentation.h | 6 +-
plugins/language-support-cpp-java/Makefile.am | 4 -
.../anjuta-language-cpp-java.ui | 332 +---
.../anjuta-language-support-cpp-java.xml | 1 -
.../language-support-cpp-java/cpp-java-assist.c | 10 +-
plugins/language-support-cpp-java/cpp-java-utils.c | 78 -
plugins/language-support-cpp-java/cpp-java-utils.h | 28 -
.../org.gnome.anjuta.plugins.cpp.gschema.xml.in | 24 -
plugins/language-support-cpp-java/plugin.c | 2190 ++++++++-----------
plugins/language-support-cpp-java/plugin.h | 9 -
plugins/language-support-python/Makefile.am | 16 +-
...g => anjuta-language-support-python-plugin.png} | Bin 2946 -> 2946 bytes
.../anjuta-language-support-python.plugin.in | 11 +
.../anjuta-language-support-python.ui | 270 +++
...ugin.xml => anjuta-language-support-python.xml} | 1 -
.../org.gnome.anjuta.plugins.python.gschema.xml.in | 9 -
plugins/language-support-python/plugin.c | 101 +-
plugins/language-support-python/plugin.h | 9 -
plugins/language-support-python/python-assist.c | 10 +-
.../python-plugin-properties.ui | 450 ----
.../python-plugin.plugin.in | 11 -
plugins/language-support-python/python-utils.c | 78 -
plugins/language-support-python/python-utils.h | 28 -
50 files changed, 3662 insertions(+), 2486 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d0bf1f0..f2fe703 100644
--- a/configure.ac
+++ b/configure.ac
@@ -883,6 +883,8 @@ plugins/language-support-cpp-java/Makefile
plugins/language-support-cpp-java/cxxparser/Makefile
plugins/run-program/Makefile
plugins/starter/Makefile
+plugins/indentation-c-style/Makefile
+plugins/indentation-python-style/Makefile
plugins/language-support-js/Makefile
plugins/language-support-vala/Makefile
plugins/language-support-python/Makefile
diff --git a/libanjuta/anjuta-utils.c b/libanjuta/anjuta-utils.c
index 6a6a83b..5df562f 100644
--- a/libanjuta/anjuta-utils.c
+++ b/libanjuta/anjuta-utils.c
@@ -57,6 +57,7 @@
#include <libanjuta/anjuta-utils.h>
#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/interfaces/ianjuta-editor-cell.h>
#define FILE_BUFFER_SIZE 1024
@@ -1275,6 +1276,61 @@ anjuta_util_convert_to_utf8 (const gchar *str)
return utf8_msg_string;
}
+#define LEFT_BRACE(ch) (ch == ')'? '(' : (ch == '}'? '{' : (ch == ']'? '[' : ch)))
+
+gboolean
+anjuta_util_jump_to_matching_brace (IAnjutaIterable *iter, gchar brace, gint limit)
+{
+ gchar point_ch = brace;
+ gint cur_iteration = 0;
+ gboolean use_limit = (limit > 0);
+ GString *braces_stack = g_string_new ("");
+
+ g_return_val_if_fail (point_ch == ')' || point_ch == ']' ||
+ point_ch == '}', FALSE);
+
+ /* DEBUG_PRINT ("%s", "Matching brace being"); */
+ /* Push brace */
+ g_string_prepend_c (braces_stack, point_ch);
+
+ while (ianjuta_iterable_previous (iter, NULL))
+ {
+ /* Check limit */
+ cur_iteration++;
+ if (use_limit && cur_iteration > limit)
+ break;
+
+ /* Skip comments and strings */
+ IAnjutaEditorAttribute attrib =
+ ianjuta_editor_cell_get_attribute (IANJUTA_EDITOR_CELL (iter), NULL);
+ if (attrib == IANJUTA_EDITOR_COMMENT || attrib == IANJUTA_EDITOR_STRING)
+ continue;
+
+ /* DEBUG_PRINT ("%s", "point ch = %c", point_ch); */
+ point_ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter), 0,
+ NULL);
+ if (point_ch == ')' || point_ch == ']' || point_ch == '}')
+ {
+ /* Push brace */
+ g_string_prepend_c (braces_stack, point_ch);
+ continue;
+ }
+ if (point_ch == LEFT_BRACE (braces_stack->str[0]))
+ {
+ /* Pop brace */
+ g_string_erase (braces_stack, 0, 1);
+ }
+ /* Bail out if there is no more in stack */
+ if (braces_stack->str[0] == '\0')
+ {
+ /* DEBUG_PRINT ("%s", "Matching brace end -- found"); */
+ return TRUE;
+ }
+ }
+ /* DEBUG_PRINT ("%s", "Matching brace end -- not found"); */
+ return FALSE;
+}
+
GList*
anjuta_util_parse_args_from_string (const gchar* string)
{
diff --git a/libanjuta/anjuta-utils.h b/libanjuta/anjuta-utils.h
index 56fe83c..0beca35 100644
--- a/libanjuta/anjuta-utils.h
+++ b/libanjuta/anjuta-utils.h
@@ -24,6 +24,7 @@
#include <gtk/gtk.h>
#include <sys/types.h>
#include <gio/gio.h>
+#include <libanjuta/interfaces/ianjuta-iterable.h>
G_BEGIN_DECLS
@@ -70,6 +71,9 @@ gchar* anjuta_util_get_a_tmp_file (void);
gchar* anjuta_util_convert_to_utf8 (const gchar *str);
+gboolean anjuta_util_jump_to_matching_brace (IAnjutaIterable *iter,
+ gchar brace, gint limit);
+
GList* anjuta_util_parse_args_from_string (const gchar* string);
/***********************************************/
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 7cabc64..299e695 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -18,6 +18,8 @@ SUBDIRS = . \
git \
glade \
js-debugger \
+ indentation-c-style \
+ indentation-python-style \
language-manager \
language-support-cpp-java \
language-support-js \
diff --git a/plugins/indentation-c-style/Makefile.am b/plugins/indentation-c-style/Makefile.am
new file mode 100644
index 0000000..951f5df
--- /dev/null
+++ b/plugins/indentation-c-style/Makefile.am
@@ -0,0 +1,71 @@
+# Plugin glade file
+indent_c_gladedir = $(anjuta_glade_dir)
+indent_c_glade_DATA = anjuta-indentation-c-style.ui
+
+# Plugin UI file
+indent_c_uidir = $(anjuta_ui_dir)
+indent_c_ui_DATA = anjuta-indentation-c-style.xml
+
+# Plugin Icon file
+indent_c_pixmapsdir = $(anjuta_image_dir)
+indent_c_pixmaps_DATA = \
+ anjuta-indentation-c-style-plugin.png \
+ anjuta-indentation-c-style-auto-16.png \
+ anjuta-indentation-c-style-auto-24.png
+
+# Plugin description file
+plugin_in_files = anjuta-indentation-c-style.plugin.in
+%.plugin: %.plugin.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+indent_c_plugindir = $(anjuta_plugin_dir)
+indent_c_plugin_DATA = $(plugin_in_files:.plugin.in=.plugin)
+
+# NOTE :
+# The naming convention is very intentional
+# We are forced to use the prefix 'lib' by automake and libtool
+# There is probably a way to avoid it but it is not worth to effort
+# to find out.
+# The 'anjuta_' prfix is a safety measure to avoid conflicts where the
+# plugin 'libpython.so' needs to link with the real 'libpython.so'
+
+# Include paths
+AM_CPPFLAGS = \
+ $(WARN_CFLAGS) \
+ $(DEPRECATED_FLAGS) \
+ $(LIBANJUTA_CFLAGS) \
+ $(EXTRA_CFLAGS) \
+ -DG_LOG_DOMAIN=\"indentation-c-style\"
+
+# Where to install the plugin
+plugindir = $(anjuta_plugin_dir)
+
+# The plugin
+plugin_LTLIBRARIES = libanjuta-indentation-c-style.la
+
+# Plugin sources
+libanjuta_indentation_c_style_la_SOURCES = \
+ plugin.c \
+ plugin.h \
+ indentation.c \
+ indentation.h
+
+libanjuta_indentation_c_style_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
+
+gsettings_in_file = org.gnome.anjuta.plugins.indent-c.gschema.xml.in
+gsettings_SCHEMAS = $(gsettings_in_file:.xml.in=.xml)
+ INTLTOOL_XML_NOMERGE_RULE@
+ GSETTINGS_RULES@
+
+
+EXTRA_DIST = \
+ $(plugin_in_files) \
+ $(indent_c_plugin_DATA) \
+ $(indent_c_ui_DATA) \
+ $(indent_c_pixmaps_DATA) \
+ $(indent_c_glade_DATA) \
+ $(gsettings_in_file)
+
+CLEANFILES = \
+ $(gsettings_SCHEMAS)
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/indentation-c-style/anjuta-indentation-c-style-auto-16.png b/plugins/indentation-c-style/anjuta-indentation-c-style-auto-16.png
new file mode 100644
index 0000000..189d62d
Binary files /dev/null and b/plugins/indentation-c-style/anjuta-indentation-c-style-auto-16.png differ
diff --git a/plugins/indentation-c-style/anjuta-indentation-c-style-auto-24.png b/plugins/indentation-c-style/anjuta-indentation-c-style-auto-24.png
new file mode 100644
index 0000000..afbfd05
Binary files /dev/null and b/plugins/indentation-c-style/anjuta-indentation-c-style-auto-24.png differ
diff --git a/plugins/indentation-c-style/anjuta-indentation-c-style-auto.svg b/plugins/indentation-c-style/anjuta-indentation-c-style-auto.svg
new file mode 100644
index 0000000..199d4b3
--- /dev/null
+++ b/plugins/indentation-c-style/anjuta-indentation-c-style-auto.svg
@@ -0,0 +1,448 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="24"
+ height="24"
+ id="svg2239"
+ sodipodi:version="0.32"
+ inkscape:version="0.45.1"
+ sodipodi:docbase="/home/maker/icons/anjuta-new2/smallsvg"
+ sodipodi:docname="anjuta-auto-indent.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ version="1.0"
+ inkscape:export-filename="/home/maker/icons/anjuta-new2/smallsvg/anjuta-auto-indent-24.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs2241">
+ <linearGradient
+ id="linearGradient3264">
+ <stop
+ style="stop-color:#c9c9c9;stop-opacity:1;"
+ offset="0"
+ id="stop3266" />
+ <stop
+ id="stop3276"
+ offset="0.25"
+ style="stop-color:#f8f8f8;stop-opacity:1;" />
+ <stop
+ id="stop3272"
+ offset="0.5"
+ style="stop-color:#e2e2e2;stop-opacity:1;" />
+ <stop
+ style="stop-color:#b0b0b0;stop-opacity:1;"
+ offset="0.75"
+ id="stop3274" />
+ <stop
+ style="stop-color:#c9c9c9;stop-opacity:1;"
+ offset="1"
+ id="stop3268" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3264"
+ id="linearGradient3281"
+ gradientUnits="userSpaceOnUse"
+ x1="14.462892"
+ y1="12.284524"
+ x2="34.534348"
+ y2="39.684914"
+ gradientTransform="matrix(0.3096041,0,0,0.3095808,-1.337593,-1.4130229)" />
+ <linearGradient
+ id="linearGradient5157">
+ <stop
+ style="stop-color:#555753"
+ offset="0"
+ id="stop5159" />
+ <stop
+ style="stop-color:#555753;stop-opacity:0;"
+ offset="1"
+ id="stop5161" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5157"
+ id="linearGradient5163"
+ x1="12.599577"
+ y1="27.091789"
+ x2="3.8727224"
+ y2="27.125141"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.6163718,0,0,0.6177592,1.6129632,2.4512392)" />
+ <linearGradient
+ id="linearGradient8650"
+ inkscape:collect="always">
+ <stop
+ id="stop8652"
+ offset="0"
+ style="stop-color:#ffffff;stop-opacity:1;" />
+ <stop
+ id="stop8654"
+ offset="1"
+ style="stop-color:#ffffff;stop-opacity:0;" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient12512">
+ <stop
+ id="stop12513"
+ offset="0.0000000"
+ style="stop-color:#ffffff;stop-opacity:1.0000000;" />
+ <stop
+ id="stop12517"
+ offset="0.50000000"
+ style="stop-color:#fff520;stop-opacity:0.89108908;" />
+ <stop
+ id="stop12514"
+ offset="1.0000000"
+ style="stop-color:#fff300;stop-opacity:0.0000000;" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient15662">
+ <stop
+ id="stop15664"
+ offset="0.0000000"
+ style="stop-color:#ffffff;stop-opacity:1.0000000;" />
+ <stop
+ id="stop15666"
+ offset="1.0000000"
+ style="stop-color:#f8f8f8;stop-opacity:1.0000000;" />
+ </linearGradient>
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient15662"
+ id="radialGradient15668"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.4726759,0,0,0.477318,1.3947925,1.6801914)"
+ cx="8.1435566"
+ cy="7.2678967"
+ fx="8.1435566"
+ fy="7.2678967"
+ r="38.158695" />
+ <linearGradient
+ id="linearGradient259">
+ <stop
+ id="stop260"
+ offset="0.0000000"
+ style="stop-color:#fafafa;stop-opacity:1.0000000;" />
+ <stop
+ id="stop261"
+ offset="1.0000000"
+ style="stop-color:#bbbbbb;stop-opacity:1.0000000;" />
+ </linearGradient>
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient259"
+ id="radialGradient15658"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.4957383,0,0,0.5088561,-0.9082853,0.7177894)"
+ cx="14.443224"
+ cy="10.289853"
+ fx="14.443224"
+ fy="10.289853"
+ r="86.70845" />
+ <linearGradient
+ id="linearGradient2896">
+ <stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="0"
+ id="stop2898" />
+ <stop
+ style="stop-color:#000000;stop-opacity:0;"
+ offset="1"
+ id="stop2900" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2896"
+ id="linearGradient2512"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.3527177,0,0,0.3968935,-0.5823082,0.599503)"
+ x1="14.584077"
+ y1="1.6392649"
+ x2="14.331437"
+ y2="4.5285392" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient2906">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop2908" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop2910" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2906"
+ id="linearGradient2510"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.4723736,-2.6820192,-6.5701006e-3)"
+ x1="13.354311"
+ y1="1.4866425"
+ x2="14.075844"
+ y2="2.4017651" />
+ <linearGradient
+ id="linearGradient2590">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop2592" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop2594" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2590"
+ id="linearGradient2508"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5250247,0,0,0.4723945,-2.9619942,0.4411996)"
+ x1="19.970377"
+ y1="6.1167107"
+ x2="19.970377"
+ y2="2.53125" />
+ <linearGradient
+ id="linearGradient5897">
+ <stop
+ style="stop-color:#000000;stop-opacity:0.0000000;"
+ offset="0.0000000"
+ id="stop5899" />
+ <stop
+ id="stop5905"
+ offset="0.50000000"
+ style="stop-color:#000000;stop-opacity:0.56701028;" />
+ <stop
+ style="stop-color:#000000;stop-opacity:0.0000000;"
+ offset="1.0000000"
+ id="stop5901" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5897"
+ id="linearGradient2506"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.6652988,0,0,0.8507738,-5.1693306,-6.566651)"
+ x1="19"
+ y1="9.7738247"
+ x2="19"
+ y2="15.635596" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient4404">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop4406" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop4408" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient4404"
+ id="linearGradient2504"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(-0.6597745,0,0,0.543039,17.468052,0.13928)"
+ x1="16.8125"
+ y1="1.875"
+ x2="16.8125"
+ y2="4.71875" />
+ <linearGradient
+ id="linearGradient2598">
+ <stop
+ style="stop-color:#a9382d;stop-opacity:1;"
+ offset="0"
+ id="stop2600" />
+ <stop
+ style="stop-color:#f04646;stop-opacity:1;"
+ offset="1"
+ id="stop2602" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2598"
+ id="linearGradient2502"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.6597745,0,0,0.5179028,-4.2351199,-0.249086)"
+ x1="18.431311"
+ y1="19.119474"
+ x2="18.402472"
+ y2="4.2702327" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient5866">
+ <stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="0"
+ id="stop5868" />
+ <stop
+ style="stop-color:#000000;stop-opacity:0;"
+ offset="1"
+ id="stop5870" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5866"
+ id="linearGradient2500"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.6121275,0,0,0.4819191,-2.4962352,1.098222)"
+ x1="19.452349"
+ y1="13.174174"
+ x2="19.685436"
+ y2="27.095339" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient8650"
+ id="radialGradient2669"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.2936405,0.1109764,-6.9704362e-2,-0.2160035,4.5725205,14.888519)"
+ cx="17.421288"
+ cy="8.2095308"
+ fx="17.421288"
+ fy="8.2095308"
+ r="17.171415" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient12512"
+ id="radialGradient2678"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(-1.1340151,-1.193205e-6,-7.9650437e-8,-1.1992054,117.37084,274.90072)"
+ cx="55"
+ cy="125"
+ fx="55"
+ fy="125"
+ r="14.375" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1"
+ inkscape:cx="11.549706"
+ inkscape:cy="10.826856"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:grid-bbox="true"
+ inkscape:document-units="px"
+ inkscape:window-width="1027"
+ inkscape:window-height="830"
+ inkscape:window-x="186"
+ inkscape:window-y="113"
+ width="24px"
+ height="24px"
+ showguides="true"
+ inkscape:guide-bbox="true" />
+ <metadata
+ id="metadata2244">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <cc:license
+ rdf:resource="http://creativecommons.org/licenses/LGPL/2.1/" />
+ </cc:Work>
+ <cc:License
+ rdf:about="http://creativecommons.org/licenses/LGPL/2.1/">
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/Reproduction" />
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/Distribution" />
+ <cc:requires
+ rdf:resource="http://web.resource.org/cc/Notice" />
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
+ <cc:requires
+ rdf:resource="http://web.resource.org/cc/ShareAlike" />
+ <cc:requires
+ rdf:resource="http://web.resource.org/cc/SourceCode" />
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="base"
+ inkscape:groupmode="layer">
+ <rect
+ style="color:#000000;fill:url(#radialGradient15658);fill-opacity:1;fill-rule:nonzero;stroke:#2e3436;stroke-width:0.9999997;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:block;overflow:visible"
+ id="rect15391"
+ width="18"
+ height="20"
+ x="2.5"
+ y="2.4999993"
+ ry="1.1490482"
+ rx="1.1490484" />
+ <rect
+ style="color:#000000;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:url(#radialGradient15668);stroke-width:0.99999964;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:block;overflow:visible"
+ id="rect15660"
+ width="16"
+ height="18"
+ x="3.4999998"
+ y="3.4999998"
+ ry="0.14904851"
+ rx="0.14904852" />
+ <g
+ style="display:inline"
+ id="g3825"
+ transform="matrix(0.4166665,0,0,0.4878049,9.000004,1.7560971)">
+ <rect
+ y="7"
+ x="11.999995"
+ height="2"
+ width="12.000005"
+ id="rect3827"
+ style="color:#000000;fill:#999999;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" />
+ <rect
+ style="color:#000000;fill:#999999;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ id="rect3829"
+ width="11"
+ height="2"
+ x="11.999995"
+ y="11" />
+ <rect
+ y="15"
+ x="11.999995"
+ height="2"
+ width="10"
+ id="rect3831"
+ style="color:#000000;fill:#999999;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" />
+ <rect
+ style="color:#000000;fill:#999999;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ id="rect3833"
+ width="12.000005"
+ height="2"
+ x="11.999995"
+ y="19" />
+ </g>
+ </g>
+ <g
+ inkscape:groupmode="layer"
+ id="layer3"
+ inkscape:label="overlay">
+ <path
+ sodipodi:nodetypes="cccccccc"
+ id="path8643"
+ d="M 4,15.120268 L 4,20.102833 L 9.9617745,20.071658 L 9.9307114,24 L 19,17.555354 L 9.8996479,11 L 9.9087461,15.089092 L 4,15.120268 z "
+ style="opacity:1;color:#000000;fill:url(#linearGradient5163);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.00000036;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" />
+ <path
+ style="opacity:1;color:#000000;fill:url(#linearGradient3281);fill-opacity:1;fill-rule:nonzero;stroke:#2e3436;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 5.7117572,0.50082916 C 5.595727,0.50876796 5.4829487,0.52673756 5.368981,0.53977856 L 5.3611906,0.53977856 L 5.0885277,2.0276265 C 4.6441091,2.1288288 4.2260009,2.3005784 3.8498592,2.5339622 L 2.6267715,1.653717 C 2.2961387,1.9103914 1.9952659,2.2097443 1.7308791,2.5339622 L 2.5800293,3.7725375 C 2.3222034,4.1665172 2.1283204,4.6163823 2.0191228,5.0890104 C 2.0191041,5.0912447 2.0191076,5.0964108 2.0191228,5.0968002 L 0.5389528,5.3304936 C 0.5118914,5.5515073 0.500001,5.7799176 0.500001,6.0082045 C 0.500001,6.1949848 0.5051587,6.3792695 0.5233721,6.5612789 L 2.003542,6.8261314 C 2.1088127,7.3401054 2.3087894,7.8201104 2.5878196,8.2438716 L 1.707508,9.4512872 C 1.9596233,9.7642552 2.2506878,10.049197 2.5644485,10.300374 L 3.8109074,9.4434982 C 4.2465281,9.7213672 4.732809,9.9162122 5.2599158,10.012152 L 5.4936269,11.484421 C 5.6597009,11.499535 5.8300085,11.5 6.0000008,11.5 C 6.2399905,11.499999 6.4692267,11.490906 6.7011339,11.461051 L 6.9815872,9.9576242 C 7.482
0563,9.8330862 7.9521967,9.6170442 8.3604831,9.3266512 L 9.560198,10.199106 C 9.871321,9.9344292 10.155826,9.6302022 10.401558,9.3032821 L 9.529037,8.0413373 C 9.765329,7.6332798 9.929058,7.1830552 10.012041,6.7014949 L 11.48442,6.4678015 C 11.497332,6.3141631 11.5,6.1651625 11.5,6.0082045 C 11.5,5.7354465 11.468296,5.468009 11.429887,5.2058571 L 9.934136,4.9332148 C 9.816921,4.5004211 9.624597,4.0966292 9.3810201,3.7335886 L 10.261332,2.5261724 C 9.988465,2.1924941 9.677197,1.8842496 9.3342781,1.6225579 L 8.0644481,2.4950133 C 7.6994856,2.2791838 7.3067354,2.1135803 6.8803119,2.0198367 L 6.6466018,0.53977856 C 6.4338812,0.51475756 6.21941,0.50082916 6.0000008,0.50082916 C 5.9407013,0.50082916 5.8796716,0.49896356 5.8208223,0.50082916 C 5.7921331,0.50173946 5.763743,0.49916106 5.7351283,0.50082916 C 5.7273783,0.50128186 5.7194925,0.50030066 5.7117572,0.50082916 z M 5.9143067,4.286663 C 5.9427674,4.2852189 5.9711832,4.286663 6.0000008,4.286663 C 6.922163,4.286663 7.6749304,5.
0393737 7.6749304,5.9614658 C 7.6749304,6.8835579 6.922162,7.6284788 6.0000008,7.6284788 C 5.0778393,7.6284791 4.332862,6.8835579 4.332862,5.9614658 C 4.3328622,5.0681894 5.0320258,4.3314304 5.9143067,4.286663 z "
+ id="path3243" />
+ </g>
+</svg>
diff --git a/plugins/indentation-c-style/anjuta-indentation-c-style-plugin.png b/plugins/indentation-c-style/anjuta-indentation-c-style-plugin.png
new file mode 100644
index 0000000..0fe99c5
Binary files /dev/null and b/plugins/indentation-c-style/anjuta-indentation-c-style-plugin.png differ
diff --git a/plugins/indentation-c-style/anjuta-indentation-c-style.plugin.in b/plugins/indentation-c-style/anjuta-indentation-c-style.plugin.in
new file mode 100644
index 0000000..671ff93
--- /dev/null
+++ b/plugins/indentation-c-style/anjuta-indentation-c-style.plugin.in
@@ -0,0 +1,11 @@
+[Anjuta Plugin]
+Location=anjuta-indentation-c-style:IndentCPlugin
+Icon=anjuta-indentation-c-style-plugin.png
+_Name=C style indentation Plugin
+_Description=auto-indentation for c style code
+Interfaces=IAnjutaLanguageSupport,IAnjutaIndenter
+UserActivatable=no
+
+[Language Support]
+Languages=C,C++,Java,Vala
+MimeTypes=text/x-c,text/x-java-source,text/x-vala
diff --git a/plugins/indentation-c-style/anjuta-indentation-c-style.ui b/plugins/indentation-c-style/anjuta-indentation-c-style.ui
new file mode 100644
index 0000000..f6b3a5f
--- /dev/null
+++ b/plugins/indentation-c-style/anjuta-indentation-c-style.ui
@@ -0,0 +1,340 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-requires anjuta 0.0 -->
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment2">
+ <property name="upper">100</property>
+ <property name="value">4</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment3">
+ <property name="upper">50</property>
+ <property name="value">10</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment4">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkListStore" id="liststore1"/>
+ <object class="GtkWindow" id="preferences_dialog">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">window1</property>
+ <child>
+ <object class="GtkFrame" id="preferences">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkVBox" id="vbox1111">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkTable" id="table15">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">10</property>
+ <property name="n_rows">4</property>
+ <property name="column_spacing">5</property>
+ <property name="row_spacing">5</property>
+ <child>
+ <object class="GtkCheckButton" id="preferences:indent-automatic">
+ <property name="label" translatable="yes">Enable smart indentation</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="preferences:multiline-leading-asterisk">
+ <property name="label" translatable="yes">Leading asterisk in multi-line comment</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="preferences:indent-modeline">
+ <property name="label" translatable="yes">Prefer vim/emacs modelines over indentation settings</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="preferences:brace-autocompletion">
+ <property name="label" translatable="yes">Enable smart brace completion</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame48">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkTable" id="table18">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">5</property>
+ <property name="row_spacing">5</property>
+ <child>
+ <object class="GtkSpinButton" id="preferences:indent-brace-size">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ <property name="adjustment">adjustment1</property>
+ <property name="climb_rate">1</property>
+ <property name="numeric">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="preferences:.editor.indent-width">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ <property name="adjustment">adjustment2</property>
+ <property name="climb_rate">1</property>
+ <property name="numeric">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label12353">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Brace indentation size in spaces:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label123">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Statement indentation size in spaces:</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label12355">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Indentation parameters</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">5</property>
+ <property name="row_spacing">5</property>
+ <child>
+ <object class="GtkRadioButton" id="preferences:indent-paranthese-lineup">
+ <property name="label" translatable="yes">Line up parentheses</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">preferences:indent-paranthese-indent</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="preferences:indent-paranthese-indent">
+ <property name="label" translatable="yes">Indent:</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="preferences:indent-paranthese-size">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ <property name="adjustment">adjustment4</property>
+ <property name="climb_rate">1</property>
+ <property name="numeric">True</property>
+ <signal name="value-changed" handler="on_spinbutton1_value_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Parenthesis indentation</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/plugins/language-support-python/python-plugin.xml b/plugins/indentation-c-style/anjuta-indentation-c-style.xml
similarity index 71%
copy from plugins/language-support-python/python-plugin.xml
copy to plugins/indentation-c-style/anjuta-indentation-c-style.xml
index 248c9d4..43f6e00 100644
--- a/plugins/language-support-python/python-plugin.xml
+++ b/plugins/indentation-c-style/anjuta-indentation-c-style.xml
@@ -3,8 +3,6 @@
<menubar name="MenuMain">
<menu name="MenuEdit" action="ActionMenuEdit">
<placeholder name="PlaceholderOperationMenus">
- <separator name="separator1"/>
- <menuitem name="Autocomplete" action="ActionEditAutocomplete" />
<menuitem name="AutoindentAction" action="ActionEditAutoindent" />
</placeholder>
</menu>
diff --git a/plugins/language-support-cpp-java/cpp-java-indentation.c b/plugins/indentation-c-style/indentation.c
similarity index 97%
rename from plugins/language-support-cpp-java/cpp-java-indentation.c
rename to plugins/indentation-c-style/indentation.c
index 9b326d1..7b66045 100644
--- a/plugins/language-support-cpp-java/cpp-java-indentation.c
+++ b/plugins/indentation-c-style/indentation.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
- * cpp-java-indentation.c
+ * indent-c-indentation.c
*
* Copyright (C) 2011 - Johannes Schmid
*
@@ -22,6 +22,7 @@
#include <ctype.h>
#include <stdlib.h>
#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-utils.h>
#include <libanjuta/interfaces/ianjuta-iterable.h>
#include <libanjuta/interfaces/ianjuta-document.h>
#include <libanjuta/interfaces/ianjuta-editor.h>
@@ -31,8 +32,7 @@
#include <libanjuta/interfaces/ianjuta-preferences.h>
#include <libanjuta/interfaces/ianjuta-language.h>
-#include "cpp-java-indentation.h"
-#include "cpp-java-utils.h"
+#include "indentation.h"
#define PREF_INDENT_BRACE_SIZE "indent-brace-size"
#define PREF_INDENT_PARANTHESE_LINEUP "indent-paranthese-lineup"
@@ -420,7 +420,7 @@ set_line_indentation (IAnjutaEditor *editor, gint line_num, gint indentation, gi
{
IAnjutaIterable *line_begin, *line_end, *indent_position;
IAnjutaIterable *current_pos;
- gint carat_offset, nchars = 0, nchars_removed = 0;
+ gint carat_offset, nchars = 0;
gchar *old_indent_string = NULL, *indent_string = NULL;
/* DEBUG_PRINT ("In %s()", __FUNCTION__); */
@@ -478,7 +478,6 @@ set_line_indentation (IAnjutaEditor *editor, gint line_num, gint indentation, gi
indent_position, NULL);
//DEBUG_PRINT ("old_indent_string = '%s'", old_indent_string);
- nchars_removed = g_utf8_strlen (old_indent_string, -1);
}
/* Only indent if there was no indentation before or old
@@ -510,7 +509,6 @@ set_line_indentation (IAnjutaEditor *editor, gint line_num, gint indentation, gi
old_indent_string =
ianjuta_editor_get_text (editor, line_begin,
indent_position, NULL);
- nchars_removed = g_utf8_strlen (old_indent_string, -1);
}
if (old_indent_string)
ianjuta_editor_erase (editor, line_begin, indent_position, NULL);
@@ -563,7 +561,7 @@ set_line_indentation (IAnjutaEditor *editor, gint line_num, gint indentation, gi
* -1 == UNKNOWN
*/
static gint
-get_line_indentation_base (CppJavaPlugin *plugin,
+get_line_indentation_base (IndentCPlugin *plugin,
IAnjutaEditor *editor,
gint line_num,
gint *incomplete_statement,
@@ -809,7 +807,7 @@ get_line_indentation_base (CppJavaPlugin *plugin,
}
/* Find matching brace and continue */
- if (!cpp_java_util_jump_to_matching_brace (iter, point_ch, -1))
+ if (!anjuta_util_jump_to_matching_brace (iter, point_ch, -1))
{
line_indent = get_line_indentation (editor, line_saved);
line_indent += extra_indent;
@@ -1027,7 +1025,7 @@ spaces_only (IAnjutaEditor* editor, IAnjutaIterable* begin, IAnjutaIterable* end
}
static gint
-get_line_auto_indentation (CppJavaPlugin *plugin, IAnjutaEditor *editor,
+get_line_auto_indentation (IndentCPlugin *plugin, IAnjutaEditor *editor,
gint line, gint *line_indent_spaces)
{
IAnjutaIterable *iter;
@@ -1141,7 +1139,7 @@ get_line_auto_indentation (CppJavaPlugin *plugin, IAnjutaEditor *editor,
else if (ch == '}')
{
ianjuta_iterable_previous (iter, NULL);
- if (cpp_java_util_jump_to_matching_brace (iter, ch, -1))
+ if (anjuta_util_jump_to_matching_brace (iter, ch, -1))
{
gint line = ianjuta_editor_get_line_from_position (editor,
iter,
@@ -1173,7 +1171,7 @@ static void
insert_editor_blocked (IAnjutaEditor* editor,
IAnjutaIterable* iter,
gchar* text,
- CppJavaPlugin* plugin)
+ IndentCPlugin* plugin)
{
g_signal_handlers_block_by_func (editor, cpp_indentation, plugin);
ianjuta_editor_insert (editor, iter, text, -1, NULL);
@@ -1184,7 +1182,7 @@ void
cpp_indentation (IAnjutaEditor *editor,
IAnjutaIterable *insert_pos,
gchar ch,
- CppJavaPlugin *plugin)
+ IndentCPlugin *plugin)
{
IAnjutaEditorAttribute attrib;
IAnjutaIterable *iter;
@@ -1279,13 +1277,13 @@ cpp_indentation (IAnjutaEditor *editor,
insert_editor_blocked (editor, iter,
"]", plugin);
break;
- case '(':
- insert_editor_blocked (editor, iter,
- ")", plugin);
- break;
- default:
- break;
- }
+ case '(':
+ insert_editor_blocked (editor, iter,
+ ")", plugin);
+ break;
+ default:
+ break;
+ }
ianjuta_editor_goto_position (editor, iter, NULL);
ianjuta_document_end_undo_action (IANJUTA_DOCUMENT (editor), NULL);
}
@@ -1339,7 +1337,7 @@ cpp_indentation (IAnjutaEditor *editor,
void
cpp_auto_indentation (IAnjutaEditor *editor,
- CppJavaPlugin *lang_plugin,
+ IndentCPlugin *lang_plugin,
IAnjutaIterable *start,
IAnjutaIterable *end)
{
@@ -1394,7 +1392,7 @@ void
java_indentation (IAnjutaEditor *editor,
IAnjutaIterable *insert_pos,
gchar ch,
- CppJavaPlugin *plugin)
+ IndentCPlugin *plugin)
{
cpp_indentation (editor, insert_pos, ch, plugin);
}
diff --git a/plugins/language-support-cpp-java/cpp-java-indentation.h b/plugins/indentation-c-style/indentation.h
similarity index 88%
rename from plugins/language-support-cpp-java/cpp-java-indentation.h
rename to plugins/indentation-c-style/indentation.h
index 54727ee..b661227 100644
--- a/plugins/language-support-cpp-java/cpp-java-indentation.h
+++ b/plugins/indentation-c-style/indentation.h
@@ -1,6 +1,6 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
- * cpp-java-indentation.h
+ * indent-c-indentation.h
*
* Copyright (C) 2011 - Johannes Schmid
*
@@ -24,11 +24,11 @@ void
cpp_indentation (IAnjutaEditor *editor,
IAnjutaIterable *insert_pos,
gchar ch,
- CppJavaPlugin *plugin);
+ IndentCPlugin *plugin);
void
cpp_auto_indentation (IAnjutaEditor *editor,
- CppJavaPlugin *plugin,
+ IndentCPlugin *plugin,
IAnjutaIterable *start,
IAnjutaIterable *end);
@@ -36,4 +36,4 @@ void
java_indentation (IAnjutaEditor *editor,
IAnjutaIterable *insert_pos,
gchar ch,
- CppJavaPlugin *plugin);
+ IndentCPlugin *plugin);
diff --git a/plugins/indentation-c-style/org.gnome.anjuta.plugins.indent-c.gschema.xml.in b/plugins/indentation-c-style/org.gnome.anjuta.plugins.indent-c.gschema.xml.in
new file mode 100644
index 0000000..33b8e4e
--- /dev/null
+++ b/plugins/indentation-c-style/org.gnome.anjuta.plugins.indent-c.gschema.xml.in
@@ -0,0 +1,31 @@
+<schemalist>
+ <schema id="org.gnome.anjuta.plugins.indent-c" path="/org/gnome/anjuta/plugins/indent-c/">
+ <key name="user-packages" type="s">
+ <default>""</default>
+ </key>
+ <key name="multiline-leading-asterisk" type="b">
+ <default>true</default>
+ </key>
+ <key name="indent-automatic" type="b">
+ <default>true</default>
+ </key>
+ <key name="indent-modeline" type="b">
+ <default>true</default>
+ </key>
+ <key name="indent-brace-size" type="i">
+ <default>0</default>
+ </key>
+ <key name="indent-paranthese-lineup" type="b">
+ <default>true</default>
+ </key>
+ <key name="indent-paranthese-indent" type="b">
+ <default>false</default>
+ </key>
+ <key name="indent-paranthese-size" type="i">
+ <default>4</default>
+ </key>
+ <key type="b" name="brace-autocompletion">
+ <default>false</default>
+ </key>
+ </schema>
+</schemalist>
diff --git a/plugins/indentation-c-style/plugin.c b/plugins/indentation-c-style/plugin.c
new file mode 100644
index 0000000..8cec6c5
--- /dev/null
+++ b/plugins/indentation-c-style/plugin.c
@@ -0,0 +1,651 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ plugin.c
+ Copyright (C) 2000 Naba Kumar
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include <config.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <libanjuta/anjuta-shell.h>
+#include <libanjuta/anjuta-debug.h>
+#include "libanjuta/anjuta-utils.h"
+#include <libanjuta/interfaces/ianjuta-iterable.h>
+#include <libanjuta/interfaces/ianjuta-document.h>
+#include <libanjuta/interfaces/ianjuta-document-manager.h>
+#include <libanjuta/interfaces/ianjuta-editor.h>
+#include <libanjuta/interfaces/ianjuta-file.h>
+#include <libanjuta/interfaces/ianjuta-editor-cell.h>
+#include <libanjuta/interfaces/ianjuta-editor-language.h>
+#include <libanjuta/interfaces/ianjuta-editor-selection.h>
+#include <libanjuta/interfaces/ianjuta-preferences.h>
+#include <libanjuta/interfaces/ianjuta-symbol-manager.h>
+#include <libanjuta/interfaces/ianjuta-language.h>
+#include <libanjuta/interfaces/ianjuta-indenter.h>
+
+#include "plugin.h"
+#include "indentation.h"
+
+/* Pixmaps */
+#define ANJUTA_PIXMAP_SWAP "anjuta-swap"
+#define ANJUTA_PIXMAP_AUTOINDENT "anjuta-indent-auto"
+#define ANJUTA_STOCK_SWAP "anjuta-swap"
+#define ANJUTA_STOCK_AUTOINDENT "anjuta-indent"
+
+#define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-indentation-c-style.xml"
+#define PREFS_BUILDER PACKAGE_DATA_DIR"/glade/anjuta-indentation-c-style.ui"
+#define ICON_FILE "anjuta-indentation-c-style-plugin.png"
+
+/* Preferences keys */
+
+#define ANJUTA_PREF_SCHEMA_PREFIX "org.gnome.anjuta."
+#define PREF_SCHEMA "org.gnome.anjuta.plugins.indent-c"
+#define PREF_INDENT_AUTOMATIC "indent-automatic"
+#define PREF_INDENT_MODELINE "indent-modeline"
+
+static gpointer parent_class;
+
+static void
+set_indentation_param_emacs (IndentCPlugin* plugin, const gchar *param,
+ const gchar *value)
+{
+ //DEBUG_PRINT ("Setting indent param: %s = %s", param, value);
+ if (strcasecmp (param, "indent-tabs-mode") == 0)
+ {
+ if (strcasecmp (value, "t") == 0)
+ {
+ plugin->param_use_spaces = 0;
+ ianjuta_editor_set_use_spaces (IANJUTA_EDITOR (plugin->current_editor),
+ FALSE, NULL);
+ }
+ else if (strcasecmp (value, "nil") == 0)
+ {
+ plugin->param_use_spaces = 1;
+ ianjuta_editor_set_use_spaces (IANJUTA_EDITOR (plugin->current_editor),
+ TRUE, NULL);
+ }
+ }
+ else if (strcasecmp (param, "c-basic-offset") == 0)
+ {
+ plugin->param_statement_indentation = atoi (value);
+ }
+ else if (strcasecmp (param, "tab-width") == 0)
+ {
+ plugin->param_tab_size = atoi (value);
+ ianjuta_editor_set_tabsize (IANJUTA_EDITOR (plugin->current_editor),
+ plugin->param_tab_size, NULL);
+ }
+}
+
+static void
+set_indentation_param_vim (IndentCPlugin* plugin, const gchar *param,
+ const gchar *value)
+{
+ //DEBUG_PRINT ("Setting indent param: %s = %s", param, value);
+ if (g_str_equal (param, "expandtab") ||
+ g_str_equal (param, "et"))
+ {
+ plugin->param_use_spaces = 1;
+ ianjuta_editor_set_use_spaces (IANJUTA_EDITOR (plugin->current_editor),
+ TRUE, NULL);
+ }
+ else if (g_str_equal (param, "noexpandtab") ||
+ g_str_equal (param, "noet"))
+ {
+ plugin->param_use_spaces = 0;
+ ianjuta_editor_set_use_spaces (IANJUTA_EDITOR (plugin->current_editor),
+ FALSE, NULL);
+ }
+ if (!value)
+ return;
+ else if (g_str_equal (param, "shiftwidth") ||
+ g_str_equal (param, "sw"))
+ {
+ plugin->param_statement_indentation = atoi (value);
+ }
+ else if (g_str_equal (param, "softtabstop") ||
+ g_str_equal (param, "sts") ||
+ g_str_equal (param, "tabstop") ||
+ g_str_equal (param, "ts"))
+ {
+ plugin->param_tab_size = atoi (value);
+ ianjuta_editor_set_tabsize (IANJUTA_EDITOR (plugin->current_editor),
+ plugin->param_tab_size, NULL);
+ }
+}
+
+static void
+parse_mode_line_emacs (IndentCPlugin *plugin, const gchar *modeline)
+{
+ gchar **strv, **ptr;
+
+ strv = g_strsplit (modeline, ";", -1);
+ ptr = strv;
+ while (*ptr)
+ {
+ gchar **keyval;
+ keyval = g_strsplit (*ptr, ":", 2);
+ if (keyval[0] && keyval[1])
+ {
+ g_strstrip (keyval[0]);
+ g_strstrip (keyval[1]);
+ set_indentation_param_emacs (plugin, g_strchug (keyval[0]),
+ g_strchug (keyval[1]));
+ }
+ g_strfreev (keyval);
+ ptr++;
+ }
+ g_strfreev (strv);
+}
+
+static void
+parse_mode_line_vim (IndentCPlugin *plugin, const gchar *modeline)
+{
+ gchar **strv, **ptr;
+
+ strv = g_strsplit_set (modeline, " \t:", -1);
+ ptr = strv;
+ while (*ptr)
+ {
+ gchar **keyval;
+ keyval = g_strsplit (*ptr, "=", 2);
+ if (keyval[0])
+ {
+ g_strstrip (keyval[0]);
+ if (keyval[1])
+ {
+ g_strstrip (keyval[1]);
+ set_indentation_param_vim (plugin, g_strchug (keyval[0]),
+ g_strchug (keyval[1]));
+ }
+ else
+ set_indentation_param_vim (plugin, g_strchug (keyval[0]),
+ NULL);
+ }
+ g_strfreev (keyval);
+ ptr++;
+ }
+ g_strfreev (strv);
+}
+
+static gchar *
+extract_mode_line (const gchar *comment_text, gboolean* vim)
+{
+ /* Search for emacs-like modelines */
+ gchar *begin_modeline, *end_modeline;
+ begin_modeline = strstr (comment_text, "-*-");
+ if (begin_modeline)
+ {
+ begin_modeline += 3;
+ end_modeline = strstr (begin_modeline, "-*-");
+ if (end_modeline)
+ {
+ *vim = FALSE;
+ return g_strndup (begin_modeline, end_modeline - begin_modeline);
+ }
+ }
+ /* Search for vim-like modelines */
+ begin_modeline = strstr (comment_text, "vim:");
+ if (begin_modeline)
+ {
+ begin_modeline += strlen ("vim:");
+ end_modeline = strstr (begin_modeline, "*/");
+ /* Check for escape characters */
+ while (end_modeline)
+ {
+ if (!g_str_equal ((end_modeline - 1), "\\"))
+ break;
+ end_modeline++;
+ end_modeline = strstr (end_modeline, "*/");
+ }
+ if (end_modeline)
+ {
+ gchar* vim_modeline = g_strndup (begin_modeline, end_modeline - begin_modeline);
+ *vim = TRUE;
+ return vim_modeline;
+ }
+ }
+ return NULL;
+}
+
+#define MINI_BUFFER_SIZE 3
+static void
+initialize_indentation_params (IndentCPlugin *plugin)
+{
+ IAnjutaIterable *iter;
+ GString *comment_text;
+ gboolean comment_begun = FALSE;
+ gboolean line_comment = FALSE;
+ gchar mini_buffer[MINI_BUFFER_SIZE] = {0};
+
+ plugin->smart_indentation = g_settings_get_boolean (plugin->settings, PREF_INDENT_AUTOMATIC);
+ /* Disable editor intern auto-indent if smart indentation is enabled */
+ ianjuta_editor_set_auto_indent (IANJUTA_EDITOR(plugin->current_editor),
+ !plugin->smart_indentation, NULL);
+
+ /* Initialize indentation parameters */
+ plugin->param_tab_size = -1;
+ plugin->param_statement_indentation = -1;
+ plugin->param_brace_indentation = -1;
+ plugin->param_case_indentation = -1;
+ plugin->param_label_indentation = -1;
+ plugin->param_use_spaces = -1;
+
+ if (g_settings_get_boolean (plugin->settings,
+ PREF_INDENT_MODELINE))
+ {
+ /* Find the first comment text in the buffer */
+ comment_text = g_string_new (NULL);
+ iter = ianjuta_editor_get_start_position (IANJUTA_EDITOR (plugin->current_editor),
+ NULL);
+ do
+ {
+ gboolean shift_buffer = TRUE;
+ gint i;
+ gchar ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter),
+ 0, NULL);
+
+ for (i = 0; i < MINI_BUFFER_SIZE - 1; i++)
+ {
+ if (mini_buffer[i] == '\0')
+ {
+ mini_buffer[i] = ch;
+ shift_buffer = FALSE;
+ break;
+ }
+ }
+ if (shift_buffer == TRUE)
+ {
+ /* Shift buffer and add */
+ for (i = 0; i < MINI_BUFFER_SIZE - 1; i++)
+ mini_buffer [i] = mini_buffer[i+1];
+ mini_buffer[i] = ch;
+ }
+
+ if (!comment_begun && strncmp (mini_buffer, "/*", 2) == 0)
+ {
+ comment_begun = TRUE;
+ /* Reset buffer */
+ mini_buffer[0] = mini_buffer[1] = '\0';
+ }
+ else if (!comment_begun && strncmp (mini_buffer, "//", 2) == 0)
+ {
+ comment_begun = TRUE;
+ line_comment = TRUE;
+ }
+ else if (!comment_begun && mini_buffer[1] != '\0')
+ {
+ /* The buffer doesn't begin with a comment */
+ break;
+ }
+ else if (comment_begun)
+ {
+ if ((line_comment && ch == '\n') ||
+ (!line_comment && strncmp (mini_buffer, "*/", 2) == 0))
+ {
+ break;
+ }
+ }
+ if (comment_begun)
+ g_string_append_c (comment_text, ch);
+ }
+ while (ianjuta_iterable_next (iter, NULL));
+
+ /* DEBUG_PRINT ("Comment text: %s", comment_text->str);*/
+ if (comment_text->len > 0)
+ {
+ /* First comment found */
+ gboolean vim;
+ gchar *modeline = extract_mode_line (comment_text->str, &vim);
+ if (modeline)
+ {
+ if (!vim)
+ parse_mode_line_emacs (plugin, modeline);
+ else
+ parse_mode_line_vim (plugin, modeline);
+ g_free (modeline);
+ }
+ }
+ g_string_free (comment_text, TRUE);
+ g_object_unref (iter);
+ }
+}
+
+/* Enable/Disable language-support */
+static void
+install_support (IndentCPlugin *lang_plugin)
+{
+ IAnjutaLanguage* lang_manager =
+ anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell,
+ IAnjutaLanguage, NULL);
+
+ if (!lang_manager)
+ return;
+
+ if (lang_plugin->support_installed)
+ return;
+
+ lang_plugin->current_language =
+ ianjuta_language_get_name_from_editor (lang_manager,
+ IANJUTA_EDITOR_LANGUAGE (lang_plugin->current_editor), NULL);
+
+ DEBUG_PRINT("Indentation support installed for: %s",
+ lang_plugin->current_language);
+
+ if (lang_plugin->current_language &&
+ (g_str_equal (lang_plugin->current_language, "C")
+ || g_str_equal (lang_plugin->current_language, "C++")
+ || g_str_equal (lang_plugin->current_language, "Vala")))
+ {
+ g_signal_connect (lang_plugin->current_editor,
+ "char-added",
+ G_CALLBACK (cpp_indentation),
+ lang_plugin);
+ }
+ else if (lang_plugin->current_language &&
+ (g_str_equal (lang_plugin->current_language, "Java")))
+ {
+ g_signal_connect (lang_plugin->current_editor,
+ "char-added",
+ G_CALLBACK (java_indentation),
+ lang_plugin);
+ }
+ else
+ {
+ return;
+ }
+
+ initialize_indentation_params (lang_plugin);
+ lang_plugin->support_installed = TRUE;
+}
+
+static void
+uninstall_support (IndentCPlugin *lang_plugin)
+{
+ if (!lang_plugin->support_installed)
+ return;
+
+ if (lang_plugin->current_language &&
+ (g_str_equal (lang_plugin->current_language, "C")
+ || g_str_equal (lang_plugin->current_language, "C++")
+ || g_str_equal (lang_plugin->current_language, "Vala")))
+ {
+ g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
+ G_CALLBACK (cpp_indentation),
+ lang_plugin);
+ }
+ else if (lang_plugin->current_language &&
+ (g_str_equal (lang_plugin->current_language, "Java")))
+ {
+ g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
+ G_CALLBACK (java_indentation),
+ lang_plugin);
+ }
+
+ lang_plugin->support_installed = FALSE;
+}
+
+static void
+on_editor_language_changed (IAnjutaEditor *editor,
+ const gchar *new_language,
+ IndentCPlugin *plugin)
+{
+ uninstall_support (plugin);
+ install_support (plugin);
+}
+
+static void
+on_value_added_current_editor (AnjutaPlugin *plugin, const gchar *name,
+ const GValue *value, gpointer data)
+{
+ IndentCPlugin *lang_plugin;
+ IAnjutaDocument* doc = IANJUTA_DOCUMENT(g_value_get_object (value));
+ lang_plugin = ANJUTA_PLUGIN_INDENT_C (plugin);
+ if (IANJUTA_IS_EDITOR(doc))
+ lang_plugin->current_editor = G_OBJECT(doc);
+ else
+ {
+ lang_plugin->current_editor = NULL;
+ return;
+ }
+ if (IANJUTA_IS_EDITOR(lang_plugin->current_editor))
+ install_support (lang_plugin);
+ g_signal_connect (lang_plugin->current_editor, "language-changed",
+ G_CALLBACK (on_editor_language_changed),
+ plugin);
+}
+
+static void
+on_value_removed_current_editor (AnjutaPlugin *plugin, const gchar *name,
+ gpointer data)
+{
+ IndentCPlugin *lang_plugin;
+ lang_plugin = ANJUTA_PLUGIN_INDENT_C (plugin);
+ if (lang_plugin->current_editor)
+ g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
+ G_CALLBACK (on_editor_language_changed),
+ plugin);
+ if (IANJUTA_IS_EDITOR(lang_plugin->current_editor))
+ uninstall_support (lang_plugin);
+ lang_plugin->current_editor = NULL;
+}
+
+static void
+on_auto_indent (GtkAction *action, gpointer data)
+{
+ IndentCPlugin *lang_plugin;
+ IAnjutaEditor *editor;
+ lang_plugin = ANJUTA_PLUGIN_INDENT_C (data);
+ editor = IANJUTA_EDITOR (lang_plugin->current_editor);
+
+ cpp_auto_indentation (editor, lang_plugin, NULL, NULL);
+}
+
+/* Plugin */
+
+static GtkActionEntry actions[] = {
+ {
+ "ActionMenuEdit",
+ NULL, N_("_Edit"),
+ NULL, NULL, NULL
+ },
+ {
+ "ActionEditAutoindent",
+ ANJUTA_STOCK_AUTOINDENT,
+ N_("Auto-Indent"), "<control>i",
+ N_("Auto-indent current line or selection based on indentation settings"),
+ G_CALLBACK (on_auto_indent)
+ }
+};
+
+static void
+register_stock_icons (AnjutaPlugin *plugin)
+{
+ static gboolean registered = FALSE;
+
+ if (registered)
+ return;
+ registered = TRUE;
+
+ /* Register stock icons */
+ BEGIN_REGISTER_ICON (plugin);
+ REGISTER_ICON_FULL (ANJUTA_PIXMAP_SWAP, ANJUTA_STOCK_SWAP);
+ REGISTER_ICON_FULL (ANJUTA_PIXMAP_AUTOINDENT, ANJUTA_STOCK_AUTOINDENT);
+ END_REGISTER_ICON;
+}
+
+static gboolean
+indent_c_plugin_activate_plugin (AnjutaPlugin *plugin)
+{
+ AnjutaUI *ui;
+ IndentCPlugin *lang_plugin;
+ static gboolean initialized = FALSE;
+
+ lang_plugin = ANJUTA_PLUGIN_INDENT_C (plugin);
+
+ DEBUG_PRINT ("%s", "AnjutaIndentCPlugin: Activating plugin ...");
+
+ if (!initialized)
+ {
+ register_stock_icons (plugin);
+ }
+
+ ui = anjuta_shell_get_ui (plugin->shell, NULL);
+ lang_plugin->action_group =
+ anjuta_ui_add_action_group_entries (ui, "ActionGroupCppJavaAssist",
+ _("C++/Java Assistance"),
+ actions,
+ G_N_ELEMENTS (actions),
+ GETTEXT_PACKAGE, TRUE,
+ plugin);
+ lang_plugin->uiid = anjuta_ui_merge (ui, UI_FILE);
+
+ lang_plugin->editor_watch_id =
+ anjuta_plugin_add_watch (plugin,
+ IANJUTA_DOCUMENT_MANAGER_CURRENT_DOCUMENT,
+ on_value_added_current_editor,
+ on_value_removed_current_editor,
+ plugin);
+
+ initialized = FALSE;
+ return TRUE;
+}
+
+static gboolean
+indent_c_plugin_deactivate_plugin (AnjutaPlugin *plugin)
+{
+ AnjutaUI *ui;
+ IndentCPlugin *lang_plugin;
+ lang_plugin = ANJUTA_PLUGIN_INDENT_C (plugin);
+
+ anjuta_plugin_remove_watch (plugin,
+ lang_plugin->editor_watch_id,
+ TRUE);
+
+ ui = anjuta_shell_get_ui (plugin->shell, NULL);
+ anjuta_ui_unmerge (ui, lang_plugin->uiid);
+
+ lang_plugin->uiid = 0;
+ DEBUG_PRINT ("%s", "AnjutaIndentCPlugin: Deactivated plugin.");
+ return TRUE;
+}
+
+static void
+indent_c_plugin_finalize (GObject *obj)
+{
+ /* Finalization codes here */
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+static void
+indent_c_plugin_dispose (GObject *obj)
+{
+ IndentCPlugin* plugin = ANJUTA_PLUGIN_INDENT_C (obj);
+ /* Disposition codes */
+
+ g_object_unref (plugin->settings);
+ g_object_unref (plugin->editor_settings);
+
+ G_OBJECT_CLASS (parent_class)->dispose (obj);
+}
+
+static void
+indent_c_plugin_instance_init (GObject *obj)
+{
+ IndentCPlugin *plugin = ANJUTA_PLUGIN_INDENT_C (obj);
+ plugin->current_editor = NULL;
+ plugin->current_language = NULL;
+ plugin->editor_watch_id = 0;
+ plugin->uiid = 0;
+ plugin->settings = g_settings_new (PREF_SCHEMA);
+ plugin->editor_settings = g_settings_new (ANJUTA_PREF_SCHEMA_PREFIX IANJUTA_EDITOR_PREF_SCHEMA);
+}
+
+static void
+indent_c_plugin_class_init (GObjectClass *klass)
+{
+ AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ plugin_class->activate = indent_c_plugin_activate_plugin;
+ plugin_class->deactivate = indent_c_plugin_deactivate_plugin;
+ klass->finalize = indent_c_plugin_finalize;
+ klass->dispose = indent_c_plugin_dispose;
+}
+
+static void
+ipreferences_merge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
+ GError** e)
+{
+ GError* error = NULL;
+ IndentCPlugin* plugin = ANJUTA_PLUGIN_INDENT_C (ipref);
+ plugin->bxml = gtk_builder_new ();
+
+ /* Add preferences */
+ if (!gtk_builder_add_from_file (plugin->bxml, PREFS_BUILDER, &error))
+ {
+ g_warning ("Couldn't load builder file: %s", error->message);
+ g_error_free (error);
+ }
+ anjuta_preferences_add_from_builder (prefs,
+ plugin->bxml, plugin->settings,
+ "preferences", _("Indentation C Style"),
+ ICON_FILE);
+}
+
+static void
+ipreferences_unmerge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
+ GError** e)
+{
+ IndentCPlugin* plugin = ANJUTA_PLUGIN_INDENT_C (ipref);
+ anjuta_preferences_remove_page(prefs, _("Indentation C Style"));
+ g_object_unref (plugin->bxml);
+}
+
+static void
+ipreferences_iface_init (IAnjutaPreferencesIface* iface)
+{
+ iface->merge = ipreferences_merge;
+ iface->unmerge = ipreferences_unmerge;
+}
+
+static void
+iindenter_indent (IAnjutaIndenter* indenter,
+ IAnjutaIterable* start,
+ IAnjutaIterable* end,
+ GError** e)
+{
+ IndentCPlugin* plugin = ANJUTA_PLUGIN_INDENT_C (indenter);
+
+ cpp_auto_indentation (IANJUTA_EDITOR (plugin->current_editor),
+ plugin,
+ start, end);
+}
+
+static void
+iindenter_iface_init (IAnjutaIndenterIface* iface)
+{
+ iface->indent = iindenter_indent;
+}
+
+ANJUTA_PLUGIN_BEGIN (IndentCPlugin, indent_c_plugin);
+ANJUTA_PLUGIN_ADD_INTERFACE(ipreferences, IANJUTA_TYPE_PREFERENCES);
+ANJUTA_PLUGIN_ADD_INTERFACE(iindenter, IANJUTA_TYPE_INDENTER);
+ANJUTA_PLUGIN_END;
+
+ANJUTA_SIMPLE_PLUGIN (IndentCPlugin, indent_c_plugin);
diff --git a/plugins/indentation-c-style/plugin.h b/plugins/indentation-c-style/plugin.h
new file mode 100644
index 0000000..7fff92f
--- /dev/null
+++ b/plugins/indentation-c-style/plugin.h
@@ -0,0 +1,69 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ plugin.h
+ Copyright (C) 2000 Naba Kumar
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef _PLUGIN_H_
+#define _PLUGIN_H_
+
+#include <libanjuta/anjuta-plugin.h>
+#include <libanjuta/interfaces/ianjuta-editor.h>
+#include <libanjuta/interfaces/ianjuta-symbol-manager.h>
+
+extern GType indent_c_plugin_get_type (GTypeModule *module);
+#define ANJUTA_TYPE_PLUGIN_INDENT_C (indent_c_plugin_get_type (NULL))
+#define ANJUTA_PLUGIN_INDENT_C(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ANJUTA_TYPE_PLUGIN_INDENT_C, IndentCPlugin))
+#define ANJUTA_PLUGIN_INDENT_C_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), ANJUTA_TYPE_PLUGIN_INDENT_C, IndentCPluginClass))
+#define ANJUTA_IS_PLUGIN_INDENT_C(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ANJUTA_TYPE_PLUGIN_INDENT_C))
+#define ANJUTA_IS_PLUGIN_INDENT_C_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ANJUTA_TYPE_PLUGIN_INDENT_C))
+#define ANJUTA_PLUGIN_INDENT_C_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ANJUTA_TYPE_PLUGIN_INDENT_C, IndentCPluginClass))
+
+typedef struct _IndentCPlugin IndentCPlugin;
+typedef struct _IndentCPluginClass IndentCPluginClass;
+
+struct _IndentCPlugin {
+ AnjutaPlugin parent;
+
+ GtkActionGroup *action_group;
+ gint uiid;
+
+ GSettings* settings;
+ GSettings* editor_settings;
+ gint editor_watch_id;
+ GObject *current_editor;
+ gboolean support_installed;
+ const gchar *current_language;
+
+ /* Adaptive indentation parameters */
+ gint param_tab_size;
+ gint param_use_spaces;
+ gint param_statement_indentation;
+ gint param_brace_indentation;
+ gint param_case_indentation;
+ gint param_label_indentation;
+ gboolean smart_indentation;
+
+ /* Preferences */
+ GtkBuilder* bxml;
+};
+
+struct _IndentCPluginClass {
+ AnjutaPluginClass parent_class;
+};
+
+#endif
diff --git a/plugins/indentation-python-style/Makefile.am b/plugins/indentation-python-style/Makefile.am
new file mode 100644
index 0000000..7e8b10c
--- /dev/null
+++ b/plugins/indentation-python-style/Makefile.am
@@ -0,0 +1,59 @@
+# Plugin UI files
+indent_python_uidir = $(anjuta_ui_dir)
+indent_python_ui_DATA = anjuta-indentation-python-style.xml
+
+# Plugin Glade file
+indent_python_gladedir = $(anjuta_glade_dir)
+indent_python_glade_DATA = anjuta-indentation-python-style.ui
+
+# Plugin Icon file
+indent_python_pixmapsdir = $(anjuta_image_dir)
+indent_python_pixmaps_DATA = anjuta-indentation-python-style-plugin.png
+
+# Plugin description file
+plugin_in_files = anjuta-indentation-python-style.plugin.in
+%.plugin: %.plugin.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+indent_python_plugindir = $(anjuta_plugin_dir)
+indent_python_plugin_DATA = $(plugin_in_files:.plugin.in=.plugin)
+
+AM_CPPFLAGS = \
+ $(XML_CFLAGS) \
+ $(LIBANJUTA_CFLAGS) \
+ -DG_LOG_DOMAIN=\"indentation-python-style\"
+
+# Where to install the plugin
+plugindir = $(anjuta_plugin_dir)
+
+# The plugin
+plugin_LTLIBRARIES = libanjuta-indentation-python-style.la
+
+# Plugin sources
+libanjuta_indentation_python_style_la_SOURCES = \
+ plugin.c \
+ plugin.h \
+ python-indentation.c \
+ python-indentation.h
+
+libanjuta_indentation_python_style_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
+
+# Plugin dependencies
+libanjuta_indentation_python_style_la_LIBADD = $(LIBANJUTA_LIBS)
+
+gsettings_in_file = org.gnome.anjuta.plugins.indent-python.gschema.xml.in
+gsettings_SCHEMAS = $(gsettings_in_file:.xml.in=.xml)
+ INTLTOOL_XML_NOMERGE_RULE@
+ GSETTINGS_RULES@
+
+EXTRA_DIST = \
+ $(plugin_in_files) \
+ $(indent_python_plugin_DATA) \
+ $(indent_python_ui_DATA) \
+ $(indent_python_glade_DATA) \
+ $(indent_python_pixmaps_DATA) \
+ $(gsettings_in_file)
+
+CLEANFILES = \
+ $(gsettings_SCHEMAS)
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/language-support-python/python_plugin.png b/plugins/indentation-python-style/anjuta-indentation-python-style-plugin.png
similarity index 100%
copy from plugins/language-support-python/python_plugin.png
copy to plugins/indentation-python-style/anjuta-indentation-python-style-plugin.png
diff --git a/plugins/indentation-python-style/anjuta-indentation-python-style.plugin b/plugins/indentation-python-style/anjuta-indentation-python-style.plugin
new file mode 100644
index 0000000..a888d02
--- /dev/null
+++ b/plugins/indentation-python-style/anjuta-indentation-python-style.plugin
@@ -0,0 +1,11 @@
+[Anjuta Plugin]
+Location=anjuta-indentation-python-style:IndentPythonPlugin
+Icon=anjuta-indentation-python-style-plugin.png
+Name=Python style indentation Plugin
+Description=auto-indentation for python style code
+Interfaces=IAnjutaLanguageSupport,IAnjutaIndenter
+UserActivatable=no
+
+[Language Support]
+Languages=Python
+MimeTypes=text/x-python,application/x-extension-wsgi
diff --git a/plugins/indentation-python-style/anjuta-indentation-python-style.plugin.in b/plugins/indentation-python-style/anjuta-indentation-python-style.plugin.in
new file mode 100755
index 0000000..5cf3304
--- /dev/null
+++ b/plugins/indentation-python-style/anjuta-indentation-python-style.plugin.in
@@ -0,0 +1,11 @@
+[Anjuta Plugin]
+Location=anjuta-indentation-python-style:IndentPythonPlugin
+Icon=anjuta-indentation-python-style-plugin.png
+_Name=Python style indentation Plugin
+_Description=auto-indentation for python style code
+Interfaces=IAnjutaLanguageSupport,IAnjutaIndenter
+UserActivatable=no
+
+[Language Support]
+Languages=Python
+MimeTypes=text/x-python,application/x-extension-wsgi
diff --git a/plugins/indentation-python-style/anjuta-indentation-python-style.ui b/plugins/indentation-python-style/anjuta-indentation-python-style.ui
new file mode 100755
index 0000000..e1d39fc
--- /dev/null
+++ b/plugins/indentation-python-style/anjuta-indentation-python-style.ui
@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment2">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkWindow" id="python_preferences_dialog">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">window1</property>
+ <child>
+ <object class="GtkVBox" id="preferences">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkCheckButton" id="preferences:indent-automatic">
+ <property name="label" translatable="yes">Enable smart indentation</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="margin_left">10</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="preferences:indent-adaptive">
+ <property name="label" translatable="yes">Enable adaptive indentation</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="margin_left">10</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame48">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table18">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">5</property>
+ <property name="row_spacing">5</property>
+ <child>
+ <object class="GtkSpinButton" id="preferences:indent-brace-size">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">adjustment2</property>
+ <property name="climb_rate">1</property>
+ <property name="numeric">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="preferences:.editor.indent-width">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">adjustment1</property>
+ <property name="climb_rate">1</property>
+ <property name="numeric">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label12353">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Brace indentation size in spaces:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label123">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Statement indentation size in spaces:</property>
+ </object>
+ <packing>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label12355">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Indentation parameters</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/plugins/language-support-python/python-plugin.xml b/plugins/indentation-python-style/anjuta-indentation-python-style.xml
similarity index 71%
copy from plugins/language-support-python/python-plugin.xml
copy to plugins/indentation-python-style/anjuta-indentation-python-style.xml
index 248c9d4..43f6e00 100644
--- a/plugins/language-support-python/python-plugin.xml
+++ b/plugins/indentation-python-style/anjuta-indentation-python-style.xml
@@ -3,8 +3,6 @@
<menubar name="MenuMain">
<menu name="MenuEdit" action="ActionMenuEdit">
<placeholder name="PlaceholderOperationMenus">
- <separator name="separator1"/>
- <menuitem name="Autocomplete" action="ActionEditAutocomplete" />
<menuitem name="AutoindentAction" action="ActionEditAutoindent" />
</placeholder>
</menu>
diff --git a/plugins/indentation-python-style/org.gnome.anjuta.plugins.indent-python.gschema.xml.in b/plugins/indentation-python-style/org.gnome.anjuta.plugins.indent-python.gschema.xml.in
new file mode 100644
index 0000000..96f2186
--- /dev/null
+++ b/plugins/indentation-python-style/org.gnome.anjuta.plugins.indent-python.gschema.xml.in
@@ -0,0 +1,13 @@
+<schemalist>
+ <schema id="org.gnome.anjuta.plugins.indent-python" path="/org/gnome/anjuta/plugins/indent-python/">
+ <key name="indent-automatic" type="b">
+ <default>true</default>
+ </key>
+ <key name="indent-adaptive" type="b">
+ <default>true</default>
+ </key>
+ <key name="indent-brace-size" type="i">
+ <default>0</default>
+ </key>
+ </schema>
+</schemalist>
diff --git a/plugins/indentation-python-style/plugin.c b/plugins/indentation-python-style/plugin.c
new file mode 100644
index 0000000..9a336c9
--- /dev/null
+++ b/plugins/indentation-python-style/plugin.c
@@ -0,0 +1,371 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * plugin.c
+ * Copyright (C) Ishan Chattopadhyaya 2009 <ichattopadhyaya gmail com>
+ *
+ * plugin.c is free software.
+ *
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * plugin.c 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 plugin.c. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <libanjuta/anjuta-shell.h>
+#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/interfaces/ianjuta-iterable.h>
+#include <libanjuta/interfaces/ianjuta-document.h>
+#include <libanjuta/interfaces/ianjuta-document-manager.h>
+#include <libanjuta/interfaces/ianjuta-editor.h>
+#include <libanjuta/interfaces/ianjuta-file.h>
+#include <libanjuta/interfaces/ianjuta-editor-cell.h>
+#include <libanjuta/interfaces/ianjuta-editor-language.h>
+#include <libanjuta/interfaces/ianjuta-editor-selection.h>
+#include <libanjuta/interfaces/ianjuta-preferences.h>
+#include <libanjuta/interfaces/ianjuta-language.h>
+#include <libanjuta/interfaces/ianjuta-indenter.h>
+
+#include "plugin.h"
+#include "python-indentation.h"
+
+/* Pixmaps */
+#define ANJUTA_STOCK_AUTOINDENT "anjuta-indent"
+
+#define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-indentation-python-style.xml"
+#define PROPERTIES_FILE_UI PACKAGE_DATA_DIR"/glade/anjuta-indentation-python-style.ui"
+#define ICON_FILE "anjuta-indentation-python-style-plugin.png"
+
+/* Preferences keys */
+#define ANJUTA_PREF_SCHEMA_PREFIX "org.gnome.anjuta."
+#define PREF_SCHEMA "org.gnome.anjuta.plugins.indent-python"
+
+static gpointer parent_class;
+
+static void
+on_editor_char_inserted_python (IAnjutaEditor *editor,
+ IAnjutaIterable *insert_pos,
+ gchar ch,
+ IndentPythonPlugin *plugin)
+{
+ python_indent (plugin, editor, insert_pos, ch);
+}
+
+static void
+install_support (IndentPythonPlugin *lang_plugin)
+{
+ IAnjutaLanguage* lang_manager =
+ anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell,
+ IAnjutaLanguage, NULL);
+
+ if (!lang_manager)
+ return;
+
+ if (lang_plugin->support_installed)
+ return;
+
+ lang_plugin->current_language =
+ ianjuta_language_get_name_from_editor (lang_manager,
+ IANJUTA_EDITOR_LANGUAGE (lang_plugin->current_editor), NULL);
+
+ if (lang_plugin->current_language &&
+ (g_str_equal (lang_plugin->current_language, "Python")))
+ {
+ g_signal_connect (lang_plugin->current_editor,
+ "char-added",
+ G_CALLBACK (on_editor_char_inserted_python),
+ lang_plugin);
+ }
+ else
+ {
+ return;
+ }
+
+ python_indent_init (lang_plugin);
+ /* Disable editor intern auto-indent */
+ ianjuta_editor_set_auto_indent (IANJUTA_EDITOR(lang_plugin->current_editor),
+ FALSE, NULL);
+
+ lang_plugin->support_installed = TRUE;
+}
+
+static void
+uninstall_support (IndentPythonPlugin *lang_plugin)
+{
+ if (!lang_plugin->support_installed)
+ return;
+
+ if (lang_plugin->current_language &&
+ (g_str_equal (lang_plugin->current_language, "Python")))
+ {
+ g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
+ G_CALLBACK (on_editor_char_inserted_python),
+ lang_plugin);
+ }
+
+ lang_plugin->support_installed = FALSE;
+}
+
+static void
+on_editor_language_changed (IAnjutaEditor *editor,
+ const gchar *new_language,
+ IndentPythonPlugin *plugin)
+{
+ uninstall_support (plugin);
+ install_support (plugin);
+}
+
+static void
+on_editor_added (AnjutaPlugin *plugin, const gchar *name,
+ const GValue *value, gpointer data)
+{
+ IndentPythonPlugin *lang_plugin;
+ IAnjutaDocument* doc = IANJUTA_DOCUMENT(g_value_get_object (value));
+ lang_plugin = ANJUTA_PLUGIN_INDENT_PYTHON(plugin);
+
+
+ if (IANJUTA_IS_EDITOR(doc))
+ {
+ lang_plugin->current_editor = G_OBJECT(doc);
+ }
+ else
+ {
+ lang_plugin->current_editor = NULL;
+ return;
+ }
+ if (lang_plugin->current_editor)
+ {
+ IAnjutaEditor* editor = IANJUTA_EDITOR (lang_plugin->current_editor);
+ GFile* current_editor_file = ianjuta_file_get_file (IANJUTA_FILE (editor),
+ NULL);
+
+ if (current_editor_file)
+ {
+ lang_plugin->current_editor_filename = g_file_get_path (current_editor_file);
+ g_object_unref (current_editor_file);
+ }
+
+ install_support (lang_plugin);
+ g_signal_connect (lang_plugin->current_editor, "language-changed",
+ G_CALLBACK (on_editor_language_changed),
+ plugin);
+ }
+}
+
+static void
+on_editor_removed (AnjutaPlugin *plugin, const gchar *name,
+ gpointer data)
+{
+ IndentPythonPlugin *lang_plugin;
+ lang_plugin = ANJUTA_PLUGIN_INDENT_PYTHON (plugin);
+
+ if (lang_plugin->current_editor)
+ g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
+ G_CALLBACK (on_editor_language_changed),
+ plugin);
+
+ uninstall_support (lang_plugin);
+
+
+ g_free (lang_plugin->current_editor_filename);
+ lang_plugin->current_editor_filename = NULL;
+ lang_plugin->current_editor = NULL;
+ lang_plugin->current_language = NULL;
+}
+
+static void
+on_auto_indent (GtkAction *action, gpointer data)
+{
+ IndentPythonPlugin *lang_plugin = ANJUTA_PLUGIN_INDENT_PYTHON (data);
+
+ python_indent_auto (lang_plugin, NULL, NULL);
+}
+
+static GtkActionEntry actions[] = {
+ {
+ "ActionMenuEdit",
+ NULL, N_("_Edit"),
+ NULL, NULL, NULL
+ },
+ {
+ "ActionEditAutoindent",
+ GTK_STOCK_NEW, //ANJUTA_STOCK_AUTOINDENT,
+ N_("Auto-Indent"), "<control>i",
+ N_("Auto-indent current line or selection based on indentation settings"),
+ G_CALLBACK (on_auto_indent)
+ }
+};
+
+static gboolean
+indent_python_plugin_activate (AnjutaPlugin *plugin)
+{
+ AnjutaUI *ui;
+
+ IndentPythonPlugin *python_plugin;
+ python_plugin = (IndentPythonPlugin*) plugin;
+
+ python_plugin->prefs = anjuta_shell_get_preferences (plugin->shell, NULL);
+
+ /* Add all UI actions and merge UI */
+ ui = anjuta_shell_get_ui (plugin->shell, NULL);
+
+ python_plugin->action_group =
+ anjuta_ui_add_action_group_entries (ui, "ActionGroupPythonAssist",
+ _("Python Assistance"),
+ actions,
+ G_N_ELEMENTS (actions),
+ GETTEXT_PACKAGE, TRUE,
+ plugin);
+ python_plugin->uiid = anjuta_ui_merge (ui, UI_FILE);
+
+ /* Add watches */
+ python_plugin->editor_watch_id = anjuta_plugin_add_watch (plugin,
+ IANJUTA_DOCUMENT_MANAGER_CURRENT_DOCUMENT,
+ on_editor_added,
+ on_editor_removed,
+ NULL);
+ return TRUE;
+}
+
+static gboolean
+indent_python_plugin_deactivate (AnjutaPlugin *plugin)
+{
+
+ AnjutaUI *ui;
+ IndentPythonPlugin *lang_plugin;
+ lang_plugin = (IndentPythonPlugin*) (plugin);
+
+ anjuta_plugin_remove_watch (plugin,
+ lang_plugin->editor_watch_id,
+ TRUE);
+
+ ui = anjuta_shell_get_ui (plugin->shell, NULL);
+ anjuta_ui_remove_action_group (ui, ANJUTA_PLUGIN_INDENT_PYTHON(plugin)->action_group);
+ anjuta_ui_unmerge (ui, ANJUTA_PLUGIN_INDENT_PYTHON(plugin)->uiid);
+
+ return TRUE;
+}
+
+static void
+indent_python_plugin_finalize (GObject *obj)
+{
+ /* Finalization codes here */
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+static void
+indent_python_plugin_dispose (GObject *obj)
+{
+ /* Disposition codes */
+ IndentPythonPlugin *plugin = (IndentPythonPlugin*)obj;
+
+ if (plugin->settings)
+ g_object_unref (plugin->settings);
+ plugin->settings = NULL;
+ if (plugin->editor_settings)
+ g_object_unref (plugin->editor_settings);
+ plugin->editor_settings = NULL;
+
+ G_OBJECT_CLASS (parent_class)->dispose (obj);
+}
+
+static void
+indent_python_plugin_instance_init (GObject *obj)
+{
+ IndentPythonPlugin *plugin = (IndentPythonPlugin*)obj;
+ plugin->action_group = NULL;
+ plugin->current_editor = NULL;
+ plugin->current_language = NULL;
+ plugin->editor_watch_id = 0;
+ plugin->uiid = 0;
+ plugin->settings = g_settings_new (PREF_SCHEMA);
+ plugin->editor_settings = g_settings_new (ANJUTA_PREF_SCHEMA_PREFIX IANJUTA_EDITOR_PREF_SCHEMA);
+}
+
+static void
+indent_python_plugin_class_init (GObjectClass *klass)
+{
+ AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ plugin_class->activate = indent_python_plugin_activate;
+ plugin_class->deactivate = indent_python_plugin_deactivate;
+ klass->finalize = indent_python_plugin_finalize;
+ klass->dispose = indent_python_plugin_dispose;
+}
+
+
+static void
+ipreferences_merge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
+ GError** e)
+{
+ GError* error = NULL;
+ IndentPythonPlugin* plugin = ANJUTA_PLUGIN_INDENT_PYTHON (ipref);
+ plugin->bxml = gtk_builder_new ();
+
+ /* Add preferences */
+ if (!gtk_builder_add_from_file (plugin->bxml, PROPERTIES_FILE_UI, &error))
+ {
+ g_warning ("Couldn't load builder file: %s", error->message);
+ g_error_free (error);
+ }
+ anjuta_preferences_add_from_builder (prefs,
+ plugin->bxml, plugin->settings,
+ "preferences", _("Indentation Python Style"),
+ ICON_FILE);
+}
+
+static void
+ipreferences_unmerge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
+ GError** e)
+{
+ IndentPythonPlugin* plugin = ANJUTA_PLUGIN_INDENT_PYTHON (ipref);
+ anjuta_preferences_remove_page(prefs, _("Indentation Python Style"));
+ g_object_unref (plugin->bxml);
+}
+
+static void
+ipreferences_iface_init (IAnjutaPreferencesIface* iface)
+{
+ iface->merge = ipreferences_merge;
+ iface->unmerge = ipreferences_unmerge;
+}
+
+static void
+iindenter_indent (IAnjutaIndenter* indenter,
+ IAnjutaIterable* start,
+ IAnjutaIterable* end,
+ GError** e)
+{
+ IndentPythonPlugin* plugin = ANJUTA_PLUGIN_INDENT_PYTHON (indenter);
+
+ python_indent_auto (plugin,
+ start, end);
+}
+
+static void
+iindenter_iface_init (IAnjutaIndenterIface* iface)
+{
+ iface->indent = iindenter_indent;
+}
+
+ANJUTA_PLUGIN_BEGIN (IndentPythonPlugin, indent_python_plugin);
+ANJUTA_PLUGIN_ADD_INTERFACE(ipreferences, IANJUTA_TYPE_PREFERENCES);
+ANJUTA_PLUGIN_ADD_INTERFACE(iindenter, IANJUTA_TYPE_INDENTER);
+ANJUTA_PLUGIN_END;
+
+ANJUTA_SIMPLE_PLUGIN (IndentPythonPlugin, indent_python_plugin);
diff --git a/plugins/indentation-python-style/plugin.h b/plugins/indentation-python-style/plugin.h
new file mode 100644
index 0000000..cdbb7e7
--- /dev/null
+++ b/plugins/indentation-python-style/plugin.h
@@ -0,0 +1,79 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * plugin.h
+ * Copyright (C) Ishan Chattopadhyaya 2009 <ichattopadhyaya gmail com>
+ *
+ * plugin.h is free software.
+ *
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * plugin.h 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 plugin.h. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _PYTHON_PLUGIN_H_
+#define _PYTHON_PLUGIN_H_
+
+#include <libanjuta/anjuta-plugin.h>
+#include <libanjuta/interfaces/ianjuta-editor.h>
+#include <libanjuta/interfaces/ianjuta-symbol-manager.h>
+
+extern GType indent_python_plugin_get_type (GTypeModule *module);
+#define ANJUTA_TYPE_PLUGIN_INDENT_PYTHON (indent_python_plugin_get_type (NULL))
+#define ANJUTA_PLUGIN_INDENT_PYTHON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ANJUTA_TYPE_PLUGIN_INDENT_PYTHON, IndentPythonPlugin))
+#define ANJUTA_PLUGIN_INDENT_PYTHON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), ANJUTA_TYPE_PLUGIN_INDENT_PYTHON, IndentPythonPluginClass))
+#define ANJUTA_IS_PLUGIN_INDENT_PYTHON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ANJUTA_TYPE_PLUGIN_INDENT_PYTHON))
+#define ANJUTA_IS_PLUGIN_INDENT_PYTHON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ANJUTA_TYPE_PLUGIN_INDENT_PYTHON))
+#define ANJUTA_PLUGIN_INDENT_PYTHON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ANJUTA_TYPE_PLUGIN_INDENT_PYTHON, IndentPythonPluginClass))
+
+
+typedef struct _IndentPythonPlugin IndentPythonPlugin;
+typedef struct _IndentPythonPluginClass IndentPythonPluginClass;
+
+struct _IndentPythonPlugin{
+ AnjutaPlugin parent;
+ gint uiid;
+ GtkActionGroup *action_group;
+
+ AnjutaPreferences *prefs;
+ GObject *current_editor;
+ gboolean support_installed;
+ const gchar *current_language;
+
+ gchar *project_root_directory;
+ gchar *current_editor_filename;
+ gchar *current_fm_filename;
+
+ /* Watches */
+ gint editor_watch_id;
+
+ /* Adaptive indentation parameters */
+ gint param_tab_size;
+ gint param_use_spaces;
+ gint param_statement_indentation;
+ gint param_brace_indentation;
+ gint param_case_indentation;
+ gint param_label_indentation;
+
+ /* Preferences */
+ GtkBuilder* bxml;
+ GSettings* settings;
+ GSettings* editor_settings;
+};
+
+struct _IndentPythonPluginClass{
+ AnjutaPluginClass parent_class;
+};
+
+#endif
diff --git a/plugins/language-support-python/python-indentation.c b/plugins/indentation-python-style/python-indentation.c
similarity index 97%
rename from plugins/language-support-python/python-indentation.c
rename to plugins/indentation-python-style/python-indentation.c
index 3924278..227d05f 100644
--- a/plugins/language-support-python/python-indentation.c
+++ b/plugins/indentation-python-style/python-indentation.c
@@ -195,7 +195,7 @@ get_line_indentation_string (IAnjutaEditor *editor, gint spaces, gint line_inden
}
static void
-set_indentation_param_emacs (PythonPlugin* plugin, const gchar *param,
+set_indentation_param_emacs (IndentPythonPlugin* plugin, const gchar *param,
const gchar *value)
{
//DEBUG_PRINT ("Setting indent param: %s = %s", param, value);
@@ -227,7 +227,7 @@ set_indentation_param_emacs (PythonPlugin* plugin, const gchar *param,
}
static void
-set_indentation_param_vim (PythonPlugin* plugin, const gchar *param,
+set_indentation_param_vim (IndentPythonPlugin* plugin, const gchar *param,
const gchar *value)
{
//DEBUG_PRINT ("Setting indent param: %s = %s", param, value);
@@ -264,7 +264,7 @@ set_indentation_param_vim (PythonPlugin* plugin, const gchar *param,
}
static void
-parse_mode_line_emacs (PythonPlugin *plugin, const gchar *modeline)
+parse_mode_line_emacs (IndentPythonPlugin *plugin, const gchar *modeline)
{
gchar **strv, **ptr;
@@ -288,7 +288,7 @@ parse_mode_line_emacs (PythonPlugin *plugin, const gchar *modeline)
}
static void
-parse_mode_line_vim (PythonPlugin *plugin, const gchar *modeline)
+parse_mode_line_vim (IndentPythonPlugin *plugin, const gchar *modeline)
{
gchar **strv, **ptr;
@@ -360,7 +360,7 @@ extract_mode_line (const gchar *comment_text, gboolean* vim)
#define MINI_BUFFER_SIZE 3
void
-python_indent_init (PythonPlugin* plugin)
+python_indent_init (IndentPythonPlugin* plugin)
{
IAnjutaIterable *iter;
GString *comment_text;
@@ -460,7 +460,7 @@ set_line_indentation (IAnjutaEditor *editor, gint line_num, gint indentation, gi
{
IAnjutaIterable *line_begin, *line_end, *indent_position;
IAnjutaIterable *current_pos;
- gint carat_offset, nchars = 0, nchars_removed = 0;
+ gint carat_offset, nchars = 0;
gchar *old_indent_string = NULL, *indent_string = NULL;
/* DEBUG_PRINT ("In %s()", __FUNCTION__); */
@@ -518,7 +518,6 @@ set_line_indentation (IAnjutaEditor *editor, gint line_num, gint indentation, gi
indent_position, NULL);
//DEBUG_PRINT ("old_indent_string = '%s'", old_indent_string);
- nchars_removed = g_utf8_strlen (old_indent_string, -1);
}
/* Only indent if there was no indentation before or old
@@ -550,7 +549,6 @@ set_line_indentation (IAnjutaEditor *editor, gint line_num, gint indentation, gi
old_indent_string =
ianjuta_editor_get_text (editor, line_begin,
indent_position, NULL);
- nchars_removed = g_utf8_strlen (old_indent_string, -1);
}
if (old_indent_string)
ianjuta_editor_erase (editor, line_begin, indent_position, NULL);
@@ -677,7 +675,7 @@ is_spaces_only (IAnjutaEditor *editor, gint line_num)
}
static gint
-get_line_indentation_base (PythonPlugin *plugin,
+get_line_indentation_base (IndentPythonPlugin *plugin,
IAnjutaEditor *editor,
gint line_num,
gint *incomplete_statement,
@@ -761,7 +759,7 @@ spaces_only (IAnjutaEditor* editor, IAnjutaIterable* begin, IAnjutaIterable* end
}
static gint
-get_line_auto_indentation (PythonPlugin *plugin, IAnjutaEditor *editor,
+get_line_auto_indentation (IndentPythonPlugin *plugin, IAnjutaEditor *editor,
gint line, gint *line_indent_spaces)
{
IAnjutaIterable *iter;
@@ -831,7 +829,7 @@ get_line_auto_indentation (PythonPlugin *plugin, IAnjutaEditor *editor,
}
void
-python_indent (PythonPlugin *plugin,
+python_indent (IndentPythonPlugin *plugin,
IAnjutaEditor *editor,
IAnjutaIterable *insert_pos,
gchar ch)
@@ -872,7 +870,7 @@ python_indent (PythonPlugin *plugin,
}
void
-python_indent_auto (PythonPlugin* lang_plugin,
+python_indent_auto (IndentPythonPlugin* lang_plugin,
IAnjutaIterable* start,
IAnjutaIterable* end)
{
diff --git a/plugins/language-support-python/python-indentation.h b/plugins/indentation-python-style/python-indentation.h
similarity index 86%
rename from plugins/language-support-python/python-indentation.h
rename to plugins/indentation-python-style/python-indentation.h
index 899eff5..a794bbc 100644
--- a/plugins/language-support-python/python-indentation.h
+++ b/plugins/indentation-python-style/python-indentation.h
@@ -25,14 +25,14 @@
#include <libanjuta/interfaces/ianjuta-iterable.h>
#include <libanjuta/interfaces/ianjuta-editor.h>
-void python_indent_init (PythonPlugin* lang_plugin);
+void python_indent_init (IndentPythonPlugin* lang_plugin);
-void python_indent (PythonPlugin* lang_plugin,
+void python_indent (IndentPythonPlugin* lang_plugin,
IAnjutaEditor* editor,
IAnjutaIterable* insert_pos,
gchar ch);
-void python_indent_auto (PythonPlugin* lang_plugin,
+void python_indent_auto (IndentPythonPlugin* lang_plugin,
IAnjutaIterable* start,
IAnjutaIterable* end);
diff --git a/plugins/language-support-cpp-java/Makefile.am b/plugins/language-support-cpp-java/Makefile.am
index 05837bd..1586d19 100644
--- a/plugins/language-support-cpp-java/Makefile.am
+++ b/plugins/language-support-cpp-java/Makefile.am
@@ -50,10 +50,6 @@ libanjuta_language_cpp_java_la_SOURCES = \
plugin.h \
cpp-java-assist.h \
cpp-java-assist.c \
- cpp-java-utils.c \
- cpp-java-utils.h \
- cpp-java-indentation.c \
- cpp-java-indentation.h \
cpp-packages.c \
cpp-packages.h
diff --git a/plugins/language-support-cpp-java/anjuta-language-cpp-java.ui b/plugins/language-support-cpp-java/anjuta-language-cpp-java.ui
index fbb44a6..e760e3c 100644
--- a/plugins/language-support-cpp-java/anjuta-language-cpp-java.ui
+++ b/plugins/language-support-cpp-java/anjuta-language-cpp-java.ui
@@ -33,316 +33,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
- <object class="GtkFrame" id="page2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkVBox" id="vbox1111">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">5</property>
- <child>
- <object class="GtkTable" id="table15">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">10</property>
- <property name="n_rows">3</property>
- <property name="column_spacing">5</property>
- <property name="row_spacing">5</property>
- <child>
- <object class="GtkCheckButton" id="preferences:indent-automatic">
- <property name="label" translatable="yes">Enable smart indentation</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="preferences:multiline-leading-asterisk">
- <property name="label" translatable="yes">Leading asterisk in multi-line comment</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="preferences:indent-modeline">
- <property name="label" translatable="yes">Prefer vim/emacs modelines over indentation settings</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkFrame" id="frame48">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkAlignment" id="alignment5">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkVBox" id="vbox2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkTable" id="table18">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">5</property>
- <property name="row_spacing">5</property>
- <child>
- <object class="GtkSpinButton" id="preferences:indent-brace-size">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">â</property>
- <property name="adjustment">adjustment1</property>
- <property name="climb_rate">1</property>
- <property name="numeric">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options"></property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="preferences:.editor.indent-width">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">â</property>
- <property name="adjustment">adjustment2</property>
- <property name="climb_rate">1</property>
- <property name="numeric">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="x_options"></property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label12353">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Brace indentation size in spaces:</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label123">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Statement indentation size in spaces:</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label12355">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Indentation parameters</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkFrame" id="frame2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkAlignment" id="alignment2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="top_padding">6</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkTable" id="table1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">5</property>
- <property name="row_spacing">5</property>
- <child>
- <object class="GtkRadioButton" id="preferences:indent-paranthese-lineup">
- <property name="label" translatable="yes">Line up parentheses</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">preferences:indent-paranthese-indent</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkRadioButton" id="preferences:indent-paranthese-indent">
- <property name="label" translatable="yes">Indent:</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="preferences:indent-paranthese-size">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">â</property>
- <property name="adjustment">adjustment4</property>
- <property name="climb_rate">1</property>
- <property name="numeric">True</property>
- <signal name="value-changed" handler="on_spinbutton1_value_changed" swapped="no"/>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Parenthesis indentation</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label12321">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Smart Indentation</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- </object>
- </child>
- <child type="tab">
- <object class="GtkLabel" id="label12351">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Smart Indentation</property>
- </object>
- <packing>
- <property name="tab_fill">False</property>
- </packing>
- </child>
- <child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -455,23 +145,6 @@
<property name="position">1</property>
</packing>
</child>
- <child>
- <object class="GtkCheckButton" id="preferences:brace-autocompletion">
- <property name="label" translatable="yes">Enable smart brace completion</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="border_width">5</property>
- <property name="use_action_appearance">False</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
</object>
</child>
<child type="label">
@@ -552,9 +225,6 @@
</packing>
</child>
</object>
- <packing>
- <property name="position">1</property>
- </packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label4">
@@ -656,7 +326,7 @@
<property name="label" translatable="yes">API Tags (C/C++)</property>
</object>
<packing>
- <property name="position">2</property>
+ <property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
diff --git a/plugins/language-support-cpp-java/anjuta-language-support-cpp-java.xml b/plugins/language-support-cpp-java/anjuta-language-support-cpp-java.xml
index bb77552..e3680ac 100644
--- a/plugins/language-support-cpp-java/anjuta-language-support-cpp-java.xml
+++ b/plugins/language-support-cpp-java/anjuta-language-support-cpp-java.xml
@@ -3,7 +3,6 @@
<menubar name="MenuMain">
<menu name="MenuEdit" action="ActionMenuEdit">
<placeholder name="PlaceholderOperationMenus">
- <menuitem name="AutoindentAction" action="ActionEditAutoindent" />
<menuitem name="ToggleCommentAction" action="ActionEditToggleComment" />
</placeholder>
</menu>
diff --git a/plugins/language-support-cpp-java/cpp-java-assist.c b/plugins/language-support-cpp-java/cpp-java-assist.c
index c548147..e5d8e8f 100644
--- a/plugins/language-support-cpp-java/cpp-java-assist.c
+++ b/plugins/language-support-cpp-java/cpp-java-assist.c
@@ -28,6 +28,7 @@
#include <ctype.h>
#include <string.h>
#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-utils.h>
#include <libanjuta/interfaces/ianjuta-file.h>
#include <libanjuta/interfaces/ianjuta-editor-cell.h>
#include <libanjuta/interfaces/ianjuta-editor-selection.h>
@@ -37,7 +38,6 @@
#include <libanjuta/interfaces/ianjuta-document.h>
#include <libanjuta/interfaces/ianjuta-symbol-manager.h>
#include "cpp-java-assist.h"
-#include "cpp-java-utils.h"
#define PREF_AUTOCOMPLETE_ENABLE "completion-enable"
#define PREF_AUTOCOMPLETE_SPACE_AFTER_FUNC "completion-space-after-func"
@@ -323,7 +323,7 @@ cpp_java_assist_is_expression_separator (gchar c, gboolean skip_braces, IAnjutaI
if (c == ')' && skip_braces)
{
- cpp_java_util_jump_to_matching_brace (iter, c, BRACE_SEARCH_LIMIT);
+ anjuta_util_jump_to_matching_brace (iter, c, BRACE_SEARCH_LIMIT);
return TRUE;
}
else if (c == ')' && !skip_braces)
@@ -871,7 +871,7 @@ cpp_java_assist_get_scope_context (IAnjutaEditor* editor,
}
else if (ch == ')')
{
- if (!cpp_java_util_jump_to_matching_brace (iter, ch, SCOPE_BRACE_JUMP_LIMIT))
+ if (!anjuta_util_jump_to_matching_brace (iter, ch, SCOPE_BRACE_JUMP_LIMIT))
{
out_of_range = TRUE;
break;
@@ -918,14 +918,14 @@ cpp_java_assist_get_calltip_context (CppJavaAssist *assist,
ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter), 0, NULL);
if (ch == ')')
{
- if (!cpp_java_util_jump_to_matching_brace (iter, ')', -1))
+ if (!anjuta_util_jump_to_matching_brace (iter, ')', -1))
return NULL;
if (!ianjuta_iterable_previous (iter, NULL))
return NULL;
}
if (ch != '(')
{
- if (!cpp_java_util_jump_to_matching_brace (iter, ')',
+ if (!anjuta_util_jump_to_matching_brace (iter, ')',
BRACE_SEARCH_LIMIT))
return NULL;
}
diff --git a/plugins/language-support-cpp-java/org.gnome.anjuta.plugins.cpp.gschema.xml.in b/plugins/language-support-cpp-java/org.gnome.anjuta.plugins.cpp.gschema.xml.in
index 1bed0f8..50cb1f9 100644
--- a/plugins/language-support-cpp-java/org.gnome.anjuta.plugins.cpp.gschema.xml.in
+++ b/plugins/language-support-cpp-java/org.gnome.anjuta.plugins.cpp.gschema.xml.in
@@ -3,27 +3,6 @@
<key name="user-packages" type="s">
<default>""</default>
</key>
- <key name="indent-automatic" type="b">
- <default>true</default>
- </key>
- <key name="multiline-leading-asterisk" type="b">
- <default>true</default>
- </key>
- <key name="indent-modeline" type="b">
- <default>true</default>
- </key>
- <key name="indent-brace-size" type="i">
- <default>0</default>
- </key>
- <key name="indent-paranthese-lineup" type="b">
- <default>true</default>
- </key>
- <key name="indent-paranthese-indent" type="b">
- <default>false</default>
- </key>
- <key name="indent-paranthese-size" type="i">
- <default>4</default>
- </key>
<key name="completion-enable" type="b">
<default>true</default>
</key>
@@ -36,9 +15,6 @@
<key name="completion-closebrace-after-func" type="b">
<default>true</default>
</key>
- <key name="brace-autocompletion" type="b">
- <default>false</default>
- </key>
<key name="calltip-enable" type="b">
<default>true</default>
</key>
diff --git a/plugins/language-support-cpp-java/plugin.c b/plugins/language-support-cpp-java/plugin.c
index 14f4701..f0ef8ca 100644
--- a/plugins/language-support-cpp-java/plugin.c
+++ b/plugins/language-support-cpp-java/plugin.c
@@ -41,11 +41,8 @@
#include <libanjuta/interfaces/ianjuta-symbol.h>
#include <libanjuta/interfaces/ianjuta-symbol-manager.h>
#include <libanjuta/interfaces/ianjuta-language.h>
-#include <libanjuta/interfaces/ianjuta-indenter.h>
#include "plugin.h"
-#include "cpp-java-utils.h"
-#include "cpp-java-indentation.h"
#include "cpp-packages.h"
@@ -53,7 +50,6 @@
#define ANJUTA_PIXMAP_SWAP "anjuta-swap"
#define ANJUTA_PIXMAP_AUTOINDENT "anjuta-indent-auto"
#define ANJUTA_STOCK_SWAP "anjuta-swap"
-#define ANJUTA_STOCK_COMPLETE "anjuta-complete"
#define ANJUTA_STOCK_AUTOINDENT "anjuta-indent"
#define ANJUTA_STOCK_COMMENT "anjuta-comment"
@@ -65,8 +61,6 @@
#define ANJUTA_PREF_SCHEMA_PREFIX "org.gnome.anjuta."
#define PREF_SCHEMA "org.gnome.anjuta.plugins.cpp"
-#define PREF_INDENT_AUTOMATIC "indent-automatic"
-#define PREF_INDENT_MODELINE "indent-modeline"
#define PREF_USER_PACKAGES "user-packages"
#define PREF_PROJECT_PACKAGES "load-project-packages"
@@ -81,307 +75,38 @@
static gpointer parent_class;
-static void
-set_indentation_param_emacs (CppJavaPlugin* plugin, const gchar *param,
- const gchar *value)
-{
- //DEBUG_PRINT ("Setting indent param: %s = %s", param, value);
- if (strcasecmp (param, "indent-tabs-mode") == 0)
- {
- if (strcasecmp (value, "t") == 0)
- {
- plugin->param_use_spaces = 0;
- ianjuta_editor_set_use_spaces (IANJUTA_EDITOR (plugin->current_editor),
- FALSE, NULL);
- }
- else if (strcasecmp (value, "nil") == 0)
- {
- plugin->param_use_spaces = 1;
- ianjuta_editor_set_use_spaces (IANJUTA_EDITOR (plugin->current_editor),
- TRUE, NULL);
- }
- }
- else if (strcasecmp (param, "c-basic-offset") == 0)
- {
- plugin->param_statement_indentation = atoi (value);
- }
- else if (strcasecmp (param, "tab-width") == 0)
- {
- plugin->param_tab_size = atoi (value);
- ianjuta_editor_set_tabsize (IANJUTA_EDITOR (plugin->current_editor),
- plugin->param_tab_size, NULL);
- }
-}
-
-static void
-set_indentation_param_vim (CppJavaPlugin* plugin, const gchar *param,
- const gchar *value)
-{
- //DEBUG_PRINT ("Setting indent param: %s = %s", param, value);
- if (g_str_equal (param, "expandtab") ||
- g_str_equal (param, "et"))
- {
- plugin->param_use_spaces = 1;
- ianjuta_editor_set_use_spaces (IANJUTA_EDITOR (plugin->current_editor),
- TRUE, NULL);
- }
- else if (g_str_equal (param, "noexpandtab") ||
- g_str_equal (param, "noet"))
- {
- plugin->param_use_spaces = 0;
- ianjuta_editor_set_use_spaces (IANJUTA_EDITOR (plugin->current_editor),
- FALSE, NULL);
- }
- if (!value)
- return;
- else if (g_str_equal (param, "shiftwidth") ||
- g_str_equal (param, "sw"))
- {
- plugin->param_statement_indentation = atoi (value);
- }
- else if (g_str_equal (param, "softtabstop") ||
- g_str_equal (param, "sts") ||
- g_str_equal (param, "tabstop") ||
- g_str_equal (param, "ts"))
- {
- plugin->param_tab_size = atoi (value);
- ianjuta_editor_set_tabsize (IANJUTA_EDITOR (plugin->current_editor),
- plugin->param_tab_size, NULL);
- }
-}
-
-static void
-parse_mode_line_emacs (CppJavaPlugin *plugin, const gchar *modeline)
-{
- gchar **strv, **ptr;
-
- strv = g_strsplit (modeline, ";", -1);
- ptr = strv;
- while (*ptr)
- {
- gchar **keyval;
- keyval = g_strsplit (*ptr, ":", 2);
- if (keyval[0] && keyval[1])
- {
- g_strstrip (keyval[0]);
- g_strstrip (keyval[1]);
- set_indentation_param_emacs (plugin, g_strchug (keyval[0]),
- g_strchug (keyval[1]));
- }
- g_strfreev (keyval);
- ptr++;
- }
- g_strfreev (strv);
-}
-
-static void
-parse_mode_line_vim (CppJavaPlugin *plugin, const gchar *modeline)
-{
- gchar **strv, **ptr;
-
- strv = g_strsplit_set (modeline, " \t:", -1);
- ptr = strv;
- while (*ptr)
- {
- gchar **keyval;
- keyval = g_strsplit (*ptr, "=", 2);
- if (keyval[0])
- {
- g_strstrip (keyval[0]);
- if (keyval[1])
- {
- g_strstrip (keyval[1]);
- set_indentation_param_vim (plugin, g_strchug (keyval[0]),
- g_strchug (keyval[1]));
- }
- else
- set_indentation_param_vim (plugin, g_strchug (keyval[0]),
- NULL);
- }
- g_strfreev (keyval);
- ptr++;
- }
- g_strfreev (strv);
-}
-
-static gchar *
-extract_mode_line (const gchar *comment_text, gboolean* vim)
-{
- /* Search for emacs-like modelines */
- gchar *begin_modeline, *end_modeline;
- begin_modeline = strstr (comment_text, "-*-");
- if (begin_modeline)
- {
- begin_modeline += 3;
- end_modeline = strstr (begin_modeline, "-*-");
- if (end_modeline)
- {
- *vim = FALSE;
- return g_strndup (begin_modeline, end_modeline - begin_modeline);
- }
- }
- /* Search for vim-like modelines */
- begin_modeline = strstr (comment_text, "vim:");
- if (begin_modeline)
- {
- begin_modeline += strlen ("vim:");
- end_modeline = strstr (begin_modeline, "*/");
- /* Check for escape characters */
- while (end_modeline)
- {
- if (!g_str_equal ((end_modeline - 1), "\\"))
- break;
- end_modeline++;
- end_modeline = strstr (end_modeline, "*/");
- }
- if (end_modeline)
- {
- gchar* vim_modeline = g_strndup (begin_modeline, end_modeline - begin_modeline);
- *vim = TRUE;
- return vim_modeline;
- }
- }
- return NULL;
-}
-
-#define MINI_BUFFER_SIZE 3
-static void
-initialize_indentation_params (CppJavaPlugin *plugin)
-{
- IAnjutaIterable *iter;
- GString *comment_text;
- gboolean comment_begun = FALSE;
- gboolean line_comment = FALSE;
- gchar mini_buffer[MINI_BUFFER_SIZE] = {0};
-
- plugin->smart_indentation = g_settings_get_boolean (plugin->settings, PREF_INDENT_AUTOMATIC);
- /* Disable editor intern auto-indent if smart indentation is enabled */
- ianjuta_editor_set_auto_indent (IANJUTA_EDITOR(plugin->current_editor),
- !plugin->smart_indentation, NULL);
-
- /* Initialize indentation parameters */
- plugin->param_tab_size = -1;
- plugin->param_statement_indentation = -1;
- plugin->param_brace_indentation = -1;
- plugin->param_case_indentation = -1;
- plugin->param_label_indentation = -1;
- plugin->param_use_spaces = -1;
-
- if (g_settings_get_boolean (plugin->settings,
- PREF_INDENT_MODELINE))
- {
- /* Find the first comment text in the buffer */
- comment_text = g_string_new (NULL);
- iter = ianjuta_editor_get_start_position (IANJUTA_EDITOR (plugin->current_editor),
- NULL);
- do
- {
- gboolean shift_buffer = TRUE;
- gint i;
- gchar ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter),
- 0, NULL);
-
- for (i = 0; i < MINI_BUFFER_SIZE - 1; i++)
- {
- if (mini_buffer[i] == '\0')
- {
- mini_buffer[i] = ch;
- shift_buffer = FALSE;
- break;
- }
- }
- if (shift_buffer == TRUE)
- {
- /* Shift buffer and add */
- for (i = 0; i < MINI_BUFFER_SIZE - 1; i++)
- mini_buffer [i] = mini_buffer[i+1];
- mini_buffer[i] = ch;
- }
-
- if (!comment_begun && strncmp (mini_buffer, "/*", 2) == 0)
- {
- comment_begun = TRUE;
- /* Reset buffer */
- mini_buffer[0] = mini_buffer[1] = '\0';
- }
- else if (!comment_begun && strncmp (mini_buffer, "//", 2) == 0)
- {
- comment_begun = TRUE;
- line_comment = TRUE;
- }
- else if (!comment_begun && mini_buffer[1] != '\0')
- {
- /* The buffer doesn't begin with a comment */
- break;
- }
- else if (comment_begun)
- {
- if ((line_comment && ch == '\n') ||
- (!line_comment && strncmp (mini_buffer, "*/", 2) == 0))
- {
- break;
- }
- }
-
- if (comment_begun)
- g_string_append_c (comment_text, ch);
-
- }
- while (ianjuta_iterable_next (iter, NULL));
-
- /* DEBUG_PRINT ("Comment text: %s", comment_text->str);*/
- if (comment_text->len > 0)
- {
-
- /* First comment found */
- gboolean vim;
- gchar *modeline = extract_mode_line (comment_text->str, &vim);
- if (modeline)
- {
- if (!vim)
- parse_mode_line_emacs (plugin, modeline);
- else
- parse_mode_line_vim (plugin, modeline);
- g_free (modeline);
- }
- }
- g_string_free (comment_text, TRUE);
- g_object_unref (iter);
- }
-}
-
/* Glade support */
static CppFileType
get_filetype (GFile *file)
{
- if (file)
- {
- gchar* mime_type = anjuta_util_get_file_mime_type (file);
- if (mime_type)
- {
- if (g_str_equal (mime_type, "text/x-csrc"))
- return LS_FILE_C;
- else if (g_str_equal (mime_type, "text/x-chdr"))
- return LS_FILE_CHDR;
- else if (g_str_equal (mime_type, "text/x-c++src"))
- return LS_FILE_CPP;
- else if (g_str_equal (mime_type, "text/x-c++hdr"))
- return LS_FILE_CPPHDR;
- else
- return LS_FILE_OTHER;
- }
- }
- return LS_FILE_OTHER;
+ if (file)
+ {
+ gchar* mime_type = anjuta_util_get_file_mime_type (file);
+ if (mime_type)
+ {
+ if (g_str_equal (mime_type, "text/x-csrc"))
+ return LS_FILE_C;
+ else if (g_str_equal (mime_type, "text/x-chdr"))
+ return LS_FILE_CHDR;
+ else if (g_str_equal (mime_type, "text/x-c++src"))
+ return LS_FILE_CPP;
+ else if (g_str_equal (mime_type, "text/x-c++hdr"))
+ return LS_FILE_CPPHDR;
+ else
+ return LS_FILE_OTHER;
+ }
+ }
+ return LS_FILE_OTHER;
}
static void
init_file_type (CppJavaPlugin* lang_plugin)
{
- GFile* file = ianjuta_file_get_file (IANJUTA_FILE (lang_plugin->current_editor),
- NULL);
+ GFile* file = ianjuta_file_get_file (IANJUTA_FILE (lang_plugin->current_editor),
+ NULL);
- lang_plugin->filetype = get_filetype (file);
+ lang_plugin->filetype = get_filetype (file);
}
static gboolean
@@ -389,403 +114,403 @@ on_glade_drop_possible (IAnjutaEditor* editor,
IAnjutaIterable* iterator,
CppJavaPlugin* lang_plugin)
{
- switch (lang_plugin->filetype)
- {
- case LS_FILE_C:
- case LS_FILE_CHDR:
- return TRUE;
- default:
- return FALSE;
- }
+ switch (lang_plugin->filetype)
+ {
+ case LS_FILE_C:
+ case LS_FILE_CHDR:
+ return TRUE;
+ default:
+ return FALSE;
+ }
}
static gchar*
language_support_check_param_name (const gchar* name,
GList** names)
{
- gint index = 0;
- GString* real_name = g_string_new (name);
- while (g_list_find_custom (*names, real_name->str, (GCompareFunc) strcmp))
- {
- g_string_free (real_name, TRUE);
- real_name = g_string_new (name);
- g_string_append_printf (real_name, "%d", ++index);
- }
- *names = g_list_append (*names, real_name->str);
- return g_string_free (real_name, FALSE);
+ gint index = 0;
+ GString* real_name = g_string_new (name);
+ while (g_list_find_custom (*names, real_name->str, (GCompareFunc) strcmp))
+ {
+ g_string_free (real_name, TRUE);
+ real_name = g_string_new (name);
+ g_string_append_printf (real_name, "%d", ++index);
+ }
+ *names = g_list_append (*names, real_name->str);
+ return g_string_free (real_name, FALSE);
}
static const gchar*
language_support_get_signal_parameter (const gchar* type_name, GList** names)
{
- const gchar* c;
- const gchar* param_name = NULL;
- GString* param_string;
- gchar* real_name;
- /* Search for the second upper character */
- for (c = type_name + 1; *c != '\0'; c++)
- {
- if (g_ascii_isupper (*c))
- {
- param_name = c;
- break;
- }
- }
- if (param_name && strlen (param_name))
- {
- param_string = g_string_new (param_name);
- g_string_down (param_string);
- }
- else
- {
- param_string = g_string_new ("arg");
- }
- real_name = language_support_check_param_name (g_string_free (param_string, FALSE), names);
-
- return real_name;
+ const gchar* c;
+ const gchar* param_name = NULL;
+ GString* param_string;
+ gchar* real_name;
+ /* Search for the second upper character */
+ for (c = type_name + 1; *c != '\0'; c++)
+ {
+ if (g_ascii_isupper (*c))
+ {
+ param_name = c;
+ break;
+ }
+ }
+ if (param_name && strlen (param_name))
+ {
+ param_string = g_string_new (param_name);
+ g_string_down (param_string);
+ }
+ else
+ {
+ param_string = g_string_new ("arg");
+ }
+ real_name = language_support_check_param_name (g_string_free (param_string, FALSE), names);
+
+ return real_name;
}
static GString*
language_support_generate_c_signature (const gchar* separator,
- const gchar* widget,
- GSignalQuery query,
- gboolean swapped,
- const gchar* handler)
+ const gchar* widget,
+ GSignalQuery query,
+ gboolean swapped,
+ const gchar* handler)
{
- GList* names = NULL;
- GString* str = g_string_new ("\n");
- const gchar* widget_param = language_support_get_signal_parameter (widget,
- &names);
- int i;
- g_string_append (str, g_type_name (query.return_type));
- if (!swapped)
- g_string_append_printf (str, "%s%s (%s *%s",
- separator, handler, widget, widget_param);
- else
- g_string_append_printf (str, "%s%s (gpointer user_data, %s *%s",
- separator, handler, widget, widget_param);
-
- for (i = 0; i < query.n_params; i++)
- {
- const gchar* type_name = g_type_name (query.param_types[i]);
- if (!type_name) continue;
-
- const gchar* param_name = language_support_get_signal_parameter (type_name,
- &names);
-
- if (query.param_types[i] <= G_TYPE_DOUBLE)
- {
- g_string_append_printf (str, ", %s %s", type_name, param_name);
- }
- else
- {
- g_string_append_printf (str, ", %s *%s", type_name, param_name);
- }
- }
- if (!swapped)
- g_string_append (str, ", gpointer user_data)");
- else
- g_string_append (str, ")");
-
- anjuta_util_glist_strings_free (names);
-
- return str;
+ GList* names = NULL;
+ GString* str = g_string_new ("\n");
+ const gchar* widget_param = language_support_get_signal_parameter (widget,
+ &names);
+ int i;
+ g_string_append (str, g_type_name (query.return_type));
+ if (!swapped)
+ g_string_append_printf (str, "%s%s (%s *%s",
+ separator, handler, widget, widget_param);
+ else
+ g_string_append_printf (str, "%s%s (gpointer user_data, %s *%s",
+ separator, handler, widget, widget_param);
+
+ for (i = 0; i < query.n_params; i++)
+ {
+ const gchar* type_name = g_type_name (query.param_types[i]);
+ if (!type_name) continue;
+
+ const gchar* param_name = language_support_get_signal_parameter (type_name,
+ &names);
+
+ if (query.param_types[i] <= G_TYPE_DOUBLE)
+ {
+ g_string_append_printf (str, ", %s %s", type_name, param_name);
+ }
+ else
+ {
+ g_string_append_printf (str, ", %s *%s", type_name, param_name);
+ }
+ }
+ if (!swapped)
+ g_string_append (str, ", gpointer user_data)");
+ else
+ g_string_append (str, ")");
+
+ anjuta_util_glist_strings_free (names);
+
+ return str;
}
const gchar* SOURCE_EXT[] =
{
- ".c",
- ".cc",
- ".C",
- ".cpp",
- ".cxx",
- ".ccg",
- NULL
+ ".c",
+ ".cc",
+ ".C",
+ ".cpp",
+ ".cxx",
+ ".ccg",
+ NULL
};
const gchar* HEADER_EXT[] =
{
- ".h",
- ".hh",
- ".H",
- ".hpp",
- ".hxx",
- ".hg",
- NULL
+ ".h",
+ ".hh",
+ ".H",
+ ".hpp",
+ ".hxx",
+ ".hg",
+ NULL
};
static GFile*
language_support_get_header_file (IAnjutaEditor* editor)
{
- GFile *file = ianjuta_file_get_file (IANJUTA_FILE (editor), NULL);
- GFile *parent = g_file_get_parent (file);
- gchar *parent_uri = g_file_get_uri (parent);
- gchar *basename = g_file_get_basename (file);
- g_object_unref (file);
- g_object_unref (parent);
- gchar *ext = strstr (basename, ".");
- GFile *ret = NULL;
-
- if (ext)
- {
- int i;
- for (i = 0; SOURCE_EXT[i] != NULL; i++)
- {
- if (g_str_equal (ext, SOURCE_EXT[i]))
- {
- int j;
- for (j = 0; HEADER_EXT[j] != NULL; j++)
- {
- gchar* filename;
- gchar* uri;
- GFile* new_file;
- *ext = '\0';
- filename = g_strdup_printf ("%s%s", basename, HEADER_EXT[j]);
- uri = g_build_filename (parent_uri, filename, NULL);
- new_file = g_file_new_for_uri (uri);
- g_free (uri);
- g_free(filename);
- if (g_file_query_exists (new_file, NULL))
- {
- ret = new_file;
- goto end;
- }
- g_object_unref (new_file);
- }
- break;
- }
- if (g_str_equal (ext, HEADER_EXT[i]))
- {
- int j;
- for (j = 0; SOURCE_EXT[j] != NULL; j++)
- {
- gchar* filename;
- gchar* uri;
- GFile* new_file;
- *ext = '\0';
- filename = g_strdup_printf ("%s%s", basename, SOURCE_EXT[j]);
- uri = g_build_filename (parent_uri, filename, NULL);
- new_file = g_file_new_for_uri (uri);
- g_free (uri);
- g_free(filename);
- if (g_file_query_exists (new_file, NULL))
- {
- ret = new_file;
- goto end;
- }
- g_object_unref (new_file);
- }
- break;
- }
- }
- }
+ GFile *file = ianjuta_file_get_file (IANJUTA_FILE (editor), NULL);
+ GFile *parent = g_file_get_parent (file);
+ gchar *parent_uri = g_file_get_uri (parent);
+ gchar *basename = g_file_get_basename (file);
+ g_object_unref (file);
+ g_object_unref (parent);
+ gchar *ext = strstr (basename, ".");
+ GFile *ret = NULL;
+
+ if (ext)
+ {
+ int i;
+ for (i = 0; SOURCE_EXT[i] != NULL; i++)
+ {
+ if (g_str_equal (ext, SOURCE_EXT[i]))
+ {
+ int j;
+ for (j = 0; HEADER_EXT[j] != NULL; j++)
+ {
+ gchar* filename;
+ gchar* uri;
+ GFile* new_file;
+ *ext = '\0';
+ filename = g_strdup_printf ("%s%s", basename, HEADER_EXT[j]);
+ uri = g_build_filename (parent_uri, filename, NULL);
+ new_file = g_file_new_for_uri (uri);
+ g_free (uri);
+ g_free(filename);
+ if (g_file_query_exists (new_file, NULL))
+ {
+ ret = new_file;
+ goto end;
+ }
+ g_object_unref (new_file);
+ }
+ break;
+ }
+ if (g_str_equal (ext, HEADER_EXT[i]))
+ {
+ int j;
+ for (j = 0; SOURCE_EXT[j] != NULL; j++)
+ {
+ gchar* filename;
+ gchar* uri;
+ GFile* new_file;
+ *ext = '\0';
+ filename = g_strdup_printf ("%s%s", basename, SOURCE_EXT[j]);
+ uri = g_build_filename (parent_uri, filename, NULL);
+ new_file = g_file_new_for_uri (uri);
+ g_free (uri);
+ g_free(filename);
+ if (g_file_query_exists (new_file, NULL))
+ {
+ ret = new_file;
+ goto end;
+ }
+ g_object_unref (new_file);
+ }
+ break;
+ }
+ }
+ }
end:
- g_free(basename);
- g_free (parent_uri);
+ g_free(basename);
+ g_free (parent_uri);
return ret;
}
static IAnjutaEditor*
language_support_get_editor_from_file (CppJavaPlugin* lang_plugin,
- GFile *file)
+ GFile *file)
{
- IAnjutaDocumentManager *document_manager = anjuta_shell_get_interface (
- ANJUTA_PLUGIN (lang_plugin)->shell,
- IAnjutaDocumentManager,
- NULL);
+ IAnjutaDocumentManager *document_manager = anjuta_shell_get_interface (
+ ANJUTA_PLUGIN (lang_plugin)->shell,
+ IAnjutaDocumentManager,
+ NULL);
- IAnjutaDocument *document = ianjuta_document_manager_find_document_with_file
+ IAnjutaDocument *document = ianjuta_document_manager_find_document_with_file
(document_manager,
file,
NULL);
- return IANJUTA_EDITOR (document);
+ return IANJUTA_EDITOR (document);
}
static IAnjutaIterable*
language_support_get_mark_position (IAnjutaEditor* editor, gchar* mark)
{
- IAnjutaEditorCell *search_start = IANJUTA_EDITOR_CELL (
- ianjuta_editor_get_start_position (editor, NULL));
- IAnjutaEditorCell *search_end = IANJUTA_EDITOR_CELL (
- ianjuta_editor_get_end_position (editor, NULL));
- IAnjutaEditorCell *result_start = NULL;
- IAnjutaEditorCell *result_end = NULL;
-
- ianjuta_editor_search_forward (IANJUTA_EDITOR_SEARCH (editor),
- mark, FALSE,
- search_start, search_end,
- &result_start,
- &result_end, NULL);
-
- if (result_start)
- g_object_unref (result_start);
-
- return result_end ? IANJUTA_ITERABLE (result_end) : NULL;
+ IAnjutaEditorCell *search_start = IANJUTA_EDITOR_CELL (
+ ianjuta_editor_get_start_position (editor, NULL));
+ IAnjutaEditorCell *search_end = IANJUTA_EDITOR_CELL (
+ ianjuta_editor_get_end_position (editor, NULL));
+ IAnjutaEditorCell *result_start = NULL;
+ IAnjutaEditorCell *result_end = NULL;
+
+ ianjuta_editor_search_forward (IANJUTA_EDITOR_SEARCH (editor),
+ mark, FALSE,
+ search_start, search_end,
+ &result_start,
+ &result_end, NULL);
+
+ if (result_start)
+ g_object_unref (result_start);
+
+ return result_end ? IANJUTA_ITERABLE (result_end) : NULL;
}
static IAnjutaIterable*
language_support_find_symbol (CppJavaPlugin* lang_plugin,
- IAnjutaEditor* editor,
- const gchar* handler)
+ IAnjutaEditor* editor,
+ const gchar* handler)
{
- IAnjutaSymbolManager *isymbol_manager = anjuta_shell_get_interface (
- ANJUTA_PLUGIN (lang_plugin)->shell,
- IAnjutaSymbolManager,
- NULL);
+ IAnjutaSymbolManager *isymbol_manager = anjuta_shell_get_interface (
+ ANJUTA_PLUGIN (lang_plugin)->shell,
+ IAnjutaSymbolManager,
+ NULL);
- IAnjutaSymbolQuery *symbol_query = ianjuta_symbol_manager_create_query (
- isymbol_manager,
- IANJUTA_SYMBOL_QUERY_SEARCH_FILE,
- IANJUTA_SYMBOL_QUERY_DB_PROJECT,
- NULL);
- IAnjutaSymbolField field = IANJUTA_SYMBOL_FIELD_FILE_POS;
- ianjuta_symbol_query_set_fields (symbol_query, 1, &field, NULL);
+ IAnjutaSymbolQuery *symbol_query = ianjuta_symbol_manager_create_query (
+ isymbol_manager,
+ IANJUTA_SYMBOL_QUERY_SEARCH_FILE,
+ IANJUTA_SYMBOL_QUERY_DB_PROJECT,
+ NULL);
+ IAnjutaSymbolField field = IANJUTA_SYMBOL_FIELD_FILE_POS;
+ ianjuta_symbol_query_set_fields (symbol_query, 1, &field, NULL);
- GFile* file = ianjuta_file_get_file (IANJUTA_FILE (editor),
- NULL);
+ GFile* file = ianjuta_file_get_file (IANJUTA_FILE (editor),
+ NULL);
- IAnjutaIterable *iter = ianjuta_symbol_query_search_file (symbol_query,
- handler, file, NULL);
+ IAnjutaIterable *iter = ianjuta_symbol_query_search_file (symbol_query,
+ handler, file, NULL);
- g_object_unref (file);
- g_object_unref (symbol_query);
+ g_object_unref (file);
+ g_object_unref (symbol_query);
- return iter;
+ return iter;
}
static gboolean
language_support_get_callback_strings (gchar** separator,
- gchar** body,
- gint* offset,
- CppFileType filetype)
+ gchar** body,
+ gint* offset,
+ CppFileType filetype)
{
- switch (filetype)
- {
- case LS_FILE_C:
- {
- *separator = C_SEPARATOR;
- *body = C_BODY;
- *offset = C_OFFSET;
- break;
- }
- case LS_FILE_CHDR:
- {
- *separator = CHDR_SEPARATOR;
- *body = CHDR_BODY;
- *offset = CHDR_OFFSET;
- break;
- }
- default:
- return FALSE;
- }
-
- return TRUE;
+ switch (filetype)
+ {
+ case LS_FILE_C:
+ {
+ *separator = C_SEPARATOR;
+ *body = C_BODY;
+ *offset = C_OFFSET;
+ break;
+ }
+ case LS_FILE_CHDR:
+ {
+ *separator = CHDR_SEPARATOR;
+ *body = CHDR_BODY;
+ *offset = CHDR_OFFSET;
+ break;
+ }
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
}
static IAnjutaIterable*
language_support_get_header_editor_and_mark (CppJavaPlugin* lang_plugin,
- IAnjutaEditor* editor,
- gchar* mark,
- IAnjutaEditor** header_editor)
+ IAnjutaEditor* editor,
+ gchar* mark,
+ IAnjutaEditor** header_editor)
{
- IAnjutaIterable* mark_position = NULL;
- GFile *header_file = language_support_get_header_file (editor);
+ IAnjutaIterable* mark_position = NULL;
+ GFile *header_file = language_support_get_header_file (editor);
- /* Yes, we have a header */
- if (header_file)
- {
- *header_editor = language_support_get_editor_from_file (lang_plugin,
- header_file);
- /* We'll now search for the mark */
+ /* Yes, we have a header */
+ if (header_file)
+ {
+ *header_editor = language_support_get_editor_from_file (lang_plugin,
+ header_file);
+ /* We'll now search for the mark */
- mark_position = language_support_get_mark_position (*header_editor, mark);
+ mark_position = language_support_get_mark_position (*header_editor, mark);
- g_object_unref (header_file);
- }
+ g_object_unref (header_file);
+ }
- return mark_position;
+ return mark_position;
}
static void
language_support_add_c_callback (CppJavaPlugin* lang_plugin,
- IAnjutaEditor* editor,
- IAnjutaIterable* position,
- GStrv split_signal_data,
- CppFileType filetype)
+ IAnjutaEditor* editor,
+ IAnjutaIterable* position,
+ GStrv split_signal_data,
+ CppFileType filetype)
{
- GSignalQuery query;
+ GSignalQuery query;
- gchar* separator;
- gchar* body;
- gint offset;
+ gchar* separator;
+ gchar* body;
+ gint offset;
- const gchar* widget = split_signal_data[0];
- const gchar* signal = split_signal_data[1];
- const gchar* handler = split_signal_data[2];
- //const gchar* user_data = split_signal_data[3]; // Currently unused
- gboolean swapped = g_str_equal (split_signal_data[4], "1");
+ const gchar* widget = split_signal_data[0];
+ const gchar* signal = split_signal_data[1];
+ const gchar* handler = split_signal_data[2];
+ //const gchar* user_data = split_signal_data[3]; // Currently unused
+ gboolean swapped = g_str_equal (split_signal_data[4], "1");
- GType type = g_type_from_name (widget);
- guint id = g_signal_lookup (signal, type);
+ GType type = g_type_from_name (widget);
+ guint id = g_signal_lookup (signal, type);
- g_signal_query (id, &query);
+ g_signal_query (id, &query);
- if (!language_support_get_callback_strings (&separator, &body, &offset, filetype))
- return;
+ if (!language_support_get_callback_strings (&separator, &body, &offset, filetype))
+ return;
- GString* str = language_support_generate_c_signature (separator, widget,
- query, swapped, handler);
+ GString* str = language_support_generate_c_signature (separator, widget,
+ query, swapped, handler);
- g_string_append (str, body);
+ g_string_append (str, body);
- ianjuta_editor_insert (editor, position,
- str->str, -1, NULL);
+ ianjuta_editor_insert (editor, position,
+ str->str, -1, NULL);
- /* Code was inserted, we'll now check if we should add a prototype to the header */
- if (filetype == LS_FILE_C)
- {
- IAnjutaEditor* header_editor;
- IAnjutaIterable* mark_position;
- mark_position = language_support_get_header_editor_and_mark (lang_plugin,
- editor,
- "/* Callbacks */",
- &header_editor);
- if (mark_position)
- {
- /* Check if there's a the prototype to the header */
- IAnjutaIterable* symbol;
- symbol = language_support_find_symbol (lang_plugin, header_editor, handler);
+ /* Code was inserted, we'll now check if we should add a prototype to the header */
+ if (filetype == LS_FILE_C)
+ {
+ IAnjutaEditor* header_editor;
+ IAnjutaIterable* mark_position;
+ mark_position = language_support_get_header_editor_and_mark (lang_plugin,
+ editor,
+ "/* Callbacks */",
+ &header_editor);
+ if (mark_position)
+ {
+ /* Check if there's a the prototype to the header */
+ IAnjutaIterable* symbol;
+ symbol = language_support_find_symbol (lang_plugin, header_editor, handler);
- if (symbol)
- {
- g_object_unref (symbol);
- } else {
- /* Add prototype to the header */
- language_support_add_c_callback (lang_plugin, header_editor, mark_position,
- split_signal_data, LS_FILE_CHDR);
+ if (symbol)
+ {
+ g_object_unref (symbol);
+ } else {
+ /* Add prototype to the header */
+ language_support_add_c_callback (lang_plugin, header_editor, mark_position,
+ split_signal_data, LS_FILE_CHDR);
- }
+ }
- g_object_unref (mark_position);
- }
- }
+ g_object_unref (mark_position);
+ }
+ }
- gchar *string = g_string_free (str, FALSE);
- /* Emit code-added signal, so symbols will be updated */
- g_signal_emit_by_name (G_OBJECT (editor), "code-added", position, string);
+ gchar *string = g_string_free (str, FALSE);
+ /* Emit code-added signal, so symbols will be updated */
+ g_signal_emit_by_name (G_OBJECT (editor), "code-added", position, string);
- if (string) g_free (string);
+ if (string) g_free (string);
- /* Will now set the caret position offset */
- ianjuta_editor_goto_line (editor,
- ianjuta_editor_get_line_from_position (
- editor, position, NULL) + offset, NULL);
+ /* Will now set the caret position offset */
+ ianjuta_editor_goto_line (editor,
+ ianjuta_editor_get_line_from_position (
+ editor, position, NULL) + offset, NULL);
}
static void
@@ -794,35 +519,35 @@ on_glade_drop (IAnjutaEditor* editor,
const gchar* signal_data,
CppJavaPlugin* lang_plugin)
{
- GStrv split_signal_data = g_strsplit(signal_data, ":", 5);
- char *handler = split_signal_data[2];
- /**
- * Split signal data format:
- * widget = split_signaldata[0];
- * signal = split_signaldata[1];
- * handler = split_signaldata[2];
- * user_data = split_signaldata[3];
- * swapped = g_str_equal (split_signaldata[4], "1");
- */
-
- IAnjutaIterable *iter;
- iter = language_support_find_symbol (lang_plugin,
- IANJUTA_EDITOR (editor),
- handler);
- if (iter == NULL)
- {
- GFile *file = ianjuta_file_get_file (IANJUTA_FILE (editor), NULL);
- CppFileType filetype = get_filetype (file);
- language_support_add_c_callback (lang_plugin, editor, iterator, split_signal_data, filetype);
- } else {
- /* Symbol found, going there */
- ianjuta_editor_goto_line (editor, ianjuta_symbol_get_int (
- IANJUTA_SYMBOL (iter),
- IANJUTA_SYMBOL_FIELD_FILE_POS,
- NULL), NULL);
- g_object_unref (iter);
- }
- g_strfreev (split_signal_data);
+ GStrv split_signal_data = g_strsplit(signal_data, ":", 5);
+ char *handler = split_signal_data[2];
+ /**
+ * Split signal data format:
+ * widget = split_signaldata[0];
+ * signal = split_signaldata[1];
+ * handler = split_signaldata[2];
+ * user_data = split_signaldata[3];
+ * swapped = g_str_equal (split_signaldata[4], "1");
+ */
+
+ IAnjutaIterable *iter;
+ iter = language_support_find_symbol (lang_plugin,
+ IANJUTA_EDITOR (editor),
+ handler);
+ if (iter == NULL)
+ {
+ GFile *file = ianjuta_file_get_file (IANJUTA_FILE (editor), NULL);
+ CppFileType filetype = get_filetype (file);
+ language_support_add_c_callback (lang_plugin, editor, iterator, split_signal_data, filetype);
+ } else {
+ /* Symbol found, going there */
+ ianjuta_editor_goto_line (editor, ianjuta_symbol_get_int (
+ IANJUTA_SYMBOL (iter),
+ IANJUTA_SYMBOL_FIELD_FILE_POS,
+ NULL), NULL);
+ g_object_unref (iter);
+ }
+ g_strfreev (split_signal_data);
}
static gchar* generate_widget_member_decl_str (gchar* widget_name)
@@ -842,7 +567,7 @@ static gboolean insert_after_mark (IAnjutaEditor* editor, gchar* mark,
IAnjutaIterable* mark_position;
mark_position = language_support_get_mark_position (editor, mark);
if (!mark_position)
- return FALSE;
+ return FALSE;
ianjuta_editor_insert (editor, mark_position, code_to_add, -1, NULL);
@@ -856,13 +581,13 @@ static gboolean insert_after_mark (IAnjutaEditor* editor, gchar* mark,
static gchar*
generate_widget_member_decl_marker (gchar* ui_filename)
{
- return g_strdup_printf ("/* ANJUTA: Widgets declaration for %s - DO NOT REMOVE */", ui_filename);
+ return g_strdup_printf ("/* ANJUTA: Widgets declaration for %s - DO NOT REMOVE */", ui_filename);
}
static gchar*
generate_widget_member_init_marker (gchar* ui_filename)
{
- return g_strdup_printf ("/* ANJUTA: Widgets initialization for %s - DO NOT REMOVE */", ui_filename);
+ return g_strdup_printf ("/* ANJUTA: Widgets initialization for %s - DO NOT REMOVE */", ui_filename);
}
static gboolean
@@ -902,8 +627,8 @@ glade_widget_already_in_scope (IAnjutaEditor* editor, gchar* widget_name,
anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell, IAnjutaSymbolManager, NULL);
query_scope = ianjuta_symbol_manager_create_query (symbol_manager,
- IANJUTA_SYMBOL_QUERY_SEARCH_SCOPE,
- IANJUTA_SYMBOL_QUERY_DB_PROJECT, NULL);
+ IANJUTA_SYMBOL_QUERY_SEARCH_SCOPE,
+ IANJUTA_SYMBOL_QUERY_DB_PROJECT, NULL);
if (!query_scope)
return FALSE;
@@ -970,591 +695,541 @@ static void
on_glade_member_add (IAnjutaEditor* editor, gchar* widget_typename,
gchar* widget_name, gchar* path, CppJavaPlugin* lang_plugin)
{
- GFile* ui_file = g_file_new_for_path (path);
- gchar* ui_filename = g_file_get_basename (ui_file);
+ GFile* ui_file = g_file_new_for_path (path);
+ gchar* ui_filename = g_file_get_basename (ui_file);
- insert_member_decl_and_init (editor, widget_name, ui_filename, lang_plugin);
+ insert_member_decl_and_init (editor, widget_name, ui_filename, lang_plugin);
}
static void
on_glade_callback_add (IAnjutaEditor* editor,
- gchar *widget_typename,
- gchar *signal_name,
- gchar *handler_name,
- gchar *object,
- gboolean swap,
- gboolean after,
- gchar* path,
- CppJavaPlugin* lang_plugin)
+ gchar *widget_typename,
+ gchar *signal_name,
+ gchar *handler_name,
+ gchar *object,
+ gboolean swap,
+ gboolean after,
+ gchar* path,
+ CppJavaPlugin* lang_plugin)
{
- GFile* ui_file = g_file_new_for_path (path);
- gchar* ui_filename = g_file_get_basename (ui_file);
-
- /* Using marker to search for compatibility */
- gchar *mark = generate_widget_member_init_marker (ui_filename);
- IAnjutaIterable* mark_position;
- mark_position = language_support_get_mark_position (editor, mark);
- if (mark_position)
- {
- IAnjutaIterable* end = ianjuta_editor_get_end_position (editor, NULL);
-
- /* String format: widgettypename:signalname:handler_name:object:swap:after */
- gchar *signal_data = g_strdup_printf("%s:%s:%s:%s:%s:%s",
- widget_typename,
- signal_name,
- handler_name,
- object,
- swap?"1":"0",
- after?"1":"0");
-
- on_glade_drop (editor, end, signal_data, lang_plugin);
-
- g_free(signal_data);
- }
- g_free(mark);
+ GFile* ui_file = g_file_new_for_path (path);
+ gchar* ui_filename = g_file_get_basename (ui_file);
+
+ /* Using marker to search for compatibility */
+ gchar *mark = generate_widget_member_init_marker (ui_filename);
+ IAnjutaIterable* mark_position;
+ mark_position = language_support_get_mark_position (editor, mark);
+ if (mark_position)
+ {
+ IAnjutaIterable* end = ianjuta_editor_get_end_position (editor, NULL);
+
+ /* String format: widgettypename:signalname:handler_name:object:swap:after */
+ gchar *signal_data = g_strdup_printf("%s:%s:%s:%s:%s:%s",
+ widget_typename,
+ signal_name,
+ handler_name,
+ object,
+ swap?"1":"0",
+ after?"1":"0");
+
+ on_glade_drop (editor, end, signal_data, lang_plugin);
+
+ g_free(signal_data);
+ }
+ g_free(mark);
}
/* Enable/Disable language-support */
static void
install_support (CppJavaPlugin *lang_plugin)
{
- IAnjutaLanguage* lang_manager =
- anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell,
- IAnjutaLanguage, NULL);
-
- if (!lang_manager)
- return;
-
- if (lang_plugin->support_installed)
- return;
-
- lang_plugin->current_language =
- ianjuta_language_get_name_from_editor (lang_manager,
- IANJUTA_EDITOR_LANGUAGE (lang_plugin->current_editor), NULL);
-
- DEBUG_PRINT("Language support installed for: %s",
- lang_plugin->current_language);
-
- if (lang_plugin->current_language &&
- (g_str_equal (lang_plugin->current_language, "C")
- || g_str_equal (lang_plugin->current_language, "C++")
- || g_str_equal (lang_plugin->current_language, "Vala")))
- {
- g_signal_connect (lang_plugin->current_editor,
- "char-added",
- G_CALLBACK (cpp_indentation),
- lang_plugin);
- }
- else if (lang_plugin->current_language &&
- (g_str_equal (lang_plugin->current_language, "Java")))
- {
- g_signal_connect (lang_plugin->current_editor,
- "char-added",
- G_CALLBACK (java_indentation),
- lang_plugin);
- }
- else
- {
- return;
- }
-
- initialize_indentation_params (lang_plugin);
- init_file_type (lang_plugin);
-
-
- if (g_str_equal (lang_plugin->current_language, "C" ) ||
- g_str_equal (lang_plugin->current_language, "C++"))
- {
- CppJavaAssist *assist;
-
- g_assert (lang_plugin->assist == NULL);
-
- assist = cpp_java_assist_new (IANJUTA_EDITOR (lang_plugin->current_editor),
- anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell,
- IAnjutaSymbolManager,
- NULL),
- lang_plugin->settings);
- lang_plugin->assist = assist;
-
-
- if (IANJUTA_IS_EDITOR_GLADE_SIGNAL (lang_plugin->current_editor))
- {
- g_signal_connect (lang_plugin->current_editor,
- "drop-possible", G_CALLBACK (on_glade_drop_possible),
- lang_plugin);
- g_signal_connect (lang_plugin->current_editor,
- "drop", G_CALLBACK (on_glade_drop),
- lang_plugin);
- }
-
- g_signal_connect (lang_plugin->current_editor,
- "glade-callback-add",
- G_CALLBACK (on_glade_callback_add),
- lang_plugin);
-
- g_signal_connect (lang_plugin->current_editor,
- "glade-member-add",
- G_CALLBACK (on_glade_member_add),
- lang_plugin);
-
- lang_plugin->packages = cpp_packages_new (ANJUTA_PLUGIN (lang_plugin));
- cpp_packages_load(lang_plugin->packages, FALSE);
- }
-
- lang_plugin->support_installed = TRUE;
+ IAnjutaLanguage* lang_manager =
+ anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell,
+ IAnjutaLanguage, NULL);
+
+ if (!lang_manager)
+ return;
+
+ if (lang_plugin->support_installed)
+ return;
+
+ lang_plugin->current_language =
+ ianjuta_language_get_name_from_editor (lang_manager,
+ IANJUTA_EDITOR_LANGUAGE (lang_plugin->current_editor), NULL);
+
+ DEBUG_PRINT("Language support installed for: %s",
+ lang_plugin->current_language);
+
+ if (!(lang_plugin->current_language &&
+ (g_str_equal (lang_plugin->current_language, "C")
+ || g_str_equal (lang_plugin->current_language, "C++")
+ || g_str_equal (lang_plugin->current_language, "Vala")
+ || g_str_equal (lang_plugin->current_language, "Java"))))
+ {
+ return;
+ }
+
+ init_file_type (lang_plugin);
+
+
+ if (g_str_equal (lang_plugin->current_language, "C" ) ||
+ g_str_equal (lang_plugin->current_language, "C++"))
+ {
+ CppJavaAssist *assist;
+
+ g_assert (lang_plugin->assist == NULL);
+
+ assist = cpp_java_assist_new (IANJUTA_EDITOR (lang_plugin->current_editor),
+ anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell,
+ IAnjutaSymbolManager,
+ NULL),
+ lang_plugin->settings);
+ lang_plugin->assist = assist;
+
+
+ if (IANJUTA_IS_EDITOR_GLADE_SIGNAL (lang_plugin->current_editor))
+ {
+ g_signal_connect (lang_plugin->current_editor,
+ "drop-possible", G_CALLBACK (on_glade_drop_possible),
+ lang_plugin);
+ g_signal_connect (lang_plugin->current_editor,
+ "drop", G_CALLBACK (on_glade_drop),
+ lang_plugin);
+ }
+
+ g_signal_connect (lang_plugin->current_editor,
+ "glade-callback-add",
+ G_CALLBACK (on_glade_callback_add),
+ lang_plugin);
+
+ g_signal_connect (lang_plugin->current_editor,
+ "glade-member-add",
+ G_CALLBACK (on_glade_member_add),
+ lang_plugin);
+
+ lang_plugin->packages = cpp_packages_new (ANJUTA_PLUGIN (lang_plugin));
+ cpp_packages_load(lang_plugin->packages, FALSE);
+ }
+
+ lang_plugin->support_installed = TRUE;
}
static void
uninstall_support (CppJavaPlugin *lang_plugin)
{
- if (!lang_plugin->support_installed)
- return;
-
- if (lang_plugin->current_language &&
- (g_str_equal (lang_plugin->current_language, "C")
- || g_str_equal (lang_plugin->current_language, "C++")
- || g_str_equal (lang_plugin->current_language, "Vala")))
- {
- g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
- G_CALLBACK (cpp_indentation),
- lang_plugin);
- }
- else if (lang_plugin->current_language &&
- (g_str_equal (lang_plugin->current_language, "Java")))
- {
- g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
- G_CALLBACK (java_indentation),
- lang_plugin);
- }
-
- if (lang_plugin->assist)
- {
- g_object_unref (lang_plugin->assist);
- lang_plugin->assist = NULL;
- }
-
- g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
- on_glade_drop_possible, lang_plugin);
- g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
- on_glade_drop, lang_plugin);
- g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
- G_CALLBACK (on_glade_member_add),
- lang_plugin);
- g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
- G_CALLBACK (on_glade_callback_add),
- lang_plugin);
-
- if (lang_plugin->packages)
- {
- g_object_unref (lang_plugin->packages);
- lang_plugin->packages = NULL;
- }
- lang_plugin->support_installed = FALSE;
+ if (!lang_plugin->support_installed)
+ return;
+
+ if (lang_plugin->assist)
+ {
+ g_object_unref (lang_plugin->assist);
+ lang_plugin->assist = NULL;
+ }
+
+ g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
+ on_glade_drop_possible, lang_plugin);
+ g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
+ on_glade_drop, lang_plugin);
+ g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
+ G_CALLBACK (on_glade_member_add),
+ lang_plugin);
+ g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
+ G_CALLBACK (on_glade_callback_add),
+ lang_plugin);
+
+ if (lang_plugin->packages)
+ {
+ g_object_unref (lang_plugin->packages);
+ lang_plugin->packages = NULL;
+ }
+ lang_plugin->support_installed = FALSE;
}
static void
on_editor_language_changed (IAnjutaEditor *editor,
- const gchar *new_language,
- CppJavaPlugin *plugin)
+ const gchar *new_language,
+ CppJavaPlugin *plugin)
{
- uninstall_support (plugin);
- install_support (plugin);
+ uninstall_support (plugin);
+ install_support (plugin);
}
static void
on_value_added_current_editor (AnjutaPlugin *plugin, const gchar *name,
- const GValue *value, gpointer data)
+ const GValue *value, gpointer data)
{
- CppJavaPlugin *lang_plugin;
- IAnjutaDocument* doc = IANJUTA_DOCUMENT(g_value_get_object (value));
- lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (plugin);
- if (IANJUTA_IS_EDITOR(doc))
- lang_plugin->current_editor = G_OBJECT(doc);
- else
- {
- lang_plugin->current_editor = NULL;
- return;
- }
- if (IANJUTA_IS_EDITOR(lang_plugin->current_editor))
- install_support (lang_plugin);
- g_signal_connect (lang_plugin->current_editor, "language-changed",
- G_CALLBACK (on_editor_language_changed),
- plugin);
+ CppJavaPlugin *lang_plugin;
+ IAnjutaDocument* doc = IANJUTA_DOCUMENT(g_value_get_object (value));
+ lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (plugin);
+ if (IANJUTA_IS_EDITOR(doc))
+ lang_plugin->current_editor = G_OBJECT(doc);
+ else
+ {
+ lang_plugin->current_editor = NULL;
+ return;
+ }
+ if (IANJUTA_IS_EDITOR(lang_plugin->current_editor))
+ install_support (lang_plugin);
+ g_signal_connect (lang_plugin->current_editor, "language-changed",
+ G_CALLBACK (on_editor_language_changed),
+ plugin);
}
static void
on_value_removed_current_editor (AnjutaPlugin *plugin, const gchar *name,
- gpointer data)
+ gpointer data)
{
- CppJavaPlugin *lang_plugin;
- lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (plugin);
- if (lang_plugin->current_editor)
- g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
- G_CALLBACK (on_editor_language_changed),
- plugin);
- if (IANJUTA_IS_EDITOR(lang_plugin->current_editor))
- uninstall_support (lang_plugin);
- lang_plugin->current_editor = NULL;
+ CppJavaPlugin *lang_plugin;
+ lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (plugin);
+ if (lang_plugin->current_editor)
+ g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
+ G_CALLBACK (on_editor_language_changed),
+ plugin);
+ if (IANJUTA_IS_EDITOR(lang_plugin->current_editor))
+ uninstall_support (lang_plugin);
+ lang_plugin->current_editor = NULL;
}
static void
on_swap_activate (GtkAction* action, gpointer data)
{
- GFile* file;
- CppJavaPlugin *lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (data);
- IAnjutaDocumentManager* docman =
- anjuta_shell_get_interface (ANJUTA_PLUGIN(lang_plugin)->shell,
- IAnjutaDocumentManager,
- NULL);
- if (!lang_plugin->current_editor || !docman)
- return;
-
- file = ianjuta_file_get_file (IANJUTA_FILE (lang_plugin->current_editor),
- NULL);
-
- GFile* new_file = language_support_get_header_file (
- IANJUTA_EDITOR (lang_plugin->current_editor));
-
- if (g_file_query_exists (new_file, NULL))
- {
- ianjuta_document_manager_goto_file_line (docman,
- new_file,
- -1,
- NULL);
- g_object_unref (new_file);
- }
-}
-
-static void
-on_auto_indent (GtkAction *action, gpointer data)
-{
- CppJavaPlugin *lang_plugin;
- IAnjutaEditor *editor;
- lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (data);
- editor = IANJUTA_EDITOR (lang_plugin->current_editor);
-
- cpp_auto_indentation (editor, lang_plugin, NULL, NULL);
+ GFile* file;
+ CppJavaPlugin *lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (data);
+ IAnjutaDocumentManager* docman =
+ anjuta_shell_get_interface (ANJUTA_PLUGIN(lang_plugin)->shell,
+ IAnjutaDocumentManager,
+ NULL);
+ if (!lang_plugin->current_editor || !docman)
+ return;
+
+// file = ianjuta_file_get_file (IANJUTA_FILE (lang_plugin->current_editor),
+// NULL);
+
+ file = language_support_get_header_file (
+ IANJUTA_EDITOR (lang_plugin->current_editor));
+
+ if (g_file_query_exists (file, NULL))
+ {
+ ianjuta_document_manager_goto_file_line (docman,
+ file,
+ -1,
+ NULL);
+ g_object_unref (file);
+ }
}
/* Automatic comments */
static gboolean
is_commented_multiline (IAnjutaEditor *editor,
- IAnjutaIterable *start,
- IAnjutaIterable *end)
+ IAnjutaIterable *start,
+ IAnjutaIterable *end)
{
- gchar *text;
- gboolean is_commented = TRUE;
-
- text = ianjuta_editor_get_text (editor, start, end, NULL);
- while (is_commented && !g_str_has_prefix (text, "/*"))
- {
- if (!ianjuta_iterable_previous (start, NULL))
- is_commented = FALSE;
- g_free (text);
- text = ianjuta_editor_get_text (editor, start, end, NULL);
- if (g_str_has_prefix (text, "*/"))
- is_commented = FALSE;
- }
- while (is_commented && !g_str_has_suffix (text, "*/"))
- {
- if (!ianjuta_iterable_next (end, NULL))
- is_commented = FALSE;
- g_free (text);
- text = ianjuta_editor_get_text (editor, start, end, NULL);
- if (g_str_has_suffix (text, "/*"))
- is_commented = FALSE;
- }
-
- g_free (text);
- return is_commented;
+ gchar *text;
+ gboolean is_commented = TRUE;
+
+ text = ianjuta_editor_get_text (editor, start, end, NULL);
+ while (is_commented && !g_str_has_prefix (text, "/*"))
+ {
+ if (!ianjuta_iterable_previous (start, NULL))
+ is_commented = FALSE;
+ g_free (text);
+ text = ianjuta_editor_get_text (editor, start, end, NULL);
+ if (g_str_has_prefix (text, "*/"))
+ is_commented = FALSE;
+ }
+ while (is_commented && !g_str_has_suffix (text, "*/"))
+ {
+ if (!ianjuta_iterable_next (end, NULL))
+ is_commented = FALSE;
+ g_free (text);
+ text = ianjuta_editor_get_text (editor, start, end, NULL);
+ if (g_str_has_suffix (text, "/*"))
+ is_commented = FALSE;
+ }
+
+ g_free (text);
+ return is_commented;
}
static void
toggle_comment_multiline (IAnjutaEditor *editor,
- IAnjutaIterable *start,
- IAnjutaIterable *end)
+ IAnjutaIterable *start,
+ IAnjutaIterable *end)
{
- IAnjutaIterable *start_copy, *end_copy;
- gchar *text;
- gboolean is_commented;
-
- start_copy = ianjuta_iterable_clone (start, NULL);
- end_copy = ianjuta_iterable_clone (end, NULL);
- is_commented = is_commented_multiline (editor, start_copy, end_copy);
- text = ianjuta_editor_get_text (editor, start_copy, end_copy, NULL);
-
- if (is_commented)
- {
- ianjuta_editor_erase (editor, start_copy, end_copy, NULL);
- ianjuta_editor_insert (editor, start_copy, text + 2,
- (strlen (text) - 4), NULL);
- }
- else
- {
- ianjuta_editor_insert (editor, end, "*/", -1, NULL);
- ianjuta_editor_insert (editor, start, "/*", -1, NULL);
- }
-
- g_object_unref (start_copy);
- g_object_unref (end_copy);
- g_free (text);
+ IAnjutaIterable *start_copy, *end_copy;
+ gchar *text;
+ gboolean is_commented;
+
+ start_copy = ianjuta_iterable_clone (start, NULL);
+ end_copy = ianjuta_iterable_clone (end, NULL);
+ is_commented = is_commented_multiline (editor, start_copy, end_copy);
+ text = ianjuta_editor_get_text (editor, start_copy, end_copy, NULL);
+
+ if (is_commented)
+ {
+ ianjuta_editor_erase (editor, start_copy, end_copy, NULL);
+ ianjuta_editor_insert (editor, start_copy, text + 2,
+ (strlen (text) - 4), NULL);
+ }
+ else
+ {
+ ianjuta_editor_insert (editor, end, "*/", -1, NULL);
+ ianjuta_editor_insert (editor, start, "/*", -1, NULL);
+ }
+
+ g_object_unref (start_copy);
+ g_object_unref (end_copy);
+ g_free (text);
}
static void
toggle_comment_singleline (CppJavaPlugin *plugin, IAnjutaEditor *editor,
- gint line)
+ gint line)
{
- IAnjutaIterable *begin, *end, *begin_copy, *end_copy;
- gchar *text, *text_stripped, **text_diff = NULL;
-
- begin = ianjuta_editor_get_line_begin_position (editor, line, NULL);
- end = ianjuta_editor_get_line_end_position (editor, line, NULL);
- begin_copy = ianjuta_iterable_clone (begin, NULL);
- end_copy = ianjuta_iterable_clone (end, NULL);
-
- if (is_commented_multiline (editor, begin_copy, end_copy))
- {
- toggle_comment_multiline (editor, begin_copy, end_copy);
- g_object_unref (begin);
- g_object_unref (end);
- g_object_unref (begin_copy);
- g_object_unref (end_copy);
- return;
- }
- g_object_unref (begin_copy);
- g_object_unref (end_copy);
-
- text = ianjuta_editor_get_text (editor, begin, end, NULL);
- text_stripped = g_strstrip (g_strdup (text));
- text_diff = g_strsplit (text, text_stripped, 2);
-
- if (plugin->current_language &&
- (g_str_equal (plugin->current_language, "C")))
- {
- if (g_str_has_prefix (text_stripped, "/*") &&
- g_str_has_suffix (text_stripped, "*/"))
- {
- ianjuta_editor_erase (editor, begin, end, NULL);
- ianjuta_editor_insert (editor, begin, text_stripped + 2,
- (strlen (text_stripped) - 4), NULL);
- if (text_diff != NULL)
- ianjuta_editor_insert (editor, begin, *text_diff, -1, NULL);
- }
- else
- {
- ianjuta_editor_insert (editor, end, "*/", -1, NULL);
- ianjuta_editor_insert (editor, begin, "/*", -1, NULL);
- }
- }
- else
- {
- if (g_str_has_prefix (text_stripped, "//"))
- {
- ianjuta_editor_erase (editor, begin, end, NULL);
- ianjuta_editor_insert (editor, begin, text_stripped + 2, -1, NULL);
- if (text_diff != NULL)
- ianjuta_editor_insert (editor, begin, *text_diff, -1, NULL);
- }
- else
- {
- ianjuta_editor_insert (editor, begin, "//", -1, NULL);
- }
- }
-
- g_object_unref (begin);
- g_object_unref (end);
- g_free (text);
- g_free (text_stripped);
- g_strfreev (text_diff);
+ IAnjutaIterable *begin, *end, *begin_copy, *end_copy;
+ gchar *text, *text_stripped, **text_diff = NULL;
+
+ begin = ianjuta_editor_get_line_begin_position (editor, line, NULL);
+ end = ianjuta_editor_get_line_end_position (editor, line, NULL);
+ begin_copy = ianjuta_iterable_clone (begin, NULL);
+ end_copy = ianjuta_iterable_clone (end, NULL);
+
+ if (is_commented_multiline (editor, begin_copy, end_copy))
+ {
+ toggle_comment_multiline (editor, begin_copy, end_copy);
+ g_object_unref (begin);
+ g_object_unref (end);
+ g_object_unref (begin_copy);
+ g_object_unref (end_copy);
+ return;
+ }
+ g_object_unref (begin_copy);
+ g_object_unref (end_copy);
+
+ text = ianjuta_editor_get_text (editor, begin, end, NULL);
+ text_stripped = g_strstrip (g_strdup (text));
+ text_diff = g_strsplit (text, text_stripped, 2);
+
+ if (plugin->current_language &&
+ (g_str_equal (plugin->current_language, "C")))
+ {
+ if (g_str_has_prefix (text_stripped, "/*") &&
+ g_str_has_suffix (text_stripped, "*/"))
+ {
+ ianjuta_editor_erase (editor, begin, end, NULL);
+ ianjuta_editor_insert (editor, begin, text_stripped + 2,
+ (strlen (text_stripped) - 4), NULL);
+ if (text_diff != NULL)
+ ianjuta_editor_insert (editor, begin, *text_diff, -1, NULL);
+ }
+ else
+ {
+ ianjuta_editor_insert (editor, end, "*/", -1, NULL);
+ ianjuta_editor_insert (editor, begin, "/*", -1, NULL);
+ }
+ }
+ else
+ {
+ if (g_str_has_prefix (text_stripped, "//"))
+ {
+ ianjuta_editor_erase (editor, begin, end, NULL);
+ ianjuta_editor_insert (editor, begin, text_stripped + 2, -1, NULL);
+ if (text_diff != NULL)
+ ianjuta_editor_insert (editor, begin, *text_diff, -1, NULL);
+ }
+ else
+ {
+ ianjuta_editor_insert (editor, begin, "//", -1, NULL);
+ }
+ }
+
+ g_object_unref (begin);
+ g_object_unref (end);
+ g_free (text);
+ g_free (text_stripped);
+ g_strfreev (text_diff);
}
static void
on_toggle_comment (GtkAction *action, gpointer data)
{
- gint line;
- gboolean has_selection;
-
- CppJavaPlugin *lang_plugin;
- IAnjutaEditor *editor;
- lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (data);
- editor = IANJUTA_EDITOR (lang_plugin->current_editor);
-
- ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT(editor), NULL);
-
- has_selection = ianjuta_editor_selection_has_selection
- (IANJUTA_EDITOR_SELECTION (editor), NULL);
- if (has_selection)
- {
- IAnjutaIterable *sel_start, *sel_end;
- sel_start = ianjuta_editor_selection_get_start (IANJUTA_EDITOR_SELECTION (editor),
- NULL);
- sel_end = ianjuta_editor_selection_get_end (IANJUTA_EDITOR_SELECTION (editor),
- NULL);
- toggle_comment_multiline (editor, sel_start, sel_end);
- g_object_unref (sel_start);
- g_object_unref (sel_end);
- }
- else
- {
- line = ianjuta_editor_get_lineno (IANJUTA_EDITOR(editor), NULL);
- toggle_comment_singleline (lang_plugin, editor, line);
- }
- ianjuta_document_end_undo_action (IANJUTA_DOCUMENT(editor), NULL);
+ gint line;
+ gboolean has_selection;
+
+ CppJavaPlugin *lang_plugin;
+ IAnjutaEditor *editor;
+ lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (data);
+ editor = IANJUTA_EDITOR (lang_plugin->current_editor);
+
+ ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT(editor), NULL);
+
+ has_selection = ianjuta_editor_selection_has_selection
+ (IANJUTA_EDITOR_SELECTION (editor), NULL);
+ if (has_selection)
+ {
+ IAnjutaIterable *sel_start, *sel_end;
+ sel_start = ianjuta_editor_selection_get_start (IANJUTA_EDITOR_SELECTION (editor),
+ NULL);
+ sel_end = ianjuta_editor_selection_get_end (IANJUTA_EDITOR_SELECTION (editor),
+ NULL);
+ toggle_comment_multiline (editor, sel_start, sel_end);
+ g_object_unref (sel_start);
+ g_object_unref (sel_end);
+ }
+ else
+ {
+ line = ianjuta_editor_get_lineno (IANJUTA_EDITOR(editor), NULL);
+ toggle_comment_singleline (lang_plugin, editor, line);
+ }
+ ianjuta_document_end_undo_action (IANJUTA_DOCUMENT(editor), NULL);
}
/* Plugin */
static GtkActionEntry actions[] = {
- {
- "ActionMenuEdit",
- NULL, N_("_Edit"),
- NULL, NULL, NULL
- },
- {
- "ActionEditAutoindent",
- ANJUTA_STOCK_AUTOINDENT,
- N_("Auto-Indent"), "<control>i",
- N_("Auto-indent current line or selection based on indentation settings"),
- G_CALLBACK (on_auto_indent)
- },
- {
- "ActionEditToggleComment",
- ANJUTA_STOCK_COMMENT,
- N_("Comment/Uncomment"), "<control>m",
- N_("Comment or uncomment current selection"),
- G_CALLBACK (on_toggle_comment)
- },
- { "ActionFileSwap",
- ANJUTA_STOCK_SWAP,
- N_("Swap .h/.c"), NULL,
- N_("Swap C header and source files"),
- G_CALLBACK (on_swap_activate)
- }
+ {
+ "ActionMenuEdit",
+ NULL, N_("_Edit"),
+ NULL, NULL, NULL
+ },
+ {
+ "ActionEditToggleComment",
+ ANJUTA_STOCK_COMMENT,
+ N_("Comment/Uncomment"), "<control>m",
+ N_("Comment or uncomment current selection"),
+ G_CALLBACK (on_toggle_comment)
+ },
+ { "ActionFileSwap",
+ ANJUTA_STOCK_SWAP,
+ N_("Swap .h/.c"), NULL,
+ N_("Swap C header and source files"),
+ G_CALLBACK (on_swap_activate)
+ }
};
static void
register_stock_icons (AnjutaPlugin *plugin)
{
- static gboolean registered = FALSE;
+ static gboolean registered = FALSE;
- if (registered)
- return;
- registered = TRUE;
+ if (registered)
+ return;
+ registered = TRUE;
- /* Register stock icons */
- BEGIN_REGISTER_ICON (plugin);
- REGISTER_ICON_FULL (ANJUTA_PIXMAP_SWAP, ANJUTA_STOCK_SWAP);
- REGISTER_ICON_FULL (ANJUTA_PIXMAP_AUTOINDENT, ANJUTA_STOCK_AUTOINDENT);
- END_REGISTER_ICON;
+ /* Register stock icons */
+ BEGIN_REGISTER_ICON (plugin);
+ REGISTER_ICON_FULL (ANJUTA_PIXMAP_SWAP, ANJUTA_STOCK_SWAP);
+ REGISTER_ICON_FULL (ANJUTA_PIXMAP_AUTOINDENT, ANJUTA_STOCK_AUTOINDENT);
+ END_REGISTER_ICON;
}
static gboolean
cpp_java_plugin_activate_plugin (AnjutaPlugin *plugin)
{
- AnjutaUI *ui;
- CppJavaPlugin *lang_plugin;
- static gboolean initialized = FALSE;
-
- lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (plugin);
-
- DEBUG_PRINT ("%s", "AnjutaLanguageCppJavaPlugin: Activating plugin ...");
-
- if (!initialized)
- {
- register_stock_icons (plugin);
- }
-
- ui = anjuta_shell_get_ui (plugin->shell, NULL);
- lang_plugin->action_group =
- anjuta_ui_add_action_group_entries (ui, "ActionGroupCppJavaAssist",
- _("C++/Java Assistance"),
- actions,
- G_N_ELEMENTS (actions),
- GETTEXT_PACKAGE, TRUE,
- plugin);
- lang_plugin->uiid = anjuta_ui_merge (ui, UI_FILE);
-
- lang_plugin->editor_watch_id =
- anjuta_plugin_add_watch (plugin,
- IANJUTA_DOCUMENT_MANAGER_CURRENT_DOCUMENT,
- on_value_added_current_editor,
- on_value_removed_current_editor,
- plugin);
-
- initialized = FALSE;
- return TRUE;
+ AnjutaUI *ui;
+ CppJavaPlugin *lang_plugin;
+ static gboolean initialized = FALSE;
+
+ lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (plugin);
+
+ DEBUG_PRINT ("%s", "AnjutaLanguageCppJavaPlugin: Activating plugin ...");
+
+ if (!initialized)
+ {
+ register_stock_icons (plugin);
+ }
+
+ ui = anjuta_shell_get_ui (plugin->shell, NULL);
+ lang_plugin->action_group =
+ anjuta_ui_add_action_group_entries (ui, "ActionGroupCppJavaAssist",
+ _("C++/Java Assistance"),
+ actions,
+ G_N_ELEMENTS (actions),
+ GETTEXT_PACKAGE, TRUE,
+ plugin);
+ lang_plugin->uiid = anjuta_ui_merge (ui, UI_FILE);
+
+ lang_plugin->editor_watch_id =
+ anjuta_plugin_add_watch (plugin,
+ IANJUTA_DOCUMENT_MANAGER_CURRENT_DOCUMENT,
+ on_value_added_current_editor,
+ on_value_removed_current_editor,
+ plugin);
+
+ initialized = FALSE;
+ return TRUE;
}
static gboolean
cpp_java_plugin_deactivate_plugin (AnjutaPlugin *plugin)
{
- AnjutaUI *ui;
- CppJavaPlugin *lang_plugin;
- lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (plugin);
-
- anjuta_plugin_remove_watch (plugin,
- lang_plugin->editor_watch_id,
- TRUE);
-
- ui = anjuta_shell_get_ui (plugin->shell, NULL);
- anjuta_ui_unmerge (ui, lang_plugin->uiid);
- anjuta_ui_remove_action_group (ui, lang_plugin->action_group);
-
- lang_plugin->action_group = NULL;
- lang_plugin->uiid = 0;
- DEBUG_PRINT ("%s", "AnjutaLanguageCppJavaPlugin: Deactivated plugin.");
- return TRUE;
+ AnjutaUI *ui;
+ CppJavaPlugin *lang_plugin;
+ lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (plugin);
+
+ anjuta_plugin_remove_watch (plugin,
+ lang_plugin->editor_watch_id,
+ TRUE);
+
+ ui = anjuta_shell_get_ui (plugin->shell, NULL);
+ anjuta_ui_unmerge (ui, lang_plugin->uiid);
+ anjuta_ui_remove_action_group (ui, lang_plugin->action_group);
+
+ lang_plugin->action_group = NULL;
+ lang_plugin->uiid = 0;
+ DEBUG_PRINT ("%s", "AnjutaLanguageCppJavaPlugin: Deactivated plugin.");
+ return TRUE;
}
static void
cpp_java_plugin_finalize (GObject *obj)
{
- /* CppJavaPlugin* plugin = ANJUTA_PLUGIN_CPP_JAVA (obj); */
+ /* CppJavaPlugin* plugin = ANJUTA_PLUGIN_CPP_JAVA (obj); */
- /* Finalization codes here */
- G_OBJECT_CLASS (parent_class)->finalize (obj);
+ /* Finalization codes here */
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
}
static void
cpp_java_plugin_dispose (GObject *obj)
{
- CppJavaPlugin* plugin = ANJUTA_PLUGIN_CPP_JAVA (obj);
- /* Disposition codes */
+ CppJavaPlugin* plugin = ANJUTA_PLUGIN_CPP_JAVA (obj);
+ /* Disposition codes */
- g_object_unref (plugin->settings);
- g_object_unref (plugin->editor_settings);
+ g_object_unref (plugin->settings);
+ g_object_unref (plugin->editor_settings);
- G_OBJECT_CLASS (parent_class)->dispose (obj);
+ G_OBJECT_CLASS (parent_class)->dispose (obj);
}
static void
cpp_java_plugin_instance_init (GObject *obj)
{
- CppJavaPlugin *plugin = ANJUTA_PLUGIN_CPP_JAVA (obj);
- plugin->action_group = NULL;
- plugin->current_editor = NULL;
- plugin->current_language = NULL;
- plugin->editor_watch_id = 0;
- plugin->uiid = 0;
- plugin->assist = NULL;
- plugin->settings = g_settings_new (PREF_SCHEMA);
- plugin->editor_settings = g_settings_new (ANJUTA_PREF_SCHEMA_PREFIX IANJUTA_EDITOR_PREF_SCHEMA);
- plugin->packages = NULL;
+ CppJavaPlugin *plugin = ANJUTA_PLUGIN_CPP_JAVA (obj);
+ plugin->action_group = NULL;
+ plugin->current_editor = NULL;
+ plugin->current_language = NULL;
+ plugin->editor_watch_id = 0;
+ plugin->uiid = 0;
+ plugin->assist = NULL;
+ plugin->settings = g_settings_new (PREF_SCHEMA);
+ plugin->editor_settings = g_settings_new (ANJUTA_PREF_SCHEMA_PREFIX IANJUTA_EDITOR_PREF_SCHEMA);
+ plugin->packages = NULL;
}
static void
cpp_java_plugin_class_init (GObjectClass *klass)
{
- AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);
+ AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
+ parent_class = g_type_class_peek_parent (klass);
- plugin_class->activate = cpp_java_plugin_activate_plugin;
- plugin_class->deactivate = cpp_java_plugin_deactivate_plugin;
- klass->finalize = cpp_java_plugin_finalize;
- klass->dispose = cpp_java_plugin_dispose;
+ plugin_class->activate = cpp_java_plugin_activate_plugin;
+ plugin_class->deactivate = cpp_java_plugin_deactivate_plugin;
+ klass->finalize = cpp_java_plugin_finalize;
+ klass->dispose = cpp_java_plugin_dispose;
}
#define PREF_WIDGET_SPACE "preferences:completion-space-after-func"
@@ -1568,213 +1243,192 @@ static void
on_autocompletion_toggled (GtkToggleButton* button,
CppJavaPlugin* plugin)
{
- GtkWidget* widget;
- gboolean sensitive = gtk_toggle_button_get_active (button);
-
- widget = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_SPACE));
- gtk_widget_set_sensitive (widget, sensitive);
- widget = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_BRACE));
- gtk_widget_set_sensitive (widget, sensitive);
- widget = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_CLOSEBRACE));
- gtk_widget_set_sensitive (widget, sensitive);
+ GtkWidget* widget;
+ gboolean sensitive = gtk_toggle_button_get_active (button);
+
+ widget = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_SPACE));
+ gtk_widget_set_sensitive (widget, sensitive);
+ widget = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_BRACE));
+ gtk_widget_set_sensitive (widget, sensitive);
+ widget = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_CLOSEBRACE));
+ gtk_widget_set_sensitive (widget, sensitive);
}
static void
cpp_java_plugin_select_user_packages (CppJavaPlugin* plugin,
AnjutaPkgConfigChooser* chooser)
{
- gchar* user_packages = g_settings_get_string (plugin->settings,
- PREF_USER_PACKAGES);
- GStrv pkgs = g_strsplit (user_packages, ";", -1);
- gchar** pkg;
- GList* packages = NULL;
- for (pkg = pkgs; *pkg != NULL; pkg++)
- {
- packages = g_list_append (packages, *pkg);
- }
- anjuta_pkg_config_chooser_set_active_packages (chooser,
- packages);
- g_strfreev (pkgs);
- g_free (user_packages);
- g_list_free (packages);
+ gchar* user_packages = g_settings_get_string (plugin->settings,
+ PREF_USER_PACKAGES);
+ GStrv pkgs = g_strsplit (user_packages, ";", -1);
+ gchar** pkg;
+ GList* packages = NULL;
+ for (pkg = pkgs; *pkg != NULL; pkg++)
+ {
+ packages = g_list_append (packages, *pkg);
+ }
+ anjuta_pkg_config_chooser_set_active_packages (chooser,
+ packages);
+ g_strfreev (pkgs);
+ g_free (user_packages);
+ g_list_free (packages);
}
static void
on_project_packages_toggled (GtkToggleButton* button,
CppJavaPlugin* plugin)
{
- GtkWidget* pkg_config;
- gboolean active = gtk_toggle_button_get_active (button);
- pkg_config = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_PKG_CONFIG));
-
- gtk_widget_set_sensitive (pkg_config, !active);
-
- anjuta_pkg_config_chooser_set_active_packages (ANJUTA_PKG_CONFIG_CHOOSER (pkg_config),
- NULL);
- if (!active)
- {
- anjuta_pkg_config_chooser_show_active_only (ANJUTA_PKG_CONFIG_CHOOSER (pkg_config),
- FALSE);
- cpp_java_plugin_select_user_packages (plugin, ANJUTA_PKG_CONFIG_CHOOSER (pkg_config));
- cpp_packages_load (plugin->packages, TRUE);
- }
- else
- {
- anjuta_pkg_config_chooser_set_active_packages (ANJUTA_PKG_CONFIG_CHOOSER (pkg_config),
- NULL);
- anjuta_pkg_config_chooser_show_active_only (ANJUTA_PKG_CONFIG_CHOOSER (pkg_config),
- TRUE);
-
- }
+ GtkWidget* pkg_config;
+ gboolean active = gtk_toggle_button_get_active (button);
+ pkg_config = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_PKG_CONFIG));
+
+ gtk_widget_set_sensitive (pkg_config, !active);
+
+ anjuta_pkg_config_chooser_set_active_packages (ANJUTA_PKG_CONFIG_CHOOSER (pkg_config),
+ NULL);
+ if (!active)
+ {
+ anjuta_pkg_config_chooser_show_active_only (ANJUTA_PKG_CONFIG_CHOOSER (pkg_config),
+ FALSE);
+ cpp_java_plugin_select_user_packages (plugin, ANJUTA_PKG_CONFIG_CHOOSER (pkg_config));
+ cpp_packages_load (plugin->packages, TRUE);
+ }
+ else
+ {
+ anjuta_pkg_config_chooser_set_active_packages (ANJUTA_PKG_CONFIG_CHOOSER (pkg_config),
+ NULL);
+ anjuta_pkg_config_chooser_show_active_only (ANJUTA_PKG_CONFIG_CHOOSER (pkg_config),
+ TRUE);
+ }
}
static void
cpp_java_plugin_update_user_packages (CppJavaPlugin* plugin,
AnjutaPkgConfigChooser* chooser)
{
- GList* pkg;
- GList* packages = anjuta_pkg_config_chooser_get_active_packages (chooser);
- GString* pkg_string = g_string_new (NULL);
-
- for (pkg = packages; pkg != NULL; pkg = g_list_next (pkg))
- {
- if (strlen (pkg_string->str))
- {
- pkg_string = g_string_append_c (pkg_string, ';');
- }
- pkg_string = g_string_append (pkg_string, pkg->data);
- }
- g_settings_set_string (plugin->settings, PREF_USER_PACKAGES,
- pkg_string->str);
- g_string_free (pkg_string, TRUE);
+ GList* pkg;
+ GList* packages = anjuta_pkg_config_chooser_get_active_packages (chooser);
+ GString* pkg_string = g_string_new (NULL);
+
+ for (pkg = packages; pkg != NULL; pkg = g_list_next (pkg))
+ {
+ if (strlen (pkg_string->str))
+ {
+ pkg_string = g_string_append_c (pkg_string, ';');
+ }
+ pkg_string = g_string_append (pkg_string, pkg->data);
+ }
+ g_settings_set_string (plugin->settings, PREF_USER_PACKAGES,
+ pkg_string->str);
+ g_string_free (pkg_string, TRUE);
}
static void
on_package_activated (AnjutaPkgConfigChooser *self, const gchar* package,
- gpointer data)
+ gpointer data)
{
- CppJavaPlugin* plugin;
+ CppJavaPlugin* plugin;
- plugin = ANJUTA_PLUGIN_CPP_JAVA (data);
+ plugin = ANJUTA_PLUGIN_CPP_JAVA (data);
- g_message ("Activate package");
+ g_message ("Activate package");
- cpp_java_plugin_update_user_packages (plugin, self);
- cpp_packages_load (plugin->packages, TRUE);
+ cpp_java_plugin_update_user_packages (plugin, self);
+ cpp_packages_load (plugin->packages, TRUE);
}
static void
on_package_deactivated (AnjutaPkgConfigChooser *self, const gchar* package,
- gpointer data)
+ gpointer data)
{
- CppJavaPlugin* plugin;
- IAnjutaSymbolManager *isymbol_manager;
- gchar* version;
-
- plugin = ANJUTA_PLUGIN_CPP_JAVA (data);
-
- DEBUG_PRINT ("deactivated %s", package);
-
- isymbol_manager = anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin)->shell,
- IAnjutaSymbolManager,
- NULL);
- version = anjuta_pkg_config_get_version (package);
- if (version)
- {
- ianjuta_symbol_manager_deactivate_package (isymbol_manager,
- package,
- version,
- NULL);
- }
- g_free (version);
-
- cpp_java_plugin_update_user_packages (plugin, self);
+ CppJavaPlugin* plugin;
+ IAnjutaSymbolManager *isymbol_manager;
+ gchar* version;
+
+ plugin = ANJUTA_PLUGIN_CPP_JAVA (data);
+
+ DEBUG_PRINT ("deactivated %s", package);
+
+ isymbol_manager = anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin)->shell,
+ IAnjutaSymbolManager,
+ NULL);
+ version = anjuta_pkg_config_get_version (package);
+ if (version)
+ {
+ ianjuta_symbol_manager_deactivate_package (isymbol_manager,
+ package,
+ version,
+ NULL);
+ }
+ g_free (version);
+
+ cpp_java_plugin_update_user_packages (plugin, self);
}
static void
ipreferences_merge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
- GError** e)
+ GError** e)
{
- GError* error = NULL;
- CppJavaPlugin* plugin = ANJUTA_PLUGIN_CPP_JAVA (ipref);
- plugin->bxml = gtk_builder_new ();
- GtkWidget* toggle;
- GtkWidget* pkg_config;
-
- /* Add preferences */
- if (!gtk_builder_add_from_file (plugin->bxml, PREFS_BUILDER, &error))
- {
- g_warning ("Couldn't load builder file: %s", error->message);
- g_error_free (error);
- }
- anjuta_preferences_add_from_builder (prefs,
- plugin->bxml, plugin->settings,
- "preferences", _("C/C++/Java/Vala"),
- ICON_FILE);
- toggle = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_AUTO));
- g_signal_connect (toggle, "toggled", G_CALLBACK (on_autocompletion_toggled),
- plugin);
- on_autocompletion_toggled (GTK_TOGGLE_BUTTON (toggle), plugin);
-
- toggle = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_PACKAGES));
- g_signal_connect (toggle, "toggled", G_CALLBACK (on_project_packages_toggled),
- plugin);
- on_project_packages_toggled (GTK_TOGGLE_BUTTON (toggle), plugin);
-
- pkg_config = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_PKG_CONFIG));
- anjuta_pkg_config_chooser_show_active_column (ANJUTA_PKG_CONFIG_CHOOSER (pkg_config),
- TRUE);
-
- g_signal_connect (G_OBJECT (pkg_config), "package-activated",
- G_CALLBACK (on_package_activated), plugin);
-
- g_signal_connect (G_OBJECT (pkg_config), "package-deactivated",
- G_CALLBACK (on_package_deactivated), plugin);
-
- if (!g_settings_get_boolean (plugin->settings,
- PREF_PROJECT_PACKAGES))
- cpp_java_plugin_select_user_packages (plugin, ANJUTA_PKG_CONFIG_CHOOSER (pkg_config));
-
- gtk_widget_show (pkg_config);
+ GError* error = NULL;
+ CppJavaPlugin* plugin = ANJUTA_PLUGIN_CPP_JAVA (ipref);
+ plugin->bxml = gtk_builder_new ();
+ GtkWidget* toggle;
+ GtkWidget* pkg_config;
+
+ /* Add preferences */
+ if (!gtk_builder_add_from_file (plugin->bxml, PREFS_BUILDER, &error))
+ {
+ g_warning ("Couldn't load builder file: %s", error->message);
+ g_error_free (error);
+ }
+ anjuta_preferences_add_from_builder (prefs,
+ plugin->bxml, plugin->settings,
+ "preferences", _("C/C++/Java/Vala"),
+ ICON_FILE);
+ toggle = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_AUTO));
+ g_signal_connect (toggle, "toggled", G_CALLBACK (on_autocompletion_toggled),
+ plugin);
+ on_autocompletion_toggled (GTK_TOGGLE_BUTTON (toggle), plugin);
+
+ toggle = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_PACKAGES));
+ g_signal_connect (toggle, "toggled", G_CALLBACK (on_project_packages_toggled),
+ plugin);
+ on_project_packages_toggled (GTK_TOGGLE_BUTTON (toggle), plugin);
+
+ pkg_config = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_PKG_CONFIG));
+ anjuta_pkg_config_chooser_show_active_column (ANJUTA_PKG_CONFIG_CHOOSER (pkg_config),
+ TRUE);
+
+ g_signal_connect (G_OBJECT (pkg_config), "package-activated",
+ G_CALLBACK (on_package_activated), plugin);
+
+ g_signal_connect (G_OBJECT (pkg_config), "package-deactivated",
+ G_CALLBACK (on_package_deactivated), plugin);
+
+ if (!g_settings_get_boolean (plugin->settings,
+ PREF_PROJECT_PACKAGES))
+ cpp_java_plugin_select_user_packages (plugin, ANJUTA_PKG_CONFIG_CHOOSER (pkg_config));
+
+ gtk_widget_show (pkg_config);
}
static void
ipreferences_unmerge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
- GError** e)
+ GError** e)
{
- CppJavaPlugin* plugin = ANJUTA_PLUGIN_CPP_JAVA (ipref);
- anjuta_preferences_remove_page(prefs, _("C/C++/Java/Vala"));
- g_object_unref (plugin->bxml);
+ CppJavaPlugin* plugin = ANJUTA_PLUGIN_CPP_JAVA (ipref);
+ anjuta_preferences_remove_page(prefs, _("C/C++/Java/Vala"));
+ g_object_unref (plugin->bxml);
}
static void
ipreferences_iface_init (IAnjutaPreferencesIface* iface)
{
- iface->merge = ipreferences_merge;
- iface->unmerge = ipreferences_unmerge;
-}
-
-static void
-iindenter_indent (IAnjutaIndenter* indenter,
- IAnjutaIterable* start,
- IAnjutaIterable* end,
- GError** e)
-{
- CppJavaPlugin* plugin = ANJUTA_PLUGIN_CPP_JAVA (indenter);
-
- cpp_auto_indentation (IANJUTA_EDITOR (plugin->current_editor),
- plugin,
- start, end);
-}
-
-static void
-iindenter_iface_init (IAnjutaIndenterIface* iface)
-{
- iface->indent = iindenter_indent;
+ iface->merge = ipreferences_merge;
+ iface->unmerge = ipreferences_unmerge;
}
ANJUTA_PLUGIN_BEGIN (CppJavaPlugin, cpp_java_plugin);
ANJUTA_PLUGIN_ADD_INTERFACE(ipreferences, IANJUTA_TYPE_PREFERENCES);
-ANJUTA_PLUGIN_ADD_INTERFACE(iindenter, IANJUTA_TYPE_INDENTER);
ANJUTA_PLUGIN_END;
ANJUTA_SIMPLE_PLUGIN (CppJavaPlugin, cpp_java_plugin);
diff --git a/plugins/language-support-cpp-java/plugin.h b/plugins/language-support-cpp-java/plugin.h
index 1d4f02f..01fd416 100644
--- a/plugins/language-support-cpp-java/plugin.h
+++ b/plugins/language-support-cpp-java/plugin.h
@@ -60,15 +60,6 @@ struct _CppJavaPlugin {
gboolean support_installed;
const gchar *current_language;
- /* Adaptive indentation parameters */
- gint param_tab_size;
- gint param_use_spaces;
- gint param_statement_indentation;
- gint param_brace_indentation;
- gint param_case_indentation;
- gint param_label_indentation;
- gboolean smart_indentation;
-
/* Assist */
CppJavaAssist *assist;
CppFileType filetype;
diff --git a/plugins/language-support-python/Makefile.am b/plugins/language-support-python/Makefile.am
index 8789043..b38379b 100644
--- a/plugins/language-support-python/Makefile.am
+++ b/plugins/language-support-python/Makefile.am
@@ -1,21 +1,21 @@
# Plugin UI files
python_plugin_uidir = $(anjuta_ui_dir)
-python_plugin_ui_DATA = python-plugin.xml
+python_plugin_ui_DATA = anjuta-language-support-python.xml
# Plugin Glade file
python_plugin_gladedir = $(anjuta_glade_dir)
-python_plugin_glade_DATA = python-plugin-properties.ui
+python_plugin_glade_DATA = anjuta-language-support-python.ui
# Plugin Icon file
python_plugin_pixmapsdir = $(anjuta_image_dir)
-python_plugin_pixmaps_DATA = python_plugin.png
+python_plugin_pixmaps_DATA = anjuta-language-support-python-plugin.png
# Plugin Python Scripts
scriptsdir = $(anjuta_plugin_dir)
scripts_SCRIPTS = anjuta-python-autocomplete.py
# Plugin description file
-plugin_in_files = python-plugin.plugin.in
+plugin_in_files = anjuta-language-support-python.plugin.in
%.plugin: %.plugin.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
python_plugin_plugindir = $(anjuta_plugin_dir)
@@ -31,15 +31,15 @@ AM_CPPFLAGS = \
plugindir = $(anjuta_plugin_dir)
# The plugin
-plugin_LTLIBRARIES = libpython_plugin.la
+plugin_LTLIBRARIES = libanjuta-language-support-python.la
# Plugin sources
-libpython_plugin_la_SOURCES = plugin.c plugin.h python-assist.c python-assist.h python-utils.c python-utils.h python-indentation.c python-indentation.h
+libanjuta_language_support_python_la_SOURCES = plugin.c plugin.h python-assist.c python-assist.h
-libpython_plugin_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
+libanjuta_language_support_python_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
# Plugin dependencies
-libpython_plugin_la_LIBADD = \
+libanjuta_language_support_python_la_LIBADD = \
$(LIBANJUTA_LIBS)
gsettings_in_file = org.gnome.anjuta.plugins.python.gschema.xml.in
diff --git a/plugins/language-support-python/python_plugin.png b/plugins/language-support-python/anjuta-language-support-python-plugin.png
similarity index 100%
rename from plugins/language-support-python/python_plugin.png
rename to plugins/language-support-python/anjuta-language-support-python-plugin.png
diff --git a/plugins/language-support-python/anjuta-language-support-python.plugin.in b/plugins/language-support-python/anjuta-language-support-python.plugin.in
new file mode 100755
index 0000000..95a3a2b
--- /dev/null
+++ b/plugins/language-support-python/anjuta-language-support-python.plugin.in
@@ -0,0 +1,11 @@
+[Anjuta Plugin]
+Location=anjuta-language-support-python:PythonPlugin
+Icon=anjuta-language-support-python-plugin.png
+_Name=Python support Plugin
+_Description=Python support plugin for code completion etc.
+Interfaces=IAnjutaLanguageSupport,IAnjutaIndenter
+UserActivatable=no
+
+[Language Support]
+Languages=Python
+MimeTypes=text/x-python,application/x-extension-wsgi
diff --git a/plugins/language-support-python/anjuta-language-support-python.ui b/plugins/language-support-python/anjuta-language-support-python.ui
new file mode 100755
index 0000000..88c039c
--- /dev/null
+++ b/plugins/language-support-python/anjuta-language-support-python.ui
@@ -0,0 +1,270 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment2">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkWindow" id="python_preferences_dialog">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">window1</property>
+ <child>
+ <object class="GtkNotebook" id="preferences">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkFrame" id="frame45">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="label_xalign">0</property>
+ <property name="label_yalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkVBox" id="vbox1118">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkCheckButton" id="preferences:completion-enable">
+ <property name="label" translatable="yes">Enable code completion</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="border_width">5</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="preferences:completion-func-space">
+ <property name="label" translatable="yes">Add a space after function call autocompletion</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="border_width">5</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="preferences:completion-func-brace">
+ <property name="label" translatable="yes">Add '(' after function call autocompletion</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="border_width">5</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label12334">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="label" translatable="yes">Autocompletion</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="label_xalign">0</property>
+ <property name="label_yalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkCheckButton" id="preferences:calltip-enable">
+ <property name="label" translatable="yes">Show calltips</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="border_width">5</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Calltips</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Autocomplete</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="page1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">10</property>
+ <property name="column_spacing">5</property>
+ <property name="row_spacing">5</property>
+ <child>
+ <object class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Path: </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="preferences:interpreter-path">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Interpreter</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Environment</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/plugins/language-support-python/python-plugin.xml b/plugins/language-support-python/anjuta-language-support-python.xml
similarity index 80%
rename from plugins/language-support-python/python-plugin.xml
rename to plugins/language-support-python/anjuta-language-support-python.xml
index 248c9d4..c7f2ce7 100644
--- a/plugins/language-support-python/python-plugin.xml
+++ b/plugins/language-support-python/anjuta-language-support-python.xml
@@ -5,7 +5,6 @@
<placeholder name="PlaceholderOperationMenus">
<separator name="separator1"/>
<menuitem name="Autocomplete" action="ActionEditAutocomplete" />
- <menuitem name="AutoindentAction" action="ActionEditAutoindent" />
</placeholder>
</menu>
</menubar>
diff --git a/plugins/language-support-python/org.gnome.anjuta.plugins.python.gschema.xml.in b/plugins/language-support-python/org.gnome.anjuta.plugins.python.gschema.xml.in
index 1f1fc23..4bba68c 100644
--- a/plugins/language-support-python/org.gnome.anjuta.plugins.python.gschema.xml.in
+++ b/plugins/language-support-python/org.gnome.anjuta.plugins.python.gschema.xml.in
@@ -3,15 +3,6 @@
<key name="no-rope-warning" type="b">
<default>false</default>
</key>
- <key name="indent-automatic" type="b">
- <default>true</default>
- </key>
- <key name="indent-adaptive" type="b">
- <default>true</default>
- </key>
- <key name="indent-brace-size" type="i">
- <default>0</default>
- </key>
<key name="completion-enable" type="b">
<default>true</default>
</key>
diff --git a/plugins/language-support-python/plugin.c b/plugins/language-support-python/plugin.c
index f70770b..7003cba 100644
--- a/plugins/language-support-python/plugin.c
+++ b/plugins/language-support-python/plugin.c
@@ -25,11 +25,11 @@
#include <config.h>
#include <ctype.h>
#include <stdlib.h>
-#include <ctype.h>
#include <libanjuta/anjuta-shell.h>
#include <libanjuta/anjuta-debug.h>
#include <libanjuta/anjuta-launcher.h>
#include <libanjuta/anjuta-preferences.h>
+#include <libanjuta/anjuta-utils.h>
#include <libanjuta/interfaces/ianjuta-iterable.h>
#include <libanjuta/interfaces/ianjuta-document.h>
#include <libanjuta/interfaces/ianjuta-document-manager.h>
@@ -46,22 +46,11 @@
#include <libanjuta/interfaces/ianjuta-indenter.h>
#include "plugin.h"
-#include "python-utils.h"
#include "python-assist.h"
-#include "python-indentation.h"
-
-/* Pixmaps */
-#define ANJUTA_PIXMAP_COMPLETE "anjuta-complete"
-#define ANJUTA_PIXMAP_AUTOCOMPLETE "anjuta-complete-auto"
-#define ANJUTA_PIXMAP_AUTOINDENT "anjuta-indent-auto"
-#define ANJUTA_STOCK_SWAP "anjuta-swap"
-#define ANJUTA_STOCK_COMPLETE "anjuta-complete"
-#define ANJUTA_STOCK_AUTOCOMPLETE "anjuta-autocomplete"
-#define ANJUTA_STOCK_AUTOINDENT "anjuta-indent"
-#define UI_FILE PACKAGE_DATA_DIR"/ui/python-plugin.xml"
-#define PROPERTIES_FILE_UI PACKAGE_DATA_DIR"/glade/python-plugin-properties.ui"
-#define ICON_FILE "python_plugin.png"
+#define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-language-support-python.xml"
+#define PROPERTIES_FILE_UI PACKAGE_DATA_DIR"/glade/anjuta-language-support-python.ui"
+#define ICON_FILE "anjuta-language-support-python-plugin.png"
/* Preferences keys */
@@ -193,8 +182,6 @@ on_glade_drop (IAnjutaEditor* editor,
const gchar* widget;
const gchar* signal;
const gchar* handler;
- const gchar* user_data;
- gboolean swapped;
GList* names = NULL;
GString* str = g_string_new (NULL);
int i;
@@ -205,8 +192,6 @@ on_glade_drop (IAnjutaEditor* editor,
widget = data[0];
signal = data[1];
handler = data[2];
- user_data = data[3];
- swapped = g_str_equal (data[4], "1");
type = g_type_from_name (widget);
id = g_signal_lookup (signal, type);
@@ -247,16 +232,6 @@ on_glade_drop (IAnjutaEditor* editor,
}
static void
-on_editor_char_inserted_python (IAnjutaEditor *editor,
- IAnjutaIterable *insert_pos,
- gchar ch,
- PythonPlugin *plugin)
-{
- python_indent (plugin, editor, insert_pos, ch);
-}
-
-
-static void
install_support (PythonPlugin *lang_plugin)
{
IAnjutaLanguage* lang_manager =
@@ -281,20 +256,10 @@ install_support (PythonPlugin *lang_plugin)
ianjuta_language_get_name_from_editor (lang_manager,
IANJUTA_EDITOR_LANGUAGE (lang_plugin->current_editor), NULL);
- if (lang_plugin->current_language &&
- (g_str_equal (lang_plugin->current_language, "Python")))
- {
- g_signal_connect (lang_plugin->current_editor,
- "char-added",
- G_CALLBACK (on_editor_char_inserted_python),
- lang_plugin);
- }
- else
- {
+ if (!(lang_plugin->current_language &&
+ (g_str_equal (lang_plugin->current_language, "Python"))))
return;
- }
- python_indent_init (lang_plugin);
/* Disable editor intern auto-indent */
ianjuta_editor_set_auto_indent (IANJUTA_EDITOR(lang_plugin->current_editor),
FALSE, NULL);
@@ -302,7 +267,6 @@ install_support (PythonPlugin *lang_plugin)
if (IANJUTA_IS_EDITOR_ASSIST (lang_plugin->current_editor) )
{
AnjutaPlugin *plugin;
- AnjutaUI *ui;
IAnjutaEditorAssist* iassist;
const gchar *project_root;
@@ -311,7 +275,6 @@ install_support (PythonPlugin *lang_plugin)
check_support (lang_plugin);
plugin = ANJUTA_PLUGIN (lang_plugin);
- ui = anjuta_shell_get_ui (plugin->shell, NULL);
iassist = IANJUTA_EDITOR_ASSIST (lang_plugin->current_editor);
g_assert (lang_plugin->assist == NULL);
@@ -346,14 +309,6 @@ uninstall_support (PythonPlugin *lang_plugin)
if (!lang_plugin->support_installed)
return;
- if (lang_plugin->current_language &&
- (g_str_equal (lang_plugin->current_language, "Python")))
- {
- g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
- G_CALLBACK (on_editor_char_inserted_python),
- lang_plugin);
- }
-
if (lang_plugin->assist)
{
g_object_unref (lang_plugin->assist);
@@ -438,26 +393,11 @@ on_editor_removed (AnjutaPlugin *plugin, const gchar *name,
lang_plugin->current_language = NULL;
}
-static void
-on_auto_indent (GtkAction *action, gpointer data)
-{
- PythonPlugin *lang_plugin = ANJUTA_PLUGIN_PYTHON (data);
-
- python_indent_auto (lang_plugin, NULL, NULL);
-}
-
static GtkActionEntry actions[] = {
{
"ActionMenuEdit",
NULL, N_("_Edit"),
NULL, NULL, NULL
- },
- {
- "ActionEditAutoindent",
- GTK_STOCK_NEW, //ANJUTA_STOCK_AUTOINDENT,
- N_("Auto-Indent"), "<control>i",
- N_("Auto-indent current line or selection based on indentation settings"),
- G_CALLBACK (on_auto_indent)
}
};
@@ -483,15 +423,12 @@ static void
on_project_root_removed (AnjutaPlugin *plugin, const gchar *name,
gpointer user_data)
{
- AnjutaUI *ui;
PythonPlugin *python_plugin;
python_plugin = ANJUTA_PLUGIN_PYTHON (plugin);
g_free (python_plugin->project_root_directory);
python_plugin->project_root_directory = NULL;
-
- ui = anjuta_shell_get_ui (plugin->shell, NULL);
}
static gboolean
@@ -500,7 +437,6 @@ python_plugin_activate (AnjutaPlugin *plugin)
AnjutaUI *ui;
PythonPlugin *python_plugin;
- static gboolean initialized = FALSE;
python_plugin = (PythonPlugin*) plugin;
@@ -510,8 +446,7 @@ python_plugin_activate (AnjutaPlugin *plugin)
ui = anjuta_shell_get_ui (plugin->shell, NULL);
python_plugin->action_group =
-
- anjuta_ui_add_action_group_entries (ui, "ActionGroupPythonAssist",
+ anjuta_ui_add_action_group_entries (ui, "ActionGroupPythonAssist",
_("Python Assistance"),
actions,
G_N_ELEMENTS (actions),
@@ -519,8 +454,6 @@ python_plugin_activate (AnjutaPlugin *plugin)
plugin);
python_plugin->uiid = anjuta_ui_merge (ui, UI_FILE);
- initialized = FALSE;
-
/* Add watches */
python_plugin->project_root_watch_id = anjuta_plugin_add_watch (plugin,
IANJUTA_PROJECT_MANAGER_PROJECT_ROOT_URI,
@@ -641,28 +574,8 @@ ipreferences_iface_init (IAnjutaPreferencesIface* iface)
iface->unmerge = ipreferences_unmerge;
}
-static void
-iindenter_indent (IAnjutaIndenter* indenter,
- IAnjutaIterable* start,
- IAnjutaIterable* end,
- GError** e)
-{
- PythonPlugin* plugin = ANJUTA_PLUGIN_PYTHON (indenter);
-
- python_indent_auto (plugin,
- start, end);
-}
-
-static void
-iindenter_iface_init (IAnjutaIndenterIface* iface)
-{
- iface->indent = iindenter_indent;
-}
-
ANJUTA_PLUGIN_BEGIN (PythonPlugin, python_plugin);
ANJUTA_PLUGIN_ADD_INTERFACE(ipreferences, IANJUTA_TYPE_PREFERENCES);
-ANJUTA_PLUGIN_ADD_INTERFACE(iindenter, IANJUTA_TYPE_INDENTER);
ANJUTA_PLUGIN_END;
-
ANJUTA_SIMPLE_PLUGIN (PythonPlugin, python_plugin);
diff --git a/plugins/language-support-python/plugin.h b/plugins/language-support-python/plugin.h
index b3ca203..5a53c2b 100644
--- a/plugins/language-support-python/plugin.h
+++ b/plugins/language-support-python/plugin.h
@@ -64,15 +64,6 @@ struct _PythonPlugin{
/* Watches */
gint project_root_watch_id;
gint editor_watch_id;
-
-
- /* Adaptive indentation parameters */
- gint param_tab_size;
- gint param_use_spaces;
- gint param_statement_indentation;
- gint param_brace_indentation;
- gint param_case_indentation;
- gint param_label_indentation;
/* Assist */
PythonAssist *assist;
diff --git a/plugins/language-support-python/python-assist.c b/plugins/language-support-python/python-assist.c
index f2031e9..3736406 100644
--- a/plugins/language-support-python/python-assist.c
+++ b/plugins/language-support-python/python-assist.c
@@ -28,6 +28,7 @@
#include <glib/gi18n.h>
#include <libanjuta/anjuta-debug.h>
#include <libanjuta/anjuta-launcher.h>
+#include <libanjuta/anjuta-utils.h>
#include <libanjuta/interfaces/ianjuta-file.h>
#include <libanjuta/interfaces/ianjuta-editor.h>
#include <libanjuta/interfaces/ianjuta-editor-cell.h>
@@ -40,7 +41,6 @@
#include <libanjuta/interfaces/ianjuta-project-manager.h>
#include <libanjuta/anjuta-plugin.h>
#include "python-assist.h"
-#include "python-utils.h"
#define PREF_AUTOCOMPLETE_ENABLE "completion-enable"
#define PREF_AUTOCOMPLETE_SPACE_AFTER_FUNC "completion-func-space"
@@ -168,7 +168,7 @@ python_assist_get_scope_context (IAnjutaEditor* editor,
}
else if (ch == ')')
{
- if (!python_util_jump_to_matching_brace (iter, ch, SCOPE_BRACE_JUMP_LIMIT))
+ if (!anjuta_util_jump_to_matching_brace (iter, ch, SCOPE_BRACE_JUMP_LIMIT))
{
out_of_range = TRUE;
break;
@@ -685,14 +685,14 @@ python_assist_get_calltip_context (PythonAssist *assist,
ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter), 0, NULL);
if (ch == ')')
{
- if (!python_util_jump_to_matching_brace (iter, ')', -1))
+ if (!anjuta_util_jump_to_matching_brace (iter, ')', -1))
return NULL;
if (!ianjuta_iterable_previous (iter, NULL))
return NULL;
}
if (ch != '(')
{
- if (!python_util_jump_to_matching_brace (iter, ')',
+ if (!anjuta_util_jump_to_matching_brace (iter, ')',
BRACE_SEARCH_LIMIT))
return NULL;
}
@@ -737,14 +737,12 @@ python_assist_calltip (PythonAssist *assist)
{
IAnjutaEditor *editor;
IAnjutaIterable *iter;
- IAnjutaIterable *cur_pos;
gchar *call_context;
gint call_context_position;
editor = IANJUTA_EDITOR (assist->priv->iassist);
iter = ianjuta_editor_get_position (editor, NULL);
- cur_pos = ianjuta_iterable_clone (iter, NULL);
ianjuta_iterable_previous (iter, NULL);
call_context = python_assist_get_calltip_context (assist, iter);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]