projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Do not use const in pspp_linreg_get_vars. Use correct covariance
[pspp-builds.git]
/
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 2bee901bb5c7f217cdeda64690526c1e0df00ce5..db2e85b5f792bc5b4c5ee96daed8891ae8b0de19 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
+/* PSPPIRE - a graphical user interface for PSPP.
Copyright (C) 2005, 2006 Free Software Foundation
Copyright (C) 2005, 2006 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
@@
-46,7
+43,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
+66,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}}
};
};
@@
-175,6
+173,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);
@@
-207,8
+206,8
@@
on_toggle_2 (GtkToggleButton *togglebutton, gpointer user_data)
static gint on_var_type_ok_clicked (GtkWidget *w, gpointer data);
static gint on_var_type_ok_clicked (GtkWidget *w, gpointer data);
+static gint hide_dialog (GtkWidget *w, gpointer data);
-#define LEN 20
static void
add_to_group (GtkWidget *w, gpointer data)
static void
add_to_group (GtkWidget *w, gpointer data)
@@
-226,11
+225,11
@@
update_width_decimals (const struct var_type_dialog *dialog)
g_assert (dialog);
text = g_strdup_printf ("%d", dialog->fmt_l.w);
g_assert (dialog);
text = g_strdup_printf ("%d", dialog->fmt_l.w);
- gtk_entry_set_text (GTK_ENTRY(dialog->entry_width), text);
+ gtk_entry_set_text (GTK_ENTRY
(dialog->entry_width), text);
g_free (text);
text = g_strdup_printf ("%d", dialog->fmt_l.d);
g_free (text);
text = g_strdup_printf ("%d", dialog->fmt_l.d);
- gtk_entry_set_text (GTK_ENTRY(dialog->entry_decimals), text);
+ gtk_entry_set_text (GTK_ENTRY
(dialog->entry_decimals), text);
g_free (text);
}
g_free (text);
}
@@
-246,17
+245,17
@@
preview_custom (GtkWidget *w, gpointer data)
if ( dialog->active_button != BUTTON_CUSTOM )
return;
if ( dialog->active_button != BUTTON_CUSTOM )
return;
- text = gtk_entry_get_text (GTK_ENTRY(dialog->entry_decimals));
+ text = gtk_entry_get_text (GTK_ENTRY
(dialog->entry_decimals));
dialog->fmt_l.d = atoi (text);
dialog->fmt_l.d = atoi (text);
- text = gtk_entry_get_text (GTK_ENTRY(dialog->entry_width));
+ text = gtk_entry_get_text (GTK_ENTRY
(dialog->entry_width));
dialog->fmt_l.w = atoi (text);
msg_disable ();
if ( ! fmt_check_output (&dialog->fmt_l))
{
dialog->fmt_l.w = atoi (text);
msg_disable ();
if ( ! fmt_check_output (&dialog->fmt_l))
{
- gtk_label_set_text (GTK_LABEL(dialog->label_psample), "---");
- gtk_label_set_text (GTK_LABEL(dialog->label_nsample), "---");
+ gtk_label_set_text (GTK_LABEL
(dialog->label_psample), "---");
+ gtk_label_set_text (GTK_LABEL
(dialog->label_nsample), "---");
}
else
{
}
else
{
@@
-265,12
+264,12
@@
preview_custom (GtkWidget *w, gpointer data)
v.f = 1234.56;
sample_text = value_to_text (v, dialog->fmt_l);
v.f = 1234.56;
sample_text = value_to_text (v, dialog->fmt_l);
- gtk_label_set_text (GTK_LABEL(dialog->label_psample), sample_text);
+ 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);
g_free (sample_text);
v.f = -v.f;
sample_text = value_to_text (v, dialog->fmt_l);
- gtk_label_set_text (GTK_LABEL(dialog->label_nsample), sample_text);
+ gtk_label_set_text (GTK_LABEL
(dialog->label_nsample), sample_text);
g_free (sample_text);
}
msg_enable ();
g_free (sample_text);
}
msg_enable ();
@@
-333,9
+332,14
@@
var_type_dialog_create (GladeXML *xml)
g_assert (xml);
dialog->window = get_widget_assert (xml,"var_type_dialog");
g_assert (xml);
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),
- GTK_WINDOW(get_widget_assert (xml, "data_editor")));
+ gtk_window_set_transient_for (GTK_WINDOW
(dialog->window),
+ GTK_WINDOW
(get_widget_assert (xml, "data_editor")));
dialog->radioButton[BUTTON_NUMERIC] =
get_widget_assert (xml,"radiobutton1");
dialog->radioButton[BUTTON_NUMERIC] =
get_widget_assert (xml,"radiobutton1");
@@
-371,10
+375,10
@@
var_type_dialog_create (GladeXML *xml)
dialog->dollar_window = get_widget_assert (xml, "dollar_window");
dialog->dollar_treeview =
dialog->dollar_window = get_widget_assert (xml, "dollar_window");
dialog->dollar_treeview =
- GTK_TREE_VIEW(get_widget_assert (xml, "dollar_treeview"));
+ GTK_TREE_VIEW
(get_widget_assert (xml, "dollar_treeview"));
dialog->custom_treeview =
dialog->custom_treeview =
- GTK_TREE_VIEW(get_widget_assert (xml, "custom_treeview"));
+ GTK_TREE_VIEW
(get_widget_assert (xml, "custom_treeview"));
dialog->ok = get_widget_assert (xml,"var_type_ok");
dialog->ok = get_widget_assert (xml,"var_type_ok");
@@
-394,7
+398,7
@@
var_type_dialog_create (GladeXML *xml)
upleasant resizing effects */
GtkSizeGroup *sizeGroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
upleasant resizing effects */
GtkSizeGroup *sizeGroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- gtk_container_foreach (GTK_CONTAINER(get_widget_assert (xml, "middle_box")),
+ gtk_container_foreach (GTK_CONTAINER
(get_widget_assert (xml, "middle_box")),
add_to_group, sizeGroup);
add_to_group, sizeGroup);
@@
-403,14
+407,14
@@
var_type_dialog_create (GladeXML *xml)
tgs[i].dialog = dialog;
tgs[i].button = i;
g_signal_connect (dialog->radioButton[i], "toggled",
tgs[i].dialog = dialog;
tgs[i].button = i;
g_signal_connect (dialog->radioButton[i], "toggled",
- G_CALLBACK(on_toggle_1), &tgs[i]);
+ G_CALLBACK
(on_toggle_1), &tgs[i]);
g_signal_connect (dialog->radioButton[i], "toggled",
g_signal_connect (dialog->radioButton[i], "toggled",
- G_CALLBACK(on_toggle_2), dialog);
+ G_CALLBACK
(on_toggle_2), dialog);
}
/* Populate the date format tree view */
}
/* Populate the date format tree view */
- dialog->date_format_treeview = GTK_TREE_VIEW(get_widget_assert (xml,
+ dialog->date_format_treeview = GTK_TREE_VIEW
(get_widget_assert (xml,
"date_format_list_view"));
renderer = gtk_cell_renderer_text_new ();
"date_format_list_view"));
renderer = gtk_cell_renderer_text_new ();
@@
-436,13
+440,13
@@
var_type_dialog_create (GladeXML *xml)
-1);
}
-1);
}
- gtk_tree_view_set_model (GTK_TREE_VIEW(dialog->date_format_treeview),
- GTK_TREE_MODEL(list_store));
+ gtk_tree_view_set_model (GTK_TREE_VIEW
(dialog->date_format_treeview),
+ GTK_TREE_MODEL
(list_store));
g_object_unref (list_store);
g_object_unref (list_store);
- g_signal_connect (
GTK_OBJECT(dialog->date_format_treeview)
, "cursor-changed",
- GTK_SIGNAL_FUNC(set_format_from_treeview), dialog);
+ g_signal_connect (
dialog->date_format_treeview
, "cursor-changed",
+ GTK_SIGNAL_FUNC
(set_format_from_treeview), dialog);
/* populate the dollar treeview */
/* populate the dollar treeview */
@@
-464,7
+468,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,
@@
-473,18
+477,18
@@
var_type_dialog_create (GladeXML *xml)
free (template);
}
free (template);
}
- gtk_tree_view_set_model (GTK_TREE_VIEW(dialog->dollar_treeview),
- GTK_TREE_MODEL(list_store));
+ gtk_tree_view_set_model (GTK_TREE_VIEW
(dialog->dollar_treeview),
+ GTK_TREE_MODEL
(list_store));
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",
- GTK_SIGNAL_FUNC(set_format_from_treeview), dialog);
+ GTK_SIGNAL_FUNC
(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",
- GTK_SIGNAL_FUNC(update_width_decimals), dialog);
+ GTK_SIGNAL_FUNC
(update_width_decimals), dialog);
/* populate the custom treeview */
/* populate the custom treeview */
@@
-516,37
+520,43
@@
var_type_dialog_create (GladeXML *xml)
-1);
}
-1);
}
- gtk_tree_view_set_model (GTK_TREE_VIEW(dialog->custom_treeview),
- GTK_TREE_MODEL(list_store));
+ gtk_tree_view_set_model (GTK_TREE_VIEW
(dialog->custom_treeview),
+ GTK_TREE_MODEL
(list_store));
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",
- GTK_SIGNAL_FUNC(set_format_type_from_treeview), dialog);
+ GTK_SIGNAL_FUNC
(set_format_type_from_treeview), dialog);
- g_signal_connect (
GTK_OBJECT(dialog->custom_treeview)
,
+ g_signal_connect (
dialog->custom_treeview
,
"cursor-changed",
"cursor-changed",
- GTK_SIGNAL_FUNC(preview_custom), dialog);
+ GTK_SIGNAL_FUNC
(preview_custom), dialog);
- g_signal_connect (
GTK_OBJECT(dialog->entry_width)
,
+ g_signal_connect (
dialog->entry_width
,
"changed",
"changed",
- GTK_SIGNAL_FUNC(preview_custom), dialog);
+ GTK_SIGNAL_FUNC
(preview_custom), dialog);
- g_signal_connect (
GTK_OBJECT(dialog->entry_decimals)
,
+ g_signal_connect (
dialog->entry_decimals
,
"changed",
"changed",
- GTK_SIGNAL_FUNC(preview_custom), dialog);
+ GTK_SIGNAL_FUNC
(preview_custom), dialog);
- /* Connect the OK button */
- g_signal_connect (dialog->ok, "clicked", G_CALLBACK(on_var_type_ok_clicked),
+ /* Connect t
o t
he OK button */
+ g_signal_connect (dialog->ok, "clicked", G_CALLBACK
(on_var_type_ok_clicked),
dialog);
dialog);
+ /* And the cancel button */
+ g_signal_connect (get_widget_assert (xml, "var_type_cancel") , "clicked",
+ G_CALLBACK (hide_dialog),
+ dialog);
+
+
}
return dialog;
}
return dialog;
@@
-557,7
+567,7
@@
var_type_dialog_create (GladeXML *xml)
void
var_type_dialog_set_active_button (struct var_type_dialog *dialog, gint b)
{
void
var_type_dialog_set_active_button (struct var_type_dialog *dialog, gint b)
{
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(dialog->radioButton[b]),
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
(dialog->radioButton[b]),
TRUE);
dialog->active_button = b;
}
TRUE);
dialog->active_button = b;
}
@@
-667,12
+677,12
@@
var_type_dialog_set_state (struct var_type_dialog *dialog)
g_string_printf (str, "%d", write_spec->d);
g_string_printf (str, "%d", write_spec->d);
- gtk_entry_set_text (GTK_ENTRY(dialog->entry_decimals),
+ gtk_entry_set_text (GTK_ENTRY
(dialog->entry_decimals),
str->str);
g_string_printf (str, "%d", write_spec->w);
str->str);
g_string_printf (str, "%d", write_spec->w);
- gtk_entry_set_text (GTK_ENTRY(dialog->entry_width),
+ gtk_entry_set_text (GTK_ENTRY
(dialog->entry_width),
str->str);
g_string_free (str, TRUE);
str->str);
g_string_free (str, TRUE);
@@
-776,19
+786,19
@@
on_var_type_ok_clicked (GtkWidget *w, gpointer data)
{
gint width = atoi (gtk_entry_get_text
{
gint width = atoi (gtk_entry_get_text
- (GTK_ENTRY(dialog->entry_width)));
+ (GTK_ENTRY
(dialog->entry_width)));
gint decimals = atoi (gtk_entry_get_text
gint decimals = atoi (gtk_entry_get_text
- (GTK_ENTRY(dialog->entry_decimals)));
+ (GTK_ENTRY
(dialog->entry_decimals)));
- gint new_type = VA
R
_NUMERIC;
+ gint new_type = VA
L
_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 = VA
R
_STRING;
+ new_type = VA
L
_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;
@@
-832,10
+842,12
@@
on_var_type_ok_clicked (GtkWidget *w, gpointer data)
-gint
-
on_var_type_cancel_clicked
(GtkWidget *w, gpointer data)
+
static
gint
+
hide_dialog
(GtkWidget *w, gpointer data)
{
{
- gtk_widget_hide (w);
+ struct var_type_dialog *dialog = data;
+
+ gtk_widget_hide (dialog->window);
return FALSE;
}
return FALSE;
}