1 /* Dia -- an diagram creation/manipulation program
2 * Copyright (C) 1998 Alexander Larsson *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #include <sys/types.h>
31 #include <gdk-pixbuf/gdk-pixbuf.h>
34 /* Added by Andrew Ferrier: for use of gnome_about_new() */
42 * Instead of polluting the Dia namespace with windoze headers, declare the
43 * required prototype here. This is bad style, but not as bad as namespace
44 * clashes to be resolved without C++ --hb
47 ShellExecuteA (long hwnd
,
48 const char* lpOperation
,
50 const char* lpParameters
,
51 const char* lpDirectory
,
55 #include "paginate_psprint.h"
57 # include "paginate_gdiprint.h"
61 #include "app_procs.h"
64 #include "object_ops.h"
65 #include "cut_n_paste.h"
66 #include "load_save.h"
70 #include "properties.h"
71 #include "propinternals.h"
72 #include "preferences.h"
73 #include "layer_dialog.h"
74 #include "connectionpoint_ops.h"
76 #include "pagesetup.h"
81 #include "gdk/gdkkeysyms.h"
82 #include "lib/properties.h"
83 #include "dia-props.h"
84 #include "diagram_tree_window.h"
85 #include "authors.h" /* master contributors data */
89 void file_quit_callback(gpointer data
, guint action
, GtkWidget
*widget
)
95 file_pagesetup_callback(gpointer data
, guint action
, GtkWidget
*widget
)
99 dia
= ddisplay_active()->diagram
;
100 create_page_setup_dlg(dia
);
104 file_print_callback(gpointer data
, guint action
, GtkWidget
*widget
)
108 dia
= ddisplay_active()->diagram
;
110 /* This option could be used with Gnome too. Does it make sense there ? */
111 if (!prefs
.prefer_psprint
)
112 diagram_print_gdi(dia
);
115 diagram_print_ps(dia
);
119 file_close_callback(gpointer data
, guint action
, GtkWidget
*widget
)
121 ddisplay_close(ddisplay_active());
125 file_new_callback(gpointer data
, guint action
, GtkWidget
*widget
)
129 static int untitled_nr
= 1;
132 g_snprintf(buffer
, 24, _("Diagram%d.dia"), untitled_nr
++);
134 dia
= new_diagram(buffer
);
135 ddisp
= new_display(dia
);
136 diagram_tree_add(diagram_tree(), dia
);
140 file_preferences_callback(gpointer data
, guint action
, GtkWidget
*widget
)
147 edit_copy_callback(gpointer data
, guint action
, GtkWidget
*widget
)
152 ddisp
= ddisplay_active();
153 copy_list
= parent_list_affected(diagram_get_sorted_selected(ddisp
->diagram
));
155 cnp_store_objects(object_copy_list(copy_list
));
156 g_list_free(copy_list
);
158 ddisplay_do_update_menu_sensitivity(ddisp
);
162 edit_cut_callback(gpointer data
, guint action
, GtkWidget
*widget
)
168 ddisp
= ddisplay_active();
170 diagram_selected_break_external(ddisp
->diagram
);
172 cut_list
= parent_list_affected(diagram_get_sorted_selected(ddisp
->diagram
));
174 cnp_store_objects(object_copy_list(cut_list
));
176 change
= undo_delete_objects_children(ddisp
->diagram
, cut_list
);
177 (change
->apply
)(change
, ddisp
->diagram
);
179 ddisplay_do_update_menu_sensitivity(ddisp
);
180 diagram_flush(ddisp
->diagram
);
183 diagram_modified(ddisp
->diagram
);
184 undo_set_transactionpoint(ddisp
->diagram
->undo
);
189 edit_paste_callback(gpointer data
, guint action
, GtkWidget
*widget
)
197 ddisp
= ddisplay_active();
199 if (!cnp_exist_stored_objects()) {
200 message_warning(_("No existing object to paste.\n"));
204 paste_list
= cnp_get_stored_objects(); /* Gets a copy */
206 paste_corner
= object_list_corner(paste_list
);
208 delta
.x
= ddisp
->visible
.left
- paste_corner
.x
;
209 delta
.y
= ddisp
->visible
.top
- paste_corner
.y
;
211 /* Move down some 10% of the visible area. */
212 delta
.x
+= (ddisp
->visible
.right
- ddisp
->visible
.left
)*0.1;
213 delta
.y
+= (ddisp
->visible
.bottom
- ddisp
->visible
.top
)*0.1;
215 object_list_move_delta(paste_list
, &delta
);
217 change
= undo_insert_objects(ddisp
->diagram
, paste_list
, 0);
218 (change
->apply
)(change
, ddisp
->diagram
);
220 diagram_modified(ddisp
->diagram
);
221 undo_set_transactionpoint(ddisp
->diagram
->undo
);
223 diagram_remove_all_selected(ddisp
->diagram
, TRUE
);
224 diagram_select_list(ddisp
->diagram
, paste_list
);
226 diagram_flush(ddisp
->diagram
);
229 /* Signal handler for getting the clipboard contents */
230 /* Note that the clipboard is for M$-style cut/copy/paste copying, while
231 the selection is for Unix-style mark-and-copy. We can't really do
236 insert_text(DDisplay
*ddisp
, Focus
*focus
, const gchar
*text
)
238 ObjectChange
*change
= NULL
;
239 int modified
= FALSE
, any_modified
= FALSE
;
240 Object
*obj
= focus
->obj
;
242 while (text
!= NULL
) {
243 gchar
*next_line
= g_utf8_strchr(text
, -1, '\n');
244 if (next_line
!= text
) {
245 gint len
= g_utf8_strlen(text
, (next_line
-text
));
246 modified
= (*focus
->key_event
)(focus
, GDK_A
, text
, len
, &change
);
248 if (next_line
!= NULL
) {
249 modified
= (*focus
->key_event
)(focus
, GDK_Return
, "\n", 1, &change
);
250 text
= g_utf8_next_char(next_line
);
254 { /* Make sure object updates its data: */
255 Point p
= obj
->position
;
256 (obj
->ops
->move
)(obj
,&p
); }
258 /* Perhaps this can be improved */
259 object_add_updates(obj
, ddisp
->diagram
);
261 if (modified
&& (change
!= NULL
)) {
262 undo_object_change(ddisp
->diagram
, obj
, change
);
266 diagram_flush(ddisp
->diagram
);
270 undo_set_transactionpoint(ddisp
->diagram
->undo
);
275 received_clipboard_handler(GtkClipboard
*clipboard
,
278 Focus
*focus
= active_focus();
279 DDisplay
*ddisp
= (DDisplay
*)data
;
281 if (text
== NULL
) return;
283 if ((focus
== NULL
) || (!focus
->has_focus
)) return;
285 if (!g_utf8_validate(text
, -1, NULL
)) {
286 message_error("Not valid UTF8");
290 insert_text(ddisp
, focus
, text
);
293 static PropDescription text_prop_singleton_desc
[] = {
294 { "text", PROP_TYPE_TEXT
},
298 make_text_prop_singleton(GPtrArray
**props
, TextProperty
**prop
)
300 *props
= prop_list_from_descs(text_prop_singleton_desc
,pdtpp_true
);
301 g_assert((*props
)->len
== 1);
303 *prop
= g_ptr_array_index((*props
),0);
304 g_free((*prop
)->text_data
);
305 (*prop
)->text_data
= NULL
;
310 edit_copy_text_callback(gpointer data
, guint action
, GtkWidget
*widget
)
312 Focus
*focus
= active_focus();
315 GPtrArray
*textprops
;
318 if ((focus
== NULL
) || (!focus
->has_focus
)) return;
320 ddisp
= ddisplay_active();
324 if (obj
->ops
->get_props
== NULL
)
327 make_text_prop_singleton(&textprops
,&prop
);
328 /* Get the first text property */
329 obj
->ops
->get_props(obj
, textprops
);
331 /* GTK docs claim the selection clipboard is ignored on Win32.
332 * The "clipboard" clipboard is mostly ignored in Unix
335 gtk_clipboard_set_text(gtk_clipboard_get(GDK_NONE
),
336 prop
->text_data
, -1);
338 gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY
),
339 prop
->text_data
, -1);
341 prop_list_free(textprops
);
345 edit_cut_text_callback(gpointer data
, guint action
, GtkWidget
*widget
)
347 Focus
*focus
= active_focus();
351 GPtrArray
*textprops
;
353 ObjectChange
*change
;
355 if ((focus
== NULL
) || (!focus
->has_focus
)) return;
357 ddisp
= ddisplay_active();
360 text
= (Text
*)focus
->user_data
;
362 if (obj
->ops
->get_props
== NULL
)
365 make_text_prop_singleton(&textprops
,&prop
);
366 /* Get the first text property */
367 obj
->ops
->get_props(obj
, textprops
);
369 /* GTK docs claim the selection clipboard is ignored on Win32.
370 * The "clipboard" clipboard is mostly ignored in Unix
373 gtk_clipboard_set_text(gtk_clipboard_get(GDK_NONE
),
374 prop
->text_data
, -1);
376 gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY
),
377 prop
->text_data
, -1);
380 prop_list_free(textprops
);
382 if (text_delete_all(text
, &change
)) {
383 object_add_updates(obj
, ddisp
->diagram
);
384 undo_object_change(ddisp
->diagram
, obj
, change
);
385 undo_set_transactionpoint(ddisp
->diagram
->undo
);
386 diagram_flush(ddisp
->diagram
);
391 edit_paste_text_callback(gpointer data
, guint action
, GtkWidget
*widget
)
395 ddisp
= ddisplay_active();
398 gtk_clipboard_request_text(gtk_clipboard_get(GDK_NONE
),
399 received_clipboard_handler
, ddisp
);
401 gtk_clipboard_request_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY
),
402 received_clipboard_handler
, ddisp
);
407 edit_delete_callback(gpointer data
, guint action
, GtkWidget
*widget
)
415 ddisp
= ddisplay_active();
417 diagram_selected_break_external(ddisp
->diagram
);
419 delete_list
= diagram_get_sorted_selected(ddisp
->diagram
);
420 change
= undo_delete_objects_children(ddisp
->diagram
, delete_list
);
421 (change
->apply
)(change
, ddisp
->diagram
);
423 diagram_modified(ddisp
->diagram
);
425 ddisplay_do_update_menu_sensitivity(ddisp
);
426 diagram_flush(ddisp
->diagram
);
428 undo_set_transactionpoint(ddisp
->diagram
->undo
);
432 edit_undo_callback(gpointer data
, guint action
, GtkWidget
*widget
)
437 ddisp
= ddisplay_active();
438 dia
= ddisp
->diagram
;
440 undo_revert_to_last_tp(dia
->undo
);
446 edit_redo_callback(gpointer data
, guint action
, GtkWidget
*widget
)
451 ddisp
= ddisplay_active();
452 dia
= ddisp
->diagram
;
454 undo_apply_to_next_tp(dia
->undo
);
460 help_manual_callback(gpointer data
, guint action
, GtkWidget
*widget
)
462 char *helpdir
, *helpindex
= NULL
, *command
;
463 guint bestscore
= G_MAXINT
;
466 GError
*error
= NULL
;
468 helpdir
= dia_get_data_directory("help");
470 message_warning(_("Could not find help directory"));
474 /* search through helpdir for the helpfile that matches the user's locale */
475 dp
= g_dir_open (helpdir
, 0, &error
);
477 message_warning(_("Could not open help directory:\n%s"),
479 g_error_free (error
);
483 while ((dentry
= g_dir_read_name(dp
)) != NULL
) {
486 score
= intl_score_locale(dentry
);
487 if (score
< bestscore
) {
491 /* use HTML Help on win32 if available */
492 helpindex
= g_strconcat(helpdir
, G_DIR_SEPARATOR_S
, dentry
,
493 G_DIR_SEPARATOR_S
"dia-manual.chm", NULL
);
494 if (!g_file_test(helpindex
, G_FILE_TEST_EXISTS
)) {
495 helpindex
= g_strconcat(helpdir
, G_DIR_SEPARATOR_S
, dentry
,
496 G_DIR_SEPARATOR_S
"index.html", NULL
);
499 helpindex
= g_strconcat(helpdir
, G_DIR_SEPARATOR_S
, dentry
,
500 G_DIR_SEPARATOR_S
"index.html", NULL
);
508 message_warning(_("Could not find help directory"));
513 #define SW_SHOWNORMAL 1
514 ShellExecuteA (0, "open", helpindex
, NULL
, helpdir
, SW_SHOWNORMAL
);
516 command
= getenv("BROWSER");
517 command
= g_strdup_printf("%s 'file://%s' &", command
? command
: "netscape", helpindex
);
526 help_about_callback(gpointer data
, guint action
, GtkWidget
*widget
)
530 /* Take advantage of gnome_about_new(),
531 * which is much cleaner and GNOME2 HIG compliant,
532 * Originally implemented by Xing Wang, modified
535 * Note: in this function there is no need to discriminate
536 * between the different kinds of 'authors'.
539 static GtkWidget
*about
;
542 * Translators should localize the following string
543 * which will give them credit in the About box.
544 * E.g. "Fulano de Tal <fulano@detal.com>"
547 gchar
*translators
= _("translator_credits-PLEASE_ADD_YOURSELF_HERE");
548 gchar logo_file
[100];
553 gchar
* datadir
= dia_get_data_directory("");
554 g_snprintf(logo_file
, sizeof(logo_file
),
555 "%s%sdia_logo.png", datadir
, G_DIR_SEPARATOR_S
);
557 logo
= gdk_pixbuf_new_from_file(logo_file
, NULL
);
560 about
= gnome_about_new(
563 _("Copyright (C) 1998-2002 The Free Software Foundation and the authors"),
564 _("Dia is a program for drawing structured diagrams.\n"
565 "Please visit http://www.lysator.liu.se/~alla/dia for more information."),
568 (strcmp (translators
, "translator_credits-PLEASE_ADD_YOURSELF_HERE")
569 ? translators
: NULL
),
573 g_object_unref (logo
);
575 g_signal_connect (about
, "destroy",
576 G_CALLBACK (gtk_widget_destroyed
),
580 gtk_widget_show_now (about
);
584 /* No GNOME, fall back to the old GTK method */
586 const gint nauthors
= (sizeof(authors
) / sizeof(authors
[0])) - 1;
587 const gint ndocumentors
= (sizeof(documentors
) / sizeof(documentors
[0])) - 1;
601 dialog
= gtk_dialog_new ();
602 gtk_window_set_role (GTK_WINDOW (dialog
), "about_dialog");
603 gtk_window_set_title (GTK_WINDOW (dialog
), _("About Dia"));
604 gtk_window_set_resizable (GTK_WINDOW (dialog
), FALSE
);
605 gtk_window_set_position (GTK_WINDOW (dialog
), GTK_WIN_POS_CENTER
);
606 g_signal_connect (GTK_OBJECT (dialog
), "destroy",
607 G_CALLBACK (gtk_widget_destroy
),
608 GTK_OBJECT (dialog
));
610 vbox
= gtk_vbox_new (FALSE
, 1);
611 gtk_container_set_border_width (GTK_CONTAINER (vbox
), 5);
612 gtk_container_add (GTK_CONTAINER(GTK_DIALOG(dialog
)->vbox
), vbox
);
615 gchar
* datadir
= dia_get_data_directory("");
616 g_snprintf(str
, sizeof(str
), "%s%sdia_logo.png", datadir
, G_DIR_SEPARATOR_S
);
617 logo
= gdk_pixbuf_new_from_file(str
, NULL
);
625 frame
= gtk_frame_new (NULL
);
626 gtk_frame_set_shadow_type (GTK_FRAME (frame
), GTK_SHADOW_IN
);
627 gtk_container_set_border_width (GTK_CONTAINER (frame
), 1);
628 gtk_box_pack_start(GTK_BOX(vbox
), frame
, FALSE
, TRUE
, 1);
630 gdk_pixbuf_render_pixmap_and_mask(logo
, &pixmap
, &bitmap
, 128);
631 gpixmap
= gtk_pixmap_new(pixmap
, bitmap
);
632 gdk_pixmap_unref(pixmap
);
633 if (bitmap
) gdk_bitmap_unref(bitmap
);
634 gtk_container_add (GTK_CONTAINER(frame
), gpixmap
);
637 frame
= gtk_frame_new (NULL
);
638 gtk_frame_set_shadow_type (GTK_FRAME (frame
), GTK_SHADOW_IN
);
639 gtk_container_set_border_width (GTK_CONTAINER (frame
), 1);
640 gtk_box_pack_start(GTK_BOX(vbox
), frame
, FALSE
, TRUE
, 1);
642 table
= gtk_table_new(3, 2, FALSE
);
643 gtk_container_set_border_width (GTK_CONTAINER (table
), 1);
644 gtk_container_add (GTK_CONTAINER (frame
), table
);
646 g_snprintf(str
, sizeof(str
), _("Dia v %s by Alexander Larsson"), VERSION
);
647 label
= gtk_label_new (str
);
648 gtk_table_attach(GTK_TABLE(table
), label
, 0,2, 0,1,
649 GTK_FILL
|GTK_EXPAND
, GTK_FILL
, 0,2);
651 /* Exact spelling is Chépélov (using *ML entities) */
652 label
= gtk_label_new(_("Maintainers: Lars Clausen and Cyrille Chepelov"));
653 gtk_table_attach(GTK_TABLE(table
), label
, 0,2, 1,2,
654 GTK_FILL
|GTK_EXPAND
, GTK_FILL
, 0,2);
656 label
= gtk_label_new (_("Please visit http://www.lysator.liu.se/~alla/dia "
657 "for more information"));
658 gtk_table_attach(GTK_TABLE(table
), label
, 0,2, 2,3,
659 GTK_FILL
|GTK_EXPAND
, GTK_FILL
, 0,2);
661 label
= gtk_label_new (_("Contributors:"));
662 gtk_table_attach(GTK_TABLE(table
), label
, 0,2, 3,4,
663 GTK_FILL
|GTK_EXPAND
, GTK_FILL
, 0,2);
665 for (i
= 0; i
< nauthors
; i
++) {
666 label
= gtk_label_new(authors
[i
]);
667 gtk_table_attach(GTK_TABLE(table
), label
, i
%2,i
%2+1, i
/2+4,i
/2+5,
668 GTK_FILL
|GTK_EXPAND
, GTK_FILL
, 0,0);
671 for (i
= nauthors
; i
< nauthors
+ ndocumentors
; i
++) {
672 label
= gtk_label_new(documentors
[i
- nauthors
]);
673 gtk_table_attach(GTK_TABLE(table
), label
, i
%2,i
%2+1, i
/2+4,i
/2+5,
674 GTK_FILL
|GTK_EXPAND
, GTK_FILL
, 0,0);
677 gtk_table_set_col_spacings(GTK_TABLE(table
), 1);
678 gtk_table_set_row_spacings(GTK_TABLE(table
), 1);
680 bbox
= gtk_hbutton_box_new();
681 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->action_area
), bbox
, TRUE
, TRUE
, 5);
682 gtk_button_box_set_child_size(GTK_BUTTON_BOX(bbox
), 80, 0);
683 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox
), 10);
685 button
= gtk_button_new_from_stock(GTK_STOCK_OK
);
686 gtk_container_add(GTK_CONTAINER(bbox
), button
);
687 g_signal_connect_swapped(GTK_OBJECT (button
), "clicked",
688 G_CALLBACK(gtk_widget_destroy
),
691 gtk_widget_show_all (dialog
);
697 view_zoom_in_callback(gpointer data
, guint action
, GtkWidget
*widget
)
703 ddisp
= ddisplay_active();
704 visible
= &ddisp
->visible
;
705 middle
.x
= visible
->left
*0.5 + visible
->right
*0.5;
706 middle
.y
= visible
->top
*0.5 + visible
->bottom
*0.5;
708 ddisplay_zoom(ddisp
, &middle
, M_SQRT2
);
712 view_zoom_out_callback(gpointer data
, guint action
, GtkWidget
*widget
)
718 ddisp
= ddisplay_active();
719 visible
= &ddisp
->visible
;
720 middle
.x
= visible
->left
*0.5 + visible
->right
*0.5;
721 middle
.y
= visible
->top
*0.5 + visible
->bottom
*0.5;
723 ddisplay_zoom(ddisp
, &middle
, M_SQRT1_2
);
727 view_zoom_set_callback(gpointer data
, guint action
, GtkWidget
*widget
)
734 ddisp
= ddisplay_active();
735 visible
= &ddisp
->visible
;
736 middle
.x
= visible
->left
*0.5 + visible
->right
*0.5;
737 middle
.y
= visible
->top
*0.5 + visible
->bottom
*0.5;
739 scale
= ((real
) action
)/1000.0 * DDISPLAY_NORMAL_ZOOM
;
741 ddisplay_zoom(ddisp
, &middle
, scale
/ ddisp
->zoom_factor
);
745 view_show_cx_pts_callback(gpointer data
, guint action
, GtkWidget
*widget
)
750 ddisp
= ddisplay_active();
752 old_val
= ddisp
->show_cx_pts
;
753 ddisp
->show_cx_pts
= GTK_CHECK_MENU_ITEM(widget
)->active
;
755 if (old_val
!= ddisp
->show_cx_pts
) {
756 ddisplay_add_update_all(ddisp
);
757 ddisplay_flush(ddisp
);
762 view_aa_callback(gpointer data
, guint action
, GtkWidget
*widget
)
767 ddisp
= ddisplay_active();
769 aa
= GTK_CHECK_MENU_ITEM(widget
)->active
;
771 if (aa
!= ddisp
->aa_renderer
) {
772 ddisplay_set_renderer(ddisp
, aa
);
773 ddisplay_add_update_all(ddisp
);
774 ddisplay_flush(ddisp
);
779 view_visible_grid_callback(gpointer data
, guint action
, GtkWidget
*widget
)
784 ddisp
= ddisplay_active();
786 old_val
= ddisp
->grid
.visible
;
787 ddisp
->grid
.visible
= GTK_CHECK_MENU_ITEM(widget
)->active
;
789 if (old_val
!= ddisp
->grid
.visible
) {
790 ddisplay_add_update_all(ddisp
);
791 ddisplay_flush(ddisp
);
796 view_snap_to_grid_callback(gpointer data
, guint action
, GtkWidget
*widget
)
800 ddisp
= ddisplay_active();
802 ddisplay_set_snap_to_grid(ddisp
, GTK_CHECK_MENU_ITEM(widget
)->active
);
805 void view_toggle_rulers_callback(gpointer data
, guint action
, GtkWidget
*widget
)
809 ddisp
= ddisplay_active();
811 /* The following is borrowed straight from the Gimp: */
813 /* This routine use promiscuous knowledge of gtk internals
814 * in order to hide and show the rulers "smoothly". This
815 * is kludgy and a hack and may break if gtk is changed
818 if (!GTK_CHECK_MENU_ITEM(widget
)->active
) {
819 if (GTK_WIDGET_VISIBLE (ddisp
->origin
)) {
820 gtk_widget_unmap (ddisp
->origin
);
821 gtk_widget_unmap (ddisp
->hrule
);
822 gtk_widget_unmap (ddisp
->vrule
);
824 GTK_WIDGET_UNSET_FLAGS (ddisp
->origin
, GTK_VISIBLE
);
825 GTK_WIDGET_UNSET_FLAGS (ddisp
->hrule
, GTK_VISIBLE
);
826 GTK_WIDGET_UNSET_FLAGS (ddisp
->vrule
, GTK_VISIBLE
);
828 gtk_widget_queue_resize (GTK_WIDGET (ddisp
->origin
->parent
));
831 if (!GTK_WIDGET_VISIBLE (ddisp
->origin
)) {
832 GTK_WIDGET_SET_FLAGS (ddisp
->origin
, GTK_VISIBLE
);
833 GTK_WIDGET_SET_FLAGS (ddisp
->hrule
, GTK_VISIBLE
);
834 GTK_WIDGET_SET_FLAGS (ddisp
->vrule
, GTK_VISIBLE
);
836 gtk_widget_map (ddisp
->origin
);
837 gtk_widget_map (ddisp
->hrule
);
838 gtk_widget_map (ddisp
->vrule
);
840 gtk_widget_queue_resize (GTK_WIDGET (ddisp
->origin
->parent
));
846 view_new_view_callback(gpointer data
, guint action
, GtkWidget
*widget
)
851 ddisp
= ddisplay_active();
852 dia
= ddisp
->diagram
;
854 ddisp
= new_display(dia
);
858 view_show_all_callback(gpointer data
, guint action
, GtkWidget
*widget
)
862 real magnify_x
, magnify_y
;
866 ddisp
= ddisplay_active();
867 dia
= ddisp
->diagram
;
869 width
= dia_renderer_get_width_pixels (ddisp
->renderer
);
870 height
= dia_renderer_get_height_pixels (ddisp
->renderer
);
872 magnify_x
= (real
)width
/
873 (dia
->data
->extents
.right
- dia
->data
->extents
.left
) / ddisp
->zoom_factor
;
874 magnify_y
= (real
)height
/
875 (dia
->data
->extents
.bottom
- dia
->data
->extents
.top
) / ddisp
->zoom_factor
;
877 middle
.x
= dia
->data
->extents
.left
+
878 (dia
->data
->extents
.right
- dia
->data
->extents
.left
) / 2.0;
879 middle
.y
= dia
->data
->extents
.top
+
880 (dia
->data
->extents
.bottom
- dia
->data
->extents
.top
) / 2.0;
882 ddisplay_zoom (ddisp
, &middle
, (magnify_x
<magnify_y
)?magnify_x
:magnify_y
);
884 ddisplay_update_scrollbars(ddisp
);
885 ddisplay_add_update_all(ddisp
);
886 ddisplay_flush(ddisp
);
890 view_redraw_callback(gpointer data
, guint action
, GtkWidget
*widget
)
893 ddisp
= ddisplay_active();
894 ddisplay_add_update_all(ddisp
);
895 ddisplay_flush(ddisp
);
899 view_diagram_properties_callback(gpointer data
, guint action
, GtkWidget
*widget
)
903 ddisp
= ddisplay_active();
904 diagram_properties_show(ddisp
->diagram
);
909 objects_place_over_callback(gpointer data
, guint action
, GtkWidget
*widget
)
911 diagram_place_over_selected(ddisplay_active()->diagram
);
915 objects_place_under_callback(gpointer data
, guint action
, GtkWidget
*widget
)
917 diagram_place_under_selected(ddisplay_active()->diagram
);
921 objects_place_up_callback(gpointer data
, guint action
, GtkWidget
*widget
)
923 diagram_place_up_selected(ddisplay_active()->diagram
);
927 objects_place_down_callback(gpointer data
, guint action
, GtkWidget
*widget
)
929 diagram_place_down_selected(ddisplay_active()->diagram
);
933 objects_parent_callback(gpointer data
, guint action
, GtkWidget
*widget
)
935 diagram_parent_selected(ddisplay_active()->diagram
);
939 objects_unparent_callback(gpointer data
, guint action
, GtkWidget
*widget
)
941 diagram_unparent_selected(ddisplay_active()->diagram
);
945 objects_unparent_children_callback(gpointer data
, guint action
, GtkWidget
*widget
)
947 diagram_unparent_children_selected(ddisplay_active()->diagram
);
951 objects_group_callback(gpointer data
, guint action
, GtkWidget
*widget
)
953 diagram_group_selected(ddisplay_active()->diagram
);
957 objects_ungroup_callback(gpointer data
, guint action
, GtkWidget
*widget
)
959 diagram_ungroup_selected(ddisplay_active()->diagram
);
963 dialogs_properties_callback(gpointer data
, guint action
, GtkWidget
*widget
)
968 dia
= ddisplay_active()->diagram
;
970 if (dia
->data
->selected
!= NULL
) {
971 selected
= dia
->data
->selected
->data
;
972 properties_show(dia
, selected
);
974 diagram_properties_show(dia
);
979 dialogs_layers_callback(gpointer data
, guint action
, GtkWidget
*widget
)
981 layer_dialog_set_diagram(ddisplay_active()->diagram
);
987 objects_align_h_callback(gpointer data
, guint action
, GtkWidget
*widget
)
995 dia
= ddisplay_active()->diagram
;
996 objects
= dia
->data
->selected
;
998 object_add_updates_list(objects
, dia
);
999 object_list_align_h(objects
, dia
, align
);
1000 diagram_update_connections_selection(dia
);
1001 object_add_updates_list(objects
, dia
);
1004 undo_set_transactionpoint(dia
->undo
);
1008 objects_align_v_callback(gpointer data
, guint action
, GtkWidget
*widget
)
1016 dia
= ddisplay_active()->diagram
;
1017 objects
= dia
->data
->selected
;
1019 object_add_updates_list(objects
, dia
);
1020 object_list_align_v(objects
, dia
, align
);
1021 diagram_update_connections_selection(dia
);
1022 object_add_updates_list(objects
, dia
);
1025 undo_set_transactionpoint(dia
->undo
);