Line data Source code
1 : /* File: gui_marked_set.c; Copyright and License: see below */
2 :
3 : #include "gui_marked_set.h"
4 : #include "entity/data_table.h"
5 : #include "entity/data_id.h"
6 : #include "u8/u8_trace.h"
7 : #include "u8/u8_log.h"
8 : #include "gui_gdk.h"
9 :
10 : static bool gui_marked_set_glib_signal_initialized = false;
11 : static guint gui_marked_set_glib_signal_id = 0;
12 : const char *GUI_MARKED_SET_GLIB_SIGNAL_NAME = "cfu_object_selected";
13 :
14 0 : void gui_marked_set_init ( gui_marked_set_t *this_,
15 : GObject *signal_source,
16 : void(*request_focus_call)(struct gui_sketch_area_struct* user_data, data_id_t diagram_wish),
17 : struct gui_sketch_area_struct* request_focus_user_data )
18 : {
19 0 : U8_TRACE_BEGIN();
20 0 : assert( NULL != signal_source );
21 :
22 0 : data_full_id_init_void( &((*this_).focused) );
23 0 : data_id_init_void( &((*this_).focused_diagram) );
24 0 : data_id_init_void( &((*this_).highlighted) );
25 0 : (*this_).highlighted_kind = LAYOUT_SUBELEMENT_KIND_VOID;
26 0 : data_id_init_void( &((*this_).highlighted_diagram) );
27 0 : (*this_).highlighted_button = GUI_SKETCH_ACTION_NONE;
28 :
29 0 : data_small_set_init( &((*this_).selected_set) );
30 :
31 : /* define a new signal */
32 0 : if ( ! gui_marked_set_glib_signal_initialized )
33 : {
34 0 : gui_marked_set_glib_signal_id = g_signal_new (
35 : GUI_MARKED_SET_GLIB_SIGNAL_NAME,
36 : G_TYPE_OBJECT,
37 : G_SIGNAL_RUN_FIRST,
38 : 0,
39 : NULL,
40 : NULL,
41 : g_cclosure_marshal_VOID__POINTER,
42 : G_TYPE_NONE,
43 : 1,
44 : G_TYPE_POINTER /* data_id_t* */
45 : );
46 0 : gui_marked_set_glib_signal_initialized = true;
47 0 : U8_TRACE_INFO_INT( "g_signal_new(\"cfu_object_selected\") returned new signal id", gui_marked_set_glib_signal_id );
48 : }
49 :
50 0 : (*this_).signal_source = signal_source;
51 :
52 : /* store a function pointer and parameter for requesting focus later */
53 0 : (*this_).request_focus_call = request_focus_call;
54 0 : (*this_).request_focus_user_data = request_focus_user_data;
55 :
56 0 : U8_TRACE_END();
57 0 : }
58 :
59 0 : void gui_marked_set_destroy( gui_marked_set_t *this_ )
60 : {
61 0 : U8_TRACE_BEGIN();
62 :
63 0 : data_full_id_destroy( &((*this_).focused) );
64 0 : data_id_destroy( &((*this_).focused_diagram) );
65 0 : data_id_destroy( &((*this_).highlighted) );
66 0 : data_id_destroy( &((*this_).highlighted_diagram) );
67 0 : data_small_set_destroy( &((*this_).selected_set) );
68 0 : (*this_).signal_source = NULL;
69 0 : (*this_).request_focus_call = NULL;
70 0 : (*this_).request_focus_user_data = NULL;
71 :
72 0 : U8_TRACE_END();
73 0 : }
74 :
75 0 : void gui_marked_set_reset( gui_marked_set_t *this_ )
76 : {
77 0 : U8_TRACE_BEGIN();
78 0 : assert( NULL != (*this_).signal_source );
79 :
80 0 : data_full_id_init_void( &((*this_).focused) );
81 0 : data_id_init_void( &((*this_).focused_diagram) );
82 0 : data_id_init_void( &((*this_).highlighted) );
83 0 : (*this_).highlighted_kind = LAYOUT_SUBELEMENT_KIND_VOID;
84 0 : data_id_init_void( &((*this_).highlighted_diagram) );
85 0 : (*this_).highlighted_button = GUI_SKETCH_ACTION_NONE;
86 0 : data_small_set_reinit( &((*this_).selected_set) );
87 :
88 0 : U8_TRACE_END();
89 0 : }
90 :
91 0 : void gui_marked_set_private_notify_listeners( gui_marked_set_t *this_, data_id_t modified_real_object_id )
92 : {
93 0 : U8_TRACE_BEGIN();
94 :
95 0 : U8_TRACE_INFO( "g_signal_emit to listeners" );
96 0 : g_signal_emit( (*this_).signal_source, gui_marked_set_glib_signal_id, 0, &modified_real_object_id );
97 :
98 0 : U8_TRACE_END();
99 0 : }
100 :
101 :
102 : /*
103 : Copyright 2016-2025 Andreas Warnke
104 :
105 : Licensed under the Apache License, Version 2.0 (the "License");
106 : you may not use this file except in compliance with the License.
107 : You may obtain a copy of the License at
108 :
109 : http://www.apache.org/licenses/LICENSE-2.0
110 :
111 : Unless required by applicable law or agreed to in writing, software
112 : distributed under the License is distributed on an "AS IS" BASIS,
113 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
114 : See the License for the specific language governing permissions and
115 : limitations under the License.
116 : */
|