Exemple #1
0
/**
 * parser_cxx_assist_install:
 * @assist: ParserCxxAssist object
 * @ieditor: Editor to install support for
 * @iparser: Parser to install support for
 *
 * Returns: Registers provider for editor
 */
static void
parser_cxx_assist_install (ParserCxxAssist *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);
		g_signal_connect (ieditor, "cancelled",
		                  G_CALLBACK (parser_cxx_assist_cancelled), assist);
	}
	else
		assist->priv->iassist = NULL;

	if (IANJUTA_IS_EDITOR_TIP (ieditor))
		assist->priv->itip = IANJUTA_EDITOR_TIP (ieditor);
	else
		assist->priv->itip = NULL;
		
	if (IANJUTA_IS_FILE (assist->priv->iassist))
	{
		GFile *file = ianjuta_file_get_file (
		                          IANJUTA_FILE (assist->priv->iassist), NULL);
		if (file != NULL)
		{
			assist->priv->editor_filename = g_file_get_path (file);
			g_object_unref (file);
		}
	}
}
Exemple #2
0
/**
 * parser_cxx_assist_query_calltip:
 * @self: Self
 * @call_context: name of method/function
 * e: Error propagation
 *
 * Starts an async query for the calltip
 */
static void
parser_cxx_assist_query_calltip (ParserCxxAssist* assist,
                                 const gchar *call_context,
                                 IAnjutaIterable* calltip_iter)
{
	/* Search file */
	if (IANJUTA_IS_FILE (assist->priv->itip))
	{
		GFile *file = ianjuta_file_get_file (IANJUTA_FILE (assist->priv->itip),
		                                     NULL);

		if (file != NULL)
		{
			assist->priv->async_calltip_file = 1;
			ianjuta_symbol_query_search_file (assist->priv->calltip_query_file,
				                              call_context, file, NULL);
			g_object_unref (file);
		}
	}

	/* Search Project */
	assist->priv->async_calltip_project = 1;
	ianjuta_symbol_query_search (assist->priv->calltip_query_project,
	                             call_context, NULL);
	
	/* Search system */
	assist->priv->async_calltip_system = 1;
	ianjuta_symbol_query_search (assist->priv->calltip_query_system,
		                         call_context, NULL);
}
Exemple #3
0
static void
on_show_in_file_manager (GtkAction* action, AnjutaFileManager* file_manager)
{
	IAnjutaDocumentManager* docman;
	IAnjutaDocument* document;
	GFile* file;

	docman = anjuta_shell_get_interface (ANJUTA_PLUGIN (file_manager)->shell,
										 IAnjutaDocumentManager, NULL);
	g_return_if_fail (docman);

	document = ianjuta_document_manager_get_current_document (docman, NULL);
	if (!IANJUTA_IS_FILE (document))
		return;

	file = ianjuta_file_get_file (IANJUTA_FILE (document), NULL);
	if (!file)
		return;

	file_view_set_selected (file_manager->fv, file);
	g_object_unref (file);

	anjuta_shell_present_widget (ANJUTA_PLUGIN (file_manager)->shell,
								 file_manager->sw, NULL);
}
Exemple #4
0
/**
 * parser_cxx_assist_create_autocompletion_cache:
 * @assist: self
 * @cursor: Current cursor position
 * 
 * Create completion cache for autocompletion. This is done async.
 *
 * Returns: the iter where a preword was detected, NULL otherwise
 */ 
static IAnjutaIterable*
parser_cxx_assist_create_autocompletion_cache (ParserCxxAssist* assist,
                                               IAnjutaIterable* cursor)
{
	IAnjutaIterable* start_iter;
	gchar* pre_word = anjuta_language_provider_get_pre_word (
	                                  assist->priv->lang_prov,
                                      IANJUTA_EDITOR (assist->priv->iassist),
									  cursor, &start_iter, WORD_CHARACTER);
	if (!pre_word || strlen (pre_word) <= 3)
	{
		if (start_iter)
			g_object_unref (start_iter);
		return NULL;
	}
	else
	{
		gchar *pattern = g_strconcat (pre_word, "%", NULL);

		parser_cxx_assist_update_pre_word (assist, pre_word);

		if (IANJUTA_IS_FILE (assist->priv->iassist))
		{
			GFile *file = ianjuta_file_get_file (
			                      IANJUTA_FILE (assist->priv->iassist), NULL);
			if (file != NULL)
			{
				assist->priv->async_file_id = 1;
				ianjuta_symbol_query_search_file (assist->priv->ac_query_file,
												  pattern, file, NULL);
				g_object_unref (file);
			}
		}
		/* This will avoid duplicates of FUNCTION and PROTOTYPE */
		assist->priv->async_project_id = 1;
		ianjuta_symbol_query_search (assist->priv->ac_query_project, pattern,
		                             NULL);
		assist->priv->async_system_id = 1;
		ianjuta_symbol_query_search (assist->priv->ac_query_system, pattern,
		                             NULL);
		g_free (pre_word);
		g_free (pattern);
		
		return start_iter;
	}
}
Exemple #5
0
static void
current_document_added (AnjutaPlugin *plugin, const gchar *name,
						const GValue *value, gpointer user_data)
{
	AnjutaFileManager* file_manager = (AnjutaFileManager*) plugin;
	IAnjutaDocument *current_document;
	GFile *file;

	if (!g_settings_get_boolean (file_manager->settings, PREF_SELECT_CURRENT_DOCUMENT))
		return;

	current_document = g_value_get_object (value);
	if (!IANJUTA_IS_FILE (current_document))
		return;

	file = ianjuta_file_get_file (IANJUTA_FILE (current_document), NULL);
	if (!file)
		return;

	ianjuta_file_manager_set_selected (IANJUTA_FILE_MANAGER (plugin), file, NULL);
	g_object_unref (file);
}
Exemple #6
0
IAnjutaEditor *
anjuta_docman_goto_file_line_mark (AnjutaDocman *docman, GFile* file,
								   gint line, gboolean mark)
{
	IAnjutaDocument *doc;
	IAnjutaEditor *te;
	AnjutaDocmanPage *page;

	g_return_val_if_fail (file != NULL, NULL);

	if (!g_file_query_exists (file, NULL))
	{
		return NULL;
	}

	/* Save current uri and line in document history list */
	page = anjuta_docman_get_current_page (docman);
	if (page && page->doc && IANJUTA_IS_FILE (page->doc))
	{
		GFile* file = ianjuta_file_get_file (IANJUTA_FILE (page->doc), NULL);

		if (file)
		{
			gint line = 0;

			if (IANJUTA_IS_EDITOR (page->doc))
			{
				line = ianjuta_editor_get_lineno (IANJUTA_EDITOR (page->doc), NULL);
			}

			an_file_history_push (file, line);
		}
	}

	/* if possible, use a document that's already open */
	doc = anjuta_docman_get_document_for_file (docman, file);
	if (doc == NULL)
	{
		te = anjuta_docman_add_editor (docman, file, NULL);
		doc = IANJUTA_DOCUMENT (te);
	}
	else if (IANJUTA_IS_EDITOR (doc))
	{
		te = IANJUTA_EDITOR (doc);
	}
	else
	{
		doc = NULL;
		te = NULL;
	}

	if (te != NULL)
	{
		if (line >= 0)
		{
			ianjuta_editor_goto_line (te, line, NULL);
			if (mark && IANJUTA_IS_MARKABLE (doc))
			{
				ianjuta_markable_delete_all_markers (IANJUTA_MARKABLE (doc),
													IANJUTA_MARKABLE_LINEMARKER,
													NULL);
				ianjuta_markable_mark (IANJUTA_MARKABLE (doc), line,
									  IANJUTA_MARKABLE_LINEMARKER, NULL, NULL);
			}
		}
	}
	if (doc != NULL)
	{
		anjuta_docman_present_notebook_page (docman, doc);
		ianjuta_document_grab_focus (IANJUTA_DOCUMENT (doc), NULL);
	}

	return te;
}