[anjuta] libanjuta/snippet-manager/file-wizard: Fixed external snippet insertion.



commit 8e02f3b18d5fa6e97f6c37cacb1f6d874d57a2d0
Author: Dragos Dena <dragos dena gmail com>
Date:   Mon Feb 28 16:01:52 2011 -0800

    libanjuta/snippet-manager/file-wizard: Fixed external snippet insertion.

 libanjuta/interfaces/libanjuta.idl                 |    5 ++++-
 plugins/file-wizard/file.c                         |    4 ++--
 plugins/snippets-manager/plugin.c                  |   13 +++++++++----
 plugins/snippets-manager/plugin.h                  |    2 +-
 plugins/snippets-manager/snippets-browser.c        |    6 ++++--
 .../snippets-interaction-interpreter.c             |   12 +++++++-----
 .../snippets-interaction-interpreter.h             |    3 ++-
 plugins/snippets-manager/snippets-provider.c       |    3 ++-
 8 files changed, 31 insertions(+), 17 deletions(-)
---
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index 005c03a..c628e48 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -5548,12 +5548,15 @@ interface IAnjutaSnippetsManager
 	/**
 	 * ianjuta_snippets_manager_insert:
 	 * @key: Trigger-key of the snippet
+	 * @editing_session: If after inserting the snippet there should be an editing
+	 * session. Mark as FALSE if not interested in the dynamic capabilities of the
+	 * snippet.
 	 * @obj: Self
 	 * @err: Error propagation and reporting
 	 *
 	 * Insert snippet in the current editor.
 	 */
-	gboolean insert (const gchar* key);
+	gboolean insert (const gchar* key, gboolean editing_session);
 }
 
 /**
diff --git a/plugins/file-wizard/file.c b/plugins/file-wizard/file.c
index 294a0c2..8d0d8ef 100644
--- a/plugins/file-wizard/file.c
+++ b/plugins/file-wizard/file.c
@@ -466,12 +466,12 @@ insert_notice(IAnjutaSnippetsManager* snippets_manager, const gchar* license_typ
 	gchar *name;
 
 	name = g_utf8_strdown (license_type, -1);
-	ianjuta_snippets_manager_insert(snippets_manager, name, NULL);
+	ianjuta_snippets_manager_insert(snippets_manager, name, FALSE, NULL);
 	g_free (name);
 }
 
 static void
 insert_header(IAnjutaSnippetsManager* snippets_manager, gint source_type)
 {
-	ianjuta_snippets_manager_insert (snippets_manager, "top_com", NULL);
+	ianjuta_snippets_manager_insert (snippets_manager, "top_com", FALSE, NULL);
 }
diff --git a/plugins/snippets-manager/plugin.c b/plugins/snippets-manager/plugin.c
index 22f7e6e..308b4b3 100644
--- a/plugins/snippets-manager/plugin.c
+++ b/plugins/snippets-manager/plugin.c
@@ -111,7 +111,8 @@ typedef struct _GlobalVariablesUpdateData
 
 gboolean
 snippet_insert (SnippetsManagerPlugin * plugin, 
-                const gchar *trigger)
+                const gchar *trigger,
+                gboolean editing_session)
 {
 	AnjutaSnippet *requested_snippet = NULL;
 	SnippetsManagerPlugin *snippets_manager_plugin = NULL;
@@ -130,7 +131,8 @@ snippet_insert (SnippetsManagerPlugin * plugin,
 	/* Get the default content of the snippet */
 	snippets_interaction_insert_snippet (snippets_manager_plugin->snippets_interaction,
 	                                     snippets_manager_plugin->snippets_db,
-	                                     requested_snippet);
+	                                     requested_snippet,
+	                                     editing_session);
 
 	return TRUE;
 }
@@ -466,10 +468,13 @@ snippets_manager_plugin_class_init (GObjectClass * klass)
 /* IAnjutaSnippetsManager interface */
 
 static gboolean 
-isnippets_manager_iface_insert (IAnjutaSnippetsManager* snippets_manager, const gchar* key, GError** err)
+isnippets_manager_iface_insert (IAnjutaSnippetsManager* snippets_manager, 
+                                const gchar* key, 
+                                gboolean editing_session,
+                                GError** err)
 {
 	SnippetsManagerPlugin* plugin = ANJUTA_PLUGIN_SNIPPETS_MANAGER (snippets_manager);
-	snippet_insert (plugin, key);
+	snippet_insert (plugin, key, editing_session);
 	return TRUE;
 }
 
diff --git a/plugins/snippets-manager/plugin.h b/plugins/snippets-manager/plugin.h
index e434b52..3b452d8 100644
--- a/plugins/snippets-manager/plugin.h
+++ b/plugins/snippets-manager/plugin.h
@@ -88,7 +88,7 @@ struct _SnippetsManagerPluginClass
 
 /* To insert a snippet to the editor. */
 gboolean
-snippet_insert (SnippetsManagerPlugin * plugin, const gchar *keyword);
+snippet_insert (SnippetsManagerPlugin * plugin, const gchar *keyword, gboolean editing_session);
 
 
 #endif /* __SNIPPETS_MANAGER_PLUGIN_H__ */
diff --git a/plugins/snippets-manager/snippets-browser.c b/plugins/snippets-manager/snippets-browser.c
index 91b750a..1efeb56 100644
--- a/plugins/snippets-manager/snippets-browser.c
+++ b/plugins/snippets-manager/snippets-browser.c
@@ -917,7 +917,8 @@ on_insert_button_clicked (GtkButton *insert_button,
 
 		snippets_interaction_insert_snippet (priv->snippets_interaction,
 		                                     priv->snippets_db,
-		                                     ANJUTA_SNIPPET (cur_object));
+		                                     ANJUTA_SNIPPET (cur_object),
+		                                     TRUE);
 	}
 
 }
@@ -969,7 +970,8 @@ on_snippets_view_row_activated (GtkTreeView *snippets_view,
 	if (ANJUTA_IS_SNIPPET (cur_object))
 		snippets_interaction_insert_snippet (priv->snippets_interaction,
 		                                     priv->snippets_db,
-		                                     ANJUTA_SNIPPET (cur_object));
+		                                     ANJUTA_SNIPPET (cur_object),
+		                                     TRUE);
 
 	g_object_unref (cur_object);
 }
diff --git a/plugins/snippets-manager/snippets-interaction-interpreter.c b/plugins/snippets-manager/snippets-interaction-interpreter.c
index 350cd17..e95cd91 100644
--- a/plugins/snippets-manager/snippets-interaction-interpreter.c
+++ b/plugins/snippets-manager/snippets-interaction-interpreter.c
@@ -764,7 +764,8 @@ snippets_interaction_destroy (SnippetsInteraction *snippets_interaction)
 void                 
 snippets_interaction_insert_snippet (SnippetsInteraction *snippets_interaction,
                                      SnippetsDB *snippets_db,
-                                     AnjutaSnippet *snippet)
+                                     AnjutaSnippet *snippet,
+                                     gboolean editing_session)
 {
 	SnippetsInteractionPrivate *priv = NULL;
 	gchar *indent = NULL, *cur_line = NULL, *snippet_default_content = NULL;
@@ -812,9 +813,10 @@ snippets_interaction_insert_snippet (SnippetsInteraction *snippets_interaction,
 	ianjuta_document_grab_focus (IANJUTA_DOCUMENT (priv->cur_editor), NULL);
 
 	priv->cur_snippet = snippet;
-	start_snippet_editing_session (snippets_interaction, 
-	                               cur_pos, 
-	                               g_utf8_strlen (snippet_default_content, -1));
+	if (editing_session)
+		start_snippet_editing_session (snippets_interaction, 
+		                               cur_pos, 
+		                               g_utf8_strlen (snippet_default_content, -1));
 
 	g_free (indent);
 	g_free (snippet_default_content);
@@ -889,7 +891,7 @@ snippets_interaction_trigger_insert_request (SnippetsInteraction *snippets_inter
 	if (ANJUTA_IS_SNIPPET (snippet))
 	{
 		ianjuta_editor_erase (priv->cur_editor, rewind_iter, cur_pos, NULL);
-		snippets_interaction_insert_snippet (snippets_interaction, snippets_db, snippet);
+		snippets_interaction_insert_snippet (snippets_interaction, snippets_db, snippet, TRUE);
 	}
 
 	g_free (trigger);
diff --git a/plugins/snippets-manager/snippets-interaction-interpreter.h b/plugins/snippets-manager/snippets-interaction-interpreter.h
index 104e00c..c9c065c 100644
--- a/plugins/snippets-manager/snippets-interaction-interpreter.h
+++ b/plugins/snippets-manager/snippets-interaction-interpreter.h
@@ -61,7 +61,8 @@ void                 snippets_interaction_start                  (SnippetsIntera
 void                 snippets_interaction_destroy                (SnippetsInteraction *snippets_interaction);
 void                 snippets_interaction_insert_snippet         (SnippetsInteraction *snippets_interaction,
                                                                   SnippetsDB *snippets_db,
-                                                                  AnjutaSnippet *snippet);
+                                                                  AnjutaSnippet *snippet,
+                                                                  gboolean editing_session);
 void                 snippets_interaction_trigger_insert_request (SnippetsInteraction *snippets_interaction,
                                                                   SnippetsDB *snippets_db);
 void                 snippets_interaction_set_editor              (SnippetsInteraction *snippets_interaction,
diff --git a/plugins/snippets-manager/snippets-provider.c b/plugins/snippets-manager/snippets-provider.c
index 8645f0d..69dc633 100644
--- a/plugins/snippets-manager/snippets-provider.c
+++ b/plugins/snippets-manager/snippets-provider.c
@@ -741,7 +741,8 @@ snippets_provider_activate (IAnjutaProvider *self,
 	/* Insert the snippet */
 	snippets_interaction_insert_snippet (priv->snippets_interaction,
 	                                     priv->snippets_db,
-	                                     snippet);
+	                                     snippet,
+	                                     TRUE);
 
 	stop_listening (ANJUTA_SNIPPETS_PROVIDER (self));
 }



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