作図ソフト dia の改良版
Revisão | 2c7f0103b325cf0f216d940585482a0c6714d240 (tree) |
---|---|
Hora | 2004-05-05 20:36:04 |
Autor | Lars Clausen <lclausen@src....> |
Commiter | Lars Clausen |
Better undo
@@ -1,3 +1,16 @@ | ||
1 | +2004-05-05 Lars Clausen <lars@raeder.dk> | |
2 | + | |
3 | + * app/dia-props.c (diagram_properties_respond): | |
4 | + * app/diagram.c (diagram_set_modified): | |
5 | + * app/undo.c: | |
6 | + * app/disp_callbacks.c: | |
7 | + * app/commands.c: | |
8 | + * app/load_save.c (diagram_save): | |
9 | + Better handling of undo and modified status -- only diagram | |
10 | + properties and page setup explicitly set modified status, all | |
11 | + other important changes should be done through the undo stack | |
12 | + now. | |
13 | + | |
1 | 14 | 2004-05-04 Lars Clausen <lars@raeder.dk> |
2 | 15 | |
3 | 16 | * app/app_procs.c (app_init): Consistently open a new diagram if |
@@ -311,8 +311,10 @@ insert_text(DDisplay *ddisp, Focus *focus, const gchar *text) | ||
311 | 311 | diagram_flush(ddisp->diagram); |
312 | 312 | } |
313 | 313 | |
314 | - if (any_modified) | |
314 | + if (any_modified) { | |
315 | + diagram_modified(ddisp->diagram); | |
315 | 316 | undo_set_transactionpoint(ddisp->diagram->undo); |
317 | + } | |
316 | 318 | } |
317 | 319 | |
318 | 320 |
@@ -428,6 +430,7 @@ edit_cut_text_callback(gpointer data, guint action, GtkWidget *widget) | ||
428 | 430 | object_add_updates(obj, ddisp->diagram); |
429 | 431 | undo_object_change(ddisp->diagram, obj, change); |
430 | 432 | undo_set_transactionpoint(ddisp->diagram->undo); |
433 | + diagram_modified(ddisp->diagram); | |
431 | 434 | diagram_flush(ddisp->diagram); |
432 | 435 | } |
433 | 436 | } |
@@ -483,6 +486,7 @@ edit_undo_callback(gpointer data, guint action, GtkWidget *widget) | ||
483 | 486 | dia = ddisp->diagram; |
484 | 487 | |
485 | 488 | undo_revert_to_last_tp(dia->undo); |
489 | + diagram_modified(dia); | |
486 | 490 | |
487 | 491 | diagram_flush(dia); |
488 | 492 | } |
@@ -497,6 +501,7 @@ edit_redo_callback(gpointer data, guint action, GtkWidget *widget) | ||
497 | 501 | dia = ddisp->diagram; |
498 | 502 | |
499 | 503 | undo_apply_to_next_tp(dia->undo); |
504 | + diagram_modified(dia); | |
500 | 505 | |
501 | 506 | diagram_flush(dia); |
502 | 507 | } |
@@ -1045,6 +1050,7 @@ objects_align_h_callback(gpointer data, guint action, GtkWidget *widget) | ||
1045 | 1050 | diagram_update_connections_selection(dia); |
1046 | 1051 | object_add_updates_list(objects, dia); |
1047 | 1052 | diagram_flush(dia); |
1053 | + diagram_modified(dia); | |
1048 | 1054 | |
1049 | 1055 | undo_set_transactionpoint(dia->undo); |
1050 | 1056 | } |
@@ -1066,6 +1072,7 @@ objects_align_v_callback(gpointer data, guint action, GtkWidget *widget) | ||
1066 | 1072 | diagram_update_connections_selection(dia); |
1067 | 1073 | object_add_updates_list(objects, dia); |
1068 | 1074 | diagram_flush(dia); |
1075 | + diagram_modified(dia); | |
1069 | 1076 | |
1070 | 1077 | undo_set_transactionpoint(dia->undo); |
1071 | 1078 | } |
@@ -272,8 +272,8 @@ diagram_properties_respond(GtkWidget *widget, | ||
272 | 272 | { |
273 | 273 | Diagram *active_diagram = ddisplay_active_diagram(); |
274 | 274 | |
275 | - if (response_id != GTK_RESPONSE_OK || | |
276 | - response_id != GTK_RESPONSE_APPLY) { | |
275 | + if (response_id == GTK_RESPONSE_OK || | |
276 | + response_id == GTK_RESPONSE_APPLY) { | |
277 | 277 | if (active_diagram) { |
278 | 278 | active_diagram->data->grid.dynamic = |
279 | 279 | gtk_toggle_button_get_active(GTK_CHECK_BUTTON(dynamic_check)); |
@@ -293,6 +293,7 @@ diagram_properties_respond(GtkWidget *widget, | ||
293 | 293 | &active_diagram->data->pagebreak_color); |
294 | 294 | diagram_add_update_all(active_diagram); |
295 | 295 | diagram_flush(active_diagram); |
296 | + diagram_set_modified(active_diagram, TRUE); | |
296 | 297 | } |
297 | 298 | } |
298 | 299 | if (response_id != GTK_RESPONSE_APPLY) |
@@ -214,32 +214,38 @@ diagram_destroy(Diagram *dia) | ||
214 | 214 | gboolean |
215 | 215 | diagram_is_modified(Diagram *dia) |
216 | 216 | { |
217 | - return dia->mollified; | |
217 | + return dia->mollified || !undo_is_saved(dia->undo); | |
218 | 218 | } |
219 | 219 | |
220 | +/** We might just have change the diagrams modified status. | |
221 | + * This doesn't set the status, but merely updates the display. | |
222 | + */ | |
220 | 223 | void |
221 | 224 | diagram_modified(Diagram *dia) |
222 | 225 | { |
223 | - diagram_set_modified(dia, TRUE); | |
226 | + GSList *displays; | |
227 | + displays = dia->displays; | |
228 | + while (displays != NULL) { | |
229 | + DDisplay *display = (DDisplay*) displays->data; | |
230 | + ddisplay_update_statusbar(display); | |
231 | + displays = g_slist_next(displays); | |
232 | + } | |
233 | + if (diagram_is_modified(dia)) dia->autosaved = FALSE; | |
234 | + /* diagram_set_modified(dia, TRUE);*/ | |
224 | 235 | } |
225 | 236 | |
237 | +/** Set this diagram explicitly modified. This should not be called | |
238 | + * by things that change the undo stack, as those modifications are | |
239 | + * noticed through changes in the undo stack. | |
240 | + */ | |
226 | 241 | void |
227 | 242 | diagram_set_modified(Diagram *dia, int modified) |
228 | 243 | { |
229 | - GSList *displays; | |
230 | - | |
231 | 244 | if (dia->mollified != modified) |
232 | 245 | { |
233 | 246 | dia->mollified = modified; |
234 | - displays = dia->displays; | |
235 | - while (displays != NULL) | |
236 | - { | |
237 | - DDisplay *display = (DDisplay*) displays->data; | |
238 | - ddisplay_update_statusbar(display); | |
239 | - displays = g_slist_next(displays); | |
240 | - } | |
241 | 247 | } |
242 | - dia->autosaved = FALSE; | |
248 | + diagram_modified(dia); | |
243 | 249 | } |
244 | 250 | |
245 | 251 | /* ************ Functions that check for menu sensitivity ********* */ |
@@ -375,11 +375,11 @@ static void handle_key_event(DDisplay *ddisp, Focus *focus, guint keysym, | ||
375 | 375 | object_add_updates(obj, ddisp->diagram); |
376 | 376 | |
377 | 377 | if (modified) { |
378 | - diagram_modified(ddisp->diagram); | |
379 | 378 | if (obj_change != NULL) { |
380 | 379 | undo_object_change(ddisp->diagram, obj, obj_change); |
381 | 380 | undo_set_transactionpoint(ddisp->diagram->undo); |
382 | 381 | } |
382 | + diagram_modified(ddisp->diagram); | |
383 | 383 | } |
384 | 384 | |
385 | 385 | diagram_flush(ddisp->diagram); |
@@ -942,9 +942,9 @@ ddisplay_drop_object(DDisplay *ddisp, gint x, gint y, DiaObjectType *otype, | ||
942 | 942 | list = g_list_prepend(NULL, obj); |
943 | 943 | undo_insert_objects(ddisp->diagram, list, 1); |
944 | 944 | diagram_update_extents(ddisp->diagram); |
945 | - diagram_modified(ddisp->diagram); | |
946 | 945 | |
947 | 946 | undo_set_transactionpoint(ddisp->diagram->undo); |
947 | + diagram_modified(ddisp->diagram); | |
948 | 948 | if (prefs.reset_tools_after_create) |
949 | 949 | tool_reset(); |
950 | 950 | return obj; |
@@ -921,8 +921,8 @@ diagram_save(Diagram *dia, const char *filename) | ||
921 | 921 | } |
922 | 922 | |
923 | 923 | dia->unsaved = FALSE; |
924 | - diagram_set_modified (dia, FALSE); | |
925 | 924 | undo_mark_save(dia->undo); |
925 | + diagram_set_modified (dia, FALSE); | |
926 | 926 | |
927 | 927 | diagram_cleanup_autosave(dia); |
928 | 928 |