50 static void gnc_doclink_cell_set_value (BasicCell *_cell,
const char *value);
53 gnc_doclink_get_glyph_from_flag (
char link_flag)
60 return GLYPH_PAPERCLIP;
67 gnc_doclink_get_flag_from_glyph (
const char *glyph)
69 if (strcmp (glyph, GLYPH_LINK) == 0)
71 else if (strcmp (glyph, GLYPH_PAPERCLIP) == 0)
80 return cell->use_glyphs;
84 gnc_doclink_cell_get_string (
Doclinkcell *cell,
char flag)
86 static char str[2] = { 0, 0 };
89 return gnc_doclink_get_glyph_from_flag (flag);
100 gnc_doclink_cell_enter (BasicCell *_cell,
101 int *cursor_position,
102 int *start_selection,
108 if (cell->confirm_cb &&
109 ! (cell->confirm_cb (cell->flag, cell->confirm_data)))
112 if (cell->read_only == TRUE)
116 this_flag = strchr (cell->
flag_order, cell->flag);
118 if (this_flag == NULL || *this_flag ==
'\0')
129 if (*this_flag !=
'\0')
130 cell->flag = *this_flag;
136 gnc_doclink_cell_set_flag (cell, cell->flag);
144 gnc_basic_cell_init (&cell->cell);
146 gnc_doclink_cell_set_flag (cell,
'\0');
147 cell->confirm_cb = NULL;
151 cell->read_only = FALSE;
152 cell->use_glyphs = FALSE;
154 cell->cell.enter_cell = gnc_doclink_cell_enter;
155 cell->cell.set_value = gnc_doclink_cell_set_value;
159 gnc_doclink_cell_new (
void)
165 gnc_doclink_cell_init (cell);
172 gnc_doclink_cell_set_value (BasicCell *_cell,
const char *value)
177 if (!value || *value ==
'\0')
180 gnc_basic_cell_set_value_internal (_cell,
"");
184 if (cell->use_glyphs)
185 flag = gnc_doclink_get_flag_from_glyph (value);
192 gnc_doclink_cell_set_flag (cell, flag);
196 gnc_doclink_cell_set_flag (
Doclinkcell *cell,
char flag)
200 g_return_if_fail (cell != NULL);
203 string = gnc_doclink_cell_get_string (cell, flag);
205 gnc_basic_cell_set_value_internal (&cell->cell,
string);
211 g_return_val_if_fail (cell != NULL,
'\0');
217 gnc_doclink_cell_set_string_getter (
Doclinkcell *cell,
218 DoclinkcellStringGetter get_string)
220 g_return_if_fail (cell != NULL);
226 gnc_doclink_cell_set_confirm_cb (
Doclinkcell *cell, DoclinkcellConfirm confirm_cb,
229 g_return_if_fail (cell != NULL);
231 cell->confirm_cb = confirm_cb;
232 cell->confirm_data = data;
239 g_return_if_fail (cell != NULL);
240 g_return_if_fail (flags != NULL);
247 gnc_doclink_cell_set_flag_order (
Doclinkcell *cell,
const char *flags)
249 g_return_if_fail (cell != NULL);
250 g_return_if_fail (flags != NULL);
256 gnc_doclink_cell_set_read_only (
Doclinkcell *cell, gboolean read_only)
258 g_return_if_fail (cell != NULL);
260 cell->read_only = read_only;
264 gnc_doclink_cell_set_use_glyphs (
Doclinkcell *cell)
266 #ifdef MAC_INTEGRATION 267 cell->use_glyphs = FALSE;
269 gboolean use_glyphs = TRUE;
272 PangoLayout *test_layout;
275 g_return_if_fail (cell != NULL);
277 label = gtk_label_new (NULL);
278 test_text = g_strconcat (GLYPH_LINK,
",", GLYPH_PAPERCLIP, NULL);
279 test_layout = gtk_widget_create_pango_layout (GTK_WIDGET (label), test_text);
281 pango_layout_set_text (test_layout, test_text, strlen (test_text));
283 count = pango_layout_get_unknown_glyphs_count (test_layout);
288 g_object_unref (test_layout);
291 cell->use_glyphs = use_glyphs;
utility functions for the GnuCash UI
char * valid_flags
The actual flag value.
The Doclinkcell object implements a cell handler that will cycle through a series of single-character...
char * flag_order
The list of valid flags.
char default_flag
Automatic flag selection order.
void gnc_doclink_cell_set_valid_flags(Doclinkcell *cell, const char *flags, char default_flag)
note that
All type declarations for the whole Gnucash engine.
DoclinkcellStringGetter get_string
Default flag for unknown user input.