anjuta r4628 - in trunk: . manuals/anjuta-manual/C manuals/reference/libanjuta plugins/project-wizard plugins/scintilla/scintilla



Author: sgranjoux
Date: Sat Jan 24 08:48:43 2009
New Revision: 4628
URL: http://svn.gnome.org/viewvc/anjuta?rev=4628&view=rev

Log:
	* 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


Modified:
   trunk/ChangeLog
   trunk/manuals/anjuta-manual/C/build.xml
   trunk/manuals/reference/libanjuta/Makefile.am
   trunk/manuals/reference/libanjuta/project-wizard-format.sgml
   trunk/plugins/project-wizard/appwizard.png
   trunk/plugins/project-wizard/druid.c
   trunk/plugins/project-wizard/header.c
   trunk/plugins/project-wizard/header.h
   trunk/plugins/project-wizard/parser.c
   trunk/plugins/scintilla/scintilla/Makefile.am

Modified: trunk/manuals/anjuta-manual/C/build.xml
==============================================================================
--- trunk/manuals/anjuta-manual/C/build.xml	(original)
+++ trunk/manuals/anjuta-manual/C/build.xml	Sat Jan 24 08:48:43 2009
@@ -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

Modified: trunk/manuals/reference/libanjuta/Makefile.am
==============================================================================
--- trunk/manuals/reference/libanjuta/Makefile.am	(original)
+++ trunk/manuals/reference/libanjuta/Makefile.am	Sat Jan 24 08:48:43 2009
@@ -73,13 +73,13 @@
 	-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 =						\

Modified: trunk/manuals/reference/libanjuta/project-wizard-format.sgml
==============================================================================
--- trunk/manuals/reference/libanjuta/project-wizard-format.sgml	(original)
+++ trunk/manuals/reference/libanjuta/project-wizard-format.sgml	Sat Jan 24 08:48:43 2009
@@ -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,

Modified: trunk/plugins/project-wizard/appwizard.png
==============================================================================
Binary files. No diff available.

Modified: trunk/plugins/project-wizard/druid.c
==============================================================================
--- trunk/plugins/project-wizard/druid.c	(original)
+++ trunk/plugins/project-wizard/druid.c	Sat Jan 24 08:48:43 2009
@@ -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 @@
 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 @@
 	
 	/* 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;

Modified: trunk/plugins/project-wizard/header.c
==============================================================================
--- trunk/plugins/project-wizard/header.c	(original)
+++ trunk/plugins/project-wizard/header.c	Sat Jan 24 08:48:43 2009
@@ -238,15 +238,53 @@
 		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;
+}

Modified: trunk/plugins/project-wizard/header.h
==============================================================================
--- trunk/plugins/project-wizard/header.h	(original)
+++ trunk/plugins/project-wizard/header.h	Sat Jan 24 08:48:43 2009
@@ -62,5 +62,6 @@
 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

Modified: trunk/plugins/project-wizard/parser.c
==============================================================================
--- trunk/plugins/project-wizard/parser.c	(original)
+++ trunk/plugins/project-wizard/parser.c	Sat Jan 24 08:48:43 2009
@@ -351,8 +351,6 @@
 	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 @@
 			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 @@
 	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 @@
 	gchar* content;
 	gsize len;
 	NPWHeaderParser* parser;
+	NPWHeader* header;
 	GError* err = NULL;
 
 	g_return_val_if_fail (list != NULL, FALSE);
@@ -631,8 +628,9 @@
 	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 @@
 		/* 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 @@
 		/* 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;	
 }
 

Modified: trunk/plugins/scintilla/scintilla/Makefile.am
==============================================================================
--- trunk/plugins/scintilla/scintilla/Makefile.am	(original)
+++ trunk/plugins/scintilla/scintilla/Makefile.am	Sat Jan 24 08:48:43 2009
@@ -91,11 +91,11 @@
 	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



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