[anjuta] Support calltips when autocompletion is not available
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [anjuta] Support calltips when autocompletion is not available
- Date: Sun, 29 Nov 2009 15:26:46 +0000 (UTC)
commit cc5844e6657a26b21ec365b917454391960cb859
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sun Nov 29 16:26:15 2009 +0100
Support calltips when autocompletion is not available
libanjuta/interfaces/libanjuta.idl | 8 ++--
.../language-support-cpp-java/cpp-java-assist.c | 55 ++++++++++++++------
.../language-support-cpp-java/cpp-java-assist.h | 2 +-
plugins/language-support-cpp-java/plugin.c | 44 ++++++++--------
4 files changed, 65 insertions(+), 44 deletions(-)
---
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index f0c92eb..fec5c43 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -1923,12 +1923,12 @@ interface IAnjutaEditor
}
/**
- * SECTION:ianjuta-editor-assist
- * @title: IAnjutaEditorAssist
- * @short_description: Editor assistance framework
+ * SECTION:ianjuta-editor-tip
+ * @title: IAnjutaEditorTip
+ * @short_description: Editor call tips assistance framework
* @see_also:
* @stability: Unstable
- * @include: libanjuta/interfaces/ianjuta-editor-assist.h
+ * @include: libanjuta/interfaces/ianjuta-editor-tip.h
*
*/
interface IAnjutaEditorTip
diff --git a/plugins/language-support-cpp-java/cpp-java-assist.c b/plugins/language-support-cpp-java/cpp-java-assist.c
index 4446b5c..a165747 100644
--- a/plugins/language-support-cpp-java/cpp-java-assist.c
+++ b/plugins/language-support-cpp-java/cpp-java-assist.c
@@ -64,6 +64,7 @@ struct _CppJavaAssistPriv {
AnjutaPreferences *preferences;
IAnjutaSymbolManager* isymbol_manager;
IAnjutaEditorAssist* iassist;
+ IAnjutaEditorTip* itip;
/* Last used cache */
gchar *search_cache;
@@ -490,7 +491,7 @@ cpp_java_assist_get_calltip_context (CppJavaAssist *assist,
(IANJUTA_EDITOR_CELL (iter), 0, NULL)));
context = cpp_java_assist_get_scope_context
- (IANJUTA_EDITOR (assist->priv->iassist), "(", iter);
+ (IANJUTA_EDITOR (assist->priv->itip), "(", iter);
/* Point iter to the first character of the scope to align calltip correctly */
ianjuta_iterable_next (iter, NULL);
@@ -565,9 +566,9 @@ cpp_java_assist_show_calltip (CppJavaAssist *assist, gchar *call_context,
MAX_COMPLETIONS);
/* Search file */
- if (IANJUTA_IS_FILE (assist->priv->iassist))
+ if (IANJUTA_IS_FILE (assist->priv->itip))
{
- GFile *file = ianjuta_file_get_file (IANJUTA_FILE (assist->priv->iassist), NULL);
+ GFile *file = ianjuta_file_get_file (IANJUTA_FILE (assist->priv->itip), NULL);
if (file != NULL)
{
@@ -622,7 +623,7 @@ cpp_java_assist_show_calltip (CppJavaAssist *assist, gchar *call_context,
if (tips)
{
- ianjuta_editor_tip_show (IANJUTA_EDITOR_TIP(assist->priv->iassist), tips,
+ ianjuta_editor_tip_show (IANJUTA_EDITOR_TIP(assist->priv->itip), tips,
position_iter, 0,
NULL);
g_list_foreach (tips, (GFunc) g_free, NULL);
@@ -642,7 +643,7 @@ cpp_java_assist_calltip (CppJavaAssist *assist,
if (!calltips)
return; /* Nothing to do */
- editor = IANJUTA_EDITOR (assist->priv->iassist);
+ editor = IANJUTA_EDITOR (assist->priv->itip);
iter = ianjuta_editor_get_position (editor, NULL);
ianjuta_iterable_previous (iter, NULL);
@@ -673,7 +674,7 @@ cpp_java_assist_calltip (CppJavaAssist *assist,
}
else
{
- ianjuta_editor_tip_cancel (IANJUTA_EDITOR_TIP(assist->priv->iassist), NULL);
+ ianjuta_editor_tip_cancel (IANJUTA_EDITOR_TIP(assist->priv->itip), NULL);
g_free (assist->priv->calltip_context);
assist->priv->calltip_context = NULL;
}
@@ -807,16 +808,31 @@ cpp_java_assist_get_name (IAnjutaProvider* provider, GError** e)
}
static void
-cpp_java_assist_install (CppJavaAssist *assist, IAnjutaEditorAssist *iassist)
+cpp_java_assist_install (CppJavaAssist *assist, IAnjutaEditor *ieditor)
{
g_return_if_fail (assist->priv->iassist == NULL);
+
+ if (IANJUTA_IS_EDITOR_ASSIST (ieditor))
+ {
+ assist->priv->iassist = IANJUTA_EDITOR_ASSIST (ieditor);
+ ianjuta_editor_assist_add (IANJUTA_EDITOR_ASSIST (ieditor), IANJUTA_PROVIDER(assist), NULL);
+ }
+ else
+ {
+ assist->priv->iassist = NULL;
+ }
+
+ if (IANJUTA_IS_EDITOR_TIP (ieditor))
+ {
+ assist->priv->itip = IANJUTA_EDITOR_TIP (ieditor);
- assist->priv->iassist = iassist;
-
- g_signal_connect (iassist, "char-added",
- G_CALLBACK (on_editor_char_added), assist);
-
- ianjuta_editor_assist_add (iassist, IANJUTA_PROVIDER(assist), NULL);
+ g_signal_connect (IANJUTA_EDITOR_TIP (ieditor), "char-added",
+ G_CALLBACK (on_editor_char_added), assist);
+ }
+ else
+ {
+ assist->priv->itip = NULL;
+ }
}
static void
@@ -861,14 +877,21 @@ cpp_java_assist_class_init (CppJavaAssistClass *klass)
}
CppJavaAssist *
-cpp_java_assist_new (IAnjutaEditorAssist *iassist,
+cpp_java_assist_new (IAnjutaEditor *ieditor,
IAnjutaSymbolManager *isymbol_manager,
AnjutaPreferences *prefs)
{
- CppJavaAssist *assist = g_object_new (TYPE_CPP_JAVA_ASSIST, NULL);
+ CppJavaAssist *assist;
+
+ if (!IANJUTA_IS_EDITOR_ASSIST (ieditor) && !IANJUTA_IS_EDITOR_TIP (ieditor))
+ {
+ /* No assistance is available with the current editor */
+ return NULL;
+ }
+ assist = g_object_new (TYPE_CPP_JAVA_ASSIST, NULL);
assist->priv->isymbol_manager = isymbol_manager;
assist->priv->preferences = prefs;
- cpp_java_assist_install (assist, iassist);
+ cpp_java_assist_install (assist, ieditor);
return assist;
}
diff --git a/plugins/language-support-cpp-java/cpp-java-assist.h b/plugins/language-support-cpp-java/cpp-java-assist.h
index 79509a0..18f1dce 100644
--- a/plugins/language-support-cpp-java/cpp-java-assist.h
+++ b/plugins/language-support-cpp-java/cpp-java-assist.h
@@ -62,7 +62,7 @@ struct _CppJavaAssist
};
GType cpp_java_assist_get_type (void) G_GNUC_CONST;
-CppJavaAssist *cpp_java_assist_new (IAnjutaEditorAssist *assist,
+CppJavaAssist *cpp_java_assist_new (IAnjutaEditor *editor,
IAnjutaSymbolManager *isymbol_manager,
AnjutaPreferences *preferences);
void cpp_java_assist_check (CppJavaAssist *assist, gboolean autocomplete,
diff --git a/plugins/language-support-cpp-java/plugin.c b/plugins/language-support-cpp-java/plugin.c
index 70d57e5..9a820a5 100644
--- a/plugins/language-support-cpp-java/plugin.c
+++ b/plugins/language-support-cpp-java/plugin.c
@@ -1623,32 +1623,30 @@ install_support (CppJavaPlugin *lang_plugin)
initialize_indentation_params (lang_plugin);
- if (IANJUTA_IS_EDITOR_ASSIST (lang_plugin->current_editor) &&
- !g_str_equal (lang_plugin->current_language, "Vala"))
+ if (!g_str_equal (lang_plugin->current_language, "Vala"))
{
- AnjutaPlugin *plugin;
- AnjutaUI *ui;
- GtkAction *action;
- IAnjutaEditorAssist* iassist;
-
- plugin = ANJUTA_PLUGIN (lang_plugin);
- ui = anjuta_shell_get_ui (plugin->shell, NULL);
- iassist = IANJUTA_EDITOR_ASSIST (lang_plugin->current_editor);
-
+ 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->prefs);
+ /* assist is NULL, if the editor does not provide any assistance */
+ if (assist != NULL)
+ {
+ GtkAction *action;
+
+ lang_plugin->assist = assist;
- lang_plugin->assist =
- cpp_java_assist_new (iassist,
- anjuta_shell_get_interface (plugin->shell,
- IAnjutaSymbolManager,
- NULL),
- lang_plugin->prefs);
-
- /* Enable autocompletion action */
- action = gtk_action_group_get_action (lang_plugin->action_group,
- "ActionEditAutocomplete");
- g_object_set (G_OBJECT (action), "visible", TRUE,
- "sensitive", TRUE, NULL);
+ /* Enable autocompletion action */
+ action = gtk_action_group_get_action (lang_plugin->action_group,
+ "ActionEditAutocomplete");
+ g_object_set (G_OBJECT (action), "visible", TRUE,
+ "sensitive", TRUE, NULL);
+ }
}
lang_plugin->support_installed = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]