[gtk+/refactor: 100/106] Use accessor functions to access GtkSpinButton
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/refactor: 100/106] Use accessor functions to access GtkSpinButton
- Date: Tue, 13 Jul 2010 17:38:25 +0000 (UTC)
commit 4cdd7e2454d551d0db2f14e9ca3b2c00d2d1143f
Author: Javier Jardón <jjardon gnome org>
Date: Tue Jul 13 00:48:49 2010 +0200
Use accessor functions to access GtkSpinButton
modules/other/gail/gailspinbutton.c | 14 +++++++++-----
tests/testgtk.c | 22 +++++++++++++++++-----
2 files changed, 26 insertions(+), 10 deletions(-)
---
diff --git a/modules/other/gail/gailspinbutton.c b/modules/other/gail/gailspinbutton.c
index c8ce652..078bf10 100644
--- a/modules/other/gail/gailspinbutton.c
+++ b/modules/other/gail/gailspinbutton.c
@@ -75,6 +75,7 @@ static void
gail_spin_button_real_initialize (AtkObject *obj,
gpointer data)
{
+ GtkAdjustment *adjustment;
GailSpinButton *spin_button = GAIL_SPIN_BUTTON (obj);
GtkSpinButton *gtk_spin_button;
@@ -85,10 +86,11 @@ gail_spin_button_real_initialize (AtkObject *obj,
* If a GtkAdjustment already exists for the spin_button,
* create the GailAdjustment
*/
- if (gtk_spin_button->adjustment)
+ adjustment = gtk_spin_button_get_adjustment (gtk_spin_button);
+ if (adjustment)
{
- spin_button->adjustment = gail_adjustment_new (gtk_spin_button->adjustment);
- g_signal_connect (gtk_spin_button->adjustment,
+ spin_button->adjustment = gail_adjustment_new (adjustment);
+ g_signal_connect (adjustment,
"value-changed",
G_CALLBACK (gail_spin_button_value_changed),
obj);
@@ -208,6 +210,7 @@ gail_spin_button_real_notify_gtk (GObject *obj,
* Get rid of the GailAdjustment for the GtkAdjustment
* which was associated with the spin_button.
*/
+ GtkAdjustment* adjustment;
GtkSpinButton* gtk_spin_button;
if (spin_button->adjustment)
@@ -220,8 +223,9 @@ gail_spin_button_real_notify_gtk (GObject *obj,
* is received
*/
gtk_spin_button = GTK_SPIN_BUTTON (widget);
- spin_button->adjustment = gail_adjustment_new (gtk_spin_button->adjustment);
- g_signal_connect (gtk_spin_button->adjustment,
+ adjustment = gtk_spin_button_get_adjustment (gtk_spin_button);
+ spin_button->adjustment = gail_adjustment_new (adjustment);
+ g_signal_connect (adjustment,
"value-changed",
G_CALLBACK (gail_spin_button_value_changed),
spin_button);
diff --git a/tests/testgtk.c b/tests/testgtk.c
index d196276..72269ed 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -5055,7 +5055,10 @@ get_value (GtkWidget *widget, gpointer data)
if (GPOINTER_TO_INT (data) == 1)
sprintf (buf, "%d", gtk_spin_button_get_value_as_int (spin));
else
- sprintf (buf, "%0.*f", spin->digits, gtk_spin_button_get_value (spin));
+ sprintf (buf, "%0.*f",
+ gtk_spin_button_get_digits (spin),
+ gtk_spin_button_get_value (spin));
+
gtk_label_set_text (label, buf);
}
@@ -5069,7 +5072,8 @@ get_spin_value (GtkWidget *widget, gpointer data)
spin = GTK_SPIN_BUTTON (widget);
label = GTK_LABEL (data);
- buffer = g_strdup_printf ("%0.*f", spin->digits,
+ buffer = g_strdup_printf ("%0.*f",
+ gtk_spin_button_get_digits (spin),
gtk_spin_button_get_value (spin));
gtk_label_set_text (label, buffer);
@@ -5079,11 +5083,13 @@ get_spin_value (GtkWidget *widget, gpointer data)
static gint
spin_button_time_output_func (GtkSpinButton *spin_button)
{
+ GtkAdjustment *adjustment;
static gchar buf[6];
gdouble hours;
gdouble minutes;
- hours = spin_button->adjustment->value / 60.0;
+ adjustment = gtk_spin_button_get_adjustment (spin_button);
+ hours = gtk_adjustment_get_value (adjustment) / 60.0;
minutes = (fabs(floor (hours) - hours) < 1e-5) ? 0.0 : 30;
sprintf (buf, "%02.0f:%02.0f", floor (hours), minutes);
if (strcmp (buf, gtk_entry_get_text (GTK_ENTRY (spin_button))))
@@ -5125,13 +5131,17 @@ spin_button_month_input_func (GtkSpinButton *spin_button,
static gint
spin_button_month_output_func (GtkSpinButton *spin_button)
{
+ GtkAdjustment *adjustment;
+ gdouble value;
gint i;
static gchar *month[12] = { "January", "February", "March", "April",
"May", "June", "July", "August", "September",
"October", "November", "December" };
+ adjustment = gtk_spin_button_get_adjustment (spin_button);
+ value = gtk_adjustment_get_value (adjustment);
for (i = 1; i <= 12; i++)
- if (fabs (spin_button->adjustment->value - (double)i) < 1e-5)
+ if (fabs (value - (double)i) < 1e-5)
{
if (strcmp (month[i-1], gtk_entry_get_text (GTK_ENTRY (spin_button))))
gtk_entry_set_text (GTK_ENTRY (spin_button), month[i-1]);
@@ -5159,10 +5169,12 @@ spin_button_hex_input_func (GtkSpinButton *spin_button,
static gint
spin_button_hex_output_func (GtkSpinButton *spin_button)
{
+ GtkAdjustment *adjustment;
static gchar buf[7];
gint val;
- val = (gint) spin_button->adjustment->value;
+ adjustment = gtk_spin_button_get_adjustment (spin_button);
+ val = (gint) gtk_adjustment_get_value (adjustment);
if (fabs (val) < 1e-5)
sprintf (buf, "0x00");
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]