[gimp/soc-2011-gimpunitentry: 63/68] GimpUnitEntry: GimpUnitAdjustment is created manually by the client



commit a907ec3b368187c511ebe41296d684acfebfdb0c
Author: Enrico Schröder <enni schroeder gmail com>
Date:   Thu Aug 11 16:54:52 2011 +0200

    GimpUnitEntry: GimpUnitAdjustment is created manually by the client
    
    Follow GtkSpinButton pattern: the adjustment must be created manually by the client and then be set via 
gimp_unit_entry_set_adjustment. This makes mirroring the GimpUnitAdjustment API unnecessary.

 app/dialogs/layer-options-dialog.c        |   22 +++---
 app/dialogs/offset-dialog.c               |    8 +-
 app/dialogs/preferences-dialog.c          |    3 +-
 app/dialogs/resize-dialog.c               |    8 +-
 app/dialogs/resolution-calibrate-dialog.c |    4 +-
 app/tools/gimprotatetool.c                |    4 +-
 app/widgets/gimpsizebox.c                 |   14 ++--
 app/widgets/gimptemplateeditor.c          |   34 +++++-----
 app/widgets/gimptextstyleeditor.c         |    8 ++-
 libgimpwidgets/gimppropwidgets.c          |   58 ++++++++--------
 libgimpwidgets/gimpunitentries.c          |   79 ++++++++++++++---------
 libgimpwidgets/gimpunitentries.h          |  100 +++++++++++++++--------------
 libgimpwidgets/gimpunitentry.c            |   99 ++++++++++------------------
 libgimpwidgets/gimpunitentry.h            |   23 ++-----
 libgimpwidgets/gimpwidgets.def            |   13 +---
 libgimpwidgets/test-unitentry.c           |   85 ++++++++++---------------
 libgimpwidgets/test-unitentrygui.c        |    4 +-
 17 files changed, 264 insertions(+), 302 deletions(-)
---
diff --git a/app/dialogs/layer-options-dialog.c b/app/dialogs/layer-options-dialog.c
index 652342b..c76dc95 100644
--- a/app/dialogs/layer-options-dialog.c
+++ b/app/dialogs/layer-options-dialog.c
@@ -69,8 +69,6 @@ layer_options_dialog_new (GimpImage    *image,
   GtkWidget          *table;
   GtkWidget          *frame;
   GtkWidget          *button;
-  GtkWidget          *width_entry;
-  GtkWidget          *height_entry;
 
   g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
   g_return_val_if_fail (layer == NULL || GIMP_IS_LAYER (layer), NULL);
@@ -139,17 +137,19 @@ layer_options_dialog_new (GimpImage    *image,
 
       /* the size unit-entries */
       options->unit_entries = GIMP_UNIT_ENTRIES (gimp_unit_entries_new ());
-      width_entry = gimp_unit_entries_add_entry  (options->unit_entries, "width", _("Width:"));
-      height_entry = gimp_unit_entries_add_entry (options->unit_entries, "height", _("Height:"));
+      gimp_unit_entries_add_entry (options->unit_entries, GIMP_UNIT_ENTRIES_WIDTH, _("Width:"));
+      gimp_unit_entries_add_entry (options->unit_entries, GIMP_UNIT_ENTRIES_HEIGHT, _("Height:"));
       
       gimp_unit_entries_set_unit        (options->unit_entries, GIMP_UNIT_PIXEL);
-      
-      gimp_unit_entry_set_resolution  (GIMP_UNIT_ENTRY (width_entry), xres);
-      gimp_unit_entry_set_resolution  (GIMP_UNIT_ENTRY (height_entry), yres);
-      gimp_unit_entry_set_value       (GIMP_UNIT_ENTRY (width_entry), gimp_image_get_width  (image));
-      gimp_unit_entry_set_value       (GIMP_UNIT_ENTRY (height_entry), gimp_image_get_height  (image));
-      gimp_unit_entry_set_bounds      (GIMP_UNIT_ENTRY (width_entry), GIMP_UNIT_PIXEL, GIMP_MAX_IMAGE_SIZE, 
GIMP_MIN_IMAGE_SIZE);
-      gimp_unit_entry_set_bounds      (GIMP_UNIT_ENTRY (height_entry), GIMP_UNIT_PIXEL, GIMP_MAX_IMAGE_SIZE, 
GIMP_MIN_IMAGE_SIZE);
+
+      gimp_unit_adjustment_set_resolution  (gimp_unit_entries_get_adjustment (options->unit_entries, 
GIMP_UNIT_ENTRIES_WIDTH),
+                                            xres);
+      gimp_unit_adjustment_set_resolution  (gimp_unit_entries_get_adjustment (options->unit_entries, 
GIMP_UNIT_ENTRIES_HEIGHT),
+                                            yres);
+
+      gimp_unit_entries_set_pixels  (options->unit_entries, GIMP_UNIT_ENTRIES_WIDTH, gimp_image_get_width  
(image));
+      gimp_unit_entries_set_pixels  (options->unit_entries, GIMP_UNIT_ENTRIES_HEIGHT, gimp_image_get_height  
(image));
+      gimp_unit_entries_set_bounds  (options->unit_entries, GIMP_UNIT_PIXEL, GIMP_MAX_IMAGE_SIZE, 
GIMP_MIN_IMAGE_SIZE);
 
       gtk_table_attach (GTK_TABLE (table), gimp_unit_entries_get_table (options->unit_entries), 0, 2, 1, 3,
                         GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
diff --git a/app/dialogs/offset-dialog.c b/app/dialogs/offset-dialog.c
index c2df0b6..961a023 100644
--- a/app/dialogs/offset-dialog.c
+++ b/app/dialogs/offset-dialog.c
@@ -169,10 +169,10 @@ offset_dialog_new (GimpDrawable *drawable,
 
   gimp_unit_entries_set_unit (entries, GIMP_UNIT_PIXEL);
 
-  gimp_unit_entry_set_resolution (gimp_unit_entries_get_entry (entries, GIMP_UNIT_ENTRIES_OFFSET_X),
-                                  xres);
-  gimp_unit_entry_set_resolution (gimp_unit_entries_get_entry (entries, GIMP_UNIT_ENTRIES_OFFSET_Y),
-                                  yres);
+  gimp_unit_adjustment_set_resolution (gimp_unit_entries_get_adjustment (entries, 
GIMP_UNIT_ENTRIES_OFFSET_X),
+                                       xres);
+  gimp_unit_adjustment_set_resolution (gimp_unit_entries_get_adjustment (entries, 
GIMP_UNIT_ENTRIES_OFFSET_Y),
+                                       yres);
 
   gimp_unit_entry_set_bounds (gimp_unit_entries_get_entry (entries, GIMP_UNIT_ENTRIES_OFFSET_X),
                               GIMP_UNIT_PIXEL,
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index c965976..2ad6a58 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -2172,10 +2172,9 @@ prefs_dialog_new (Gimp       *gimp,
                                        _("Horizontal"),
                                        _("Vertical"),
                                        NULL,  /* unit_property_name */
-                                       -1.0, -1.0, 
+                                       1.0, 1.0, 
                                        TRUE));
     gimp_unit_entries_set_mode (unit_entries, GIMP_UNIT_ENTRY_MODE_RESOLUTION);
-
   }
 
   hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
diff --git a/app/dialogs/resize-dialog.c b/app/dialogs/resize-dialog.c
index 6270af8..01dc923 100644
--- a/app/dialogs/resize-dialog.c
+++ b/app/dialogs/resize-dialog.c
@@ -215,10 +215,10 @@ resize_dialog_new (GimpViewable       *viewable,
 
   gtk_box_pack_start (GTK_BOX (vbox), gimp_unit_entries_get_table (unit_entries), FALSE, FALSE, 0);
 
-  gimp_unit_entry_set_resolution (
-    gimp_unit_entries_get_entry (unit_entries, GIMP_UNIT_ENTRIES_OFFSET_X), xres);
-  gimp_unit_entry_set_resolution (
-    gimp_unit_entries_get_entry (unit_entries, GIMP_UNIT_ENTRIES_OFFSET_Y), yres);
+  gimp_unit_adjustment_set_resolution (gimp_unit_entries_get_adjustment (unit_entries, 
GIMP_UNIT_ENTRIES_OFFSET_X), 
+                                       xres);
+  gimp_unit_adjustment_set_resolution (gimp_unit_entries_get_adjustment (unit_entries, 
GIMP_UNIT_ENTRIES_OFFSET_Y), 
+                                       yres);
 
   gimp_unit_entries_set_unit (unit_entries, GIMP_UNIT_PIXEL);
   gimp_unit_entries_set_bounds (unit_entries, GIMP_UNIT_PIXEL, 0 , 0);
diff --git a/app/dialogs/resolution-calibrate-dialog.c b/app/dialogs/resolution-calibrate-dialog.c
index 99538cb..be2fb35 100644
--- a/app/dialogs/resolution-calibrate-dialog.c
+++ b/app/dialogs/resolution-calibrate-dialog.c
@@ -152,8 +152,8 @@ resolution_calibrate_dialog (GimpUnitEntries   *resolution_entries,
     GIMP_UNIT_ENTRY (gimp_unit_entries_add_entry (calibrate_entries, "horizontal", _("Horizontal")));  
   vertical_entry = 
     GIMP_UNIT_ENTRY (gimp_unit_entries_add_entry (calibrate_entries, "vertical", _("Vertical")));            
           
-  gimp_unit_entry_set_resolution         (horizontal_entry, calibrate_xres);
-  gimp_unit_entry_set_resolution         (vertical_entry,   calibrate_yres);
+  gimp_unit_adjustment_set_resolution (gimp_unit_entry_get_adjustment (horizontal_entry), calibrate_xres);
+  gimp_unit_adjustment_set_resolution (gimp_unit_entry_get_adjustment (vertical_entry),   calibrate_yres);
   gimp_unit_entry_set_pixels             (horizontal_entry, ruler_width);
   gimp_unit_entry_set_pixels             (vertical_entry,   ruler_height);
 
diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c
index be97e56..c590efb 100644
--- a/app/tools/gimprotatetool.c
+++ b/app/tools/gimprotatetool.c
@@ -262,8 +262,8 @@ gimp_rotate_tool_prepare (GimpTransformTool *tr_tool)
 
   gimp_unit_entries_set_unit (entries, gimp_display_get_shell (display)->unit);
 
-  gimp_unit_entry_set_resolution (gimp_unit_entries_get_entry (entries, "center_x"), xres);
-  gimp_unit_entry_set_resolution (gimp_unit_entries_get_entry (entries, "center_y"), yres);
+  gimp_unit_adjustment_set_resolution (gimp_unit_entries_get_adjustment (entries, "center_x"), xres);
+  gimp_unit_adjustment_set_resolution (gimp_unit_entries_get_adjustment (entries, "center_y"), yres);
 
   gimp_unit_entry_set_bounds (gimp_unit_entries_get_entry (entries, "center_x"),
                               GIMP_UNIT_PIXEL,
diff --git a/app/widgets/gimpsizebox.c b/app/widgets/gimpsizebox.c
index 6992254..328d251 100644
--- a/app/widgets/gimpsizebox.c
+++ b/app/widgets/gimpsizebox.c
@@ -207,7 +207,7 @@ gimp_size_box_constructed (GObject *object)
   g_list_free (children);
 
   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
-  gtk_table_attach_defaults (GTK_TABLE (gimp_unit_entries_get_table (unit_entries)), vbox, 4, 6, 3, 4);
+  gtk_table_attach_defaults (GTK_TABLE (gimp_unit_entries_get_table (unit_entries)), vbox, 4, 6, 2, 3);
   gtk_widget_show (vbox);
 
   label = gtk_label_new (NULL);
@@ -306,18 +306,18 @@ gimp_size_box_set_property (GObject      *object,
     case PROP_XRESOLUTION:
       box->xresolution = g_value_get_double (value);
       if (priv->unit_entries)
-        gimp_unit_entry_set_resolution (gimp_unit_entries_get_entry (priv->unit_entries, 
-                                                                     GIMP_UNIT_ENTRIES_WIDTH),
-                                        box->xresolution);
+        gimp_unit_adjustment_set_resolution (
+            gimp_unit_entries_get_adjustment (priv->unit_entries, GIMP_UNIT_ENTRIES_WIDTH),
+            box->xresolution);
       gimp_size_box_update_resolution (box);
       break;
 
     case PROP_YRESOLUTION:
       box->yresolution = g_value_get_double (value);
       if (priv->unit_entries)
-        gimp_unit_entry_set_resolution (gimp_unit_entries_get_entry (priv->unit_entries, 
-                                                                     GIMP_UNIT_ENTRIES_HEIGHT),
-                                        box->xresolution);
+        gimp_unit_adjustment_set_resolution (
+            gimp_unit_entries_get_adjustment (priv->unit_entries, GIMP_UNIT_ENTRIES_HEIGHT),
+            box->yresolution);
       gimp_size_box_update_resolution (box);
       break;
 
diff --git a/app/widgets/gimptemplateeditor.c b/app/widgets/gimptemplateeditor.c
index 27077dc..c2c98f7 100644
--- a/app/widgets/gimptemplateeditor.c
+++ b/app/widgets/gimptemplateeditor.c
@@ -294,10 +294,10 @@ gimp_template_editor_constructed (GObject *object)
   gtk_box_pack_start (GTK_BOX (hbox), gimp_unit_entries_get_table (private->resolution_entries), TRUE, TRUE, 
0);
   gtk_widget_show (gimp_unit_entries_get_table (private->resolution_entries));
 
-  gimp_unit_entry_set_resolution (gimp_unit_entries_get_nth_entry (private->unit_entries, 0),
-                                  gimp_template_get_resolution_x (template));
-  gimp_unit_entry_set_resolution (gimp_unit_entries_get_nth_entry (private->unit_entries, 1),
-                                  gimp_template_get_resolution_y (template));
+  gimp_unit_adjustment_set_resolution (gimp_unit_entries_get_adjustment (private->unit_entries, 
GIMP_UNIT_ENTRIES_WIDTH),
+                                       gimp_template_get_resolution_x (template));
+  gimp_unit_adjustment_set_resolution (gimp_unit_entries_get_adjustment (private->unit_entries, 
GIMP_UNIT_ENTRIES_HEIGHT),
+                                       gimp_template_get_resolution_y (template));
 
   /*  the resolution chainbutton  */
   chainbutton = gimp_unit_entries_add_chain_button (private->resolution_entries,
@@ -533,12 +533,12 @@ gimp_template_editor_aspect_callback (GtkWidget          *widget,
                                        gimp_template_editor_template_notify,
                                        editor);
 
-      gimp_unit_entry_set_resolution (gimp_unit_entries_get_entry (private->unit_entries,
-                                                                   GIMP_UNIT_ENTRIES_WIDTH),
-                                      yresolution); 
-      gimp_unit_entry_set_resolution (gimp_unit_entries_get_entry (private->unit_entries,
-                                                                   GIMP_UNIT_ENTRIES_WIDTH),
-                                      xresolution);                                                          
      
+      gimp_unit_adjustment_set_resolution (gimp_unit_entries_get_adjustment (private->unit_entries,
+                                                                             GIMP_UNIT_ENTRIES_WIDTH),
+                                           xresolution); 
+      gimp_unit_adjustment_set_resolution (gimp_unit_entries_get_adjustment (private->unit_entries,
+                                                                             GIMP_UNIT_ENTRIES_HEIGHT),
+                                           yresolution);                                                     
           
 
       g_object_set (template,
                     GIMP_UNIT_ENTRIES_WIDTH,  height,
@@ -573,13 +573,15 @@ gimp_template_editor_template_notify (GimpTemplate       *template,
     {
       if (! strcmp (param_spec->name, "xresolution"))
         {
-          gimp_unit_entry_set_resolution (gimp_unit_entries_get_nth_entry (private->unit_entries, 0),
-                                          gimp_template_get_resolution_x (template));
+          gimp_unit_adjustment_set_resolution (gimp_unit_entries_get_adjustment (private->unit_entries,
+                                                                                 GIMP_UNIT_ENTRIES_HEIGHT),
+                                               gimp_template_get_resolution_x (template));
         }
       else if (! strcmp (param_spec->name, "yresolution"))
         {
-          gimp_unit_entry_set_resolution (gimp_unit_entries_get_nth_entry (private->unit_entries, 1),
-                                          gimp_template_get_resolution_y (template));                        
       
+          gimp_unit_adjustment_set_resolution (gimp_unit_entries_get_adjustment (private->unit_entries, 
+                                                                                 GIMP_UNIT_ENTRIES_WIDTH),
+                                               gimp_template_get_resolution_y (template));                   
            
         }
     }
 
@@ -610,8 +612,8 @@ gimp_template_editor_template_notify (GimpTemplate       *template,
                        gimp_template_get_base_type (template),
                        NULL, NULL, &desc, NULL);
 
-  xres = ROUND (gimp_template_get_resolution_x (template));
-  yres = ROUND (gimp_template_get_resolution_y (template));
+  xres = ROUND (gimp_template_get_resolution_y (template));
+  yres = ROUND (gimp_template_get_resolution_x (template));
 
   if (xres != yres)
     text = g_strdup_printf (_("%d × %d ppi, %s"), xres, yres, desc);
diff --git a/app/widgets/gimptextstyleeditor.c b/app/widgets/gimptextstyleeditor.c
index 57cfee7..df3285c 100644
--- a/app/widgets/gimptextstyleeditor.c
+++ b/app/widgets/gimptextstyleeditor.c
@@ -183,8 +183,9 @@ gimp_text_style_editor_class_init (GimpTextStyleEditorClass *klass)
 static void
 gimp_text_style_editor_init (GimpTextStyleEditor *editor)
 {
-  GtkWidget *image;
-  GimpRGB    color;
+  GtkWidget          *image;
+  GimpRGB             color;
+  GimpUnitAdjustment *unit_adjustment;
 
   gtk_orientable_set_orientation (GTK_ORIENTABLE (editor),
                                   GTK_ORIENTATION_VERTICAL);
@@ -206,7 +207,8 @@ gimp_text_style_editor_init (GimpTextStyleEditor *editor)
                            _("Change font of selected text"), NULL);
 
   editor->unit_entry = gimp_unit_entry_new ();
-  gimp_unit_entry_set_unit (GIMP_UNIT_ENTRY (editor->unit_entry), GIMP_UNIT_PIXEL);
+  unit_adjustment = gimp_unit_entry_get_adjustment (GIMP_UNIT_ENTRY (editor->unit_entry));
+  gimp_unit_adjustment_set_unit (unit_adjustment, GIMP_UNIT_PIXEL);
   gtk_box_pack_start (GTK_BOX (editor->upper_hbox), editor->unit_entry,
                       FALSE, FALSE, 0);
   gtk_widget_show (editor->unit_entry);
diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c
index 518aff5..e29f4f2 100644
--- a/libgimpwidgets/gimppropwidgets.c
+++ b/libgimpwidgets/gimppropwidgets.c
@@ -2922,7 +2922,7 @@ gimp_prop_coordinates_connect     (GObject       *config,
   gdouble             *old_y_value;
   GimpUnit            *old_unit_value;
   gboolean            chain_checked;
-  GimpUnitEntry       *entry1, *entry2;
+  GimpUnitEntry       *x_entry, *y_entry;
   GimpUnitEntries     *unit_entries;
 
   g_return_val_if_fail (GIMP_IS_UNIT_ENTRIES (unitentries), FALSE);
@@ -2962,37 +2962,37 @@ gimp_prop_coordinates_connect     (GObject       *config,
       unit_value      = GIMP_UNIT_INCH;
     }
 
-  entry1 = gimp_unit_entries_get_nth_entry (unit_entries, 0);
-  entry2 = gimp_unit_entries_get_nth_entry (unit_entries, 1);
-  g_return_val_if_fail (GIMP_IS_UNIT_ENTRY (entry1), FALSE);
-  g_return_val_if_fail (GIMP_IS_UNIT_ENTRY (entry2), FALSE);
+  x_entry = gimp_unit_entries_get_nth_entry (unit_entries, 0);
+  y_entry = gimp_unit_entries_get_nth_entry (unit_entries, 1);
+  g_return_val_if_fail (GIMP_IS_UNIT_ENTRY (x_entry), FALSE);
+  g_return_val_if_fail (GIMP_IS_UNIT_ENTRY (y_entry), FALSE);
 
   set_param_spec (NULL,
-                  GTK_WIDGET (entry1),
+                  GTK_WIDGET (x_entry),
                   x_param_spec);
   set_param_spec (NULL,
-                  GTK_WIDGET (entry2),
+                  GTK_WIDGET (y_entry),
                   y_param_spec);
 
   gimp_unit_entries_set_unit (unit_entries, unit_value);
 
-  gimp_unit_entry_set_resolution (entry1, xresolution);
-  gimp_unit_entry_set_resolution (entry2, yresolution);
+  gimp_unit_adjustment_set_resolution (gimp_unit_entry_get_adjustment (x_entry), xresolution);
+  gimp_unit_adjustment_set_resolution (gimp_unit_entry_get_adjustment (y_entry), yresolution);
 
   chain_checked = (ABS (x_value - y_value) < 1);
 
-  gimp_unit_entry_set_bounds (entry1,
+  gimp_unit_entry_set_bounds (x_entry,
                               GIMP_UNIT_PIXEL,
-                              x_upper,
-                              x_lower);
+                              x_lower,
+                              x_upper);
 
-  gimp_unit_entry_set_bounds (entry2,
+  gimp_unit_entry_set_bounds (y_entry,
                               GIMP_UNIT_PIXEL,
-                              y_upper,
-                              y_lower);
+                              y_lower,
+                              y_upper);
 
-  gimp_unit_entry_set_value_in_unit (entry1, x_value, GIMP_UNIT_PIXEL);
-  gimp_unit_entry_set_value_in_unit (entry2, y_value, GIMP_UNIT_PIXEL);                                      
 
+  gimp_unit_entry_set_pixels (x_entry, x_value);
+  gimp_unit_entry_set_pixels (y_entry, y_value);                                       
 
   g_object_set_data (G_OBJECT (unit_entries), "gimp-config-param-spec-x",
                      x_param_spec);
@@ -3068,7 +3068,7 @@ gimp_prop_coordinates_callback  (GimpUnitEntries *entries,
   gdouble       *old_y_value;
   GimpUnit      *old_unit_value;
   gboolean       backwards;
-  GimpUnitEntry *entry1, *entry2;
+  GimpUnitEntry *x_entry, *y_entry;
 
   x_param_spec = g_object_get_data (G_OBJECT (entries),
                                     "gimp-config-param-spec-x");
@@ -3080,12 +3080,12 @@ gimp_prop_coordinates_callback  (GimpUnitEntries *entries,
   unit_param_spec = g_object_get_data (G_OBJECT (entries),
                                        "gimp-config-param-spec-unit");
 
-  entry1 = gimp_unit_entries_get_nth_entry (entries, 0);
-  entry2 = gimp_unit_entries_get_nth_entry (entries, 1);                                    
+  x_entry = gimp_unit_entries_get_nth_entry (entries, 0);
+  y_entry = gimp_unit_entries_get_nth_entry (entries, 1);                                    
 
-  x_value    = gimp_unit_entry_get_value_in_unit (entry1, GIMP_UNIT_PIXEL);
-  y_value    = gimp_unit_entry_get_value_in_unit (entry2, GIMP_UNIT_PIXEL);
-  unit_value = gimp_unit_entry_get_unit (entry1);
+  x_value    = gimp_unit_entry_get_pixels (x_entry);
+  y_value    = gimp_unit_entry_get_pixels (y_entry);
+  unit_value = gimp_unit_adjustment_get_unit (gimp_unit_entry_get_adjustment (x_entry));
 
   old_x_value    = g_object_get_data (G_OBJECT (entries), "old-x-value");
   old_y_value    = g_object_get_data (G_OBJECT (entries), "old-y-value");
@@ -3182,13 +3182,13 @@ gimp_prop_coordinates_notify_unit  (GObject             *config,
                 param_spec->name, &value,
                 NULL);
 
-  if (value != gimp_unit_entry_get_unit (entry))
+  if (value != gimp_unit_adjustment_get_unit (gimp_unit_entry_get_adjustment (entry)))
     {
       g_signal_handlers_block_by_func (entries,
                                        gimp_prop_coordinates_callback,
                                        config);
 
-      gimp_unit_entry_set_unit (entry, value);
+      gimp_unit_adjustment_set_unit (gimp_unit_entry_get_adjustment (entry), value);
 
       g_signal_handlers_unblock_by_func (entries,
                                          gimp_prop_coordinates_callback,
@@ -3225,7 +3225,7 @@ gimp_prop_coordinates_notify_x  (GObject           *config,
                     NULL);
     }
 
-  if (value != gimp_unit_entry_get_value_in_unit (entry, GIMP_UNIT_PIXEL))
+  if (value != gimp_unit_entry_get_pixels (entry))
     {
       gdouble *old_x_value = g_object_get_data (G_OBJECT (entries),
                                                 "old-x-value");
@@ -3234,7 +3234,7 @@ gimp_prop_coordinates_notify_x  (GObject           *config,
                                        gimp_prop_coordinates_callback,
                                        config);
 
-      gimp_unit_entry_set_value_in_unit (entry, value, GIMP_UNIT_PIXEL);
+      gimp_unit_entry_set_pixels (entry, value);
 
       if (old_x_value)
         *old_x_value = value;
@@ -3274,7 +3274,7 @@ gimp_prop_coordinates_notify_y (GObject           *config,
                     NULL);
     }
 
-  if (value != gimp_unit_entry_get_value_in_unit (entry, GIMP_UNIT_PIXEL))
+  if (value != gimp_unit_entry_get_pixels (entry))
     {
       gdouble *old_y_value = g_object_get_data (G_OBJECT (entries),
                                                 "old-y-value");
@@ -3283,7 +3283,7 @@ gimp_prop_coordinates_notify_y (GObject           *config,
                                        gimp_prop_coordinates_callback,
                                        config);
 
-      gimp_unit_entry_set_value_in_unit (entry, value, GIMP_UNIT_PIXEL);
+      gimp_unit_entry_set_pixels (entry, value);
 
       if (old_y_value)
         *old_y_value = value;
diff --git a/libgimpwidgets/gimpunitentries.c b/libgimpwidgets/gimpunitentries.c
index 20d378f..58d8e9e 100644
--- a/libgimpwidgets/gimpunitentries.c
+++ b/libgimpwidgets/gimpunitentries.c
@@ -110,8 +110,9 @@ gimp_unit_entries_add_entry (GimpUnitEntries *entries,
                              const gchar     *id,
                              const gchar     *label_str)
 {
-  GimpUnitEntriesPrivate  *private = GIMP_UNIT_ENTRIES_GET_PRIVATE (entries);
-  GimpUnitEntry           *entry   = GIMP_UNIT_ENTRY (gimp_unit_entry_new ()); 
+  GimpUnitEntriesPrivate  *private    = GIMP_UNIT_ENTRIES_GET_PRIVATE (entries);
+  GimpUnitAdjustment      *adjustment = gimp_unit_adjustment_new ();
+  GimpUnitEntry           *entry      = GIMP_UNIT_ENTRY (gimp_unit_entry_new ()); 
   GimpUnitEntry           *other_entry;
   GtkWidget               *label;
   guint                   bottom;
@@ -121,6 +122,8 @@ gimp_unit_entries_add_entry (GimpUnitEntries *entries,
                           top_attach,
                           bottom_attach;
 
+  gimp_unit_entry_set_adjustment (entry, adjustment);                        
+
   /* retrieve bottom row of table */
   gtk_table_get_size (GTK_TABLE (gimp_unit_entries_get_table (entries)), &bottom, NULL);
 
@@ -369,27 +372,22 @@ gdouble
 gimp_unit_entries_get_pixels (GimpUnitEntries *entries, 
                               const gchar     *id)
 {
-  return gimp_unit_entries_get_value_in_unit (entries, id, GIMP_UNIT_PIXEL);
+  GimpUnitEntry *entry;
+
+  entry = gimp_unit_entries_get_entry (entries, id);
+
+  return gimp_unit_entry_get_pixels (entry);
 }
 
 gdouble         
 gimp_unit_entries_get_nth_pixels (GimpUnitEntries *entries, 
                                   gint             index)
 {
-  return gimp_unit_entry_get_pixels (gimp_unit_entries_get_nth_entry (entries, index));
-}
+  GimpUnitEntry *entry;
 
-gdouble 
-gimp_unit_entries_get_value_in_unit (GimpUnitEntries *entries,
-                                     const gchar     *id, 
-                                     GimpUnit        unit)
-{
-  GimpUnitEntry *entry = gimp_unit_entries_get_entry (entries, id);
+  entry = gimp_unit_entries_get_nth_entry (entries, index);
 
-  if (entry != NULL)
-    return gimp_unit_entry_get_value_in_unit (entry, unit);
-  else
-    return -1;
+  return gimp_unit_entry_get_pixels (entry);
 }
 
 /* sets the unit of all entries */
@@ -397,14 +395,14 @@ void
 gimp_unit_entries_set_unit (GimpUnitEntries *entries, 
                             GimpUnit         unit)
 {
-  GimpUnitEntry *entry;
-  gint           i, count = gimp_unit_entries_get_entry_count (entries);
+  GimpUnitAdjustment *adj;
+  gint                i, count = gimp_unit_entries_get_entry_count (entries);
 
   /* iterate over list of entries */
   for (i = 0; i < count; i++) 
   {
-    entry = gimp_unit_entries_get_nth_entry (entries, i);
-    gimp_unit_entry_set_unit (entry, unit);
+    adj = gimp_unit_entries_get_nth_adjustment (entries, i);
+    gimp_unit_adjustment_set_unit (adj, unit);
   }
 }
 
@@ -413,14 +411,14 @@ void
 gimp_unit_entries_set_resolution (GimpUnitEntries *entries,
                                   gdouble          res)
 {
-  GimpUnitEntry *entry;
-  gint           i, count = gimp_unit_entries_get_entry_count (entries);
+  GimpUnitAdjustment *adj;
+  gint                i, count = gimp_unit_entries_get_entry_count (entries);
 
   /* iterate over list of entries */
   for (i = 0; i < count; i++) 
   {
-    entry = gimp_unit_entries_get_nth_entry (entries, i);
-    gimp_unit_entry_set_resolution (entry, res);
+    adj = gimp_unit_entries_get_nth_adjustment (entries, i);
+    gimp_unit_adjustment_set_resolution (adj, res);
   }
 }
 
@@ -437,7 +435,6 @@ gimp_unit_entries_set_mode (GimpUnitEntries   *entries,
   {
     entry = gimp_unit_entries_get_nth_entry (entries, i);
     gimp_unit_entry_set_mode (entry, mode);
-    gimp_unit_entry_set_resolution (entry, 1.0);  /* otherwise calculation is not correct */
   }
 }
 
@@ -502,11 +499,11 @@ gimp_unit_entries_set_pixels (GimpUnitEntries *entries,
                               const gchar     *id,
                               gdouble          value)
 {
-  GimpUnitEntry *entry;
+  GimpUnitAdjustment *adj;
 
-  entry = gimp_unit_entries_get_entry (entries, id);
+  adj = gimp_unit_entries_get_adjustment (entries, id);
 
-  gimp_unit_entry_set_value_in_unit (entry, value, GIMP_UNIT_PIXEL);
+  gimp_unit_adjustment_set_value_in_unit (adj, value, GIMP_UNIT_PIXEL);
 }               
                    
 void            
@@ -514,9 +511,31 @@ gimp_unit_entries_set_nth_pixels (GimpUnitEntries *entries,
                                   gint             index,
                                   gdouble          value)
 {
+  GimpUnitAdjustment *adj;
+
+  adj = gimp_unit_entries_get_nth_adjustment (entries, index);
+
+  gimp_unit_adjustment_set_value_in_unit (adj, value, GIMP_UNIT_PIXEL);
+}      
+
+GimpUnitAdjustment*  
+gimp_unit_entries_get_adjustment (GimpUnitEntries *entries,
+                                  const gchar     *id)
+{
   GimpUnitEntry *entry;
 
-  entry = gimp_unit_entries_get_nth_entry (entries, index);
+  entry = gimp_unit_entries_get_entry (entries, id);
+
+  return gimp_unit_entry_get_adjustment (entry);
+}
 
-  gimp_unit_entry_set_value_in_unit (entry, value, GIMP_UNIT_PIXEL);
-}                                
+GimpUnitAdjustment*  
+gimp_unit_entries_get_nth_adjustment  (GimpUnitEntries *entries,
+                                       gint             index)
+{
+  GimpUnitEntry *entry;
+  
+  entry = gimp_unit_entries_get_nth_entry (entries, index);
+  
+  return gimp_unit_entry_get_adjustment (entry);  
+}                       
diff --git a/libgimpwidgets/gimpunitentries.h b/libgimpwidgets/gimpunitentries.h
index 211e813..f90abc2 100644
--- a/libgimpwidgets/gimpunitentries.h
+++ b/libgimpwidgets/gimpunitentries.h
@@ -59,55 +59,57 @@ struct _GimpUnitEntriesClass
   GObjectClass parent_class;
 };
 
-GType           gimp_unit_entries_get_type              (void);
-GimpUnitEntries*gimp_unit_entries_new                   (void);
-
-GtkWidget*      gimp_unit_entries_add_entry             (GimpUnitEntries *entries, 
-                                                         const gchar     *id,
-                                                         const gchar     *label);
-void            gimp_unit_entries_add_preview_label     (GimpUnitEntries *entries, 
-                                                         GimpUnit         unit, 
-                                                         const char      *id1, 
-                                                         const char      *id2);
-GtkWidget*      gimp_unit_entries_add_chain_button      (GimpUnitEntries *entries,
-                                                         const char      *id1, 
-                                                         const char      *id2);
-
-GimpUnitEntry*  gimp_unit_entries_get_entry             (GimpUnitEntries *entries, 
-                                                         const gchar     *id);
-GimpUnitEntry*  gimp_unit_entries_get_nth_entry         (GimpUnitEntries *entries, 
-                                                         gint             index);
-gint            gimp_unit_entries_get_entry_count       (GimpUnitEntries *entries);
-gdouble         gimp_unit_entries_get_pixels            (GimpUnitEntries *entries, 
-                                                         const gchar     *id);
-gdouble         gimp_unit_entries_get_nth_pixels        (GimpUnitEntries *entries, 
-                                                         gint             index);                            
                                 
-GtkWidget*      gimp_unit_entries_get_table             (GimpUnitEntries *entries);                          
                                   
-gdouble         gimp_unit_entries_get_value_in_unit     (GimpUnitEntries *entries,
-                                                         const gchar     *id,
-                                                         GimpUnit         unit);
-GtkWidget*      gimp_unit_entries_get_chain_button      (GimpUnitEntries *entries);                          
                                    
-
-void            gimp_unit_entries_set_unit              (GimpUnitEntries *entries, 
-                                                         GimpUnit         unit);
-void            gimp_unit_entries_set_resolution        (GimpUnitEntries *entries, 
-                                                         gdouble          res);
-void            gimp_unit_entries_set_mode              (GimpUnitEntries *entries, 
-                                                         GimpUnitEntryMode mode);
-void            gimp_unit_entries_set_activates_default (GimpUnitEntries *entries, 
-                                                         gboolean         setting);
-void            gimp_unit_entries_set_bounds            (GimpUnitEntries *entries, 
-                                                         GimpUnit         unit, 
-                                                         gdouble          upper, 
-                                                         gdouble          lower);
-void            gimp_unit_entries_set_pixels            (GimpUnitEntries *entries, 
-                                                         const gchar     *id,
-                                                         gdouble          value);
-void            gimp_unit_entries_set_nth_pixels        (GimpUnitEntries *entries, 
-                                                         gint             index,
-                                                         gdouble          value);                            
                                                                                              
-
-void            gimp_unit_entries_grab_focus            (GimpUnitEntries *entries);
+GType                gimp_unit_entries_get_type              (void);
+GimpUnitEntries*     gimp_unit_entries_new                   (void);
+
+GtkWidget*           gimp_unit_entries_add_entry             (GimpUnitEntries *entries, 
+                                                              const gchar     *id,
+                                                              const gchar     *label);
+void                 gimp_unit_entries_add_preview_label     (GimpUnitEntries *entries, 
+                                                              GimpUnit         unit, 
+                                                              const gchar     *id1, 
+                                                              const gchar     *id2);
+GtkWidget*           gimp_unit_entries_add_chain_button      (GimpUnitEntries *entries,
+                                                              const gchar     *id1, 
+                                                              const gchar     *id2);
+
+GimpUnitAdjustment*  gimp_unit_entries_get_adjustment        (GimpUnitEntries *entries,
+                                                              const gchar     *id);
+GimpUnitAdjustment*  gimp_unit_entries_get_nth_adjustment    (GimpUnitEntries *entries,
+                                                              gint             index);
+GimpUnitEntry*       gimp_unit_entries_get_entry             (GimpUnitEntries *entries, 
+                                                              const gchar     *id);
+GimpUnitEntry*       gimp_unit_entries_get_nth_entry         (GimpUnitEntries *entries, 
+                                                              gint             index);
+gint                 gimp_unit_entries_get_entry_count       (GimpUnitEntries *entries);
+gdouble              gimp_unit_entries_get_pixels            (GimpUnitEntries *entries, 
+                                                              const gchar     *id);
+gdouble              gimp_unit_entries_get_nth_pixels        (GimpUnitEntries *entries, 
+                                                              gint             index);                       
                                      
+GtkWidget*           gimp_unit_entries_get_table             (GimpUnitEntries *entries);                     
                                        
+
+GtkWidget*           gimp_unit_entries_get_chain_button      (GimpUnitEntries *entries);                     
                                         
+
+void                 gimp_unit_entries_set_unit              (GimpUnitEntries *entries, 
+                                                              GimpUnit         unit);
+void                 gimp_unit_entries_set_resolution        (GimpUnitEntries *entries, 
+                                                              gdouble          res);
+void                 gimp_unit_entries_set_mode              (GimpUnitEntries *entries, 
+                                                              GimpUnitEntryMode mode);
+void                 gimp_unit_entries_set_activates_default (GimpUnitEntries *entries, 
+                                                              gboolean         setting);
+void                 gimp_unit_entries_set_bounds            (GimpUnitEntries *entries, 
+                                                              GimpUnit         unit, 
+                                                              gdouble          upper, 
+                                                              gdouble          lower);
+void                 gimp_unit_entries_set_pixels            (GimpUnitEntries *entries, 
+                                                              const gchar     *id,
+                                                              gdouble          value);
+void                 gimp_unit_entries_set_nth_pixels        (GimpUnitEntries *entries, 
+                                                              gint             index,
+                                                              gdouble          value);                       
                                                                                                   
+
+void                 gimp_unit_entries_grab_focus            (GimpUnitEntries *entries);
 
 G_END_DECLS
 
diff --git a/libgimpwidgets/gimpunitentry.c b/libgimpwidgets/gimpunitentry.c
index 4c33408..f1cf40b 100644
--- a/libgimpwidgets/gimpunitentry.c
+++ b/libgimpwidgets/gimpunitentry.c
@@ -102,9 +102,9 @@ gimp_unit_entry_init (GimpUnitEntry *unit_entry)
   private = GIMP_UNIT_ENTRY_GET_PRIVATE (unit_entry);                                                   
 
   /* create and set our adjustment subclass */
-  private->unit_adjustment = gimp_unit_adjustment_new ();
+  /*private->unit_adjustment = gimp_unit_adjustment_new ();
   gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (unit_entry), 
-                                  GTK_ADJUSTMENT  (private->unit_adjustment));
+                                  GTK_ADJUSTMENT  (private->unit_adjustment));*/
 
   /* some default values */
   private->dont_update_text = FALSE;  
@@ -114,10 +114,6 @@ gimp_unit_entry_init (GimpUnitEntry *unit_entry)
 
   /* connect signals */
   g_signal_connect (&unit_entry->parent_instance, 
-                    "output",
-                    G_CALLBACK(gimp_unit_entry_output), 
-                    (gpointer) gimp_unit_entry_get_adjustment (unit_entry));
-  g_signal_connect (&unit_entry->parent_instance, 
                     "input",
                     G_CALLBACK(gimp_unit_entry_input), 
                     (gpointer) unit_entry);
@@ -150,11 +146,31 @@ gimp_unit_entry_new (void)
 GimpUnitAdjustment*
 gimp_unit_entry_get_adjustment (GimpUnitEntry *entry)
 {
-  GimpUnitEntryPrivate *private = GIMP_UNIT_ENTRY_GET_PRIVATE (entry);
+  GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (entry));
+  
+  if (!GIMP_IS_UNIT_ADJUSTMENT (adjustment))
+  {
+    g_warning ("gimp_unit_entry_get_adjustment: GimpUnitEntry has no or invalid adjustment. "
+               "Create GimpUnitAdjustment instance and set via gimp_unit_entry_set_adjustment() first.");
+    return NULL;
+  }
 
-  return private->unit_adjustment;
+  return GIMP_UNIT_ADJUSTMENT (adjustment);
 }
 
+void                  
+gimp_unit_entry_set_adjustment  (GimpUnitEntry      *entry,
+                                 GimpUnitAdjustment *adjustment)
+{
+  gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (entry), 
+                                  GTK_ADJUSTMENT  (adjustment));
+
+  g_signal_connect (GTK_SPIN_BUTTON (entry), 
+                    "output",
+                    G_CALLBACK(gimp_unit_entry_output), 
+                    (gpointer) adjustment);                                
+}        
+
 /* connect to another entry */
 void 
 gimp_unit_entry_connect (GimpUnitEntry *entry, 
@@ -382,66 +398,13 @@ gimp_unit_entry_menu_item      (GtkWidget *menu_item,
   gimp_unit_adjustment_set_unit (adj, unit);
 }                        
 
-/* convenience getters/setters */
-void 
-gimp_unit_entry_set_unit (GimpUnitEntry *entry, 
-                          GimpUnit       unit)
-{
-  GimpUnitAdjustment *adj = gimp_unit_entry_get_adjustment (entry);
-  gimp_unit_adjustment_set_unit (adj, unit);
-}
-
-void 
-gimp_unit_entry_set_resolution (GimpUnitEntry *entry, 
-                                gdouble        resolution)
-{
-  GimpUnitAdjustment *adj = gimp_unit_entry_get_adjustment (entry);
-  gimp_unit_adjustment_set_resolution (adj, resolution);
-}
-
-void 
-gimp_unit_entry_set_value (GimpUnitEntry *entry, 
-                           gdouble        value)
-{
-  GimpUnitAdjustment *adj = gimp_unit_entry_get_adjustment (entry);
-  gimp_unit_adjustment_set_value (adj, value);
-}
-
-gdouble 
-gimp_unit_entry_get_value (GimpUnitEntry *entry)
-{
-  GimpUnitAdjustment *adj = gimp_unit_entry_get_adjustment (entry);
-  return gimp_unit_adjustment_get_value (adj);
-}
-
+/* convenience getters/setters */                         
 gdouble
 gimp_unit_entry_get_pixels (GimpUnitEntry *entry)
 {
-  return gimp_unit_entry_get_value_in_unit (entry, GIMP_UNIT_PIXEL);
-}
-
-gdouble
-gimp_unit_entry_get_value_in_unit (GimpUnitEntry *entry, 
-                                   GimpUnit       unit)
-{
   GimpUnitAdjustment *adj = gimp_unit_entry_get_adjustment (entry);
-  return gimp_unit_adjustment_get_value_in_unit (adj, unit);
-}
 
-void 
-gimp_unit_entry_set_value_in_unit (GimpUnitEntry *entry,
-                                   gdouble        value, 
-                                   GimpUnit       unit)
-{
-  GimpUnitAdjustment *adj = gimp_unit_entry_get_adjustment (entry);
-  gimp_unit_adjustment_set_value_in_unit (adj, value, unit);
-}
-
-GimpUnit 
-gimp_unit_entry_get_unit (GimpUnitEntry *entry)
-{
-  GimpUnitAdjustment *adj = gimp_unit_entry_get_adjustment (entry);
-  return gimp_unit_adjustment_get_unit (adj);
+  return gimp_unit_adjustment_get_value_in_unit (adj, GIMP_UNIT_PIXEL);
 }
 
 void
@@ -458,7 +421,8 @@ void
 gimp_unit_entry_set_pixels (GimpUnitEntry      *entry,
                             gdouble             value)
 {
-  gimp_unit_entry_set_value_in_unit (entry, value, GIMP_UNIT_PIXEL);
+  GimpUnitAdjustment *adj = gimp_unit_entry_get_adjustment (entry);
+  gimp_unit_adjustment_set_value_in_unit (adj, value, GIMP_UNIT_PIXEL);
 }                           
 
 void
@@ -466,8 +430,15 @@ gimp_unit_entry_set_mode (GimpUnitEntry     *entry,
                           GimpUnitEntryMode  mode)
 {
   GimpUnitEntryPrivate *private = GIMP_UNIT_ENTRY_GET_PRIVATE (entry);
+  GimpUnitAdjustment   *adj     = gimp_unit_entry_get_adjustment (entry);
 
   private->mode = mode;
+
+  /* set resolution in resolution mode to 1, otherwise calculation is not correct */
+  if (mode == GIMP_UNIT_ENTRY_MODE_RESOLUTION)
+  {
+    gimp_unit_adjustment_set_resolution (adj, 1.0);
+  }
 }
 
 /* get string in format "value unit" */
diff --git a/libgimpwidgets/gimpunitentry.h b/libgimpwidgets/gimpunitentry.h
index 50d90f3..aeca35a 100644
--- a/libgimpwidgets/gimpunitentry.h
+++ b/libgimpwidgets/gimpunitentry.h
@@ -60,27 +60,16 @@ GType                 gimp_unit_entry_get_type          (void);
 GtkWidget *           gimp_unit_entry_new               (void);
 
 GimpUnitAdjustment *  gimp_unit_entry_get_adjustment    (GimpUnitEntry      *entry);
-gdouble               gimp_unit_entry_get_value         (GimpUnitEntry      *entry);
 gdouble               gimp_unit_entry_get_pixels        (GimpUnitEntry      *entry);
-gdouble               gimp_unit_entry_get_value_in_unit (GimpUnitEntry      *entry, 
-                                                         GimpUnit            unit);
-GimpUnit              gimp_unit_entry_get_unit          (GimpUnitEntry      *entry);
 
-void                  gimp_unit_entry_set_bounds        (GimpUnitEntry      *entry, 
-                                                         GimpUnit            unit, 
-                                                         gdouble             upper, 
-                                                         gdouble             lower);
+void                  gimp_unit_entry_set_adjustment    (GimpUnitEntry      *entry,
+                                                         GimpUnitAdjustment *adjustment);
+void                  gimp_unit_entry_set_bounds        (GimpUnitEntry *entry, 
+                                                         GimpUnit       unit, 
+                                                         gdouble        lower,
+                                                         gdouble        upper);
 void                  gimp_unit_entry_set_mode          (GimpUnitEntry      *entry, 
                                                          GimpUnitEntryMode   mode);
-void                  gimp_unit_entry_set_unit          (GimpUnitEntry      *entry, 
-                                                         GimpUnit           unit);
-void                  gimp_unit_entry_set_resolution    (GimpUnitEntry      *entry,
-                                                         gdouble             resolution);
-void                  gimp_unit_entry_set_value         (GimpUnitEntry      *entry, 
-                                                         gdouble             value);
-void                  gimp_unit_entry_set_value_in_unit (GimpUnitEntry      *entry, 
-                                                         gdouble             value, 
-                                                         GimpUnit            unit);
 void                  gimp_unit_entry_set_pixels        (GimpUnitEntry      *entry,
                                                          gdouble             value);
                                                          
diff --git a/libgimpwidgets/gimpwidgets.def b/libgimpwidgets/gimpwidgets.def
index 7864df9..111ce7d 100644
--- a/libgimpwidgets/gimpwidgets.def
+++ b/libgimpwidgets/gimpwidgets.def
@@ -358,7 +358,7 @@ EXPORTS
        gimp_toggle_button_sensitive_update
        gimp_toggle_button_update
        gimp_uint_adjustment_update
-       gimp_unit_adjustment_connect
+       gimp_unit_adjustment_follow_unit_of
        gimp_unit_adjustment_get_resolution
        gimp_unit_adjustment_get_type
        gimp_unit_adjustment_get_unit
@@ -378,15 +378,16 @@ EXPORTS
        gimp_unit_entries_add_chain_button
        gimp_unit_entries_add_entry
        gimp_unit_entries_add_preview_label
+       gimp_unit_entries_get_adjustment
        gimp_unit_entries_get_chain_button
        gimp_unit_entries_get_entry
        gimp_unit_entries_get_entry_count
+       gimp_unit_entries_get_nth_adjustment
        gimp_unit_entries_get_nth_entry
        gimp_unit_entries_get_nth_pixels
        gimp_unit_entries_get_pixels
        gimp_unit_entries_get_table
        gimp_unit_entries_get_type
-       gimp_unit_entries_get_value_in_unit
        gimp_unit_entries_grab_focus
        gimp_unit_entries_new
        gimp_unit_entries_set_activates_default
@@ -400,17 +401,11 @@ EXPORTS
        gimp_unit_entry_get_adjustment
        gimp_unit_entry_get_pixels
        gimp_unit_entry_get_type
-       gimp_unit_entry_get_unit
-       gimp_unit_entry_get_value
-       gimp_unit_entry_get_value_in_unit
        gimp_unit_entry_new
+       gimp_unit_entry_set_adjustment
        gimp_unit_entry_set_bounds
        gimp_unit_entry_set_mode
        gimp_unit_entry_set_pixels
-       gimp_unit_entry_set_resolution
-       gimp_unit_entry_set_unit
-       gimp_unit_entry_set_value
-       gimp_unit_entry_set_value_in_unit
        gimp_unit_entry_to_string
        gimp_unit_entry_to_string_in_unit
        gimp_unit_menu_get_pixel_digits
diff --git a/libgimpwidgets/test-unitentry.c b/libgimpwidgets/test-unitentry.c
index f2be515..39d1d54 100644
--- a/libgimpwidgets/test-unitentry.c
+++ b/libgimpwidgets/test-unitentry.c
@@ -20,15 +20,23 @@
 
 typedef struct
 {
-  GimpUnitEntry *entry1, *entry2;
+  GimpUnitEntry      *entry1, *entry2;
+  GimpUnitAdjustment *adj1, *adj2;
 } GimpTestFixture;
 
 static void
 gimp_test_unitentry_setup (GimpTestFixture *fixture,
                            gconstpointer    data)
 {
+
   fixture->entry1 = GIMP_UNIT_ENTRY (gimp_unit_entry_new ());
   fixture->entry2 = GIMP_UNIT_ENTRY (gimp_unit_entry_new ());
+
+  fixture->adj1 = gimp_unit_adjustment_new ();
+  gimp_unit_entry_set_adjustment (fixture->entry1, fixture->adj1);
+  fixture->adj2 = gimp_unit_adjustment_new ();
+  gimp_unit_entry_set_adjustment (fixture->entry2, fixture->adj2);
+
   gimp_unit_entry_connect (fixture->entry1, fixture->entry2);
   gimp_unit_entry_connect (fixture->entry2, fixture->entry1);
 }
@@ -56,8 +64,8 @@ parse (GimpTestFixture *f,
 {
   gtk_entry_set_text (GTK_ENTRY (f->entry1), "10 px");
 
-  g_assert (gimp_unit_entry_get_value_in_unit (f->entry1, GIMP_UNIT_PIXEL) == 10.0);
-  g_assert (gimp_unit_entry_get_unit          (f->entry1) == GIMP_UNIT_PIXEL);
+  g_assert (gimp_unit_entry_get_pixels      (f->entry1) == 10.0);
+  g_assert (gimp_unit_adjustment_get_unit   (f->adj1)   == GIMP_UNIT_PIXEL);
 }
 
 /**
@@ -70,12 +78,12 @@ static void
 parse_without_unit (GimpTestFixture *f,
                     gconstpointer    data)
 {
-  gimp_unit_entry_set_unit (f->entry1, GIMP_UNIT_PIXEL);
+  gimp_unit_adjustment_set_unit (f->adj1, GIMP_UNIT_PIXEL);
 
   gtk_entry_set_text (GTK_ENTRY (f->entry1), "10");
 
-  g_assert (gimp_unit_entry_get_value_in_unit (f->entry1, GIMP_UNIT_PIXEL) == 10.0);
-  g_assert (gimp_unit_entry_get_unit          (f->entry1) == GIMP_UNIT_PIXEL);
+  g_assert (gimp_unit_entry_get_pixels      (f->entry1) == 10.0);
+  g_assert (gimp_unit_adjustment_get_unit   (f->adj1)   == GIMP_UNIT_PIXEL);
 }
 
 /**
@@ -87,12 +95,12 @@ static void
 parse_addition_without_unit (GimpTestFixture *f,
                              gconstpointer    data)
 {
-  gimp_unit_entry_set_unit (f->entry1, GIMP_UNIT_INCH);
+  gimp_unit_adjustment_set_unit (f->adj1, GIMP_UNIT_INCH);
 
   gtk_entry_set_text (GTK_ENTRY (f->entry1), "10 in + 20");
 
-  g_assert (gimp_unit_entry_get_value (f->entry1) == 30.0);
-  g_assert (gimp_unit_entry_get_unit  (f->entry1) == GIMP_UNIT_INCH);
+  g_assert (gimp_unit_adjustment_get_value (f->adj1) == 30.0);
+  g_assert (gimp_unit_adjustment_get_unit  (f->adj1) == GIMP_UNIT_INCH);
 }
 
 /**
@@ -105,12 +113,12 @@ static void
 parse_different_units (GimpTestFixture *f,
                        gconstpointer    data)
 {
-  gimp_unit_entry_set_resolution (f->entry1, 72);
+  gimp_unit_adjustment_set_resolution (f->adj1, 72);
 
   gtk_entry_set_text (GTK_ENTRY (f->entry1), "10 in + 72 px");
 
-  g_assert (gimp_unit_entry_get_value_in_unit (f->entry1, GIMP_UNIT_INCH) == 11.0);
-  g_assert (gimp_unit_entry_get_unit          (f->entry1) == GIMP_UNIT_INCH);
+  g_assert (gimp_unit_adjustment_get_value (f->adj1) == 11.0);
+  g_assert (gimp_unit_adjustment_get_unit  (f->adj1) == GIMP_UNIT_INCH);
 }
 
 /**
@@ -123,40 +131,16 @@ static void
 change_units (GimpTestFixture *f,
               gconstpointer    data)
 {
-  gimp_unit_entry_set_resolution (f->entry1, 72);
-  gimp_unit_entry_set_resolution (f->entry2, 72);
-  gimp_unit_entry_set_unit       (f->entry1, GIMP_UNIT_PIXEL);
-  gimp_unit_entry_set_unit       (f->entry2, GIMP_UNIT_PIXEL);
-  gimp_unit_entry_set_value      (f->entry2, 72);
+  gimp_unit_adjustment_set_resolution (f->adj1, 72);
+  gimp_unit_adjustment_set_resolution (f->adj2, 72);
+  gimp_unit_adjustment_set_unit       (f->adj1, GIMP_UNIT_PIXEL);
+  gimp_unit_adjustment_set_unit       (f->adj2, GIMP_UNIT_PIXEL);
+  gimp_unit_adjustment_set_value      (f->adj2, 72);
 
   gtk_entry_set_text (GTK_ENTRY (f->entry1), "10 in");
 
-  g_assert (gimp_unit_entry_get_value         (f->entry2) == 1.0);
-  g_assert (gimp_unit_entry_get_unit          (f->entry2) == GIMP_UNIT_INCH);
-}
-
-/**
- * parse_addition_to_default_unit
- *
- * A term entered in the form "10 + 5mm" should be treated as "10 in + 5 mm"
- * (if default unit is inch)
- * FIXME: doesn't work right now because GimpEevl internally combines
- * "10 + 5 mm" to 15 mm so we are not informed of the single "10 " and
- * we can not apply our default unit .
- * In other words: unit resolver callback is not called for the "10 " but
- * instead directly with "15 mm"
- **/
-static void
-parse_addition_to_default_unit (GimpTestFixture *f,
-                                gconstpointer    data)
-{
-  gimp_unit_entry_set_resolution (f->entry1, 72);
-  gimp_unit_entry_set_unit       (f->entry1, GIMP_UNIT_INCH);
-
-  gtk_entry_set_text (GTK_ENTRY (f->entry1), "10 + 72 px");
-
-  g_assert (gimp_unit_entry_get_value_in_unit (f->entry1, GIMP_UNIT_INCH) == 11.0);
-  g_assert (gimp_unit_entry_get_unit          (f->entry1) == GIMP_UNIT_INCH);
+  g_assert (gimp_unit_adjustment_get_value (f->adj2) == 1.0);
+  g_assert (gimp_unit_adjustment_get_unit  (f->adj2) == GIMP_UNIT_INCH);
 }
 
 /**
@@ -168,12 +152,12 @@ static void
 parse_multiplication (GimpTestFixture *f,
                       gconstpointer    data)
 {
-  gimp_unit_entry_set_unit (f->entry1, GIMP_UNIT_INCH);
+  gimp_unit_adjustment_set_unit (f->adj1, GIMP_UNIT_INCH);
 
   gtk_entry_set_text (GTK_ENTRY (f->entry1), "10 in * 10");
 
-  g_assert (gimp_unit_entry_get_value (f->entry1) == 100.0);
-  g_assert (gimp_unit_entry_get_unit  (f->entry1) == GIMP_UNIT_INCH);
+  g_assert (gimp_unit_adjustment_get_value (f->adj1) == 100.0);
+  g_assert (gimp_unit_adjustment_get_unit  (f->adj1) == GIMP_UNIT_INCH);
 }
 
 /**
@@ -186,13 +170,13 @@ static void
 parse_multidim_multiplication (GimpTestFixture *f,
                                gconstpointer    data)
 {
-  gimp_unit_entry_set_unit  (f->entry1, GIMP_UNIT_INCH);
-  gimp_unit_entry_set_value (f->entry1, 10.0);
+  gimp_unit_adjustment_set_unit  (f->adj1, GIMP_UNIT_INCH);
+  gimp_unit_adjustment_set_value (f->adj1, 10.0);
 
   gtk_entry_set_text (GTK_ENTRY (f->entry1), "10 in * 10 px");
 
-  g_assert (gimp_unit_entry_get_value (f->entry1) == 10.0);
-  g_assert (gimp_unit_entry_get_unit  (f->entry1) == GIMP_UNIT_INCH);
+  g_assert (gimp_unit_adjustment_get_value (f->adj1) == 10.0);
+  g_assert (gimp_unit_adjustment_get_unit  (f->adj1) == GIMP_UNIT_INCH);
 }
 
 int main (int   argc,
@@ -208,7 +192,6 @@ int main (int   argc,
     ADD_TEST (parse_addition_without_unit)
     ADD_TEST (parse_different_units);
     ADD_TEST (change_units);
-    //ADD_TEST (parse_addition_to_default_unit);
     ADD_TEST (parse_multiplication);
     ADD_TEST (parse_multidim_multiplication)
     
diff --git a/libgimpwidgets/test-unitentrygui.c b/libgimpwidgets/test-unitentrygui.c
index 077dcda..d643d6f 100644
--- a/libgimpwidgets/test-unitentrygui.c
+++ b/libgimpwidgets/test-unitentrygui.c
@@ -63,8 +63,8 @@ create_interface(void)
   /* set some default values */
   a = gimp_unit_entries_get_entry (entries, "xres");
   b = gimp_unit_entries_get_entry (entries, "yres");
-  gimp_unit_entry_set_value (a, 72);
-  gimp_unit_entry_set_value (b, 72);
+  gimp_unit_adjustment_set_value (gimp_unit_entry_get_adjustment (a), 72);
+  gimp_unit_adjustment_set_value (gimp_unit_entry_get_adjustment (b), 72);
   gimp_unit_entry_set_mode (a, GIMP_UNIT_ENTRY_MODE_RESOLUTION);
   gimp_unit_entry_set_mode (b, GIMP_UNIT_ENTRY_MODE_RESOLUTION);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]