[anjuta] libanjuta: Improve symbol-db behavior on cut, paste, undo, redo and when multiple files are modified



commit f14fd0fffae39bc3e2e9e3df18fbaebb1808fad5
Author: Marco Diego Aurélio Mesquita <marcodiegomesquita gmail com>
Date:   Tue May 21 15:41:03 2013 -0300

    libanjuta: Improve symbol-db behavior on cut, paste, undo, redo and when multiple files are modified.

 libanjuta/interfaces/libanjuta.idl         |   13 +++++++------
 plugins/language-support-cpp-java/plugin.c |   17 ++++++++++-------
 plugins/sourceview/sourceview.c            |   10 ++++++++++
 plugins/symbol-db/plugin.c                 |   10 ++++++----
 4 files changed, 33 insertions(+), 17 deletions(-)
---
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index e7c1dce..6056a89 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -1357,15 +1357,15 @@ interface IAnjutaEditor
        void   ::glade_callback_add (gchar *widget_typename, gchar *signal_name, gchar *handler_name, gchar 
*object, gboolean swap, gboolean after, gchar *filename);
 
        /**
-        * IAnjutaEditor::code-added:
-        * @position: The iter position where @ch is added.
-        * @code: The code that has been added.
+        * IAnjutaEditor::code-changed:
+        * @position: The iter position where code has been changed or NULL.
+        * @code: The code that has been added or NULL.
         * @obj: Self
         *
-        * This signal is emitted when code is added inside the editor.
-        * The newly added code is @code which has been inserted at @position.
+        * This signal is emitted when code is changed inside the editor.
+        * When such information is availabe, @position stores the position where @code was added.
         */
-       void   ::code_added (IAnjutaIterable *position, gchar *code);
+       void   ::code_changed (IAnjutaIterable *position, gchar *code);
 
        /**
         * IAnjutaEditor::char-added:
@@ -6465,6 +6465,7 @@ interface IAnjutaSymbolManager
        #include "ianjuta-iterable.h"
        #include "ianjuta-symbol.h"
        #include "ianjuta-symbol-query.h"
+       #include <libanjuta/interfaces/ianjuta-editor.h>
 
        /**
         * IAnjutaSymbolManager::prj_scan_end:
diff --git a/plugins/language-support-cpp-java/plugin.c b/plugins/language-support-cpp-java/plugin.c
index b771001..11dd925 100644
--- a/plugins/language-support-cpp-java/plugin.c
+++ b/plugins/language-support-cpp-java/plugin.c
@@ -445,8 +445,8 @@ language_support_get_header_editor_and_mark (CppJavaPlugin* lang_plugin,
 
 static void
 language_support_add_c_callback (CppJavaPlugin* lang_plugin,
-                                    IAnjutaEditor* editor,
-                                    IAnjutaIterable* position,
+                                 IAnjutaEditor* editor,
+                                 IAnjutaIterable* position,
                                  GStrv split_signal_data,
                                  CppFileType filetype)
 {
@@ -478,7 +478,7 @@ language_support_add_c_callback (CppJavaPlugin* lang_plugin,
 
     g_string_append (str, body);
 
-ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT(editor), NULL);
+    ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT(editor), NULL);
     ianjuta_editor_insert (editor, position,
                            str->str, -1, NULL);
        ianjuta_document_end_undo_action (IANJUTA_DOCUMENT(editor), NULL);
@@ -505,7 +505,7 @@ ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT(editor), NULL);
                 /* Add prototype to the header */
                 language_support_add_c_callback (lang_plugin, header_editor, mark_position,
                                                  split_signal_data, LS_FILE_CHDR);
-
+                g_signal_emit_by_name (G_OBJECT (header_editor), "code-changed", NULL, NULL);
             }
 
             g_object_unref (mark_position);
@@ -513,8 +513,9 @@ ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT(editor), NULL);
     }
 
     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);
+    g_signal_emit_by_name (G_OBJECT (editor), "code-changed", position, string);
 
     if (string) g_free (string);
 
@@ -582,8 +583,9 @@ static gboolean insert_after_mark (IAnjutaEditor* editor, gchar* mark,
 
        ianjuta_editor_insert (editor, mark_position, code_to_add, -1, NULL);
 
-       /* Emit code-added signal, so symbols will be updated */
-       g_signal_emit_by_name (G_OBJECT (editor), "code-added", mark_position, code_to_add);
+       /* Emit code-added signal, so symbols will be updated *
+       g_signal_emit_by_name (G_OBJECT (editor), "code-changed", mark_position, code_to_add);*/
+
        g_object_unref (mark_position);
 
        return TRUE;
@@ -696,6 +698,7 @@ static void insert_member_decl_and_init (IAnjutaEditor* editor, gchar* widget_na
               if (insert_after_mark (editor, member_decl_marker, member_decl, lang_plugin))
               {
                      insert_after_mark (editor, member_init_marker, member_init, lang_plugin);
+                     g_signal_emit_by_name (G_OBJECT (editor), "code-changed", NULL, NULL);
                      anjuta_status_set (status, _("Code added for widget."));
               }
               ianjuta_document_end_undo_action (IANJUTA_DOCUMENT(editor), NULL);
diff --git a/plugins/sourceview/sourceview.c b/plugins/sourceview/sourceview.c
index f6ab2b0..9fd7d4f 100644
--- a/plugins/sourceview/sourceview.c
+++ b/plugins/sourceview/sourceview.c
@@ -46,6 +46,7 @@
 #include <libanjuta/interfaces/ianjuta-editor-glade-signal.h>
 #include <libanjuta/interfaces/ianjuta-language-provider.h>
 #include <libanjuta/interfaces/ianjuta-provider.h>
+#include <libanjuta/interfaces/ianjuta-symbol-manager.h>
 
 #include <gtksourceview/gtksource.h>
 
@@ -1549,6 +1550,11 @@ static void idocument_end_undo_action (IAnjutaDocument *editor, GError **e)
        gtk_text_buffer_end_user_action (GTK_TEXT_BUFFER(sv->priv->document));
 }
 
+static void
+update_symbols(IAnjutaDocument* edit)
+{
+       g_signal_emit_by_name (G_OBJECT (IANJUTA_EDITOR(edit)), "code-changed", NULL, NULL);
+}
 
 static void
 idocument_undo(IAnjutaDocument* edit, GError** ee)
@@ -1564,6 +1570,7 @@ idocument_undo(IAnjutaDocument* edit, GError** ee)
        
        anjuta_view_scroll_to_cursor(sv->priv->view);
        g_signal_emit_by_name(G_OBJECT(sv), "update_ui", sv);
+       update_symbols(edit);
 }
 
 static void
@@ -1574,6 +1581,7 @@ idocument_redo(IAnjutaDocument* edit, GError** ee)
                gtk_source_buffer_redo(GTK_SOURCE_BUFFER(sv->priv->document));
        anjuta_view_scroll_to_cursor(sv->priv->view);
        g_signal_emit_by_name(G_OBJECT(sv), "update_ui", sv);
+       update_symbols(edit);
 }
 
 /* Grab focus */
@@ -1597,6 +1605,7 @@ idocument_cut(IAnjutaDocument* edit, GError** ee)
        g_signal_handlers_block_by_func (sv->priv->document, on_insert_text, sv);
        anjuta_view_cut_clipboard(sv->priv->view);
        g_signal_handlers_unblock_by_func (sv->priv->document, on_insert_text, sv);
+       update_symbols(edit);
 }
 
 static void
@@ -1615,6 +1624,7 @@ idocument_paste(IAnjutaDocument* edit, GError** ee)
        g_signal_handlers_block_by_func (sv->priv->document, on_insert_text, sv);
        anjuta_view_paste_clipboard(sv->priv->view);
        g_signal_handlers_unblock_by_func (sv->priv->document, on_insert_text, sv);
+       update_symbols(edit);
 }
 
 static void
diff --git a/plugins/symbol-db/plugin.c b/plugins/symbol-db/plugin.c
index cad5e6d..8dba592 100644
--- a/plugins/symbol-db/plugin.c
+++ b/plugins/symbol-db/plugin.c
@@ -367,8 +367,9 @@ editor_buffer_symbols_update (IAnjutaEditor *editor, SymbolDBPlugin *sdb_plugin)
        
        /* we won't proceed with the updating of the symbols if we didn't type in 
           anything */
+
        if (sdb_plugin->need_symbols_update == FALSE)
-               return TRUE;
+               return FALSE;
 
        if (editor) 
        {
@@ -441,9 +442,10 @@ editor_buffer_symbols_update (IAnjutaEditor *editor, SymbolDBPlugin *sdb_plugin)
        /* no need to free local_path, it'll be automatically freed later by the buffer_update
         * function */
 
-       sdb_plugin->need_symbols_update = FALSE;
+       if(sdb_plugin->buffer_update_files->len > 0)
+               sdb_plugin->need_symbols_update = TRUE;
 
-       return proc_id > 0 ? TRUE : FALSE;
+       return !sdb_plugin->need_symbols_update;
 }
 static gboolean
 on_editor_buffer_symbols_update_timeout (gpointer user_data)
@@ -741,7 +743,7 @@ value_added_current_editor (AnjutaPlugin *plugin, const char *name,
                g_signal_connect (G_OBJECT (editor), "char-added",
                                                  G_CALLBACK (on_char_added),
                                                  sdb_plugin);
-               g_signal_connect (G_OBJECT (editor), "code-added",
+               g_signal_connect (G_OBJECT (editor), "code-changed",
                                                  G_CALLBACK (on_code_added),
                                                  sdb_plugin);
                g_signal_connect (G_OBJECT(editor), "update_ui",


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