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_gui_realize (BasicCell* bcell, gpointer data)
60 bcell->gui_private = data;
61 bcell->gui_realize = NULL;
65 gnc_basic_cell_gui_destroy (BasicCell* bcell)
67 if (bcell->gui_realize == NULL)
69 bcell->gui_realize = gnc_basic_cell_gui_realize;
74 gnc_basic_cell_new (
void)
78 cell = g_new0 (BasicCell, 1);
80 gnc_basic_cell_init (cell);
86 gnc_basic_cell_clear (BasicCell *cell)
88 g_free (cell->cell_name);
89 cell->cell_name = NULL;
90 g_free (cell->cell_type_name);
91 cell->cell_type_name = NULL;
92 cell->changed = FALSE;
93 cell->conditionally_changed = FALSE;
96 cell->value_chars = 0;
98 cell->set_value = NULL;
99 cell->enter_cell = NULL;
100 cell->modify_verify = NULL;
101 cell->direct_update = NULL;
102 cell->leave_cell = NULL;
103 cell->gui_realize = NULL;
104 cell->gui_move = NULL;
105 cell->gui_destroy = NULL;
107 cell->is_popup = FALSE;
109 cell->gui_private = NULL;
111 g_free (cell->sample_text);
112 cell->sample_text = NULL;
116 gnc_basic_cell_init (BasicCell *cell)
118 gnc_basic_cell_clear (cell);
120 cell->gui_realize = gnc_basic_cell_gui_realize;
121 cell->gui_destroy = gnc_basic_cell_gui_destroy;
123 cell->value = g_strdup (
"");
127 gnc_basic_cell_destroy (BasicCell *cell)
131 cell->destroy (cell);
134 if (cell->gui_destroy)
135 (*(cell->gui_destroy)) (cell);
138 g_free (cell->value);
142 gnc_basic_cell_clear (cell);
150 gnc_basic_cell_set_name (BasicCell *cell,
const char *name)
153 if (cell->cell_name == name)
return;
155 g_free (cell->cell_name);
156 cell->cell_name = g_strdup (name);
160 gnc_basic_cell_has_name (BasicCell *cell,
const char *name)
162 if (!cell)
return FALSE;
163 if (!name)
return FALSE;
164 if (!cell->cell_name)
return FALSE;
166 return (strcmp (name, cell->cell_name) == 0);
171 gnc_basic_cell_set_type_name (BasicCell *cell,
const gchar *type_name)
174 if (cell->cell_type_name == type_name)
return;
176 g_free (cell->cell_type_name);
177 cell->cell_type_name = g_strdup(type_name);
181 gnc_basic_cell_has_type_name (BasicCell *cell,
const gchar *type_name)
183 if (!cell)
return FALSE;
184 if (!type_name)
return FALSE;
185 if (!cell->cell_type_name)
return FALSE;
187 return (g_strcmp0 (type_name, cell->cell_type_name));
191 gnc_basic_cell_set_sample_text (BasicCell *cell,
192 const char *sample_text)
195 if (cell->sample_text == sample_text)
return;
197 g_free (cell->sample_text);
198 cell->sample_text = g_strdup (sample_text);
202 gnc_basic_cell_set_alignment (BasicCell *cell,
203 CellAlignment alignment)
206 cell->alignment = alignment;
210 gnc_basic_cell_set_expandable (BasicCell *cell, gboolean expandable)
213 cell->expandable = expandable;
217 gnc_basic_cell_set_span (BasicCell *cell, gboolean span)
224 gnc_basic_cell_get_value (BasicCell *cell)
226 g_return_val_if_fail (cell != NULL, NULL);
232 gnc_basic_cell_set_value (BasicCell *cell,
const char *val)
236 cb = cell->set_value;
241 cell->set_value = NULL;
243 cell->set_value = cb;
246 gnc_basic_cell_set_value_internal (cell, val);
250 gnc_basic_cell_get_changed (BasicCell *cell)
252 if (!cell)
return FALSE;
254 return cell->changed;
258 gnc_basic_cell_get_conditionally_changed (BasicCell *cell)
260 if (!cell)
return FALSE;
262 return cell->conditionally_changed;
266 gnc_basic_cell_set_changed (BasicCell *cell, gboolean changed)
270 cell->changed = changed;
274 gnc_basic_cell_set_conditionally_changed (BasicCell *cell, gboolean changed)
278 cell->conditionally_changed = changed;
282 gnc_basic_cell_set_value_internal (BasicCell *cell,
const char *value)
292 if (cell->value == value)
295 g_free (cell->value);
296 cell->value = g_strdup (value);
297 cell->value_chars = g_utf8_strlen(value, -1);
302 const char *change,
const char *newval,
303 const char *toks, gint *cursor_position)
305 struct lconv *lc = gnc_localeconv ();
306 gunichar decimal_point;
307 gunichar thousands_sep;
308 const char *symbol = NULL;
311 if (print_info.monetary)
313 const gnc_commodity *comm = print_info.commodity;
315 decimal_point = g_utf8_get_char (lc->mon_decimal_point);
316 thousands_sep = g_utf8_get_char (lc->mon_thousands_sep);
323 tokens = g_strconcat (toks, symbol, NULL);
327 decimal_point = g_utf8_get_char (lc->decimal_point);
328 thousands_sep = g_utf8_get_char (lc->thousands_sep);
330 tokens = g_strdup (toks);
333 for (
const char *c = change; c && *c; c = g_utf8_next_char (c))
335 gunichar uc = g_utf8_get_char (c);
336 if (!g_unichar_isdigit (uc) &&
337 !g_unichar_isspace (uc) &&
338 !g_unichar_isalpha (uc) &&
339 (decimal_point != uc) &&
340 (thousands_sep != uc) &&
341 (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.