From 9d81248e5f66bdefeedebe7642feb8e21f200950 Mon Sep 17 00:00:00 2001 From: Mikael Hallendal Date: Fri, 13 Apr 2001 01:58:14 +0000 Subject: Added e-table/e-cell-spin-button.lo Added e-table/e-cell-float.lo 2001-04-13 Mikael Hallendal * gal/Makefile.am (libgal_la_LIBADD): Added e-table/e-cell-spin-button.lo Added e-table/e-cell-float.lo * gal/util/e-util.[ch] (e_format_number_float): Added function to format floats. Uses e_format_number for the integer part. (e_marshal_NONE__POINTER_INT_INT_INT): Added used by gal/e-table/e-cell-spin-button.c svn path=/trunk/; revision=9295 --- e-util/e-util.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ e-util/e-util.h | 7 +++++++ 2 files changed, 64 insertions(+) diff --git a/e-util/e-util.c b/e-util/e-util.c index 204a2c3ad9..5bbb9522b4 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -661,6 +661,23 @@ e_marshal_INT__POINTER_POINTER_POINTER_POINTER (GtkObject *object, func_data); } + +void +e_marshal_NONE__POINTER_INT_INT_INT (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args) +{ + (* (void (*)(GtkObject *, gpointer, int, int, int, gpointer)) func) + (object, + GTK_VALUE_POINTER (args[0]), + GTK_VALUE_INT (args[1]), + GTK_VALUE_INT (args[2]), + + GTK_VALUE_INT (args[3]), + func_data); +} + gchar** e_strsplit (const gchar *string, const gchar *delimiter, @@ -825,6 +842,46 @@ e_format_number (gint number) } } +gchar * +e_format_number_float (gfloat number) +{ + gint int_part; + gint fraction; + struct lconv *locality; + gchar *str_intpart; + gchar *decimal_point; + gchar *str_fraction; + gchar *value; + + locality = localeconv(); + + int_part = (int) number; + str_intpart = e_format_number (int_part); + + if (!strcmp(locality->mon_decimal_point, "")) { + decimal_point = "."; + } + else { + decimal_point = locality->mon_decimal_point; + } + + fraction = (int) ((number - int_part) * 100); + + if (fraction == 0) { + str_fraction = g_strdup ("00"); + } + else { + str_fraction = g_strdup_printf ("%02d", fraction); + } + + value = g_strconcat (str_intpart, decimal_point, str_fraction, NULL); + + g_free (str_intpart); + g_free (str_fraction); + + return value; +} + gboolean e_create_directory (gchar *directory) { diff --git a/e-util/e-util.h b/e-util/e-util.h index 374c41693a..bf89b27aa1 100644 --- a/e-util/e-util.h +++ b/e-util/e-util.h @@ -79,6 +79,8 @@ gchar *e_strstrcase (cons const gchar *needle); void e_filename_make_safe (gchar *string); gchar *e_format_number (gint number); +gchar *e_format_number_float (gfloat number); + gboolean e_create_directory (gchar *directory); @@ -191,6 +193,11 @@ void e_marshal_INT__POINTER_POINTER_POINTER_POINTER (GtkO gpointer func_data, GtkArg *args); +void e_marshal_NONE__POINTER_INT_INT_INT (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args); + #ifdef __cplusplus } #endif /* __cplusplus */ -- cgit v1.2.3