42 #include "gnc-locale-utils.h" 48 static QofLogModule log_module = GNC_MOD_REGISTER;
51 gnc_cell_name_equal (
const char * cell_name_1,
52 const char * cell_name_2)
54 return (g_strcmp0 (cell_name_1, cell_name_2) == 0);
58 gnc_basic_cell_new (
void)
62 cell = g_new0 (BasicCell, 1);
64 gnc_basic_cell_init (cell);
70 gnc_basic_cell_clear (BasicCell *cell)
72 g_free (cell->cell_name);
73 cell->cell_name = NULL;
74 g_free (cell->cell_type_name);
75 cell->cell_type_name = NULL;
76 cell->changed = FALSE;
77 cell->conditionally_changed = FALSE;
80 cell->value_chars = 0;
82 cell->set_value = NULL;
83 cell->enter_cell = NULL;
84 cell->modify_verify = NULL;
85 cell->direct_update = NULL;
86 cell->leave_cell = NULL;
87 cell->gui_realize = NULL;
88 cell->gui_move = NULL;
89 cell->gui_destroy = NULL;
91 cell->is_popup = FALSE;
93 cell->gui_private = NULL;
95 g_free (cell->sample_text);
96 cell->sample_text = NULL;
100 gnc_basic_cell_init (BasicCell *cell)
102 gnc_basic_cell_clear (cell);
104 cell->value = g_strdup (
"");
108 gnc_basic_cell_destroy (BasicCell *cell)
112 cell->destroy (cell);
115 if (cell->gui_destroy)
116 (*(cell->gui_destroy)) (cell);
119 g_free (cell->value);
123 gnc_basic_cell_clear (cell);
131 gnc_basic_cell_set_name (BasicCell *cell,
const char *name)
134 if (cell->cell_name == name)
return;
136 g_free (cell->cell_name);
137 cell->cell_name = g_strdup (name);
141 gnc_basic_cell_has_name (BasicCell *cell,
const char *name)
143 if (!cell)
return FALSE;
144 if (!name)
return FALSE;
145 if (!cell->cell_name)
return FALSE;
147 return (strcmp (name, cell->cell_name) == 0);
152 gnc_basic_cell_set_type_name (BasicCell *cell,
const gchar *type_name)
155 if (cell->cell_type_name == type_name)
return;
157 g_free (cell->cell_type_name);
158 cell->cell_type_name = g_strdup(type_name);
162 gnc_basic_cell_has_type_name (BasicCell *cell,
const gchar *type_name)
164 if (!cell)
return FALSE;
165 if (!type_name)
return FALSE;
166 if (!cell->cell_type_name)
return FALSE;
168 return (g_strcmp0 (type_name, cell->cell_type_name));
172 gnc_basic_cell_set_sample_text (BasicCell *cell,
173 const char *sample_text)
176 if (cell->sample_text == sample_text)
return;
178 g_free (cell->sample_text);
179 cell->sample_text = g_strdup (sample_text);
183 gnc_basic_cell_set_alignment (BasicCell *cell,
184 CellAlignment alignment)
187 cell->alignment = alignment;
191 gnc_basic_cell_set_expandable (BasicCell *cell, gboolean expandable)
194 cell->expandable = expandable;
198 gnc_basic_cell_set_span (BasicCell *cell, gboolean span)
205 gnc_basic_cell_get_value (BasicCell *cell)
207 g_return_val_if_fail (cell != NULL, NULL);
213 gnc_basic_cell_set_value (BasicCell *cell,
const char *val)
217 cb = cell->set_value;
222 cell->set_value = NULL;
224 cell->set_value = cb;
227 gnc_basic_cell_set_value_internal (cell, val);
231 gnc_basic_cell_get_changed (BasicCell *cell)
233 if (!cell)
return FALSE;
235 return cell->changed;
239 gnc_basic_cell_get_conditionally_changed (BasicCell *cell)
241 if (!cell)
return FALSE;
243 return cell->conditionally_changed;
247 gnc_basic_cell_set_changed (BasicCell *cell, gboolean changed)
251 cell->changed = changed;
255 gnc_basic_cell_set_conditionally_changed (BasicCell *cell, gboolean changed)
259 cell->conditionally_changed = changed;
263 gnc_basic_cell_set_value_internal (BasicCell *cell,
const char *value)
273 if (cell->value == value)
276 g_free (cell->value);
277 cell->value = g_strdup (value);
278 cell->value_chars = g_utf8_strlen(value, -1);
283 const char *change,
const char *newval,
284 const char *toks, gint *cursor_position)
286 struct lconv *lc = gnc_localeconv ();
287 gunichar decimal_point;
288 gunichar thousands_sep;
289 const char *symbol = NULL;
292 if (print_info.monetary)
294 const gnc_commodity *comm = print_info.commodity;
296 decimal_point = g_utf8_get_char (lc->mon_decimal_point);
297 thousands_sep = g_utf8_get_char (lc->mon_thousands_sep);
304 tokens = g_strconcat (toks, symbol, NULL);
308 decimal_point = g_utf8_get_char (lc->decimal_point);
309 thousands_sep = g_utf8_get_char (lc->thousands_sep);
311 tokens = g_strdup (toks);
314 for (
const char *c = change; c && *c; c = g_utf8_next_char (c))
316 gunichar uc = g_utf8_get_char (c);
317 if (!g_unichar_isdigit (uc) &&
318 !g_unichar_isspace (uc) &&
319 !g_unichar_isalpha (uc) &&
320 (decimal_point != uc) &&
321 (thousands_sep != uc) &&
322 (g_utf8_strchr (tokens, -1, uc) == NULL))
#define ENTER(format, args...)
Print a function entry debugging message.
gnc_commodity * gnc_default_currency(void)
Return the default currency set by the user.
void gnc_filter_text_set_cursor_position(const char *incoming_text, const char *symbol, int *zcursor_position)
Updates cursor_position after removal of currency symbols.
const char * gnc_commodity_get_nice_symbol(const gnc_commodity *cm)
Retrieve a symbol for the specified commodity, suitable for display to the user.
All type declarations for the whole Gnucash engine.
char * gnc_filter_text_for_currency_symbol(const char *incoming_text, const char *symbol)
Returns the incoming text removed of a currency symbol.
#define LEAVE(format, args...)
Print a function exit debugging message.