1 /* Dia -- an diagram creation/manipulation program
2 * Copyright (C) 1998 Alexander Larsson
4 * List of "dynamic" (animated) objects, and their refresh rates
5 * Copyright (C) 2002 Cyrille Chépélov
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "dynamic_refresh.h"
22 #include "dynamic_obj.h"
24 #include "diagramdata.h"
25 #include "object_ops.h"
26 #include "app/connectionpoint_ops.h"
29 static guint timeout
= 0;
30 static guint idle_id
= 0;
31 static guint timer_id
= 0;
33 static void foreach_dynobj(DiaObject
* obj
, gpointer data
) {
34 gboolean moved
= FALSE
;
35 GList
* list
= dia_open_diagrams();
37 while (list
!= NULL
) {
39 DiagramData
* obj_ddata
;
42 dia
= (Diagram
*)list
->data
;
43 list
= g_list_next(list
);
45 layer
= dia_object_get_parent_layer(obj
);
48 obj_ddata
= layer_get_parent_diagram(layer
);
49 if (!obj_ddata
) continue;
51 if (dia
->data
== obj_ddata
) {
53 obj
->ops
->move(obj
,&obj
->position
);
56 object_add_updates(obj
,dia
);
57 diagram_update_connections_object(dia
,obj
, TRUE
);
62 static gboolean
timer_handler(gpointer data
) {
65 dynobj_list_foreach(foreach_dynobj
,data
);
67 list
= dia_open_diagrams();
68 while (list
!= NULL
) {
69 Diagram
* dia
= (Diagram
*)list
->data
;
70 list
= g_list_next(list
);
75 dynobj_refresh_kick();
79 static gboolean
idle_handler(gpointer data
) {
82 new_timeout
= dynobj_list_get_dynobj_rate();
83 if (timeout
!= new_timeout
) {
85 gtk_timeout_remove(timer_id
);
88 timeout
= new_timeout
;
90 timer_id
= gtk_timeout_add(timeout
,timer_handler
,NULL
);
97 void dynobj_refresh_kick(void) {
99 idle_id
= gtk_idle_add_priority(GTK_PRIORITY_LOW
,idle_handler
,NULL
);
102 void dynobj_refresh_init(void) {
106 void dynobj_refresh_finish(void) {
107 if (timer_id
) gtk_timeout_remove(timer_id
);
108 if (idle_id
) gtk_idle_remove(idle_id
);