Line data Source code
1 : /* File: gui_simple_message_to_user.c; Copyright and License: see below */
2 :
3 : #include "gui_simple_message_to_user.h"
4 : #include "gui_error_info_printer.h"
5 : #include "u8/u8_trace.h"
6 : #include "u8/u8_log.h"
7 : #include "meta/meta_info.h"
8 : #include "meta/meta_version.h"
9 : #include "u8/u8_error.h"
10 : #include <stdbool.h>
11 : #include <assert.h>
12 :
13 0 : void gui_simple_message_to_user_init ( gui_simple_message_to_user_t *this_, GtkWidget *text_label, GtkWidget *icon_image, gui_resources_t *res )
14 : {
15 0 : U8_TRACE_BEGIN();
16 0 : assert ( text_label != NULL );
17 0 : assert ( icon_image != NULL );
18 0 : assert ( res != NULL );
19 :
20 0 : (*this_).type_id = GUI_SIMPLE_MESSAGE_TYPE_NO_MESSAGE;
21 0 : (*this_).text_label = text_label;
22 0 : (*this_).icon_image = icon_image;
23 0 : (*this_).res = res;
24 :
25 0 : (*this_).private_temp_str = utf8stringbuf_init( sizeof((*this_).private_temp_buf), (*this_).private_temp_buf );
26 0 : utf8stringbuf_clear( (*this_).private_temp_str );
27 :
28 0 : U8_TRACE_END();
29 0 : }
30 :
31 0 : void gui_simple_message_to_user_destroy ( gui_simple_message_to_user_t *this_ )
32 : {
33 0 : U8_TRACE_BEGIN();
34 :
35 0 : (*this_).text_label = NULL;
36 0 : (*this_).icon_image = NULL;
37 0 : (*this_).res = NULL;
38 :
39 0 : U8_TRACE_END();
40 0 : }
41 :
42 0 : void gui_simple_message_to_user_show_message ( gui_simple_message_to_user_t *this_,
43 : gui_simple_message_type_t type_id,
44 : gui_simple_message_content_t content_id )
45 : {
46 0 : U8_TRACE_BEGIN();
47 :
48 : /* update type id: */
49 0 : (*this_).type_id = type_id;
50 0 : gui_simple_message_to_user_private_set_icon_image( this_, type_id );
51 :
52 : /* update content text: */
53 0 : utf8stringbuf_clear( (*this_).private_temp_str );
54 0 : switch ( content_id )
55 : {
56 0 : case GUI_SIMPLE_MESSAGE_CONTENT_ABOUT:
57 : {
58 0 : utf8stringbuf_append_str( (*this_).private_temp_str,
59 : "This is " META_INFO_PROGRAM_NAME_STR " version "
60 : );
61 0 : utf8stringbuf_append_str( (*this_).private_temp_str,
62 : META_VERSION_STR
63 : );
64 0 : utf8stringbuf_append_str( (*this_).private_temp_str,
65 : "\n"
66 : "License: " META_INFO_LICENSE_STR " / "
67 : "Copyright: " META_INFO_COPYRIGHT_STR "\n"
68 : "Thanks to all who have contributed to improving and deploying this tool."
69 : );
70 : }
71 0 : break;
72 :
73 0 : case GUI_SIMPLE_MESSAGE_CONTENT_STRING_TRUNCATED:
74 : {
75 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Maximum string length exceeded." );
76 : }
77 0 : break;
78 :
79 0 : case GUI_SIMPLE_MESSAGE_CONTENT_NO_SELECTION:
80 : {
81 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Nothing selected." );
82 : }
83 0 : break;
84 :
85 0 : case GUI_SIMPLE_MESSAGE_CONTENT_NO_FOCUS:
86 : {
87 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "No element is focused." );
88 : }
89 0 : break;
90 :
91 0 : case GUI_SIMPLE_MESSAGE_CONTENT_DELETING_NOT_POSSIBLE:
92 : {
93 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Some objects could not be deleted: They are still referenced/used." );
94 : }
95 0 : break;
96 :
97 0 : case GUI_SIMPLE_MESSAGE_CONTENT_NO_MORE_UNDO:
98 : {
99 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "No more actions to be un-done." );
100 : }
101 0 : break;
102 :
103 0 : case GUI_SIMPLE_MESSAGE_CONTENT_UNDO_NOT_POSSIBLE:
104 : {
105 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "No more actions can be un-done: undo list at limit." );
106 : }
107 0 : break;
108 :
109 0 : case GUI_SIMPLE_MESSAGE_CONTENT_NO_MORE_REDO:
110 : {
111 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "No more actions to be re-done." );
112 : }
113 0 : break;
114 :
115 0 : case GUI_SIMPLE_MESSAGE_CONTENT_NO_INPUT_DATA:
116 : {
117 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "No input data." );
118 : }
119 0 : break;
120 :
121 0 : case GUI_SIMPLE_MESSAGE_CONTENT_SET_PARTLY_UNSUITABLE:
122 : {
123 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Operation cannot be performed on all elements in the set." );
124 : }
125 0 : break;
126 :
127 0 : case GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_WRITE_ERROR:
128 : {
129 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Database could not be written to the database file." );
130 : }
131 0 : break;
132 :
133 0 : case GUI_SIMPLE_MESSAGE_CONTENT_ANCESTOR_IS_NOT_DESCENDANT:
134 : {
135 0 : utf8stringbuf_append_str( (*this_).private_temp_str,
136 : "An ancestor (parent/root) diagram cannot move to a descendant (child) location.\n"
137 : "Instead, try to move a descendant out to an ancestor or sibling location"
138 : );
139 : }
140 0 : break;
141 :
142 0 : case GUI_SIMPLE_MESSAGE_CONTENT_DEBUG_MODE:
143 : {
144 0 : utf8stringbuf_append_str( (*this_).private_temp_str,
145 : "This software was compiled in DEBUG mode.\nIt may be slower than the RELEASE version.\n"
146 : "Confidential information may be printed to syslog."
147 : );
148 : }
149 0 : break;
150 :
151 0 : case GUI_SIMPLE_MESSAGE_CONTENT_NO_RELATIONSHIPS:
152 : {
153 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "The current diagram type does not allow one to create relationships." );
154 : }
155 0 : break;
156 :
157 0 : case GUI_SIMPLE_MESSAGE_CONTENT_NO_FEATURES:
158 : {
159 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "The current diagram type does not allow one to create features." );
160 : }
161 0 : break;
162 :
163 0 : case GUI_SIMPLE_MESSAGE_CONTENT_FEATURELESS_CLASSIFIER:
164 : {
165 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "The current classifier type does not allow one to create features." );
166 : }
167 0 : break;
168 :
169 0 : case GUI_SIMPLE_MESSAGE_CONTENT_IS_ALWAYS_INSTANCE:
170 : {
171 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "The current classifier type does not allow one to remove the instance flag." );
172 : }
173 0 : break;
174 :
175 0 : case GUI_SIMPLE_MESSAGE_CONTENT_DB_IS_READ_ONLY:
176 : {
177 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "The database file is open in read only mode." );
178 : }
179 0 : break;
180 :
181 0 : default:
182 : {
183 0 : U8_LOG_ERROR("unexptected gui_simple_message_content_t");
184 : }
185 : }
186 0 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( (*this_).private_temp_str ));
187 0 : U8_LOG_EVENT( utf8stringbuf_get_string( (*this_).private_temp_str ) );
188 :
189 : /* show: */
190 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
191 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
192 :
193 0 : U8_TRACE_END();
194 0 : }
195 :
196 0 : void gui_simple_message_to_user_show_message_with_quantity ( gui_simple_message_to_user_t *this_,
197 : gui_simple_message_type_t type_id,
198 : const gui_simple_message_content_quantity_t *content_id,
199 : int quantity )
200 : {
201 0 : U8_TRACE_BEGIN();
202 0 : assert( content_id != NULL );
203 :
204 : /* update type id: */
205 0 : (*this_).type_id = type_id;
206 0 : gui_simple_message_to_user_private_set_icon_image( this_, type_id );
207 :
208 : /* update content text: */
209 0 : utf8stringbuf_clear( (*this_).private_temp_str );
210 0 : if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DB_INCONSISTENT )
211 : {
212 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DB_INCONSISTENT" );
213 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Current database is inconsistent; errors: " );
214 0 : utf8stringbuf_append_int( (*this_).private_temp_str, quantity );
215 : }
216 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_MAX_WINDOWS_ALREADY_OPEN )
217 : {
218 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_MAX_WINDOWS_ALREADY_OPEN" );
219 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Maximum number of windows already open: " );
220 0 : utf8stringbuf_append_int( (*this_).private_temp_str, quantity );
221 : }
222 : else
223 : {
224 0 : U8_LOG_ERROR("unexptected content_id");
225 0 : assert(false);
226 : }
227 0 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( (*this_).private_temp_str ));
228 :
229 : /* show: */
230 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
231 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
232 :
233 0 : U8_TRACE_END();
234 0 : }
235 :
236 : #if 0
237 : void gui_simple_message_to_user_show_message_with_line ( gui_simple_message_to_user_t *this_,
238 : gui_simple_message_type_t type_id,
239 : const gui_simple_message_content_position_t *content_id,
240 : int stream_line )
241 : {
242 : U8_TRACE_BEGIN();
243 : assert( content_id != NULL );
244 :
245 : /* update type id: */
246 : (*this_).type_id = type_id;
247 : gui_simple_message_to_user_private_set_icon_image( this_, type_id );
248 :
249 : /* update content text: */
250 : utf8stringbuf_clear( (*this_).private_temp_str );
251 : if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_INVALID_INPUT_DATA )
252 : {
253 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_INVALID_INPUT_DATA" );
254 : utf8stringbuf_append_str( (*this_).private_temp_str, "Invalid input data at line " );
255 : utf8stringbuf_append_int( (*this_).private_temp_str, stream_line );
256 : }
257 : else
258 : {
259 : U8_LOG_ERROR("unexptected content_id");
260 : assert(false);
261 : }
262 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( (*this_).private_temp_str ));
263 :
264 : /* show: */
265 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
266 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
267 :
268 : U8_TRACE_END();
269 : }
270 : #endif
271 :
272 0 : void gui_simple_message_to_user_show_message_with_name ( gui_simple_message_to_user_t *this_,
273 : gui_simple_message_type_t type_id,
274 : const gui_simple_message_content_name_t *content_id,
275 : const char *name )
276 : {
277 0 : U8_TRACE_BEGIN();
278 0 : assert( content_id != NULL );
279 0 : assert( name != NULL );
280 :
281 : /* update type id: */
282 0 : (*this_).type_id = type_id;
283 0 : gui_simple_message_to_user_private_set_icon_image( this_, type_id );
284 :
285 : /* update content text: */
286 0 : utf8stringbuf_clear( (*this_).private_temp_str );
287 0 : if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_NOT_OPENED )
288 : {
289 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_NOT_OPENED" );
290 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Chosen database file could not be opened/created:\n" );
291 0 : utf8stringbuf_append_str( (*this_).private_temp_str, name );
292 : }
293 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_NOT_CREATEABLE )
294 : {
295 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_NOT_CREATEABLE" );
296 0 : utf8stringbuf_append_str( (*this_).private_temp_str,
297 : "Database file could not be created, the parent directory is possibly read-only:\n"
298 : );
299 0 : utf8stringbuf_append_str( (*this_).private_temp_str, name );
300 : }
301 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_OPENED_WITH_ERROR )
302 : {
303 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_OPENED_WITH_ERROR" );
304 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Chosen database file opened/created with warning:\n" );
305 0 : utf8stringbuf_append_str( (*this_).private_temp_str, name );
306 : }
307 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_FILE_EXPORT_FAILED )
308 : {
309 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_FILE_EXPORT_FAILED" );
310 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Export failed, destination path: " );
311 0 : utf8stringbuf_append_str( (*this_).private_temp_str, name );
312 : }
313 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_NAME_NOT_UNIQUE )
314 : {
315 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_NAME_NOT_UNIQUE" );
316 0 : utf8stringbuf_append_str( (*this_).private_temp_str,
317 : "Name already in use (use copy and paste to insert the existing object): "
318 : );
319 0 : utf8stringbuf_append_str( (*this_).private_temp_str, name );
320 : }
321 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_LOADING_WAIT )
322 : {
323 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_LOADING_WAIT" );
324 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Loading DB file ...\n" );
325 0 : utf8stringbuf_append_str( (*this_).private_temp_str, name );
326 : }
327 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_EXPORTING_WAIT )
328 : {
329 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_EXPORTING_WAIT" );
330 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Exporting files ...\n" );
331 0 : utf8stringbuf_append_str( (*this_).private_temp_str, name );
332 : }
333 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_WRITTEN )
334 : {
335 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_WRITTEN" );
336 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Database file written: " );
337 0 : utf8stringbuf_append_str( (*this_).private_temp_str, name );
338 : }
339 : else
340 : {
341 0 : U8_LOG_ERROR("unexptected content_id");
342 0 : assert(false);
343 : }
344 0 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( (*this_).private_temp_str ));
345 0 : U8_TRACE_INFO_STR( "error at", name );
346 :
347 : /* show: */
348 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
349 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
350 :
351 0 : U8_TRACE_END();
352 0 : }
353 :
354 0 : void gui_simple_message_to_user_show_message_with_names ( gui_simple_message_to_user_t *this_,
355 : gui_simple_message_type_t type_id,
356 : const gui_simple_message_content_names_t *content_id,
357 : const char *list_of_names )
358 : {
359 0 : U8_TRACE_BEGIN();
360 0 : assert( content_id != NULL );
361 0 : assert( list_of_names != NULL );
362 :
363 : /* update type id: */
364 0 : (*this_).type_id = type_id;
365 0 : gui_simple_message_to_user_private_set_icon_image( this_, type_id );
366 :
367 : /* update content text: */
368 0 : utf8stringbuf_clear( (*this_).private_temp_str );
369 : {
370 0 : U8_LOG_ERROR("unexptected content_id");
371 0 : assert(false);
372 : }
373 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( (*this_).private_temp_str ));
374 :
375 : /* show: */
376 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
377 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
378 :
379 : U8_TRACE_END();
380 : }
381 :
382 0 : void gui_simple_message_to_user_show_message_with_error ( gui_simple_message_to_user_t *this_,
383 : gui_simple_message_type_t type_id,
384 : const gui_simple_message_content_error_t *content_id,
385 : const char *error_message )
386 : {
387 0 : U8_TRACE_BEGIN();
388 0 : assert( content_id != NULL );
389 0 : assert( error_message != NULL );
390 :
391 : /* update type id: */
392 0 : (*this_).type_id = type_id;
393 0 : gui_simple_message_to_user_private_set_icon_image( this_, type_id );
394 :
395 : /* update content text: */
396 0 : utf8stringbuf_clear( (*this_).private_temp_str );
397 0 : if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_NOT_YET_IMPLEMENTED )
398 : {
399 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_NOT_YET_IMPLEMENTED" );
400 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "This feature is not yet implemented: " );
401 0 : utf8stringbuf_append_str( (*this_).private_temp_str, error_message );
402 : }
403 : else
404 : {
405 0 : U8_LOG_ERROR("unexptected content_id");
406 0 : assert(false);
407 : }
408 0 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( (*this_).private_temp_str ));
409 :
410 : /* show: */
411 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
412 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
413 :
414 0 : U8_TRACE_END();
415 0 : }
416 :
417 : const char *const (gui_simple_message_to_user_private_table_name[DATA_STAT_TABLE_MAX])
418 : = {"lifelines","classifiers","features","relations","classifier-occurrences","diagrams"};
419 : const char *const (gui_simple_message_to_user_private_series_name4change[DATA_STAT_SERIES_MAX])
420 : = {"created","modified","deleted","ignored","warning","error"};
421 : const char *const (gui_simple_message_to_user_private_series_name4other[DATA_STAT_SERIES_MAX])
422 : = {"exported","un/selected","deleted","ignored","warning","error"};
423 :
424 0 : void gui_simple_message_to_user_show_message_with_stat ( gui_simple_message_to_user_t *this_,
425 : gui_simple_message_type_t type_id,
426 : const gui_simple_message_content_stat_t *content_id,
427 : const data_stat_t *stat
428 : )
429 : {
430 0 : U8_TRACE_BEGIN();
431 0 : assert( stat != NULL );
432 0 : assert( content_id != NULL );
433 0 : data_stat_trace( stat );
434 :
435 : /* update type id: */
436 0 : (*this_).type_id = type_id;
437 0 : gui_simple_message_to_user_private_set_icon_image( this_, type_id );
438 :
439 : /* update content text: */
440 0 : utf8stringbuf_clear( (*this_).private_temp_str );
441 0 : if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_CUT_TO_CLIPBOARD )
442 : {
443 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_CUT_TO_CLIPBOARD" );
444 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Selection cut to clipboard: \n" );
445 0 : gui_simple_message_to_user_private_append_stat( this_, stat, true, (*this_).private_temp_str );
446 : }
447 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_COPY_TO_CLIPBOARD )
448 : {
449 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_COPY_TO_CLIPBOARD" );
450 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Selection copied to clipboard: \n" );
451 0 : gui_simple_message_to_user_private_append_stat( this_, stat, true, (*this_).private_temp_str );
452 : }
453 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_PASTE_FROM_CLIPBOARD )
454 : {
455 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_PASTE_FROM_CLIPBOARD" );
456 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Clipboard pasted: \n" );
457 0 : gui_simple_message_to_user_private_append_stat( this_, stat, false, (*this_).private_temp_str );
458 : }
459 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DELETE )
460 : {
461 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DELETE" );
462 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Selection deleted: \n" );
463 0 : gui_simple_message_to_user_private_append_stat( this_, stat, false, (*this_).private_temp_str );
464 : }
465 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_UNDO )
466 : {
467 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_UNDO" );
468 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Undo success: \n" );
469 0 : gui_simple_message_to_user_private_append_stat( this_, stat, false, (*this_).private_temp_str );
470 : }
471 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_REDO )
472 : {
473 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_REDO" );
474 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Redo success: \n" );
475 0 : gui_simple_message_to_user_private_append_stat( this_, stat, false, (*this_).private_temp_str );
476 : }
477 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_TYPE_CHANGE )
478 : {
479 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_TYPE_CHANGE" );
480 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Type changed: \n" );
481 0 : gui_simple_message_to_user_private_append_stat( this_, stat, false, (*this_).private_temp_str );
482 : }
483 : else
484 : {
485 0 : U8_LOG_ERROR("unexptected content_id");
486 0 : assert(false);
487 : }
488 0 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( (*this_).private_temp_str ));
489 :
490 : /* show: */
491 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
492 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
493 :
494 0 : U8_TRACE_END();
495 0 : }
496 :
497 0 : void gui_simple_message_to_user_show_message_with_names_and_stat( gui_simple_message_to_user_t *this_,
498 : gui_simple_message_type_t type_id,
499 : const gui_simple_message_content_names_stat_t *content_id,
500 : const char *list_of_names,
501 : const data_stat_t *stat )
502 : {
503 0 : U8_TRACE_BEGIN();
504 0 : assert( stat != NULL );
505 0 : assert( list_of_names != NULL );
506 0 : assert( content_id != NULL );
507 0 : data_stat_trace( stat );
508 :
509 : /* update type id: */
510 0 : (*this_).type_id = type_id;
511 0 : gui_simple_message_to_user_private_set_icon_image( this_, type_id );
512 :
513 : /* update content text: */
514 0 : utf8stringbuf_clear( (*this_).private_temp_str );
515 0 : if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_EXPORT_FINISHED )
516 : {
517 0 : U8_LOG_EVENT_STR( "GUI_SIMPLE_MESSAGE_CONTENT_EXPORT_FINISHED", list_of_names );
518 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "Files exported, format: " );
519 0 : utf8stringbuf_append_str( (*this_).private_temp_str, list_of_names );
520 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "\n" );
521 0 : gui_simple_message_to_user_private_append_stat( this_, stat, true, (*this_).private_temp_str );
522 0 : if ( 0 != data_stat_get_series_count ( stat, DATA_STAT_SERIES_WARNING ) )
523 : {
524 0 : utf8stringbuf_append_str( (*this_).private_temp_str, "\nFor details see comments in exported files." );
525 : }
526 : }
527 : else
528 : {
529 0 : U8_LOG_ERROR("unexptected content_id");
530 0 : assert(false);
531 : }
532 0 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( (*this_).private_temp_str ));
533 :
534 : /* show: */
535 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
536 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
537 :
538 0 : U8_TRACE_END();
539 0 : }
540 :
541 0 : void gui_simple_message_to_user_private_append_stat ( gui_simple_message_to_user_t *this_,
542 : const data_stat_t *stat,
543 : bool alt_labels,
544 : utf8stringbuf_t out_buf
545 : )
546 : {
547 0 : U8_TRACE_BEGIN();
548 0 : assert( stat != NULL );
549 :
550 0 : bool first_series = true;
551 0 : for ( int series_idx = 0; series_idx < DATA_STAT_SERIES_MAX; series_idx ++ )
552 : {
553 0 : if ( 0 != data_stat_get_series_count ( stat, series_idx ) )
554 : {
555 0 : if ( first_series )
556 : {
557 0 : first_series = false;
558 : }
559 : else
560 : {
561 0 : utf8stringbuf_append_str( out_buf, "\n" );
562 : }
563 0 : const char *const series_name
564 : = alt_labels
565 : ? gui_simple_message_to_user_private_series_name4other[series_idx]
566 0 : : gui_simple_message_to_user_private_series_name4change[series_idx];
567 0 : utf8stringbuf_append_str( out_buf, series_name );
568 0 : utf8stringbuf_append_str( out_buf, ": " );
569 :
570 0 : bool first_table = true;
571 0 : for ( int tables_idx = 0; tables_idx < DATA_STAT_TABLE_MAX; tables_idx ++ )
572 : {
573 0 : uint_fast32_t cnt = data_stat_get_count ( stat, tables_idx, series_idx );
574 0 : if ( 0 != cnt )
575 : {
576 0 : if ( first_table )
577 : {
578 0 : first_table = false;
579 : }
580 : else
581 : {
582 0 : utf8stringbuf_append_str( out_buf, ", " );
583 : }
584 0 : const char *const table_name = gui_simple_message_to_user_private_table_name[tables_idx];
585 0 : utf8stringbuf_append_str( out_buf, table_name );
586 0 : utf8stringbuf_append_str( out_buf, ":" );
587 0 : utf8stringbuf_append_int( out_buf, cnt );
588 : }
589 : }
590 : }
591 : }
592 0 : if ( 0 == data_stat_get_total_count ( stat ) )
593 : {
594 0 : utf8stringbuf_append_str( out_buf, "0" );
595 : }
596 0 : U8_TRACE_INFO( utf8stringbuf_get_string( out_buf ) );
597 :
598 0 : U8_TRACE_END();
599 0 : }
600 :
601 0 : void gui_simple_message_to_user_show_error_info ( gui_simple_message_to_user_t *this_, const u8_error_info_t *err_info )
602 : {
603 0 : U8_TRACE_BEGIN();
604 :
605 : /* update type id: */
606 0 : (*this_).type_id = GUI_SIMPLE_MESSAGE_TYPE_ERROR;
607 0 : gui_simple_message_to_user_private_set_icon_image( this_, GUI_SIMPLE_MESSAGE_TYPE_ERROR );
608 :
609 : /* update content text: */
610 0 : utf8stringbuf_clear( (*this_).private_temp_str );
611 : {
612 : gui_error_info_printer_t my_err_info_printer;
613 0 : gui_error_info_printer_init( &my_err_info_printer );
614 0 : gui_error_info_printer_show_error_info( &my_err_info_printer, err_info, (*this_).private_temp_str );
615 0 : gui_error_info_printer_destroy( &my_err_info_printer );
616 : }
617 0 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( (*this_).private_temp_str ) );
618 :
619 : /* show: */
620 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
621 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
622 :
623 0 : U8_TRACE_END();
624 0 : }
625 :
626 0 : void gui_simple_message_to_user_hide ( gui_simple_message_to_user_t *this_ )
627 : {
628 0 : U8_TRACE_BEGIN();
629 :
630 0 : (*this_).type_id = GUI_SIMPLE_MESSAGE_TYPE_NO_MESSAGE;
631 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), FALSE );
632 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), FALSE );
633 :
634 0 : U8_TRACE_END();
635 0 : }
636 :
637 :
638 : /*
639 : Copyright 2016-2024 Andreas Warnke
640 :
641 : Licensed under the Apache License, Version 2.0 (the "License");
642 : you may not use this file except in compliance with the License.
643 : You may obtain a copy of the License at
644 :
645 : http://www.apache.org/licenses/LICENSE-2.0
646 :
647 : Unless required by applicable law or agreed to in writing, software
648 : distributed under the License is distributed on an "AS IS" BASIS,
649 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
650 : See the License for the specific language governing permissions and
651 : limitations under the License.
652 : */
|