SF.net SVN: geany-plugins:[963] trunk/geanylatex

frlan at users.sourceforge.net frlan at xxxxx
Tue Sep 29 19:09:33 UTC 2009


Revision: 963
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=963&view=rev
Author:   frlan
Date:     2009-09-29 19:09:33 +0000 (Tue, 29 Sep 2009)

Log Message:
-----------
GeanyLaTeX: Update to Geany plugin API v159 and make usage of utils_get_file_list_full()

Modified Paths:
--------------
    trunk/geanylatex/doc/geanylatex.tex
    trunk/geanylatex/src/geanylatex.c
    trunk/geanylatex/src/reftex.c
    trunk/geanylatex/src/reftex.h
    trunk/geanylatex/src/templates.c
    trunk/geanylatex/src/templates.h

Modified: trunk/geanylatex/doc/geanylatex.tex
===================================================================
--- trunk/geanylatex/doc/geanylatex.tex	2009-09-29 19:08:26 UTC (rev 962)
+++ trunk/geanylatex/doc/geanylatex.tex	2009-09-29 19:09:33 UTC (rev 963)
@@ -135,7 +135,7 @@
 you used a prepared package e.g. from your distribution you probably
 need to install an additional package, this might be called geany-dev
 or geany-devel. Please note that in order to compile and use this
-plugin, you need Geany 0.18 or later (Geany Plugin API v147 or higher).
+plugin, you need Geany 0.19svn or later (Geany Plugin API v159 or higher).
 
 Furthermore you need, of course, a C compiler and python installed. The
 GNU version of the C compiler is recommended. Also there should be a

Modified: trunk/geanylatex/src/geanylatex.c
===================================================================
--- trunk/geanylatex/src/geanylatex.c	2009-09-29 19:08:26 UTC (rev 962)
+++ trunk/geanylatex/src/geanylatex.c	2009-09-29 19:09:33 UTC (rev 963)
@@ -24,7 +24,7 @@
 
 #include "geanylatex.h"
 
-PLUGIN_VERSION_CHECK(147)
+PLUGIN_VERSION_CHECK(159)
 
 PLUGIN_SET_INFO(_("LaTeX"), _("Plugin to provide better LaTeX support"),
 	VERSION,"Frank Lanitz <frank at frank.uvena.de>")
@@ -66,7 +66,7 @@
 static GtkWidget *box = NULL;
 
 /* Configuration file */
-static gchar *config_file = NULL; 
+static gchar *config_file = NULL;
 
 PLUGIN_KEY_GROUP(geanylatex, COUNT_KB)
 
@@ -448,7 +448,7 @@
 	if (doc->real_path != NULL)
 	{
 		dir = g_path_get_dirname(doc->real_path);
-		file_list = utils_get_file_list(dir, NULL, NULL);
+		file_list = utils_get_file_list_full(dir, TRUE, TRUE, NULL);
 		glatex_add_Labels(textbox_ref, file_list);
 		model = gtk_combo_box_get_model(GTK_COMBO_BOX(textbox_ref));
 		gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model),
@@ -754,21 +754,21 @@
 	gtk_misc_set_alignment(GTK_MISC(label_template), 0, 0.5);
 
 	gtk_table_attach_defaults(GTK_TABLE(table), label_template, 0, 1, 0, 1);
-	gtk_table_attach_defaults(GTK_TABLE(table), template_combobox, 1, 2, 0, 1);	
-	
-	/*  Adding default/build in templates to pull down and set the generic 
+	gtk_table_attach_defaults(GTK_TABLE(table), template_combobox, 1, 2, 0, 1);
+
+	/*  Adding default/build in templates to pull down and set the generic
 	 * 	one as default */
-	gtk_combo_box_insert_text(GTK_COMBO_BOX(template_combobox), 
-		LATEX_WIZARD_TEMPLATE_DEFAULT, _("Default"));	
-	gtk_combo_box_set_active(GTK_COMBO_BOX(template_combobox), 
+	gtk_combo_box_insert_text(GTK_COMBO_BOX(template_combobox),
+		LATEX_WIZARD_TEMPLATE_DEFAULT, _("Default"));
+	gtk_combo_box_set_active(GTK_COMBO_BOX(template_combobox),
 		LATEX_WIZARD_TEMPLATE_DEFAULT);
-	
-	/*  Checking whether some custom template are available and adding 
-	 *  if so. 
+
+	/*  Checking whether some custom template are available and adding
+	 *  if so.
 	 *  Also init array with templates available. */
 	template_list = glatex_init_custom_templates();
 	glatex_add_templates_to_combobox(template_list, template_combobox);
-	
+
 	/*  Documentclass */
 	label_documentclass = gtk_label_new(_("Documentclass:"));
 	documentclass_combobox = gtk_combo_box_new_text();
@@ -784,7 +784,7 @@
 		_("Letter"));
 	gtk_combo_box_insert_text(GTK_COMBO_BOX(documentclass_combobox), 4,
 		_("Presentation"));
-	
+
 	gtk_combo_box_set_active(GTK_COMBO_BOX(documentclass_combobox), 0);
 
 	gtk_misc_set_alignment(GTK_MISC(label_documentclass), 0, 0.5);
@@ -804,7 +804,7 @@
 					  latex_encodings[i].name);
 	}
 
-	gtk_combo_box_set_active(GTK_COMBO_BOX(encoding_combobox), 
+	gtk_combo_box_set_active(GTK_COMBO_BOX(encoding_combobox),
 		find_latex_enc(geany_data->file_prefs->default_new_encoding));
 
 	gtk_misc_set_alignment(GTK_MISC(label_encoding), 0, 0.5);
@@ -1029,14 +1029,14 @@
 			}
 
 		}
-		
+
 		/*  Get the correct template */
-		/*  First check whether its a build in one or a custom one than 
+		/*  First check whether its a build in one or a custom one than
 		 *  assign the wished template */
-		if (template_int < LATEX_WIZARD_TEMPLATE_END || 
+		if (template_int < LATEX_WIZARD_TEMPLATE_END ||
 			template_list == NULL)
 		{
-			if (template_int == LATEX_WIZARD_TEMPLATE_DEFAULT && 
+			if (template_int == LATEX_WIZARD_TEMPLATE_DEFAULT &&
 				documentclass_int == 3 && documentclass_int == 4)
 				code = g_string_new(TEMPLATE_LATEX);
 			else if (documentclass_int == 3)
@@ -1047,16 +1047,16 @@
 				code = g_string_new(TEMPLATE_LATEX);
 		}
 		else
-		{	
+		{
 			TemplateEntry *tmp = NULL;
-			
-			/* Return if the value choose is for some uknown reason to high */	
+
+			/* Return if the value choose is for some uknown reason to high */
 			if (template_int > (template_list->len + LATEX_WIZARD_TEMPLATE_END))
 				return;
-			
+
 			tmp = g_ptr_array_index(template_list, template_int - LATEX_WIZARD_TEMPLATE_END);
 			code = glatex_get_template_from_file(tmp->filepath);
-			
+
 			/* Cleaning up template array as there is no usage for anymore */
 			g_ptr_array_foreach (template_list, (GFunc)glatex_free_TemplateEntry, NULL);
 			g_ptr_array_free(template_list, TRUE);
@@ -1091,7 +1091,7 @@
 					{
 						author = g_strconcat("\\author{", author, "}\n", NULL);
 					}
-	
+
 					utils_string_replace_all(code, "{AUTHOR}", author);
 				}
 				else
@@ -1103,7 +1103,7 @@
 					{
 						utils_string_replace_all(code, "{AUTHOR}", "\% \\author{}\n");
 					}
-	
+
 				g_free(author);
 			}
 			if (date != NULL)
@@ -1129,7 +1129,7 @@
 					{
 						title = g_strconcat("\\title{", title, "}\n", NULL);
 					}
-	
+
 					utils_string_replace_all(code, "{TITLE}", title);
 				}
 				else
@@ -1141,13 +1141,13 @@
 					{
 						utils_string_replace_all(code, "{TITLE}", "\% \\title{} \n");
 					}
-	
+
 				g_free(title);
 			}
-	
+
 			utils_string_replace_all(code, "{OPENING}", _("Dear Sir or Madame"));
 			utils_string_replace_all(code, "{CLOSING}", _("With kind regards"));
-	
+
 			output = g_string_free(code, FALSE);
 			show_output(output, NULL, encoding_int);
 			g_free(output);

Modified: trunk/geanylatex/src/reftex.c
===================================================================
--- trunk/geanylatex/src/reftex.c	2009-09-29 19:08:26 UTC (rev 962)
+++ trunk/geanylatex/src/reftex.c	2009-09-29 19:09:33 UTC (rev 963)
@@ -23,32 +23,21 @@
 #include "reftex.h"
 #include "latexutils.h"
 
-void glatex_parse_aux_file(gpointer file, gpointer combobox)
+void glatex_parse_aux_file(gchar *file, gpointer combobox)
 {
 	gchar **aux_entries = NULL;
 	int i = 0;
 	LaTeXLabel *tmp;
-	gchar *tmp_complete_path = NULL;
-	gchar *tmp_basedir = NULL;
-	gchar *sep = NULL;
 	gchar *tmp_label_name = NULL;
-	GeanyDocument *doc = NULL;
 
-	doc = document_get_current();
-	tmp_basedir = g_path_get_dirname(doc->real_path);
-	if (doc == NULL)
-		return;
-
 	if (file != NULL)
 	{
 		/*  Return if its not an aux file */
 		if (!g_str_has_suffix(file, ".aux"))
 			return;
-			
-		sep = (utils_str_equal(doc->real_path, "/")) ? "" : G_DIR_SEPARATOR_S;
-		tmp_complete_path = g_strconcat(tmp_basedir, sep, file, NULL);
-		aux_entries = geanylatex_read_file_in_array(tmp_complete_path);
 
+		aux_entries = geanylatex_read_file_in_array(file);
+
 		if (aux_entries != NULL)
 		{
 			for (i = 0; aux_entries[i] != NULL ; i++)
@@ -64,19 +53,7 @@
 			}
 			g_free(aux_entries);
 		}
-
-		/* Cleaning up a bit */
-		if (tmp_complete_path != NULL)
-		{
-			g_free(tmp_complete_path);
-			tmp_complete_path = NULL;
-		}
 	}
-	if (tmp_basedir != NULL)
-	{
-		g_free(tmp_basedir);
-		tmp_basedir = NULL;
-	}
 }
 
 void glatex_add_Labels(GtkWidget *combobox, GSList *dir)
@@ -86,7 +63,8 @@
 	{
 		return;
 	}
-	g_slist_foreach(dir, glatex_parse_aux_file, combobox);
+
+	g_slist_foreach(dir, (GFunc) glatex_parse_aux_file, combobox);
 }
 
 

Modified: trunk/geanylatex/src/reftex.h
===================================================================
--- trunk/geanylatex/src/reftex.h	2009-09-29 19:08:26 UTC (rev 962)
+++ trunk/geanylatex/src/reftex.h	2009-09-29 19:09:33 UTC (rev 963)
@@ -35,6 +35,6 @@
 
 LaTeXLabel *glatex_parseLine(const gchar *line);
 
-void glatex_parse_aux_file(gpointer file, gpointer combobox);
+void glatex_parse_aux_file(gchar* file, gpointer combobox);
 
 #endif

Modified: trunk/geanylatex/src/templates.c
===================================================================
--- trunk/geanylatex/src/templates.c	2009-09-29 19:08:26 UTC (rev 962)
+++ trunk/geanylatex/src/templates.c	2009-09-29 19:09:33 UTC (rev 963)
@@ -37,26 +37,20 @@
 }
 
 
-static void glatex_init_cutom_template_item(gpointer file, gpointer array)
-{	
-	gchar* filepath;
+static void glatex_init_cutom_template_item(gchar *file, GPtrArray *array)
+{
 	TemplateEntry *template = g_new0(TemplateEntry, 1);
-	
+
 	/* Return if its not a searched file */
 	if (g_str_has_suffix(file,".gtl") == FALSE)
 		return;
-	
-	/* Creating up config dir for checking for templates */
-	filepath = g_strconcat(geany->app->configdir,
-		G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
-		"geanyLaTeX", G_DIR_SEPARATOR_S, file, NULL);
-	template->filepath = filepath;
-	
-	/* FIXME: Cut of .gtl from filename */
-	template->label = file;
-	
+
+	template->filepath = g_strdup(file);
+
+	template->label = g_path_get_basename(file);
+
 	/* Adding struct to array */
-	template->template = glatex_get_template_from_file(filepath);
+	template->template = glatex_get_template_from_file(file);
 	g_ptr_array_add(array, template);
 }
 
@@ -67,21 +61,21 @@
 	gchar *tmp_basedir = NULL;
 	GSList *file_list = NULL;
 	GPtrArray *templates = NULL;
-	
+
 	/* Creating up config dir for checking for templates */
 	tmp_basedir = g_strconcat(geany->app->configdir,
 			G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
 			"geanyLaTeX", G_DIR_SEPARATOR_S, NULL);
-	
+
 	/* Putting all files in configdir to a file list */
-	file_list = utils_get_file_list(tmp_basedir, length, NULL);
-	
+	file_list = utils_get_file_list_full(tmp_basedir, TRUE, TRUE, NULL);
+
 	/* Init GPtrArray */
 	templates = g_ptr_array_new();
-	
+
 	/* Iterating on all list items */
 	g_slist_foreach(file_list, (GFunc)glatex_init_cutom_template_item, templates);
-	
+ 	g_slist_foreach(file_list, (GFunc) g_free, NULL);
 	g_slist_free(file_list);
 	return templates;
 }
@@ -104,7 +98,7 @@
 	for (i = 0; i < templates->len; i++)
 	{
 		tmp = g_ptr_array_index(templates,i);
-		gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), 
-			tmp->label);	
+		gtk_combo_box_append_text(GTK_COMBO_BOX(combobox),
+			tmp->label);
 	}
 }

Modified: trunk/geanylatex/src/templates.h
===================================================================
--- trunk/geanylatex/src/templates.h	2009-09-29 19:08:26 UTC (rev 962)
+++ trunk/geanylatex/src/templates.h	2009-09-29 19:09:33 UTC (rev 963)
@@ -24,13 +24,13 @@
 
 #include "geanylatex.h"
 
-/* Add an enum entry for every new build in templates which are not 
- * the TEMPLATE_LATEX_BEAMER and TEMPLATE_LATEX_LETTER. 
- * Anyway, you sould prefer to add new templates not by patching this 
- * code but by providing a template as described in documentation. 
- * However, whenever adding a new template here, please ensure 
- * LATEX_WIZARD_TEMPLATE_END is the last entry as it will trigger 
- * the custom templates.*/ 
+/* Add an enum entry for every new build in templates which are not
+ * the TEMPLATE_LATEX_BEAMER and TEMPLATE_LATEX_LETTER.
+ * Anyway, you sould prefer to add new templates not by patching this
+ * code but by providing a template as described in documentation.
+ * However, whenever adding a new template here, please ensure
+ * LATEX_WIZARD_TEMPLATE_END is the last entry as it will trigger
+ * the custom templates.*/
 enum {
 	LATEX_WIZARD_TEMPLATE_DEFAULT = 0,
 	LATEX_WIZARD_TEMPLATE_END


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Plugins-Commits mailing list