[anjuta] Adapt the language-support-js plugin to the new interface IAnjutaLanguageProvider



commit 049d73ae9657ffc0c2f678a5e611afd65f02e12f
Author: Moritz LÃdecke <ritze skweez net>
Date:   Mon Jul 23 18:14:14 2012 +0200

    Adapt the language-support-js plugin to the new interface IAnjutaLanguageProvider

 plugins/language-support-js/Makefile.am            |    2 +-
 .../anjuta-language-javascript.ui                  |  540 ++++++++++++++------
 .../js-support-plugin.plugin.in                    |    2 +-
 .../org.gnome.anjuta.js.gschema.xml.in             |   22 -
 .../org.gnome.anjuta.plugins.js.gschema.xml.in     |   31 ++
 plugins/language-support-js/plugin.c               |  276 +++++++----
 plugins/language-support-js/plugin.h               |    8 +-
 plugins/language-support-js/prefs.h                |    4 +-
 8 files changed, 611 insertions(+), 274 deletions(-)
---
diff --git a/plugins/language-support-js/Makefile.am b/plugins/language-support-js/Makefile.am
index b78fd0e..7ff09e7 100644
--- a/plugins/language-support-js/Makefile.am
+++ b/plugins/language-support-js/Makefile.am
@@ -65,7 +65,7 @@ libjs_support_plugin_la_LIBADD = \
 	$(LIBANJUTA_LIBS) \
 	$(XML_LIBS)
 
-gsettings_in_file = org.gnome.anjuta.js.gschema.xml.in
+gsettings_in_file = org.gnome.anjuta.plugins.js.gschema.xml.in
 gsettings_SCHEMAS = $(gsettings_in_file:.xml.in=.xml)
 @INTLTOOL_XML_NOMERGE_RULE@
 @GSETTINGS_RULES@
diff --git a/plugins/language-support-js/anjuta-language-javascript.ui b/plugins/language-support-js/anjuta-language-javascript.ui
index d57be1b..2e0c540 100644
--- a/plugins/language-support-js/anjuta-language-javascript.ui
+++ b/plugins/language-support-js/anjuta-language-javascript.ui
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy toplevel-contextual -->
@@ -8,176 +8,369 @@
       <column type="gchararray"/>
     </columns>
   </object>
+  <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="value">4</property>
-    <property name="upper">10</property>
+    <property name="upper">100</property>
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
   <object class="GtkWindow" id="preferences_dialog">
+    <property name="can_focus">False</property>
     <property name="title" translatable="yes">window1</property>
     <child>
-      <object class="GtkVBox" id="vbox1">
+      <object class="GtkNotebook" id="preferences">
         <property name="visible">True</property>
-        <property name="orientation">vertical</property>
+        <property name="can_focus">True</property>
         <child>
-          <object class="GtkFrame" id="frame1">
+          <object class="GtkVBox" id="vbox1">
             <property name="visible">True</property>
-            <property name="label_xalign">0</property>
-            <property name="shadow_type">in</property>
+            <property name="can_focus">False</property>
             <child>
-              <object class="GtkAlignment" id="alignment1">
+              <object class="GtkFrame" id="frame45">
                 <property name="visible">True</property>
-                <property name="left_padding">12</property>
+                <property name="can_focus">False</property>
+                <property name="label_xalign">0</property>
+                <property name="label_yalign">0</property>
+                <property name="shadow_type">none</property>
                 <child>
-                  <object class="GtkHBox" id="hbox1">
+                  <object class="GtkVBox" id="vbox1118">
                     <property name="visible">True</property>
+                    <property name="can_focus">False</property>
                     <child>
-                      <object class="GtkTreeView" id="jsdirs_treeview">
+                      <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="model">jsdirs_liststore</property>
-                        <property name="enable_search">False</property>
-                        <property name="search_column">0</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>
+                    <child>
+                      <object class="GtkFrame" id="frame3">
+                        <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="GtkTreeViewColumn" id="text">
-                            <property name="title">Test</property>
+                          <object class="GtkAlignment" id="alignment3">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="left_padding">12</property>
                             <child>
-                              <object class="GtkCellRendererText" id="test-renderer"/>
-                              <attributes>
-                                <attribute name="text">0</attribute>
-                              </attributes>
+                              <object class="GtkVBox" id="vbox3">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <object class="GtkCheckButton" id="preferences:completion-space-after-func">
+                                    <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="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="use_underline">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="preferences:completion-brace-after-func">
+                                    <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="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="use_underline">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="preferences:completion-closebrace-after-func">
+                                    <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="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>
                           </object>
                         </child>
+                        <child type="label_item">
+                          <placeholder/>
+                        </child>
                       </object>
                       <packing>
-                        <property name="position">0</property>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</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="frame15">
+                <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="alignment153">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
                     <child>
-                      <object class="GtkVBox" id="vbox2">
+                      <object class="GtkHBox" id="hbox18">
                         <property name="visible">True</property>
-                        <property name="orientation">vertical</property>
+                        <property name="can_focus">False</property>
                         <child>
-                          <object class="GtkButton" id="jsdirs_add_button">
-                            <property name="label">gtk-add</property>
+                          <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">True</property>
-                            <property name="use_stock">True</property>
-                            <signal name="clicked" handler="on_jsdirs_add_button_clicked"/>
+                            <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>
+            <child>
+              <object class="GtkFrame" id="frame20">
+                <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="alignment13">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkHBox" id="hbox12">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <child>
-                          <object class="GtkButton" id="jsdirs_rm_button">
-                            <property name="label">gtk-remove</property>
+                          <object class="GtkCheckButton" id="preferences:javascript-missed">
+                            <property name="label" translatable="yes">Highlight missed semicolon</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
-                            <property name="receives_default">True</property>
-                            <property name="use_stock">True</property>
-                            <signal name="clicked" handler="on_jsdirs_rm_button_clicked"/>
+                            <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="position">1</property>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
                           </packing>
                         </child>
                       </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">1</property>
-                      </packing>
                     </child>
                   </object>
                 </child>
-              </object>
-            </child>
-            <child type="label">
-              <object class="GtkLabel" id="label1">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">JS Find dirs</property>
-                <attributes>
-                  <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
-                </attributes>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkHBox" id="hbox2">
-            <property name="visible">True</property>
-            <property name="spacing">12</property>
-            <child>
-              <object class="GtkLabel" id="label2">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">Gir repository's directory:   </property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">preferences_entry:text::0:javascript-girdir</property>
+                <child type="label">
+                  <object class="GtkLabel" id="label24">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Highlights</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                </child>
               </object>
               <packing>
                 <property name="expand">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="preferences_entry:text::0:javascript-girdir">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="invisible_char">&#x25CF;</property>
-              </object>
-              <packing>
-                <property name="position">1</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
               </packing>
             </child>
           </object>
           <packing>
-            <property name="position">1</property>
+            <property name="position">0</property>
           </packing>
         </child>
-        <child>
-          <object class="GtkHBox" id="hbox3">
+        <child type="tab">
+          <object class="GtkLabel" id="label1">
             <property name="visible">True</property>
-            <property name="spacing">12</property>
-            <child>
-              <object class="GtkLabel" id="label3">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">Gjs repository's directory:   </property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">preferences_entry:text::0:javascript-gjsdir</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="preferences_entry:text::0:javascript-gjsdir">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="invisible_char">&#x25CF;</property>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Autocomplete</property>
           </object>
           <packing>
-            <property name="position">2</property>
+            <property name="position">0</property>
+            <property name="tab_fill">False</property>
           </packing>
         </child>
         <child>
-          <object class="GtkHBox" id="hbox4">
+          <object class="GtkVBox" id="vbox23">
             <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="spacing">5</property>
             <child>
-              <object class="GtkLabel" id="label4">
+              <object class="GtkFrame" id="frame111">
                 <property name="visible">True</property>
-                <property name="label" translatable="yes">Min character for completion </property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkAlignment" id="alignment165">
+                    <property name="visible">True</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkHBox" id="hbox1">
+                        <property name="visible">True</property>
+                        <child>
+                          <object class="GtkTreeView" id="jsdirs_treeview">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="model">jsdirs_liststore</property>
+                            <property name="enable_search">False</property>
+                            <property name="search_column">0</property>
+                            <child>
+                              <object class="GtkTreeViewColumn" id="text">
+                                <property name="title">Test</property>
+                                <child>
+                                  <object class="GtkCellRendererText" id="test-renderer"/>
+                                  <attributes>
+                                    <attribute name="text">0</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkVBox" id="vbox442">
+                            <property name="visible">True</property>
+                            <property name="orientation">vertical</property>
+                            <child>
+                              <object class="GtkButton" id="jsdirs_add_button">
+                                <property name="label">gtk-add</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="use_stock">True</property>
+                                <signal name="clicked" handler="on_jsdirs_add_button_clicked"/>
+                              </object>
+                              <packing>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkButton" id="jsdirs_rm_button">
+                                <property name="label">gtk-remove</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="use_stock">True</property>
+                                <signal name="clicked" handler="on_jsdirs_rm_button_clicked"/>
+                              </object>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label122">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">JS Find dirs</property>
+                    <attributes>
+                      <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+                    </attributes>
+                  </object>
+                </child>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -185,57 +378,114 @@
               </packing>
             </child>
             <child>
-              <object class="GtkSpinButton" id="preferences_spin:int:3:1:javascript-min-codecomplete">
-                  <property name="visible">True</property>
-                  <property name="can_focus">True</property>
-                  <property name="invisible_char">&#x2022;</property>
-                  <property name="adjustment">adjustment2</property>
-                  <property name="climb_rate">1</property>
-                  <property name="numeric">True</property>
+              <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>
+                <property name="n_rows">3</property>
+                <property name="n_columns">2</property>
+                <child>
+                  <object class="GtkLabel" id="label8">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="halign">start</property>
+                    <property name="label" translatable="yes">Gir repository's directory: </property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">0</property>
+                    <property name="bottom_attach">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="preferences:javascript-girdir">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="invisible_char">â</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">0</property>
+                    <property name="bottom_attach">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label9">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="halign">start</property>
+                    <property name="label" translatable="yes">Gjs repository's directory: </property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="preferences:javascript-gjsdir">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="invisible_char">â</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>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label10">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="halign">start</property>
+                    <property name="label" translatable="yes">Min character for completion: </property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkSpinButton" id="preferences:javascript-min-codecomplete">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="halign">end</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="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </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">3</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkCheckButton" id="preferences_toggle:bool:1:1:javascript-missed">
-            <property name="label" translatable="yes">Highlight missed semicolon</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="draw_indicator">True</property>
-          </object>
-          <packing>
-            <property name="position">4</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkCheckButton" id="preferences_toggle:bool:1:1:javascript-add-brace-after-func">
-            <property name="label" translatable="yes">Add brace after function call autocompletion</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="draw_indicator">True</property>
-          </object>
-          <packing>
-            <property name="position">5</property>
+            <property name="position">1</property>
           </packing>
         </child>
-        <child>
-          <object class="GtkCheckButton" id="preferences_toggle:bool:1:1:javascript-show-calltips">
-            <property name="label" translatable="yes">Show calltips</property>
+        <child type="tab">
+          <object class="GtkLabel" id="label5">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="draw_indicator">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Environment</property>
           </object>
           <packing>
-            <property name="position">7</property>
+            <property name="position">1</property>
+            <property name="tab_fill">False</property>
           </packing>
         </child>
       </object>
diff --git a/plugins/language-support-js/js-support-plugin.plugin.in b/plugins/language-support-js/js-support-plugin.plugin.in
index 7cbc5db..7bf014a 100644
--- a/plugins/language-support-js/js-support-plugin.plugin.in
+++ b/plugins/language-support-js/js-support-plugin.plugin.in
@@ -8,4 +8,4 @@ UserActivatable=no
 
 [Language Support]
 Languages=JavaScript
-MimeTypes=application/javascript
\ No newline at end of file
+MimeTypes=application/javascript
diff --git a/plugins/language-support-js/org.gnome.anjuta.plugins.js.gschema.xml.in b/plugins/language-support-js/org.gnome.anjuta.plugins.js.gschema.xml.in
new file mode 100644
index 0000000..4d04b0a
--- /dev/null
+++ b/plugins/language-support-js/org.gnome.anjuta.plugins.js.gschema.xml.in
@@ -0,0 +1,31 @@
+<schemalist>
+	<schema id="org.gnome.anjuta.plugins.js" path="/org/gnome/anjuta/plugins/js/">
+		<key name="javascript-girdir" type="s">
+			<default>""</default>
+		</key>
+		<key name="javascript-gjsdir" type="s">
+			<default>""</default>
+		</key>
+		<key name="javascript-min-codecomplete" type="i">
+			<default>3</default>
+		</key>
+		<key name="javascript-missed" type="b">
+			<default>true</default>
+		</key>
+		<key name="completion-enable" type="b">
+			<default>true</default>
+		</key>
+		<key name="completion-space-after-func" type="b">
+			<default>false</default>
+		</key>
+		<key name="completion-brace-after-func" type="b">
+			<default>true</default>
+		</key>
+		<key name="completion-closebrace-after-func" type="b">
+			<default>false</default>
+		</key>
+		<key name="calltip-enable" type="b">
+			<default>true</default>
+		</key>
+	</schema>
+</schemalist>
diff --git a/plugins/language-support-js/plugin.c b/plugins/language-support-js/plugin.c
index f0331e8..a88f03d 100644
--- a/plugins/language-support-js/plugin.c
+++ b/plugins/language-support-js/plugin.c
@@ -21,11 +21,13 @@
 #include <libanjuta/anjuta-shell.h>
 #include <libanjuta/anjuta-session.h>
 #include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-language-provider.h>
 #include <libanjuta/interfaces/ianjuta-document-manager.h>
 #include <libanjuta/interfaces/ianjuta-project-manager.h>
 #include <libanjuta/interfaces/ianjuta-editor-assist.h>
 #include <libanjuta/interfaces/ianjuta-editor-tip.h>
 #include <libanjuta/interfaces/ianjuta-language.h>
+#include <libanjuta/interfaces/ianjuta-language-provider.h>
 #include <libanjuta/interfaces/ianjuta-preferences.h>
 #include <ctype.h>
 
@@ -66,13 +68,12 @@ js_support_plugin_activate (AnjutaPlugin *plugin)
 
 	DEBUG_PRINT ("%s", "JSLang: Activating JSLang plugin ...");
 	js_support_plugin = (JSLang*) plugin;
+	js_support_plugin->prefs = g_settings_new (JS_SUPPORT_SCHEMA);
 	js_support_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);
-
-	js_support_plugin->prefs = g_settings_new (JS_SUPPORT_SCHEMA);
 	return TRUE;
 }
 
@@ -115,7 +116,6 @@ static void
 js_support_plugin_instance_init (GObject *obj)
 {
 	JSLang *plugin = (JSLang*)obj;
-	plugin->last = NULL;
 	plugin->prefs = NULL;
 	plugin->symbol = NULL;
 }
@@ -151,18 +151,32 @@ install_support (JSLang *plugin)
 													   IANJUTA_EDITOR_LANGUAGE (plugin->current_editor), NULL);
 	if (!lang || !g_str_equal (lang, "JavaScript"))
 		return;
+		
+	plugin->lang_prov = g_object_new (ANJUTA_TYPE_LANGUAGE_PROVIDER, NULL);
+	anjuta_language_provider_install (plugin->lang_prov,
+	                                  IANJUTA_EDITOR (plugin->current_editor),
+	                                  plugin->prefs);
 
 	DEBUG_PRINT ("%s", "JSLang: Install support");
-
-	ianjuta_editor_assist_add (IANJUTA_EDITOR_ASSIST(plugin->current_editor), IANJUTA_PROVIDER(plugin), NULL);
+	
+	ianjuta_editor_assist_add (IANJUTA_EDITOR_ASSIST(plugin->current_editor),
+	                           IANJUTA_PROVIDER(plugin), NULL);
 }
 
 static void
 uninstall_support (JSLang *plugin)
 {
+	if (plugin->lang_prov)
+    {
+        g_object_unref (plugin->lang_prov);
+        plugin->lang_prov = NULL;
+    }
+    
 	DEBUG_PRINT ("%s", "JSLang: Uninstall support");
+	
+	ianjuta_editor_assist_remove (IANJUTA_EDITOR_ASSIST(plugin->current_editor),
+	                              IANJUTA_PROVIDER(plugin), NULL);
 
-	ianjuta_editor_assist_remove (IANJUTA_EDITOR_ASSIST(plugin->current_editor), IANJUTA_PROVIDER(plugin), NULL);
 }
 
 static void
@@ -277,15 +291,16 @@ on_jsdirs_add_button_clicked (GtkButton *button, gpointer user_data)
 }
 
 static void
-jsdirs_init_treeview (GtkBuilder* bxml)
+jsdirs_init_treeview (JSLang* plugin)
 {
 	const gchar *project_root = NULL;
 	GtkTreeIter iter;
-	GtkListStore *list_store = GTK_LIST_STORE (gtk_builder_get_object (bxml, JSDIRS_LISTSTORE));
+	GtkListStore *list_store = GTK_LIST_STORE (gtk_builder_get_object (
+	                                               plugin->bxml, JSDIRS_LISTSTORE));
 	if (!list_store)
 		return;
 
-	anjuta_shell_get (ANJUTA_PLUGIN (getPlugin ())->shell,
+	anjuta_shell_get (ANJUTA_PLUGIN (plugin)->shell,
 					  IANJUTA_PROJECT_MANAGER_PROJECT_ROOT_URI,
 					  G_TYPE_STRING, &project_root, NULL);
 
@@ -308,34 +323,65 @@ jsdirs_init_treeview (GtkBuilder* bxml)
 	}
 }
 
+#define PREF_WIDGET_SPACE "preferences:completion-space-after-func"
+#define PREF_WIDGET_BRACE "preferences:completion-brace-after-func"
+#define PREF_WIDGET_CLOSEBRACE "preferences:completion-closebrace-after-func"
+#define PREF_WIDGET_AUTO "preferences:completion-enable"
+
+static void
+on_autocompletion_toggled (GtkToggleButton* button,
+                           JSLang* 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);
+}
+
 static void
 ipreferences_merge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
 					GError** e)
 {
-	GError* error = NULL;
-	GtkBuilder* bxml = gtk_builder_new ();
-
 	/* Add preferences */
-	if (!gtk_builder_add_from_file (bxml, PREFS_BUILDER, &error))
+	GError* error = NULL;
+	JSLang* plugin = (JSLang*) ipref;
+	plugin->bxml = gtk_builder_new ();
+    GtkWidget* toggle;
+    
+	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);
+        g_warning ("Couldn't load builder file: %s", error->message);
+        g_error_free (error);
 	}
-	GtkTreeView *tree = GTK_TREE_VIEW (gtk_builder_get_object (bxml, JSDIRS_TREEVIEW));
+	
+	GtkTreeView *tree = GTK_TREE_VIEW (gtk_builder_get_object (plugin->bxml, JSDIRS_TREEVIEW));
 
-	gtk_builder_connect_signals (bxml, tree);
-	jsdirs_init_treeview (bxml);
+	gtk_builder_connect_signals (plugin->bxml, tree);
+	jsdirs_init_treeview (plugin);
+	
 	anjuta_preferences_add_from_builder (prefs,
-								 bxml, NULL, "vbox1", _("JavaScript"),
-								 ICON_FILE);
-	g_object_unref (bxml);
+	                                     plugin->bxml,
+	                                     plugin->prefs,
+	                                     "preferences", _("JavaScript"),
+	                                     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);
 }
 
 static void
 ipreferences_unmerge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
 					  GError** e)
 {
+	JSLang* plugin = (JSLang*) ipref;
 	anjuta_preferences_remove_page(prefs, _("JavaScript"));
+	g_object_unref (plugin->bxml);
 }
 
 static void
@@ -346,99 +392,117 @@ ipreferences_iface_init (IAnjutaPreferencesIface* iface)
 }
 
 static void
-iprovider_activate (IAnjutaProvider *obj, IAnjutaIterable* iter,  gpointer data, GError **err)
+iprovider_activate (IAnjutaProvider* self,
+                    IAnjutaIterable* iter,
+                    gpointer data,
+                    GError** e)
 {
-	DEBUG_PRINT("activate");
-
-	JSLang *plugin = (JSLang*)obj;
-	gchar *str = (gchar*)data;
-
-	g_assert (plugin->current_editor);
-	g_assert (str);
+	JSLang *plugin = (JSLang*) self;
+	anjuta_language_provider_activate (plugin->lang_prov, self, iter, data);
+}
 
-	gint a = ianjuta_iterable_diff (plugin->last, iter, NULL);
+static void
+iprovider_populate (IAnjutaProvider* self,
+                    IAnjutaIterable* cursor,
+                    GError** e)
+{
+	JSLang *plugin = (JSLang*) self;
+	anjuta_language_provider_populate (plugin->lang_prov, self, cursor);
+}
 
-	ianjuta_editor_insert (IANJUTA_EDITOR (plugin->current_editor), iter, str + a, -1, NULL);
-			
-	gchar *sym = code_completion_get_str (IANJUTA_EDITOR (plugin->current_editor), FALSE);
-	g_assert (sym != NULL);
+static const gchar*
+iprovider_get_name (IAnjutaProvider* self,
+                    GError** e)
+{
+	return _("JavaScript");
+}
 
-	if (sym && code_completion_is_symbol_func (plugin, sym))
-	{
-		IAnjutaIterable *position = ianjuta_editor_get_position (IANJUTA_EDITOR (plugin->current_editor), NULL);
+static IAnjutaIterable*
+iprovider_get_start_iter (IAnjutaProvider* self,
+                          GError** e)
+{
+	JSLang *plugin = (JSLang*) self;
+	return anjuta_language_provider_get_start_iter (plugin->lang_prov);
+}
 
-		if (g_settings_get_boolean (plugin->prefs, ADD_BRACE_AFTER_FUNCCALL))
-		{
-			ianjuta_editor_insert (IANJUTA_EDITOR (plugin->current_editor), position, " (", -1, NULL);
-		}
-		if (g_settings_get_boolean (plugin->prefs, SHOW_CALLTIPS))
-		{
-/*			GList *t = NULL;
-			gchar *args = code_completion_get_func_tooltip (plugin, sym);
-			t = g_list_append (t, args);
-			if (args)
-			{
-				ianjuta_editor_tip_show (IANJUTA_EDITOR_TIP(plugin->current_editor), t,
-							 position, NULL);
-
-				g_free (args);
-			}*/
-		}
-	}
-	g_free (sym);
+static void
+iprovider_iface_init (IAnjutaProviderIface* iface)
+{
+	iface->activate       = iprovider_activate;
+	iface->populate       = iprovider_populate;
+	iface->get_name       = iprovider_get_name;
+	iface->get_start_iter = iprovider_get_start_iter;
 }
 
-static const gchar* 
-iprovider_get_name (IAnjutaProvider *obj, GError **err)
+static GList*
+ilanguage_provider_get_calltip_cache (IAnjutaLanguageProvider *obj,
+                                      gchar* call_context,
+                                      GError** err)
 {
-	return _("JS");
+	/* TODO: Not implemented yet */
+	return NULL;
 }
 
-static IAnjutaIterable* 
-iprovider_get_start_iter (IAnjutaProvider *obj, GError **err)
+static gchar*
+ilanguage_provider_get_calltip_context (IAnjutaLanguageProvider *obj,
+                                        IAnjutaIterable *iter,
+                                        GError** err)
 {
-	JSLang *plugin = (JSLang*)obj;
+/*	TODO: Not implemented yet
+	GList *t = NULL;
+	gchar *args = code_completion_get_func_tooltip (plugin, sym);
+	t = g_list_append (t, args);
+	if (args)
+	{
+		ianjuta_editor_tip_show (IANJUTA_EDITOR_TIP(plugin->current_editor), t,
+		                         position, NULL);
+		g_free (args);
+	}
+*/
+	return NULL;
+}
 
-	return plugin->last;
+static void
+ilanguage_provider_new_calltip (IAnjutaLanguageProvider* obj,
+                                gchar* call_context,
+                                IAnjutaIterable* cursor,
+                                GError** err)
+{
+	/* TODO: Not implemented yet */
+	return;
 }
 
-static void 
-iprovider_populate (IAnjutaProvider *obj, IAnjutaIterable* iter, GError **err)
+static IAnjutaIterable*
+ilanguage_provider_populate (IAnjutaLanguageProvider* obj,
+                             IAnjutaIterable* iter,
+                             GError **err)
 {
-	static GList *trash = NULL;
 	JSLang *plugin = (JSLang*)obj;
-
-	if (plugin->last) {
-		g_object_unref (plugin->last);
-	}
-
-        plugin->last = ianjuta_iterable_clone(iter, NULL);
+	IAnjutaIterable* start_iter;
+	GList *suggestions;
+	
+	start_iter = ianjuta_iterable_clone (iter, NULL);
 
 	if (!plugin->current_editor)
-		return;
+		return start_iter;
 	gint depth;
-	GList *suggestions = NULL;
 	gchar *str = code_completion_get_str (IANJUTA_EDITOR (plugin->current_editor), FALSE);
 
-	if (trash)
-	{
-		g_list_foreach (trash, (GFunc)g_free, NULL);
-		g_list_free (trash);
-		trash = NULL;
-	}
-
 	if (!str)
-		return;
+		return start_iter;
 
 	g_assert (plugin->prefs);
+	gchar *file = file_completion (IANJUTA_EDITOR (plugin->current_editor), &depth);
 
 	if (strlen (str) < g_settings_get_int (plugin->prefs, MIN_CODECOMPLETE))
 	{
-		ianjuta_editor_assist_proposals ( IANJUTA_EDITOR_ASSIST (plugin->current_editor), obj,  NULL,  TRUE, NULL);
-		return;
+		ianjuta_editor_assist_proposals (IANJUTA_EDITOR_ASSIST (plugin->current_editor),
+										 IANJUTA_PROVIDER(obj), NULL, NULL, TRUE, NULL);
+		/* Highlight missed semicolon */
+		code_completion_get_list (plugin, file, NULL, depth);
+		return start_iter;
 	}
 
-	gchar *file = file_completion (IANJUTA_EDITOR (plugin->current_editor), &depth);
 	gint i;
 	DEBUG_PRINT ("JSLang: Auto complete for %s (TMFILE=%s)", str, file);
 	for (i = strlen (str) - 1; i; i--)
@@ -446,10 +510,9 @@ iprovider_populate (IAnjutaProvider *obj, IAnjutaIterable* iter, GError **err)
 		if (str[i] == '.')
 			break;
 	}
+	/* TODO: Use anjuta_language_provider_get_pre_word in the future */
 	if (i > 0)
-	{
 		suggestions = code_completion_get_list (plugin, file, g_strndup (str, i), depth);
-	}
 	else
 		suggestions = code_completion_get_list (plugin, file, NULL, depth);
 	if (suggestions)
@@ -467,38 +530,51 @@ iprovider_populate (IAnjutaProvider *obj, IAnjutaIterable* iter, GError **err)
 		}
 		GList *i;
 		for (; k > 0; k--)
-			ianjuta_iterable_previous (plugin->last, NULL);
+			ianjuta_iterable_previous (start_iter, NULL);
 
 		for (i = suggestions; i; i = g_list_next(i)) {
-			IAnjutaEditorAssistProposal* proposal = g_new0(IAnjutaEditorAssistProposal, 1);
+			IAnjutaEditorAssistProposal* proposal;
+			IAnjutaLanguageProviderProposalData* prop_data;
+			
+			proposal = g_new0(IAnjutaEditorAssistProposal, 1);
+			prop_data = g_new0 (IAnjutaLanguageProviderProposalData, 1);
 
 			if (!i->data)
 				continue;
-	
+
 			proposal->label = i->data;
-			proposal->data = i->data;
+			prop_data->name = i->data;
+			prop_data->is_func = code_completion_is_symbol_func (plugin, str);
+			/* TODO: Not implemented yet */
+			prop_data->has_para = TRUE;
+			prop_data->info = i->data;
+			proposal->data = prop_data;
 			nsuggest = g_list_prepend (nsuggest, proposal);
 		}
-		ianjuta_editor_assist_proposals ( IANJUTA_EDITOR_ASSIST (plugin->current_editor), obj,  nsuggest,  TRUE, NULL);
+		ianjuta_editor_assist_proposals (IANJUTA_EDITOR_ASSIST (plugin->current_editor),
+		                                 IANJUTA_PROVIDER(obj), nsuggest, NULL, TRUE, NULL);
 		g_list_free (nsuggest);
-                trash = suggestions;
-		return;
+		return start_iter;
 	}
-	ianjuta_editor_assist_proposals ( IANJUTA_EDITOR_ASSIST (plugin->current_editor), obj,  NULL,  TRUE, NULL);
+	ianjuta_editor_assist_proposals (IANJUTA_EDITOR_ASSIST (plugin->current_editor),
+	                                 IANJUTA_PROVIDER(obj), NULL, NULL, TRUE, NULL);
+	
+	return start_iter;
 }
 
 static void
-iprovider_iface_init (IAnjutaProviderIface* iface)
+ilanguage_provider_iface_init (IAnjutaLanguageProviderIface* iface)
 {
-	iface->activate	= iprovider_activate;
-	iface->get_name	= iprovider_get_name;
-	iface->get_start_iter = iprovider_get_start_iter;
-	iface->populate= iprovider_populate;
+	iface->get_calltip_cache   = ilanguage_provider_get_calltip_cache;
+	iface->get_calltip_context = ilanguage_provider_get_calltip_context;
+	iface->new_calltip         = ilanguage_provider_new_calltip;
+	iface->populate_language   = ilanguage_provider_populate;
 }
 
 ANJUTA_PLUGIN_BEGIN (JSLang, js_support_plugin);
 ANJUTA_PLUGIN_ADD_INTERFACE(ipreferences, IANJUTA_TYPE_PREFERENCES);
 ANJUTA_PLUGIN_ADD_INTERFACE(iprovider, IANJUTA_TYPE_PROVIDER);
+ANJUTA_PLUGIN_ADD_INTERFACE(ilanguage_provider, IANJUTA_TYPE_LANGUAGE_PROVIDER)
 ANJUTA_PLUGIN_END;
 
 ANJUTA_SIMPLE_PLUGIN (JSLang, js_support_plugin);
diff --git a/plugins/language-support-js/plugin.h b/plugins/language-support-js/plugin.h
index af6195d..15f830e 100644
--- a/plugins/language-support-js/plugin.h
+++ b/plugins/language-support-js/plugin.h
@@ -21,6 +21,7 @@
 #define _JS_SUPPORT_PLUGIN_H_
 
 #include <libanjuta/anjuta-plugin.h>
+#include <libanjuta/anjuta-language-provider.h>
 
 #include "database-symbol.h"
 
@@ -32,12 +33,15 @@ struct _JSLang{
 	gint editor_watch_id;
 	GObject *current_editor;
 //	gchar *current;
-	gpointer last;
 //	GList *complition_cache;
 //	gint uiid;
-	GSettings *prefs;
 	DatabaseSymbol* symbol;
+	AnjutaLanguageProvider *lang_prov;
 //	GtkActionGroup *action_group;
+
+	/* Preferences */
+	GtkBuilder* bxml;
+	GSettings* prefs;
 };
 
 struct _JSLangClass{
diff --git a/plugins/language-support-js/prefs.h b/plugins/language-support-js/prefs.h
index de2d61a..e5aa101 100644
--- a/plugins/language-support-js/prefs.h
+++ b/plugins/language-support-js/prefs.h
@@ -19,10 +19,8 @@
 #ifndef _JS_SUPPORT_PREFS_H_
 #define _JS_SUPPORT_PREFS_H_
 
-#define JS_SUPPORT_SCHEMA "org.gnome.anjuta.js"
+#define JS_SUPPORT_SCHEMA "org.gnome.anjuta.plugins.js"
 #define MIN_CODECOMPLETE "javascript-min-codecomplete"
-#define ADD_BRACE_AFTER_FUNCCALL "javascript-add-brace-after-func"
-#define SHOW_CALLTIPS "javascript-show-calltips"
 #define HIGHLIGHT_MISSEDSEMICOLON "javascript-missed"
 #define GIR_DIR_KEY "javascript-girdir"
 #define GJS_DIR_KEY "javascript-gjsdir"



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