LCOV - code coverage report
Current view: top level - gui/source - gui_main_window.c (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.61.0_covts Lines: 0 599 0.0 %
Date: 2024-10-26 21:44:38 Functions: 0 17 0.0 %

          Line data    Source code
       1             : /* File: gui_main_window.c; Copyright and License: see below */
       2             : 
       3             : #include "gui_main_window.h"
       4             : #include "gui_clipboard.h"
       5             : #include "gui_type_resource.h"
       6             : #include "u8/u8_trace.h"
       7             : #include "entity/data_diagram_type.h"
       8             : #include "entity/data_classifier_type.h"
       9             : #include "entity/data_feature_type.h"
      10             : #include "entity/data_relationship_type.h"
      11             : #include "storage/data_database.h"
      12             : #include "storage/data_change_notifier.h"
      13             : #include "meta/meta_info.h"
      14             : #ifndef NDEBUG
      15             : #include "u8stream/universal_stream_output_stream.h"
      16             : #include "utf8stream/utf8stream_writer.h"
      17             : #endif  /* not NDEBUG */
      18             : #include <gdk/gdk.h>
      19             : #include <gtk/gtk.h>
      20             : #include <stdio.h>
      21             : #include <stdbool.h>
      22             : 
      23           0 : void gui_main_window_init( gui_main_window_t *this_,
      24             :                            ctrl_controller_t *controller,
      25             :                            io_data_file_t *data_file,
      26             :                            data_database_reader_t *db_reader,
      27             :                            gui_resources_t *res,
      28             :                            GtkApplication *gtk_app,
      29             :                            observer_t *window_close_observer,
      30             :                            observer_t *window_open_observer )
      31             : {
      32           0 :     U8_TRACE_BEGIN();
      33           0 :     assert( gtk_app != NULL );
      34             : 
      35             :     /* init own attributes */
      36           0 :     (*this_).window_close_observer = window_close_observer;
      37           0 :     (*this_).window_open_observer = window_open_observer;
      38           0 :     (*this_).data_file = data_file;
      39             : #ifndef NDEBUG
      40           0 :     (*this_).controller = controller;
      41             : #endif  /* not NDEBUG */
      42             : 
      43             :     /* init window */
      44             :     {
      45           0 :         (*this_).window = gtk_application_window_new( gtk_app );
      46             :         const char *window_title;
      47           0 :         window_title = io_data_file_get_filename_const( data_file );
      48           0 :         gtk_window_set_title(GTK_WINDOW( (*this_).window ), ( window_title == NULL ) ? META_INFO_PROGRAM_NAME_STR : window_title );
      49           0 :         gtk_widget_set_size_request( (*this_).window, 800, 400 );
      50           0 :         gtk_window_set_default_size( GTK_WINDOW( (*this_).window ), 16*70, 9*70 );
      51             :     }
      52             : 
      53             :     /* init the message widgets */
      54           0 :     gui_main_window_private_init_simple_message_to_user( this_, res );
      55           0 :     gui_simple_message_to_user_init( &((*this_).message_to_user), (*this_).message_text_label, (*this_).message_icon_image, res );
      56             : 
      57             :     /* init the keyboard shortcuts */
      58             :     {
      59           0 :         (*this_).keyboard_shortcut_ctrl = GTK_SHORTCUT_CONTROLLER(gtk_shortcut_controller_new());
      60           0 :         gtk_widget_add_controller( (*this_).window, GTK_EVENT_CONTROLLER((*this_).keyboard_shortcut_ctrl) );
      61             :     }
      62             : 
      63             :     /* init tools */
      64           0 :     gui_main_window_private_init_toolbox( this_, res );
      65             : 
      66             :     /* determine the current/main clipboard */
      67           0 :     GdkClipboard *current_clipboard = NULL;
      68             :     {
      69           0 :         current_clipboard = gtk_widget_get_clipboard( GTK_WIDGET((*this_).window) );  /* idea taken from gtk demo */
      70             :     }
      71             : 
      72           0 :     gui_marked_set_init( &((*this_).marker_data),
      73           0 :                          G_OBJECT((*this_).window),
      74             :                          &gui_sketch_area_show_diagram,
      75           0 :                          &((*this_).sketcharea_data)
      76             :                        );
      77           0 :     gui_toolbox_init( &((*this_).tools_data),
      78           0 :                       GTK_WIDGET((*this_).tool_row),
      79           0 :                       GTK_WIDGET((*this_).view_navigate),
      80           0 :                       GTK_WIDGET((*this_).view_edit),
      81           0 :                       GTK_WIDGET((*this_).view_create),
      82           0 :                       GTK_WIDGET((*this_).view_search),
      83             :                       current_clipboard,
      84             :                       &((*this_).marker_data),
      85             :                       &((*this_).message_to_user),
      86             :                       db_reader,
      87             :                       controller
      88             :                     );
      89             : 
      90             :     /* init search widgets and sketch area */
      91           0 :     gui_main_window_private_init_search_and_sketch_area( this_, res );
      92           0 :     gui_search_runner_init( &((*this_).search_runner),
      93             :                             &((*this_).message_to_user),
      94             :                             db_reader,
      95             :                             io_data_file_get_database_ptr( data_file ),
      96             :                             &((*this_).sketcharea_data)
      97             :                           );
      98           0 :     gui_search_request_init( &((*this_).search_request),
      99             :                              (*this_).search_label,
     100             :                              (*this_).search_entry,
     101             :                              (*this_).search_button,
     102             :                              &((*this_).marker_data),
     103             :                              &((*this_).search_runner)
     104             :                            );
     105           0 :     gui_sketch_area_init( &((*this_).sketcharea_data),
     106             :                           (*this_).sketcharea,
     107             :                           &((*this_).marker_data),
     108             :                           &((*this_).tools_data),
     109             :                           &((*this_).message_to_user),
     110             :                           res,
     111             :                           controller,
     112             :                           db_reader
     113             :                         );
     114             : 
     115             :     /* init attribute editor widgets */
     116           0 :     gui_main_window_private_init_attributes_editor( this_, res );
     117             : 
     118           0 :     gui_attributes_editor_init( &((*this_).attributes_editor),
     119           0 :                                 GTK_LABEL( (*this_).id_label ),
     120           0 :                                 GTK_ENTRY( (*this_).name_entry ),
     121           0 :                                 GTK_ENTRY( (*this_).stereotype_entry ),
     122             :                                 (*this_).type_dropdown,
     123           0 :                                 GTK_WIDGET( (*this_).type_diag_grid ),
     124           0 :                                 GTK_WIDGET( (*this_).type_clas_grid ),
     125           0 :                                 GTK_WIDGET( (*this_).type_feat_grid ),
     126           0 :                                 GTK_WIDGET( (*this_).type_rel_grid ),
     127           0 :                                 GTK_TEXT_VIEW( (*this_).description_text_view ),
     128           0 :                                 GTK_BUTTON( (*this_).file_save_button ),
     129             :                                 res,
     130             :                                 controller,
     131             :                                 db_reader,
     132             :                                 io_data_file_get_database_ptr( data_file ),
     133             :                                 &((*this_).message_to_user)
     134             :                               );
     135             : 
     136             :     /* init the file choosers */
     137           0 :     gui_file_use_db_dialog_init( &((*this_).file_use_db_dialog),
     138             :                                  controller,
     139             :                                  data_file,
     140           0 :                                  GTK_WINDOW( (*this_).window ),
     141             :                                  &((*this_).message_to_user)
     142             :                                );
     143           0 :     gui_file_export_dialog_init( &((*this_).file_export_dialog),
     144             :                                  io_data_file_get_database_ptr( data_file ),
     145             :                                  db_reader,
     146           0 :                                  GTK_WINDOW( (*this_).window ),
     147             :                                  &((*this_).message_to_user)
     148             :                                );
     149             : 
     150           0 :     U8_TRACE_INFO("GTK+ Widgets are created.");
     151             : 
     152           0 :     (*this_).two_panes = gtk_paned_new( GTK_ORIENTATION_HORIZONTAL );
     153           0 :     gtk_paned_set_start_child( GTK_PANED((*this_).two_panes), (*this_).sketch_stack_column );
     154           0 :     gtk_paned_set_resize_start_child( GTK_PANED((*this_).two_panes), true );
     155           0 :     gtk_paned_set_shrink_start_child( GTK_PANED((*this_).two_panes), false );
     156           0 :     gtk_paned_set_end_child( GTK_PANED((*this_).two_panes), (*this_).attr_edit_column );
     157           0 :     gtk_paned_set_resize_end_child( GTK_PANED((*this_).two_panes), false );
     158           0 :     gtk_paned_set_shrink_end_child( GTK_PANED((*this_).two_panes), true );
     159           0 :     gtk_widget_set_vexpand( GTK_WIDGET( (*this_).sketch_stack_column ), true );
     160           0 :     gtk_widget_set_hexpand( GTK_WIDGET( (*this_).sketch_stack_column ), true );
     161           0 :     gtk_widget_set_vexpand( GTK_WIDGET( (*this_).attr_edit_column ), true );
     162           0 :     gtk_widget_set_hexpand( GTK_WIDGET( (*this_).attr_edit_column ), false );
     163           0 :     gtk_paned_set_position( GTK_PANED((*this_).two_panes), 11*70 );
     164             : 
     165           0 :     (*this_).main_stack_column = gtk_box_new( GTK_ORIENTATION_VERTICAL, /*spacing:*/ 0 );
     166           0 :     gtk_box_append( GTK_BOX((*this_).main_stack_column), GTK_WIDGET((*this_).tool_row) );
     167           0 :     (*this_).options_layout = gui_file_export_dialog_get_options( &((*this_).file_export_dialog) );
     168           0 :     gtk_box_append( GTK_BOX((*this_).main_stack_column), (*this_).options_layout );
     169           0 :     gtk_box_append( GTK_BOX((*this_).main_stack_column), GTK_WIDGET((*this_).two_panes) );
     170           0 :     gtk_box_append( GTK_BOX((*this_).main_stack_column), GTK_WIDGET((*this_).message_row) );
     171           0 :     gtk_widget_set_vexpand( GTK_WIDGET( (*this_).tool_row ), false );
     172           0 :     gtk_widget_set_hexpand( GTK_WIDGET( (*this_).tool_row ), true );
     173           0 :     gtk_widget_set_vexpand( GTK_WIDGET( (*this_).two_panes ), true );
     174           0 :     gtk_widget_set_hexpand( GTK_WIDGET( (*this_).two_panes ), true );
     175           0 :     gtk_widget_set_vexpand( GTK_WIDGET( (*this_).message_row ), false );
     176           0 :     gtk_widget_set_hexpand( GTK_WIDGET( (*this_).message_row ), true );
     177             : 
     178           0 :     gtk_window_set_child( GTK_WINDOW((*this_).window), (*this_).main_stack_column );
     179           0 :     gtk_window_set_resizable( GTK_WINDOW((*this_).window), true );
     180             : 
     181           0 :     U8_TRACE_INFO("GTK+ Widgets are added to containers.");
     182             : 
     183             :     /* inject dependencies by signals */
     184             :     /* parameter info: g_signal_connect( instance-that-emits-the-signal, signal-name, callback-handler, data-to-be-passed-to-callback-handler) */
     185           0 :     g_signal_connect( G_OBJECT((*this_).window), "close-request", G_CALLBACK(gui_main_window_delete_event_callback), this_ );
     186           0 :     g_signal_connect( G_OBJECT((*this_).window), "destroy", G_CALLBACK(gui_main_window_destroy_event_callback), this_ );
     187           0 :     g_signal_connect( G_OBJECT((*this_).window), DATA_CHANGE_NOTIFIER_GLIB_SIGNAL_NAME, G_CALLBACK(gui_main_window_data_changed_callback), this_ );
     188           0 :     g_signal_connect( G_OBJECT((*this_).sketcharea), DATA_CHANGE_NOTIFIER_GLIB_SIGNAL_NAME, G_CALLBACK(gui_sketch_area_data_changed_callback), &((*this_).sketcharea_data) );
     189           0 :     g_signal_connect( G_OBJECT((*this_).tool_row), GUI_TOOLBOX_GLIB_SIGNAL_NAME, G_CALLBACK(gui_sketch_area_tool_changed_callback), &((*this_).sketcharea_data) );
     190           0 :     g_signal_connect( G_OBJECT((*this_).file_new_db), "clicked", G_CALLBACK(gui_main_window_new_db_btn_callback), this_ );
     191           0 :     g_signal_connect( G_OBJECT((*this_).file_use_db), "clicked", G_CALLBACK(gui_main_window_open_db_btn_callback), this_ );
     192           0 :     g_signal_connect( G_OBJECT((*this_).file_save_button), "clicked", G_CALLBACK(gui_main_window_save_btn_callback), this_ );
     193           0 :     g_signal_connect( G_OBJECT((*this_).file_export), "clicked", G_CALLBACK(gui_main_window_export_btn_callback), this_ );
     194           0 :     g_signal_connect( G_OBJECT((*this_).view_new_window), "clicked", G_CALLBACK(gui_main_window_new_window_btn_callback), this_ );
     195             : 
     196           0 :     gui_toolbox_t *const tools = &((*this_).tools_data);
     197           0 :     g_signal_connect( G_OBJECT((*this_).view_navigate), "clicked", G_CALLBACK(gui_toolbox_navigate_btn_callback), tools );
     198           0 :     g_signal_connect( G_OBJECT((*this_).view_edit), "clicked", G_CALLBACK(gui_toolbox_edit_btn_callback), tools );
     199           0 :     g_signal_connect( G_OBJECT((*this_).view_create), "clicked", G_CALLBACK(gui_toolbox_create_btn_callback), tools );
     200           0 :     g_signal_connect( G_OBJECT((*this_).view_search), "clicked", G_CALLBACK(gui_toolbox_search_btn_callback), tools );
     201             : 
     202             :     /* The search id button is connected to two callback functions: one to switch to search mode, one to perform a search: */
     203           0 :     g_signal_connect( G_OBJECT((*this_).id_search_btn),
     204             :                       "clicked",
     205             :                       G_CALLBACK(gui_toolbox_search_id_btn_callback),
     206             :                       tools
     207             :                     );
     208           0 :     g_signal_connect( G_OBJECT((*this_).id_search_btn),
     209             :                       "clicked",
     210             :                       G_CALLBACK(gui_search_request_id_search_callback),
     211             :                       &((*this_).search_request)
     212             :                     );
     213             : 
     214           0 :     g_signal_connect( G_OBJECT((*this_).tool_row), GUI_TOOLBOX_GLIB_SIGNAL_NAME, G_CALLBACK(gui_search_request_tool_changed_callback), &((*this_).search_request) );
     215           0 :     g_signal_connect( G_OBJECT((*this_).search_entry), DATA_CHANGE_NOTIFIER_GLIB_SIGNAL_NAME, G_CALLBACK(gui_search_request_data_changed_callback), &((*this_).search_request) );
     216           0 :     g_signal_connect( G_OBJECT((*this_).search_entry), "activate", G_CALLBACK(gui_search_request_search_start_callback), &((*this_).search_request) );
     217           0 :     g_signal_connect( G_OBJECT((*this_).search_button), "clicked", G_CALLBACK(gui_search_request_search_start_callback), &((*this_).search_request) );
     218             : 
     219           0 :     g_signal_connect( G_OBJECT((*this_).edit_undo), "clicked", G_CALLBACK(gui_toolbox_undo_btn_callback), tools );
     220           0 :     g_signal_connect( G_OBJECT((*this_).edit_redo), "clicked", G_CALLBACK(gui_toolbox_redo_btn_callback), tools );
     221           0 :     g_signal_connect( G_OBJECT((*this_).edit_cut), "clicked", G_CALLBACK(gui_toolbox_cut_btn_callback), tools );
     222           0 :     g_signal_connect( G_OBJECT((*this_).edit_copy), "clicked", G_CALLBACK(gui_toolbox_copy_btn_callback), tools );
     223           0 :     g_signal_connect( G_OBJECT((*this_).edit_paste), "clicked", G_CALLBACK(gui_toolbox_paste_btn_callback), tools );
     224           0 :     g_signal_connect( G_OBJECT((*this_).edit_delete), "clicked", G_CALLBACK(gui_toolbox_delete_btn_callback), tools );
     225           0 :     g_signal_connect( G_OBJECT((*this_).edit_instantiate), "clicked", G_CALLBACK(gui_toolbox_instantiate_btn_callback), tools );
     226           0 :     g_signal_connect( G_OBJECT((*this_).edit_highlight), "clicked", G_CALLBACK(gui_toolbox_highlight_btn_callback), tools );
     227           0 :     g_signal_connect( G_OBJECT((*this_).edit_reset), "clicked", G_CALLBACK(gui_toolbox_reset_btn_callback), tools );
     228             : 
     229           0 :     g_signal_connect( G_OBJECT((*this_).name_entry),
     230             :                       "activate",
     231             :                       G_CALLBACK(gui_attributes_editor_name_enter_callback),
     232             :                       &((*this_).attributes_editor)
     233             :                     );
     234             :     {
     235           0 :         GtkEventControllerFocus *evt_focus_n = GTK_EVENT_CONTROLLER_FOCUS(gtk_event_controller_focus_new());
     236           0 :         g_signal_connect( evt_focus_n,
     237             :                           "leave",
     238             :                           G_CALLBACK(gui_attributes_editor_name_focus_left_callback),
     239             :                           &((*this_).attributes_editor)
     240             :                         );
     241           0 :         gtk_widget_add_controller( (*this_).name_entry, GTK_EVENT_CONTROLLER(evt_focus_n) );
     242             :     }
     243             :     {
     244           0 :         GtkEventControllerFocus *evt_focus_s = GTK_EVENT_CONTROLLER_FOCUS(gtk_event_controller_focus_new());
     245           0 :         g_signal_connect( evt_focus_s,
     246             :                           "leave",
     247             :                           G_CALLBACK(gui_attributes_editor_stereotype_focus_left_callback),
     248             :                           &((*this_).attributes_editor)
     249             :                         );
     250           0 :         gtk_widget_add_controller( (*this_).stereotype_entry, GTK_EVENT_CONTROLLER(evt_focus_s) );
     251             :     }
     252             :     {
     253           0 :         GtkEventControllerFocus *evt_focus_d = GTK_EVENT_CONTROLLER_FOCUS(gtk_event_controller_focus_new());
     254           0 :         g_signal_connect( evt_focus_d,
     255             :                           "leave",
     256             :                           G_CALLBACK(gui_attributes_editor_description_focus_left_callback),
     257             :                           &((*this_).attributes_editor)
     258             :                         );
     259           0 :         gtk_widget_add_controller( (*this_).description_text_view, GTK_EVENT_CONTROLLER(evt_focus_d) );
     260             :     }
     261           0 :     g_signal_connect( G_OBJECT((*this_).stereotype_entry), "activate", G_CALLBACK(gui_attributes_editor_stereotype_enter_callback), &((*this_).attributes_editor) );
     262           0 :     g_signal_connect_after( G_OBJECT((*this_).type_dropdown), "notify::selected", G_CALLBACK(gui_attributes_editor_type_changed_callback), &((*this_).attributes_editor));
     263           0 :     for( int_fast32_t diag_idx = 0; diag_idx < GUI_TYPE_RESOURCE_LIST_DIAGRAMS; diag_idx ++ )
     264             :     {
     265           0 :         g_signal_connect( G_OBJECT((*this_).type_diag_btn[ diag_idx ]),
     266             :                           "clicked",
     267             :                           G_CALLBACK( gui_attributes_editor_type_of_diagram_btn_callback ),
     268             :                           &((*this_).type_diag_data[diag_idx])
     269             :                         );
     270             :     }
     271           0 :     for( int_fast32_t clas_idx = 0; clas_idx < GUI_TYPE_RESOURCE_LIST_CLASSIFIERS; clas_idx ++ )
     272             :     {
     273           0 :         g_signal_connect( G_OBJECT((*this_).type_clas_btn[ clas_idx ]),
     274             :                           "clicked",
     275             :                           G_CALLBACK( gui_attributes_editor_type_of_classifier_btn_callback ),
     276             :                           &((*this_).type_clas_data[clas_idx])
     277             :                         );
     278             :     }
     279           0 :     for( int_fast32_t feat_idx = 0; feat_idx < GUI_TYPE_RESOURCE_LIST_INV_FEATURES; feat_idx ++ )
     280             :     {
     281           0 :         g_signal_connect( G_OBJECT((*this_).type_feat_btn[ feat_idx ]),
     282             :                           "clicked",
     283             :                           G_CALLBACK( gui_attributes_editor_type_of_feature_btn_callback ),
     284             :                           &((*this_).type_feat_data[feat_idx])
     285             :                         );
     286             :     }
     287           0 :     for( int_fast32_t rel_idx = 0; rel_idx < GUI_TYPE_RESOURCE_LIST_RELATIONS; rel_idx ++ )
     288             :     {
     289           0 :         g_signal_connect( G_OBJECT((*this_).type_rel_btn[ rel_idx ]),
     290             :                           "clicked",
     291             :                           G_CALLBACK( gui_attributes_editor_type_of_relationship_btn_callback ),
     292             :                           &((*this_).type_rel_data[rel_idx])
     293             :                         );
     294             :     }
     295           0 :     g_signal_connect( G_OBJECT((*this_).window), GUI_MARKED_SET_GLIB_SIGNAL_NAME, G_CALLBACK(gui_attributes_editor_focused_object_changed_callback), &((*this_).attributes_editor) );
     296           0 :     g_signal_connect( G_OBJECT((*this_).name_entry), DATA_CHANGE_NOTIFIER_GLIB_SIGNAL_NAME, G_CALLBACK(gui_attributes_editor_data_changed_callback), &((*this_).attributes_editor) );
     297             :         /* ^-- name_entry is the  proxy for all widgets of attributes_editor */
     298             : 
     299           0 :     g_signal_connect( G_OBJECT((*this_).tool_about), "clicked", G_CALLBACK(gui_main_window_about_btn_callback), this_ );
     300             : 
     301           0 :     U8_TRACE_INFO("GTK+ Callbacks are connected to widget events.");
     302             : 
     303             :     /* register observers */
     304             : 
     305           0 :     (*this_).data_notifier = data_database_get_notifier_ptr( io_data_file_get_database_ptr( data_file ) );
     306           0 :     data_change_notifier_add_listener( (*this_).data_notifier, G_OBJECT((*this_).window) );
     307           0 :     data_change_notifier_add_listener( (*this_).data_notifier, G_OBJECT((*this_).sketcharea) );
     308           0 :     data_change_notifier_add_listener( (*this_).data_notifier, G_OBJECT((*this_).name_entry) );
     309             :         /* ^-- name_entry is the  proxy for all widgets of attributes_editor */
     310           0 :     data_change_notifier_add_listener( (*this_).data_notifier, G_OBJECT((*this_).search_entry) );
     311             : 
     312           0 :     U8_TRACE_INFO("GTK+ Widgets are registered as listeners at signal emitter.");
     313             : 
     314           0 :     gtk_widget_set_visible( (*this_).window, TRUE );
     315           0 :     gtk_widget_set_sensitive( GTK_WIDGET((*this_).window), TRUE );  /* idea taken from gtk demo */
     316             : 
     317           0 :     GdkSurface *surface = gtk_native_get_surface( GTK_NATIVE((*this_).window) );
     318           0 :     gdk_surface_set_cursor( surface, NULL );  /* idea taken from gtk3->4 guide */
     319             : 
     320           0 :     gui_attributes_editor_update_widgets( &((*this_).attributes_editor) );  /* hide some widgets again */
     321             : #ifdef NDEBUG
     322             :     gui_simple_message_to_user_hide( &((*this_).message_to_user) );
     323             : #else
     324           0 :     gui_simple_message_to_user_show_message ( &((*this_).message_to_user), GUI_SIMPLE_MESSAGE_TYPE_INFO, GUI_SIMPLE_MESSAGE_CONTENT_DEBUG_MODE );
     325             : #endif
     326           0 :     gui_search_request_hide( &((*this_).search_request) );
     327           0 :     U8_TRACE_INFO("GTK+ Widgets are shown.");
     328           0 :     U8_TRACE_END();
     329           0 : }
     330             : 
     331           0 : void gui_main_window_destroy( gui_main_window_t *this_ )
     332             : {
     333           0 :     U8_TRACE_BEGIN();
     334             : 
     335             :     /* Note: The widgets may be destroyed already. A cast by G_OBJECT is therefore illegal. */
     336           0 :     data_change_notifier_remove_listener( (*this_).data_notifier, (GObject*)(*this_).window );
     337           0 :     data_change_notifier_remove_listener( (*this_).data_notifier, (GObject*)(*this_).name_entry );
     338           0 :     data_change_notifier_remove_listener( (*this_).data_notifier, (GObject*)(*this_).sketcharea );
     339           0 :     data_change_notifier_remove_listener( (*this_).data_notifier, (GObject*)(*this_).search_entry );
     340             : 
     341           0 :     U8_TRACE_INFO("GTK+ Widgets are unregistered as listeners from data module.");
     342           0 :     gui_file_export_dialog_destroy ( &((*this_).file_export_dialog) );
     343           0 :     gui_file_use_db_dialog_destroy ( &((*this_).file_use_db_dialog) );
     344           0 :     U8_TRACE_INFO("GTK+ hidden windows are destroyed.");
     345             : 
     346           0 :     gui_search_request_destroy( &((*this_).search_request) );
     347           0 :     gui_search_runner_destroy( &((*this_).search_runner) );
     348           0 :     gui_sketch_area_destroy( &((*this_).sketcharea_data) );
     349           0 :     gui_toolbox_destroy( &((*this_).tools_data) );
     350           0 :     gui_marked_set_destroy( &((*this_).marker_data) );
     351           0 :     gui_attributes_editor_destroy( &((*this_).attributes_editor) );
     352           0 :     gui_simple_message_to_user_destroy( &((*this_).message_to_user) );
     353           0 :     (*this_).data_file = NULL;
     354             : #ifndef NDEBUG
     355           0 :     (*this_).controller = NULL;
     356             : #endif  /* not NDEBUG */
     357             : 
     358           0 :     U8_TRACE_END();
     359           0 : }
     360             : 
     361           0 : static inline void gtk_button_set_image( GtkButton *btn, GtkWidget *icon )
     362             : {
     363           0 :     gtk_button_set_child( btn, icon );
     364           0 : }
     365             : 
     366           0 : void gui_main_window_private_init_toolbox( gui_main_window_t *this_, gui_resources_t *res )
     367             : {
     368           0 :     U8_TRACE_BEGIN();
     369             : 
     370           0 :     (*this_).file_new_db_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_file_new_db( res ) ) );
     371           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).file_new_db_icon), 32 /*=w*/ , 32 /*=h*/ );
     372           0 :     (*this_).file_new_db = GTK_BUTTON(gtk_button_new());
     373           0 :     gtk_button_set_image( GTK_BUTTON((*this_).file_new_db), (*this_).file_new_db_icon );
     374           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).file_new_db), "New" );
     375             :     /* gtk_button_set_label( (*this_).file_new_db, "New" ); */
     376             : 
     377           0 :     (*this_).file_use_db_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_file_use_db( res ) ) );
     378           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).file_use_db_icon), 32 /*=w*/ , 32 /*=h*/ );
     379           0 :     (*this_).file_use_db = GTK_BUTTON(gtk_button_new());
     380           0 :     gtk_button_set_image( GTK_BUTTON((*this_).file_use_db), (*this_).file_use_db_icon );
     381           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).file_use_db), "Open" );
     382             : 
     383           0 :     (*this_).file_save_button = gtk_button_new();
     384           0 :     (*this_).file_save_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_file_save( res ) ) );
     385           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).file_save_icon), 32 /*=w*/ , 32 /*=h*/ );
     386           0 :     gtk_button_set_image( GTK_BUTTON((*this_).file_save_button), (*this_).file_save_icon );
     387           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).file_save_button), "Save (Ctrl-S)" );
     388           0 :     GtkShortcutTrigger *commit_trig = gtk_shortcut_trigger_parse_string( "<Control>S" );
     389           0 :     GtkShortcutAction *commit_act = gtk_callback_action_new( &gui_main_window_save_shortcut_callback,
     390             :                                                              this_,
     391             :                                                              NULL
     392             :                                                            );
     393           0 :     GtkShortcut* ctrl_s = gtk_shortcut_new_with_arguments( commit_trig,
     394             :                                                            commit_act,
     395             :                                                            NULL /* = format_string */
     396             :                                                          );
     397           0 :     gtk_shortcut_controller_add_shortcut( (*this_).keyboard_shortcut_ctrl, ctrl_s );
     398             : 
     399           0 :     (*this_).file_export_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_file_export( res ) ) );
     400           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).file_export_icon), 32 /*=w*/ , 32 /*=h*/ );
     401           0 :     (*this_).file_export = GTK_BUTTON(gtk_button_new());
     402           0 :     gtk_button_set_image( GTK_BUTTON((*this_).file_export), (*this_).file_export_icon );
     403           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).file_export), "Export" );
     404             : 
     405           0 :     (*this_).tool_sect_1_icon = gtk_image_new_from_paintable( GDK_PAINTABLE ( gui_resources_get_tool_sect( res ) ) );
     406           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).tool_sect_1_icon), 12 /*=w*/ , 32 /*=h*/ );
     407           0 :     gtk_image_set_pixel_size( GTK_IMAGE((*this_).tool_sect_1_icon), 32 );
     408           0 :     gtk_widget_set_halign( (*this_).tool_sect_1_icon, GTK_ALIGN_START );
     409             : 
     410           0 :      (*this_).tool_sect_2_icon = gtk_image_new_from_paintable( GDK_PAINTABLE ( gui_resources_get_tool_sect( res ) ) );
     411           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).tool_sect_2_icon), 12 /*=w*/ , 32 /*=h*/ );
     412           0 :     gtk_image_set_pixel_size( GTK_IMAGE((*this_).tool_sect_2_icon), 32 );
     413           0 :     gtk_widget_set_halign( (*this_).tool_sect_2_icon, GTK_ALIGN_START );
     414             : 
     415           0 :     (*this_).view_new_window_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_view_new_window( res ) ) );
     416           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).view_new_window_icon), 32 /*=w*/ , 32 /*=h*/ );
     417           0 :     (*this_).view_new_window = GTK_BUTTON(gtk_button_new());
     418           0 :     gtk_button_set_image( GTK_BUTTON((*this_).view_new_window), (*this_).view_new_window_icon );
     419           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).view_new_window), "New Window" );
     420             : 
     421           0 :     (*this_).view_navigate_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_view_navigate( res ) ) );
     422           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).view_navigate_icon), 32 /*=w*/ , 32 /*=h*/ );
     423           0 :     (*this_).view_edit_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_view_edit( res ) ) );
     424           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).view_edit_icon), 32 /*=w*/ , 32 /*=h*/ );
     425           0 :     (*this_).view_create_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_view_create( res ) ) );
     426           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).view_create_icon), 32 /*=w*/ , 32 /*=h*/ );
     427           0 :     (*this_).view_search_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_view_search( res ) ) );
     428           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).view_search_icon), 32 /*=w*/ , 32 /*=h*/ );
     429             : 
     430           0 :     (*this_).view_navigate = gtk_toggle_button_new();
     431           0 :     gtk_button_set_child( GTK_BUTTON((*this_).view_navigate), (*this_).view_navigate_icon );
     432             : 
     433           0 :     (*this_).view_edit = gtk_toggle_button_new();
     434           0 :     gtk_button_set_child( GTK_BUTTON((*this_).view_edit), (*this_).view_edit_icon );
     435           0 :     gtk_toggle_button_set_group( GTK_TOGGLE_BUTTON((*this_).view_edit), GTK_TOGGLE_BUTTON((*this_).view_navigate) );
     436             : 
     437           0 :     (*this_).view_create = gtk_toggle_button_new();
     438           0 :     gtk_button_set_child( GTK_BUTTON((*this_).view_create), (*this_).view_create_icon );
     439           0 :     gtk_toggle_button_set_group( GTK_TOGGLE_BUTTON((*this_).view_create), GTK_TOGGLE_BUTTON((*this_).view_edit) );
     440             : 
     441           0 :     (*this_).view_search = gtk_toggle_button_new();
     442           0 :     gtk_button_set_child( GTK_BUTTON((*this_).view_search), (*this_).view_search_icon );
     443           0 :     gtk_toggle_button_set_group( GTK_TOGGLE_BUTTON((*this_).view_search), GTK_TOGGLE_BUTTON((*this_).view_create) );
     444             : 
     445           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).view_navigate), "Navigate" );
     446           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).view_edit), "Edit" );
     447           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).view_create), "Create" );
     448           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).view_search), "Search" );
     449             : 
     450           0 :     (*this_).edit_undo_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_edit_undo( res ) ) );
     451           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).edit_undo_icon), 32 /*=w*/ , 32 /*=h*/ );
     452           0 :     (*this_).edit_undo = GTK_BUTTON(gtk_button_new());
     453           0 :     gtk_button_set_image( GTK_BUTTON((*this_).edit_undo), (*this_).edit_undo_icon );
     454           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).edit_undo), "Undo (Ctrl-Z)" );
     455           0 :     GtkShortcutTrigger *undo_trig = gtk_shortcut_trigger_parse_string( "<Control>Z" );
     456           0 :     GtkShortcutAction *undo_act = gtk_callback_action_new( &gui_toolbox_undo_shortcut_callback,
     457           0 :                                                            &((*this_).tools_data),
     458             :                                                            NULL
     459             :                                                          );
     460           0 :     GtkShortcut* ctrl_z = gtk_shortcut_new_with_arguments( undo_trig,
     461             :                                                            undo_act,
     462             :                                                            NULL /* = format_string */
     463             :                                                          );
     464           0 :     gtk_shortcut_controller_add_shortcut( (*this_).keyboard_shortcut_ctrl, ctrl_z );
     465             : 
     466           0 :     (*this_).edit_redo_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_edit_redo( res ) ) );
     467           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).edit_redo_icon), 32 /*=w*/ , 32 /*=h*/ );
     468           0 :     (*this_).edit_redo = GTK_BUTTON(gtk_button_new());
     469           0 :     gtk_button_set_image( GTK_BUTTON((*this_).edit_redo), (*this_).edit_redo_icon );
     470           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).edit_redo), "Redo (Ctrl-Y)" );
     471           0 :     GtkShortcutTrigger *redo_trig = gtk_shortcut_trigger_parse_string( "<Control>Y" );
     472           0 :     GtkShortcutAction *redo_act = gtk_callback_action_new( &gui_toolbox_redo_shortcut_callback,
     473           0 :                                                            &((*this_).tools_data),
     474             :                                                            NULL
     475             :                                                          );
     476           0 :     GtkShortcut* ctrl_y = gtk_shortcut_new_with_arguments( redo_trig,
     477             :                                                            redo_act,
     478             :                                                            NULL /* = format_string */
     479             :                                                          );
     480           0 :     gtk_shortcut_controller_add_shortcut( (*this_).keyboard_shortcut_ctrl, ctrl_y );
     481             : 
     482           0 :     (*this_).edit_cut_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_edit_cut( res ) ) );
     483           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).edit_cut_icon), 32 /*=w*/ , 32 /*=h*/ );
     484           0 :     (*this_).edit_cut = GTK_BUTTON(gtk_button_new());
     485           0 :     gtk_button_set_image( GTK_BUTTON((*this_).edit_cut), (*this_).edit_cut_icon );
     486           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).edit_cut), "Cut (Ctrl-X)" );
     487             :     /*
     488             :     GDK_KEY_x + GDK_CONTROL_MASK handling see gui_sketch_area_key_press_callback();
     489             :     moved there to not interfere with text input fields
     490             :     */
     491             : 
     492           0 :     (*this_).edit_copy_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_edit_copy( res ) ) );
     493           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).edit_copy_icon), 32 /*=w*/ , 32 /*=h*/ );
     494           0 :     (*this_).edit_copy = GTK_BUTTON(gtk_button_new());
     495           0 :     gtk_button_set_image( GTK_BUTTON((*this_).edit_copy), (*this_).edit_copy_icon );
     496           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).edit_copy), "Copy (Ctrl-C)" );
     497             :     /*
     498             :     GDK_KEY_c + GDK_CONTROL_MASK handling see gui_sketch_area_key_press_callback();
     499             :     moved there to not interfere with text input fields
     500             :     */
     501             : 
     502           0 :     (*this_).edit_paste_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_edit_paste( res ) ) );
     503           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).edit_paste_icon), 32 /*=w*/ , 32 /*=h*/ );
     504           0 :     (*this_).edit_paste = GTK_BUTTON(gtk_button_new());
     505           0 :     gtk_button_set_image( GTK_BUTTON((*this_).edit_paste), (*this_).edit_paste_icon );
     506           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).edit_paste), "Paste (Ctrl-V)" );
     507             :     /*
     508             :     GK_KEY_v + GDK_CONTROL_MASK handling see gui_sketch_area_key_press_callback();
     509             :     moved there to not interfere with text input fields
     510             :     */
     511             : 
     512           0 :     (*this_).edit_delete_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_edit_delete( res ) ) );
     513           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).edit_delete_icon), 32 /*=w*/ , 32 /*=h*/ );
     514           0 :     (*this_).edit_delete = GTK_BUTTON(gtk_button_new());
     515           0 :     gtk_button_set_image( GTK_BUTTON((*this_).edit_delete), (*this_).edit_delete_icon );
     516           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).edit_delete), "Delete (DEL)" );
     517             :     /*
     518             :     GDK_KEY_Delete handling see gui_sketch_area_key_press_callback();
     519             :     moved there to not interfere with text input fields
     520             :     */
     521             : 
     522           0 :     (*this_).edit_instantiate_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_edit_instantiate( res ) ) );
     523           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).edit_instantiate_icon), 32 /*=w*/ , 32 /*=h*/ );
     524           0 :     (*this_).edit_instantiate = GTK_BUTTON(gtk_button_new());
     525           0 :     gtk_button_set_image( GTK_BUTTON((*this_).edit_instantiate), (*this_).edit_instantiate_icon );
     526           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).edit_instantiate), "Instantiate" );
     527             : 
     528           0 :     (*this_).edit_highlight_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_edit_highlight( res ) ) );
     529           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).edit_highlight_icon), 32 /*=w*/ , 32 /*=h*/ );
     530           0 :     (*this_).edit_highlight = GTK_BUTTON(gtk_button_new());
     531           0 :     gtk_button_set_image( GTK_BUTTON((*this_).edit_highlight), (*this_).edit_highlight_icon );
     532           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).edit_highlight), "Highlight" );
     533             : 
     534           0 :     (*this_).edit_reset_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_edit_reset( res ) ) );
     535           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).edit_reset_icon), 32 /*=w*/ , 32 /*=h*/ );
     536           0 :     (*this_).edit_reset = GTK_BUTTON(gtk_button_new());
     537           0 :     gtk_button_set_image( GTK_BUTTON((*this_).edit_reset), (*this_).edit_reset_icon );
     538           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).edit_reset), "Reset Selection" );
     539             : 
     540           0 :     (*this_).tool_about_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_crystal_facet_uml( res ) ) );
     541           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).tool_about_icon), 32 /*=w*/ , 32 /*=h*/ );
     542           0 :     (*this_).tool_about = GTK_BUTTON(gtk_button_new());
     543           0 :     gtk_button_set_image( GTK_BUTTON((*this_).tool_about), (*this_).tool_about_icon );
     544           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).tool_about), "About" );
     545             : 
     546             :     /* insert widgets to box container */
     547             :     {
     548           0 :         (*this_).tool_row = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, /*spacing:*/ 4 );
     549           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).file_new_db) );
     550           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).file_use_db) );
     551           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).file_save_button) );
     552           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).file_export) );
     553           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).tool_sect_1_icon) );
     554           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).view_new_window) );
     555           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).view_search) );
     556           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).view_navigate) );
     557           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).view_edit) );
     558           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).view_create) );
     559           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).tool_sect_2_icon) );
     560           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).edit_undo) );
     561           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).edit_redo) );
     562           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).edit_cut) );
     563           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).edit_copy) );
     564           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).edit_paste) );
     565           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).edit_delete) );
     566           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).edit_instantiate) );
     567           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).edit_highlight) );
     568           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).edit_reset) );
     569           0 :         gtk_box_append( GTK_BOX((*this_).tool_row), GTK_WIDGET((*this_).tool_about) );
     570             :     }
     571             : 
     572           0 :     U8_TRACE_END();
     573           0 : }
     574             : 
     575           0 : void gui_main_window_private_init_attributes_editor( gui_main_window_t *this_, gui_resources_t *res )
     576             : {
     577           0 :     U8_TRACE_BEGIN();
     578             : 
     579           0 :     (*this_).attr_section_icon = gtk_image_new_from_paintable( GDK_PAINTABLE ( gui_resources_get_edit_attributes_sect( res ) ) );
     580           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).attr_section_icon), 48 /*=w*/ , 12 /*=h*/ );
     581           0 :     gtk_image_set_pixel_size( GTK_IMAGE((*this_).attr_section_icon), 48 );
     582           0 :     gtk_widget_set_halign( (*this_).attr_section_icon, GTK_ALIGN_START );
     583             : 
     584           0 :     (*this_).id_label = gtk_label_new( "" );
     585           0 :     gtk_label_set_selectable( GTK_LABEL( (*this_).id_label ), true );
     586           0 :     (*this_).name_label = gtk_label_new( "Name:" );
     587           0 :     (*this_).description_label = gtk_label_new( "Description:" );
     588           0 :     (*this_).stereotype_label = gtk_label_new( "Stereotype:" );
     589           0 :     (*this_).type_label = gtk_label_new( "Type:" );
     590           0 :     gtk_label_set_xalign( GTK_LABEL( (*this_).id_label ), 1.0 ); /* align right */
     591           0 :     gtk_label_set_xalign( GTK_LABEL( (*this_).name_label ), 0.0 );
     592           0 :     gtk_label_set_xalign( GTK_LABEL( (*this_).description_label ), 0.0 );
     593           0 :     gtk_label_set_xalign( GTK_LABEL( (*this_).stereotype_label ), 0.0 );
     594           0 :     gtk_label_set_xalign( GTK_LABEL( (*this_).type_label ), 0.0 );
     595             : 
     596           0 :     (*this_).id_search_btn = gtk_button_new();
     597           0 :     (*this_).id_search_btn_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_search_search( res ) ) );
     598           0 :     gtk_button_set_image( GTK_BUTTON((*this_).id_search_btn), (*this_).id_search_btn_icon );
     599           0 :     gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).id_search_btn), "Find Occurrences" );
     600           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).id_search_btn_icon), 32 /*=w*/ , 32 /*=h*/ );
     601             : 
     602             :     /* insert widgets to box container */
     603             :     {
     604           0 :         (*this_).id_row = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, /*spacing:*/ 8 );
     605           0 :         gtk_box_append( GTK_BOX((*this_).id_row), GTK_WIDGET((*this_).attr_section_icon) );
     606           0 :         gtk_box_append( GTK_BOX((*this_).id_row), GTK_WIDGET((*this_).id_label) );
     607           0 :         gtk_box_append( GTK_BOX((*this_).id_row), GTK_WIDGET((*this_).id_search_btn) );
     608             : 
     609           0 :         gtk_widget_set_vexpand ( GTK_WIDGET( (*this_).attr_section_icon ), false );
     610           0 :         gtk_widget_set_hexpand ( GTK_WIDGET( (*this_).attr_section_icon ), false );
     611           0 :         gtk_widget_set_vexpand ( GTK_WIDGET( (*this_).id_label ), false );
     612           0 :         gtk_widget_set_hexpand ( GTK_WIDGET( (*this_).id_label ), true );
     613           0 :         gtk_widget_set_vexpand ( GTK_WIDGET( (*this_).id_search_btn ), false );
     614           0 :         gtk_widget_set_hexpand ( GTK_WIDGET( (*this_).id_search_btn ), false );
     615             :     }
     616             : 
     617           0 :     (*this_).name_entry = gtk_entry_new();
     618             : 
     619           0 :     (*this_).stereotype_entry = gtk_entry_new();
     620             : 
     621           0 :     (*this_).description_text_view = gtk_text_view_new();
     622           0 :     gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( (*this_).description_text_view ),
     623             :                                  GTK_WRAP_WORD_CHAR
     624             :                                );
     625           0 :     gtk_widget_set_vexpand( GTK_WIDGET( (*this_).description_text_view ), true );
     626           0 :     gtk_widget_set_hexpand( GTK_WIDGET( (*this_).description_text_view ), false );
     627             :     //gtk_widget_set_size_request( GTK_WIDGET((*this_).description_text_view), 128 /*=w*/ , 48 /*=h*/ );
     628             :     /* need own scroll window container */
     629           0 :     gtk_text_view_set_bottom_margin( GTK_TEXT_VIEW( (*this_).description_text_view ), 12 );
     630           0 :     gtk_text_view_set_left_margin( GTK_TEXT_VIEW( (*this_).description_text_view ), 12 );
     631           0 :     gtk_text_view_set_right_margin( GTK_TEXT_VIEW( (*this_).description_text_view ), 12 );
     632           0 :     gtk_text_view_set_top_margin( GTK_TEXT_VIEW( (*this_).description_text_view ), 12 );
     633           0 :     (*this_).description_scroll_win = gtk_scrolled_window_new();
     634           0 :     gtk_scrolled_window_set_child( GTK_SCROLLED_WINDOW((*this_).description_scroll_win), (*this_).description_text_view );
     635           0 :     gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( (*this_).description_scroll_win ),
     636             :                                     GTK_POLICY_AUTOMATIC,
     637             :                                     GTK_POLICY_AUTOMATIC
     638             :                                   );
     639             : 
     640           0 :     GListStore *model = NULL;  /* the model is set later */
     641           0 :     GtkExpression *expression = NULL;  /* not needed: there is no search entry that could find list elements */
     642           0 :     (*this_).type_dropdown = GTK_DROP_DOWN( gtk_drop_down_new ( G_LIST_MODEL( model ), expression ) );
     643           0 :     GtkBuilderScope *scope = gtk_builder_cscope_new();
     644             :     static const char bytes[] =
     645             :     "<interface>\n"
     646             :     "<template class=\"GtkListItem\">\n"
     647             :     "  <property name=\"child\">\n"
     648             :     "    <object class=\"GtkPaned\">\n"
     649             :     "      <property name=\"start-child\">\n"
     650             :     "        <object class=\"GtkImage\">\n"
     651             :     "          <binding name=\"paintable\">\n"
     652             :     "            <lookup name=\"icon\" type=\"GuiTypeResource\">\n"
     653             :     "              <lookup name=\"item\">GtkListItem</lookup>\n"
     654             :     "            </lookup>\n"
     655             :     "          </binding>\n"
     656             :     "        </object>\n"
     657             :     "      </property>\n"
     658             :     "      <property name=\"end-child\">\n"
     659             :     "        <object class=\"GtkLabel\">\n"
     660             :     "          <property name=\"xalign\">0</property>\n"
     661             :     "          <binding name=\"label\">\n"
     662             :     "            <lookup name=\"name\" type=\"GuiTypeResource\">\n"
     663             :     "              <lookup name=\"item\">GtkListItem</lookup>\n"
     664             :     "            </lookup>\n"
     665             :     "          </binding>\n"
     666             :     "        </object>\n"
     667             :     "      </property>\n"
     668             :     "      <property name=\"position\">48</property>\n"
     669             :     "    </object>\n"
     670             :     "  </property>\n"
     671             :     "</template>\n"
     672             :     "</interface>\n";
     673           0 :     GBytes *byteptr = g_bytes_new( &bytes, sizeof(bytes)-sizeof(char) );
     674           0 :     GtkListItemFactory *factory = gtk_builder_list_item_factory_new_from_bytes( scope, byteptr );
     675           0 :     gtk_drop_down_set_factory( (*this_).type_dropdown, factory );
     676           0 :     g_object_unref( scope );
     677           0 :     g_object_unref( factory );
     678           0 :     g_bytes_unref( byteptr );
     679             : 
     680             :     static gui_type_resource_list_t res_select;
     681           0 :     gui_type_resource_list_init( &res_select, res );
     682             :     {
     683           0 :         (*this_).type_diag_grid = GTK_GRID( gtk_grid_new() );
     684           0 :         gtk_widget_set_halign( GTK_WIDGET( (*this_).type_diag_grid ), GTK_ALIGN_END );
     685             :         const gui_type_resource_t (*diag_data)[];
     686             :         unsigned int diag_data_length;
     687           0 :         gui_type_resource_list_get_all_diagram_types( &res_select, &diag_data, &diag_data_length );
     688           0 :         assert( diag_data_length == GUI_TYPE_RESOURCE_LIST_DIAGRAMS );
     689           0 :         for( int_fast32_t diag_idx = 0; diag_idx < GUI_TYPE_RESOURCE_LIST_DIAGRAMS; diag_idx ++ )
     690             :         {
     691           0 :             const gui_type_resource_t *const type_data = &((*diag_data)[diag_idx]);
     692           0 :             const data_diagram_type_t diag_type = data_type_get_diagram_type( gui_type_resource_get_type_id( type_data ) );
     693           0 :             GdkTexture *const diag_icon = gui_type_resource_get_icon( type_data );
     694           0 :             const char *const diag_name = gui_type_resource_get_name( type_data );
     695             : 
     696           0 :             gui_attribute_type_of_diagram_init( &((*this_).type_diag_data[diag_idx]), diag_type, &((*this_).attributes_editor) );
     697           0 :             (*this_).type_diag_img[ diag_idx ] = GTK_IMAGE( gtk_image_new_from_paintable( GDK_PAINTABLE( diag_icon ) ) );
     698           0 :             gtk_widget_set_size_request( GTK_WIDGET( (*this_).type_diag_img[ diag_idx ] ), 32 /*=w*/ , 24 /*=h*/ );
     699           0 :             (*this_).type_diag_btn[ diag_idx ] = GTK_BUTTON( gtk_button_new() );
     700           0 :             gtk_button_set_image( (*this_).type_diag_btn[ diag_idx ], GTK_WIDGET( (*this_).type_diag_img[ diag_idx ] ) );
     701           0 :             gtk_widget_set_tooltip_text( GTK_WIDGET( (*this_).type_diag_btn[ diag_idx ] ), diag_name );
     702           0 :             gtk_grid_attach( (*this_).type_diag_grid, GTK_WIDGET( (*this_).type_diag_btn[ diag_idx ] ), diag_idx%7, diag_idx/7, 1, 1 );
     703             :         }
     704             : 
     705           0 :         (*this_).type_clas_grid = GTK_GRID( gtk_grid_new() );
     706           0 :         gtk_widget_set_halign( GTK_WIDGET( (*this_).type_clas_grid ), GTK_ALIGN_END );
     707             :         const gui_type_resource_t (*clas_data)[];
     708             :         unsigned int clas_data_length;
     709           0 :         gui_type_resource_list_get_all_classifier_types( &res_select, &clas_data, &clas_data_length );
     710           0 :         assert( clas_data_length == GUI_TYPE_RESOURCE_LIST_CLASSIFIERS );
     711           0 :         for( int_fast32_t clas_idx = 0; clas_idx < GUI_TYPE_RESOURCE_LIST_CLASSIFIERS; clas_idx ++ )
     712             :         {
     713           0 :             const gui_type_resource_t *const type_data = &((*clas_data)[clas_idx]);
     714           0 :             const data_classifier_type_t clas_type = data_type_get_classifier_type( gui_type_resource_get_type_id( type_data ) );
     715           0 :             GdkTexture *const clas_icon = gui_type_resource_get_icon( type_data );
     716           0 :             const char *const clas_name = gui_type_resource_get_name( type_data );
     717             : 
     718           0 :             gui_attribute_type_of_classifier_init( &((*this_).type_clas_data[clas_idx]), clas_type, &((*this_).attributes_editor) );
     719           0 :             (*this_).type_clas_img[ clas_idx ] = GTK_IMAGE( gtk_image_new_from_paintable( GDK_PAINTABLE( clas_icon ) ) );
     720           0 :             gtk_widget_set_size_request( GTK_WIDGET( (*this_).type_clas_img[ clas_idx ] ), 32 /*=w*/ , 24 /*=h*/ );
     721           0 :             (*this_).type_clas_btn[ clas_idx ] = GTK_BUTTON( gtk_button_new() );
     722           0 :             gtk_button_set_image( (*this_).type_clas_btn[ clas_idx ], GTK_WIDGET( (*this_).type_clas_img[ clas_idx ] ) );
     723           0 :             gtk_widget_set_tooltip_text( GTK_WIDGET( (*this_).type_clas_btn[ clas_idx ] ), clas_name );
     724           0 :             gtk_grid_attach( (*this_).type_clas_grid, GTK_WIDGET( (*this_).type_clas_btn[ clas_idx ] ), clas_idx%7, clas_idx/7, 1, 1 );
     725             :         }
     726             : 
     727           0 :         (*this_).type_feat_grid = GTK_GRID( gtk_grid_new() );
     728           0 :         gtk_widget_set_halign( GTK_WIDGET( (*this_).type_feat_grid ), GTK_ALIGN_END );
     729             :         const gui_type_resource_t (*feat_data)[];
     730             :         unsigned int feat_data_length;
     731           0 :         gui_type_resource_list_get_invariant_feature_types( &res_select, &feat_data, &feat_data_length );
     732           0 :         assert( feat_data_length == GUI_TYPE_RESOURCE_LIST_INV_FEATURES );
     733           0 :         for( int_fast32_t feat_idx = 0; feat_idx < GUI_TYPE_RESOURCE_LIST_INV_FEATURES; feat_idx ++ )  /* ignore the lifeline */
     734             :         {
     735           0 :             const gui_type_resource_t *const type_data = &((*feat_data)[feat_idx]);
     736           0 :             const data_feature_type_t feat_type = data_type_get_feature_type( gui_type_resource_get_type_id( type_data ) );
     737           0 :             GdkTexture *const feat_icon = gui_type_resource_get_icon( type_data );
     738           0 :             const char *const feat_name = gui_type_resource_get_name( type_data );
     739             : 
     740           0 :             gui_attribute_type_of_feature_init( &((*this_).type_feat_data[feat_idx]), feat_type, &((*this_).attributes_editor) );
     741           0 :             (*this_).type_feat_img[ feat_idx ] = GTK_IMAGE( gtk_image_new_from_paintable( GDK_PAINTABLE( feat_icon ) ) );
     742           0 :             gtk_widget_set_size_request( GTK_WIDGET( (*this_).type_feat_img[ feat_idx ] ), 32 /*=w*/ , 24 /*=h*/ );
     743           0 :             (*this_).type_feat_btn[ feat_idx ] = GTK_BUTTON( gtk_button_new() );
     744           0 :             gtk_button_set_image( (*this_).type_feat_btn[ feat_idx ], GTK_WIDGET( (*this_).type_feat_img[ feat_idx ] ) );
     745           0 :             gtk_widget_set_tooltip_text( GTK_WIDGET( (*this_).type_feat_btn[ feat_idx ] ), feat_name );
     746           0 :             gtk_grid_attach( (*this_).type_feat_grid, GTK_WIDGET( (*this_).type_feat_btn[ feat_idx ] ), feat_idx%7, feat_idx/7, 1, 1 );
     747             :         }
     748             : 
     749           0 :         (*this_).type_rel_grid = GTK_GRID( gtk_grid_new() );
     750           0 :         gtk_widget_set_halign( GTK_WIDGET( (*this_).type_rel_grid ), GTK_ALIGN_END );
     751             :         const gui_type_resource_t (*rel_data)[];
     752             :         unsigned int rel_data_length;
     753           0 :         gui_type_resource_list_get_all_relationship_types( &res_select, &rel_data, &rel_data_length );
     754           0 :         assert( rel_data_length == GUI_TYPE_RESOURCE_LIST_RELATIONS );
     755           0 :         for( int_fast32_t rel_idx = 0; rel_idx < GUI_TYPE_RESOURCE_LIST_RELATIONS; rel_idx ++ )
     756             :         {
     757           0 :             const gui_type_resource_t *const type_data = &((*rel_data)[rel_idx]);
     758           0 :             const data_relationship_type_t rel_type = data_type_get_relationship_type( gui_type_resource_get_type_id( type_data ) );
     759           0 :             GdkTexture *const rel_icon = gui_type_resource_get_icon( type_data );
     760           0 :             const char *const rel_name = gui_type_resource_get_name( type_data );
     761             : 
     762           0 :             gui_attribute_type_of_relationship_init( &((*this_).type_rel_data[rel_idx]), rel_type, &((*this_).attributes_editor) );
     763           0 :             (*this_).type_rel_img[ rel_idx ] = GTK_IMAGE( gtk_image_new_from_paintable( GDK_PAINTABLE( rel_icon ) ) );
     764           0 :             gtk_widget_set_size_request( GTK_WIDGET( (*this_).type_rel_img[ rel_idx ] ), 32 /*=w*/ , 24 /*=h*/ );
     765           0 :             (*this_).type_rel_btn[ rel_idx ] = GTK_BUTTON( gtk_button_new() );
     766           0 :             gtk_button_set_image( (*this_).type_rel_btn[ rel_idx ], GTK_WIDGET( (*this_).type_rel_img[ rel_idx ] ) );
     767           0 :             gtk_widget_set_tooltip_text( GTK_WIDGET( (*this_).type_rel_btn[ rel_idx ] ), rel_name );
     768           0 :             gtk_grid_attach( (*this_).type_rel_grid, GTK_WIDGET( (*this_).type_rel_btn[ rel_idx ] ), rel_idx%7, rel_idx/7, 1, 1 );
     769             :         }
     770             :     }
     771           0 :     gui_type_resource_list_destroy( &res_select );
     772             : 
     773             :     /* insert widgets to box container */
     774             :     {
     775           0 :         (*this_).attr_edit_column = gtk_box_new( GTK_ORIENTATION_VERTICAL, /*spacing:*/ 4 );
     776           0 :         gtk_box_append( GTK_BOX((*this_).attr_edit_column), GTK_WIDGET((*this_).id_row) );
     777           0 :         gtk_box_append( GTK_BOX((*this_).attr_edit_column), GTK_WIDGET((*this_).name_label) );
     778           0 :         gtk_box_append( GTK_BOX((*this_).attr_edit_column), GTK_WIDGET((*this_).name_entry) );
     779           0 :         gtk_box_append( GTK_BOX((*this_).attr_edit_column), GTK_WIDGET((*this_).stereotype_label) );
     780           0 :         gtk_box_append( GTK_BOX((*this_).attr_edit_column), GTK_WIDGET((*this_).stereotype_entry) );
     781           0 :         gtk_box_append( GTK_BOX((*this_).attr_edit_column), GTK_WIDGET((*this_).type_label) );
     782           0 :         gtk_box_append( GTK_BOX((*this_).attr_edit_column), GTK_WIDGET((*this_).type_dropdown) );
     783           0 :         gtk_box_append( GTK_BOX((*this_).attr_edit_column), GTK_WIDGET((*this_).type_diag_grid) );
     784           0 :         gtk_box_append( GTK_BOX((*this_).attr_edit_column), GTK_WIDGET((*this_).type_clas_grid) );
     785           0 :         gtk_box_append( GTK_BOX((*this_).attr_edit_column), GTK_WIDGET((*this_).type_feat_grid) );
     786           0 :         gtk_box_append( GTK_BOX((*this_).attr_edit_column), GTK_WIDGET((*this_).type_rel_grid) );
     787           0 :         gtk_box_append( GTK_BOX((*this_).attr_edit_column), GTK_WIDGET((*this_).description_label) );
     788           0 :         gtk_box_append( GTK_BOX((*this_).attr_edit_column), GTK_WIDGET((*this_).description_scroll_win) );
     789             : 
     790           0 :         gtk_widget_set_vexpand( GTK_WIDGET( (*this_).description_scroll_win ), true );
     791           0 :         gtk_widget_set_hexpand( GTK_WIDGET( (*this_).description_scroll_win ), true );
     792             :     }
     793             : 
     794           0 :     U8_TRACE_END();
     795           0 : }
     796             : 
     797           0 : void gui_main_window_private_init_simple_message_to_user( gui_main_window_t *this_, gui_resources_t *res )
     798             : {
     799           0 :     U8_TRACE_BEGIN();
     800             : 
     801           0 :     (*this_).message_text_label = gtk_label_new( "" );
     802           0 :     gtk_label_set_xalign(GTK_LABEL( (*this_).message_text_label ), 0.0 );
     803             : 
     804           0 :     (*this_).message_icon_image = gtk_image_new_from_paintable( GDK_PAINTABLE ( gui_resources_get_crystal_facet_uml( res ) ) );
     805             :     /* TODO check if GtkPicture is better suited than GtkImage because of setting the size */
     806             :     // gtk_widget_set_size_request( GTK_WIDGET((*this_).message_icon_image), 32 /*=w*/ , 32 /*=h*/ );
     807             :     // gtk_image_set_pixel_size( GTK_IMAGE((*this_).message_icon_image), 32 );
     808           0 :     gtk_widget_set_size_request( GTK_WIDGET((*this_).message_icon_image), 32 /*=w*/ , 32 /*=h*/ );
     809             : 
     810             :     /* insert widgets to box container */
     811             :     {
     812           0 :         (*this_).message_row = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, /*spacing:*/ 20 );
     813           0 :         gtk_box_append( GTK_BOX((*this_).message_row), GTK_WIDGET((*this_).message_icon_image) );
     814           0 :         gtk_box_append( GTK_BOX((*this_).message_row), GTK_WIDGET((*this_).message_text_label) );
     815             : 
     816           0 :         gtk_widget_set_vexpand( GTK_WIDGET( (*this_).message_icon_image ), false );
     817           0 :         gtk_widget_set_hexpand( GTK_WIDGET( (*this_).message_icon_image ), false );
     818           0 :         gtk_widget_set_vexpand( GTK_WIDGET( (*this_).message_text_label ), false );
     819           0 :         gtk_widget_set_hexpand( GTK_WIDGET( (*this_).message_text_label ), true );
     820             :     }
     821             : 
     822           0 :     U8_TRACE_END();
     823           0 : }
     824             : 
     825           0 : void gui_main_window_private_init_search_and_sketch_area( gui_main_window_t *this_, gui_resources_t *res )
     826             : {
     827           0 :     U8_TRACE_BEGIN();
     828             : 
     829             :     /* init search widgets */
     830             :     {
     831           0 :         (*this_).search_label = gtk_label_new ( "Search:" );
     832           0 :         gtk_label_set_xalign( GTK_LABEL( (*this_).search_label ), 1.0 ); /* align right */
     833           0 :         gtk_label_set_yalign( GTK_LABEL( (*this_).search_label ), 0.5 ); /* align middle-height */
     834             : 
     835           0 :         (*this_).search_entry = gtk_entry_new();
     836             : 
     837           0 :         (*this_).search_button = gtk_button_new();
     838           0 :         (*this_).search_btn_icon = gtk_image_new_from_paintable( GDK_PAINTABLE( gui_resources_get_search_search( res ) ) );
     839           0 :         gtk_button_set_image( GTK_BUTTON((*this_).search_button), (*this_).search_btn_icon );
     840           0 :         gtk_widget_set_tooltip_text( GTK_WIDGET((*this_).search_button), "Search" );
     841           0 :         gtk_widget_set_size_request( GTK_WIDGET((*this_).search_btn_icon), 32 /*=w*/ , 32 /*=h*/ );
     842             :     }
     843             : 
     844             :     /* insert widgets to box container */
     845             :     {
     846           0 :         (*this_).search_row = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, /*spacing:*/ 4 );
     847           0 :         gtk_box_append( GTK_BOX((*this_).search_row), GTK_WIDGET((*this_).search_label) );
     848           0 :         gtk_box_append( GTK_BOX((*this_).search_row), GTK_WIDGET((*this_).search_entry) );
     849           0 :         gtk_box_append( GTK_BOX((*this_).search_row), GTK_WIDGET((*this_).search_button) );
     850             : 
     851           0 :         gtk_widget_set_vexpand ( GTK_WIDGET( (*this_).search_label ), false );
     852           0 :         gtk_widget_set_hexpand ( GTK_WIDGET( (*this_).search_label ), false );
     853           0 :         gtk_widget_set_vexpand ( GTK_WIDGET( (*this_).search_entry ), false );
     854           0 :         gtk_widget_set_hexpand ( GTK_WIDGET( (*this_).search_entry ), true );
     855           0 :         gtk_widget_set_vexpand ( GTK_WIDGET( (*this_).search_button ), false );
     856           0 :         gtk_widget_set_hexpand ( GTK_WIDGET( (*this_).search_button ), false );
     857             :     }
     858             : 
     859             :     /* init sketch area */
     860             :     {
     861           0 :         (*this_).sketcharea = gtk_drawing_area_new();
     862           0 :         gtk_widget_set_can_focus( GTK_WIDGET( (*this_).sketcharea ), TRUE );  /* this allows the text entry widgets to lose the focus */
     863           0 :         gtk_widget_set_size_request( GTK_WIDGET( (*this_).sketcharea ), 600, 360);  /* set a minimum initial size */
     864             :         /*gtk_widget_set_focus_on_click( GTK_WIDGET( (*this_).sketcharea ), TRUE ); not yet existing: since GTK 3.2 */
     865             :     }
     866             : 
     867             :     /* insert widgets to box container */
     868             :     {
     869           0 :         (*this_).sketch_stack_column = gtk_box_new( GTK_ORIENTATION_VERTICAL, /*spacing:*/ 0 );
     870           0 :         gtk_box_append( GTK_BOX((*this_).sketch_stack_column), GTK_WIDGET((*this_).search_row) );
     871           0 :         gtk_box_append( GTK_BOX((*this_).sketch_stack_column), GTK_WIDGET((*this_).sketcharea) );
     872             : 
     873           0 :         gtk_widget_set_vexpand ( GTK_WIDGET( (*this_).search_row ), false );
     874           0 :         gtk_widget_set_hexpand ( GTK_WIDGET( (*this_).search_row ), true );
     875           0 :         gtk_widget_set_vexpand ( GTK_WIDGET( (*this_).sketcharea ), true );
     876           0 :         gtk_widget_set_hexpand ( GTK_WIDGET( (*this_).sketcharea ), true );
     877             :     }
     878             : 
     879           0 :     U8_TRACE_END();
     880           0 : }
     881             : 
     882           0 : void gui_main_window_destroy_event_callback( GtkWidget *widget, gpointer data )
     883             : {
     884           0 :     U8_TRACE_BEGIN();
     885           0 :     gui_main_window_t *this_ = data;
     886           0 :     assert( (*this_).window == (void*)widget );
     887             : 
     888             :     /* forward destroy request to gui_window_manager: */
     889           0 :     observer_notify( (*this_).window_close_observer, this_ );
     890             : 
     891           0 :     U8_TRACE_TIMESTAMP();
     892           0 :     U8_TRACE_END();
     893           0 : }
     894             : 
     895           0 : gboolean gui_main_window_delete_event_callback( GtkWindow *widget, gpointer data )
     896             : {
     897           0 :     U8_TRACE_BEGIN();
     898           0 :     gui_main_window_t *this_ = data;
     899           0 :     assert( (*this_).window == (void*)widget );
     900             :     (void) this_;  /* unused in case of NDEBUG */
     901             : 
     902           0 :     U8_TRACE_TIMESTAMP();
     903           0 :     U8_TRACE_END();
     904           0 :     return false;  /* return false to trigger destroy event */
     905             : }
     906             : 
     907           0 : void gui_main_window_new_db_btn_callback( GtkWidget* button, gpointer data )
     908             : {
     909           0 :     U8_TRACE_BEGIN();
     910           0 :     gui_main_window_t *this_ = data;
     911             : 
     912           0 :     gui_simple_message_to_user_hide( &((*this_).message_to_user) );
     913             : 
     914           0 :     gui_file_use_db_dialog_show( &((*this_).file_use_db_dialog), false /* open_existing*/ );
     915             : 
     916           0 :     U8_TRACE_TIMESTAMP();
     917           0 :     U8_TRACE_END();
     918           0 : }
     919             : 
     920           0 : void gui_main_window_open_db_btn_callback( GtkWidget* button, gpointer data )
     921             : {
     922           0 :     U8_TRACE_BEGIN();
     923           0 :     gui_main_window_t *this_ = data;
     924             : 
     925           0 :     gui_simple_message_to_user_hide( &((*this_).message_to_user) );
     926             : 
     927           0 :     gui_file_use_db_dialog_show( &((*this_).file_use_db_dialog), true /* open_existing*/ );
     928             : 
     929           0 :     U8_TRACE_TIMESTAMP();
     930           0 :     U8_TRACE_END();
     931           0 : }
     932             : 
     933           0 : void gui_main_window_save_btn_callback( GtkButton *button, gpointer user_data )
     934             : {
     935           0 :     U8_TRACE_BEGIN();
     936             :     gui_main_window_t *this_;
     937           0 :     this_ = (gui_main_window_t*) user_data;
     938           0 :     assert( this_ != NULL );
     939             : 
     940           0 :     gui_simple_message_to_user_hide( &((*this_).message_to_user) );
     941             : 
     942           0 :     gui_attributes_editor_commit_changes ( &((*this_).attributes_editor) );
     943             : 
     944             :     u8_error_t d_err;
     945           0 :     d_err = U8_ERROR_NONE;
     946           0 :     d_err |= io_data_file_trace_stats( (*this_).data_file );
     947           0 :     d_err |= io_data_file_sync_to_disk( (*this_).data_file );
     948           0 :     d_err |= io_data_file_trace_stats( (*this_).data_file );
     949           0 :     if ( U8_ERROR_NONE != d_err )
     950             :     {
     951           0 :         gui_simple_message_to_user_show_message( &((*this_).message_to_user),
     952             :                                                  GUI_SIMPLE_MESSAGE_TYPE_WARNING,
     953             :                                                  GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_WRITE_ERROR
     954             :                                                );
     955             :     }
     956             :     else
     957             :     {
     958           0 :         gui_simple_message_to_user_show_message_with_name( &((*this_).message_to_user),
     959             :                                                            GUI_SIMPLE_MESSAGE_TYPE_INFO,
     960             :                                                            GUI_SIMPLE_MESSAGE_CONTENT_DB_FILE_WRITTEN,
     961           0 :                                                            io_data_file_get_filename_const( (*this_).data_file )
     962             :                                                          );
     963             : #ifndef NDEBUG
     964             :         /* in debug mode, also check consistency of database */
     965             :         universal_stream_output_stream_t out_stream;
     966           0 :         universal_stream_output_stream_init( &out_stream, stdout );
     967           0 :         universal_output_stream_t *const out_base = universal_stream_output_stream_get_output_stream( &out_stream );
     968             :         utf8stream_writer_t out_report;
     969           0 :         utf8stream_writer_init( &out_report, out_base );
     970             :         uint32_t found_errors;
     971             :         uint32_t fixed_errors;
     972           0 :         ctrl_controller_repair_database( (*this_).controller,
     973             :                                          false /* no repair, just test */,
     974             :                                          &found_errors,
     975             :                                          &fixed_errors,
     976             :                                          &out_report
     977             :                                        );
     978           0 :         if (( found_errors != 0 ) || ( fixed_errors != 0 ))
     979             :         {
     980           0 :             gui_simple_message_to_user_show_message_with_quantity( &((*this_).message_to_user),
     981             :                                                                    GUI_SIMPLE_MESSAGE_TYPE_ERROR,
     982             :                                                                    GUI_SIMPLE_MESSAGE_CONTENT_DB_INCONSISTENT,
     983             :                                                                    found_errors
     984             :                                                                  );
     985             :         }
     986           0 :         utf8stream_writer_destroy( &out_report );
     987           0 :         universal_stream_output_stream_destroy( &out_stream );
     988             : #endif
     989             :     }
     990             : 
     991           0 :     U8_TRACE_TIMESTAMP();
     992           0 :     U8_TRACE_END();
     993           0 : }
     994             : 
     995           0 : gboolean gui_main_window_save_shortcut_callback( GtkWidget* widget, GVariant* args, gpointer user_data )
     996             : {
     997           0 :     gui_main_window_save_btn_callback( (GtkButton*)widget, user_data );
     998           0 :     return TRUE;
     999             : }
    1000             : 
    1001           0 : void gui_main_window_export_btn_callback( GtkWidget* button, gpointer data )
    1002             : {
    1003           0 :     U8_TRACE_BEGIN();
    1004           0 :     gui_main_window_t *this_ = data;
    1005             : 
    1006           0 :     gui_simple_message_to_user_hide( &((*this_).message_to_user) );
    1007             : 
    1008           0 :     const bool was_visible = gtk_widget_get_visible( (*this_).options_layout );
    1009           0 :     gtk_widget_set_visible( (*this_).options_layout, ! was_visible );
    1010             : 
    1011           0 :     U8_TRACE_TIMESTAMP();
    1012           0 :     U8_TRACE_END();
    1013           0 : }
    1014             : 
    1015           0 : void gui_main_window_new_window_btn_callback( GtkWidget* button, gpointer data )
    1016             : {
    1017           0 :     U8_TRACE_BEGIN();
    1018           0 :     gui_main_window_t *this_ = data;
    1019             : 
    1020             :     /* hide last message */
    1021           0 :     gui_simple_message_to_user_hide( &((*this_).message_to_user) );
    1022             : 
    1023             :     /* forward new window request to gui_window_manager: */
    1024           0 :     observer_notify( (*this_).window_open_observer, &((*this_).message_to_user) );
    1025             : 
    1026           0 :     U8_TRACE_TIMESTAMP();
    1027           0 :     U8_TRACE_END();
    1028           0 : }
    1029             : 
    1030           0 : void gui_main_window_about_btn_callback( GtkWidget* button, gpointer data )
    1031             : {
    1032           0 :     U8_TRACE_BEGIN();
    1033           0 :     gui_main_window_t *this_ = data;
    1034             : 
    1035           0 :     if ( GUI_SIMPLE_MESSAGE_TYPE_ABOUT == gui_simple_message_to_user_get_type_id( &((*this_).message_to_user) ) )
    1036             :     {
    1037             :         /* hide the already visible about message */
    1038           0 :         gui_simple_message_to_user_hide( &((*this_).message_to_user) );
    1039             :     }
    1040             :     else
    1041             :     {
    1042           0 :         gui_simple_message_to_user_show_message( &((*this_).message_to_user),
    1043             :                                                  GUI_SIMPLE_MESSAGE_TYPE_ABOUT,
    1044             :                                                  GUI_SIMPLE_MESSAGE_CONTENT_ABOUT
    1045             :                                                );
    1046             :     }
    1047             : 
    1048           0 :     U8_TRACE_TIMESTAMP();
    1049           0 :     U8_TRACE_END();
    1050           0 : }
    1051             : 
    1052           0 : void gui_main_window_data_changed_callback( GtkWidget *window, data_change_message_t *msg, gpointer user_data )
    1053             : {
    1054           0 :     U8_TRACE_BEGIN();
    1055           0 :     gui_main_window_t *this_ = user_data;
    1056             : 
    1057           0 :     if (( DATA_CHANGE_EVENT_TYPE_DB_OPENED == data_change_message_get_event( msg ) )
    1058           0 :         || ( DATA_CHANGE_EVENT_TYPE_DB_CLOSED == data_change_message_get_event( msg ) ))
    1059             :     {
    1060             :         /* the database has changed */
    1061           0 :         const char *filename = io_data_file_get_filename_const( (*this_).data_file );
    1062           0 :         if ( NULL == filename )
    1063             :         {
    1064           0 :             gtk_window_set_title(GTK_WINDOW((*this_).window), META_INFO_PROGRAM_NAME_STR );
    1065             :         }
    1066             :         else
    1067             :         {
    1068           0 :             gtk_window_set_title(GTK_WINDOW((*this_).window), filename );
    1069             :         }
    1070             :     }
    1071             : 
    1072           0 :     U8_TRACE_TIMESTAMP();
    1073           0 :     U8_TRACE_END();
    1074           0 : }
    1075             : 
    1076             : 
    1077             : /*
    1078             : Copyright 2016-2024 Andreas Warnke
    1079             : 
    1080             : Licensed under the Apache License, Version 2.0 (the "License");
    1081             : you may not use this file except in compliance with the License.
    1082             : You may obtain a copy of the License at
    1083             : 
    1084             :     http://www.apache.org/licenses/LICENSE-2.0
    1085             : 
    1086             : Unless required by applicable law or agreed to in writing, software
    1087             : distributed under the License is distributed on an "AS IS" BASIS,
    1088             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1089             : See the License for the specific language governing permissions and
    1090             : limitations under the License.
    1091             : */

Generated by: LCOV version 1.16