Example #1
0
static IAnjutaVcs*
get_vcs_plugin(AnjutaFileManager* file_manager, const gchar* root_uri)
{
	typedef struct
	{
		const gchar* file;
		const gchar* name;
	} VcsSystem;
	VcsSystem vcs_systems[] = {
		{".svn", "Subversion"},
		{".git", "Git"},
		{NULL, NULL}
	};
	
	gint i;
	const gchar* vcs_system = NULL;
	IAnjutaVcs* ivcs = NULL;
	for (i = 0; vcs_systems[i].name != NULL; i++)
	{
		gchar* vcs_uri = g_build_filename (root_uri, vcs_systems[i].file, NULL);
		GFile* vcs_file = g_file_new_for_uri (vcs_uri);
		if (g_file_query_exists(vcs_file, NULL))
		{
			vcs_system = vcs_systems[i].name;
		}
		g_free (vcs_uri);
		g_object_unref (vcs_file);
		if (vcs_system)
			break;
	}
	       
	if (vcs_system)
	{
		/* Load current language editor support plugins */
		AnjutaPluginManager* plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN(file_manager)->shell, NULL);
		GList* plugin_handles = anjuta_plugin_manager_query (plugin_manager,
														   "Anjuta Plugin",
														   "Interfaces",
														   "IAnjutaVcs",
														   "Vcs",
														   "System",
														   vcs_system, NULL);
		if (plugin_handles)
		{
			ivcs = IANJUTA_VCS(anjuta_plugin_manager_get_plugin_by_handle (plugin_manager,
			                                                               (AnjutaPluginHandle *)plugin_handles->data));

			g_signal_connect (G_OBJECT (ivcs), "status_changed",
			                  G_CALLBACK (refresh_signal_cb),
			                  file_manager);
			
			g_list_free (plugin_handles);
		}
	}
	return ivcs;
}
Example #2
0
static void
project_import_checkout_project (AnjutaProjectImportPlugin *import_plugin,
                                 ProjectImportDialog *import_dialog)
{
	CheckoutData *ch_data;
	AnjutaAsyncNotify *async_notify;
	gchar *vcs_uri, *plugin_id, *name;
	GFile *dest_dir, *checkout_dir;
	AnjutaPluginManager *plugin_manager;
	IAnjutaVcs *ivcs;
	GError *err;

	name = project_import_dialog_get_name (import_dialog);
	dest_dir = project_import_dialog_get_dest_dir (import_dialog);
	checkout_dir = g_file_get_child (dest_dir, name);

	g_object_unref (dest_dir);
	g_free (name);
	
	ch_data = g_slice_new (CheckoutData);
	ch_data->import_plugin = import_plugin;
	ch_data->import_dialog = import_dialog;
	ch_data->checkout_dir = checkout_dir;
	
	async_notify = anjuta_async_notify_new ();
	g_signal_connect (async_notify, "finished", G_CALLBACK (checkout_finished),
	                  ch_data);

	vcs_uri = project_import_dialog_get_vcs_uri (import_dialog);
	plugin_id = project_import_dialog_get_vcs_id (import_dialog);

	plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN (import_plugin)->shell, NULL);
	ivcs = IANJUTA_VCS (anjuta_plugin_manager_get_plugin_by_id (plugin_manager, plugin_id));

	err = NULL;
	ianjuta_vcs_checkout (ivcs, vcs_uri, checkout_dir, NULL, async_notify, &err);
	if (err)
	{
		anjuta_util_dialog_error (GTK_WINDOW (import_dialog),
		                          _("Couldn't check out the supplied URI "
		                            "\"%s\". The error returned was: \"%s\""),
		                          vcs_uri, err->message);

		g_error_free (err);
		
		goto cleanup;
	}

	/* hide the import dialog */
	gtk_widget_hide (GTK_WIDGET (import_dialog));

cleanup:
	g_free (vcs_uri);
	g_free (plugin_id);
}
Example #3
0
static IAnjutaVcs*
get_vcs_plugin(AnjutaFileManager* file_manager, const gchar* root_uri)
{
	typedef struct
	{
		const gchar* file;
		const gchar* name;
	} VcsSystem;
	VcsSystem vcs_systems[] = {
		{".svn", "Subversion"},
		{".git", "Git"},
		{NULL, NULL}
	};
	
	gint i;
	const gchar* vcs_system = NULL;
	IAnjutaVcs* ivcs = NULL;
	for (i = 0; vcs_systems[i].name != NULL; i++)
	{
		gchar* vcs_uri = g_build_filename (root_uri, vcs_systems[i].file, NULL);
		GFile* vcs_file = g_file_new_for_uri (vcs_uri);
		if (g_file_query_exists(vcs_file, NULL))
		{
			vcs_system = vcs_systems[i].name;
		}
		g_free (vcs_uri);
		g_object_unref (vcs_file);
		if (vcs_system)
			break;
	}
	
	if (vcs_system)
	{
		/* Load current language editor support plugins */
		AnjutaPluginManager* plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN(file_manager)->shell, NULL);
		GList* plugin_descs = anjuta_plugin_manager_query (plugin_manager,
														   "Anjuta Plugin",
														   "Interfaces",
														   "IAnjutaVcs",
														   "Vcs",
														   "System",
														   vcs_system, NULL);
		if (plugin_descs)
		{
			gchar* plugin_id;
			anjuta_plugin_description_get_string (plugin_descs->data, "Anjuta Plugin", "Location",
													  &plugin_id);
			ivcs = IANJUTA_VCS(anjuta_plugin_manager_get_plugin_by_id (plugin_manager,
																	   plugin_id));
			g_list_free (plugin_descs);
		}
	}
	return ivcs;
}