Commit 4d5020a5 authored by Almer S. Tigelaar's avatar Almer S. Tigelaar Committed by Almer S. Tigelaar

Remove subdirectories, convert into a flat directory with structured

2000-10-01  Almer S. Tigelaar  <almer1@dds.nl>

	* templates/autoformat/, templates/autoformat/Makefile.am:
	Remove subdirectories, convert into a flat directory with structured
	filenames.

	* configure.in:
	Remove templates/autoformat subdirectories

	* gnumeric.spec.in:
	Adjust to cope with new autoformat directory structure

	* src/dialogs/Makefile.am:
	Remove -DGNUMERIC_AUTOFORMATDIR

	* src/Makefile.am
	Add -DGNUMERIC_AUTOFORMATDIR

	* src/file-autoft.c, src/file-autoft.h:
	New, functions for loading special listings of the autoformat
	directory.

	* src/dialogs/dialog-autoformat:
	(categories_load): Remove
	(categories_free): Remove
	(templates_load): Adjust to use template_list_load
parent 5f36e81e
2000-10-01 Almer S. Tigelaar <almer1@dds.nl>
* templates/autoformat/, templates/autoformat/Makefile.am:
Remove subdirectories, convert into a flat directory with structured
filenames.
* configure.in:
Remove templates/autoformat subdirectories
* gnumeric.spec.in:
Adjust to cope with new autoformat directory structure
* src/dialogs/Makefile.am:
Remove -DGNUMERIC_AUTOFORMATDIR
* src/Makefile.am
Add -DGNUMERIC_AUTOFORMATDIR
* src/file-autoft.c, src/file-autoft.h:
New, functions for loading special listings of the autoformat
directory.
* src/dialogs/dialog-autoformat:
(categories_load): Remove
(categories_free): Remove
(templates_load): Adjust to use template_list_load
2000-09-30 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_create_toolbars) : All three toolbars are
......
2000-10-01 Almer S. Tigelaar <almer1@dds.nl>
* templates/autoformat/, templates/autoformat/Makefile.am:
Remove subdirectories, convert into a flat directory with structured
filenames.
* configure.in:
Remove templates/autoformat subdirectories
* gnumeric.spec.in:
Adjust to cope with new autoformat directory structure
* src/dialogs/Makefile.am:
Remove -DGNUMERIC_AUTOFORMATDIR
* src/Makefile.am
Add -DGNUMERIC_AUTOFORMATDIR
* src/file-autoft.c, src/file-autoft.h:
New, functions for loading special listings of the autoformat
directory.
* src/dialogs/dialog-autoformat:
(categories_load): Remove
(categories_free): Remove
(templates_load): Adjust to use template_list_load
2000-09-30 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_create_toolbars) : All three toolbars are
......
2000-10-01 Almer S. Tigelaar <almer1@dds.nl>
* templates/autoformat/, templates/autoformat/Makefile.am:
Remove subdirectories, convert into a flat directory with structured
filenames.
* configure.in:
Remove templates/autoformat subdirectories
* gnumeric.spec.in:
Adjust to cope with new autoformat directory structure
* src/dialogs/Makefile.am:
Remove -DGNUMERIC_AUTOFORMATDIR
* src/Makefile.am
Add -DGNUMERIC_AUTOFORMATDIR
* src/file-autoft.c, src/file-autoft.h:
New, functions for loading special listings of the autoformat
directory.
* src/dialogs/dialog-autoformat:
(categories_load): Remove
(categories_free): Remove
(templates_load): Adjust to use template_list_load
2000-09-30 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_create_toolbars) : All three toolbars are
......
2000-10-01 Almer S. Tigelaar <almer1@dds.nl>
* templates/autoformat/, templates/autoformat/Makefile.am:
Remove subdirectories, convert into a flat directory with structured
filenames.
* configure.in:
Remove templates/autoformat subdirectories
* gnumeric.spec.in:
Adjust to cope with new autoformat directory structure
* src/dialogs/Makefile.am:
Remove -DGNUMERIC_AUTOFORMATDIR
* src/Makefile.am
Add -DGNUMERIC_AUTOFORMATDIR
* src/file-autoft.c, src/file-autoft.h:
New, functions for loading special listings of the autoformat
directory.
* src/dialogs/dialog-autoformat:
(categories_load): Remove
(categories_free): Remove
(templates_load): Adjust to use template_list_load
2000-09-30 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_create_toolbars) : All three toolbars are
......
2000-10-01 Almer S. Tigelaar <almer1@dds.nl>
* templates/autoformat/, templates/autoformat/Makefile.am:
Remove subdirectories, convert into a flat directory with structured
filenames.
* configure.in:
Remove templates/autoformat subdirectories
* gnumeric.spec.in:
Adjust to cope with new autoformat directory structure
* src/dialogs/Makefile.am:
Remove -DGNUMERIC_AUTOFORMATDIR
* src/Makefile.am
Add -DGNUMERIC_AUTOFORMATDIR
* src/file-autoft.c, src/file-autoft.h:
New, functions for loading special listings of the autoformat
directory.
* src/dialogs/dialog-autoformat:
(categories_load): Remove
(categories_free): Remove
(templates_load): Adjust to use template_list_load
2000-09-30 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_create_toolbars) : All three toolbars are
......
2000-10-01 Almer S. Tigelaar <almer1@dds.nl>
* templates/autoformat/, templates/autoformat/Makefile.am:
Remove subdirectories, convert into a flat directory with structured
filenames.
* configure.in:
Remove templates/autoformat subdirectories
* gnumeric.spec.in:
Adjust to cope with new autoformat directory structure
* src/dialogs/Makefile.am:
Remove -DGNUMERIC_AUTOFORMATDIR
* src/Makefile.am
Add -DGNUMERIC_AUTOFORMATDIR
* src/file-autoft.c, src/file-autoft.h:
New, functions for loading special listings of the autoformat
directory.
* src/dialogs/dialog-autoformat:
(categories_load): Remove
(categories_free): Remove
(templates_load): Adjust to use template_list_load
2000-09-30 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_create_toolbars) : All three toolbars are
......
2000-10-01 Almer S. Tigelaar <almer1@dds.nl>
* templates/autoformat/, templates/autoformat/Makefile.am:
Remove subdirectories, convert into a flat directory with structured
filenames.
* configure.in:
Remove templates/autoformat subdirectories
* gnumeric.spec.in:
Adjust to cope with new autoformat directory structure
* src/dialogs/Makefile.am:
Remove -DGNUMERIC_AUTOFORMATDIR
* src/Makefile.am
Add -DGNUMERIC_AUTOFORMATDIR
* src/file-autoft.c, src/file-autoft.h:
New, functions for loading special listings of the autoformat
directory.
* src/dialogs/dialog-autoformat:
(categories_load): Remove
(categories_free): Remove
(templates_load): Adjust to use template_list_load
2000-09-30 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_create_toolbars) : All three toolbars are
......
......@@ -495,12 +495,6 @@ po/Makefile.in
templates/Makefile
templates/english/Makefile
templates/autoformat/Makefile
templates/autoformat/General/Makefile
templates/autoformat/3D/Makefile
templates/autoformat/Classical/Makefile
templates/autoformat/Colourful/Makefile
templates/autoformat/Financial/Makefile
templates/autoformat/List/Makefile
macros/Makefile
gnumeric.desktop
stamp.h
......
......@@ -86,12 +86,7 @@ fi
%{prefix}/share/pixmaps/gnumeric/*
%{prefix}/share/pixmaps/gnome-gnumeric.png
%{prefix}/share/gnumeric/@VERSION@/templates/*.gnumeric
%{prefix}/share/gnumeric/@VERSION@/autoformat-templates/General/*.template
%{prefix}/share/gnumeric/@VERSION@/autoformat-templates/Classical/*.template
%{prefix}/share/gnumeric/@VERSION@/autoformat-templates/Colourful/*.template
%{prefix}/share/gnumeric/@VERSION@/autoformat-templates/Financial/*.template
%{prefix}/share/gnumeric/@VERSION@/autoformat-templates/List/*.template
%{prefix}/share/gnumeric/@VERSION@/autoformat-templates/3D/*.template
%{prefix}/share/gnumeric/@VERSION@/autoformat-templates/*.xml
%{prefix}/share/mime-info/gnumeric.keys
%{prefix}/share/mime-info/gnumeric.mime
%{prefix}/share/mc/templates/gnumeric.desktop
......@@ -104,6 +99,9 @@ fi
%doc HACKING AUTHORS ChangeLog NEWS BUGS README COPYING TODO
%changelog
* Sun Oct 01 2000 Almer S. Tigelaar <almer1@dds.nl>
- Make some minor adjustments for the autoformatter
* Thu Sept 28 2000 Jody Goldberg <jgoldberg@home.com>
- Updated version requirements for gnome-print
......
......@@ -24,19 +24,20 @@ endif
#noinst_PROGRAMS = number-match
INCLUDES = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DGNUMERIC_DATADIR=\""$(gnumeric_datadir)"\" \
-DGNUMERIC_LIBDIR=\""$(gnumeric_libdir)"\" \
-DGNOME_ICONDIR=\""$(datadir)/pixmaps"\" \
-DGNOME_DATADIR=\""$(datadir)"\" \
-I$(includedir) \
-I$(top_srcdir)/ \
-I$(srcdir)/ \
-I$(srcdir)/widgets \
-I$(srcdir)/functions \
-I$(srcdir)/dialogs \
$(EXTRA_GNOME_CFLAGS) \
INCLUDES = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DGNUMERIC_DATADIR=\""$(gnumeric_datadir)"\" \
-DGNUMERIC_LIBDIR=\""$(gnumeric_libdir)"\" \
-DGNUMERIC_AUTOFORMATDIR=\""$(gnumeric_autoformatdir)"\" \
-DGNOME_ICONDIR=\""$(datadir)/pixmaps"\" \
-DGNOME_DATADIR=\""$(datadir)"\" \
-I$(includedir) \
-I$(top_srcdir)/ \
-I$(srcdir)/ \
-I$(srcdir)/widgets \
-I$(srcdir)/functions \
-I$(srcdir)/dialogs \
$(EXTRA_GNOME_CFLAGS) \
$(GUILE_INCS)
GNUMERIC_BASE_SOURCES = \
......@@ -96,6 +97,8 @@ GNUMERIC_BASE_SOURCES = \
expr-name.h \
file.c \
file.h \
file-autoft.c \
file-autoft.h \
format-template.h \
format-template.c \
formats.h \
......
......@@ -16,7 +16,6 @@ INCLUDES = \
-I$(srcdir)/.. \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DGNUMERIC_DATADIR=\""$(gnumeric_datadir)"\" \
-DGNUMERIC_AUTOFORMATDIR=\""$(gnumeric_autoformatdir)"\" \
-DGNUMERIC_ICONDIR=\""$(iconsdir)"\" \
-I$(includedir) \
$(EXTRA_GNOME_CFLAGS) \
......
......@@ -29,8 +29,6 @@
#include <glade/glade.h>
#include <math.h>
#include <dirent.h>
#include <errno.h>
#include "gnumeric.h"
#include "gnumeric-util.h"
......@@ -42,6 +40,7 @@
#include "preview-grid-controller.h"
#include "format-template.h"
#include "file-autoft.h"
#include "command-context.h"
#include "workbook.h"
......@@ -219,75 +218,6 @@ cb_get_cell_style (int row, int col, gpointer data)
/********************************************************************************
* UTILITY FUNCTIONS
********************************************************************************/
/**
* load_categories:
*
* Loads the list of categories available
*
* Return value: NULL on failure or a pointer to a list with categories on success.
**/
static GList *
load_categories (void)
{
DIR *dir;
struct dirent *ent;
int count = 0;
GList *list = NULL;
dir = opendir (GNUMERIC_AUTOFORMATDIR);
if (dir == NULL && errno == ENOENT) {
g_warning ("The autoformat template directory %s, does not exist!", GNUMERIC_AUTOFORMATDIR);
return NULL;
}
while ((ent = readdir (dir))) {
if (strcmp (ent->d_name, ".") != 0 && strcmp (ent->d_name, "..") != 0) {
list = g_list_append (list, g_strdup (ent->d_name));
count++;
}
}
if (errno) {
g_warning ("Error while reading listing of %s", GNUMERIC_AUTOFORMATDIR);
closedir (dir);
g_list_free (list);
return NULL;
} else if (count == 0) {
g_warning ("The autoformat template directory %s, has no category subdirectories!", GNUMERIC_AUTOFORMATDIR);
closedir (dir);
g_list_free (list);
return NULL;
}
closedir (dir);
return list;
}
/**
* free_categories:
* @list: A GList
*
* Free the category list
**/
static void
free_categories (GList *list)
{
GList *iterator = list;
while (iterator) {
g_free (iterator->data);
iterator = g_list_next (iterator);
}
g_list_free (list);
}
/**
* templates_free:
......@@ -329,57 +259,53 @@ templates_free (AutoFormatInfo *info)
static gboolean
templates_load (AutoFormatInfo *info)
{
DIR *dir;
struct dirent *ent;
char *directory;
int count = 0;
gboolean error = FALSE;
GList *template_list, *iterator;;
g_return_val_if_fail (info != NULL, FALSE);
g_return_val_if_fail (info->templates == NULL, FALSE);
if (g_list_length (info->categories) == 0)
return FALSE;
directory = g_strdup_printf ("%s%s/", GNUMERIC_AUTOFORMATDIR, info->current_category);
dir = opendir (directory);
if (dir == NULL) {
g_warning ("Error opening directory %s", directory);
error = TRUE;
}
template_list = template_list_load ();
if (dir) {
while ((ent = readdir (dir))) {
if (strcmp (ent->d_name, ".") != 0 && strcmp (ent->d_name, "..") != 0) {
FormatTemplate *ft;
char *filename;
iterator = template_list;
while (iterator) {
char *filename = iterator->data;
char **array = g_strsplit (g_basename (filename), ".", -1);
char *category = array[1];
filename = g_strdup_printf ("%s%s", directory, ent->d_name);
ft = format_template_new_from_file (workbook_command_context_gui (info->wb),
filename);
/*
* Load it if it belongs in the currently active category
*/
if (strcmp (info->current_category, category) == 0) {
FormatTemplate *ft;
ft = format_template_new_from_file (workbook_command_context_gui (info->wb),
filename);
format_template_set_size (ft, 0, 0, PREVIEW_COLS - 1, PREVIEW_ROWS - 1);
format_template_set_size (ft, 0, 0, PREVIEW_COLS - 1, PREVIEW_ROWS - 1);
if (ft == NULL) {
g_warning ("Error while reading %s", filename);
error = TRUE;
break;
}
g_free (filename);
if (ft == NULL) {
info->templates = g_slist_prepend (info->templates, ft);
count++;
g_warning ("Error while reading %s", filename);
error = TRUE;
break;
}
info->templates = g_slist_prepend (info->templates, ft);
count++;
}
info->templates = g_slist_reverse (info->templates);
}
g_free (directory);
closedir (dir);
g_strfreev (array);
iterator = g_list_next (iterator);
}
template_list_free (template_list);
info->templates = g_slist_reverse (info->templates);
/*
* We need to temporary lock the preview loading/freeing or
......@@ -1061,7 +987,7 @@ dialog_autoformat (Workbook *wb)
/*
* Fill category list
*/
if ((info->categories = load_categories ()) == NULL) {
if ((info->categories = category_list_load ()) == NULL) {
GtkWidget *wdialog;
wdialog = gnome_warning_dialog_parented (_("An error occured while reading the category list"),
......@@ -1109,7 +1035,7 @@ dialog_autoformat (Workbook *wb)
gtk_object_unref (GTK_OBJECT (info->tooltips));
free_categories (info->categories);
category_list_free (info->categories);
gtk_widget_destroy (GTK_WIDGET (info->dialog));
gtk_object_unref (GTK_OBJECT (gui));
......
/*
* file-autoft.c : Retrieve available autoformat templates/categories
*
* Copyright (C) Almer. S. Tigelaar.
* E-mail: almer1@dds.nl or almer-t@bigfoot.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <dirent.h>
#include <errno.h>
#include "file-autoft.h"
/**
* util_list_free:
* @list : a GList
*
* Free a list with items
**/
static void
util_list_free (GList *list)
{
GList *iterator = list;
while (iterator) {
g_free (iterator->data);
iterator = g_list_next (iterator);
}
g_list_free (list);
}
/**
* template_list_load:
*
* Load the list of available templates
*
* Return value: The list of templates (should be freed with templates_list_free)
**/
GList *
template_list_load (void)
{
DIR *dir;
struct dirent *ent;
int count = 0;
GList *list = NULL;
dir = opendir (GNUMERIC_AUTOFORMATDIR);
if (dir == NULL && errno == ENOENT) {
g_warning ("The autoformat template directory %s, does not exist!", GNUMERIC_AUTOFORMATDIR);
return NULL;
}
while ((ent = readdir (dir))) {
if (strcmp (ent->d_name, ".") != 0 && strcmp (ent->d_name, "..") != 0) {
list = g_list_append (list, g_strdup_printf ("%s/%s", GNUMERIC_AUTOFORMATDIR, ent->d_name));
count++;
}
}
if (errno) {
g_warning ("Error while reading listing of %s", GNUMERIC_AUTOFORMATDIR);
closedir (dir);
g_list_free (list);
return NULL;
} else if (count == 0) {
g_warning ("The autoformat template directory %s contains no templates at all!", GNUMERIC_AUTOFORMATDIR);
closedir (dir);
g_list_free (list);
return NULL;
}
closedir (dir);
return list;
}
/**
* template_list_free:
* @list: A GList
*
* Free the template list
**/
void
template_list_free (GList *list)
{
util_list_free (list);
}
/**
* category_list_load
*
* Loads the list of categories available
*
* Return value: NULL on failure or a pointer to a list with categories on success.
**/
GList *
category_list_load (void)
{
GList *template_list, *iterator, *subiterator;
GList *list = NULL;
template_list = template_list_load ();
/*
* Strip category part from each filename and put this in a separate list
* In the filename the second part is always the category
*/
iterator = template_list;
while (iterator) {
char *string = iterator->data;
char **array = g_strsplit (g_basename (string), ".", -1);
char *category = array[1];
gboolean exists = FALSE;
/*
* Don't add this item if it already exists
*/
subiterator = list;
while (subiterator) {
char *data = subiterator->data;
if (strcmp (data, category) == 0) {
exists = TRUE;
break;
}
subiterator = g_list_next (subiterator);
}
/*
* Add the new category if it doesn't exist yet,
* note that we always add the 'General' category to the
* top of the list if it exists
*/
if (!exists) {
if (strcmp (category, "General") == 0)
list = g_list_insert (list, g_strdup (category), 0);
else
list = g_list_append (list, g_strdup (category));
}
g_strfreev (array);
iterator = g_list_next (iterator);
}
template_list_free (template_list);
return list;
}
/**
* category_list_free:
* @list: A GList
*
* Free the template list
**/
void
category_list_free (GList *list)
{
util_list_free (list);
}
#ifndef GNUMERIC_FILE_AUTOFT_H
#define GNUMERIC_FILE_AUTOFT_H
#include "gnumeric.h"
GList *template_list_load (void);
void template_list_free (GList *list);
GList *category_list_load (void);
void category_list_free (GList *list);
#endif /* GNUMERIC_FILE_AUTOFT_H */
SUBDIRS = General Classical Colourful Financial List 3D
autoformat_templatesdir=$(gnumeric_autoformatdir)
autoformat_templates_DATA= \
autoformat.3D.button.xml \
autoformat.3D.list.xml \
autoformat.Classical.cool.xml \
autoformat.Classical.simple.xml \
autoformat.Classical.trendy.xml \
autoformat.Colourful.banana.xml \
autoformat.Colourful.black.xml \
autoformat.Colourful.blue.xml \
autoformat.Colourful.orange.xml \
autoformat.Colourful.vanilla.xml \
autoformat.Financial.basic.xml \
autoformat.Financial.desert.xml \
autoformat.Financial.ice.xml \
autoformat.Financial.modern.xml \
autoformat.Financial.purple.xml \
autoformat.General.advanced.xml \
autoformat.General.basic.xml \
autoformat.General.empty.xml \
autoformat.General.table.xml \
autoformat.List.basic.xml \
autoformat.List.green.xml \
autoformat.List.lila.xml \
autoformat.List.simple.xml
EXTRA_DIST = $(autoformat_templates_DATA)
<?xml version="1.0"?>
<gmr:FormatTemplate xmlns:gmr="http://www.gnome.org/gnumeric/format-template/v1">
<gmr:Information author="Gnumeric Team" name="Button" description="A button like template" category="3D"/>
<gmr:Members>
<gmr:Member>
<gmr:Row>
<gmr:Placement offset="0" offset_gravity="1"/>
<gmr:Dimensions size="1"/>
</gmr:Row>
<gmr:Col>
<gmr:Placement offset="0" offset_gravity="1"/>
<gmr:Dimensions size="1"/>
</gmr:Col>
<gmr:Frequency direction="0" repeat="0" skip="0" edge="0"/>
<gmr:Style HAlign="1" VAlign="2" Fit="0" Orient="1" Shade="1" Fore="0:0:0" Back="BC1E:BC1E:BC1E" PatternColor="0:0:0" Format="General">