projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implemented a zip-writer to correspond to zip-reader
[pspp]
/
src
/
ui
/
gui
/
var-type-dialog.c
diff --git
a/src/ui/gui/var-type-dialog.c
b/src/ui/gui/var-type-dialog.c
index d64b81293a5840a196f8eef2a56e19e316630d48..a4c2a22769c3be34911893232659125d14dd726b 100644
(file)
--- a/
src/ui/gui/var-type-dialog.c
+++ b/
src/ui/gui/var-type-dialog.c
@@
-1,21
+1,18
@@
-/*
- PSPPIRE --- A Graphical User Interface for PSPP
- Copyright (C) 2005, 2006 Free Software Foundation
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2005, 2006, 2010, 2011 Free Software Foundation
-
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 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 3
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.
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This module describes the behaviour of the Variable Type dialog box used
/* This module describes the behaviour of the Variable Type dialog box used
@@
-24,19
+21,15
@@
#include <config.h>
#include <gtk/gtk.h>
#include <config.h>
#include <gtk/gtk.h>
-#include <glade/glade.h>
-
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
-#include "var-type-dialog.h"
-
-#include "helper.h"
-
-#include <data/variable.h>
-#include <data/settings.h>
-#include <libpspp/message.h>
-
+#include "data/data-out.h"
+#include "data/settings.h"
+#include "data/variable.h"
+#include "libpspp/message.h"
+#include "ui/gui/helper.h"
+#include "ui/gui/var-type-dialog.h"
struct tgs
{
struct tgs
{
@@
-46,7
+39,7
@@
struct tgs
struct format_opt {
struct format_opt {
- gchar desc[
18
];
+ gchar desc[
21
];
struct fmt_spec spec;
};
struct fmt_spec spec;
};
@@
-69,7
+62,8
@@
static const struct format_opt format_option[] =
{ "mmm yy", {FMT_MOYR, 6, 0} },
{ "dd WK yyyy", {FMT_WKYR, 10, 0} },
{ "dd WK yy", {FMT_WKYR, 8, 0} },
{ "mmm yy", {FMT_MOYR, 6, 0} },
{ "dd WK yyyy", {FMT_WKYR, 10, 0} },
{ "dd WK yy", {FMT_WKYR, 8, 0} },
- { "dd-mmm-yyyy HH:MM", {FMT_DATETIME, 17, 0}}
+ { "dd-mmm-yyyy HH:MM", {FMT_DATETIME, 17, 0}},
+ { "dd-mmm-yyyy HH:MM:SS", {FMT_DATETIME, 20, 0}}
};
};
@@
-128,7
+122,7
@@
static void update_width_decimals (const struct var_type_dialog *dialog);
static void
set_local_width_decimals (struct var_type_dialog *dialog)
{
static void
set_local_width_decimals (struct var_type_dialog *dialog)
{
- dialog->fmt_l = * var_get_
write
_format (dialog->pv);
+ dialog->fmt_l = * var_get_
print
_format (dialog->pv);
switch (dialog->active_button)
{
switch (dialog->active_button)
{
@@
-175,6
+169,7
@@
on_toggle_2 (GtkToggleButton *togglebutton, gpointer user_data)
switch (dialog->active_button)
{
case BUTTON_STRING:
switch (dialog->active_button)
{
case BUTTON_STRING:
+ gtk_widget_show (dialog->entry_width);
gtk_widget_show (dialog->width_decimals);
gtk_widget_hide (dialog->label_decimals);
gtk_widget_hide (dialog->entry_decimals);
gtk_widget_show (dialog->width_decimals);
gtk_widget_hide (dialog->label_decimals);
gtk_widget_hide (dialog->entry_decimals);
@@
-264,12
+259,12
@@
preview_custom (GtkWidget *w, gpointer data)
union value v;
v.f = 1234.56;
union value v;
v.f = 1234.56;
- sample_text =
value_to_text (v, dialog->fmt_l
);
+ sample_text =
g_strchug (data_out (&v, NULL, &dialog->fmt_l)
);
gtk_label_set_text (GTK_LABEL (dialog->label_psample), sample_text);
g_free (sample_text);
v.f = -v.f;
gtk_label_set_text (GTK_LABEL (dialog->label_psample), sample_text);
g_free (sample_text);
v.f = -v.f;
- sample_text =
value_to_text (v, dialog->fmt_l
);
+ sample_text =
g_strchug (data_out (&v, NULL, &dialog->fmt_l)
);
gtk_label_set_text (GTK_LABEL (dialog->label_nsample), sample_text);
g_free (sample_text);
}
gtk_label_set_text (GTK_LABEL (dialog->label_nsample), sample_text);
g_free (sample_text);
}
@@
-317,29
+312,27
@@
set_format_type_from_treeview (GtkTreeView *treeview, gpointer data)
dialog->fmt_l = custom_format;
dialog->fmt_l.type = *(int*) g_value_get_pointer (&the_value);
dialog->fmt_l = custom_format;
dialog->fmt_l.type = *(int*) g_value_get_pointer (&the_value);
-
}
}
-
-
-/* Create the structure from the XML definitions */
+/* Create the structure */
struct var_type_dialog *
struct var_type_dialog *
-var_type_dialog_create (G
ladeXML *xm
l)
+var_type_dialog_create (G
tkWindow *topleve
l)
{
gint i;
struct var_type_dialog *dialog = g_malloc (sizeof (struct var_type_dialog));
{
gint i;
struct var_type_dialog *dialog = g_malloc (sizeof (struct var_type_dialog));
-
g_assert (xml
);
+
GtkBuilder *xml = builder_new ("var-sheet-dialogs.ui"
);
dialog->window = get_widget_assert (xml,"var_type_dialog");
dialog->window = get_widget_assert (xml,"var_type_dialog");
+ dialog->active_button = -1;
g_signal_connect (dialog->window, "delete-event",
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
gtk_window_set_transient_for (GTK_WINDOW (dialog->window),
g_signal_connect (dialog->window, "delete-event",
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
gtk_window_set_transient_for (GTK_WINDOW (dialog->window),
-
GTK_WINDOW (get_widget_assert (xml, "data_editor"))
);
+
toplevel
);
dialog->radioButton[BUTTON_NUMERIC] =
get_widget_assert (xml,"radiobutton1");
dialog->radioButton[BUTTON_NUMERIC] =
get_widget_assert (xml,"radiobutton1");
@@
-445,8
+438,8
@@
var_type_dialog_create (GladeXML *xml)
g_object_unref (list_store);
g_object_unref (list_store);
- g_signal_connect (
GTK_OBJECT (dialog->date_format_treeview)
, "cursor-changed",
- G
TK_SIGNAL_FUNC
(set_format_from_treeview), dialog);
+ g_signal_connect (
dialog->date_format_treeview
, "cursor-changed",
+ G
_CALLBACK
(set_format_from_treeview), dialog);
/* populate the dollar treeview */
/* populate the dollar treeview */
@@
-468,7
+461,7
@@
var_type_dialog_create (GladeXML *xml)
for ( i = 0 ; i < sizeof (dollar_format)/sizeof (dollar_format[0]) ; ++i )
{
for ( i = 0 ; i < sizeof (dollar_format)/sizeof (dollar_format[0]) ; ++i )
{
- char *template =
fmt
_dollar_template (&dollar_format[i]);
+ char *template =
settings
_dollar_template (&dollar_format[i]);
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter,
0, template,
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter,
0, template,
@@
-482,13
+475,13
@@
var_type_dialog_create (GladeXML *xml)
g_object_unref (list_store);
g_object_unref (list_store);
- g_signal_connect (
GTK_OBJECT (dialog->dollar_treeview)
,
+ g_signal_connect (
dialog->dollar_treeview
,
"cursor-changed",
"cursor-changed",
- G
TK_SIGNAL_FUNC
(set_format_from_treeview), dialog);
+ G
_CALLBACK
(set_format_from_treeview), dialog);
- g_signal_connect_swapped (
GTK_OBJECT (dialog->dollar_treeview)
,
+ g_signal_connect_swapped (
dialog->dollar_treeview
,
"cursor-changed",
"cursor-changed",
- G
TK_SIGNAL_FUNC
(update_width_decimals), dialog);
+ G
_CALLBACK
(update_width_decimals), dialog);
/* populate the custom treeview */
/* populate the custom treeview */
@@
-526,24
+519,24
@@
var_type_dialog_create (GladeXML *xml)
g_object_unref (list_store);
g_object_unref (list_store);
- g_signal_connect (
GTK_OBJECT (dialog->custom_treeview)
,
+ g_signal_connect (
dialog->custom_treeview
,
"cursor-changed",
"cursor-changed",
- G
TK_SIGNAL_FUNC
(set_format_type_from_treeview), dialog);
+ G
_CALLBACK
(set_format_type_from_treeview), dialog);
- g_signal_connect (
GTK_OBJECT (dialog->custom_treeview)
,
+ g_signal_connect (
dialog->custom_treeview
,
"cursor-changed",
"cursor-changed",
- G
TK_SIGNAL_FUNC
(preview_custom), dialog);
+ G
_CALLBACK
(preview_custom), dialog);
- g_signal_connect (
GTK_OBJECT (dialog->entry_width)
,
+ g_signal_connect (
dialog->entry_width
,
"changed",
"changed",
- G
TK_SIGNAL_FUNC
(preview_custom), dialog);
+ G
_CALLBACK
(preview_custom), dialog);
- g_signal_connect (
GTK_OBJECT (dialog->entry_decimals)
,
+ g_signal_connect (
dialog->entry_decimals
,
"changed",
"changed",
- G
TK_SIGNAL_FUNC
(preview_custom), dialog);
+ G
_CALLBACK
(preview_custom), dialog);
/* Connect to the OK button */
/* Connect to the OK button */
@@
-555,10
+548,10
@@
var_type_dialog_create (GladeXML *xml)
g_signal_connect (get_widget_assert (xml, "var_type_cancel") , "clicked",
G_CALLBACK (hide_dialog),
dialog);
g_signal_connect (get_widget_assert (xml, "var_type_cancel") , "clicked",
G_CALLBACK (hide_dialog),
dialog);
-
-
}
}
+ g_object_unref (xml);
+
return dialog;
}
return dialog;
}
@@
-666,21
+659,21
@@
select_treeview_from_format_type (GtkTreeView *treeview,
static void
var_type_dialog_set_state (struct var_type_dialog *dialog)
{
static void
var_type_dialog_set_state (struct var_type_dialog *dialog)
{
- const struct fmt_spec *
write_spec
;
+ const struct fmt_spec *
format
;
GString *str = g_string_new ("");
g_assert (dialog);
g_assert (dialog->pv);
/* Populate width and decimals */
GString *str = g_string_new ("");
g_assert (dialog);
g_assert (dialog->pv);
/* Populate width and decimals */
-
write_spec = var_get_write
_format (dialog->pv);
+
format = var_get_print
_format (dialog->pv);
- g_string_printf (str, "%d",
write_spec
->d);
+ g_string_printf (str, "%d",
format
->d);
gtk_entry_set_text (GTK_ENTRY (dialog->entry_decimals),
str->str);
gtk_entry_set_text (GTK_ENTRY (dialog->entry_decimals),
str->str);
- g_string_printf (str, "%d",
write_spec
->w);
+ g_string_printf (str, "%d",
format
->w);
gtk_entry_set_text (GTK_ENTRY (dialog->entry_width),
str->str);
gtk_entry_set_text (GTK_ENTRY (dialog->entry_width),
str->str);
@@
-688,7
+681,7
@@
var_type_dialog_set_state (struct var_type_dialog *dialog)
g_string_free (str, TRUE);
/* Populate the radio button states */
g_string_free (str, TRUE);
/* Populate the radio button states */
- switch (
write_spec
->type)
+ switch (
format
->type)
{
case FMT_F:
var_type_dialog_set_active_button (dialog, BUTTON_NUMERIC);
{
case FMT_F:
var_type_dialog_set_active_button (dialog, BUTTON_NUMERIC);
@@
-711,7
+704,7
@@
var_type_dialog_set_state (struct var_type_dialog *dialog)
var_type_dialog_set_active_button (dialog, BUTTON_DOLLAR);
gtk_widget_show_all (dialog->width_decimals);
var_type_dialog_set_active_button (dialog, BUTTON_DOLLAR);
gtk_widget_show_all (dialog->width_decimals);
- select_treeview_from_format (dialog->dollar_treeview,
write_spec
);
+ select_treeview_from_format (dialog->dollar_treeview,
format
);
break;
case FMT_DATE:
case FMT_EDATE:
break;
case FMT_DATE:
case FMT_EDATE:
@@
-729,7
+722,7
@@
var_type_dialog_set_state (struct var_type_dialog *dialog)
var_type_dialog_set_active_button (dialog, BUTTON_DATE);
gtk_widget_hide (dialog->width_decimals);
gtk_widget_show (dialog->date_format_list);
var_type_dialog_set_active_button (dialog, BUTTON_DATE);
gtk_widget_hide (dialog->width_decimals);
gtk_widget_show (dialog->date_format_list);
- select_treeview_from_format (dialog->date_format_treeview,
write_spec
);
+ select_treeview_from_format (dialog->date_format_treeview,
format
);
break;
case FMT_CCA:
case FMT_CCB:
break;
case FMT_CCA:
case FMT_CCB:
@@
-738,7
+731,7
@@
var_type_dialog_set_state (struct var_type_dialog *dialog)
case FMT_CCE:
var_type_dialog_set_active_button (dialog, BUTTON_CUSTOM);
select_treeview_from_format_type (dialog->custom_treeview,
case FMT_CCE:
var_type_dialog_set_active_button (dialog, BUTTON_CUSTOM);
select_treeview_from_format_type (dialog->custom_treeview,
-
write_spec
->type);
+
format
->type);
gtk_widget_show_all (dialog->width_decimals);
break;
default:
gtk_widget_show_all (dialog->width_decimals);
break;
default:
@@
-791,14
+784,12
@@
on_var_type_ok_clicked (GtkWidget *w, gpointer data)
gint decimals = atoi (gtk_entry_get_text
(GTK_ENTRY (dialog->entry_decimals)));
gint decimals = atoi (gtk_entry_get_text
(GTK_ENTRY (dialog->entry_decimals)));
- gint new_type = VAR_NUMERIC;
gint new_width = 0;
bool result = false;
struct fmt_spec spec;
switch (dialog->active_button)
{
case BUTTON_STRING:
gint new_width = 0;
bool result = false;
struct fmt_spec spec;
switch (dialog->active_button)
{
case BUTTON_STRING:
- new_type = VAR_STRING;
new_width = width;
result = make_output_format_try (&spec, FMT_A, width, 0);
break;
new_width = width;
result = make_output_format_try (&spec, FMT_A, width, 0);
break;