X-Git-Url: https://git.sur5r.net/?p=glabels;a=blobdiff_plain;f=src%2Fobject-editor-position-page.c;h=43e7802495e140b966d7d522f193f1f0c6cf74af;hp=e72036e07d6f42ec1634dd7e2fa9b134767a1cce;hb=db2403f05e4bd16e08346e4896e8feead63d0b12;hpb=9971dd3e6268224ee930a26fdb30f22395406233 diff --git a/src/object-editor-position-page.c b/src/object-editor-position-page.c index e72036e0..43e78024 100644 --- a/src/object-editor-position-page.c +++ b/src/object-editor-position-page.c @@ -1,53 +1,55 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - /* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * object-editor.c: object properties editor module + * object-editor-position-page.c + * Copyright (C) 2003-2009 Jim Evins . * - * Copyright (C) 2003 Jim Evins . + * This file is part of gLabels. * - * This program is free software; you can redistribute it and/or modify + * gLabels 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 + * 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, + * gLabels 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with gLabels. If not, see . */ + #include #include "object-editor.h" #include -#include -#include +#include #include #include "prefs.h" +#include "builder-util.h" +#include "units-util.h" #include "object-editor-private.h" #include "debug.h" + /*===========================================*/ /* Private macros */ /*===========================================*/ + /*===========================================*/ /* Private data types */ /*===========================================*/ + /*===========================================*/ /* Private globals */ /*===========================================*/ + /*===========================================*/ /* Local function prototypes */ /*===========================================*/ @@ -59,6 +61,7 @@ void gl_object_editor_prepare_position_page (glObjectEditor *editor) { + lglUnits units; const gchar *units_string; gdouble climb_rate; gint digits; @@ -66,22 +69,20 @@ gl_object_editor_prepare_position_page (glObjectEditor *editor) gl_debug (DEBUG_EDITOR, "START"); /* Extract widgets from XML tree. */ - editor->priv->pos_page_vbox = glade_xml_get_widget (editor->priv->gui, - "pos_page_vbox"); - editor->priv->pos_x_spin = glade_xml_get_widget (editor->priv->gui, - "pos_x_spin"); - editor->priv->pos_y_spin = glade_xml_get_widget (editor->priv->gui, - "pos_y_spin"); - editor->priv->pos_x_units_label = glade_xml_get_widget (editor->priv->gui, - "pos_x_units_label"); - editor->priv->pos_y_units_label = glade_xml_get_widget (editor->priv->gui, - "pos_y_units_label"); + gl_builder_util_get_widgets (editor->priv->builder, + "pos_page_vbox", &editor->priv->pos_page_vbox, + "pos_x_spin", &editor->priv->pos_x_spin, + "pos_y_spin", &editor->priv->pos_y_spin, + "pos_x_units_label", &editor->priv->pos_x_units_label, + "pos_y_units_label", &editor->priv->pos_y_units_label, + NULL); /* Get configuration information */ - units_string = gl_prefs_get_units_string (); - editor->priv->units_per_point = gl_prefs_get_units_per_point (); - climb_rate = gl_prefs_get_units_step_size (); - digits = gl_prefs_get_units_precision (); + units = gl_prefs_model_get_units (gl_prefs); + units_string = lgl_units_get_name (units); + editor->priv->units_per_point = lgl_units_get_units_per_point (units); + climb_rate = gl_units_util_get_step_size (units); + digits = gl_units_util_get_precision (units); /* Modify widgets based on configuration */ gtk_spin_button_set_digits (GTK_SPIN_BUTTON(editor->priv->pos_x_spin), digits); @@ -98,17 +99,18 @@ gl_object_editor_prepare_position_page (glObjectEditor *editor) /* Connect signals */ g_signal_connect_swapped (G_OBJECT (editor->priv->pos_x_spin), - "changed", + "value-changed", G_CALLBACK (gl_object_editor_changed_cb), G_OBJECT (editor)); g_signal_connect_swapped (G_OBJECT (editor->priv->pos_y_spin), - "changed", + "value-changed", G_CALLBACK (gl_object_editor_changed_cb), G_OBJECT (editor)); gl_debug (DEBUG_EDITOR, "END"); } + /*****************************************************************************/ /* Set position. */ /*****************************************************************************/ @@ -119,7 +121,12 @@ gl_object_editor_set_position (glObjectEditor *editor, { gl_debug (DEBUG_EDITOR, "START"); - editor->priv->stop_signals = TRUE; + + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->pos_x_spin), + gl_object_editor_changed_cb, editor); + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->pos_y_spin), + gl_object_editor_changed_cb, editor); + /* save a copy in internal units */ editor->priv->x = x; @@ -135,11 +142,17 @@ gl_object_editor_set_position (glObjectEditor *editor, gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->pos_x_spin), x); gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->pos_y_spin), y); - editor->priv->stop_signals = FALSE; + + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->pos_x_spin), + gl_object_editor_changed_cb, editor); + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->pos_y_spin), + gl_object_editor_changed_cb, editor); + gl_debug (DEBUG_EDITOR, "END"); } + /*****************************************************************************/ /* Set maximum position. */ /*****************************************************************************/ @@ -152,7 +165,12 @@ gl_object_editor_set_max_position (glObjectEditor *editor, gl_debug (DEBUG_EDITOR, "START"); - editor->priv->stop_signals = TRUE; + + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->pos_x_spin), + gl_object_editor_changed_cb, editor); + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->pos_y_spin), + gl_object_editor_changed_cb, editor); + /* save a copy in internal units */ editor->priv->x_max = x_max; @@ -166,19 +184,23 @@ gl_object_editor_set_max_position (glObjectEditor *editor, /* Set widget values */ tmp = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->pos_x_spin)); - gtk_spin_button_set_range (GTK_SPIN_BUTTON (editor->priv->pos_x_spin), - -x_max, 2.0*x_max); + gtk_spin_button_set_range (GTK_SPIN_BUTTON (editor->priv->pos_x_spin), -x_max, 2.0*x_max); gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->pos_x_spin), tmp); tmp = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->pos_y_spin)); - gtk_spin_button_set_range (GTK_SPIN_BUTTON (editor->priv->pos_y_spin), - -y_max, 2.0*y_max); + gtk_spin_button_set_range (GTK_SPIN_BUTTON (editor->priv->pos_y_spin), -y_max, 2.0*y_max); gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->pos_y_spin), tmp); - editor->priv->stop_signals = FALSE; + + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->pos_x_spin), + gl_object_editor_changed_cb, editor); + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->pos_y_spin), + gl_object_editor_changed_cb, editor); + gl_debug (DEBUG_EDITOR, "END"); } + /*****************************************************************************/ /* Query position. */ /*****************************************************************************/ @@ -204,35 +226,42 @@ gl_object_editor_get_position (glObjectEditor *editor, gl_debug (DEBUG_EDITOR, "END"); } + /*****************************************************************************/ /* PRIVATE. Prefs changed callback. Update units related items. */ /*****************************************************************************/ void position_prefs_changed_cb (glObjectEditor *editor) { + lglUnits units; const gchar *units_string; gdouble climb_rate; gint digits; gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->pos_x_spin), + gl_object_editor_changed_cb, editor); + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->pos_y_spin), + gl_object_editor_changed_cb, editor); + + /* Get new configuration information */ - units_string = gl_prefs_get_units_string (); - editor->priv->units_per_point = gl_prefs_get_units_per_point (); - climb_rate = gl_prefs_get_units_step_size (); - digits = gl_prefs_get_units_precision (); + units = gl_prefs_model_get_units (gl_prefs); + units_string = lgl_units_get_name (units); + editor->priv->units_per_point = lgl_units_get_units_per_point (units); + climb_rate = gl_units_util_get_step_size (units); + digits = gl_units_util_get_precision (units); /* Update characteristics of x_spin/y_spin */ - editor->priv->stop_signals = TRUE; - gtk_spin_button_set_digits (GTK_SPIN_BUTTON(editor->priv->pos_x_spin), - digits); - gtk_spin_button_set_digits (GTK_SPIN_BUTTON(editor->priv->pos_y_spin), - digits); + gtk_spin_button_set_digits (GTK_SPIN_BUTTON(editor->priv->pos_x_spin), digits); + gtk_spin_button_set_digits (GTK_SPIN_BUTTON(editor->priv->pos_y_spin), digits); gtk_spin_button_set_increments (GTK_SPIN_BUTTON(editor->priv->pos_x_spin), climb_rate, 10.0*climb_rate); gtk_spin_button_set_increments (GTK_SPIN_BUTTON(editor->priv->pos_y_spin), climb_rate, 10.0*climb_rate); - editor->priv->stop_signals = FALSE; + /* Update units_labels */ gtk_label_set_text (GTK_LABEL(editor->priv->pos_x_units_label), @@ -241,13 +270,26 @@ position_prefs_changed_cb (glObjectEditor *editor) units_string); /* Update values of x_spin/y_spin */ - gl_object_editor_set_position (editor, - editor->priv->x, - editor->priv->y); - gl_object_editor_set_max_position (editor, - editor->priv->x_max, - editor->priv->y_max); + gl_object_editor_set_position (editor, editor->priv->x, editor->priv->y); + gl_object_editor_set_max_position (editor, editor->priv->x_max, editor->priv->y_max); + + + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->pos_x_spin), + gl_object_editor_changed_cb, editor); + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->pos_y_spin), + gl_object_editor_changed_cb, editor); + gl_debug (DEBUG_EDITOR, "END"); } + + +/* + * Local Variables: -- emacs + * mode: C -- emacs + * c-basic-offset: 8 -- emacs + * tab-width: 8 -- emacs + * indent-tabs-mode: nil -- emacs + * End: -- emacs + */