[anjuta] Added code-added signal. Now symbol-db is updated on glade signal drop.
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] Added code-added signal. Now symbol-db is updated on glade signal drop.
- Date: Thu, 24 Feb 2011 17:52:43 +0000 (UTC)
commit 96303702a574dfd7ee72d05d16785f29388731c7
Author: Marco Diego Aurélio Mesquita <marcodiegomesquita gmail com>
Date: Thu Feb 24 13:00:08 2011 -0300
Added code-added signal. Now symbol-db is updated on glade signal drop.
libanjuta/interfaces/libanjuta.idl | 11 ++++
plugins/language-support-cpp-java/plugin.c | 3 +
plugins/symbol-db/plugin.c | 79 +++++++++++++++++-----------
3 files changed, 63 insertions(+), 30 deletions(-)
---
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index 6e59672..9a00f90 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -1274,6 +1274,17 @@ interface IAnjutaEditor
COMMENT,
STRING
}
+
+ /**
+ * IAnjutaEditor::code-added:
+ * @position: The iter position where @ch is added.
+ * @code: The code that has been added.
+ * @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.
+ */
+ void ::code_added (IAnjutaIterable *position, gchar *code);
/**
* IAnjutaEditor::char-added:
diff --git a/plugins/language-support-cpp-java/plugin.c b/plugins/language-support-cpp-java/plugin.c
index 34bfb58..711676b 100644
--- a/plugins/language-support-cpp-java/plugin.c
+++ b/plugins/language-support-cpp-java/plugin.c
@@ -509,6 +509,9 @@ language_support_add_c_callback (IAnjutaEditor* editor,
ianjuta_editor_insert (editor, position,
str->str, -1, NULL);
+ /* Emit code-added signal, so symbols will be updated */
+ g_signal_emit_by_name (G_OBJECT (editor), "code-added", position, str);
+
g_string_free (str, TRUE);
/* Will now set the caret position offset */
diff --git a/plugins/symbol-db/plugin.c b/plugins/symbol-db/plugin.c
index 20c0756..6db0c5b 100644
--- a/plugins/symbol-db/plugin.c
+++ b/plugins/symbol-db/plugin.c
@@ -348,13 +348,11 @@ static GtkActionEntry actions_search[] = {
};
static gboolean
-on_editor_buffer_symbols_update_timeout (gpointer user_data)
+editor_buffer_symbols_update (SymbolDBPlugin *sdb_plugin)
{
- SymbolDBPlugin *sdb_plugin;
IAnjutaEditor *ed;
gchar *current_buffer = NULL;
gsize buffer_size = 0;
- gdouble seconds_elapsed;
GFile* file;
gchar * local_path;
GPtrArray *real_files_list;
@@ -363,30 +361,11 @@ on_editor_buffer_symbols_update_timeout (gpointer user_data)
gint i;
gint proc_id ;
- g_return_val_if_fail (user_data != NULL, FALSE);
-
- sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (user_data);
-
- if (sdb_plugin->current_editor == NULL)
- return FALSE;
-
- /* check the timer. If it's elapsed enought time since the last time the user
- * typed in something, than proceed with updating, elsewhere don't do nothing
- */
- if (sdb_plugin->update_timer == NULL)
+ /* 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;
-
- seconds_elapsed = g_timer_elapsed (sdb_plugin->update_timer, NULL);
- if (seconds_elapsed < TIMEOUT_SECONDS_AFTER_LAST_TIP)
- return TRUE;
-
-
- /* 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;
-
if (sdb_plugin->current_editor)
{
ed = IANJUTA_EDITOR (sdb_plugin->current_editor);
@@ -401,10 +380,10 @@ on_editor_buffer_symbols_update_timeout (gpointer user_data)
if (file == NULL)
return FALSE;
-
+
/* take the path reference */
local_path = g_file_get_path (file);
-
+
/* ok that's good. Let's have a last check: is the current file present
* on the buffer_update_files?
*/
@@ -439,7 +418,7 @@ on_editor_buffer_symbols_update_timeout (gpointer user_data)
text_buffers,
buffer_sizes);
}
-
+
if (proc_id > 0)
{
/* good. All is ready for a buffer scan. Add the file_scan into the arrays */
@@ -447,7 +426,7 @@ on_editor_buffer_symbols_update_timeout (gpointer user_data)
g_ptr_array_add (sdb_plugin->buffer_update_files, local_path_dup);
/* add the id too */
g_ptr_array_add (sdb_plugin->buffer_update_ids, GINT_TO_POINTER (proc_id));
-
+
/* add a task so that scan_end_manager can manage this */
g_tree_insert (sdb_plugin->proc_id_tree, GINT_TO_POINTER (proc_id),
GINT_TO_POINTER (TASK_BUFFER_UPDATE));
@@ -459,11 +438,37 @@ on_editor_buffer_symbols_update_timeout (gpointer user_data)
/* no need to free local_path, it'll be automatically freed later by the buffer_update
* function */
-
+
sdb_plugin->need_symbols_update = FALSE;
return proc_id > 0 ? TRUE : FALSE;
}
+static gboolean
+on_editor_buffer_symbols_update_timeout (gpointer user_data)
+{
+ SymbolDBPlugin *sdb_plugin;
+ gdouble seconds_elapsed;
+
+ g_return_val_if_fail (user_data != NULL, FALSE);
+
+ sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (user_data);
+
+ if (sdb_plugin->current_editor == NULL)
+ return FALSE;
+
+ /* check the timer. If it's elapsed enought time since the last time the user
+ * typed in something, than proceed with updating, elsewhere don't do nothing
+ */
+ if (sdb_plugin->update_timer == NULL)
+ return TRUE;
+
+ seconds_elapsed = g_timer_elapsed (sdb_plugin->update_timer, NULL);
+
+ if (seconds_elapsed < TIMEOUT_SECONDS_AFTER_LAST_TIP)
+ return TRUE;
+
+ return editor_buffer_symbols_update (sdb_plugin);
+}
static void
on_editor_buffer_symbol_update_scan_end (SymbolDBEngine *dbe, gint process_id,
@@ -558,6 +563,14 @@ on_editor_update_ui (IAnjutaEditor *editor, SymbolDBPlugin *sdb_plugin)
}
static void
+on_code_added (IAnjutaEditor *editor, IAnjutaIterable *position, gchar *code,
+ SymbolDBPlugin *sdb_plugin)
+{
+ sdb_plugin->need_symbols_update = TRUE;
+ editor_buffer_symbols_update (sdb_plugin);
+}
+
+static void
on_char_added (IAnjutaEditor *editor, IAnjutaIterable *position, gchar ch,
SymbolDBPlugin *sdb_plugin)
{
@@ -726,6 +739,9 @@ 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_CALLBACK (on_code_added),
+ sdb_plugin);
g_signal_connect (G_OBJECT(editor), "update_ui",
G_CALLBACK (on_editor_update_ui),
sdb_plugin);
@@ -748,6 +764,9 @@ on_editor_foreach_disconnect (gpointer key, gpointer value, gpointer user_data)
g_signal_handlers_disconnect_by_func (G_OBJECT(key),
G_CALLBACK (on_char_added),
user_data);
+ g_signal_handlers_disconnect_by_func (G_OBJECT(key),
+ G_CALLBACK (on_code_added),
+ user_data);
g_object_weak_unref (G_OBJECT(key),
(GWeakNotify) (on_editor_destroy),
user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]