/** Set the display's snap-to-grid setting, updating menu and button * in the process */ void ddisplay_set_snap_to_grid(DDisplay *ddisp, gboolean snap) { GtkToggleAction *snap_to_grid; ddisp->grid.snap = snap; snap_to_grid = GTK_TOGGLE_ACTION (menus_get_action ("ViewSnaptogrid")); if (is_integrated_ui ()) integrated_ui_toolbar_grid_snap_synchronize_to_display (ddisp); /* Currently, this can cause double emit, but that's a small problem. */ gtk_toggle_action_set_active (snap_to_grid, ddisp->grid.snap); ddisplay_update_statusbar(ddisp); }
/** * @param ddisp The diagram display object that a window is created for * @param title */ static void use_integrated_ui_for_display_shell(DDisplay *ddisp, char *title) { GtkWidget *table; GtkWidget *label; /* Text label for the notebook page */ GtkWidget *tab_label_container; /* Container to hold text label & close button */ int width, height; /* Width/Heigth of the diagram */ GtkWidget *image; GtkWidget *close_button; /* Close button for the notebook page */ GtkRcStyle *rcstyle; gint notebook_page_index; ddisp->is_standalone_window = FALSE; ddisp->shell = GTK_WIDGET (ui.main_window); ddisp->modified_status = GTK_WIDGET (ui.statusbar); tab_label_container = gtk_hbox_new(FALSE,3); label = gtk_label_new( title ); gtk_box_pack_start( GTK_BOX(tab_label_container), label, FALSE, FALSE, 0 ); gtk_widget_show (label); /* Create a new tab page */ ddisp->container = gtk_vbox_new(FALSE, 0); /* <from GEdit> */ /* don't allow focus on the close button */ close_button = gtk_button_new(); gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE); gtk_button_set_focus_on_click (GTK_BUTTON (close_button), FALSE); /* make it as small as possible */ rcstyle = gtk_rc_style_new (); rcstyle->xthickness = rcstyle->ythickness = 0; gtk_widget_modify_style (close_button, rcstyle); g_object_unref (rcstyle), image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); gtk_container_add (GTK_CONTAINER(close_button), image); g_signal_connect (G_OBJECT (close_button), "clicked", G_CALLBACK (close_notebook_page_callback), ddisp->container); /* </from GEdit> */ gtk_box_pack_start( GTK_BOX(tab_label_container), close_button, FALSE, FALSE, 0 ); gtk_widget_show (close_button); gtk_widget_show (image); /* Set events for new tab page */ _ddisplay_setup_events (ddisp, ddisp->container); notebook_page_index = gtk_notebook_append_page (GTK_NOTEBOOK(ui.diagram_notebook), ddisp->container, tab_label_container); g_object_set_data (G_OBJECT (ddisp->container), "DDisplay", ddisp); g_object_set_data (G_OBJECT (ddisp->container), "tab-label", label); g_object_set_data (G_OBJECT (ddisp->container), "window", ui.main_window); /* the table containing all widgets */ table = gtk_table_new (3, 3, FALSE); gtk_table_set_col_spacing (GTK_TABLE (table), 0, 1); gtk_table_set_col_spacing (GTK_TABLE (table), 1, 2); gtk_table_set_row_spacing (GTK_TABLE (table), 0, 1); gtk_table_set_row_spacing (GTK_TABLE (table), 1, 2); gtk_container_set_border_width (GTK_CONTAINER (table), 2); gtk_box_pack_start( GTK_BOX(ddisp->container), table, TRUE, TRUE, 0 ); /* scrollbars, rulers, canvas, menu popup button */ ddisp->origin = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (ddisp->origin), GTK_SHADOW_OUT); _ddisplay_setup_rulers (ddisp, ddisp->container, table); /* Get the width/height of the Notebook child area */ /* TODO: Fix width/height hardcoded values */ width = 100; height = 100; _ddisplay_setup_scrollbars (ddisp, table, width, height); _ddisplay_setup_navigation (ddisp, table); ddisp->canvas = create_canvas (ddisp); /* place all remaining widgets */ gtk_table_attach (GTK_TABLE (table), ddisp->origin, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), ddisp->canvas, 1, 2, 1, 2, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); ddisp->common_toolbar = ui.toolbar; /* Stand-alone window menubar */ ddisp->menu_bar = NULL; /* Stand-alone window Zoom status/menu */ ddisp->zoom_status = NULL; /* Stand-alone window Grid on/off button */ ddisp->grid_status = NULL; /* Stand-alone window Object Snapping button */ ddisp->mainpoint_status = NULL; gtk_widget_show (ddisp->container); gtk_widget_show (table); display_rulers_show (ddisp); gtk_widget_show (ddisp->canvas); /* Show new page */ gtk_notebook_set_current_page (ui.diagram_notebook, notebook_page_index); integrated_ui_toolbar_grid_snap_synchronize_to_display (ddisp); integrated_ui_toolbar_object_snap_synchronize_to_display (ddisp); /* set the focus to the canvas area */ gtk_widget_grab_focus (ddisp->canvas); }