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_new( (*this_).private_temp_buf, sizeof((*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 : /* REPLACED BY gui_simple_message_to_user_show_error_info */
238 : void gui_simple_message_to_user_show_message_with_line ( gui_simple_message_to_user_t *this_,
239 : gui_simple_message_type_t type_id,
240 : const gui_simple_message_content_position_t *content_id,
241 : int stream_line )
242 : {
243 : U8_TRACE_BEGIN();
244 : assert( content_id != NULL );
245 :
246 : /* update type id: */
247 : (*this_).type_id = type_id;
248 : gui_simple_message_to_user_private_set_icon_image( this_, type_id );
249 :
250 : /* update content text: */
251 : utf8stringbuf_clear( &((*this_).private_temp_str) );
252 : if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_INVALID_INPUT_DATA )
253 : {
254 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_INVALID_INPUT_DATA" );
255 : utf8stringbuf_append_str( &((*this_).private_temp_str), "Invalid input data at line " );
256 : utf8stringbuf_append_int( &((*this_).private_temp_str), stream_line );
257 : }
258 : else
259 : {
260 : U8_LOG_ERROR("unexptected content_id");
261 : assert(false);
262 : }
263 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ));
264 :
265 : /* show: */
266 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
267 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
268 :
269 : U8_TRACE_END();
270 : }
271 : #endif
272 :
273 0 : void gui_simple_message_to_user_show_message_with_name ( gui_simple_message_to_user_t *this_,
274 : gui_simple_message_type_t type_id,
275 : const gui_simple_message_content_name_t *content_id,
276 : const char *name )
277 : {
278 0 : U8_TRACE_BEGIN();
279 0 : assert( content_id != NULL );
280 0 : assert( name != NULL );
281 :
282 : /* update type id: */
283 0 : (*this_).type_id = type_id;
284 0 : gui_simple_message_to_user_private_set_icon_image( this_, type_id );
285 :
286 : /* update content text: */
287 0 : utf8stringbuf_clear( &((*this_).private_temp_str) );
288 0 : if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_NOT_OPENED )
289 : {
290 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_NOT_OPENED" );
291 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "Chosen database file could not be opened/created:\n" );
292 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), name );
293 : }
294 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_NOT_CREATEABLE )
295 : {
296 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_NOT_CREATEABLE" );
297 0 : utf8stringbuf_append_str( &((*this_).private_temp_str),
298 : "Database file could not be created, the parent directory is possibly read-only:\n"
299 : );
300 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), name );
301 : }
302 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_OPENED_WITH_ERROR )
303 : {
304 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_OPENED_WITH_ERROR" );
305 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "Chosen database file opened/created with warning:\n" );
306 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), name );
307 : }
308 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_FILE_EXPORT_FAILED )
309 : {
310 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_FILE_EXPORT_FAILED" );
311 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "Export failed, destination path: " );
312 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), name );
313 : }
314 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_NAME_NOT_UNIQUE )
315 : {
316 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_NAME_NOT_UNIQUE" );
317 0 : utf8stringbuf_append_str( &((*this_).private_temp_str),
318 : "Name already in use (use copy and paste to insert the existing object): "
319 : );
320 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), name );
321 : }
322 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_LOADING_WAIT )
323 : {
324 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_LOADING_WAIT" );
325 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "Loading DB file ...\n" );
326 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), name );
327 : }
328 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_EXPORTING_WAIT )
329 : {
330 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_EXPORTING_WAIT" );
331 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "Exporting files ...\n" );
332 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), name );
333 : }
334 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_WRITTEN )
335 : {
336 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_WRITTEN" );
337 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "Database file written: " );
338 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), name );
339 : }
340 : else
341 : {
342 0 : U8_LOG_ERROR("unexptected content_id");
343 0 : assert(false);
344 : }
345 0 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ));
346 0 : U8_TRACE_INFO_STR( "error at", name );
347 :
348 : /* show: */
349 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
350 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
351 :
352 0 : U8_TRACE_END();
353 0 : }
354 :
355 0 : void gui_simple_message_to_user_show_message_with_names ( gui_simple_message_to_user_t *this_,
356 : gui_simple_message_type_t type_id,
357 : const gui_simple_message_content_names_t *content_id,
358 : const char *list_of_names )
359 : {
360 0 : U8_TRACE_BEGIN();
361 0 : assert( content_id != NULL );
362 0 : assert( list_of_names != NULL );
363 :
364 : /* update type id: */
365 0 : (*this_).type_id = type_id;
366 0 : gui_simple_message_to_user_private_set_icon_image( this_, type_id );
367 :
368 : /* update content text: */
369 0 : utf8stringbuf_clear( &((*this_).private_temp_str) );
370 : {
371 0 : U8_LOG_ERROR("unexptected content_id");
372 0 : assert(false);
373 : }
374 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ));
375 :
376 : /* show: */
377 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
378 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
379 :
380 : U8_TRACE_END();
381 : }
382 :
383 0 : void gui_simple_message_to_user_show_message_with_error ( gui_simple_message_to_user_t *this_,
384 : gui_simple_message_type_t type_id,
385 : const gui_simple_message_content_error_t *content_id,
386 : const char *error_message )
387 : {
388 0 : U8_TRACE_BEGIN();
389 0 : assert( content_id != NULL );
390 0 : assert( error_message != NULL );
391 :
392 : /* update type id: */
393 0 : (*this_).type_id = type_id;
394 0 : gui_simple_message_to_user_private_set_icon_image( this_, type_id );
395 :
396 : /* update content text: */
397 0 : utf8stringbuf_clear( &((*this_).private_temp_str) );
398 0 : if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_NOT_YET_IMPLEMENTED )
399 : {
400 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_NOT_YET_IMPLEMENTED" );
401 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "This feature is not yet implemented: " );
402 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), error_message );
403 : }
404 : else
405 : {
406 0 : U8_LOG_ERROR("unexptected content_id");
407 0 : assert(false);
408 : }
409 0 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ));
410 :
411 : /* show: */
412 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
413 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
414 :
415 0 : U8_TRACE_END();
416 0 : }
417 :
418 : const char *const (gui_simple_message_to_user_private_table_name[DATA_STAT_TABLE_MAX])
419 : = {"lifelines","classifiers","features","relationships","classifier-occurrences","diagrams"};
420 : const char *const (gui_simple_message_to_user_private_series_name4change[DATA_STAT_SERIES_MAX])
421 : = {"created","modified","deleted","ignored","warning","error"};
422 : const char *const (gui_simple_message_to_user_private_series_name4other[DATA_STAT_SERIES_MAX])
423 : = {"exported","un/selected","deleted","ignored","warning","error"};
424 :
425 0 : void gui_simple_message_to_user_show_message_with_stat ( gui_simple_message_to_user_t *this_,
426 : gui_simple_message_type_t type_id,
427 : const gui_simple_message_content_stat_t *content_id,
428 : const data_stat_t *stat
429 : )
430 : {
431 0 : U8_TRACE_BEGIN();
432 0 : assert( stat != NULL );
433 0 : assert( content_id != NULL );
434 0 : data_stat_trace( stat );
435 :
436 : /* update type id: */
437 0 : (*this_).type_id = type_id;
438 0 : gui_simple_message_to_user_private_set_icon_image( this_, type_id );
439 :
440 : /* update content text: */
441 0 : utf8stringbuf_clear( &((*this_).private_temp_str) );
442 0 : if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_CUT_TO_CLIPBOARD )
443 : {
444 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_CUT_TO_CLIPBOARD" );
445 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "Selection cut to clipboard: \n" );
446 0 : gui_simple_message_to_user_private_append_stat( this_, stat, true, (*this_).private_temp_str );
447 : }
448 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_COPY_TO_CLIPBOARD )
449 : {
450 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_COPY_TO_CLIPBOARD" );
451 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "Selection copied to clipboard: \n" );
452 0 : gui_simple_message_to_user_private_append_stat( this_, stat, true, (*this_).private_temp_str );
453 : }
454 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_PASTE_FROM_CLIPBOARD )
455 : {
456 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_PASTE_FROM_CLIPBOARD" );
457 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "Clipboard pasted: \n" );
458 0 : gui_simple_message_to_user_private_append_stat( this_, stat, false, (*this_).private_temp_str );
459 : }
460 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_DELETE )
461 : {
462 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_DELETE" );
463 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "Selection deleted: \n" );
464 0 : gui_simple_message_to_user_private_append_stat( this_, stat, false, (*this_).private_temp_str );
465 : }
466 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_UNDO )
467 : {
468 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_UNDO" );
469 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "Undo success: \n" );
470 0 : gui_simple_message_to_user_private_append_stat( this_, stat, false, (*this_).private_temp_str );
471 : }
472 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_REDO )
473 : {
474 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_REDO" );
475 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "Redo success: \n" );
476 0 : gui_simple_message_to_user_private_append_stat( this_, stat, false, (*this_).private_temp_str );
477 : }
478 0 : else if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_TYPE_CHANGE )
479 : {
480 0 : U8_LOG_EVENT( "GUI_SIMPLE_MESSAGE_CONTENT_TYPE_CHANGE" );
481 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "Type changed: \n" );
482 0 : gui_simple_message_to_user_private_append_stat( this_, stat, false, (*this_).private_temp_str );
483 : }
484 : else
485 : {
486 0 : U8_LOG_ERROR("unexptected content_id");
487 0 : assert(false);
488 : }
489 0 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ));
490 :
491 : /* show: */
492 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
493 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
494 :
495 0 : U8_TRACE_END();
496 0 : }
497 :
498 0 : void gui_simple_message_to_user_show_message_with_names_and_stat( gui_simple_message_to_user_t *this_,
499 : gui_simple_message_type_t type_id,
500 : const gui_simple_message_content_names_stat_t *content_id,
501 : const char *list_of_names,
502 : const data_stat_t *stat )
503 : {
504 0 : U8_TRACE_BEGIN();
505 0 : assert( stat != NULL );
506 0 : assert( list_of_names != NULL );
507 0 : assert( content_id != NULL );
508 0 : data_stat_trace( stat );
509 :
510 : /* update type id: */
511 0 : (*this_).type_id = type_id;
512 0 : gui_simple_message_to_user_private_set_icon_image( this_, type_id );
513 :
514 : /* update content text: */
515 0 : utf8stringbuf_clear( &((*this_).private_temp_str) );
516 0 : if ( content_id == GUI_SIMPLE_MESSAGE_CONTENT_EXPORT_FINISHED )
517 : {
518 0 : U8_LOG_EVENT_STR( "GUI_SIMPLE_MESSAGE_CONTENT_EXPORT_FINISHED", list_of_names );
519 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "Files exported, format: " );
520 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), list_of_names );
521 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "\n" );
522 0 : gui_simple_message_to_user_private_append_stat( this_, stat, true, (*this_).private_temp_str );
523 0 : if ( 0 != data_stat_get_series_count ( stat, DATA_STAT_SERIES_WARNING ) )
524 : {
525 0 : utf8stringbuf_append_str( &((*this_).private_temp_str), "\nFor details see comments in exported xmi file." );
526 : }
527 : }
528 : else
529 : {
530 0 : U8_LOG_ERROR("unexptected content_id");
531 0 : assert(false);
532 : }
533 0 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ));
534 :
535 : /* show: */
536 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
537 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
538 :
539 0 : U8_TRACE_END();
540 0 : }
541 :
542 0 : void gui_simple_message_to_user_private_append_stat ( gui_simple_message_to_user_t *this_,
543 : const data_stat_t *stat,
544 : bool alt_labels,
545 : utf8stringbuf_t out_buf
546 : )
547 : {
548 0 : U8_TRACE_BEGIN();
549 0 : assert( stat != NULL );
550 :
551 0 : bool first_series = true;
552 0 : for ( int series_idx = 0; series_idx < DATA_STAT_SERIES_MAX; series_idx ++ )
553 : {
554 0 : if ( 0 != data_stat_get_series_count ( stat, series_idx ) )
555 : {
556 0 : if ( first_series )
557 : {
558 0 : first_series = false;
559 : }
560 : else
561 : {
562 0 : utf8stringbuf_append_str( &out_buf, "\n" );
563 : }
564 0 : const char *const series_name
565 : = alt_labels
566 : ? gui_simple_message_to_user_private_series_name4other[series_idx]
567 0 : : gui_simple_message_to_user_private_series_name4change[series_idx];
568 0 : utf8stringbuf_append_str( &out_buf, series_name );
569 0 : utf8stringbuf_append_str( &out_buf, ": " );
570 :
571 0 : bool first_table = true;
572 0 : for ( int tables_idx = 0; tables_idx < DATA_STAT_TABLE_MAX; tables_idx ++ )
573 : {
574 0 : uint_fast32_t cnt = data_stat_get_count ( stat, tables_idx, series_idx );
575 0 : if ( 0 != cnt )
576 : {
577 0 : if ( first_table )
578 : {
579 0 : first_table = false;
580 : }
581 : else
582 : {
583 0 : utf8stringbuf_append_str( &out_buf, ", " );
584 : }
585 0 : const char *const table_name = gui_simple_message_to_user_private_table_name[tables_idx];
586 0 : utf8stringbuf_append_str( &out_buf, table_name );
587 0 : utf8stringbuf_append_str( &out_buf, ":" );
588 0 : utf8stringbuf_append_int( &out_buf, cnt );
589 : }
590 : }
591 : }
592 : }
593 0 : if ( 0 == data_stat_get_total_count ( stat ) )
594 : {
595 0 : utf8stringbuf_append_str( &out_buf, "0" );
596 : }
597 0 : U8_TRACE_INFO( utf8stringbuf_get_string( &out_buf ) );
598 :
599 0 : U8_TRACE_END();
600 0 : }
601 :
602 0 : void gui_simple_message_to_user_show_error_info ( gui_simple_message_to_user_t *this_, const u8_error_info_t *err_info )
603 : {
604 0 : U8_TRACE_BEGIN();
605 :
606 : /* update type id: */
607 0 : (*this_).type_id = GUI_SIMPLE_MESSAGE_TYPE_ERROR;
608 0 : gui_simple_message_to_user_private_set_icon_image( this_, GUI_SIMPLE_MESSAGE_TYPE_ERROR );
609 :
610 : /* update content text: */
611 0 : utf8stringbuf_clear( &((*this_).private_temp_str) );
612 : {
613 : gui_error_info_printer_t my_err_info_printer;
614 0 : gui_error_info_printer_init( &my_err_info_printer );
615 0 : gui_error_info_printer_show_error_info( &my_err_info_printer, err_info, (*this_).private_temp_str );
616 0 : gui_error_info_printer_destroy( &my_err_info_printer );
617 : }
618 0 : gtk_label_set_text ( GTK_LABEL( (*this_).text_label ), utf8stringbuf_get_string( &((*this_).private_temp_str) ) );
619 :
620 : /* show: */
621 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), TRUE );
622 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), TRUE );
623 :
624 0 : U8_TRACE_END();
625 0 : }
626 :
627 0 : void gui_simple_message_to_user_hide ( gui_simple_message_to_user_t *this_ )
628 : {
629 0 : U8_TRACE_BEGIN();
630 :
631 0 : (*this_).type_id = GUI_SIMPLE_MESSAGE_TYPE_NO_MESSAGE;
632 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).text_label ), FALSE );
633 0 : gtk_widget_set_visible( GTK_WIDGET ( (*this_).icon_image ), FALSE );
634 :
635 0 : U8_TRACE_END();
636 0 : }
637 :
638 :
639 : /*
640 : Copyright 2016-2025 Andreas Warnke
641 :
642 : Licensed under the Apache License, Version 2.0 (the "License");
643 : you may not use this file except in compliance with the License.
644 : You may obtain a copy of the License at
645 :
646 : http://www.apache.org/licenses/LICENSE-2.0
647 :
648 : Unless required by applicable law or agreed to in writing, software
649 : distributed under the License is distributed on an "AS IS" BASIS,
650 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
651 : See the License for the specific language governing permissions and
652 : limitations under the License.
653 : */
|