Commit 24df5a0d authored by Sebastien Granjoux's avatar Sebastien Granjoux

Allow to read project templates from user defined directories Document

	* plugins/project-wizard/druid.c,
	plugins/project-wizard/parser.c,
	plugins/project-wizard/header.c,
	plugins/project-wizard/header.h,
	manuals/reference/libanjuta/project-wizard-format.sgml:
	Allow to read project templates from user defined directories
	Document this improvement

	* manuals/anjuta-manual/C/build.xml:
	Fix error in xml tags

	* plugins/scintilla/scintilla/Makefile.am,
	manuals/reference/libanjuta/Makefile.am:
	Fix makefile after scintilla move

	* plugins/project-wizard/appwizard.png:
	Use a transparent background for project wizard side image

svn path=/trunk/; revision=4628
parent 689866fe
2009-01-24 Sébastien Granjoux <seb.sfo@free.fr>
* plugins/project-wizard/druid.c,
plugins/project-wizard/parser.c,
plugins/project-wizard/header.c,
plugins/project-wizard/header.h,
manuals/reference/libanjuta/project-wizard-format.sgml:
Allow to read project templates from user defined directories
Document this improvement
* manuals/anjuta-manual/C/build.xml:
Fix error in xml tags
* plugins/scintilla/scintilla/Makefile.am,
manuals/reference/libanjuta/Makefile.am:
Fix makefile after scintilla move
* plugins/project-wizard/appwizard.png:
Use a transparent background for project wizard side image
2009-01-23 Massimo Cora' <mcora@svn.gnome.org>
* plugins/symbol-db/images/Makefile.am:
......@@ -136,7 +136,7 @@
</itemizedlist>
</para>
</sect2>
<sect2 id="configure">
<sect2 id="select-configure">
<title>Select a configuration</title>
<para>
If you have created different configurations, you can select which one is active by
......@@ -144,7 +144,7 @@
<guimenuitem>Select Configuration</guimenuitem></menuchoice>.
</para>
</sect2>
<sect2 id="configure">
<sect2 id="clean-configure">
<title>Clean a configuration</title>
<para>
To clean the project and leave it in a state that requires rerunning the
......
......@@ -73,13 +73,13 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir) \
-I$(top_builddir)/libanjuta \
-I$(top_builddir)/plugins/editor/scintilla/include \
-I$(top_builddir)/plugins/scintilla/scintilla/include \
$(LIBANJUTA_CFLAGS)
GTKDOC_LIBS = \
$(top_builddir)/libanjuta/libanjuta.la \
$(top_builddir)/libanjuta/interfaces/libanjuta-interfaces.la \
$(top_builddir)/plugins/editor/scintilla/libanjuta-scintilla.la \
$(top_builddir)/plugins/scintilla/scintilla/libanjuta-scintilla.la \
$(LIBANJUTA_LIBS)
else
INCLUDES = \
......
......@@ -12,8 +12,17 @@
<sect1 id="overview">
<title>Overview</title>
<para>
The template file <emphasis>looks like</emphasis> a
xml document. It is divided in four parts:
The template files <emphasis>look like</emphasis>
xml documents and have normally the extension
<filename>.wiz</filename>. All templates and others
related files are installed by default in <filename>$anjuta_install_dir/share/anjuta/project</filename>. But the project wizard looks
for templates in the sub directory <filename>anjuta/project</filename> of
all user data directories as defined by
<ulink type="http" url="http://www.freedesktop.org/Standards/basedir-spec">XDG Base Directory Specification</ulink> too. It is possible to
override a Anjuta project template by an user one put,
by example, in <filename>~/.local/share/anjuta/project</filename>.
</para>
<para> The template file is divided in four parts:
an header block, one or more page blocks, a content block
and an optional action block. The file is read several times, one
time for each block but before reading it,
......
plugins/project-wizard/appwizard.png

17.5 KB | W: | H:

plugins/project-wizard/appwizard.png

20.8 KB | W: | H:

plugins/project-wizard/appwizard.png
plugins/project-wizard/appwizard.png
plugins/project-wizard/appwizard.png
plugins/project-wizard/appwizard.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -48,9 +48,6 @@
/*---------------------------------------------------------------------------*/
#define PROJECT_WIZARD_DIRECTORY PACKAGE_DATA_DIR"/project"
/* Uncomment if you want to keep project wizards in a non-standard dir
#define LOCAL_PROJECT_WIZARD_DIRECTORY anjuta_utils_data_dir/projects/
*/
/* Default property name useable in wizard file
*---------------------------------------------------------------------------*/
......@@ -345,8 +342,10 @@ static gboolean
npw_druid_fill_selection_page (NPWDruid* druid)
{
gboolean ok;
gchar* local_dir;
gchar* dir;
const gchar * const * sys_dir;
const gchar * user_dir;
/* Remove all previous data */
druid->project_book = GTK_NOTEBOOK (gtk_assistant_get_nth_page (GTK_ASSISTANT (druid->window), PROJECT_PAGE));
gtk_notebook_remove_page(druid->project_book, 0);
......@@ -354,18 +353,26 @@ npw_druid_fill_selection_page (NPWDruid* druid)
/* Create list of projects */
druid->header_list = npw_header_list_new ();
/* Read project template in user directory,
* normally ~/.local/share/anjuta/project,
* the first template read override the others */
dir = g_build_filename (g_get_user_data_dir (), "anjuta", "project", NULL);
npw_header_list_readdir (&druid->header_list, dir);
g_free (dir);
/* Read project template in system directory */
for (sys_dir = g_get_system_data_dirs (); *sys_dir != NULL; sys_dir++)
{
dir = g_build_filename (*sys_dir, "anjuta", "project", NULL);
npw_header_list_readdir (&druid->header_list, PROJECT_WIZARD_DIRECTORY);
g_free (dir);
}
/* Fill list with all project in directory */
ok = npw_header_list_readdir (&druid->header_list, PROJECT_WIZARD_DIRECTORY);
#ifdef LOCAL_PROJECT_WIZARD_DIRECTORY
local_dir = g_build_filename (g_get_home_dir(), LOCAL_PROJECT_WIZARD_DIRECTORY, NULL);
#else
local_dir = anjuta_util_get_user_data_file_path ("projects/",NULL);
#endif
ok = npw_header_list_readdir (&druid->header_list, local_dir) || ok;
g_free (local_dir);
/* Read anjuta installation directory */
npw_header_list_readdir (&druid->header_list, PROJECT_WIZARD_DIRECTORY);
if (!ok)
if (g_list_length (druid->header_list) == 0)
{
anjuta_util_dialog_error (GTK_WINDOW (ANJUTA_PLUGIN (druid->plugin)->shell),_("Unable to find any project template in %s"), PROJECT_WIZARD_DIRECTORY);
return FALSE;
......
......@@ -238,15 +238,53 @@ npw_header_list_insert_header (GList *list, NPWHeader *header)
template_list = (GList *)node->data;
first = (NPWHeader *)template_list->data;
res = g_ascii_strcasecmp (npw_header_get_category (first), npw_header_get_category (header));
if (res > 0) break;
if (res == 0)
{
node->data = g_list_insert_sorted (template_list, header, (GCompareFunc) compare_header_name);
return list;
}
else if (res > 0)
{
break;
}
}
template_list = g_list_prepend (NULL, header);
return g_list_insert_before (list, node, template_list);
}
NPWHeader*
npw_header_list_find_header (GList *list, NPWHeader *header)
{
GList *node;
GList *template_list;
for (node = g_list_first (list); node != NULL; node = g_list_next (node))
{
NPWHeader* first;
gint res;
template_list = (GList *)node->data;
first = (NPWHeader *)template_list->data;
res = g_ascii_strcasecmp (npw_header_get_category (first), npw_header_get_category (header));
if (res == 0)
{
GList *find;
find = g_list_find_custom (template_list, header, (GCompareFunc) compare_header_name);
if (find != NULL)
{
return (NPWHeader *)find->data;
}
break;
}
else if (res > 0)
{
break;
}
}
return NULL;
}
......@@ -62,5 +62,6 @@ GList* npw_header_check_required_packages (NPWHeader* self);
GList* npw_header_list_new (void);
void npw_header_list_free (GList* list);
GList * npw_header_list_insert_header (GList *list, NPWHeader *header);
NPWHeader* npw_header_list_find_header (GList *list, NPWHeader *header);
#endif
......@@ -351,8 +351,6 @@ typedef struct _NPWHeaderParser
NPWTag* last;
/* Unknown element stack */
guint unknown;
/* List where should be added the header */
GList** list;
/* Current header */
NPWHeader* header;
/* Name of file read */
......@@ -529,7 +527,6 @@ parse_header_text (GMarkupParseContext* context,
if (npw_header_get_category (parser->header) == NULL)
{
npw_header_set_category (parser->header, text);
*parser->list = npw_header_list_insert_header (*parser->list, parser->header);
}
else
{
......@@ -575,7 +572,6 @@ npw_header_parser_new (GList** list, const gchar* filename)
parser->unknown = 0;
parser->tag[0] = NPW_NO_TAG;
parser->last = parser->tag;
parser->list = list;
parser->header = NULL;
parser->filename = g_strdup (filename);
......@@ -615,6 +611,7 @@ npw_header_list_read (GList** list, const gchar* filename)
gchar* content;
gsize len;
NPWHeaderParser* parser;
NPWHeader* header;
GError* err = NULL;
g_return_val_if_fail (list != NULL, FALSE);
......@@ -631,8 +628,9 @@ npw_header_list_read (GList** list, const gchar* filename)
parser = npw_header_parser_new (list, filename);
npw_header_parser_parse (parser, content, len, &err);
header = parser->header;
/* Parse only a part of the file, so need to call parser_end_parse */
npw_header_parser_free (parser);
g_free (content);
......@@ -641,7 +639,8 @@ npw_header_list_read (GList** list, const gchar* filename)
/* Parsing must end with an error
* generated at the end of the project wizard block */
g_warning ("Missing project wizard block in %s", filename);
npw_header_free (header);
return FALSE;
}
if (g_error_matches (err, parser_error_quark (), NPW_STOP_PARSING) == FALSE)
......@@ -649,11 +648,18 @@ npw_header_list_read (GList** list, const gchar* filename)
/* Parsing error */
g_warning (err->message);
g_error_free (err);
npw_header_free (header);
return FALSE;
}
g_error_free (err);
/* Add header to list if template does not already exist*/
if (npw_header_list_find_header (*list, header) == NULL)
{
*list = npw_header_list_insert_header (*list, header);
}
return TRUE;
}
......
......@@ -91,11 +91,11 @@ update-scintilla:
cp $(srcdir)/scintilla/include/*.iface $(srcdir)/include/
echo "## Lexers make file" > lexers.make
echo 'LEXER_OBJS = \' >> lexers.make;
echo -n ' $$(top_srcdir)/plugins/editor/scintilla/StyleContext.o' >> lexers.make
echo -n ' $$(top_srcdir)/plugins/scintilla/scintilla/StyleContext.o' >> lexers.make
for lex in Lex*.cxx; do \
lex=`echo $$lex | sed -e "s/cxx$$/o/"`; \
echo '\' >> lexers.make; \
echo -n ' $$(top_srcdir)/plugins/editor/scintilla/' >> lexers.make; \
echo -n ' $$(top_srcdir)/plugins/scintilla/scintilla/' >> lexers.make; \
echo -n "$$lex" >> lexers.make; \
done
echo "" >> lexers.make
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment