19 |
|
|
20 |
#include "editor.h" |
#include "editor.h" |
21 |
|
|
22 |
|
static const gchar SituationEditList[] = "SituationEditListQuark"; |
23 |
|
|
24 |
#define APP_IP_EDIT_TYPE (app_ip_edit_get_type()) |
#define APP_IP_EDIT_TYPE (app_ip_edit_get_type()) |
25 |
#define APP_IP_EDIT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), APP_IP_EDIT_TYPE, AppIpEdit)) |
#define APP_IP_EDIT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), APP_IP_EDIT_TYPE, AppIpEdit)) |
26 |
#define IS_APP_IP_EDIT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), APP_IP_EDIT_TYPE)) |
#define IS_APP_IP_EDIT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), APP_IP_EDIT_TYPE)) |
307 |
return app_ip_edit_get_data (ed->edit); |
return app_ip_edit_get_data (ed->edit); |
308 |
} |
} |
309 |
|
|
310 |
|
static void |
311 |
|
_tx_situation_edit_destroy (gpointer *ptr) |
312 |
|
{ |
313 |
|
GSList *editors = *ptr; |
314 |
|
for (GSList *elem = editors; elem; elem = g_slist_next (elem)) |
315 |
|
gtk_widget_destroy (GTK_WIDGET (elem->data)); |
316 |
|
g_slist_free (editors); |
317 |
|
g_free (ptr); |
318 |
|
} |
319 |
|
|
320 |
|
static GSList * |
321 |
|
_ipe_get_situation_edit_list (AppTranscript *tx) |
322 |
|
{ |
323 |
|
gpointer *ptr = g_object_get_data (G_OBJECT (tx), SituationEditList); |
324 |
|
if (!ptr) |
325 |
|
return NULL; |
326 |
|
return (GSList*) *ptr; |
327 |
|
} |
328 |
|
|
329 |
|
static void |
330 |
|
_ipe_set_situation_edit_list (AppTranscript *tx, GSList *editors) |
331 |
|
{ |
332 |
|
gpointer *ptr = g_object_get_data (G_OBJECT (tx), SituationEditList); |
333 |
|
if (ptr) { |
334 |
|
((GSList*) *ptr) = editors; |
335 |
|
} else { |
336 |
|
ptr = g_new (gpointer, 1); |
337 |
|
*ptr = editors; |
338 |
|
g_object_set_data_full (G_OBJECT (tx), SituationEditList, ptr, |
339 |
|
(GDestroyNotify) _tx_situation_edit_destroy); |
340 |
|
} |
341 |
|
} |
342 |
|
|
343 |
|
GSList * |
344 |
|
app_transcript_get_open_editors (AppTranscript *tx) |
345 |
|
{ |
346 |
|
GSList *editors = _ipe_get_situation_edit_list (tx); |
347 |
|
return g_slist_copy (editors); |
348 |
|
} |
349 |
|
|
350 |
|
void |
351 |
|
app_ip_editor_find_and_destroy (AppIp *ip) |
352 |
|
{ |
353 |
|
AppTranscript *tx = app_ip_get_transcript (ip); |
354 |
|
GSList *editors = _ipe_get_situation_edit_list (tx); |
355 |
|
|
356 |
|
for (GSList *elem = editors; elem; elem = g_slist_next (elem)) { |
357 |
|
AppIp *cur = app_ip_editor_get_current (APP_IP_EDITOR (elem->data)); |
358 |
|
if (ip == cur) { |
359 |
|
app_ip_editor_destroy (elem->data); |
360 |
|
break; |
361 |
|
} |
362 |
|
} |
363 |
|
} |
364 |
|
|
365 |
void |
void |
366 |
app_ip_editor_new (AppIp *ip) |
app_ip_editor_new (AppIp *ip) |
367 |
{ |
{ |
368 |
g_return_if_fail (ip); |
g_return_if_fail (ip); |
369 |
|
|
370 |
AppTranscript *tx = app_ip_get_transcript (ip); |
AppTranscript *tx = app_ip_get_transcript (ip); |
371 |
|
GSList *editors = _ipe_get_situation_edit_list (tx); |
372 |
|
|
373 |
gboolean done = FALSE; |
gboolean done = FALSE; |
374 |
for (GSList *elem = tx->ip_edit; elem; elem = g_slist_next (elem)) |
for (GSList *elem = editors; elem; elem = g_slist_next (elem)) { |
375 |
{ |
if (app_ip_editor_get_current (APP_IP_EDITOR (elem->data)) == ip) |
376 |
if (app_ip_editor_get_current (APP_IP_EDITOR (elem->data)) == ip) |
{ |
377 |
{ |
gtk_window_present (GTK_WINDOW (elem->data)); |
378 |
gtk_window_present (GTK_WINDOW (elem->data)); |
|
379 |
|
// We should just return here, but gcc 3.0.2 20010922 gives |
380 |
// We should just return here, but gcc 3.0.2 20010922 gives |
// a bogus "will never be executed" warning. |
381 |
// a bogus "will never be executed" warning. |
|
382 |
|
done = TRUE; |
383 |
done = TRUE; |
break; |
384 |
break; |
} |
385 |
} |
} |
|
} |
|
386 |
if (done) |
if (done) |
387 |
return; |
return; |
388 |
|
|
394 |
|
|
395 |
app_ip_edit_set_data (APP_IP_EDITOR (editor)->edit, ip); |
app_ip_edit_set_data (APP_IP_EDITOR (editor)->edit, ip); |
396 |
|
|
397 |
tx->ip_edit = g_slist_prepend (tx->ip_edit, editor); |
editors = g_slist_prepend (editors, editor); |
398 |
|
_ipe_set_situation_edit_list (tx, editors); |
399 |
|
|
400 |
g_signal_connect_object |
g_signal_connect_object |
401 |
(tx, "notify::protection", |
(tx, "notify::protection", |
428 |
AppIp *ip = app_ip_edit_get_data (ed->edit); |
AppIp *ip = app_ip_edit_get_data (ed->edit); |
429 |
AppTranscript *tx = app_ip_get_transcript (ip); |
AppTranscript *tx = app_ip_get_transcript (ip); |
430 |
|
|
431 |
tx->ip_edit = g_slist_remove (tx->ip_edit, ed); |
GSList *editors = _ipe_get_situation_edit_list (tx); |
432 |
|
if (editors) { |
433 |
|
editors = g_slist_remove (editors, ed); |
434 |
|
_ipe_set_situation_edit_list (tx, editors); |
435 |
|
} |
436 |
|
|
437 |
g_object_unref (ed->edit); |
g_object_unref (ed->edit); |
438 |
|
|