/*
PSPPIRE --- A Graphical User Interface for PSPP
Copyright (C) 2005, 2006 Free Software Foundation
- Written by John Darrington
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
#include "var-type-dialog.h"
-#include "psppire-variable.h"
#include "helper.h"
#include <data/variable.h>
static void
set_local_width_decimals(struct var_type_dialog *dialog)
{
- dialog->fmt_l = * psppire_variable_get_write_spec(dialog->pv);
+ dialog->fmt_l = * var_get_write_format (dialog->pv);
switch (dialog->active_button)
{
#define LEN 20
-/* return a string of the form "$#,###.##" according to FMT.
- FMT must be of type FMT_DOLLAR
- */
-static const gchar *
-dollar_format_template(const struct fmt_spec *fmt)
-{
- static gchar buf[LEN];
- g_assert( fmt->type == FMT_DOLLAR);
-
- {
- gint c ;
- gint int_part = fmt->w - fmt->d;
- if ( fmt->d > 0 ) --int_part;
- g_assert(int_part > 0);
-
- g_strlcpy(buf, "$", LEN);
-
- c = int_part - 1;
- while(c > 0)
- {
- g_strlcat(buf, "#", LEN);
- if(--c % 4 == 0 && c > 0 )
- {
- g_strlcat(buf, ",", LEN);
- --c;
- }
- }
- if ( fmt->d > 0 )
- {
- g_strlcat(buf, ".", LEN);
- for ( c = 0 ; c < fmt->d ; ++c )
- g_strlcat(buf, "#", LEN);
- }
- }
-
- return buf;
-}
-
static void
add_to_group(GtkWidget *w, gpointer data)
{
for ( i = 0 ; i < sizeof(dollar_format)/sizeof(dollar_format[0]) ; ++i )
{
+ char *template = fmt_dollar_template (&dollar_format[i]);
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter,
- 0, dollar_format_template(&dollar_format[i]),
+ 0, template,
1, &dollar_format[i],
-1);
+ free (template);
}
gtk_tree_view_set_model(GTK_TREE_VIEW(dialog->dollar_treeview),
g_assert(dialog->pv);
/* Populate width and decimals */
- write_spec = psppire_variable_get_write_spec(dialog->pv);
+ write_spec = var_get_write_format (dialog->pv);
g_string_printf(str, "%d", write_spec->d);
break;
}
- if ( result == true )
+ if ( result == true )
{
- psppire_variable_set_type(dialog->pv, new_type);
- psppire_variable_set_width(dialog->pv, new_width);
- psppire_variable_set_write_spec(dialog->pv, spec);
- psppire_variable_set_print_spec(dialog->pv, spec);
+ var_set_width (dialog->pv, new_width);
+ var_set_both_formats (dialog->pv, &spec);
}
}