[gimp/soc-2011-gimpunitentry] GimpUnitEntry: first part of refactoring following code review



commit 577a85ebc2a9048ff33082b4f915ce2f53d1b289
Author: Enrico SchroÌder <enni schroeder gmail com>
Date:   Wed Aug 10 13:04:36 2011 +0200

    GimpUnitEntry: first part of refactoring following code review

 .gitignore                                |    3 -
 app/dialogs/layer-options-dialog.c        |    8 +-
 app/dialogs/offset-dialog.c               |   17 +-
 app/dialogs/preferences-dialog.c          |  137 ++++++++---------
 app/dialogs/resize-dialog.c               |   40 +++---
 app/dialogs/resolution-calibrate-dialog.c |   21 +--
 app/dialogs/resolution-calibrate-dialog.h |    4 +-
 app/tools/gimprotatetool.c                |    7 +-
 app/tools/gimprotatetool.h                |    2 +-
 app/widgets/gimpgrideditor.c              |    8 +-
 app/widgets/gimptemplateeditor.c          |   41 ++---
 libgimpwidgets/.gitignore                 |    2 +
 libgimpwidgets/Makefile.am                |    5 +-
 libgimpwidgets/gimppropwidgets.c          |    6 +-
 libgimpwidgets/gimpunitadjustment.c       |  217 ++++++++++++++------------
 libgimpwidgets/gimpunitadjustment.h       |   55 +++----
 libgimpwidgets/gimpunitentries.c          |  194 +++++++++++++-----------
 libgimpwidgets/gimpunitentries.h          |   17 +--
 libgimpwidgets/gimpunitentry.c            |  238 ++++++++++++++++++----------
 libgimpwidgets/gimpunitentry.h            |   21 +--
 libgimpwidgets/gimpunitparser.c           |   43 +++---
 libgimpwidgets/gimpunitparser.h           |    2 +-
 libgimpwidgets/gimpwidgets.def            |    5 +-
 libgimpwidgets/test-unitentrygui.c        |   12 +-
 24 files changed, 579 insertions(+), 526 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 98b3fb5..c5269c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,6 +46,3 @@
 /stamp-h
 /stamp-h.in
 /stamp-h1
-
-/libgimpwidgets/test-unitentry
-/libgimpwidgets/test-unitentrygui
\ No newline at end of file
diff --git a/app/dialogs/layer-options-dialog.c b/app/dialogs/layer-options-dialog.c
index e7227da..9959c0a 100644
--- a/app/dialogs/layer-options-dialog.c
+++ b/app/dialogs/layer-options-dialog.c
@@ -134,12 +134,12 @@ layer_options_dialog_new (GimpImage    *image,
 
       gimp_image_get_resolution (image, &xres, &yres);
 
-      /* UnitEntry */
+      /* the size unit-entries */
       options->unit_entries = GIMP_UNIT_ENTRIES (gimp_unit_entries_new ());
-      width_entry = gimp_unit_entries_add_entry_defaults  (options->unit_entries, "width", _("Width:"));
-      height_entry = gimp_unit_entries_add_entry_defaults (options->unit_entries, "height", _("Height:"));
+      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_entry_set_unit        (GIMP_UNIT_ENTRY (width_entry), GIMP_UNIT_PIXEL);
+      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);
diff --git a/app/dialogs/offset-dialog.c b/app/dialogs/offset-dialog.c
index 2382f5a..2cca48a 100644
--- a/app/dialogs/offset-dialog.c
+++ b/app/dialogs/offset-dialog.c
@@ -49,14 +49,14 @@
 
 typedef struct
 {
-  GimpContext    *context;
+  GimpContext     *context;
 
-  GtkWidget      *dialog;
-  GObject        *offset_entries;
+  GtkWidget       *dialog;
+  GimpUnitEntries *offset_entries;
 
-  GimpOffsetType  fill_type;
+  GimpOffsetType   fill_type;
 
-  GimpImage      *image;
+  GimpImage       *image;
 } OffsetDialog;
 
 
@@ -160,11 +160,10 @@ offset_dialog_new (GimpDrawable *drawable,
   gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
   gtk_widget_show (vbox);
 
-  dialog->offset_entries = gimp_unit_entries_new ();
-  entries = GIMP_UNIT_ENTRIES (dialog->offset_entries);
+  dialog->offset_entries = entries = gimp_unit_entries_new ();
   
-  gimp_unit_entries_add_entry_defaults (entries, GIMP_UNIT_ENTRIES_OFFSET_X, _("X:"));
-  gimp_unit_entries_add_entry_defaults (entries, GIMP_UNIT_ENTRIES_OFFSET_Y, _("X:"));
+  gimp_unit_entries_add_entry (entries, GIMP_UNIT_ENTRIES_OFFSET_X, _("X:"));
+  gimp_unit_entries_add_entry (entries, GIMP_UNIT_ENTRIES_OFFSET_Y, _("X:"));
 
   gtk_box_pack_start (GTK_BOX (vbox), gimp_unit_entries_get_table (entries), FALSE, FALSE, 0);
 
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 890e7ec..a4f67be 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -73,52 +73,52 @@
 
 /*  preferences local functions  */
 
-static GtkWidget * prefs_dialog_new               (Gimp       *gimp,
-                                                   GimpConfig *config);
-static void        prefs_config_notify            (GObject    *config,
-                                                   GParamSpec *param_spec,
-                                                   GObject    *config_copy);
-static void        prefs_config_copy_notify       (GObject    *config_copy,
-                                                   GParamSpec *param_spec,
-                                                   GObject    *config);
-static void        prefs_response                 (GtkWidget  *widget,
-                                                   gint        response_id,
-                                                   GtkWidget  *dialog);
-
-static void        prefs_message                  (GtkMessageType  type,
-                                                   gboolean        destroy,
-                                                   const gchar    *message);
-
-static void   prefs_notebook_page_callback        (GtkNotebook      *notebook,
-                                                   gpointer          page,
-                                                   guint             page_num,
-                                                   GtkTreeSelection *sel);
-static void   prefs_resolution_source_callback    (GtkWidget  *widget,
-                                                   GObject    *config);
-static void   prefs_resolution_calibrate_callback (GtkWidget  *widget,
-                                                   GObject    *entries);
-static void   prefs_input_devices_dialog          (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_keyboard_shortcuts_dialog     (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_menus_save_callback           (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_menus_clear_callback          (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_menus_remove_callback         (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_session_save_callback         (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_session_clear_callback        (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_devices_save_callback         (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_devices_clear_callback        (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_tool_options_save_callback    (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_tool_options_clear_callback   (GtkWidget  *widget,
-                                                   Gimp       *gimp);
+static GtkWidget * prefs_dialog_new               (Gimp               *gimp,
+                                                   GimpConfig         *config);
+static void   prefs_config_notify                 (GObject            *config,
+                                                   GParamSpec         *param_spec,
+                                                   GObject            *config_copy);
+static void   prefs_config_copy_notify            (GObject            *config_copy,
+                                                   GParamSpec         *param_spec,
+                                                   GObject            *config);
+static void   prefs_response                      (GtkWidget          *widget,
+                                                   gint                response_id,
+                                                   GtkWidget          *dialog);
+
+static void   prefs_message                       (GtkMessageType      type,
+                                                   gboolean            destroy,
+                                                   const gchar        *message);
+
+static void   prefs_notebook_page_callback        (GtkNotebook        *notebook,
+                                                   gpointer            page,
+                                                   guint               page_num,
+                                                   GtkTreeSelection   *sel);
+static void   prefs_resolution_source_callback    (GtkWidget          *widget,
+                                                   GObject            *config);
+static void   prefs_resolution_calibrate_callback (GtkWidget          *widget,
+                                                   GimpUnitEntries    *entries);
+static void   prefs_input_devices_dialog          (GtkWidget          *widget,
+                                                   Gimp               *gimp);
+static void   prefs_keyboard_shortcuts_dialog     (GtkWidget          *widget,
+                                                   Gimp               *gimp);
+static void   prefs_menus_save_callback           (GtkWidget          *widget,
+                                                   Gimp               *gimp);
+static void   prefs_menus_clear_callback          (GtkWidget          *widget,
+                                                   Gimp               *gimp);
+static void   prefs_menus_remove_callback         (GtkWidget          *widget,
+                                                   Gimp               *gimp);
+static void   prefs_session_save_callback         (GtkWidget          *widget,
+                                                   Gimp               *gimp);
+static void   prefs_session_clear_callback        (GtkWidget          *widget,
+                                                   Gimp               *gimp);
+static void   prefs_devices_save_callback         (GtkWidget          *widget,
+                                                   Gimp               *gimp);
+static void   prefs_devices_clear_callback        (GtkWidget          *widget,
+                                                   Gimp               *gimp);
+static void   prefs_tool_options_save_callback    (GtkWidget          *widget,
+                                                   Gimp               *gimp);
+static void   prefs_tool_options_clear_callback   (GtkWidget          *widget,
+                                                   Gimp               *gimp);
 
 
 /*  private variables  */
@@ -453,18 +453,13 @@ prefs_resolution_source_callback (GtkWidget *widget,
     }
   else
     {
-      GimpUnitEntries *entries = GIMP_UNIT_ENTRIES (
-                                 g_object_get_data (G_OBJECT (widget),
-                                                    "monitor_resolution_sizeentry"));
+      GimpUnitEntries *entries = g_object_get_data (G_OBJECT (widget),
+                                                    "monitor_resolution_sizeentry");
 
       g_return_if_fail (GIMP_IS_UNIT_ENTRIES (entries));
 
-      xres = gimp_unit_entry_get_value_in_unit (
-              gimp_unit_entries_get_nth_entry (entries, 0),
-              GIMP_UNIT_PIXEL);
-      yres = gimp_unit_entry_get_value_in_unit (
-              gimp_unit_entries_get_nth_entry (entries, 1),
-              GIMP_UNIT_PIXEL);                                         
+      xres = gimp_unit_entries_get_pixels (entries, "monitor-xresolution");
+      yres = gimp_unit_entries_get_pixels (entries, "monitor-yresolution");
     }
 
   g_object_set (config,
@@ -475,15 +470,14 @@ prefs_resolution_source_callback (GtkWidget *widget,
 }
 
 static void
-prefs_resolution_calibrate_callback (GtkWidget *widget,
-                                     GObject   *unit_entries)
+prefs_resolution_calibrate_callback (GtkWidget         *widget,
+                                     GimpUnitEntries   *unit_entries)
 {
   GtkWidget *dialog;
   GtkWidget *notebook;
   GtkWidget *image;
 
-  dialog = gtk_widget_get_toplevel (gimp_unit_entries_get_table (
-                                    GIMP_UNIT_ENTRIES (unit_entries)));
+  dialog = gtk_widget_get_toplevel (gimp_unit_entries_get_table (unit_entries));
 
   notebook = g_object_get_data (G_OBJECT (dialog),   "notebook");
   image    = g_object_get_data (G_OBJECT (notebook), "image");
@@ -1383,7 +1377,7 @@ prefs_dialog_new (Gimp       *gimp,
   GSList            *group;
   GtkWidget         *editor;
   gint               i;
-  GimpUnitEntries *unit_entries;
+  GimpUnitEntries   *unit_entries;
 
   GObject           *object;
   GimpCoreConfig    *core_config;
@@ -2319,8 +2313,8 @@ prefs_dialog_new (Gimp       *gimp,
                                        "monitor-yresolution",
                                        _("Horizontal"),
                                        _("Vertical"),
-                                       NULL,
-                                       1.0, 1.0, /* FIXME: UnitEntry needs 1.0 as "resolution of resolution" , otherwise calculation is not correct */
+                                       NULL,  /* unit_property_name */
+                                       -1.0, -1.0, 
                                        TRUE));
     gimp_unit_entries_set_mode (unit_entries, GIMP_UNIT_ENTRY_MODE_RESOLUTION);
 
@@ -2328,9 +2322,10 @@ prefs_dialog_new (Gimp       *gimp,
 
   hbox = gtk_hbox_new (FALSE, 0);
 
-  gtk_box_pack_start (GTK_BOX (hbox), unit_entries->table, TRUE, TRUE, 24);
-  gtk_widget_show (unit_entries->table);
-  gtk_widget_set_sensitive (unit_entries->table, ! display_config->monitor_res_from_gdk);
+  gtk_box_pack_start (GTK_BOX (hbox), gimp_unit_entries_get_table (unit_entries), TRUE, TRUE, 24);
+  gtk_widget_show (gimp_unit_entries_get_table (unit_entries));
+  gtk_widget_set_sensitive (gimp_unit_entries_get_table (unit_entries),
+                           ! display_config->monitor_res_from_gdk);
 
   group = NULL;
 
@@ -2381,11 +2376,15 @@ prefs_dialog_new (Gimp       *gimp,
   gtk_widget_set_sensitive (calibrate_button,
                             ! display_config->monitor_res_from_gdk);
 
-  g_object_bind_property (button, "active",
-                          unit_entries->table,  "sensitive",
+  g_object_bind_property (button,                                      
+                          "active",
+                          gimp_unit_entries_get_table (unit_entries),  
+                          "sensitive",
                           G_BINDING_SYNC_CREATE);
-  g_object_bind_property (button,           "active",
-                          calibrate_button, "sensitive",
+  g_object_bind_property (button,           
+                          "active",
+                          calibrate_button, 
+                          "sensitive",
                           G_BINDING_SYNC_CREATE);
 
   g_signal_connect (calibrate_button, "clicked",
diff --git a/app/dialogs/resize-dialog.c b/app/dialogs/resize-dialog.c
index ec5143f..4d24374 100644
--- a/app/dialogs/resize-dialog.c
+++ b/app/dialogs/resize-dialog.c
@@ -90,21 +90,19 @@ resize_dialog_new (GimpViewable       *viewable,
                    GimpResizeCallback  callback,
                    gpointer            user_data)
 {
-  GtkWidget    *dialog;
-  GtkWidget    *main_vbox;
-  GtkWidget    *vbox;
-  GtkWidget    *abox;
-  GtkWidget    *frame;
-  GtkWidget    *button;
-  GtkWidget    *spinbutton;
-  GimpUnitEntries      *unit_entries;
-  GtkObject    *adjustment;
-  GdkPixbuf    *pixbuf;
-  ResizeDialog *private;
-  GimpImage    *image = NULL;
-  const gchar  *text  = NULL;
-  gint          width, height;
-  gdouble       xres, yres;
+  GtkWidget       *dialog;
+  GtkWidget       *main_vbox;
+  GtkWidget       *vbox;
+  GtkWidget       *abox;
+  GtkWidget       *frame;
+  GtkWidget       *button;
+  GimpUnitEntries *unit_entries;
+  GdkPixbuf       *pixbuf;
+  ResizeDialog    *private;
+  GimpImage       *image = NULL;
+  const gchar     *text  = NULL;
+  gint             width, height;
+  gdouble          xres, yres;
 
   g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
   g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
@@ -206,12 +204,12 @@ resize_dialog_new (GimpViewable       *viewable,
 
   /*  the offset unit-entries  */
   private->offset_unit_entries = unit_entries = GIMP_UNIT_ENTRIES (gimp_unit_entries_new ()); 
-  gimp_unit_entries_add_entry_defaults (unit_entries, 
-                                        GIMP_UNIT_ENTRIES_OFFSET_X,
-                                        _("X"));
-  gimp_unit_entries_add_entry_defaults (unit_entries, 
-                                        GIMP_UNIT_ENTRIES_OFFSET_Y,
-                                        _("Y"));                                                                                    
+  gimp_unit_entries_add_entry (unit_entries, 
+                               GIMP_UNIT_ENTRIES_OFFSET_X,
+                               _("X"));
+  gimp_unit_entries_add_entry (unit_entries, 
+                               GIMP_UNIT_ENTRIES_OFFSET_Y,
+                               _("Y"));                                                                                    
 
   gtk_box_pack_start (GTK_BOX (vbox), gimp_unit_entries_get_table (unit_entries), FALSE, FALSE, 0);
 
diff --git a/app/dialogs/resolution-calibrate-dialog.c b/app/dialogs/resolution-calibrate-dialog.c
index f85c772..03ce586 100644
--- a/app/dialogs/resolution-calibrate-dialog.c
+++ b/app/dialogs/resolution-calibrate-dialog.c
@@ -45,8 +45,8 @@ static gint                 ruler_height      = 1;
  * is connected to a #GimpSizeEntry handling the resolution to be set.
  **/
 void
-resolution_calibrate_dialog (GObject   *unit_entries,
-                             GdkPixbuf *pixbuf)
+resolution_calibrate_dialog (GimpUnitEntries   *resolution_entries,
+                             GdkPixbuf         *pixbuf)
 {
   GtkWidget           *dialog;
   GtkWidget           *table;
@@ -57,18 +57,15 @@ resolution_calibrate_dialog (GObject   *unit_entries,
   GdkScreen           *screen;
   GdkRectangle         rect;
   gint                 monitor;
-  GimpUnitEntries     *resolution_entries;
   GimpUnitEntry       *horizontal_entry, *vertical_entry;
 
-  g_return_if_fail (GIMP_IS_UNIT_ENTRIES (unit_entries));
+  g_return_if_fail (GIMP_IS_UNIT_ENTRIES (resolution_entries));
   g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));
 
   /*  this dialog can only exist once  */
   if (calibrate_entries)
     return;
 
-  resolution_entries = GIMP_UNIT_ENTRIES (unit_entries);
-
   dialog = gimp_dialog_new (_("Calibrate Monitor Resolution"),
                             "gimp-resolution-calibration",
                             gtk_widget_get_toplevel (gimp_unit_entries_get_table (resolution_entries)),
@@ -143,18 +140,18 @@ resolution_calibrate_dialog (GObject   *unit_entries,
   gtk_widget_show (hbox);
 
   calibrate_xres =
-    gimp_unit_entries_get_nth_pixels (resolution_entries, 0);
+    gimp_unit_entries_get_pixels (resolution_entries,  "monitor-xresolution");
   calibrate_yres =
-    gimp_unit_entries_get_nth_pixels (resolution_entries, 1);
+    gimp_unit_entries_get_pixels (resolution_entries,  "monitor-yresolution");
 
   calibrate_entries = 
     GIMP_UNIT_ENTRIES (gimp_unit_entries_new ()); 
   gimp_unit_entries_set_bounds (calibrate_entries, GIMP_UNIT_PIXEL, GIMP_MAX_IMAGE_SIZE, 1);
   
   horizontal_entry = 
-    GIMP_UNIT_ENTRY (gimp_unit_entries_add_entry_defaults (calibrate_entries, "horizontal", _("Horizontal")));  
+    GIMP_UNIT_ENTRY (gimp_unit_entries_add_entry (calibrate_entries, "horizontal", _("Horizontal")));  
   vertical_entry = 
-    GIMP_UNIT_ENTRY (gimp_unit_entries_add_entry_defaults (calibrate_entries, "vertical", _("Vertical")));                       
+    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_entry_set_pixels             (horizontal_entry, ruler_width);
@@ -187,8 +184,8 @@ resolution_calibrate_dialog (GObject   *unit_entries,
           gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain_button),
                                         FALSE);
 
-        gimp_unit_entries_set_nth_pixels (resolution_entries, 0, calibrate_xres);
-        gimp_unit_entries_set_nth_pixels (resolution_entries, 1, calibrate_yres);
+        gimp_unit_entries_set_pixels (resolution_entries, "monitor-xresolution", calibrate_xres);
+        gimp_unit_entries_set_pixels (resolution_entries, "monitor-xresolution", calibrate_yres);
       }
 
     default:
diff --git a/app/dialogs/resolution-calibrate-dialog.h b/app/dialogs/resolution-calibrate-dialog.h
index 7c9a721..5c183aa 100644
--- a/app/dialogs/resolution-calibrate-dialog.h
+++ b/app/dialogs/resolution-calibrate-dialog.h
@@ -19,8 +19,8 @@
 #define __RESOLUTION_CALIBRATE_DIALOG_H__
 
 
-void  resolution_calibrate_dialog (GObject    *resolution_entries,
-                                   GdkPixbuf  *pixbuf);
+void  resolution_calibrate_dialog (GimpUnitEntries    *resolution_entries,
+                                   GdkPixbuf          *pixbuf);
 
 
 #endif /* __RESOLUTION_CALIBRATE_DIALOG_H__ */
diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c
index d3cae2a..c08c448 100644
--- a/app/tools/gimprotatetool.c
+++ b/app/tools/gimprotatetool.c
@@ -200,10 +200,9 @@ gimp_rotate_tool_dialog (GimpTransformTool *tr_tool)
                     GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
   gtk_widget_show (scale);
 
-  rotate->unit_entries = gimp_unit_entries_new ();
-  entries = GIMP_UNIT_ENTRIES (rotate->unit_entries);
-  gimp_unit_entries_add_entry_defaults (entries, "center_x", _("Center X:"));
-  gimp_unit_entries_add_entry_defaults (entries, "center_y", _("Center Y:"));
+  rotate->unit_entries = entries = gimp_unit_entries_new ();
+  gimp_unit_entries_add_entry (entries, "center_x", _("Center X:"));
+  gimp_unit_entries_add_entry (entries, "center_y", _("Center Y:"));
   gimp_table_attach_aligned (GTK_TABLE (table), 0, 3, NULL,
                              0.0, 0.5, gimp_unit_entries_get_table (entries), 1, TRUE);
 
diff --git a/app/tools/gimprotatetool.h b/app/tools/gimprotatetool.h
index 779b1dc..d3011c5 100644
--- a/app/tools/gimprotatetool.h
+++ b/app/tools/gimprotatetool.h
@@ -39,7 +39,7 @@ struct _GimpRotateTool
 
   GtkAdjustment     *angle_adj;
   GtkWidget         *angle_spin_button;
-  GObject           *unit_entries;
+  GimpUnitEntries   *unit_entries;
 };
 
 struct _GimpRotateToolClass
diff --git a/app/widgets/gimpgrideditor.c b/app/widgets/gimpgrideditor.c
index 218e685..d194406 100644
--- a/app/widgets/gimpgrideditor.c
+++ b/app/widgets/gimpgrideditor.c
@@ -189,8 +189,8 @@ gimp_grid_editor_constructed (GObject *object)
                                          editor->yresolution,
                                          TRUE));
 
-  gtk_box_pack_start (GTK_BOX (hbox), entries->table, TRUE, TRUE, 0);
-  gtk_widget_show (entries->table);
+  gtk_box_pack_start (GTK_BOX (hbox), gimp_unit_entries_get_table (entries), TRUE, TRUE, 0);
+  gtk_widget_show (gimp_unit_entries_get_table (entries));
 
   gtk_widget_show (hbox);
 
@@ -212,8 +212,8 @@ gimp_grid_editor_constructed (GObject *object)
                                          editor->yresolution,
                                          TRUE));
 
-  gtk_box_pack_start (GTK_BOX (hbox), entries->table, TRUE, TRUE, 0);
-  gtk_widget_show (entries->table);
+  gtk_box_pack_start (GTK_BOX (hbox), gimp_unit_entries_get_table (entries), TRUE, TRUE, 0);
+  gtk_widget_show (gimp_unit_entries_get_table (entries));
 
   gtk_widget_show (hbox);
 }
diff --git a/app/widgets/gimptemplateeditor.c b/app/widgets/gimptemplateeditor.c
index 5b399a2..36ce699 100644
--- a/app/widgets/gimptemplateeditor.c
+++ b/app/widgets/gimptemplateeditor.c
@@ -143,7 +143,6 @@ gimp_template_editor_constructed (GObject *object)
   GtkWidget                 *scrolled_window;
   GtkWidget                 *text_view;
   GtkTextBuffer             *text_buffer;
-  GList                     *focus_chain = NULL;
   gchar                     *text;
 
   if (G_OBJECT_CLASS (parent_class)->constructed)
@@ -181,17 +180,17 @@ gimp_template_editor_constructed (GObject *object)
 
   private->unit_entries = GIMP_UNIT_ENTRIES (gimp_unit_entries_new ());
                         
-  gtk_table_attach_defaults (GTK_TABLE (table), private->unit_entries->table, 0, 2, 0, 2);
+  gtk_table_attach_defaults (GTK_TABLE (table), gimp_unit_entries_get_table (private->unit_entries), 0, 2, 0, 2);
 
-  gimp_unit_entries_add_entry_defaults (private->unit_entries, 
-                                        "width", 
+  gimp_unit_entries_add_entry (private->unit_entries, 
+                                        GIMP_UNIT_ENTRIES_WIDTH, 
                                         _("Width:"));
-  gimp_unit_entries_add_entry_defaults (private->unit_entries,
-                                        "height",
+  gimp_unit_entries_add_entry (private->unit_entries,
+                                        GIMP_UNIT_ENTRIES_HEIGHT,
                                         _("Height:"));
 
   gimp_prop_coordinates_connect (G_OBJECT (template),
-                                 "width", "height", "unit",
+                                 GIMP_UNIT_ENTRIES_WIDTH, GIMP_UNIT_ENTRIES_HEIGHT, "unit",
                                  G_OBJECT (private->unit_entries), NULL,
                                  gimp_template_get_resolution_x (template),
                                  gimp_template_get_resolution_y (template));
@@ -284,16 +283,16 @@ gimp_template_editor_constructed (GObject *object)
 
   private->resolution_entries = GIMP_UNIT_ENTRIES (gimp_unit_entries_new ()); 
 
-  gimp_unit_entries_add_entry_defaults (private->resolution_entries,
+  gimp_unit_entries_add_entry (private->resolution_entries,
                                            "xres",
                                            _("X resolution:"));
-  gimp_unit_entries_add_entry_defaults (private->resolution_entries,
+  gimp_unit_entries_add_entry (private->resolution_entries,
                                            "yres",
                                            _("Y resolution:"));
   gimp_unit_entries_set_mode (private->resolution_entries, GIMP_UNIT_ENTRY_MODE_RESOLUTION);                              
 
-  gtk_box_pack_start (GTK_BOX (hbox), private->resolution_entries->table, TRUE, TRUE, 0);
-  gtk_widget_show (private->resolution_entries->table);
+  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));
@@ -310,16 +309,6 @@ gimp_template_editor_constructed (GObject *object)
                                  G_OBJECT (private->resolution_entries), chainbutton,
                                  1.0, 1.0);
 
-  /*focus_chain = g_list_prepend (focus_chain,
-                                GIMP_SIZE_ENTRY (private->resolution_entries)->unitmenu);
-  focus_chain = g_list_prepend (focus_chain, chainbutton);
-  focus_chain = g_list_prepend (focus_chain, yres);
-  focus_chain = g_list_prepend (focus_chain, xres);
-
-  gtk_container_set_focus_chain (GTK_CONTAINER (private->resolution_entries),
-                                 focus_chain);*/
-  g_list_free (focus_chain);
-
   combo = gimp_prop_enum_combo_box_new (G_OBJECT (template),
                                         "image-type",
                                         GIMP_RGB, GIMP_GRAY);
@@ -539,14 +528,16 @@ gimp_template_editor_aspect_callback (GtkWidget          *widget,
                                        gimp_template_editor_template_notify,
                                        editor);
 
-      gimp_unit_entry_set_resolution (gimp_unit_entries_get_nth_entry (private->unit_entries, 0),
+      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_nth_entry (private->unit_entries, 1),
+      gimp_unit_entry_set_resolution (gimp_unit_entries_get_entry (private->unit_entries,
+                                                                   GIMP_UNIT_ENTRIES_WIDTH),
                                       xresolution);                                                                
 
       g_object_set (template,
-                    "width",       height,
-                    "height",      width,
+                    GIMP_UNIT_ENTRIES_WIDTH,  height,
+                    GIMP_UNIT_ENTRIES_HEIGHT, width,
                     "xresolution", yresolution,
                     "yresolution", xresolution,
                     NULL);
diff --git a/libgimpwidgets/.gitignore b/libgimpwidgets/.gitignore
index 12291fa..13b7620 100644
--- a/libgimpwidgets/.gitignore
+++ b/libgimpwidgets/.gitignore
@@ -11,3 +11,5 @@
 /makefile.mingw
 /test-eevl*
 /test-preview-area
+/test-unitentry
+/test-unitentrygui
diff --git a/libgimpwidgets/Makefile.am b/libgimpwidgets/Makefile.am
index cb55b6c..9c966cb 100644
--- a/libgimpwidgets/Makefile.am
+++ b/libgimpwidgets/Makefile.am
@@ -166,10 +166,10 @@ libgimpwidgets_2_0_la_sources = \
 	gimpstock.h			\
 	gimpstringcombobox.c		\
 	gimpstringcombobox.h		\
-	gimpunitcombobox.c		\
-	gimpunitcombobox.h		\
 	gimpunitadjustment.c		\
 	gimpunitadjustment.h		\
+	gimpunitcombobox.c		\
+	gimpunitcombobox.h		\
 	gimpunitentry.c			\
 	gimpunitentry.h			\
 	gimpunitentries.c			\
@@ -254,6 +254,7 @@ libgimpwidgetsinclude_HEADERS = \
 	gimpstock.h			\
 	gimpstringcombobox.h		\
 	gimpunitcombobox.h		\
+	gimpunitadjustment.h \
 	gimpunitentry.h			\
 	gimpunitmenu.h			\
 	gimpunitstore.h			\
diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c
index dba03ee..6a92738 100644
--- a/libgimpwidgets/gimppropwidgets.c
+++ b/libgimpwidgets/gimppropwidgets.c
@@ -2859,8 +2859,8 @@ gimp_prop_coordinates_new (GObject                   *config,
 
   unit_entries = GIMP_UNIT_ENTRIES (gimp_unit_entries_new ());
 
-  gimp_unit_entries_add_entry_defaults (unit_entries, x_property_name, x_label_str);
-  gimp_unit_entries_add_entry_defaults (unit_entries, y_property_name, y_label_str);
+  gimp_unit_entries_add_entry (unit_entries, x_property_name, x_label_str);
+  gimp_unit_entries_add_entry (unit_entries, y_property_name, y_label_str);
 
   if (has_chainbutton)
     {
@@ -2878,7 +2878,7 @@ gimp_prop_coordinates_new (GObject                   *config,
                                        xresolution,
                                        yresolution))
     {
-      gtk_widget_destroy (unit_entries->table);
+      gtk_widget_destroy (gimp_unit_entries_get_table (unit_entries));
       return NULL;
     }
 
diff --git a/libgimpwidgets/gimpunitadjustment.c b/libgimpwidgets/gimpunitadjustment.c
index 7fe1ab3..8b95d4b 100644
--- a/libgimpwidgets/gimpunitadjustment.c
+++ b/libgimpwidgets/gimpunitadjustment.c
@@ -43,7 +43,6 @@
 #define DEFAULT_UNIT                    GIMP_UNIT_INCH
 #define DEFAULT_RESOLUTION              72.0
 #define DEFAULT_UPPER                   GIMP_MAX_IMAGE_SIZE
-#define UNIT_ADJUSTMENT_STRING_LENGTH   15
 
 enum 
 { 
@@ -52,29 +51,48 @@ enum
   LAST_SIGNAL
 };
 
+typedef struct
+{
+  GimpUnit  unit;           /* the unit our value is in */
+  gdouble   resolution;     /* resolution in dpi */
+} GimpUnitAdjustmentPrivate;
+
+#define GIMP_UNIT_ADJUSTMENT_GET_PRIVATE(obj) \
+  ((GimpUnitAdjustmentPrivate *) ((GimpUnitAdjustment *) (obj))->private)
+
 G_DEFINE_TYPE (GimpUnitAdjustment, gimp_unit_adjustment, GTK_TYPE_ADJUSTMENT);
 
-static void gimp_unit_adjustment_convert_unit     (GimpUnitAdjustment *adj, GimpUnit unit);
-static void gimp_unit_adjustment_changed_handler  (GimpUnitAdjustment *adj, gpointer userData);
+static void gimp_unit_adjustment_convert_to_unit             (GimpUnitAdjustment *adj, GimpUnit unit);
+static void gimp_unit_adjustment_other_unit_changed_handler  (GimpUnitAdjustment *adj, gpointer userData);
 
 static guint unit_adjustment_signals[LAST_SIGNAL] = {0};
 
 static void
 gimp_unit_adjustment_init (GimpUnitAdjustment *unit_adjustment)
 {
+  GimpUnitAdjustmentPrivate *private;
+
+  unit_adjustment->private = G_TYPE_INSTANCE_GET_PRIVATE (unit_adjustment,
+                                                          GIMP_TYPE_UNIT_ADJUSTMENT,
+                                                          GimpUnitAdjustmentPrivate);
+
+  private = GIMP_UNIT_ADJUSTMENT_GET_PRIVATE (unit_adjustment);                                                        
+
   /* set default values */
   gtk_adjustment_set_upper (&unit_adjustment->parent_instance, DEFAULT_UPPER);
   gtk_adjustment_set_step_increment (&unit_adjustment->parent_instance, 1.0);
   gtk_adjustment_set_page_increment (&unit_adjustment->parent_instance, 10.0);
 
   /* default unit, resolution */
-  unit_adjustment->unit        = DEFAULT_UNIT;
-  unit_adjustment->resolution  = DEFAULT_RESOLUTION;
+  private->unit        = DEFAULT_UNIT;
+  private->resolution  = DEFAULT_RESOLUTION;
 }
 
 static void
 gimp_unit_adjustment_class_init (GimpUnitAdjustmentClass *klass)
 {
+  g_type_class_add_private (klass, sizeof (GimpUnitAdjustmentPrivate));
+
   unit_adjustment_signals [UNIT_CHANGED] = 
     g_signal_new ("unit-changed",
                   GIMP_TYPE_UNIT_ADJUSTMENT,
@@ -98,76 +116,80 @@ gimp_unit_adjustment_class_init (GimpUnitAdjustmentClass *klass)
                   0);
 }
 
-GObject *
+GimpUnitAdjustment *
 gimp_unit_adjustment_new (void)
 {
-  return g_object_new (GIMP_TYPE_UNIT_ADJUSTMENT, NULL);
+  return GIMP_UNIT_ADJUSTMENT (g_object_new (GIMP_TYPE_UNIT_ADJUSTMENT, NULL));
 }
 
 static void
-gimp_unit_adjustment_changed_handler (GimpUnitAdjustment *adj,
-                                      gpointer            user_data)
+gimp_unit_adjustment_other_unit_changed_handler (GimpUnitAdjustment *adj,
+                                                 gpointer            user_data)
 {
-  GimpUnitAdjustment *adjustment = GIMP_UNIT_ADJUSTMENT (user_data);
-  GimpUnit           unit        = gimp_unit_adjustment_get_unit (adj);
+  GimpUnitAdjustment *other_adj  = GIMP_UNIT_ADJUSTMENT (user_data);
+  GimpUnit           unit        = gimp_unit_adjustment_get_unit (other_adj);
 
-  gimp_unit_adjustment_convert_unit (adjustment, unit);
+  gimp_unit_adjustment_convert_to_unit (adj, unit);
 }
 
 /* connects adjustment to another adjustment */
 void   
-gimp_unit_adjustment_connect (GimpUnitAdjustment *adj, 
-                              GimpUnitAdjustment *target)
+gimp_unit_adjustment_follow_unit_of (GimpUnitAdjustment *adj, 
+                                     GimpUnitAdjustment *other)
 {
-  g_signal_connect (target,
-                    "unit-changed",
-                    G_CALLBACK (gimp_unit_adjustment_changed_handler),
-                    (gpointer*) adj); 
+  g_signal_connect_swapped (other,
+                           "unit-changed",
+                            G_CALLBACK (gimp_unit_adjustment_other_unit_changed_handler),
+                            (gpointer*) adj); 
 }
 
 /* converts value from one unit to another */
 static void
-gimp_unit_adjustment_convert_unit (GimpUnitAdjustment *adj,
-                                   GimpUnit            unit)
+gimp_unit_adjustment_convert_to_unit (GimpUnitAdjustment *adj,
+                                      GimpUnit            unit)
 {
-  gdouble new_value = 0, lower, upper;
-  if (adj->unit != unit)
-  {
-    DEBUG   (("GimpUnitAdjustment: changing unit from %s to %s\n",
-             gimp_unit_get_abbreviation (adj->unit),
-             gimp_unit_get_abbreviation (unit));)
-
-    /* convert value to new unit */
-    new_value = gimp_units_to_pixels (gtk_adjustment_get_value (&(adj->parent_instance)),
-                                     adj->unit,
-                                     adj->resolution);
-    new_value = gimp_pixels_to_units (new_value,
-                                     unit, 
-                                     adj->resolution);
-
-    /* also convert bounds */
-    upper = gimp_units_to_pixels (gtk_adjustment_get_upper (GTK_ADJUSTMENT (adj)),
-                                  adj->unit,
-                                  adj->resolution);
-    lower = gimp_units_to_pixels (gtk_adjustment_get_lower (GTK_ADJUSTMENT (adj)),
-                                  adj->unit,
-                                 adj->resolution);
-
-    upper = gimp_pixels_to_units (upper,
-                                  unit, 
-                                  adj->resolution);
-    lower = gimp_pixels_to_units (lower,
-                                  unit, 
-                                  adj->resolution);
-
-    gtk_adjustment_set_upper (GTK_ADJUSTMENT (adj), upper);
-    gtk_adjustment_set_lower (GTK_ADJUSTMENT (adj), lower);
-
-    /* set the new unit */
-    adj->unit  = unit;
-
-    gimp_unit_adjustment_set_value (adj, new_value);
-  }
+  GimpUnitAdjustmentPrivate *private   = GIMP_UNIT_ADJUSTMENT_GET_PRIVATE (adj);
+  gdouble                    new_value = 0;
+  gdouble                    lower;
+  gdouble                    upper;
+
+  if (private->unit == unit)
+    return;
+
+  DEBUG   (("GimpUnitAdjustment: changing unit from %s to %s\n",
+           gimp_unit_get_abbreviation (private->unit),
+           gimp_unit_get_abbreviation (unit));)
+
+  /* convert value to new unit */
+  new_value = gimp_units_to_pixels (gtk_adjustment_get_value (&(adj->parent_instance)),
+                                    private->unit,
+                                    private->resolution);
+  new_value = gimp_pixels_to_units (new_value,
+                                    unit, 
+                                    private->resolution);
+
+  /* also convert bounds */
+  upper = gimp_units_to_pixels (gtk_adjustment_get_upper (GTK_ADJUSTMENT (adj)),
+                                private->unit,
+                                private->resolution);
+  lower = gimp_units_to_pixels (gtk_adjustment_get_lower (GTK_ADJUSTMENT (adj)),
+                                private->unit,
+                                private->resolution);
+
+  upper = gimp_pixels_to_units (upper,
+                                unit, 
+                                private->resolution);
+  lower = gimp_pixels_to_units (lower,
+                                unit, 
+                                private->resolution);
+
+  gtk_adjustment_set_upper (GTK_ADJUSTMENT (adj), upper);
+  gtk_adjustment_set_lower (GTK_ADJUSTMENT (adj), lower);
+
+  /* set the new unit */
+  private->unit = unit;
+
+  gimp_unit_adjustment_set_value (adj, new_value);
 }
 
 /* sets unit of adjustment, does conversion if neccessary */
@@ -175,7 +197,7 @@ void
 gimp_unit_adjustment_set_unit (GimpUnitAdjustment *adj, 
                                GimpUnit            unit)
 {
-  gimp_unit_adjustment_convert_unit (adj, unit);
+  gimp_unit_adjustment_convert_to_unit (adj, unit);
 
   /* emit "unit-changed" */
   g_signal_emit(adj, unit_adjustment_signals [UNIT_CHANGED], 0);
@@ -195,9 +217,11 @@ gimp_unit_adjustment_set_value_in_unit (GimpUnitAdjustment *adj,
                                         gdouble             value, 
                                         GimpUnit            unit)
 {
+  GimpUnitAdjustmentPrivate *private   = GIMP_UNIT_ADJUSTMENT_GET_PRIVATE (adj);
+
   /* convert from given unit to adjustments unit */
-  value = gimp_units_to_pixels (value, unit, adj->resolution);
-  value = gimp_pixels_to_units (value, adj->unit, adj->resolution);
+  value = gimp_units_to_pixels (value, unit, private->resolution);
+  value = gimp_pixels_to_units (value, private->unit, private->resolution);
 
   gimp_unit_adjustment_set_value (adj, value);
 }
@@ -216,10 +240,11 @@ gdouble
 gimp_unit_adjustment_get_value_in_unit (GimpUnitAdjustment *adj, 
                                         GimpUnit            unit)
 {
-  gdouble value = gimp_unit_adjustment_get_value (adj);
+  GimpUnitAdjustmentPrivate *private   = GIMP_UNIT_ADJUSTMENT_GET_PRIVATE (adj);
+  gdouble                    value     = gimp_unit_adjustment_get_value (adj);
 
-  value = gimp_units_to_pixels (value, adj->unit, adj->resolution);
-  value = gimp_pixels_to_units (value, unit, adj->resolution);
+  value = gimp_units_to_pixels (value, private->unit, private->resolution);
+  value = gimp_pixels_to_units (value, unit, private->resolution);
 
   return value;
 }
@@ -228,9 +253,11 @@ void
 gimp_unit_adjustment_set_resolution (GimpUnitAdjustment *adj, 
                                      gdouble             res)
 {
-  if (adj->resolution != res) 
+  GimpUnitAdjustmentPrivate *private   = GIMP_UNIT_ADJUSTMENT_GET_PRIVATE (adj);
+
+  if (private->resolution != res) 
   {
-    adj->resolution = res;
+    private->resolution = res;
     /* emit "resolution-changed" */
     g_signal_emit(adj, unit_adjustment_signals [RESOLUTION_CHANGED], 0);
   }
@@ -239,59 +266,51 @@ gimp_unit_adjustment_set_resolution (GimpUnitAdjustment *adj,
 gdouble 
 gimp_unit_adjustment_get_resolution (GimpUnitAdjustment *adj)
 {
-  return adj->resolution;
-}
+  GimpUnitAdjustmentPrivate *private   = GIMP_UNIT_ADJUSTMENT_GET_PRIVATE (adj);
 
-/* get string in format "value unit" */
-gchar* 
-gimp_unit_adjustment_to_string (GimpUnitAdjustment *adj)
-{
-  return gimp_unit_adjustment_to_string_in_unit (adj, adj->unit);
-}
-
-gchar*  
-gimp_unit_adjustment_to_string_in_unit (GimpUnitAdjustment *adj, 
-                                        GimpUnit            unit)
-{
-  gdouble value;
-  gchar *text = g_malloc (sizeof (gchar) * UNIT_ADJUSTMENT_STRING_LENGTH);
-
-  value = gimp_unit_adjustment_get_value_in_unit (adj, unit);
-
-  g_snprintf (text, UNIT_ADJUSTMENT_STRING_LENGTH, "%.*f %s", 
-             gimp_unit_get_digits (unit),
-             value,
-             gimp_unit_get_abbreviation (unit));
-
-  return text;
+  return private->resolution;
 }
 
 GimpUnit 
 gimp_unit_adjustment_get_unit (GimpUnitAdjustment *adj)
 {
-  return adj->unit;
+  GimpUnitAdjustmentPrivate *private   = GIMP_UNIT_ADJUSTMENT_GET_PRIVATE (adj);
+
+  return private->unit;
 }
 
 void
 gimp_unit_adjustment_set_bounds (GimpUnitAdjustment *adj, 
                                  GimpUnit            unit, 
-                                 gdouble             upper, 
-                                 gdouble             lower)
+                                 gdouble             lower, 
+                                 gdouble             upper)
 {
+  GimpUnitAdjustmentPrivate *private   = GIMP_UNIT_ADJUSTMENT_GET_PRIVATE (adj);
+  gdouble                    temp;
+
+  /* switch lower and upper bounds if neccessary
+     (older revisions used gimp_unit_adjustment_set_bounds (adj, unit, upper, lower)) */
+  if (lower > upper) 
+  {
+    temp = upper;
+    upper = lower;
+    lower = temp;    
+  }
+
   /* convert bounds from given unit to current unit */
   upper = gimp_units_to_pixels (upper,
                                 unit,
-                                adj->resolution);
+                                private->resolution);
   lower = gimp_units_to_pixels (lower,
                                 unit,
-                                adj->resolution);
+                                private->resolution);
 
   upper = gimp_pixels_to_units (upper,
-                                adj->unit, 
-                                adj->resolution);
+                                private->unit, 
+                                private->resolution);
   lower = gimp_pixels_to_units (lower,
-                                adj->unit, 
-                                adj->resolution);
+                                private->unit, 
+                                private->resolution);
 
   /* set bounds */
   gtk_adjustment_set_upper (GTK_ADJUSTMENT (adj), upper);
diff --git a/libgimpwidgets/gimpunitadjustment.h b/libgimpwidgets/gimpunitadjustment.h
index f334c13..1fc985b 100644
--- a/libgimpwidgets/gimpunitadjustment.h
+++ b/libgimpwidgets/gimpunitadjustment.h
@@ -26,9 +26,6 @@
 
 G_BEGIN_DECLS
 
-/**
- * boiler-plate
- **/
 #define GIMP_TYPE_UNIT_ADJUSTMENT            (gimp_unit_adjustment_get_type ())
 #define GIMP_UNIT_ADJUSTMENT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_UNIT_ADJUSTMENT, GimpUnitAdjustment))
 #define GIMP_UNIT_ADJUSTMENT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_UNIT_ADJUSTMENT, GimpUnitAdjustmentClass))
@@ -43,10 +40,7 @@ struct _GimpUnitAdjustment
 {
   GtkAdjustment parent_instance;
 
-  /* private */
-  /* TODO move private fields into own struct? */
-  GimpUnit  unit;           /* the unit our value is in */
-  gdouble   resolution;     /* resolution in dpi */
+  gpointer      private;
 };
 
 struct _GimpUnitAdjustmentClass
@@ -55,35 +49,32 @@ struct _GimpUnitAdjustmentClass
 };
 
 
-GType     gimp_unit_adjustment_get_type           (void);
-GObject  *gimp_unit_adjustment_new                (void);
+GType                gimp_unit_adjustment_get_type           (void);
+GimpUnitAdjustment  *gimp_unit_adjustment_new                (void);
 
-void      gimp_unit_adjustment_set_unit           (GimpUnitAdjustment *adj, 
-                                                   GimpUnit            unit);
-void      gimp_unit_adjustment_set_value          (GimpUnitAdjustment *adj, 
-                                                   gdouble             value);
-void      gimp_unit_adjustment_set_value_in_unit  (GimpUnitAdjustment *adj, 
-                                                   gdouble             value, 
-                                                   GimpUnit            unit);
-void      gimp_unit_adjustment_set_resolution     (GimpUnitAdjustment *adj, 
-                                                   gdouble             res);
-void      gimp_unit_adjustment_set_bounds         (GimpUnitAdjustment *adj, 
-                                                   GimpUnit            unit, 
-                                                   gdouble             upper, 
-                                                   gdouble             lower);                                                   
+void                 gimp_unit_adjustment_set_unit           (GimpUnitAdjustment *adj, 
+                                                              GimpUnit            unit);
+void                 gimp_unit_adjustment_set_value          (GimpUnitAdjustment *adj, 
+                                                              gdouble             value);
+void                 gimp_unit_adjustment_set_value_in_unit  (GimpUnitAdjustment *adj, 
+                                                              gdouble             value, 
+                                                              GimpUnit            unit);
+void                 gimp_unit_adjustment_set_resolution     (GimpUnitAdjustment *adj, 
+                                                              gdouble             res);
+void                 gimp_unit_adjustment_set_bounds         (GimpUnitAdjustment *adj, 
+                                                              GimpUnit            unit, 
+                                                              gdouble             lower, 
+                                                              gdouble             upper);                                                   
                                                                                                       
-gdouble   gimp_unit_adjustment_get_value          (GimpUnitAdjustment *adj);
-gdouble   gimp_unit_adjustment_get_value_in_unit  (GimpUnitAdjustment *adj, 
-                                                   GimpUnit            unit);
-gdouble   gimp_unit_adjustment_get_resolution     (GimpUnitAdjustment *adj);
-GimpUnit  gimp_unit_adjustment_get_unit           (GimpUnitAdjustment *adj);
+gdouble              gimp_unit_adjustment_get_value          (GimpUnitAdjustment *adj);
+gdouble              gimp_unit_adjustment_get_value_in_unit  (GimpUnitAdjustment *adj, 
+                                                              GimpUnit            unit);
+gdouble              gimp_unit_adjustment_get_resolution     (GimpUnitAdjustment *adj);
+GimpUnit             gimp_unit_adjustment_get_unit           (GimpUnitAdjustment *adj);
 
-gchar*    gimp_unit_adjustment_to_string          (GimpUnitAdjustment *adj);
-gchar*    gimp_unit_adjustment_to_string_in_unit  (GimpUnitAdjustment *adj, 
-                                                   GimpUnit            unit);
 
-void      gimp_unit_adjustment_connect            (GimpUnitAdjustment *adj, 
-                                                   GimpUnitAdjustment *target);
+void                 gimp_unit_adjustment_follow_unit_of     (GimpUnitAdjustment *adj, 
+                                                              GimpUnitAdjustment *other);
 
 G_END_DECLS
 
diff --git a/libgimpwidgets/gimpunitentries.c b/libgimpwidgets/gimpunitentries.c
index 547396b..20d378f 100644
--- a/libgimpwidgets/gimpunitentries.c
+++ b/libgimpwidgets/gimpunitentries.c
@@ -35,12 +35,25 @@
 #define DEBUG(x) /* nothing */
 #endif
 
+#define UNIT_ENTRIES_LEFT_ATTACH  2
+#define UNIT_ENTRIES_RIGHT_ATTACH 3
+
 enum
 {
   CHANGED,
   LAST_SIGNAL
 };
 
+typedef struct
+{
+  GtkWidget  *table;
+  GtkWidget  *chain_button;
+  GHashTable *entries_store;
+} GimpUnitEntriesPrivate;
+
+#define GIMP_UNIT_ENTRIES_GET_PRIVATE(obj) \
+  ((GimpUnitEntriesPrivate *) ((GimpUnitEntries *) (obj))->private)
+
 G_DEFINE_TYPE (GimpUnitEntries, gimp_unit_entries, G_TYPE_OBJECT);
 
 static void gimp_unit_entries_label_updater  (GtkAdjustment *adj, gpointer user_data);
@@ -51,16 +64,24 @@ static guint unit_entries_signals[LAST_SIGNAL] = {0};
 static void
 gimp_unit_entries_init (GimpUnitEntries *entries)
 {
-  entries->table          = gtk_table_new     (1, 1, FALSE);
-  entries->entries_store  = g_hash_table_new  (NULL, NULL);
-  entries->chain_button   = NULL;
-  entries->bottom         = 0;
-  entries->right          = 0;
+  GimpUnitEntriesPrivate *private;
+
+  entries->private = G_TYPE_INSTANCE_GET_PRIVATE (entries,
+                                                  GIMP_TYPE_UNIT_ENTRIES,
+                                                  GimpUnitEntriesPrivate);
+
+  private = GIMP_UNIT_ENTRIES_GET_PRIVATE (entries);   
+
+  private->table          = gtk_table_new     (1, 1, FALSE);
+  private->entries_store  = g_hash_table_new  (g_str_hash, g_str_equal);
+  private->chain_button   = NULL;
 }
 
 static void
 gimp_unit_entries_class_init (GimpUnitEntriesClass *klass)
 {
+  g_type_class_add_private (klass, sizeof (GimpUnitEntriesPrivate));
+
   unit_entries_signals[CHANGED] = 
     g_signal_new ("changed",
                   GIMP_TYPE_UNIT_ENTRIES,
@@ -73,32 +94,41 @@ gimp_unit_entries_class_init (GimpUnitEntriesClass *klass)
                   G_TYPE_OBJECT);
 }
 
-GObject*
+GimpUnitEntries*
 gimp_unit_entries_new (void)
 {
-  GObject *table;
+  GObject *entries;
 
-  table = g_object_new (GIMP_TYPE_UNIT_ENTRIES, NULL);
+  entries = g_object_new (GIMP_TYPE_UNIT_ENTRIES, NULL);
 
-  return table;
+  return GIMP_UNIT_ENTRIES (entries);
 }
 
 /* add an UnitEntry */
 GtkWidget* 
 gimp_unit_entries_add_entry (GimpUnitEntries *entries,
                              const gchar     *id,
-                             const gchar     *labelStr,
-                             gint             x,
-                             gint             y)
+                             const gchar     *label_str)
 {
-  GimpUnitEntry *entry = GIMP_UNIT_ENTRY (gimp_unit_entry_new ()); 
-  GtkWidget     *label;
+  GimpUnitEntriesPrivate  *private = GIMP_UNIT_ENTRIES_GET_PRIVATE (entries);
+  GimpUnitEntry           *entry   = GIMP_UNIT_ENTRY (gimp_unit_entry_new ()); 
+  GimpUnitEntry           *other_entry;
+  GtkWidget               *label;
+  guint                   bottom;
+  gint                    i;
+  gint                    left_attach,
+                          right_attach,
+                          top_attach,
+                          bottom_attach;
+
+  /* retrieve bottom row of table */
+  gtk_table_get_size (GTK_TABLE (gimp_unit_entries_get_table (entries)), &bottom, NULL);
 
   /* position of the entry (leave one row/column empty for labels etc) */
-  gint left_attach   = x + 1,
-       right_attach  = x + 2,
-       top_attach    = y + 1,
-       bottom_attach = y + 2;
+  left_attach   = UNIT_ENTRIES_LEFT_ATTACH,
+  right_attach  = UNIT_ENTRIES_RIGHT_ATTACH,
+  top_attach    = bottom,
+  bottom_attach = bottom + 1;
 
   /* remember position in table so that we later can place other widgets around it */
   g_object_set_data (G_OBJECT (entry), "left_attach", GINT_TO_POINTER (left_attach));
@@ -107,24 +137,18 @@ gimp_unit_entries_add_entry (GimpUnitEntries *entries,
   g_object_set_data (G_OBJECT (entry), "bottom_attach", GINT_TO_POINTER (bottom_attach));
 
   /* add entry to table at position (1, count) */
-  gtk_table_attach_defaults (GTK_TABLE (entries->table),
+  gtk_table_attach_defaults (GTK_TABLE (gimp_unit_entries_get_table (entries)),
                              GTK_WIDGET (entry), 
                              left_attach,
                              right_attach,
                              top_attach,
                              bottom_attach);
 
-  /* save new size of our table if neccessary */                           
-  if (bottom_attach > entries->bottom)                           
-      entries->bottom = bottom_attach;
-  if (right_attach > entries->right)
-      entries->right = right_attach;
-
   /* if label string is given, create label and attach to the left of entry */
-  if (labelStr != NULL)
+  if (label_str != NULL)
   {
-    label = gtk_label_new (labelStr);
-    gtk_table_attach (GTK_TABLE (entries->table),
+    label = gtk_label_new (label_str);
+    gtk_table_attach (GTK_TABLE (gimp_unit_entries_get_table (entries)),
                       label,
                       left_attach-1 , left_attach, top_attach, bottom_attach,
                       GTK_SHRINK, GTK_EXPAND | GTK_FILL,
@@ -136,36 +160,19 @@ gimp_unit_entries_add_entry (GimpUnitEntries *entries,
   g_signal_connect (gimp_unit_entry_get_adjustment (entry), "value-changed",
                     G_CALLBACK (gimp_unit_entries_entry_changed), (gpointer) entries);
   g_signal_connect (gimp_unit_entry_get_adjustment (entry), "resolution-changed",
-                    G_CALLBACK (gimp_unit_entries_entry_changed), (gpointer) entries);                 
-
-  gtk_widget_show_all (entries->table); 
-
-  g_hash_table_insert (entries->entries_store, (gpointer) id, (gpointer) entry);
-
-  return GTK_WIDGET (entry);
-}
-
-GtkWidget* 
-gimp_unit_entries_add_entry_defaults (GimpUnitEntries *entries,
-                                      const gchar     *id,
-                                      const gchar     *labelStr)
-{
-  GimpUnitEntry *entry, *entry2;
-  gint i;
-
-  entry = GIMP_UNIT_ENTRY (gimp_unit_entries_add_entry (entries,
-                                                        id,
-                                                        labelStr,
-                                                        1,
-                                                        entries->bottom));
-
+                    G_CALLBACK (gimp_unit_entries_entry_changed), (gpointer) entries); 
+                    
   /* connect entry to others */
-  for (i = 0; i < g_hash_table_size (entries->entries_store); i++)
+  for (i = 0; i < g_hash_table_size (private->entries_store); i++)
   {
-    entry2 = gimp_unit_entries_get_nth_entry (entries, i);
-    gimp_unit_entry_connect (GIMP_UNIT_ENTRY (entry), GIMP_UNIT_ENTRY (entry2));
-    gimp_unit_entry_connect (GIMP_UNIT_ENTRY (entry2), GIMP_UNIT_ENTRY (entry));
-  }                                         
+    other_entry = gimp_unit_entries_get_nth_entry (entries, i);
+    gimp_unit_entry_connect (GIMP_UNIT_ENTRY (entry), GIMP_UNIT_ENTRY (other_entry));
+    gimp_unit_entry_connect (GIMP_UNIT_ENTRY (other_entry), GIMP_UNIT_ENTRY (entry));
+  }                      
+
+  gtk_widget_show_all (gimp_unit_entries_get_table (entries)); 
+
+  g_hash_table_insert (private->entries_store, (gpointer) id, (gpointer) entry);
 
   return GTK_WIDGET (entry);
 }
@@ -177,10 +184,13 @@ gimp_unit_entries_add_preview_label (GimpUnitEntries *entries,
                                      const gchar     *id1,
                                      const gchar     *id2)
 {
-  GtkWidget     *label = gtk_label_new("preview");
+  GtkWidget     *label  = gtk_label_new("preview");
   GimpUnitEntry *entry1 = gimp_unit_entries_get_entry (entries, id1);
   GimpUnitEntry *entry2 = gimp_unit_entries_get_entry (entries, id2);
-  gint          left_attach, right_attach, top_attach, bottom_attach;
+  gint          left_attach, 
+                right_attach, 
+                top_attach, 
+                bottom_attach;
 
   /* save unit */
   g_object_set_data (G_OBJECT (label), "unit", GINT_TO_POINTER (unit));
@@ -195,7 +205,7 @@ gimp_unit_entries_add_preview_label (GimpUnitEntries *entries,
   bottom_attach = top_attach + 1;
 
   /* add label below unit entries */
-  gtk_table_attach (GTK_TABLE (entries->table),
+  gtk_table_attach (GTK_TABLE (gimp_unit_entries_get_table (entries)),
                     label,
                     left_attach, right_attach, 
                     top_attach, bottom_attach,
@@ -208,8 +218,6 @@ gimp_unit_entries_add_preview_label (GimpUnitEntries *entries,
                              PANGO_ATTR_SCALE,  PANGO_SCALE_SMALL,
                              -1);*/
 
-  entries->bottom++;
-
   gtk_widget_show (GTK_WIDGET (label));
 
   /* connect label updater to changed signal */
@@ -228,19 +236,20 @@ gimp_unit_entries_add_chain_button  (GimpUnitEntries *entries,
                                      const gchar     *id1,
                                      const gchar     *id2)
 {
-  GtkWidget        *chain_button;
-  GimpUnitEntry    *entry1      = gimp_unit_entries_get_entry (entries, id1);
-  GimpUnitEntry    *entry2      = gimp_unit_entries_get_entry (entries, id2);
+  GimpUnitEntriesPrivate  *private        = GIMP_UNIT_ENTRIES_GET_PRIVATE (entries);
+  GtkWidget               *chain_button;
+  GimpUnitEntry           *entry1         = gimp_unit_entries_get_entry (entries, id1);
+  GimpUnitEntry           *entry2         = gimp_unit_entries_get_entry (entries, id2);
 
   /* retrieve position of entries */
   gint right_attach  = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (entry1), "right_attach"));
   gint top_attach    = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (entry1), "top_attach"));
   gint bottom_attach = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (entry2), "bottom_attach"));
 
-  chain_button = gimp_chain_button_new(GIMP_CHAIN_RIGHT);
+  chain_button = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
 
   /* add chain_button to right of entries, spanning from the first to the second */
-  gtk_table_attach (GTK_TABLE (entries->table),
+  gtk_table_attach (GTK_TABLE (gimp_unit_entries_get_table (entries)),
                     GTK_WIDGET (chain_button),
                     right_attach, right_attach + 1,
                     top_attach, bottom_attach,
@@ -250,7 +259,7 @@ gimp_unit_entries_add_chain_button  (GimpUnitEntries *entries,
 
   gtk_widget_show (chain_button);  
   
-  entries->chain_button = chain_button;                        
+  private->chain_button = chain_button;                        
 
   return chain_button;
 }
@@ -260,9 +269,10 @@ GimpUnitEntry*
 gimp_unit_entries_get_entry (GimpUnitEntries *entries,
                              const gchar     *id)
 {
-  GimpUnitEntry *entry;
+  GimpUnitEntriesPrivate  *private = GIMP_UNIT_ENTRIES_GET_PRIVATE (entries);
+  GimpUnitEntry           *entry;
 
-  entry = GIMP_UNIT_ENTRY (g_hash_table_lookup (entries->entries_store, id));
+  entry = GIMP_UNIT_ENTRY (g_hash_table_lookup (private->entries_store, id));
 
   if (entry == NULL)
   {
@@ -277,11 +287,13 @@ GimpUnitEntry*
 gimp_unit_entries_get_nth_entry (GimpUnitEntries *entries, 
                                  gint             index)
 {
-  GHashTableIter   iter;
-  gpointer         key, value;
-  gint             i;
+  GimpUnitEntriesPrivate  *private = GIMP_UNIT_ENTRIES_GET_PRIVATE (entries);
+  GHashTableIter           iter;
+  gpointer                 key,
+                           value;
+  gint                     i;
 
-  if (g_hash_table_size (entries->entries_store) <= index || index < 0)
+  if (g_hash_table_size (private->entries_store) <= index || index < 0)
   {
     g_warning ("gimp_unit_entries_get_nth_entry: index < 0 or hash table size smaller than index");
     return NULL;
@@ -289,7 +301,7 @@ gimp_unit_entries_get_nth_entry (GimpUnitEntries *entries,
 
   i = 0;
 
-  g_hash_table_iter_init (&iter, entries->entries_store);
+  g_hash_table_iter_init (&iter, private->entries_store);
 
   while (g_hash_table_iter_next (&iter, &key, &value))
   {
@@ -310,18 +322,14 @@ gimp_unit_entries_label_updater (GtkAdjustment *adj,
   GtkLabel           *label       = GTK_LABEL (user_data);
   GimpUnitEntry      *entry1      = GIMP_UNIT_ENTRY (g_object_get_data (G_OBJECT (label), "entry1"));
   GimpUnitEntry      *entry2      = GIMP_UNIT_ENTRY (g_object_get_data (G_OBJECT (label), "entry2"));
-  GimpUnitAdjustment *adjustment;   
   GimpUnit            unit;
 
   /* retrieve preview unit */
   unit = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label), "unit"));
 
   /* retrieve values of the two entries */
-  adjustment = gimp_unit_entry_get_adjustment (entry1);
-  g_sprintf (str, "%s", gimp_unit_adjustment_to_string_in_unit (adjustment, unit));
-
-  adjustment = gimp_unit_entry_get_adjustment (entry2);
-  g_sprintf (str, "%s x %s ", str, gimp_unit_adjustment_to_string_in_unit (adjustment, unit));
+  g_sprintf (str, "%s", gimp_unit_entry_to_string_in_unit (entry1, unit));
+  g_sprintf (str, "%s x %s ", str, gimp_unit_entry_to_string_in_unit (entry2, unit));
 
   gtk_label_set_text (label, str);
 }
@@ -344,14 +352,16 @@ gimp_unit_entries_entry_changed  (GtkAdjustment *adj,
   }
 
   /* emit "changed" */
-  g_signal_emit(entries, unit_entries_signals[CHANGED], 0, entry);
+  g_signal_emit (entries, unit_entries_signals[CHANGED], 0, entry);
 }
 
 /* get count of attached unit entries */
 gint
 gimp_unit_entries_get_entry_count (GimpUnitEntries *entries)
 {
-  return g_hash_table_size (entries->entries_store);
+  GimpUnitEntriesPrivate  *private = GIMP_UNIT_ENTRIES_GET_PRIVATE (entries);
+
+  return g_hash_table_size (private->entries_store);
 }
 
 /* get value of given entry in pixels */
@@ -427,6 +437,7 @@ 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 */
   }
 }
 
@@ -449,8 +460,8 @@ gimp_unit_entries_set_activates_default (GimpUnitEntries *entries,
 void            
 gimp_unit_entries_set_bounds (GimpUnitEntries *entries, 
                               GimpUnit         unit, 
-                              gdouble          upper, 
-                              gdouble          lower)
+                              gdouble          lower, 
+                              gdouble          upper)
 {
   GimpUnitEntry *entry;
   gint           i, count = gimp_unit_entries_get_entry_count (entries);
@@ -459,26 +470,31 @@ gimp_unit_entries_set_bounds (GimpUnitEntries *entries,
   for (i = 0; i < count; i++) 
   {
     entry = gimp_unit_entries_get_nth_entry (entries, i);
-    gimp_unit_entry_set_bounds (entry, unit, upper, lower);
+    gimp_unit_entry_set_bounds (entry, unit, lower, upper);
   }
 }                                  
 
 void 
 gimp_unit_entries_grab_focus (GimpUnitEntries *entries)
 {
-  gtk_widget_grab_focus (GTK_WIDGET (gimp_unit_entries_get_nth_entry (entries, 0)));
+  if (gimp_unit_entries_get_entry_count > 0)
+    gtk_widget_grab_focus (GTK_WIDGET (gimp_unit_entries_get_nth_entry (entries, 0)));
 }
 
 GtkWidget*      
 gimp_unit_entries_get_table  (GimpUnitEntries *entries)
 {
-  return entries->table;
+  GimpUnitEntriesPrivate  *private = GIMP_UNIT_ENTRIES_GET_PRIVATE (entries);
+
+  return private->table;
 }
 
 GtkWidget*      
 gimp_unit_entries_get_chain_button  (GimpUnitEntries *entries)
 {
-  return entries->chain_button;
+  GimpUnitEntriesPrivate  *private = GIMP_UNIT_ENTRIES_GET_PRIVATE (entries);
+
+  return private->chain_button;
 }
 
 void            
@@ -503,4 +519,4 @@ gimp_unit_entries_set_nth_pixels (GimpUnitEntries *entries,
   entry = gimp_unit_entries_get_nth_entry (entries, index);
 
   gimp_unit_entry_set_value_in_unit (entry, value, GIMP_UNIT_PIXEL);
-}                                       
+}                                
diff --git a/libgimpwidgets/gimpunitentries.h b/libgimpwidgets/gimpunitentries.h
index 3514dbe..211e813 100644
--- a/libgimpwidgets/gimpunitentries.h
+++ b/libgimpwidgets/gimpunitentries.h
@@ -49,15 +49,9 @@ typedef struct _GimpUnitEntriesClass  GimpUnitEntriesClass;
 
 struct _GimpUnitEntries
 {
-  GObject parent_instance;
+  GObject  parent_instance;
 
-  /* private */
-  GtkWidget  *table;
-  GtkWidget  *chain_button;
-  GHashTable *entries_store;
-
-  /* dimensions of "sub-table" containing the actual entries */ 
-  gint       bottom, right;
+  gpointer private;
 };
 
 struct _GimpUnitEntriesClass
@@ -66,15 +60,10 @@ struct _GimpUnitEntriesClass
 };
 
 GType           gimp_unit_entries_get_type              (void);
-GObject*        gimp_unit_entries_new                   (void);
+GimpUnitEntries*gimp_unit_entries_new                   (void);
 
 GtkWidget*      gimp_unit_entries_add_entry             (GimpUnitEntries *entries, 
                                                          const gchar     *id,
-                                                         const gchar     *label,
-                                                         gint             x, 
-                                                         gint             y);
-GtkWidget*      gimp_unit_entries_add_entry_defaults    (GimpUnitEntries *entries, 
-                                                         const gchar     *id, 
                                                          const gchar     *label);
 void            gimp_unit_entries_add_preview_label     (GimpUnitEntries *entries, 
                                                          GimpUnit         unit, 
diff --git a/libgimpwidgets/gimpunitentry.c b/libgimpwidgets/gimpunitentry.c
index 57ac049..4c33408 100644
--- a/libgimpwidgets/gimpunitentry.c
+++ b/libgimpwidgets/gimpunitentry.c
@@ -51,6 +51,27 @@
 #define UNIT_ENTRY_ERROR_COLOR    "LightSalmon"
 #define UNIT_ENTRY_SIZE_REQUEST   200
 
+typedef struct
+{
+  GimpUnitAdjustment *unit_adjustment; 
+
+  /* flag set TRUE when entry's text should not be overwritten
+     (i.e. during user input) */
+  /* FIXME: maybe it's possible to block signals that trigger updates instead */
+  gboolean            dont_update_text;
+
+  /* input mode */
+  GimpUnitEntryMode   mode;
+
+  /* is our input valid? (for error indication) */
+  gboolean            input_valid;
+  /* the timer source which handles the error indication */
+  GSource             *timer;
+} GimpUnitEntryPrivate;
+
+#define GIMP_UNIT_ENTRY_GET_PRIVATE(obj) \
+  ((GimpUnitEntryPrivate *) ((GimpUnitEntry *) (obj))->private)
+
 G_DEFINE_TYPE (GimpUnitEntry, gimp_unit_entry, GTK_TYPE_SPIN_BUTTON);
 
 static gboolean gimp_unit_entry_parse           (GimpUnitEntry *unitEntry);
@@ -65,50 +86,57 @@ static gint     gimp_unit_entry_input           (GtkSpinButton          *spinbut
 static void     gimp_unit_entry_populate_popup  (GtkEntry               *entry,
                                                  GtkMenu                *menu,
                                                  gpointer                user_data); 
-static void     gimp_unit_entry_menu_item       (GtkWidget              *menuItem,
+static void     gimp_unit_entry_menu_item       (GtkWidget              *menu_item,
                                                  gpointer               *user_data);
 static gboolean gimp_unit_entry_timer_callback  (GtkWidget              *entry);                                               
 
 static void
-gimp_unit_entry_init (GimpUnitEntry *unitEntry)
+gimp_unit_entry_init (GimpUnitEntry *unit_entry)
 { 
-  /* create and set our adjustment subclass */
-  GObject *adjustment = gimp_unit_adjustment_new ();
+  GimpUnitEntryPrivate *private;
+
+  unit_entry->private = G_TYPE_INSTANCE_GET_PRIVATE (unit_entry,
+                                                     GIMP_TYPE_UNIT_ENTRY,
+                                                     GimpUnitEntryPrivate);
+
+  private = GIMP_UNIT_ENTRY_GET_PRIVATE (unit_entry);                                                   
 
-  unitEntry->unitAdjustment = GIMP_UNIT_ADJUSTMENT (adjustment);
-  gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (unitEntry), 
-                                  GTK_ADJUSTMENT  (adjustment));
+  /* create and set our adjustment subclass */
+  private->unit_adjustment = gimp_unit_adjustment_new ();
+  gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (unit_entry), 
+                                  GTK_ADJUSTMENT  (private->unit_adjustment));
 
   /* some default values */
-  unitEntry->dontUpdateText = FALSE;  
-  unitEntry->mode           = GIMP_UNIT_ENTRY_MODE_UNIT;  
-  unitEntry->input_valid    = TRUE; 
-  unitEntry->timer          = NULL;                            
+  private->dont_update_text = FALSE;  
+  private->mode             = GIMP_UNIT_ENTRY_MODE_UNIT;  
+  private->input_valid      = TRUE; 
+  private->timer            = NULL;                            
 
   /* connect signals */
-  g_signal_connect (&unitEntry->parent_instance, 
+  g_signal_connect (&unit_entry->parent_instance, 
                     "output",
                     G_CALLBACK(gimp_unit_entry_output), 
-                    (gpointer) adjustment);
-  g_signal_connect (&unitEntry->parent_instance, 
+                    (gpointer) gimp_unit_entry_get_adjustment (unit_entry));
+  g_signal_connect (&unit_entry->parent_instance, 
                     "input",
                     G_CALLBACK(gimp_unit_entry_input), 
-                    (gpointer) unitEntry);
-  g_signal_connect (&unitEntry->parent_instance.entry,
+                    (gpointer) unit_entry);
+  g_signal_connect (&unit_entry->parent_instance.entry,
                     "changed",
                     G_CALLBACK(gimp_unit_entry_text_changed), 
-                    (gpointer) unitEntry);
-  g_signal_connect (&unitEntry->parent_instance.entry,
+                    (gpointer) unit_entry);
+  g_signal_connect (&unit_entry->parent_instance.entry,
                     "populate-popup",
                     G_CALLBACK(gimp_unit_entry_populate_popup), 
                     NULL);
 
-  gtk_widget_set_size_request (GTK_WIDGET (unitEntry), UNIT_ENTRY_SIZE_REQUEST, -1);
+  gtk_widget_set_size_request (GTK_WIDGET (unit_entry), UNIT_ENTRY_SIZE_REQUEST, -1);
 }
 
 static void
 gimp_unit_entry_class_init (GimpUnitEntryClass *class)
 {
+  g_type_class_add_private (class, sizeof (GimpUnitEntryPrivate));
 }
 
 GtkWidget*
@@ -122,7 +150,9 @@ gimp_unit_entry_new (void)
 GimpUnitAdjustment*
 gimp_unit_entry_get_adjustment (GimpUnitEntry *entry)
 {
-  return entry->unitAdjustment;
+  GimpUnitEntryPrivate *private = GIMP_UNIT_ENTRY_GET_PRIVATE (entry);
+
+  return private->unit_adjustment;
 }
 
 /* connect to another entry */
@@ -130,21 +160,24 @@ void
 gimp_unit_entry_connect (GimpUnitEntry *entry, 
                          GimpUnitEntry *target)
 {
-  gimp_unit_adjustment_connect (entry->unitAdjustment, target->unitAdjustment);
+  gimp_unit_adjustment_follow_unit_of (gimp_unit_entry_get_adjustment (entry),
+                                       gimp_unit_entry_get_adjustment (target));
 }
 
 /* read and parse entered text */
 static gboolean
 gimp_unit_entry_parse (GimpUnitEntry *entry)
 {
+  GimpUnitEntryPrivate *private         = GIMP_UNIT_ENTRY_GET_PRIVATE (entry);
   GimpUnitParserResult result; 
   gboolean             success;
-  const gchar          *str = gtk_entry_get_text (GTK_ENTRY (entry));
+  const gchar          *str             = gtk_entry_get_text (GTK_ENTRY (entry));
+  GimpUnitAdjustment   *unit_adjustment = gimp_unit_entry_get_adjustment (entry);
 
   /* set resolution (important for correct calculation of px) */
-  result.resolution = entry->unitAdjustment->resolution;
+  result.resolution = gimp_unit_adjustment_get_resolution (unit_adjustment);
   /* set unit (we want to use current unit if the user didn't enter one) */
-  result.unit = entry->unitAdjustment->unit;
+  result.unit = gimp_unit_adjustment_get_unit (unit_adjustment);
 
   /* parse string of entry */
   success = gimp_unit_parser_parse (str, &result);
@@ -153,31 +186,31 @@ gimp_unit_entry_parse (GimpUnitEntry *entry)
   {
     /* reset color */
     gtk_widget_modify_base (GTK_WIDGET (entry), GTK_STATE_NORMAL, NULL);
-    entry->input_valid = TRUE;
+    private->input_valid = TRUE;
 
     /* set new unit */  
-    if (result.unit != entry->unitAdjustment->unit)
+    if (result.unit != gimp_unit_adjustment_get_unit (unit_adjustment))
     {
-      gimp_unit_adjustment_set_unit (entry->unitAdjustment, result.unit);
+      gimp_unit_adjustment_set_unit (gimp_unit_entry_get_adjustment (entry), result.unit);
     }
 
     /* set new value */
-    if (gimp_unit_adjustment_get_value (entry->unitAdjustment) != result.value)
+    if (result.value != gimp_unit_adjustment_get_value (gimp_unit_entry_get_adjustment (entry)))
     {
       /* result from parser is in inch, so convert to desired unit */
       result.value = gimp_units_to_pixels (result.value,
-                                            GIMP_UNIT_INCH,
-                                            entry->unitAdjustment->resolution);
+                                           GIMP_UNIT_INCH,
+                                           gimp_unit_adjustment_get_resolution (unit_adjustment));
       result.value = gimp_pixels_to_units (result.value,
-                                            entry->unitAdjustment->unit, 
-                                            entry->unitAdjustment->resolution);
+                                           gimp_unit_adjustment_get_unit (unit_adjustment), 
+                                           gimp_unit_adjustment_get_resolution (unit_adjustment));
 
-      gimp_unit_adjustment_set_value (entry->unitAdjustment, result.value);
+      gimp_unit_adjustment_set_value (gimp_unit_entry_get_adjustment (entry), result.value);
     }
   }
   else
   {
-    entry->input_valid = FALSE;
+    private->input_valid = FALSE;
     return FALSE;
   }
 
@@ -189,33 +222,34 @@ static gboolean
 gimp_unit_entry_output (GtkSpinButton *spin,
                         gpointer       data)
 {
-  GimpUnitAdjustment *adj         = GIMP_UNIT_ADJUSTMENT (data);
-  GimpUnitEntry      *entry       = GIMP_UNIT_ENTRY (spin); 
-  gchar              *adj_string;
-  gchar               res_string [UNIT_ENTRY_STRING_LENGTH];
+  GimpUnitAdjustment   *adj         = GIMP_UNIT_ADJUSTMENT (data);
+  GimpUnitEntry        *entry       = GIMP_UNIT_ENTRY (spin); 
+  GimpUnitEntryPrivate *private     = GIMP_UNIT_ENTRY_GET_PRIVATE (entry);
+  gchar                *output      = NULL;
+  gchar                 resolution_mode_output [UNIT_ENTRY_STRING_LENGTH];
 
   /* if updating disabled => return (user input must not be overwritten) */
-  if (entry->dontUpdateText)
+  if (private->dont_update_text)
   {
     return TRUE;
   }
   
   /* set text of the entry */
-  if (entry->mode == GIMP_UNIT_ENTRY_MODE_UNIT)
+  if (private->mode == GIMP_UNIT_ENTRY_MODE_UNIT)
   {
-    adj_string = gimp_unit_adjustment_to_string (adj);
-    gtk_entry_set_text (GTK_ENTRY (entry), adj_string);
-    g_free (adj_string);
+    output = gimp_unit_entry_to_string (entry);
+    gtk_entry_set_text (GTK_ENTRY (entry), output);
+    g_free (output);
   }
   else
   {
-    snprintf (res_string, UNIT_ENTRY_STRING_LENGTH, "%.1f px/%s", 
+    snprintf (resolution_mode_output, UNIT_ENTRY_STRING_LENGTH, "%.1f px/%s", 
               gimp_unit_adjustment_get_value (adj),
               gimp_unit_get_abbreviation (gimp_unit_adjustment_get_unit (adj)));
-    gtk_entry_set_text (GTK_ENTRY (entry), res_string);
+    gtk_entry_set_text (GTK_ENTRY (entry), resolution_mode_output);
   }
 
-  DEBUG (("on_output: %s\n", text);)
+  DEBUG (("on_output: %s\n", output);)
 
   return TRUE;
 }
@@ -225,7 +259,8 @@ static void
 gimp_unit_entry_text_changed (GtkEditable *editable, 
                               gpointer     user_data)
 {
-  GimpUnitEntry *entry = GIMP_UNIT_ENTRY (user_data);
+  GimpUnitEntry        *entry   = GIMP_UNIT_ENTRY (user_data);
+  GimpUnitEntryPrivate *private = GIMP_UNIT_ENTRY_GET_PRIVATE (entry);
 
   DEBUG (("on_text_changed\n");)
 
@@ -233,41 +268,45 @@ gimp_unit_entry_text_changed (GtkEditable *editable,
   if (gtk_widget_has_focus (GTK_WIDGET (entry)))
   {
     /* if timer exists, reset */
-    if (entry->timer != NULL)
+    if (private->timer != NULL)
     {
-      g_source_destroy (entry->timer);
+      g_source_destroy (private->timer);
     }
     /* create timer */
-    entry->timer = g_timeout_source_new_seconds (UNIT_ENTRY_ERROR_TIMEOUT);
-    g_source_set_callback (entry->timer, 
+    private->timer = g_timeout_source_new_seconds (UNIT_ENTRY_ERROR_TIMEOUT);
+    g_source_set_callback (private->timer, 
                            (GSourceFunc) gimp_unit_entry_timer_callback,
                            (gpointer) entry,
                            NULL);
-    g_source_attach (entry->timer, NULL);
+    g_source_attach (private->timer, NULL);
   }
 
-  if (!entry->mode == GIMP_UNIT_ENTRY_MODE_RESOLUTION)
+  if (!private->mode == GIMP_UNIT_ENTRY_MODE_RESOLUTION)
   {
     /* disable updating the displayed text (user input must not be overwriten) */
-    entry->dontUpdateText = TRUE;
+    private->dont_update_text = TRUE;
     /* parse input */
     gimp_unit_entry_parse (entry);
     /* reenable updating */
-    entry->dontUpdateText = FALSE;
+    private->dont_update_text = FALSE;
   }
 }
 
 static gint
-gimp_unit_entry_input (GtkSpinButton *spinButton,
+gimp_unit_entry_input (GtkSpinButton *spin_button,
                        gpointer       arg1,
                        gpointer       user_data)
 {
-  if (!GIMP_UNIT_ENTRY (spinButton)->mode == GIMP_UNIT_ENTRY_MODE_RESOLUTION)
+  GimpUnitEntry        *entry   = GIMP_UNIT_ENTRY (spin_button);
+  GimpUnitEntryPrivate *private = GIMP_UNIT_ENTRY_GET_PRIVATE (entry);
+  
+  if (!private->mode == GIMP_UNIT_ENTRY_MODE_RESOLUTION)
   {
     /* parse and set value ourselves before GtkSpinButton does so, because
-       GtkSpinButton would truncate our input and ignore parts of it */
-    gimp_unit_entry_parse (GIMP_UNIT_ENTRY (spinButton));
-    gimp_unit_entry_output (spinButton, (gpointer)GIMP_UNIT_ENTRY(spinButton)->unitAdjustment);
+       GtkSpinButton would truncate our input and ignore everything which 
+       is not a numbner */
+    gimp_unit_entry_parse (GIMP_UNIT_ENTRY (spin_button));
+    gimp_unit_entry_output (spin_button, (gpointer) gimp_unit_entry_get_adjustment (entry));
   }
 
   /* we want GtkSpinButton to handle the input nontheless (there is no problem anymore
@@ -278,18 +317,18 @@ gimp_unit_entry_input (GtkSpinButton *spinButton,
 static gboolean 
 gimp_unit_entry_timer_callback  (GtkWidget *entry)                                   
 {
-  GimpUnitEntry *unit_entry = GIMP_UNIT_ENTRY (entry);
+  GimpUnitEntryPrivate *private = GIMP_UNIT_ENTRY_GET_PRIVATE (GIMP_UNIT_ENTRY (entry));
 
   /* paint entry red if input is invalid */
-  if (!unit_entry->input_valid)
+  if (!private->input_valid)
   {
     GdkColor color;
     gdk_color_parse (UNIT_ENTRY_ERROR_COLOR, &color);
-    gtk_widget_modify_base (GTK_WIDGET (entry), GTK_STATE_NORMAL, &color);
+    gtk_widget_modify_base (entry, GTK_STATE_NORMAL, &color);
   }
 
   /* delete timer */
-  unit_entry->timer = NULL;
+  private->timer = NULL;
 
   return FALSE;
 }
@@ -299,45 +338,45 @@ gimp_unit_entry_populate_popup (GtkEntry *entry,
                                 GtkMenu  *menu,
                                 gpointer  user_data)
 {
-  GtkWidget *menuItem;
-  int       i = 0;
+  GimpUnitEntryPrivate *private = GIMP_UNIT_ENTRY_GET_PRIVATE (GIMP_UNIT_ENTRY (entry));
+  GtkWidget *menu_item;
+  gint       i                  = 0;
+  gint       first_unit;
 
-  /* populate popup with item for each available unit */
-  menuItem = gtk_separator_menu_item_new ();
-  gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuItem);
+  menu_item = gtk_separator_menu_item_new ();
+  gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
 
   /* ignore PIXEL when in resolution mode */
-  (GIMP_UNIT_ENTRY (entry)->mode == GIMP_UNIT_ENTRY_MODE_RESOLUTION) ? (i = 1) : (i = 0); 
+  (private->mode == GIMP_UNIT_ENTRY_MODE_RESOLUTION) 
+      ? (first_unit = 1) : (first_unit = 0); 
 
-  for (; i < gimp_unit_get_number_of_units(); i++)
+  /* populate popup with item for each available unit 
+     (reversing iteration order to display commonly used units first) */
+  for (i = gimp_unit_get_number_of_units() - 1; i >= first_unit; i--)
   {
-    menuItem = gtk_menu_item_new_with_label (gimp_unit_get_singular (i));
-    gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuItem);
+    menu_item = gtk_menu_item_new_with_label (gimp_unit_get_singular (i));
+    gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
 
     /* save corresponding unit in menu item */
-    g_object_set_data (G_OBJECT (menuItem), "unit", GINT_TO_POINTER (i));
+    g_object_set_data (G_OBJECT (menu_item), "unit", GINT_TO_POINTER (i));
 
-    g_signal_connect(menuItem, "activate",
+    g_signal_connect(menu_item, "activate",
                      (GCallback) gimp_unit_entry_menu_item, 
                      gimp_unit_entry_get_adjustment (GIMP_UNIT_ENTRY (entry)));
   }
 
-  menuItem = gtk_menu_item_new_with_label ("Set Unit:");
-  gtk_widget_set_sensitive (menuItem, FALSE);
-  gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuItem);
-
   gtk_widget_show_all (GTK_WIDGET (menu));
 }
 
 static void
-gimp_unit_entry_menu_item      (GtkWidget *menuItem,
+gimp_unit_entry_menu_item      (GtkWidget *menu_item,
                                 gpointer  *user_data)
 {
   GimpUnitAdjustment *adj   = GIMP_UNIT_ADJUSTMENT (user_data);
   GimpUnit            unit;
               
   /* get selected unit */
-  unit = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menuItem), "unit"));
+  unit = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "unit"));
 
   /* change unit according to selected unit */
   gimp_unit_adjustment_set_unit (adj, unit);
@@ -408,11 +447,11 @@ gimp_unit_entry_get_unit (GimpUnitEntry *entry)
 void
 gimp_unit_entry_set_bounds (GimpUnitEntry *entry, 
                             GimpUnit       unit, 
-                            gdouble        upper,
-                            gdouble        lower)
+                            gdouble        lower,
+                            gdouble        upper)
 {
   GimpUnitAdjustment *adj = gimp_unit_entry_get_adjustment (entry);
-  gimp_unit_adjustment_set_bounds (adj, unit, upper, lower);
+  gimp_unit_adjustment_set_bounds (adj, unit, lower, upper);
 }
 
 void
@@ -426,5 +465,34 @@ void
 gimp_unit_entry_set_mode (GimpUnitEntry     *entry,
                           GimpUnitEntryMode  mode)
 {
-  entry->mode = mode;
+  GimpUnitEntryPrivate *private = GIMP_UNIT_ENTRY_GET_PRIVATE (entry);
+
+  private->mode = mode;
+}
+
+/* get string in format "value unit" */
+gchar* 
+gimp_unit_entry_to_string (GimpUnitEntry *entry)
+{
+  return gimp_unit_entry_to_string_in_unit (
+           entry, 
+           gimp_unit_adjustment_get_unit (gimp_unit_entry_get_adjustment (entry)));
 }
+
+gchar*  
+gimp_unit_entry_to_string_in_unit (GimpUnitEntry *entry, 
+                                   GimpUnit       unit)
+{
+  gdouble value;
+  gchar *text = g_malloc (sizeof (gchar) * UNIT_ENTRY_STRING_LENGTH);
+
+  value = gimp_unit_adjustment_get_value_in_unit (gimp_unit_entry_get_adjustment (entry),
+                                                  unit);
+
+  g_snprintf (text, UNIT_ENTRY_STRING_LENGTH, "%.*f %s", 
+             gimp_unit_get_digits (unit),
+             value,
+             gimp_unit_get_abbreviation (unit));
+
+  return text;
+}       
diff --git a/libgimpwidgets/gimpunitentry.h b/libgimpwidgets/gimpunitentry.h
index 96ec627..50d90f3 100644
--- a/libgimpwidgets/gimpunitentry.h
+++ b/libgimpwidgets/gimpunitentry.h
@@ -48,20 +48,7 @@ struct _GimpUnitEntry
 {
   GtkSpinButton parent_instance;
 
-  /* private */
-  GimpUnitAdjustment *unitAdjustment; /* for convinience */
-
-  /* flag set TRUE when entry's text should not be overwritten
-     (i.e. during user input) */
-  gboolean            dontUpdateText;
-
-  /* input mode */
-  GimpUnitEntryMode   mode;
-
-  /* is our input valid? (for error indication) */
-  gboolean            input_valid;
-  /* the timer source which handles the error indication */
-  GSource             *timer;
+  gpointer      private;
 };
 
 struct _GimpUnitEntryClass
@@ -95,7 +82,11 @@ void                  gimp_unit_entry_set_value_in_unit (GimpUnitEntry      *ent
                                                          gdouble             value, 
                                                          GimpUnit            unit);
 void                  gimp_unit_entry_set_pixels        (GimpUnitEntry      *entry,
-                                                         gdouble             value);                                                           
+                                                         gdouble             value);
+                                                         
+gchar*                gimp_unit_entry_to_string         (GimpUnitEntry      *entry);
+gchar*                gimp_unit_entry_to_string_in_unit (GimpUnitEntry      *entry, 
+                                                         GimpUnit            unit);                                                                                                                    
                                                          
 void                  gimp_unit_entry_connect           (GimpUnitEntry      *entry, 
                                                          GimpUnitEntry      *target);                                                                                                               
diff --git a/libgimpwidgets/gimpunitparser.c b/libgimpwidgets/gimpunitparser.c
index 72ebc8a..37693b2 100644
--- a/libgimpwidgets/gimpunitparser.c
+++ b/libgimpwidgets/gimpunitparser.c
@@ -31,10 +31,6 @@
 #define DEBUG(x) /* nothing */
 #endif
 
-/**
- * prototypes
- */
-
 /* unit resolver for GimpEevl */
 static gboolean unit_resolver (const gchar      *ident,
                                GimpEevlQuantity *result,
@@ -46,38 +42,38 @@ gboolean
 gimp_unit_parser_parse (const char *str, GimpUnitParserResult *result)
 {
   /* GimpEevl related stuff */
-  GimpEevlQuantity  eevlResult;
+  GimpEevlQuantity  eevl_result;
   GError            *error    = NULL;
   const gchar       *errorpos = 0;
 
   if (strlen (str) <= 0)
     return FALSE;
     
-  /* set unitFound to FALSE so we can determine the first unit the user entered and use that
+  /* set unit_found to FALSE so we can determine the first unit the user entered and use that
      as unit for our result */
-  result->unitFound = FALSE;
+  result->unit_found = FALSE;
 
   DEBUG (("parsing: %s", str));
 
   /* parse text via GimpEevl */
   gimp_eevl_evaluate (str,
                       unit_resolver,
-                      &eevlResult,
+                      &eevl_result,
                       (gpointer) result,
                       &errorpos,
                       &error);
 
-  if (error || errorpos || eevlResult.dimension > 1)
+  if (error || errorpos || eevl_result.dimension > 1)
   {
     DEBUG (("gimpeevl parsing error \n"));
     return FALSE;
   }
   else
   {
-    DEBUG (("gimpeevl parser result: %s = %lg (%d)", str, eevlResult.value, eevlResult.dimension));
+    DEBUG (("gimpeevl parser result: %s = %lg (%d)", str, eevl_result.value, eevl_result.dimension));
     DEBUG (("determined unit: %s\n", gimp_unit_get_abbreviation (result->unit)));
 
-    result->value = eevlResult.value;
+    result->value = eevl_result.value;
   }
 
   return TRUE;
@@ -89,11 +85,11 @@ gboolean unit_resolver (const gchar      *ident,
                         GimpEevlQuantity *result,
                         gpointer          user_data)
 {
-  GimpUnitParserResult   *parserResult = (GimpUnitParserResult*) user_data;
-  GimpUnit               *unit        = &(parserResult->unit);
+  GimpUnitParserResult   *parser_result = (GimpUnitParserResult*) user_data;
+  GimpUnit               *unit        = &(parser_result->unit);
   gboolean               resolved     = FALSE;
   gboolean               default_unit = (ident == NULL);
-  gint                   numUnits     = gimp_unit_get_number_of_units ();
+  gint                   num_units    = gimp_unit_get_number_of_units ();
   const gchar            *abbr; 
   gint                   i            = 0;
 
@@ -110,17 +106,18 @@ gboolean unit_resolver (const gchar      *ident,
     result->dimension = 1;
 
     if (*unit == GIMP_UNIT_PIXEL) /* handle case that unit is px */
-      result->value = parserResult->resolution;
-    else                          /* otherwise use factor */
+      result->value = parser_result->resolution;
+    else                          /* otherwise use unit factor */
       result->value = gimp_unit_get_factor (*unit);
 
-    parserResult->unitFound = TRUE;
-    resolved                = TRUE; 
+    parser_result->unit_found = TRUE;
+    resolved                  = TRUE; 
+    
     return resolved;
   }
 
   /* find matching unit */
-  for (i = 0; i < numUnits; i++)
+  for (i = 0; i < num_units; i++)
   {
     abbr = gimp_unit_get_abbreviation (i);
 
@@ -128,17 +125,17 @@ gboolean unit_resolver (const gchar      *ident,
     {
       /* handle case that unit is px */
       if (i == GIMP_UNIT_PIXEL)
-        result->value = parserResult->resolution;
+        result->value = parser_result->resolution;
       else
         result->value = gimp_unit_get_factor (i);
 
-      if (!parserResult->unitFound)
+      if (!parser_result->unit_found)
       {
         *unit = i;
-        parserResult->unitFound = TRUE;
+        parser_result->unit_found = TRUE;
       }
 
-      i = numUnits;
+      i = num_units;
       resolved = TRUE;
     }
   }
diff --git a/libgimpwidgets/gimpunitparser.h b/libgimpwidgets/gimpunitparser.h
index 1f32413..230986f 100644
--- a/libgimpwidgets/gimpunitparser.h
+++ b/libgimpwidgets/gimpunitparser.h
@@ -32,7 +32,7 @@ struct _GimpUnitParserResult
   gdouble   value;
   gdouble   resolution;
   GimpUnit  unit;
-  gboolean  unitFound;
+  gboolean  unit_found;
 };
 
 gboolean gimp_unit_parser_parse (const char *str, GimpUnitParserResult *result);
diff --git a/libgimpwidgets/gimpwidgets.def b/libgimpwidgets/gimpwidgets.def
index a1ae384..d57f939 100644
--- a/libgimpwidgets/gimpwidgets.def
+++ b/libgimpwidgets/gimpwidgets.def
@@ -365,8 +365,6 @@ EXPORTS
 	gimp_unit_adjustment_set_unit
 	gimp_unit_adjustment_set_value
 	gimp_unit_adjustment_set_value_in_unit
-	gimp_unit_adjustment_to_string
-	gimp_unit_adjustment_to_string_in_unit
 	gimp_unit_combo_box_get_active
 	gimp_unit_combo_box_get_type
 	gimp_unit_combo_box_new
@@ -374,7 +372,6 @@ EXPORTS
 	gimp_unit_combo_box_set_active
 	gimp_unit_entries_add_chain_button
 	gimp_unit_entries_add_entry
-	gimp_unit_entries_add_entry_defaults
 	gimp_unit_entries_add_preview_label
 	gimp_unit_entries_get_chain_button
 	gimp_unit_entries_get_entry
@@ -409,6 +406,8 @@ EXPORTS
 	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
 	gimp_unit_menu_get_type
 	gimp_unit_menu_get_unit
diff --git a/libgimpwidgets/test-unitentrygui.c b/libgimpwidgets/test-unitentrygui.c
index f16dfcb..077dcda 100644
--- a/libgimpwidgets/test-unitentrygui.c
+++ b/libgimpwidgets/test-unitentrygui.c
@@ -41,8 +41,8 @@ create_interface(void)
 
   /* entry table */
   entries = GIMP_UNIT_ENTRIES (gimp_unit_entries_new ());
-  gimp_unit_entries_add_entry_defaults (entries, "width", "Width");
-  gimp_unit_entries_add_entry_defaults (entries, "height", "Height");
+  gimp_unit_entries_add_entry (entries, "width", "Width");
+  gimp_unit_entries_add_entry (entries, "height", "Height");
   gimp_unit_entries_add_preview_label (entries, GIMP_UNIT_PIXEL, "width", "height");
 
   gimp_unit_entries_add_chain_button (entries, "width", "height");
@@ -53,12 +53,12 @@ create_interface(void)
   gimp_unit_adjustment_set_value (gimp_unit_entry_get_adjustment (a), 20);
   gimp_unit_adjustment_set_value (gimp_unit_entry_get_adjustment (b), 20);
 
-  gtk_box_pack_start (GTK_BOX (vbox), entries->table, FALSE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), gimp_unit_entries_get_table (entries), FALSE, TRUE, 0);
 
   /* resolution entry */
   entries = GIMP_UNIT_ENTRIES (gimp_unit_entries_new ());
-  gimp_unit_entries_add_entry_defaults (entries, "xres", "X Resolution");
-  gimp_unit_entries_add_entry_defaults (entries, "yres", "Y Resolution");
+  gimp_unit_entries_add_entry (entries, "xres", "X Resolution");
+  gimp_unit_entries_add_entry (entries, "yres", "Y Resolution");
 
   /* set some default values */
   a = gimp_unit_entries_get_entry (entries, "xres");
@@ -68,7 +68,7 @@ create_interface(void)
   gimp_unit_entry_set_mode (a, GIMP_UNIT_ENTRY_MODE_RESOLUTION);
   gimp_unit_entry_set_mode (b, GIMP_UNIT_ENTRY_MODE_RESOLUTION);
 
-  gtk_box_pack_end (GTK_BOX (vbox), entries->table, FALSE, TRUE, 5);
+  gtk_box_pack_end (GTK_BOX (vbox), gimp_unit_entries_get_table (entries), FALSE, TRUE, 5);
 
   /* signals */
   g_signal_connect_swapped (G_OBJECT(window), "destroy",



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