projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Set individual cell renderers for variable sheet columns
[pspp]
/
src
/
ui
/
gui
/
psppire-val-chooser.c
diff --git
a/src/ui/gui/psppire-val-chooser.c
b/src/ui/gui/psppire-val-chooser.c
index eb233b4ae5d2ed87fd1f536b8e85c3252c90af95..25a34f1275dc7d813c81b09c086fe92ead436d48 100644
(file)
--- a/
src/ui/gui/psppire-val-chooser.c
+++ b/
src/ui/gui/psppire-val-chooser.c
@@
-1,5
+1,5
@@
/* PSPPIRE - a graphical user interface for PSPP.
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2011 Free Software Foundation
+ Copyright (C) 2011
, 2014
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
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
@@
-16,6
+16,7
@@
#include <config.h>
#include <config.h>
+#include <float.h>
#include <gtk/gtk.h>
#include "dialog-common.h"
#include "psppire-val-chooser.h"
#include <gtk/gtk.h>
#include "dialog-common.h"
#include "psppire-val-chooser.h"
@@
-295,7
+296,7
@@
static void range_set (PsppireValChooser *vr, struct old_value *ov, const struct
static GtkWidget * range_entry (struct layout *l, struct range_widgets *rw)
{
static GtkWidget * range_entry (struct layout *l, struct range_widgets *rw)
{
- GtkWidget *vbox = gtk_
vbox_new (3, FALSE
);
+ GtkWidget *vbox = gtk_
box_new (GTK_ORIENTATION_VERTICAL, 3
);
GtkWidget *entrylo = gtk_entry_new ();
GtkWidget *label = gtk_label_new (_("through"));
GtkWidget *entryhi = gtk_entry_new ();
GtkWidget *entrylo = gtk_entry_new ();
GtkWidget *label = gtk_label_new (_("through"));
GtkWidget *entryhi = gtk_entry_new ();
@@
-303,7
+304,11
@@
static GtkWidget * range_entry (struct layout *l, struct range_widgets *rw)
rw->e1 = GTK_ENTRY (entrylo);
rw->e2 = GTK_ENTRY (entryhi);
rw->e1 = GTK_ENTRY (entrylo);
rw->e2 = GTK_ENTRY (entryhi);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ g_object_set (G_OBJECT (label),
+ "valign", GTK_ALIGN_CENTER,
+ "halign", GTK_ALIGN_START,
+ NULL);
+
g_signal_connect (vbox, "notify::sensitive", G_CALLBACK (focus_follows_sensitivity), entrylo);
g_signal_connect (vbox, "notify::sensitive", G_CALLBACK (focus_follows_sensitivity), entrylo);
@@
-339,13
+344,15
@@
static void
psppire_val_chooser_init (PsppireValChooser *vr)
{
gint i;
psppire_val_chooser_init (PsppireValChooser *vr)
{
gint i;
- GtkWidget *aln = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
- GtkWidget *table = gtk_table_new (11, 2, FALSE);
+ GtkWidget *grid = gtk_grid_new ();
GSList *group = NULL;
gint row = 0;
GSList *group = NULL;
gint row = 0;
- gtk_alignment_set_padding (GTK_ALIGNMENT (aln), 0, 0, 5, 5);
-
+ g_object_set (G_OBJECT (grid),
+ "margin-start", 5,
+ "margin-end", 5,
+ NULL);
+
vr->input_var_is_string = FALSE;
for (i = 0; i < n_VAL_CHOOSER_BUTTONS; ++i)
vr->input_var_is_string = FALSE;
for (i = 0; i < n_VAL_CHOOSER_BUTTONS; ++i)
@@
-356,21
+363,26
@@
psppire_val_chooser_init (PsppireValChooser *vr)
vr->rw[i].rb = GTK_TOGGLE_BUTTON (gtk_radio_button_new (group));
gtk_label_set_mnemonic_widget (vr->rw[i].label, GTK_WIDGET (vr->rw[i].rb));
vr->rw[i].rb = GTK_TOGGLE_BUTTON (gtk_radio_button_new (group));
gtk_label_set_mnemonic_widget (vr->rw[i].label, GTK_WIDGET (vr->rw[i].rb));
- gtk_misc_set_alignment (GTK_MISC (vr->rw[i].label), 0, 0.5);
+ g_object_set (G_OBJECT (vr->rw[i].label),
+ "valign", GTK_ALIGN_CENTER,
+ "halign", GTK_ALIGN_START,
+ NULL);
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (vr->rw[i].rb));
/* Attach the buttons */
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (vr->rw[i].rb));
/* Attach the buttons */
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (vr->rw[i].rb),
- 0, 1, row, row + 1,
- 0, GTK_EXPAND | GTK_FILL,
- 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (vr->rw[i].rb),
+ 0, row, 1, 1);
+ gtk_widget_set_hexpand (GTK_WIDGET (vr->rw[i].rb), FALSE);
+
/* Attach the labels */
/* Attach the labels */
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (vr->rw[i].label),
- 1, 2, row, row + 1,
- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
- 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (vr->rw[i].label),
+ 1, row, 1, 1);
+
+ gtk_widget_set_hexpand (GTK_WIDGET (vr->rw[i].label), TRUE);
+
+
++row;
if (l->fill)
++row;
if (l->fill)
@@
-379,8
+391,10
@@
psppire_val_chooser_init (PsppireValChooser *vr)
gtk_widget_set_sensitive (fill, FALSE);
gtk_widget_set_sensitive (fill, FALSE);
- gtk_table_attach_defaults (GTK_TABLE (table), fill, 1, 2,
- row, row + 1);
+ gtk_grid_attach (GTK_GRID (grid), fill, 1, row, 1, 1);
+
+ gtk_widget_set_hexpand (fill, TRUE);
+
++row;
g_signal_connect (vr->rw[i].rb, "toggled", G_CALLBACK (set_sensitivity_from_toggle), fill);
++row;
g_signal_connect (vr->rw[i].rb, "toggled", G_CALLBACK (set_sensitivity_from_toggle), fill);
@@
-389,10
+403,9
@@
psppire_val_chooser_init (PsppireValChooser *vr)
gtk_frame_set_shadow_type (GTK_FRAME (vr), GTK_SHADOW_ETCHED_IN);
gtk_frame_set_shadow_type (GTK_FRAME (vr), GTK_SHADOW_ETCHED_IN);
- gtk_container_add (GTK_CONTAINER (aln), table);
- gtk_container_add (GTK_CONTAINER (vr), aln);
+ gtk_container_add (GTK_CONTAINER (vr), grid);
- gtk_widget_show_all (
aln
);
+ gtk_widget_show_all (
grid
);
}
}
@@
-452,7
+465,7
@@
old_value_to_string (const GValue *src, GValue *dest)
{
case OV_NUMERIC:
{
{
case OV_NUMERIC:
{
- gchar *text = g_strdup_printf ("%
g"
, ov->v.v);
+ gchar *text = g_strdup_printf ("%
.*g", DBL_DIG + 1
, ov->v.v);
g_value_set_string (dest, text);
g_free (text);
}
g_value_set_string (dest, text);
g_free (text);
}
@@
-476,10
+489,10
@@
old_value_to_string (const GValue *src, GValue *dest)
g_unichar_to_utf8 (0x2013, en_dash);
g_unichar_to_utf8 (0x2013, en_dash);
- text = g_strdup_printf ("%
g %s %
g",
-
ov->v.range[0],
-
en_dash,
-
ov->v.range[1]);
+ text = g_strdup_printf ("%
.*g %s %.*
g",
+
DBL_DIG + 1,
ov->v.range[0],
+ en_dash,
+
DBL_DIG + 1,
ov->v.range[1]);
g_value_set_string (dest, text);
g_free (text);
}
g_value_set_string (dest, text);
g_free (text);
}
@@
-491,9
+504,9
@@
old_value_to_string (const GValue *src, GValue *dest)
g_unichar_to_utf8 (0x2013, en_dash);
g_unichar_to_utf8 (0x2013, en_dash);
- text = g_strdup_printf ("LOWEST %s %g",
+ text = g_strdup_printf ("LOWEST %s %
.*
g",
en_dash,
en_dash,
- ov->v.range[1]);
+
DBL_DIG + 1,
ov->v.range[1]);
g_value_set_string (dest, text);
g_free (text);
g_value_set_string (dest, text);
g_free (text);
@@
-506,8
+519,8
@@
old_value_to_string (const GValue *src, GValue *dest)
g_unichar_to_utf8 (0x2013, en_dash);
g_unichar_to_utf8 (0x2013, en_dash);
- text = g_strdup_printf ("%g %s HIGHEST",
- ov->v.range[0],
+ text = g_strdup_printf ("%
.*
g %s HIGHEST",
+
DBL_DIG + 1,
ov->v.range[0],
en_dash);
g_value_set_string (dest, text);
en_dash);
g_value_set_string (dest, text);
@@
-548,7
+561,7
@@
old_value_append_syntax (struct string *str, const struct old_value *ov)
switch (ov->type)
{
case OV_NUMERIC:
switch (ov->type)
{
case OV_NUMERIC:
- ds_put_c_format (str, "%
g"
, ov->v.v);
+ ds_put_c_format (str, "%
.*g", DBL_DIG + 1
, ov->v.v);
break;
case OV_STRING:
{
break;
case OV_STRING:
{
@@
-568,17
+581,17
@@
old_value_append_syntax (struct string *str, const struct old_value *ov)
ds_put_cstr (str, "ELSE");
break;
case OV_RANGE:
ds_put_cstr (str, "ELSE");
break;
case OV_RANGE:
- ds_put_c_format (str, "%
g THRU %
g",
-
ov->v.range[0],
-
ov->v.range[1]);
+ ds_put_c_format (str, "%
.*g THRU %.*
g",
+
DBL_DIG + 1,
ov->v.range[0],
+
DBL_DIG + 1,
ov->v.range[1]);
break;
case OV_LOW_UP:
break;
case OV_LOW_UP:
- ds_put_c_format (str, "LOWEST THRU %g",
-
ov->v.range[1]);
+ ds_put_c_format (str, "LOWEST THRU %
.*
g",
+
DBL_DIG + 1,
ov->v.range[1]);
break;
case OV_HIGH_DOWN:
break;
case OV_HIGH_DOWN:
- ds_put_c_format (str, "%g THRU HIGHEST",
-
ov->v.range[0]);
+ ds_put_c_format (str, "%
.*
g THRU HIGHEST",
+
DBL_DIG + 1,
ov->v.range[0]);
break;
default:
g_warning ("Invalid type in old recode value");
break;
default:
g_warning ("Invalid type in old recode value");
@@
-612,7
+625,7
@@
psppire_val_chooser_get_status (PsppireValChooser *vr, struct old_value *ov)
static gchar *
num_to_string (gdouble x)
{
static gchar *
num_to_string (gdouble x)
{
- return g_strdup_printf ("%
g"
, x);
+ return g_strdup_printf ("%
.*g", DBL_DIG + 1
, x);
}
}