File: gui_simple_message_to_user.c

package info (click to toggle)
crystal-facet-uml 1.63.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 21,640 kB
  • sloc: ansic: 109,610; xml: 3,085; makefile: 138; sh: 113
file content (652 lines) | stat: -rw-r--r-- 27,104 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
/* File: gui_simple_message_to_user.c; Copyright and License: see below */

#include "gui_simple_message_to_user.h"
#include "gui_error_info_printer.h"
#include "u8/u8_trace.h"
#include "u8/u8_log.h"
#include "meta/meta_info.h"
#include "meta/meta_version.h"
#include "u8/u8_error.h"
#include <stdbool.h>
#include <assert.h>

void gui_simple_message_to_user_init ( gui_simple_message_to_user_t *this_, GtkWidget *text_label, GtkWidget *icon_image, gui_resources_t *res )
{
    U8_TRACE_BEGIN();
    assert ( text_label != NULL );
    assert ( icon_image != NULL );
    assert ( res != NULL );

    (*this_).type_id = GUI_SIMPLE_MESSAGE_TYPE_NO_MESSAGE;
    (*this_).text_label = text_label;
    (*this_).icon_image = icon_image;
    (*this_).res = res;

    (*this_).private_temp_str = utf8stringbuf_new( (*this_).private_temp_buf, sizeof((*this_).private_temp_buf) );
    utf8stringbuf_clear( &((*this_).private_temp_str) );

    U8_TRACE_END();
}

void gui_simple_message_to_user_destroy ( gui_simple_message_to_user_t *this_ )
{
    U8_TRACE_BEGIN();

    (*this_).text_label = NULL;
    (*this_).icon_image = NULL;
    (*this_).res = NULL;

    U8_TRACE_END();
}

void gui_simple_message_to_user_show_message ( gui_simple_message_to_user_t *this_,
                                               gui_simple_message_type_t type_id,
                                               gui_simple_message_content_t content_id )
{
    U8_TRACE_BEGIN();

    /* update type id: */
    (*this_).type_id = type_id;
    gui_simple_message_to_user_private_set_icon_image( this_, type_id );

    /* update content text: */
    utf8stringbuf_clear( &((*this_).private_temp_str) );
    switch ( content_id )
    {
        case GUI_SIMPLE_MESSAGE_CONTENT_ABOUT:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str),
                                      "This is " META_INFO_PROGRAM_NAME_STR " version "
                                    );
            utf8stringbuf_append_str( &((*this_).private_temp_str),
                                      META_VERSION_STR
                                    );
            utf8stringbuf_append_str( &((*this_).private_temp_str),
                                      "\n"
                                      "License: " META_INFO_LICENSE_STR " / "
                                      "Copyright: " META_INFO_COPYRIGHT_STR "\n"
                                      "Thanks to all who have contributed to improving and deploying this tool."
                                    );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_STRING_TRUNCATED:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "Maximum string length exceeded." );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_NO_SELECTION:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "Nothing selected." );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_NO_FOCUS:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "No element is focused." );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_DELETING_NOT_POSSIBLE:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "Some objects could not be deleted: They are still referenced/used." );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_NO_MORE_UNDO:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "No more actions to be un-done." );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_UNDO_NOT_POSSIBLE:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "No more actions can be un-done: undo list at limit." );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_NO_MORE_REDO:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "No more actions to be re-done." );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_NO_INPUT_DATA:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "No input data." );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_SET_PARTLY_UNSUITABLE:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "Operation cannot be performed on all elements in the set." );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_WRITE_ERROR:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "Database could not be written to the database file." );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_ANCESTOR_IS_NOT_DESCENDANT:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str),
                                      "An ancestor (parent/root) diagram cannot move to a descendant (child) location.\n"
                                      "Instead, try to move a descendant out to an ancestor or sibling location"
                                    );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_DEBUG_MODE:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str),
                                      "This software was compiled in DEBUG mode.\nIt may be slower than the RELEASE version.\n"
                                      "Confidential information may be printed to syslog."
                                    );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_NO_RELATIONSHIPS:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "The current diagram type does not allow one to create relationships." );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_NO_FEATURES:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "The current diagram type does not allow one to create features." );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_FEATURELESS_CLASSIFIER:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "The current classifier type does not allow one to create features." );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_IS_ALWAYS_INSTANCE:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "The current classifier type does not allow one to remove the instance flag." );
        }
        break;

        case GUI_SIMPLE_MESSAGE_CONTENT_DB_IS_READ_ONLY:
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "The database file is open in read only mode." );
        }
        break;

        default:
        {
            U8_LOG_ERROR("unexptected gui_simple_message_content_t");
        }
    }
    gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ));
    U8_LOG_EVENT( utf8stringbuf_get_string( &((*this_).private_temp_str) ) );

    /* show: */
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );

    U8_TRACE_END();
}

void gui_simple_message_to_user_show_message_with_quantity ( gui_simple_message_to_user_t *this_,
                                                             gui_simple_message_type_t type_id,
                                                             const gui_simple_message_content_quantity_t *content_id,
                                                             int quantity )
{
    U8_TRACE_BEGIN();
    assert( content_id != NULL );

    /* update type id: */
    (*this_).type_id = type_id;
    gui_simple_message_to_user_private_set_icon_image( this_, type_id );

    /* update content text: */
    utf8stringbuf_clear( &((*this_).private_temp_str) );
    if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DB_INCONSISTENT )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DB_INCONSISTENT" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Current database is inconsistent; errors: " );
        utf8stringbuf_append_int( &((*this_).private_temp_str), quantity );
    }
    else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_MAX_WINDOWS_ALREADY_OPEN )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_MAX_WINDOWS_ALREADY_OPEN" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Maximum number of windows already open: " );
        utf8stringbuf_append_int( &((*this_).private_temp_str), quantity );
    }
    else
    {
        U8_LOG_ERROR("unexptected content_id");
        assert(false);
    }
    gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ));

    /* show: */
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );

    U8_TRACE_END();
}

#if 0
void gui_simple_message_to_user_show_message_with_line ( gui_simple_message_to_user_t *this_,
                                                         gui_simple_message_type_t type_id,
                                                         const gui_simple_message_content_position_t *content_id,
                                                         int stream_line )
{
    U8_TRACE_BEGIN();
    assert( content_id != NULL );

    /* update type id: */
    (*this_).type_id = type_id;
    gui_simple_message_to_user_private_set_icon_image( this_, type_id );

    /* update content text: */
    utf8stringbuf_clear( &((*this_).private_temp_str) );
    if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_INVALID_INPUT_DATA )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_INVALID_INPUT_DATA" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Invalid input data at line " );
        utf8stringbuf_append_int( &((*this_).private_temp_str), stream_line );
    }
    else
    {
        U8_LOG_ERROR("unexptected content_id");
        assert(false);
    }
    gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ));

    /* show: */
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );

    U8_TRACE_END();
}
#endif

void gui_simple_message_to_user_show_message_with_name ( gui_simple_message_to_user_t *this_,
                                                         gui_simple_message_type_t type_id,
                                                         const gui_simple_message_content_name_t *content_id,
                                                         const char *name )
{
    U8_TRACE_BEGIN();
    assert( content_id != NULL );
    assert( name != NULL );

    /* update type id: */
    (*this_).type_id = type_id;
    gui_simple_message_to_user_private_set_icon_image( this_, type_id );

    /* update content text: */
    utf8stringbuf_clear( &((*this_).private_temp_str) );
    if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_NOT_OPENED )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_NOT_OPENED" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Chosen database file could not be opened/created:\n" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), name );
    }
    else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_NOT_CREATEABLE )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_NOT_CREATEABLE" );
        utf8stringbuf_append_str( &((*this_).private_temp_str),
                                  "Database file could not be created, the parent directory is possibly read-only:\n"
                                );
        utf8stringbuf_append_str( &((*this_).private_temp_str), name );
    }
    else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_OPENED_WITH_ERROR )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_OPENED_WITH_ERROR" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Chosen database file opened/created with warning:\n" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), name );
    }
    else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_FILE_EXPORT_FAILED )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_FILE_EXPORT_FAILED" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Export failed, destination path: " );
        utf8stringbuf_append_str( &((*this_).private_temp_str), name );
    }
    else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_NAME_NOT_UNIQUE )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_NAME_NOT_UNIQUE" );
        utf8stringbuf_append_str( &((*this_).private_temp_str),
                                  "Name already in use (use copy and paste to insert the existing object): "
                                );
        utf8stringbuf_append_str( &((*this_).private_temp_str), name );
    }
    else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_LOADING_WAIT )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_LOADING_WAIT" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Loading DB file ...\n" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), name );
    }
    else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_EXPORTING_WAIT )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_EXPORTING_WAIT" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Exporting files ...\n" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), name );
    }
    else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_WRITTEN )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_WRITTEN" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Database file written: " );
        utf8stringbuf_append_str( &((*this_).private_temp_str), name );
    }
    else
    {
        U8_LOG_ERROR("unexptected content_id");
        assert(false);
    }
    gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ));
    U8_TRACE_INFO_STR( "error at", name );

    /* show: */
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );

    U8_TRACE_END();
}

void gui_simple_message_to_user_show_message_with_names ( gui_simple_message_to_user_t *this_,
                                                          gui_simple_message_type_t type_id,
                                                          const gui_simple_message_content_names_t *content_id,
                                                          const char *list_of_names )
{
    U8_TRACE_BEGIN();
    assert( content_id != NULL );
    assert( list_of_names != NULL );

    /* update type id: */
    (*this_).type_id = type_id;
    gui_simple_message_to_user_private_set_icon_image( this_, type_id );

    /* update content text: */
    utf8stringbuf_clear( &((*this_).private_temp_str) );
    {
        U8_LOG_ERROR("unexptected content_id");
        assert(false);
    }
    gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ));

    /* show: */
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );

    U8_TRACE_END();
}

void gui_simple_message_to_user_show_message_with_error ( gui_simple_message_to_user_t *this_,
                                                          gui_simple_message_type_t type_id,
                                                          const gui_simple_message_content_error_t *content_id,
                                                          const char *error_message )
{
    U8_TRACE_BEGIN();
    assert( content_id != NULL );
    assert( error_message != NULL );

    /* update type id: */
    (*this_).type_id = type_id;
    gui_simple_message_to_user_private_set_icon_image( this_, type_id );

    /* update content text: */
    utf8stringbuf_clear( &((*this_).private_temp_str) );
    if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_NOT_YET_IMPLEMENTED )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_NOT_YET_IMPLEMENTED" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "This feature is not yet implemented: " );
        utf8stringbuf_append_str( &((*this_).private_temp_str), error_message );
    }
    else
    {
        U8_LOG_ERROR("unexptected content_id");
        assert(false);
    }
    gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ));

    /* show: */
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );

    U8_TRACE_END();
}

const char *const (gui_simple_message_to_user_private_table_name[DATA_STAT_TABLE_MAX])
    = {"lifelines","classifiers","features","relations","classifier-occurrences","diagrams"};
const char *const (gui_simple_message_to_user_private_series_name4change[DATA_STAT_SERIES_MAX])
    = {"created","modified","deleted","ignored","warning","error"};
const char *const (gui_simple_message_to_user_private_series_name4other[DATA_STAT_SERIES_MAX])
    = {"exported","un/selected","deleted","ignored","warning","error"};

void gui_simple_message_to_user_show_message_with_stat ( gui_simple_message_to_user_t *this_,
                                                         gui_simple_message_type_t type_id,
                                                         const gui_simple_message_content_stat_t *content_id,
                                                         const data_stat_t *stat
                                                       )
{
    U8_TRACE_BEGIN();
    assert( stat != NULL );
    assert( content_id != NULL );
    data_stat_trace( stat );

    /* update type id: */
    (*this_).type_id = type_id;
    gui_simple_message_to_user_private_set_icon_image( this_, type_id );

    /* update content text: */
    utf8stringbuf_clear( &((*this_).private_temp_str) );
    if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_CUT_TO_CLIPBOARD )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_CUT_TO_CLIPBOARD" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Selection cut to clipboard: \n" );
        gui_simple_message_to_user_private_append_stat( this_, stat, true, (*this_).private_temp_str );
    }
    else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_COPY_TO_CLIPBOARD )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_COPY_TO_CLIPBOARD" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Selection copied to clipboard: \n" );
        gui_simple_message_to_user_private_append_stat( this_, stat, true, (*this_).private_temp_str );
    }
    else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_PASTE_FROM_CLIPBOARD )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_PASTE_FROM_CLIPBOARD" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Clipboard pasted: \n" );
        gui_simple_message_to_user_private_append_stat( this_, stat, false, (*this_).private_temp_str );
    }
    else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DELETE )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DELETE" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Selection deleted: \n" );
        gui_simple_message_to_user_private_append_stat( this_, stat, false, (*this_).private_temp_str );
    }
    else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_UNDO )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_UNDO" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Undo success: \n" );
        gui_simple_message_to_user_private_append_stat( this_, stat, false, (*this_).private_temp_str );
    }
    else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_REDO )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_REDO" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Redo success: \n" );
        gui_simple_message_to_user_private_append_stat( this_, stat, false, (*this_).private_temp_str );
    }
    else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_TYPE_CHANGE )
    {
        U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_TYPE_CHANGE" );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Type changed: \n" );
        gui_simple_message_to_user_private_append_stat( this_, stat, false, (*this_).private_temp_str );
    }
    else
    {
        U8_LOG_ERROR("unexptected content_id");
        assert(false);
    }
    gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ));

    /* show: */
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );

    U8_TRACE_END();
}

void gui_simple_message_to_user_show_message_with_names_and_stat( gui_simple_message_to_user_t *this_,
                                                                  gui_simple_message_type_t type_id,
                                                                  const gui_simple_message_content_names_stat_t *content_id,
                                                                  const char *list_of_names,
                                                                  const data_stat_t *stat )
{
    U8_TRACE_BEGIN();
    assert( stat != NULL );
    assert( list_of_names != NULL );
    assert( content_id != NULL );
    data_stat_trace( stat );

    /* update type id: */
    (*this_).type_id = type_id;
    gui_simple_message_to_user_private_set_icon_image( this_, type_id );

    /* update content text: */
    utf8stringbuf_clear( &((*this_).private_temp_str) );
    if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_EXPORT_FINISHED )
    {
        U8_LOG_EVENT_STR( "GUI_SIMPLE_MESSAGE_CONTENT_EXPORT_FINISHED", list_of_names );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "Files exported, format: " );
        utf8stringbuf_append_str( &((*this_).private_temp_str), list_of_names );
        utf8stringbuf_append_str( &((*this_).private_temp_str), "\n" );
        gui_simple_message_to_user_private_append_stat( this_, stat, true, (*this_).private_temp_str );
        if ( 0 != data_stat_get_series_count ( stat, DATA_STAT_SERIES_WARNING ) )
        {
            utf8stringbuf_append_str( &((*this_).private_temp_str), "\nFor details see comments in exported xmi file." );
        }
    }
    else
    {
        U8_LOG_ERROR("unexptected content_id");
        assert(false);
    }
    gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ));

    /* show: */
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );

    U8_TRACE_END();
}

void gui_simple_message_to_user_private_append_stat ( gui_simple_message_to_user_t *this_,
                                                      const data_stat_t *stat,
                                                      bool alt_labels,
                                                      utf8stringbuf_t out_buf
                                                    )
{
    U8_TRACE_BEGIN();
    assert( stat != NULL );

    bool first_series = true;
    for ( int series_idx = 0; series_idx < DATA_STAT_SERIES_MAX; series_idx ++ )
    {
        if ( 0 != data_stat_get_series_count ( stat, series_idx ) )
        {
            if ( first_series )
            {
                first_series = false;
            }
            else
            {
                utf8stringbuf_append_str( &out_buf, "\n" );
            }
            const char *const series_name
                = alt_labels
                ? gui_simple_message_to_user_private_series_name4other[series_idx]
                : gui_simple_message_to_user_private_series_name4change[series_idx];
            utf8stringbuf_append_str( &out_buf, series_name );
            utf8stringbuf_append_str( &out_buf, ": " );

            bool first_table = true;
            for ( int tables_idx = 0; tables_idx < DATA_STAT_TABLE_MAX; tables_idx ++ )
            {
                uint_fast32_t cnt = data_stat_get_count ( stat, tables_idx, series_idx );
                if ( 0 != cnt )
                {
                    if ( first_table )
                    {
                        first_table = false;
                    }
                    else
                    {
                        utf8stringbuf_append_str( &out_buf, ", " );
                    }
                    const char *const table_name = gui_simple_message_to_user_private_table_name[tables_idx];
                    utf8stringbuf_append_str( &out_buf, table_name );
                    utf8stringbuf_append_str( &out_buf, ":" );
                    utf8stringbuf_append_int( &out_buf, cnt );
                }
            }
        }
    }
    if ( 0 == data_stat_get_total_count ( stat ) )
    {
        utf8stringbuf_append_str( &out_buf, "0" );
    }
    U8_TRACE_INFO( utf8stringbuf_get_string( &out_buf ) );

    U8_TRACE_END();
}

void gui_simple_message_to_user_show_error_info ( gui_simple_message_to_user_t *this_, const u8_error_info_t *err_info )
{
    U8_TRACE_BEGIN();

    /* update type id: */
    (*this_).type_id = GUI_SIMPLE_MESSAGE_TYPE_ERROR;
    gui_simple_message_to_user_private_set_icon_image( this_, GUI_SIMPLE_MESSAGE_TYPE_ERROR );

    /* update content text: */
    utf8stringbuf_clear( &((*this_).private_temp_str) );
    {
        gui_error_info_printer_t my_err_info_printer;
        gui_error_info_printer_init( &my_err_info_printer );
        gui_error_info_printer_show_error_info( &my_err_info_printer, err_info, (*this_).private_temp_str );
        gui_error_info_printer_destroy( &my_err_info_printer );
    }
    gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ) );

    /* show: */
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );

    U8_TRACE_END();
}

void gui_simple_message_to_user_hide ( gui_simple_message_to_user_t *this_ )
{
    U8_TRACE_BEGIN();

    (*this_).type_id = GUI_SIMPLE_MESSAGE_TYPE_NO_MESSAGE;
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), FALSE );
    gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), FALSE );

    U8_TRACE_END();
}


/*
Copyright 2016-2025 Andreas Warnke

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/