1 /*
2 * File: documents.c
3 *
4 * Description: handles the list of models
5 *
6 *
7 * This source code is part of kludge3d, and is released under the
8 * GNU General Public License.
9 *
10 *
11 */
12
13
14 #include "globals.h"
15 #include "documents.h"
16 #include "undo.h"
17
18
19 #ifdef MEMWATCH
20 #include "memwatch.h"
21 #endif
22
23
24 /* GLOBALS ****************************************************************/
25
26 GSList *models = NULL;
27
28
29 /* FUNCS ******************************************************************/
30
docs_switch_model(Model * m)31 void docs_switch_model( Model *m ) {
32 if( m == NULL ) return;
33
34 the_model = m;
35
36 g_signal_emit_by_name( notificationObj,
37 "switched-model", m );
38 g_signal_emit_by_name( notificationObj,
39 "notify::model-appearance-changed", NULL );
40 g_signal_emit_by_name( notificationObj,
41 "notify::model-structure-changed", NULL );
42 g_signal_emit_by_name( notificationObj,
43 "notify::model-texturelist-changed", NULL );
44
45 }
46
docs_add_model(Model * m)47 void docs_add_model( Model *m ) {
48 if( m == NULL ) return;
49
50 models = g_slist_append( models, m );
51 undo_enable( m );
52
53 g_signal_emit_by_name( notificationObj,
54 "added-model", m );
55 }
56
57
docs_remove_model(Model * m)58 void docs_remove_model( Model *m ) {
59 if( m == NULL ) return;
60
61 models = g_slist_remove( models, m );
62
63 g_signal_emit_by_name( notificationObj,
64 "removed-model", m );
65
66 action_clear_stack( m );
67 model_delete( m );
68 }
69
70
docs_cleanup(void)71 void docs_cleanup( void ) {
72 GSList *l;
73
74 for( l = models; l; l = l->next ) {
75 action_clear_stack( (Model*)l->data );
76 model_delete( (Model*)l->data );
77 }
78
79 g_slist_free( models );
80 models = NULL;
81
82 the_model = NULL;
83 }
84
85