projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge commit 'origin/stable'
[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 48b6e988dce3b9f3ebe5a928c14cb880d4ca68f3..05ba5d3c9e748c61662bc8ee48914a521938490f 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
@@
-24,7
+21,6
@@
#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>
@@
-46,7
+42,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
+65,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}}
};
};
@@
-102,23
+99,23
@@
static const int cc_format[] =
static void select_treeview_from_format
(GtkTreeView *treeview, const struct fmt_spec *fmt);
static void select_treeview_from_format
(GtkTreeView *treeview, const struct fmt_spec *fmt);
-static void select_treeview_from_format_type(GtkTreeView *treeview,
+static void select_treeview_from_format_type
(GtkTreeView *treeview,
const int fmt_type);
/* callback for when any of the radio buttons are toggled */
static void
const int fmt_type);
/* callback for when any of the radio buttons are toggled */
static void
-on_toggle_1(GtkToggleButton *togglebutton, gpointer user_data)
+on_toggle_1
(GtkToggleButton *togglebutton, gpointer user_data)
{
struct tgs *tgs = user_data;
{
struct tgs *tgs = user_data;
- if ( gtk_toggle_button_get_active(togglebutton) == FALSE)
+ if ( gtk_toggle_button_get_active
(togglebutton) == FALSE)
return ;
tgs->dialog->active_button = tgs->button;
}
return ;
tgs->dialog->active_button = tgs->button;
}
-static void update_width_decimals(const struct var_type_dialog *dialog);
+static void update_width_decimals
(const struct var_type_dialog *dialog);
#define force_max(x, val) if (x > val) x = val
#define force_max(x, val) if (x > val) x = val
@@
-126,18
+123,18
@@
static void update_width_decimals(const struct var_type_dialog *dialog);
Set the local format from the variable
and force them to have sensible values */
static void
Set the local format from the variable
and force them to have sensible values */
static void
-set_local_width_decimals(struct var_type_dialog *dialog)
+set_local_width_decimals
(struct var_type_dialog *dialog)
{
dialog->fmt_l = * var_get_write_format (dialog->pv);
switch (dialog->active_button)
{
case BUTTON_STRING:
{
dialog->fmt_l = * var_get_write_format (dialog->pv);
switch (dialog->active_button)
{
case BUTTON_STRING:
- force_max( dialog->fmt_l.w, 255);
+ force_max
( dialog->fmt_l.w, 255);
break;
default:
break;
default:
- force_max( dialog->fmt_l.w, 40);
- force_max( dialog->fmt_l.d, 16);
+ force_max
( dialog->fmt_l.w, 40);
+ force_max
( dialog->fmt_l.d, 16);
break;
}
}
break;
}
}
@@
-145,99
+142,100
@@
set_local_width_decimals(struct var_type_dialog *dialog)
/* callback for when any of the radio buttons are toggled */
static void
/* callback for when any of the radio buttons are toggled */
static void
-on_toggle_2(GtkToggleButton *togglebutton, gpointer user_data)
+on_toggle_2
(GtkToggleButton *togglebutton, gpointer user_data)
{
struct var_type_dialog *dialog = user_data;
{
struct var_type_dialog *dialog = user_data;
- if ( gtk_toggle_button_get_active(togglebutton) == FALSE)
+ if ( gtk_toggle_button_get_active
(togglebutton) == FALSE)
{
switch (dialog->active_button)
{
case BUTTON_DATE:
{
switch (dialog->active_button)
{
case BUTTON_DATE:
- gtk_widget_hide(dialog->date_format_list);
+ gtk_widget_hide
(dialog->date_format_list);
break;
case BUTTON_CUSTOM:
break;
case BUTTON_CUSTOM:
- gtk_widget_hide(dialog->custom_currency_hbox);
+ gtk_widget_hide
(dialog->custom_currency_hbox);
break;
case BUTTON_DOLLAR:
break;
case BUTTON_DOLLAR:
- gtk_widget_hide(dialog->dollar_window);
+ gtk_widget_hide
(dialog->dollar_window);
break;
case BUTTON_STRING:
break;
case BUTTON_STRING:
- gtk_widget_show(dialog->label_decimals);
- gtk_widget_show(dialog->entry_decimals);
+ gtk_widget_show
(dialog->label_decimals);
+ gtk_widget_show
(dialog->entry_decimals);
break;
}
return ;
}
break;
}
return ;
}
- set_local_width_decimals(dialog);
- update_width_decimals(dialog);
+ set_local_width_decimals
(dialog);
+ update_width_decimals
(dialog);
switch (dialog->active_button)
{
case BUTTON_STRING:
switch (dialog->active_button)
{
case BUTTON_STRING:
- gtk_widget_show(dialog->width_decimals);
- gtk_widget_hide(dialog->label_decimals);
- gtk_widget_hide(dialog->entry_decimals);
+ gtk_widget_show (dialog->entry_width);
+ gtk_widget_show (dialog->width_decimals);
+ gtk_widget_hide (dialog->label_decimals);
+ gtk_widget_hide (dialog->entry_decimals);
break;
case BUTTON_DATE:
break;
case BUTTON_DATE:
- select_treeview_from_format(dialog->date_format_treeview,
+ select_treeview_from_format
(dialog->date_format_treeview,
&format_option[0].spec);
&format_option[0].spec);
- gtk_widget_hide(dialog->width_decimals);
- gtk_widget_show(dialog->date_format_list);
+ gtk_widget_hide
(dialog->width_decimals);
+ gtk_widget_show
(dialog->date_format_list);
break;
case BUTTON_DOLLAR:
break;
case BUTTON_DOLLAR:
- select_treeview_from_format(dialog->dollar_treeview,
+ select_treeview_from_format
(dialog->dollar_treeview,
&dollar_format[0]);
&dollar_format[0]);
- gtk_widget_show(dialog->dollar_window);
- gtk_widget_show_all(dialog->width_decimals);
+ gtk_widget_show
(dialog->dollar_window);
+ gtk_widget_show_all
(dialog->width_decimals);
break;
case BUTTON_CUSTOM:
break;
case BUTTON_CUSTOM:
- select_treeview_from_format_type(dialog->custom_treeview,
+ select_treeview_from_format_type
(dialog->custom_treeview,
cc_format[0]);
cc_format[0]);
- gtk_widget_show(dialog->width_decimals);
- gtk_widget_show(dialog->custom_currency_hbox);
+ gtk_widget_show
(dialog->width_decimals);
+ gtk_widget_show
(dialog->custom_currency_hbox);
break;
default:
break;
default:
- gtk_widget_show_all(dialog->width_decimals);
+ gtk_widget_show_all
(dialog->width_decimals);
break;
}
}
break;
}
}
-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
static void
-add_to_group(GtkWidget *w, gpointer data)
+add_to_group
(GtkWidget *w, gpointer data)
{
GtkSizeGroup *sg = data;
{
GtkSizeGroup *sg = data;
- gtk_size_group_add_widget(sg, w);
+ gtk_size_group_add_widget
(sg, w);
}
/* Set the local width and decimals entry boxes to reflec the local format */
static void
}
/* Set the local width and decimals entry boxes to reflec the local format */
static void
-update_width_decimals(const struct var_type_dialog *dialog)
+update_width_decimals
(const struct var_type_dialog *dialog)
{
gchar *text;
{
gchar *text;
- g_assert(dialog);
+ g_assert
(dialog);
- text = g_strdup_printf("%d", dialog->fmt_l.w);
- gtk_entry_set_text
(GTK_ENTRY
(dialog->entry_width), text);
- g_free(text);
+ text = g_strdup_printf
("%d", dialog->fmt_l.w);
+ gtk_entry_set_text
(GTK_ENTRY
(dialog->entry_width), text);
+ g_free
(text);
- text = g_strdup_printf("%d", dialog->fmt_l.d);
- gtk_entry_set_text
(GTK_ENTRY
(dialog->entry_decimals), text);
- g_free(text);
+ text = g_strdup_printf
("%d", dialog->fmt_l.d);
+ gtk_entry_set_text
(GTK_ENTRY
(dialog->entry_decimals), text);
+ g_free
(text);
}
/* Callback for when the custom treeview row is changed.
It sets dialog box to reflect the selected format */
static void
}
/* Callback for when the custom treeview row is changed.
It sets dialog box to reflect the selected format */
static void
-preview_custom(GtkWidget *w, gpointer data)
+preview_custom
(GtkWidget *w, gpointer data)
{
const gchar *text ;
{
const gchar *text ;
@@
-246,17
+244,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));
- dialog->fmt_l.d = atoi(text);
+ text = gtk_entry_get_text
(GTK_ENTRY
(dialog->entry_decimals));
+ dialog->fmt_l.d = atoi
(text);
- text = gtk_entry_get_text
(GTK_ENTRY
(dialog->entry_width));
- dialog->fmt_l.w = atoi(text);
+ text = gtk_entry_get_text
(GTK_ENTRY
(dialog->entry_width));
+ dialog->fmt_l.w = atoi
(text);
msg_disable ();
msg_disable ();
- if ( ! fmt_check_output(&dialog->fmt_l))
+ 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
{
@@
-264,14
+262,14
@@
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);
- gtk_label_set_text
(GTK_LABEL
(dialog->label_psample), sample_text);
- g_free(sample_text);
+ sample_text = value_to_text
(v, NULL
, dialog->fmt_l);
+ gtk_label_set_text
(GTK_LABEL
(dialog->label_psample), sample_text);
+ g_free
(sample_text);
v.f = -v.f;
v.f = -v.f;
- sample_text = value_to_text
(v
, dialog->fmt_l);
- gtk_label_set_text
(GTK_LABEL
(dialog->label_nsample), sample_text);
- g_free(sample_text);
+ sample_text = value_to_text
(v, NULL
, dialog->fmt_l);
+ gtk_label_set_text
(GTK_LABEL
(dialog->label_nsample), sample_text);
+ g_free
(sample_text);
}
msg_enable ();
}
}
msg_enable ();
}
@@
-279,105
+277,110
@@
preview_custom(GtkWidget *w, gpointer data)
/* Callback for when a treeview row is changed.
It sets the fmt_l_spec to reflect the selected format */
static void
/* Callback for when a treeview row is changed.
It sets the fmt_l_spec to reflect the selected format */
static void
-set_format_from_treeview(GtkTreeView *treeview, gpointer data)
+set_format_from_treeview
(GtkTreeView *treeview, gpointer data)
{
struct var_type_dialog *dialog = data;
GtkTreeIter iter ;
GValue the_value = {0};
{
struct var_type_dialog *dialog = data;
GtkTreeIter iter ;
GValue the_value = {0};
- GtkTreeSelection* sel = gtk_tree_view_get_selection(treeview);
+ GtkTreeSelection* sel = gtk_tree_view_get_selection
(treeview);
- GtkTreeModel * model = gtk_tree_view_get_model(treeview);
+ GtkTreeModel * model = gtk_tree_view_get_model
(treeview);
gtk_tree_selection_get_selected (sel, &model, &iter);
gtk_tree_selection_get_selected (sel, &model, &iter);
- gtk_tree_model_get_value(model, &iter, 1, &the_value);
+ gtk_tree_model_get_value
(model, &iter, 1, &the_value);
- dialog->fmt_l = *(struct fmt_spec *) g_value_get_pointer(&the_value);
+ dialog->fmt_l = *(struct fmt_spec *) g_value_get_pointer
(&the_value);
}
/* Callback for when a treeview row is changed.
It sets the type of the fmt_l to reflect the selected type */
static void
}
/* Callback for when a treeview row is changed.
It sets the type of the fmt_l to reflect the selected type */
static void
-set_format_type_from_treeview(GtkTreeView *treeview, gpointer data)
+set_format_type_from_treeview
(GtkTreeView *treeview, gpointer data)
{
static struct fmt_spec custom_format = {0,0,0};
struct var_type_dialog *dialog = data;
GtkTreeIter iter ;
GValue the_value = {0};
{
static struct fmt_spec custom_format = {0,0,0};
struct var_type_dialog *dialog = data;
GtkTreeIter iter ;
GValue the_value = {0};
- GtkTreeSelection* sel = gtk_tree_view_get_selection(treeview);
+ GtkTreeSelection* sel = gtk_tree_view_get_selection
(treeview);
- GtkTreeModel * model = gtk_tree_view_get_model(treeview);
+ GtkTreeModel * model = gtk_tree_view_get_model
(treeview);
gtk_tree_selection_get_selected (sel, &model, &iter);
gtk_tree_selection_get_selected (sel, &model, &iter);
- gtk_tree_model_get_value(model, &iter, 1, &the_value);
+ gtk_tree_model_get_value
(model, &iter, 1, &the_value);
dialog->fmt_l = custom_format;
dialog->fmt_l = custom_format;
- dialog->fmt_l.type = *(int*) g_value_get_pointer(&the_value);
+ 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;
{
gint i;
- struct var_type_dialog *dialog = g_malloc(sizeof(struct var_type_dialog));
+ struct var_type_dialog *dialog = g_malloc (sizeof (struct var_type_dialog));
+
+ GtkBuilder *xml = builder_new ("var-sheet-dialogs.ui");
- g_assert(xml);
+ dialog->window = get_widget_assert (xml,"var_type_dialog");
+ dialog->active_button = -1;
- dialog->window = get_widget_assert(xml,"var_type_dialog");
- gtk_window_set_transient_for(GTK_WINDOW(dialog->window),
- GTK_WINDOW(get_widget_assert(xml, "data_editor")));
+ g_signal_connect (dialog->window, "delete-event",
+ G_CALLBACK (gtk_widget_hide_on_delete), NULL);
+
+ gtk_window_set_transient_for (GTK_WINDOW (dialog->window),
+ toplevel);
dialog->radioButton[BUTTON_NUMERIC] =
dialog->radioButton[BUTTON_NUMERIC] =
- get_widget_assert(xml,"radiobutton1");
+ get_widget_assert
(xml,"radiobutton1");
dialog->radioButton[BUTTON_COMMA] =
dialog->radioButton[BUTTON_COMMA] =
- get_widget_assert(xml,"radiobutton2");
+ get_widget_assert
(xml,"radiobutton2");
dialog->radioButton[BUTTON_DOT] =
dialog->radioButton[BUTTON_DOT] =
- get_widget_assert(xml,"radiobutton3");
+ get_widget_assert
(xml,"radiobutton3");
dialog->radioButton[BUTTON_SCIENTIFIC] =
dialog->radioButton[BUTTON_SCIENTIFIC] =
- get_widget_assert(xml,"radiobutton4");
+ get_widget_assert
(xml,"radiobutton4");
dialog->radioButton[BUTTON_DATE] =
dialog->radioButton[BUTTON_DATE] =
- get_widget_assert(xml,"radiobutton5");
+ get_widget_assert
(xml,"radiobutton5");
dialog->radioButton[BUTTON_DOLLAR] =
dialog->radioButton[BUTTON_DOLLAR] =
- get_widget_assert(xml,"radiobutton6");
+ get_widget_assert
(xml,"radiobutton6");
dialog->radioButton[BUTTON_CUSTOM] =
dialog->radioButton[BUTTON_CUSTOM] =
- get_widget_assert(xml,"radiobutton7");
+ get_widget_assert
(xml,"radiobutton7");
dialog->radioButton[BUTTON_STRING] =
dialog->radioButton[BUTTON_STRING] =
- get_widget_assert(xml,"radiobutton8");
+ get_widget_assert
(xml,"radiobutton8");
- dialog->date_format_list = get_widget_assert(xml, "scrolledwindow4");
- dialog->width_decimals = get_widget_assert(xml, "width_decimals");
- dialog->label_decimals = get_widget_assert(xml, "decimals_label");
- dialog->entry_decimals = get_widget_assert(xml, "decimals_entry");
+ dialog->date_format_list = get_widget_assert
(xml, "scrolledwindow4");
+ dialog->width_decimals = get_widget_assert
(xml, "width_decimals");
+ dialog->label_decimals = get_widget_assert
(xml, "decimals_label");
+ dialog->entry_decimals = get_widget_assert
(xml, "decimals_entry");
- dialog->label_psample = get_widget_assert(xml, "psample_label");
- dialog->label_nsample = get_widget_assert(xml, "nsample_label");
+ dialog->label_psample = get_widget_assert
(xml, "psample_label");
+ dialog->label_nsample = get_widget_assert
(xml, "nsample_label");
- dialog->entry_width = get_widget_assert(xml,"width_entry");
+ dialog->entry_width = get_widget_assert
(xml,"width_entry");
- dialog->custom_currency_hbox = get_widget_assert(xml,
+ dialog->custom_currency_hbox = get_widget_assert
(xml,
"custom_currency_hbox");
"custom_currency_hbox");
- dialog->dollar_window = get_widget_assert(xml, "dollar_window");
+ dialog->dollar_window = get_widget_assert
(xml, "dollar_window");
dialog->dollar_treeview =
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");
{
{
@@
-392,9
+395,9
@@
var_type_dialog_create (GladeXML *xml)
However only one child is ever shown at a time.
We need to make sure that they all have the same width, to avoid
upleasant resizing effects */
However only one child is ever shown at a time.
We need to make sure that they all have the same width, to avoid
upleasant resizing effects */
- GtkSizeGroup *sizeGroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+ 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);
@@
-402,18
+405,18
@@
var_type_dialog_create (GladeXML *xml)
{
tgs[i].dialog = dialog;
tgs[i].button = i;
{
tgs[i].dialog = dialog;
tgs[i].button = i;
- g_signal_connect(dialog->radioButton[i], "toggled",
- G_CALLBACK(on_toggle_1), &tgs[i]);
+ g_signal_connect
(dialog->radioButton[i], "toggled",
+ G_CALLBACK
(on_toggle_1), &tgs[i]);
- g_signal_connect(dialog->radioButton[i], "toggled",
- G_CALLBACK(on_toggle_2), dialog);
+ g_signal_connect
(dialog->radioButton[i], "toggled",
+ 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"));
"date_format_list_view"));
- renderer = gtk_cell_renderer_text_new();
+ renderer = gtk_cell_renderer_text_new
();
column = gtk_tree_view_column_new_with_attributes ("Title",
renderer,
column = gtk_tree_view_column_new_with_attributes ("Title",
renderer,
@@
-427,7
+430,7
@@
var_type_dialog_create (GladeXML *xml)
list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
- for ( i = 0 ; i < sizeof
(format_option) / sizeof
(format_option[0]) ; ++i )
+ for ( i = 0 ; i < sizeof
(format_option) / sizeof
(format_option[0]) ; ++i )
{
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter,
{
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter,
@@
-436,18
+439,18
@@
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 */
- renderer = gtk_cell_renderer_text_new();
+ renderer = gtk_cell_renderer_text_new
();
column = gtk_tree_view_column_new_with_attributes ("Title",
renderer,
column = gtk_tree_view_column_new_with_attributes ("Title",
renderer,
@@
-462,9
+465,9
@@
var_type_dialog_create (GladeXML *xml)
list_store = gtk_list_store_new (2, G_TYPE_STRING,
G_TYPE_POINTER);
list_store = gtk_list_store_new (2, G_TYPE_STRING,
G_TYPE_POINTER);
- 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,23
+476,23
@@
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 */
- renderer = gtk_cell_renderer_text_new();
+ renderer = gtk_cell_renderer_text_new
();
column = gtk_tree_view_column_new_with_attributes ("Title",
renderer,
column = gtk_tree_view_column_new_with_attributes ("Title",
renderer,
@@
-508,7
+511,7
@@
var_type_dialog_create (GladeXML *xml)
{
enum fmt_type cc_fmts[5] = {FMT_CCA, FMT_CCB, FMT_CCC, FMT_CCD, FMT_CCE};
gchar text[4];
{
enum fmt_type cc_fmts[5] = {FMT_CCA, FMT_CCB, FMT_CCC, FMT_CCD, FMT_CCE};
gchar text[4];
- g_snprintf(text, 4, "%s", fmt_name (cc_fmts[i]));
+ g_snprintf
(text, 4, "%s", fmt_name (cc_fmts[i]));
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter,
0, text,
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter,
0, text,
@@
-516,48
+519,54
@@
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);
}
}
+ g_object_unref (xml);
+
return dialog;
}
/* Set a particular button to be active */
void
return dialog;
}
/* Set a particular button to be active */
void
-var_type_dialog_set_active_button(struct var_type_dialog *dialog, gint b)
+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;
}
@@
-566,7
+575,7
@@
var_type_dialog_set_active_button(struct var_type_dialog *dialog, gint b)
/* Set the TREEVIEW list cursor to the item described by FMT */
static void
/* Set the TREEVIEW list cursor to the item described by FMT */
static void
-select_treeview_from_format(GtkTreeView *treeview, const struct fmt_spec *fmt)
+select_treeview_from_format
(GtkTreeView *treeview, const struct fmt_spec *fmt)
{
GtkTreePath *path ;
{
GtkTreePath *path ;
@@
-575,44
+584,44
@@
select_treeview_from_format(GtkTreeView *treeview, const struct fmt_spec *fmt)
efficient, but the list is short ... */
GtkTreeIter iter;
efficient, but the list is short ... */
GtkTreeIter iter;
- GtkTreeModel * model = gtk_tree_view_get_model(treeview);
+ GtkTreeModel * model = gtk_tree_view_get_model
(treeview);
gboolean success;
gboolean success;
- for (success = gtk_tree_model_get_iter_first(model, &iter);
+ for (success = gtk_tree_model_get_iter_first
(model, &iter);
success;
success;
- success = gtk_tree_model_iter_next(model, &iter))
+ success = gtk_tree_model_iter_next
(model, &iter))
{
const struct fmt_spec *spec;
GValue value = {0};
{
const struct fmt_spec *spec;
GValue value = {0};
- gtk_tree_model_get_value(model, &iter, 1, &value);
+ gtk_tree_model_get_value
(model, &iter, 1, &value);
- spec = g_value_get_pointer(&value);
+ spec = g_value_get_pointer
(&value);
- if ( 0 == memcmp(spec, fmt, sizeof (struct fmt_spec)))
+ if ( 0 == memcmp
(spec, fmt, sizeof (struct fmt_spec)))
{
break;
}
}
{
break;
}
}
- path = gtk_tree_model_get_path(model, &iter);
+ path = gtk_tree_model_get_path
(model, &iter);
if ( path )
{
if ( path )
{
- gtk_tree_view_set_cursor(treeview, path, 0, 0);
- gtk_tree_path_free(path);
+ gtk_tree_view_set_cursor
(treeview, path, 0, 0);
+ gtk_tree_path_free
(path);
}
else
{
char str[FMT_STRING_LEN_MAX + 1];
}
else
{
char str[FMT_STRING_LEN_MAX + 1];
- g_warning
("Unusual date format: %s\n", fmt_to_string
(fmt, str));
+ g_warning
("Unusual date format: %s\n", fmt_to_string
(fmt, str));
}
}
/* Set the TREEVIEW list cursor to the item described by FMT_TYPE */
static void
}
}
/* Set the TREEVIEW list cursor to the item described by FMT_TYPE */
static void
-select_treeview_from_format_type(GtkTreeView *treeview,
+select_treeview_from_format_type
(GtkTreeView *treeview,
const int fmt_type)
{
GtkTreePath *path ;
const int fmt_type)
{
GtkTreePath *path ;
@@
-622,86
+631,86
@@
select_treeview_from_format_type(GtkTreeView *treeview,
efficient, but the list is short ... */
GtkTreeIter iter;
efficient, but the list is short ... */
GtkTreeIter iter;
- GtkTreeModel * model = gtk_tree_view_get_model(treeview);
+ GtkTreeModel * model = gtk_tree_view_get_model
(treeview);
gboolean success;
gboolean success;
- for (success = gtk_tree_model_get_iter_first(model, &iter);
+ for (success = gtk_tree_model_get_iter_first
(model, &iter);
success;
success;
- success = gtk_tree_model_iter_next(model, &iter))
+ success = gtk_tree_model_iter_next
(model, &iter))
{
int spec ;
GValue value = {0};
{
int spec ;
GValue value = {0};
- gtk_tree_model_get_value(model, &iter, 1, &value);
+ gtk_tree_model_get_value
(model, &iter, 1, &value);
- spec = * ((int *) g_value_get_pointer(&value));
+ spec = * ((int *) g_value_get_pointer
(&value));
if ( spec == fmt_type)
break;
}
if ( spec == fmt_type)
break;
}
- path = gtk_tree_model_get_path(model, &iter);
+ path = gtk_tree_model_get_path
(model, &iter);
if ( path )
{
if ( path )
{
- gtk_tree_view_set_cursor(treeview, path, 0, 0);
- gtk_tree_path_free(path);
+ gtk_tree_view_set_cursor
(treeview, path, 0, 0);
+ gtk_tree_path_free
(path);
}
else
}
else
- g_warning("Unknown custom type %d\n", fmt_type);
+ g_warning
("Unknown custom type %d\n", fmt_type);
}
/* Set up the state of the dialog box to match the variable VAR */
static void
}
/* Set up the state of the dialog box to match the variable VAR */
static void
-var_type_dialog_set_state(struct var_type_dialog *dialog)
+var_type_dialog_set_state
(struct var_type_dialog *dialog)
{
const struct fmt_spec *write_spec ;
{
const struct fmt_spec *write_spec ;
- GString *str = g_string_new("");
+ GString *str = g_string_new
("");
- g_assert(dialog);
- g_assert(dialog->pv);
+ g_assert
(dialog);
+ g_assert
(dialog->pv);
/* Populate width and decimals */
write_spec = var_get_write_format (dialog->pv);
/* Populate width and decimals */
write_spec = var_get_write_format (dialog->pv);
- 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);
str->str);
- g_string_printf(str, "%d", write_spec->w);
+ 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);
str->str);
- g_string_free(str, TRUE);
+ g_string_free
(str, TRUE);
/* Populate the radio button states */
switch (write_spec->type)
{
case FMT_F:
/* Populate the radio button states */
switch (write_spec->type)
{
case FMT_F:
- var_type_dialog_set_active_button(dialog, BUTTON_NUMERIC);
- gtk_widget_show_all(dialog->width_decimals);
+ var_type_dialog_set_active_button
(dialog, BUTTON_NUMERIC);
+ gtk_widget_show_all
(dialog->width_decimals);
break;
case FMT_A:
break;
case FMT_A:
- var_type_dialog_set_active_button(dialog, BUTTON_STRING);
- gtk_widget_hide(dialog->label_decimals);
- gtk_widget_hide(dialog->entry_decimals);
+ var_type_dialog_set_active_button
(dialog, BUTTON_STRING);
+ gtk_widget_hide
(dialog->label_decimals);
+ gtk_widget_hide
(dialog->entry_decimals);
break;
case FMT_COMMA:
break;
case FMT_COMMA:
- var_type_dialog_set_active_button(dialog, BUTTON_COMMA);
- gtk_widget_show_all(dialog->width_decimals);
+ var_type_dialog_set_active_button
(dialog, BUTTON_COMMA);
+ gtk_widget_show_all
(dialog->width_decimals);
break;
case FMT_DOT:
break;
case FMT_DOT:
- var_type_dialog_set_active_button(dialog, BUTTON_DOT);
- gtk_widget_show_all(dialog->width_decimals);
+ var_type_dialog_set_active_button
(dialog, BUTTON_DOT);
+ gtk_widget_show_all
(dialog->width_decimals);
break;
case FMT_DOLLAR:
break;
case FMT_DOLLAR:
- 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, write_spec);
break;
case FMT_DATE:
case FMT_EDATE:
break;
case FMT_DATE:
case FMT_EDATE:
@@
-716,23
+725,23
@@
var_type_dialog_set_state(struct var_type_dialog *dialog)
case FMT_DTIME:
case FMT_WKDAY:
case FMT_MONTH:
case FMT_DTIME:
case FMT_WKDAY:
case FMT_MONTH:
- 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);
+ 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);
break;
case FMT_CCA:
case FMT_CCB:
case FMT_CCC:
case FMT_CCD:
case FMT_CCE:
break;
case FMT_CCA:
case FMT_CCB:
case FMT_CCC:
case FMT_CCD:
case FMT_CCE:
- var_type_dialog_set_active_button(dialog, BUTTON_CUSTOM);
- select_treeview_from_format_type(dialog->custom_treeview,
+ var_type_dialog_set_active_button
(dialog, BUTTON_CUSTOM);
+ select_treeview_from_format_type
(dialog->custom_treeview,
write_spec->type);
write_spec->type);
- gtk_widget_show_all(dialog->width_decimals);
+ gtk_widget_show_all
(dialog->width_decimals);
break;
default:
break;
default:
- gtk_widget_show_all(dialog->width_decimals);
+ gtk_widget_show_all
(dialog->width_decimals);
break;
}
}
break;
}
}
@@
-740,11
+749,11
@@
var_type_dialog_set_state(struct var_type_dialog *dialog)
/* Popup the dialog box */
void
/* Popup the dialog box */
void
-var_type_dialog_show(struct var_type_dialog *dialog)
+var_type_dialog_show
(struct var_type_dialog *dialog)
{
{
- var_type_dialog_set_state(dialog);
+ var_type_dialog_set_state
(dialog);
- gtk_widget_show(dialog->window);
+ gtk_widget_show
(dialog->window);
}
/* Fills F with an output format specification with type TYPE, width
}
/* Fills F with an output format specification with type TYPE, width
@@
-767,53
+776,53
@@
make_output_format_try (struct fmt_spec *f, int type, int w, int d)
/* Callback for when the var type dialog is closed using the OK button.
It sets the appropriate variable accordingly. */
static gint
/* Callback for when the var type dialog is closed using the OK button.
It sets the appropriate variable accordingly. */
static gint
-on_var_type_ok_clicked(GtkWidget *w, gpointer data)
+on_var_type_ok_clicked
(GtkWidget *w, gpointer data)
{
struct var_type_dialog *dialog = data;
{
struct var_type_dialog *dialog = data;
- g_assert(dialog);
- g_assert(dialog->pv);
+ g_assert
(dialog);
+ g_assert
(dialog->pv);
{
{
- gint width = atoi(gtk_entry_get_text
- (GTK_ENTRY(dialog->entry_width)));
+ gint width = atoi
(gtk_entry_get_text
+ (GTK_ENTRY
(dialog->entry_width)));
- 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 = 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;
new_width = width;
- result = make_output_format_try(&spec, FMT_A, width, 0);
+ result = make_output_format_try
(&spec, FMT_A, width, 0);
break;
case BUTTON_NUMERIC:
break;
case BUTTON_NUMERIC:
- result = make_output_format_try(&spec, FMT_F, width, decimals);
+ result = make_output_format_try
(&spec, FMT_F, width, decimals);
break;
case BUTTON_COMMA:
break;
case BUTTON_COMMA:
- result = make_output_format_try(&spec, FMT_COMMA, width, decimals);
+ result = make_output_format_try
(&spec, FMT_COMMA, width, decimals);
break;
case BUTTON_DOT:
break;
case BUTTON_DOT:
- result = make_output_format_try(&spec, FMT_DOT, width, decimals);
+ result = make_output_format_try
(&spec, FMT_DOT, width, decimals);
break;
case BUTTON_SCIENTIFIC:
break;
case BUTTON_SCIENTIFIC:
- result = make_output_format_try(&spec, FMT_E, width, decimals);
+ result = make_output_format_try
(&spec, FMT_E, width, decimals);
break;
case BUTTON_DATE:
case BUTTON_CUSTOM:
break;
case BUTTON_DATE:
case BUTTON_CUSTOM:
- g_assert
(fmt_check_output
(&dialog->fmt_l));
- result = memcpy
(&spec, &dialog->fmt_l, sizeof
(struct fmt_spec));
+ g_assert
(fmt_check_output
(&dialog->fmt_l));
+ result = memcpy
(&spec, &dialog->fmt_l, sizeof
(struct fmt_spec));
break;
case BUTTON_DOLLAR:
break;
case BUTTON_DOLLAR:
- result = make_output_format_try(&spec, FMT_DOLLAR, width, decimals);
+ result = make_output_format_try
(&spec, FMT_DOLLAR, width, decimals);
break;
default:
break;
default:
- g_print("Unknown variable type: %d\n", dialog->active_button) ;
+ g_print
("Unknown variable type: %d\n", dialog->active_button) ;
result = false;
break;
}
result = false;
break;
}
@@
-825,17
+834,19
@@
on_var_type_ok_clicked(GtkWidget *w, gpointer data)
}
}
}
}
- gtk_widget_hide(dialog->window);
+ gtk_widget_hide
(dialog->window);
return FALSE;
}
return FALSE;
}
-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;
}