[gimp/soc-2011-gimpunitentry: 13/68] GimpUnitEntry: Refactoring



commit 9856c2cf7bf8ef17592f83bc27f6691a809ad062
Author: Enrico Schröder <enni schroeder gmail com>
Date:   Thu Jun 9 12:52:43 2011 +0200

    GimpUnitEntry: Refactoring
    
    Some refactoring and additional convenience functions

 libgimpwidgets/gimpunitadjustment.c |    5 +++++
 libgimpwidgets/gimpunitadjustment.h |    3 ++-
 libgimpwidgets/gimpunitentry.c      |    6 ++++++
 libgimpwidgets/gimpunitentry.h      |    3 ++-
 libgimpwidgets/gimpunitentrytable.c |    3 +--
 libgimpwidgets/gimpunitentrytable.h |    2 +-
 libgimpwidgets/gimpunitparser.c     |    3 ++-
 libgimpwidgets/gimpwidgets.def      |    2 ++
 8 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/libgimpwidgets/gimpunitadjustment.c b/libgimpwidgets/gimpunitadjustment.c
index b46b8a5..9865f16 100644
--- a/libgimpwidgets/gimpunitadjustment.c
+++ b/libgimpwidgets/gimpunitadjustment.c
@@ -225,4 +225,9 @@ gimp_unit_adjustment_to_string_in_unit (GimpUnitAdjustment *adj, GimpUnit unit)
 
   return text;
 }
+GimpUnit 
+gimp_unit_adjustment_get_unit (GimpUnitAdjustment *adj)
+{
+  return adj->unit;
+}
 
diff --git a/libgimpwidgets/gimpunitadjustment.h b/libgimpwidgets/gimpunitadjustment.h
index d3e6c36..27b91af 100644
--- a/libgimpwidgets/gimpunitadjustment.h
+++ b/libgimpwidgets/gimpunitadjustment.h
@@ -75,6 +75,7 @@ gdouble gimp_unit_adjustment_get_value (GimpUnitAdjustment *adj);
 gdouble gimp_unit_adjustment_get_value_in_unit    (GimpUnitAdjustment *adj, GimpUnit unit);
 void    gimp_unit_adjustment_set_resolution (GimpUnitAdjustment *adj, gdouble res);
 gdouble gimp_unit_adjustment_get_resolution (GimpUnitAdjustment *adj);
+GimpUnit gimp_unit_adjustment_get_unit (GimpUnitAdjustment *adj);
 /* get string in format "value unit" */
 gchar*  gimp_unit_adjustment_to_string (GimpUnitAdjustment *adj);
 gchar*  gimp_unit_adjustment_to_string_in_unit (GimpUnitAdjustment *adj, GimpUnit unit);
@@ -83,4 +84,4 @@ void    gimp_unit_adjustment_connect (GimpUnitAdjustment *adj, GimpUnitAdjustmen
 
 G_END_DECLS
 
-#endif /*__GIMP_UNIT_ADJUSTMENT_H__*/
\ No newline at end of file
+#endif /*__GIMP_UNIT_ADJUSTMENT_H__*/
diff --git a/libgimpwidgets/gimpunitentry.c b/libgimpwidgets/gimpunitentry.c
index 3606486..6e2a640 100644
--- a/libgimpwidgets/gimpunitentry.c
+++ b/libgimpwidgets/gimpunitentry.c
@@ -470,3 +470,9 @@ gimp_unit_entry_get_value_in_unit (GimpUnitEntry *entry, GimpUnit unit)
   GimpUnitAdjustment *adj = gimp_unit_entry_get_adjustment (entry);
   return gimp_unit_adjustment_get_value_in_unit (adj, unit);
 }
+GimpUnit 
+gimp_unit_entry_get_unit (GimpUnitEntry *entry)
+{
+  GimpUnitAdjustment *adj = gimp_unit_entry_get_adjustment (entry);
+  return gimp_unit_adjustment_get_unit (adj);
+}
diff --git a/libgimpwidgets/gimpunitentry.h b/libgimpwidgets/gimpunitentry.h
index 00ab53e..9330747 100644
--- a/libgimpwidgets/gimpunitentry.h
+++ b/libgimpwidgets/gimpunitentry.h
@@ -76,7 +76,8 @@ void gimp_unit_entry_set_resolution (GimpUnitEntry *entry, gdouble resolution);
 void gimp_unit_entry_set_value (GimpUnitEntry *entry, gdouble resolution);
 gdouble gimp_unit_entry_get_value (GimpUnitEntry *entry);
 gdouble gimp_unit_entry_get_value_in_unit (GimpUnitEntry *entry, GimpUnit unit);
+GimpUnit gimp_unit_entry_get_unit (GimpUnitEntry *entry);
 
 G_END_DECLS
 
-#endif /*__GIMP_UNIT_ENTRY_H__*/
\ No newline at end of file
+#endif /*__GIMP_UNIT_ENTRY_H__*/
diff --git a/libgimpwidgets/gimpunitentrytable.c b/libgimpwidgets/gimpunitentrytable.c
index 7ff5a8c..178fe48 100644
--- a/libgimpwidgets/gimpunitentrytable.c
+++ b/libgimpwidgets/gimpunitentrytable.c
@@ -191,8 +191,7 @@ void label_updater (GtkAdjustment *adj, gpointer userData)
   GimpUnitEntryTable *table       = GIMP_UNIT_ENTRY_TABLE (userData);
   GimpUnitAdjustment *adjustment;
   gint                count       = g_list_length (table->entries);
-  gint                i           = 0;
-  GimpUnit            *unit;       
+  gint                i           = 0;     
 
   if (table->previewLabel == NULL || count <= 0)
     return;
diff --git a/libgimpwidgets/gimpunitentrytable.h b/libgimpwidgets/gimpunitentrytable.h
index f4f2abc..8b8b3dd 100644
--- a/libgimpwidgets/gimpunitentrytable.h
+++ b/libgimpwidgets/gimpunitentrytable.h
@@ -87,4 +87,4 @@ GimpUnitEntry* gimp_unit_entry_table_get_nth_entry (GimpUnitEntryTable *table, g
 
 G_END_DECLS
 
-#endif /*__GIMP_UNIT_ENTRY_TABLE_H__*/
\ No newline at end of file
+#endif /*__GIMP_UNIT_ENTRY_TABLE_H__*/
diff --git a/libgimpwidgets/gimpunitparser.c b/libgimpwidgets/gimpunitparser.c
index 990f16f..72ebc8a 100644
--- a/libgimpwidgets/gimpunitparser.c
+++ b/libgimpwidgets/gimpunitparser.c
@@ -52,7 +52,7 @@ gimp_unit_parser_parse (const char *str, GimpUnitParserResult *result)
 
   if (strlen (str) <= 0)
     return FALSE;
-  
+    
   /* set unitFound to FALSE so we can determine the first unit the user entered and use that
      as unit for our result */
   result->unitFound = FALSE;
@@ -98,6 +98,7 @@ gboolean unit_resolver (const gchar      *ident,
   gint                   i            = 0;
 
   result->dimension = 1;
+  DEBUG (("unit resolver: %s", ident));
 
   /* if no unit is specified, use default unit */
   if (default_unit)
diff --git a/libgimpwidgets/gimpwidgets.def b/libgimpwidgets/gimpwidgets.def
index bbbe332..638f5da 100644
--- a/libgimpwidgets/gimpwidgets.def
+++ b/libgimpwidgets/gimpwidgets.def
@@ -361,6 +361,7 @@ EXPORTS
        gimp_unit_adjustment_connect
        gimp_unit_adjustment_get_resolution
        gimp_unit_adjustment_get_type
+       gimp_unit_adjustment_get_unit
        gimp_unit_adjustment_get_value
        gimp_unit_adjustment_get_value_in_unit
        gimp_unit_adjustment_new
@@ -378,6 +379,7 @@ EXPORTS
        gimp_unit_entry_get_adjustment
        gimp_unit_entry_get_id
        gimp_unit_entry_get_type
+       gimp_unit_entry_get_unit
        gimp_unit_entry_get_value
        gimp_unit_entry_get_value_in_unit
        gimp_unit_entry_new


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