don't update min/max bounding box when drawing with CLEAR polarity
[geda-gerbv.git] / src / interface.c
blob2ac8e47cad607fa7d30c3dd46f94472b4b753285
1 /*
2 * gEDA - GNU Electronic Design Automation
3 * This file is a part of gerbv.
5 * Copyright (C) 2000-2003 Stefan Petersen (spe@stacken.kth.se)
7 * $Id$
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.s
14 * This program is distributed in the hope that it toowill be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
24 /** \file interface.c
25 \brief GUI building functions for Gerbv
26 \ingroup gerbv
29 #ifdef HAVE_CONFIG_H
30 # include <config.h>
31 #endif
33 #include <sys/types.h>
34 #include <sys/stat.h>
35 #include <unistd.h>
36 #include <string.h>
37 #include <stdio.h>
38 #include <math.h>
40 #include <gdk/gdkkeysyms.h>
41 #include <gtk/gtk.h>
43 #include "gerbv.h"
44 #include "main.h"
45 #include "callbacks.h"
46 #include "interface.h"
47 #include "render.h"
49 #include "draw-gdk.h"
50 #include "draw.h"
52 #include "gerbv_icon.h"
53 #include "icons.h"
54 extern gerbv_render_info_t screenRenderInfo;
56 #define WIN_TITLE "Gerbv -- gEDA's Gerber Viewer"
57 #define _(String) (String)
59 #define dprintf if(DEBUG) printf
61 /* ---------------------------------------------- */
62 void
63 rename_main_window(char const* filename, GtkWidget *main_win)
65 GString *win_title=g_string_new(NULL);
66 static GtkWidget *win=NULL;
68 if( main_win != NULL )
69 win = main_win;
71 g_assert(win != NULL);
73 g_string_printf (win_title,"%s version %s: %s", WIN_TITLE, VERSION, filename);
74 gtk_window_set_title(GTK_WINDOW(win), win_title->str);
75 g_string_free(win_title,TRUE);
78 /* ---------------------------------------------- */
79 void
80 set_window_icon (GtkWidget * this_window)
82 GdkPixmap *pixmap;
83 GdkBitmap *mask;
85 pixmap = gdk_pixmap_create_from_xpm_d (this_window->window, &mask,
86 &this_window->style->bg[GTK_STATE_NORMAL], gerbv_icon_xpm);
87 gdk_window_set_icon (this_window->window, NULL, pixmap, mask);
89 return;
92 /* ---------------------------------------------- */
93 void
94 interface_load_accels (void)
96 gchar *accel_map_filename = g_build_filename (g_get_home_dir(), GERBV_ACCELS_RELPATH, NULL);
97 if (accel_map_filename) {
98 gtk_accel_map_load (accel_map_filename);
99 g_free (accel_map_filename);
103 /* ---------------------------------------------- */
104 void
105 interface_save_accels (void)
107 gchar *accel_map_filename = g_build_filename (g_get_home_dir(), GERBV_ACCELS_RELPATH, NULL);
108 if (accel_map_filename) {
109 gtk_accel_map_save (accel_map_filename);
110 g_free (accel_map_filename);
114 /* ---------------------------------------------- */
115 void
116 interface_create_gui (int req_width, int req_height)
118 GtkStockItem stock;
120 GtkWidget *mainWindow;
121 GtkWidget *vbox1;
122 GtkWidget *menubar1;
124 GtkWidget *menuitem_file;
125 GtkWidget *menuitem_file_menu;
126 GtkWidget *new;
127 GtkWidget *open_project;
128 GtkWidget *image33;
129 GtkWidget *open_layer;
130 GtkWidget *revert;
131 GtkWidget *save;
132 GtkWidget *save_as;
133 GtkWidget *save_layer;
134 GtkWidget *save_as_layer;
135 GtkWidget *separatormenuitem1;
136 GtkWidget *menuitem_file_export;
137 GtkWidget *menuitem_file_export_menu;
138 GtkWidget *png;
139 GtkWidget *pdf;
140 GtkWidget *svg;
141 GtkWidget *postscript;
142 GtkWidget *rs274x,*drill,*rs274xm,*drillm;
144 GtkWidget *separator1;
145 #if GTK_CHECK_VERSION(2,10,0)
146 GtkWidget *print;
147 GtkWidget *separator2;
148 #endif
149 GtkWidget *quit;
151 GtkWidget *menuitem_edit;
152 GtkWidget *menuitem_edit_menu;
153 GtkWidget *properties_selected;
154 GtkWidget *delete_selected;
155 GtkWidget *menuitem_view;
156 GtkWidget *menuitem_view_menu;
157 GtkWidget *view_fullscreen;
158 GtkWidget *show_toolbar;
159 GtkWidget *show_sidepane;
160 GtkWidget *separator3;
161 GtkWidget *toggle_layer_visibility_item1;
162 GtkWidget *toggle_layer_visibility_item2;
163 GtkWidget *toggle_layer_visibility_item3;
164 GtkWidget *toggle_layer_visibility_item4;
165 GtkWidget *toggle_layer_visibility_item5;
166 GtkWidget *toggle_layer_visibility_item6;
167 GtkWidget *toggle_layer_visibility_item7;
168 GtkWidget *toggle_layer_visibility_item8;
169 GtkWidget *toggle_layer_visibility_item9;
170 GtkWidget *toggle_layer_visibility_item10;
171 GtkWidget *separator4;
172 GtkWidget *zoom_in;
173 GtkWidget *zoom_out;
174 GtkWidget *fit_to_window;
175 GtkWidget *separator5;
176 GtkWidget *backgroundColor;
177 GtkWidget *menuitem_view_render, *menuitem_view_render_menu;
178 GSList *menu_view_render_group;
179 GtkWidget *render_fast, *render_fast_xor, *render_normal, *render_hq;
180 GtkWidget *menuitem_view_unit, *menuitem_view_unit_menu;
181 GSList *menu_view_unit_group;
182 GtkWidget *unit_mil, *unit_mm, *unit_in;
183 GtkWidget *menuitem_layer;
184 GtkWidget *menuitem_layer_menu;
185 GtkWidget *layer_visibility;
186 GtkWidget *layer_invert;
187 GtkWidget *layer_color;
188 GtkWidget *layer_reload;
189 GtkWidget *layer_orientation;
190 GtkWidget *layer_format;
191 GtkWidget *layer_up;
192 GtkWidget *layer_down;
193 GtkWidget *layer_remove;
194 GtkWidget *menuitem_analyze;
195 GtkWidget *menuitem_analyze_menu;
196 GtkWidget *analyze_active_gerbers;
197 GtkWidget *analyze_active_drill;
198 GtkWidget *analyze_benchmark;
199 /*GtkWidget *control_gerber_options;*/
200 GtkWidget *menuitem_tools;
201 GtkWidget *menuitem_tools_menu;
202 GtkWidget *toggletoolbutton_pointer;
203 GtkWidget *pointer_tool;
204 GdkPixbuf *pointerpixbuf;
205 GtkWidget *pointerimage;
206 GtkWidget *pan_tool;
207 GtkWidget *zoom_tool;
208 GtkWidget *measure_tool;
209 GtkWidget *menuitem_help;
210 GtkWidget *layer_visibility_menu;
211 GtkWidget *layer_visibility_main_menu;
212 GtkWidget *menuitem_help_menu;
213 /*GtkWidget *online_manual;*/
214 GtkWidget *about;
215 GtkWidget *bugs_menuitem;
216 GtkWidget *image34;
217 GtkWidget *toolbar_hbox;
218 GtkWidget *handlebox;
219 GtkWidget *button_toolbar;
220 /*GtkIconSize tmp_toolbar_icon_size;*/
221 GtkWidget *toolbutton_new;
222 GtkWidget *toolbutton_open;
223 GtkWidget *toolbutton_revert;
224 GtkWidget *toolbutton_save;
225 GtkWidget *separatortoolitem1;
226 #if GTK_CHECK_VERSION(2,10,0)
227 GtkWidget *toolbutton_print;
228 GtkWidget *separatortoolitem2;
229 #endif
230 GtkWidget *toolbutton_zoom_in;
231 GtkWidget *toolbutton_zoom_out;
232 GtkWidget *toolbutton_zoom_fit;
233 /* Implement these tool buttons later when we have icons */
234 /* GtkWidget *separatortoolitem3; */
235 /* GtkWidget *toolbutton_analyze; */
236 /* GtkWidget *toolbutton_validate;*/
237 /* GtkWidget *toolbutton_control; */
238 GtkWidget *separatortoolitem4;
239 GtkWidget *toggletoolbutton_pan;
240 GtkWidget *toggletoolbutton_zoom;
241 GtkWidget *toggletoolbutton_measure;
242 GtkWidget *hpaned1;
243 GtkWidget *sidepane_vbox;
244 GtkWidget *sidepane_notebook;
245 GtkWidget *vbox10;
246 GtkWidget *hbox4;
247 GtkWidget *label1;
248 GtkWidget *render_combobox;
249 GtkWidget *scrolledwindow1;
250 GtkWidget *hbox1;
251 GtkWidget *button4;
252 GtkWidget *image8;
253 GtkWidget *button5;
254 GtkWidget *image9;
255 GtkWidget *button6;
256 GtkWidget *image10;
257 GtkWidget *button7;
258 GtkWidget *image11;
259 GtkWidget *Layer_label;
260 GtkWidget *vbox11;
261 GtkWidget *messages_scrolledwindow;
262 GtkWidget *message_textview;
263 GtkWidget *clear_messages_button;
264 GtkWidget *Message_label;
265 GtkWidget *vbox2;
266 GtkWidget *main_view_table;
267 GtkWidget *hRuler;
268 GtkWidget *vRuler;
269 GtkWidget *hbox5;
270 GtkWidget *statusbar_label_left;
271 GtkWidget *statusUnitComboBox;
272 GtkWidget *statusbar_label_right;
273 GtkWidget *drawingarea, *hAdjustment, *vAdjustment, *hScrollbar, *vScrollbar;
275 GtkAccelGroup *accel_group;
276 GtkTooltips *tooltips;
278 /* Inline icons */
279 GdkPixbuf *zoompixbuf;
280 GtkWidget *zoomimage;
281 GdkPixbuf *measurepixbuf;
282 GtkWidget *measureimage;
283 GdkPixbuf *movepixbuf;
284 GtkWidget *moveimage;
286 GtkWidget *tempImage;
288 pointerpixbuf = gdk_pixbuf_new_from_inline(-1, pointer, FALSE, NULL);
289 movepixbuf = gdk_pixbuf_new_from_inline(-1, move, FALSE, NULL);
290 zoompixbuf = gdk_pixbuf_new_from_inline(-1, lzoom, FALSE, NULL);
291 measurepixbuf = gdk_pixbuf_new_from_inline(-1, ruler, FALSE, NULL);
293 tooltips = gtk_tooltips_new();
294 accel_group = gtk_accel_group_new ();
296 mainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
297 gtk_window_set_title (GTK_WINDOW (mainWindow), _(WIN_TITLE));
299 vbox1 = gtk_vbox_new (FALSE, 0);
300 gtk_container_add (GTK_CONTAINER (mainWindow), vbox1);
302 menubar1 = gtk_menu_bar_new ();
303 gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0);
305 /* --- File menu --- */
306 menuitem_file = gtk_menu_item_new_with_mnemonic (_("_File"));
307 gtk_container_add (GTK_CONTAINER (menubar1), menuitem_file);
309 /* File menu items dealing with a gerbv project. */
310 menuitem_file_menu = gtk_menu_new ();
311 gtk_menu_set_accel_group (GTK_MENU(menuitem_file_menu), accel_group);
312 gtk_menu_set_accel_path (GTK_MENU(menuitem_file_menu), ACCEL_FILE);
313 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_file), menuitem_file_menu);
315 new = gtk_image_menu_item_new_from_stock (GTK_STOCK_NEW, NULL);
316 SET_ACCELS_FROM_STOCK (GTK_STOCK_NEW, ACCEL_FILE_NEW);
317 gtk_tooltips_set_tip (tooltips, new, "Close all layers and start a new project", NULL);
318 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), new);
320 open_project = gtk_image_menu_item_new_with_mnemonic (_("_Open project..."));
321 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), open_project);
322 gtk_tooltips_set_tip (tooltips, open_project, "Open an existing Gerbv project", NULL);
323 image33 = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
324 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (open_project), image33);
326 save = gtk_image_menu_item_new_with_mnemonic (_("Save project"));
327 screen.win.curFileMenuItem1 = save;
328 gtk_tooltips_set_tip (tooltips, save, "Save the current project", NULL);
329 tempImage = gtk_image_new_from_stock (GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU);
330 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (save), tempImage);
331 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), save);
333 save_as = gtk_image_menu_item_new_with_mnemonic (_("Save project as..."));
334 screen.win.curFileMenuItem2 = save_as;
335 gtk_tooltips_set_tip (tooltips, save_as, "Save the current project to a new file", NULL);
336 tempImage = gtk_image_new_from_stock (GTK_STOCK_SAVE_AS, GTK_ICON_SIZE_MENU);
337 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (save_as), tempImage);
338 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), save_as);
340 revert = gtk_image_menu_item_new_from_stock (GTK_STOCK_REVERT_TO_SAVED, NULL);
341 screen.win.curFileMenuItem3 = revert;
342 SET_ACCELS_FROM_STOCK (GTK_STOCK_REVERT_TO_SAVED, ACCEL_FILE_REVERT);
343 gtk_tooltips_set_tip (tooltips, revert, "Reload all layers", NULL);
344 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), revert);
346 /* File menu items dealing individual layers. */
347 separator1 = gtk_separator_menu_item_new ();
348 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), separator1);
349 gtk_widget_set_sensitive (separator1, FALSE);
351 open_layer = gtk_menu_item_new_with_mnemonic (_("Open _layer(s)..."));
352 gtk_accel_map_add_entry (ACCEL_FILE_OPEN_LAYER_PATH, ACCEL_FILE_OPEN_LAYER_KEY, ACCEL_FILE_OPEN_LAYER_MOD);
353 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), open_layer);
354 gtk_tooltips_set_tip (tooltips, open_layer, "Open Gerber, drill, or pick and place file(s)", NULL);
356 save_layer = gtk_menu_item_new_with_mnemonic (_("_Save active layer"));
357 screen.win.curFileMenuItem4 = save_layer;
358 gtk_tooltips_set_tip (tooltips, save_layer, "Save the active layer", NULL);
359 gtk_accel_map_add_entry (ACCEL_FILE_SAVE_LAYER_PATH, ACCEL_FILE_SAVE_LAYER_KEY, ACCEL_FILE_SAVE_LAYER_MOD);
360 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), save_layer);
362 save_as_layer = gtk_menu_item_new_with_mnemonic (_("Save active layer _as..."));
363 screen.win.curFileMenuItem5 = save_as_layer;
364 gtk_tooltips_set_tip (tooltips, save_as_layer, "Save the active layer to a new file", NULL);
365 gtk_accel_map_add_entry (ACCEL_FILE_SAVE_LAYER_AS_PATH, ACCEL_FILE_SAVE_LAYER_AS_KEY, ACCEL_FILE_SAVE_LAYER_AS_MOD);
366 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), save_as_layer);
368 /* File menu items dealing with exporting different types of files. */
369 separatormenuitem1 = gtk_separator_menu_item_new ();
370 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), separatormenuitem1);
371 gtk_widget_set_sensitive (separatormenuitem1, FALSE);
373 menuitem_file_export = gtk_menu_item_new_with_mnemonic (_("_Export"));
374 screen.win.curFileMenuItem6 = menuitem_file_export;
375 gtk_tooltips_set_tip (tooltips, menuitem_file_export, "Export all visible layers to a new format", NULL);
376 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), menuitem_file_export);
378 menuitem_file_export_menu = gtk_menu_new ();
379 gtk_menu_set_accel_group (GTK_MENU(menuitem_file_export_menu), accel_group);
380 gtk_menu_set_accel_path (GTK_MENU(menuitem_file_export_menu), ACCEL_FILE_EXPORT);
381 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_file_export), menuitem_file_export_menu);
383 png = gtk_menu_item_new_with_mnemonic (_("P_NG..."));
384 gtk_container_add (GTK_CONTAINER (menuitem_file_export_menu), png);
385 gtk_tooltips_set_tip (tooltips, png, _("Export project to a PNG file..."), NULL);
387 pdf = gtk_menu_item_new_with_mnemonic (_("P_DF..."));
388 gtk_container_add (GTK_CONTAINER (menuitem_file_export_menu), pdf);
389 gtk_tooltips_set_tip (tooltips, pdf, _("Export project to a PDF file..."), NULL);
391 svg = gtk_menu_item_new_with_mnemonic (_("_SVG..."));
392 gtk_container_add (GTK_CONTAINER (menuitem_file_export_menu), svg);
393 gtk_tooltips_set_tip (tooltips, svg, _("Export project to a SVG file"), NULL);
395 postscript = gtk_menu_item_new_with_mnemonic (_("_PostScript..."));
396 gtk_container_add (GTK_CONTAINER (menuitem_file_export_menu), postscript);
397 gtk_tooltips_set_tip (tooltips, postscript, _("Export project to a PostScript file"), NULL);
399 rs274x = gtk_menu_item_new_with_mnemonic (_("RS-274X (_Gerber)..."));
400 gtk_container_add (GTK_CONTAINER (menuitem_file_export_menu), rs274x);
401 gtk_tooltips_set_tip (tooltips, rs274x, _("Export layer to a RS-274X (Gerber) file"), NULL);
403 drill = gtk_menu_item_new_with_mnemonic (_("_Excellon drill..."));
404 gtk_container_add (GTK_CONTAINER (menuitem_file_export_menu), drill);
405 gtk_tooltips_set_tip (tooltips, drill, _("Export layer to an Excellon drill file"), NULL);
407 rs274xm = gtk_menu_item_new_with_mnemonic (_("RS-274X Merge (Gerber)..."));
408 gtk_container_add (GTK_CONTAINER (menuitem_file_export_menu), rs274xm);
409 gtk_tooltips_set_tip (tooltips, rs274xm, _("Export (merge visible gerber layers) to a RS-274X (Gerber) file"), NULL);
411 drillm = gtk_menu_item_new_with_mnemonic (_("Excellon drill Merge..."));
412 gtk_container_add (GTK_CONTAINER (menuitem_file_export_menu), drillm);
413 gtk_tooltips_set_tip (tooltips, drillm, _("Export (merge visible drill layers) to an Excellon drill file"), NULL);
415 /* File menu items dealing with printing and quitting. */
416 separator1 = gtk_separator_menu_item_new ();
417 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), separator1);
418 gtk_widget_set_sensitive (separator1, FALSE);
420 #if GTK_CHECK_VERSION(2,10,0)
421 if (gtk_stock_lookup(GTK_STOCK_PRINT, &stock)) {
422 gchar new[] = "_Print...";
423 stock.label = new;
424 gtk_stock_add(&stock, 1);
427 print = gtk_image_menu_item_new_from_stock (GTK_STOCK_PRINT, NULL);
428 screen.win.curFileMenuItem7 = print;
429 SET_ACCELS_FROM_STOCK (GTK_STOCK_PRINT, ACCEL_FILE_PRINT);
430 gtk_tooltips_set_tip (tooltips, print, "Print the visible layers", NULL);
431 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), print);
433 separator2 = gtk_separator_menu_item_new ();
434 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), separator2);
435 gtk_widget_set_sensitive (separator2, FALSE);
436 #endif
437 quit = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
438 SET_ACCELS_FROM_STOCK (GTK_STOCK_QUIT, ACCEL_FILE_QUIT);
439 gtk_tooltips_set_tip (tooltips, quit, "Quit Gerbv", NULL);
440 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), quit);
442 /* --- Next menu item (Edit) --- */
443 menuitem_edit = gtk_menu_item_new_with_mnemonic (_("_Edit"));
444 screen.win.curEditMenuItem = menuitem_edit;
445 gtk_container_add (GTK_CONTAINER (menubar1), menuitem_edit);
447 menuitem_edit_menu = gtk_menu_new ();
448 gtk_menu_set_accel_group (GTK_MENU(menuitem_edit_menu), accel_group);
449 gtk_menu_set_accel_path (GTK_MENU(menuitem_edit_menu), ACCEL_EDIT);
450 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_edit), menuitem_edit_menu);
452 properties_selected = gtk_image_menu_item_new_with_mnemonic (_("Display _properties of selected object(s)"));
453 SET_ACCELS_FROM_STOCK (GTK_STOCK_PROPERTIES, ACCEL_EDIT_PROPERTIES);
454 gtk_tooltips_set_tip (tooltips, properties_selected, "Examine the properties of the selected object", NULL);
455 tempImage = gtk_image_new_from_stock (GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_MENU);
456 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (properties_selected), tempImage);
457 gtk_container_add (GTK_CONTAINER (menuitem_edit_menu), properties_selected);
459 delete_selected = gtk_image_menu_item_new_with_mnemonic (_("_Delete selected object(s)"));
460 SET_ACCELS_FROM_STOCK (GTK_STOCK_REMOVE, ACCEL_EDIT_DELETE);
461 gtk_tooltips_set_tip (tooltips, delete_selected, "Delete selected objects", NULL);
462 tempImage = gtk_image_new_from_stock (GTK_STOCK_DELETE, GTK_ICON_SIZE_MENU);
463 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (delete_selected), tempImage);
464 gtk_container_add (GTK_CONTAINER (menuitem_edit_menu), delete_selected);
466 /* Include these after they are coded.
467 tempMenuItem = gtk_image_menu_item_new_with_label ("Edit object properties");
468 gtk_menu_shell_append ((GtkMenuShell *)screen.win.drawWindowPopupMenu, tempMenuItem);
469 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Edit the properties of the selected object", NULL);
470 g_signal_connect ((gpointer) tempMenuItem, "activate",
471 G_CALLBACK (callbacks_edit_object_properties_clicked), NULL);
473 tempMenuItem = gtk_image_menu_item_new_with_label ("Move object(s)");
474 gtk_menu_shell_append ((GtkMenuShell *)screen.win.drawWindowPopupMenu, tempMenuItem);
475 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Move the selected object(s)",NULL);
476 g_signal_connect ((gpointer) tempMenuItem, "activate",
477 G_CALLBACK (callbacks_move_objects_clicked), NULL);
479 tempMenuItem = gtk_image_menu_item_new_with_label ("Reduce area");
480 gtk_menu_shell_append ((GtkMenuShell *)screen.win.drawWindowPopupMenu, tempMenuItem);
481 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Reduce the area of the object (e.g. to prevent component floating)",NULL);
482 g_signal_connect ((gpointer) tempMenuItem, "activate",
483 G_CALLBACK (callbacks_reduce_object_area_clicked), NULL);
486 /* Use the "Edit" menu as right click popup menu for the drawing area */
487 screen.win.drawWindowPopupMenu = menuitem_edit_menu;
489 /* --- Next menu item (View) --- */
490 menuitem_view = gtk_menu_item_new_with_mnemonic (_("_View"));
491 gtk_container_add (GTK_CONTAINER (menubar1), menuitem_view);
493 menuitem_view_menu = gtk_menu_new ();
494 gtk_menu_set_accel_group (GTK_MENU(menuitem_view_menu), accel_group);
495 gtk_menu_set_accel_path (GTK_MENU(menuitem_view_menu), ACCEL_VIEW);
496 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_view), menuitem_view_menu);
498 view_fullscreen = gtk_check_menu_item_new_with_mnemonic (_("Fullscr_een"));
499 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (view_fullscreen), FALSE);
500 gtk_tooltips_set_tip (tooltips, view_fullscreen, "Toggle between fullscreen and normal view", NULL);
501 SET_ACCELS (ACCEL_VIEW_FULLSCREEN);
502 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), view_fullscreen);
504 show_toolbar = gtk_check_menu_item_new_with_mnemonic (_("Show _Toolbar"));
505 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_toolbar), TRUE);
506 gtk_tooltips_set_tip (tooltips, show_toolbar, "Toggle visibility of the toolbar", NULL);
507 SET_ACCELS (ACCEL_VIEW_TOOLBAR);
508 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), show_toolbar);
510 show_sidepane = gtk_check_menu_item_new_with_mnemonic (_("Show _Sidepane"));
511 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_sidepane), TRUE);
512 gtk_tooltips_set_tip (tooltips, show_sidepane, "Toggle visibility of the sidepane", NULL);
513 SET_ACCELS (ACCEL_VIEW_SIDEPANE);
514 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), show_sidepane);
516 separator3 = gtk_separator_menu_item_new ();
517 gtk_widget_set_sensitive (separator3, FALSE);
518 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), separator3);
520 layer_visibility_main_menu = gtk_menu_item_new_with_mnemonic (_("Toggle layer _visibility"));
521 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), layer_visibility_main_menu);
523 layer_visibility_menu = gtk_menu_new ();
524 gtk_menu_set_accel_group (GTK_MENU(layer_visibility_menu), accel_group);
525 gtk_menu_set_accel_path (GTK_MENU(layer_visibility_menu), ACCEL_VIEW_VIS);
526 gtk_menu_item_set_submenu (GTK_MENU_ITEM (layer_visibility_main_menu), layer_visibility_menu);
528 toggle_layer_visibility_item1 = gtk_menu_item_new_with_label ("Toggle visibility of layer 1");
529 SET_ACCELS (ACCEL_VIEW_VIS_LAYER1);
530 gtk_container_add (GTK_CONTAINER (layer_visibility_menu), toggle_layer_visibility_item1);
532 toggle_layer_visibility_item2 = gtk_menu_item_new_with_label ("Toggle visibility of layer 2");
533 SET_ACCELS (ACCEL_VIEW_VIS_LAYER2);
534 gtk_container_add (GTK_CONTAINER (layer_visibility_menu), toggle_layer_visibility_item2);
536 toggle_layer_visibility_item3 = gtk_menu_item_new_with_label ("Toggle visibility of layer 3");
537 SET_ACCELS (ACCEL_VIEW_VIS_LAYER3);
538 gtk_container_add (GTK_CONTAINER (layer_visibility_menu), toggle_layer_visibility_item3);
540 toggle_layer_visibility_item4 = gtk_menu_item_new_with_label ("Toggle visibility of layer 4");
541 SET_ACCELS (ACCEL_VIEW_VIS_LAYER4);
542 gtk_container_add (GTK_CONTAINER (layer_visibility_menu), toggle_layer_visibility_item4);
544 toggle_layer_visibility_item5 = gtk_menu_item_new_with_label ("Toggle visibility of layer 5");
545 SET_ACCELS (ACCEL_VIEW_VIS_LAYER5);
546 gtk_container_add (GTK_CONTAINER (layer_visibility_menu), toggle_layer_visibility_item5);
548 toggle_layer_visibility_item6 = gtk_menu_item_new_with_label ("Toggle visibility of layer 6");
549 SET_ACCELS (ACCEL_VIEW_VIS_LAYER6);
550 gtk_container_add (GTK_CONTAINER (layer_visibility_menu), toggle_layer_visibility_item6);
552 toggle_layer_visibility_item7 = gtk_menu_item_new_with_label ("Toggle visibility of layer 7");
553 SET_ACCELS (ACCEL_VIEW_VIS_LAYER7);
554 gtk_container_add (GTK_CONTAINER (layer_visibility_menu), toggle_layer_visibility_item7);
556 toggle_layer_visibility_item8 = gtk_menu_item_new_with_label ("Toggle visibility of layer 8");
557 SET_ACCELS (ACCEL_VIEW_VIS_LAYER8);
558 gtk_container_add (GTK_CONTAINER (layer_visibility_menu), toggle_layer_visibility_item8);
560 toggle_layer_visibility_item9 = gtk_menu_item_new_with_label ("Toggle visibility of layer 9");
561 SET_ACCELS (ACCEL_VIEW_VIS_LAYER9);
562 gtk_container_add (GTK_CONTAINER (layer_visibility_menu), toggle_layer_visibility_item9);
564 toggle_layer_visibility_item10 = gtk_menu_item_new_with_label ("Toggle visibility of layer 10");
565 SET_ACCELS (ACCEL_VIEW_VIS_LAYER10);
566 gtk_container_add (GTK_CONTAINER (layer_visibility_menu), toggle_layer_visibility_item10);
568 separator4 = gtk_separator_menu_item_new ();
569 gtk_widget_set_sensitive (separator4, FALSE);
570 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), separator4);
572 zoom_in = gtk_image_menu_item_new_from_stock (GTK_STOCK_ZOOM_IN, NULL);
573 SET_ACCELS_FROM_STOCK (GTK_STOCK_ZOOM_IN, ACCEL_VIEW_ZOOM_IN);
574 gtk_tooltips_set_tip (tooltips, zoom_in, "Zoom in", NULL);
575 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), zoom_in);
577 zoom_out = gtk_image_menu_item_new_from_stock (GTK_STOCK_ZOOM_OUT, NULL);
578 SET_ACCELS_FROM_STOCK (GTK_STOCK_ZOOM_OUT, ACCEL_VIEW_ZOOM_OUT);
579 gtk_tooltips_set_tip (tooltips, zoom_out, "Zoom out", NULL);
580 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), zoom_out);
582 fit_to_window = gtk_image_menu_item_new_from_stock (GTK_STOCK_ZOOM_FIT, NULL);
583 gtk_tooltips_set_tip (tooltips, fit_to_window, "Zoom to fit all visible layers in the window", NULL);
584 SET_ACCELS_FROM_STOCK (GTK_STOCK_ZOOM_FIT, ACCEL_VIEW_ZOOM_FIT);
585 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), fit_to_window);
587 separator5 = gtk_separator_menu_item_new ();
588 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), separator5);
589 gtk_widget_set_sensitive (separator5, FALSE);
591 backgroundColor = gtk_menu_item_new_with_mnemonic ("Change background color");
592 gtk_tooltips_set_tip (tooltips, backgroundColor, "Change the background color", NULL);
593 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), backgroundColor);
595 { // rendering submenu
596 menuitem_view_render = gtk_menu_item_new_with_mnemonic (_("_Rendering"));
597 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), menuitem_view_render);
599 menuitem_view_render_menu = gtk_menu_new ();
600 gtk_menu_set_accel_group (GTK_MENU(menuitem_view_render_menu), accel_group);
601 gtk_menu_set_accel_path (GTK_MENU(menuitem_view_render_menu), ACCEL_VIEW_RENDER);
602 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_view_render), menuitem_view_render_menu);
604 menu_view_render_group = NULL;
606 render_fast = gtk_radio_menu_item_new_with_mnemonic (menu_view_render_group, _("_Fast"));
607 menu_view_render_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (render_fast));
608 gtk_container_add (GTK_CONTAINER (menuitem_view_render_menu), render_fast);
610 render_fast_xor = gtk_radio_menu_item_new_with_mnemonic (menu_view_render_group, _("Fast (_XOR)"));
611 menu_view_render_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (render_fast_xor));
612 gtk_container_add (GTK_CONTAINER (menuitem_view_render_menu), render_fast_xor);
614 render_normal = gtk_radio_menu_item_new_with_mnemonic (menu_view_render_group, _("_Normal"));
615 menu_view_render_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (render_normal));
616 gtk_container_add (GTK_CONTAINER (menuitem_view_render_menu), render_normal);
618 render_hq = gtk_radio_menu_item_new_with_mnemonic (menu_view_render_group, _("High _Quality"));
619 menu_view_render_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (render_hq));
620 gtk_container_add (GTK_CONTAINER (menuitem_view_render_menu), render_hq);
622 screen.win.menu_view_render_group = malloc(4*sizeof(GtkWidget *));
623 if(screen.win.menu_view_render_group == NULL)
624 GERB_FATAL_ERROR("malloc for rendering type synchronization failed.\n");
626 screen.win.menu_view_render_group[GERBV_RENDER_TYPE_GDK] = GTK_CHECK_MENU_ITEM(render_fast);
627 screen.win.menu_view_render_group[GERBV_RENDER_TYPE_GDK_XOR] = GTK_CHECK_MENU_ITEM(render_fast_xor);
628 screen.win.menu_view_render_group[GERBV_RENDER_TYPE_CAIRO_NORMAL] = GTK_CHECK_MENU_ITEM(render_normal);
629 screen.win.menu_view_render_group[GERBV_RENDER_TYPE_CAIRO_HIGH_QUALITY] = GTK_CHECK_MENU_ITEM(render_hq);
632 { // units submenu
633 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (render_fast), TRUE);
635 menuitem_view_unit = gtk_menu_item_new_with_mnemonic (_("U_nits"));
636 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), menuitem_view_unit);
638 menuitem_view_unit_menu = gtk_menu_new ();
639 gtk_menu_set_accel_group (GTK_MENU(menuitem_view_unit_menu), accel_group);
640 gtk_menu_set_accel_path (GTK_MENU(menuitem_view_unit_menu), ACCEL_VIEW_UNITS);
641 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_view_unit), menuitem_view_unit_menu);
643 menu_view_unit_group = NULL;
645 unit_mil = gtk_radio_menu_item_new_with_mnemonic (menu_view_unit_group, _("mi_l"));
646 menu_view_unit_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (unit_mil));
647 gtk_container_add (GTK_CONTAINER (menuitem_view_unit_menu), unit_mil);
649 unit_mm = gtk_radio_menu_item_new_with_mnemonic (menu_view_unit_group, _("_mm"));
650 menu_view_unit_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (unit_mm));
651 gtk_container_add (GTK_CONTAINER (menuitem_view_unit_menu), unit_mm);
653 unit_in = gtk_radio_menu_item_new_with_mnemonic (menu_view_unit_group, _("_in"));
654 menu_view_unit_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (unit_in));
655 gtk_container_add (GTK_CONTAINER (menuitem_view_unit_menu), unit_in);
657 screen.win.menu_view_unit_group = malloc(3*sizeof(GtkWidget *));
658 if(screen.win.menu_view_unit_group == NULL)
659 GERB_FATAL_ERROR("malloc for display unit synchronization failed.\n");
661 screen.win.menu_view_unit_group[GERBV_MILS] = GTK_CHECK_MENU_ITEM(unit_mil);
662 screen.win.menu_view_unit_group[GERBV_MMS] = GTK_CHECK_MENU_ITEM(unit_mm);
663 screen.win.menu_view_unit_group[GERBV_INS] = GTK_CHECK_MENU_ITEM(unit_in);
666 /* --- Next menu item (Current Layer) --- */
667 menuitem_layer = gtk_menu_item_new_with_mnemonic (_("_Layer"));
668 gtk_container_add (GTK_CONTAINER (menubar1), menuitem_layer);
670 menuitem_layer_menu = gtk_menu_new ();
671 gtk_menu_set_accel_group (GTK_MENU (menuitem_layer_menu), accel_group);
672 gtk_menu_set_accel_path (GTK_MENU (menuitem_layer_menu), ACCEL_LAYER);
673 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_layer), menuitem_layer_menu);
675 layer_visibility = gtk_menu_item_new_with_mnemonic ("Toggle _visibility");
676 gtk_tooltips_set_tip (tooltips, layer_visibility, "Toggles the visibility of the layer currently selected in the sidepane", NULL);
677 gtk_container_add (GTK_CONTAINER (menuitem_layer_menu), layer_visibility);
679 layer_invert = gtk_menu_item_new_with_mnemonic ("_Invert color");
680 gtk_tooltips_set_tip (tooltips, layer_invert, "Invert the display polarity of the layer currently selected in the sidepane", NULL);
681 gtk_container_add (GTK_CONTAINER (menuitem_layer_menu), layer_invert);
683 layer_color = gtk_menu_item_new_with_mnemonic (_("_Change color"));
684 SET_ACCELS (ACCEL_LAYER_COLOR);
685 gtk_tooltips_set_tip (tooltips, layer_color, "Change the display color of the layer currently selected in the sidepane", NULL);
686 gtk_container_add (GTK_CONTAINER (menuitem_layer_menu), layer_color);
688 layer_reload = gtk_menu_item_new_with_mnemonic (_("_Reload layer"));
689 gtk_tooltips_set_tip (tooltips, layer_reload, "Reload the layer from disk", NULL);
690 gtk_container_add (GTK_CONTAINER (menuitem_layer_menu), layer_reload);
692 layer_orientation = gtk_menu_item_new_with_mnemonic (_("Modify _orientation"));
693 gtk_container_add (GTK_CONTAINER (menuitem_layer_menu), layer_orientation);
694 gtk_tooltips_set_tip (tooltips, layer_orientation, "Translate, scale, rotate, or mirror the layer currently selected in the sidepane", NULL);
696 layer_format = gtk_menu_item_new_with_mnemonic (_("Edit file _format"));
697 gtk_container_add (GTK_CONTAINER (menuitem_layer_menu), layer_format);
698 gtk_tooltips_set_tip (tooltips, layer_format, "View and edit the numerical format used to parse this layer currently selected in the sidepane", NULL);
700 layer_up = gtk_image_menu_item_new_with_mnemonic (_("Move u_p"));
701 gtk_tooltips_set_tip (tooltips, layer_up, "Move the layer currently selected in the sidepane one step up", NULL);
702 tempImage = gtk_image_new_from_stock (GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU);
703 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (layer_up), tempImage);
704 SET_ACCELS (ACCEL_LAYER_UP);
705 gtk_container_add (GTK_CONTAINER (menuitem_layer_menu), layer_up);
707 layer_down = gtk_image_menu_item_new_with_mnemonic (_("Move dow_n"));
708 gtk_tooltips_set_tip (tooltips, layer_down, "Move the layer currently selected in the sidepane one step down", NULL);
709 tempImage = gtk_image_new_from_stock (GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_MENU);
710 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (layer_down), tempImage);
711 SET_ACCELS (ACCEL_LAYER_DOWN);
712 gtk_container_add (GTK_CONTAINER (menuitem_layer_menu), layer_down);
714 layer_remove = gtk_image_menu_item_new_with_mnemonic (_("_Delete"));
715 gtk_container_add (GTK_CONTAINER (menuitem_layer_menu), layer_remove);
716 gtk_tooltips_set_tip (tooltips, layer_remove, "Remove the layer currently selected in the sidepane", NULL);
717 tempImage = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU);
718 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (layer_remove), tempImage);
720 /* The callbacks need this reference to grey the layer menu out, if there are none loaded. */
721 screen.win.curLayerMenuItem = menuitem_layer;
723 /* Use the "Current Layer" menu as right click popup menu for layer tree */
724 screen.win.layerTreePopupMenu = menuitem_layer_menu;
726 /* --- Next menu item (Analyze) --- */
727 menuitem_analyze = gtk_menu_item_new_with_mnemonic (_("_Analyze"));
728 screen.win.curAnalyzeMenuItem = menuitem_analyze;
729 gtk_container_add (GTK_CONTAINER (menubar1), menuitem_analyze);
731 menuitem_analyze_menu = gtk_menu_new ();
732 gtk_menu_set_accel_group (GTK_MENU(menuitem_analyze_menu), accel_group);
733 gtk_menu_set_accel_path (GTK_MENU(menuitem_analyze_menu), ACCEL_ANAL);
734 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_analyze), menuitem_analyze_menu);
736 analyze_active_gerbers = gtk_menu_item_new_with_mnemonic (_("Analyze visible _Gerber layers"));
737 gtk_tooltips_set_tip (tooltips, analyze_active_gerbers,
738 "Examine a detailed anaylsis of the contents of all visible Gerber layers", NULL);
739 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu), analyze_active_gerbers);
741 analyze_active_drill = gtk_menu_item_new_with_mnemonic (_("Analyze visible _drill layers"));
742 gtk_tooltips_set_tip (tooltips, analyze_active_drill,
743 "Examine a detailed anaylsis of the contents of all visible drill layers", NULL);
744 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu), analyze_active_drill);
746 analyze_benchmark = gtk_menu_item_new_with_mnemonic (_("_Benchmark (1 min)"));
747 gtk_tooltips_set_tip (tooltips, analyze_benchmark,
748 "Benchmark different rendering methods. Will make the application unresponsive for 1 minute!", NULL);
749 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu), analyze_benchmark);
752 /* Wait and add in for 2.1??
753 control_gerber_options = gtk_menu_item_new_with_mnemonic (_("Control Gerber options..."));
754 gtk_tooltips_set_tip (tooltips, control_gerber_options, "Set which Gerber features should be displayed", NULL);
755 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu), control_gerber_options);
757 menuitem_tools = gtk_menu_item_new_with_mnemonic (_("_Tools"));
758 gtk_container_add (GTK_CONTAINER (menubar1), menuitem_tools);
760 menuitem_tools_menu = gtk_menu_new ();
761 gtk_menu_set_accel_group (GTK_MENU(menuitem_tools_menu), accel_group);
762 gtk_menu_set_accel_path (GTK_MENU(menuitem_tools_menu), ACCEL_TOOLS);
763 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_tools), menuitem_tools_menu);
764 pointer_tool = gtk_image_menu_item_new_with_mnemonic (_("_Pointer Tool"));
766 GtkWidget *tempImage = gtk_image_new_from_pixbuf (pointerpixbuf);
767 gtk_image_menu_item_set_image ((GtkImageMenuItem *)pointer_tool, tempImage);
769 SET_ACCELS (ACCEL_TOOLS_POINTER);
770 gtk_container_add (GTK_CONTAINER (menuitem_tools_menu), pointer_tool);
771 gtk_tooltips_set_tip (tooltips, pointer_tool, "Select objects on the screen", NULL);
772 pan_tool = gtk_image_menu_item_new_with_mnemonic ("Pa_n Tool");
774 tempImage = gtk_image_new_from_pixbuf (movepixbuf);
775 gtk_image_menu_item_set_image ((GtkImageMenuItem *)pan_tool, tempImage);
777 SET_ACCELS (ACCEL_TOOLS_PAN);
778 gtk_container_add (GTK_CONTAINER (menuitem_tools_menu), pan_tool);
779 gtk_tooltips_set_tip (tooltips, pan_tool, "Pan by left clicking and dragging", NULL);
781 zoom_tool = gtk_image_menu_item_new_with_mnemonic (_("_Zoom Tool"));
783 tempImage = gtk_image_new_from_pixbuf (zoompixbuf);
784 gtk_image_menu_item_set_image ((GtkImageMenuItem *)zoom_tool, tempImage);
786 SET_ACCELS (ACCEL_TOOLS_ZOOM);
787 gtk_container_add (GTK_CONTAINER (menuitem_tools_menu), zoom_tool);
788 gtk_tooltips_set_tip (tooltips, zoom_tool, "Zoom by left clicking or dragging", NULL);
790 measure_tool = gtk_image_menu_item_new_with_mnemonic (_("_Measure Tool"));
792 tempImage = gtk_image_new_from_pixbuf (measurepixbuf);
793 gtk_image_menu_item_set_image ((GtkImageMenuItem *)measure_tool, tempImage);
795 SET_ACCELS (ACCEL_TOOLS_MEASURE);
796 gtk_container_add (GTK_CONTAINER (menuitem_tools_menu), measure_tool);
797 gtk_tooltips_set_tip (tooltips, measure_tool, "Measure distances on the screen", NULL);
799 menuitem_help = gtk_menu_item_new_with_mnemonic (_("_Help"));
800 gtk_container_add (GTK_CONTAINER (menubar1), menuitem_help);
802 menuitem_help_menu = gtk_menu_new ();
803 gtk_menu_set_accel_group (GTK_MENU(menuitem_help_menu), accel_group);
804 gtk_menu_set_accel_path (GTK_MENU(menuitem_help_menu), ACCEL_HELP);
805 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_help), menuitem_help_menu);
807 /* Not ready for 2.0
808 online_manual = gtk_menu_item_new_with_mnemonic (_("_Online Manual..."));
809 gtk_container_add (GTK_CONTAINER (menuitem_help_menu), online_manual);
810 gtk_tooltips_set_tip (tooltips, online_manual, "View the online help documentation", NULL);
813 about = gtk_image_menu_item_new_with_mnemonic (_("_About Gerbv..."));
814 gtk_container_add (GTK_CONTAINER (menuitem_help_menu), about);
815 gtk_tooltips_set_tip (tooltips, about, "View information about gerbv", NULL);
816 image34 = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_MENU);
817 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (about), image34);
819 bugs_menuitem = gtk_menu_item_new_with_mnemonic (_("Known _bugs in this version..."));
820 gtk_container_add (GTK_CONTAINER (menuitem_help_menu), bugs_menuitem);
821 gtk_tooltips_set_tip (tooltips, bugs_menuitem, "View list of known gerbv bugs", NULL);
823 /* Create toolbar (button bar) beneath main menu */
824 toolbar_hbox = gtk_hbox_new (FALSE, 0);
825 gtk_box_pack_start (GTK_BOX (vbox1), toolbar_hbox, FALSE, FALSE, 0);
827 handlebox = gtk_handle_box_new ();
829 gtk_box_pack_start (GTK_BOX (toolbar_hbox), handlebox, TRUE, TRUE, 0);
831 button_toolbar = gtk_toolbar_new ();
832 gtk_widget_set_size_request (button_toolbar, 500, -1);
833 gtk_container_add (GTK_CONTAINER (handlebox), button_toolbar);
834 gtk_toolbar_set_style (GTK_TOOLBAR (button_toolbar), GTK_TOOLBAR_ICONS);
835 /*tmp_toolbar_icon_size = gtk_toolbar_get_icon_size (GTK_TOOLBAR (button_toolbar));*/
837 toolbutton_new = (GtkWidget*) gtk_tool_button_new_from_stock (GTK_STOCK_NEW);
838 gtk_tooltips_set_tip (tooltips, toolbutton_new, "Close all layers and start a new project", NULL);
839 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_new);
841 toolbutton_open = (GtkWidget*) gtk_tool_button_new_from_stock (GTK_STOCK_OPEN);
842 gtk_tooltips_set_tip (tooltips, toolbutton_open, "Open a previously saved gerbv project", NULL);
843 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_open);
845 toolbutton_revert = (GtkWidget*) gtk_tool_button_new_from_stock (GTK_STOCK_REVERT_TO_SAVED);
846 gtk_tooltips_set_tip (tooltips, toolbutton_revert, "Reload all layers in project", NULL);
847 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_revert);
849 toolbutton_save = (GtkWidget*) gtk_tool_button_new_from_stock (GTK_STOCK_SAVE);
850 gtk_tooltips_set_tip (tooltips, toolbutton_save, "Save the current project", NULL);
851 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_save);
853 separatortoolitem1 = (GtkWidget*) gtk_separator_tool_item_new ();
854 gtk_container_add (GTK_CONTAINER (button_toolbar), separatortoolitem1);
855 #if GTK_CHECK_VERSION(2,10,0)
856 toolbutton_print = (GtkWidget*) gtk_tool_button_new_from_stock (GTK_STOCK_PRINT);
857 gtk_tooltips_set_tip (tooltips, toolbutton_print, "Print the visible layers", NULL);
858 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_print);
860 separatortoolitem2 = (GtkWidget*) gtk_separator_tool_item_new ();
861 gtk_container_add (GTK_CONTAINER (button_toolbar), separatortoolitem2);
862 #endif
863 toolbutton_zoom_in = (GtkWidget*) gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_IN);
864 gtk_tooltips_set_tip (tooltips, toolbutton_zoom_in, "Zoom in", NULL);
865 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_zoom_in);
867 toolbutton_zoom_out = (GtkWidget*) gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_OUT);
868 gtk_tooltips_set_tip (tooltips, toolbutton_zoom_out, "Zoom out", NULL);
869 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_zoom_out);
871 toolbutton_zoom_fit = (GtkWidget*) gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_FIT);
872 gtk_tooltips_set_tip (tooltips, toolbutton_zoom_fit, "Zoom to fit all visible layers in the window", NULL);
873 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_zoom_fit);
875 /* Turn these on later when we have icons for these buttons */
877 separatortoolitem3 = (GtkWidget*) gtk_separator_tool_item_new ();
878 gtk_container_add (GTK_CONTAINER (button_toolbar), separatortoolitem3);
880 toolbutton_analyze = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-apply");
881 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_analyze);
883 toolbutton_validate = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-apply");
884 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_validate);
886 toolbutton_control = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-apply");
887 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_control);
890 separatortoolitem4 = (GtkWidget*) gtk_separator_tool_item_new ();
891 gtk_container_add (GTK_CONTAINER (button_toolbar), separatortoolitem4);
892 toggletoolbutton_pointer = (GtkWidget*) gtk_toggle_tool_button_new();
893 pointerimage = gtk_image_new_from_pixbuf(pointerpixbuf);
894 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_pointer),
895 pointerimage);
896 gtk_tooltips_set_tip (tooltips, toggletoolbutton_pointer, "Select objects on the screen", NULL);
897 gtk_container_add (GTK_CONTAINER (button_toolbar), toggletoolbutton_pointer);
898 toggletoolbutton_pan = (GtkWidget*) gtk_toggle_tool_button_new();
899 moveimage = gtk_image_new_from_pixbuf(movepixbuf);
900 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_pan),
901 moveimage);
902 gtk_tooltips_set_tip (tooltips, toggletoolbutton_pan, "Pan by left clicking and dragging", NULL);
903 gtk_container_add (GTK_CONTAINER (button_toolbar), toggletoolbutton_pan);
906 toggletoolbutton_zoom = (GtkWidget*) gtk_toggle_tool_button_new();
907 zoomimage = gtk_image_new_from_pixbuf(zoompixbuf);
908 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_zoom),
909 zoomimage);
910 gtk_tooltips_set_tip (tooltips, toggletoolbutton_zoom, "Zoom by left clicking or dragging", NULL);
911 gtk_container_add (GTK_CONTAINER (button_toolbar), toggletoolbutton_zoom);
913 toggletoolbutton_measure = (GtkWidget*) gtk_toggle_tool_button_new();
914 measureimage = gtk_image_new_from_pixbuf(measurepixbuf);
915 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_measure),
916 measureimage);
917 gtk_tooltips_set_tip (tooltips, toggletoolbutton_measure, "Measure distances on the screen", NULL);
918 gtk_container_add (GTK_CONTAINER (button_toolbar), toggletoolbutton_measure);
920 hpaned1 = gtk_hpaned_new ();
921 gtk_box_pack_start (GTK_BOX (vbox1), hpaned1, TRUE, TRUE, 0);
922 gtk_paned_set_position (GTK_PANED (hpaned1), 225);
924 sidepane_vbox = gtk_vbox_new (FALSE, 0);
925 gtk_widget_set_size_request (sidepane_vbox, 150, -1);
927 gtk_paned_pack1 (GTK_PANED (hpaned1), sidepane_vbox, TRUE, FALSE);
928 gtk_container_set_border_width (GTK_CONTAINER (sidepane_vbox), 5);
930 sidepane_notebook = gtk_notebook_new ();
931 gtk_widget_set_size_request (sidepane_notebook, 100, -1);
932 gtk_box_pack_start (GTK_BOX (sidepane_vbox), sidepane_notebook, TRUE, TRUE, 0);
934 vbox10 = gtk_vbox_new (FALSE, 3);
935 gtk_container_add (GTK_CONTAINER (sidepane_notebook), vbox10);
936 gtk_widget_set_size_request (vbox10, 82, -1);
937 gtk_container_set_border_width (GTK_CONTAINER (vbox10), 4);
939 hbox4 = gtk_hbox_new (FALSE, 0);
940 gtk_box_pack_start (GTK_BOX (vbox10), hbox4, FALSE, FALSE, 0);
942 label1 = gtk_label_new (_("Rendering: "));
943 gtk_box_pack_start (GTK_BOX (hbox4), label1, FALSE, FALSE, 0);
945 render_combobox = gtk_combo_box_new_text ();
946 gtk_box_pack_start (GTK_BOX (hbox4), render_combobox, TRUE, TRUE, 0);
948 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox), _("Fast"));
949 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox), _("Fast, with XOR"));
950 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox), _("Normal"));
951 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox), _("High quality"));
952 if (screenRenderInfo.renderType < GERBV_RENDER_TYPE_MAX)
953 gtk_combo_box_set_active (GTK_COMBO_BOX (render_combobox), screenRenderInfo.renderType);
955 scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
956 gtk_box_pack_start (GTK_BOX (vbox10), scrolledwindow1, TRUE, TRUE, 0);
957 gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow1), 2);
958 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1),
959 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
960 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1),
961 GTK_SHADOW_IN);
963 hbox1 = gtk_hbox_new (TRUE, 0);
964 gtk_box_pack_start (GTK_BOX (vbox10), hbox1, FALSE, FALSE, 0);
966 button4 = gtk_button_new ();
967 gtk_box_pack_start (GTK_BOX (hbox1), button4, FALSE, TRUE, 0);
969 image8 = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON);
970 gtk_container_add (GTK_CONTAINER (button4), image8);
972 button5 = gtk_button_new ();
973 gtk_box_pack_start (GTK_BOX (hbox1), button5, FALSE, TRUE, 0);
975 image9 = gtk_image_new_from_stock (GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON);
976 gtk_container_add (GTK_CONTAINER (button5), image9);
978 button6 = gtk_button_new ();
979 gtk_box_pack_start (GTK_BOX (hbox1), button6, FALSE, TRUE, 0);
981 image10 = gtk_image_new_from_stock (GTK_STOCK_GO_UP, GTK_ICON_SIZE_BUTTON);
982 gtk_container_add (GTK_CONTAINER (button6), image10);
984 button7 = gtk_button_new ();
985 gtk_box_pack_start (GTK_BOX (hbox1), button7, FALSE, TRUE, 0);
987 image11 = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_BUTTON);
988 gtk_container_add (GTK_CONTAINER (button7), image11);
990 Layer_label = gtk_label_new (_("Layers"));
991 gtk_notebook_set_tab_label (GTK_NOTEBOOK (sidepane_notebook),
992 gtk_notebook_get_nth_page (GTK_NOTEBOOK (sidepane_notebook), 0),
993 Layer_label);
995 vbox11 = gtk_vbox_new (FALSE, 2);
996 gtk_container_add (GTK_CONTAINER (sidepane_notebook), vbox11);
997 gtk_container_set_border_width (GTK_CONTAINER (vbox11), 3);
999 messages_scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
1000 gtk_box_pack_start (GTK_BOX (vbox11), messages_scrolledwindow, TRUE, TRUE, 0);
1001 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (messages_scrolledwindow),
1002 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1004 message_textview = gtk_text_view_new ();
1005 gtk_container_add (GTK_CONTAINER (messages_scrolledwindow), message_textview);
1006 gtk_text_view_set_editable (GTK_TEXT_VIEW (message_textview), FALSE);
1007 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (message_textview), GTK_WRAP_WORD);
1008 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (message_textview), FALSE);
1010 clear_messages_button = gtk_button_new_from_stock (GTK_STOCK_CLEAR);
1011 gtk_box_pack_start (GTK_BOX (vbox11), clear_messages_button, FALSE, FALSE, 0);
1013 Message_label = gtk_label_new (_("Messages"));
1014 gtk_notebook_set_tab_label (GTK_NOTEBOOK (sidepane_notebook),
1015 gtk_notebook_get_nth_page (GTK_NOTEBOOK (sidepane_notebook), 1),
1016 Message_label);
1018 vbox2 = gtk_vbox_new (FALSE, 4);
1019 gtk_paned_pack2 (GTK_PANED (hpaned1), vbox2, TRUE, FALSE);
1020 gtk_container_set_border_width (GTK_CONTAINER (vbox2), 4);
1022 main_view_table = gtk_table_new (3, 3, FALSE);
1023 gtk_box_pack_start (GTK_BOX (vbox2), main_view_table, TRUE, TRUE, 0);
1025 hRuler = gtk_hruler_new ();
1026 gtk_table_attach (GTK_TABLE (main_view_table), hRuler, 1, 2, 0, 1,
1027 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1028 (GtkAttachOptions) (GTK_FILL), 0, 0);
1029 gtk_ruler_set_range (GTK_RULER (hRuler), 0, 100, 8.56051, 1000);
1031 vRuler = gtk_vruler_new ();
1032 gtk_table_attach (GTK_TABLE (main_view_table), vRuler, 0, 1, 1, 2,
1033 (GtkAttachOptions) (GTK_FILL),
1034 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
1035 gtk_ruler_set_range (GTK_RULER (vRuler), 0, 100, 8.37341, 1000);
1037 drawingarea = gtk_drawing_area_new();
1038 gtk_table_attach (GTK_TABLE (main_view_table), drawingarea, 1, 2, 1, 2,
1039 (GtkAttachOptions) (GTK_FILL),
1040 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
1042 hAdjustment = (GtkWidget *) gtk_adjustment_new (0.0, -1000.0, 1000.0, 1000.0, 1000.0, 500.0);
1043 vAdjustment = (GtkWidget *) gtk_adjustment_new (0.0, -1000.0, 1000.0, 1000.0, 1000.0, 500.0);
1045 hScrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (hAdjustment));
1046 gtk_table_attach (GTK_TABLE (main_view_table), hScrollbar, 1, 2, 2, 3,
1047 (GtkAttachOptions) (GTK_FILL),
1048 (GtkAttachOptions) (GTK_FILL), 0, 0);
1050 vScrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (vAdjustment));
1051 gtk_table_attach (GTK_TABLE (main_view_table), vScrollbar, 2, 3, 1, 2,
1052 (GtkAttachOptions) (GTK_FILL),
1053 (GtkAttachOptions) (GTK_FILL), 0, 0);
1055 hbox5 = gtk_hbox_new (FALSE, 10);
1056 gtk_box_pack_start (GTK_BOX (vbox2), hbox5, FALSE, FALSE, 0);
1058 statusbar_label_left = gtk_label_new ("( 0.0, 0.0 )");
1059 gtk_box_pack_start (GTK_BOX (hbox5), statusbar_label_left, FALSE, FALSE, 0);
1060 gtk_widget_set_size_request (statusbar_label_left, 130, -1);
1061 gtk_label_set_justify ((GtkLabel *) statusbar_label_left, GTK_JUSTIFY_RIGHT);
1063 statusUnitComboBox = gtk_combo_box_new_text ();
1064 gtk_box_pack_start (GTK_BOX (hbox5), statusUnitComboBox, FALSE, FALSE, 0);
1065 gtk_combo_box_append_text (GTK_COMBO_BOX (statusUnitComboBox), _("mil"));
1066 gtk_combo_box_append_text (GTK_COMBO_BOX (statusUnitComboBox), _("mm"));
1067 gtk_combo_box_append_text (GTK_COMBO_BOX (statusUnitComboBox), _("in"));
1069 statusbar_label_right = gtk_label_new (_(""));
1070 gtk_box_pack_start (GTK_BOX (hbox5), statusbar_label_right, TRUE, TRUE, 0);
1071 gtk_label_set_ellipsize ((GtkLabel *)statusbar_label_right, PANGO_ELLIPSIZE_END);
1072 gtk_misc_set_alignment (GTK_MISC (statusbar_label_right), 0, 0.5);
1077 * Connect signals to widgets
1080 /* --- File menu --- */
1081 g_signal_connect ((gpointer) new, "activate",
1082 G_CALLBACK (callbacks_new_activate),
1083 NULL);
1084 g_signal_connect ((gpointer) open_project, "activate",
1085 G_CALLBACK (callbacks_open_project_activate),
1086 NULL);
1087 g_signal_connect ((gpointer) open_layer, "activate",
1088 G_CALLBACK (callbacks_open_layer_activate),
1089 NULL);
1090 g_signal_connect ((gpointer) revert, "activate",
1091 G_CALLBACK (callbacks_revert_activate),
1092 NULL);
1093 g_signal_connect ((gpointer) save_layer, "activate",
1094 G_CALLBACK (callbacks_save_layer_activate),
1095 NULL);
1096 g_signal_connect ((gpointer) save_as_layer, "activate",
1097 G_CALLBACK (callbacks_generic_save_activate),
1098 (gpointer) CALLBACKS_SAVE_LAYER_AS);
1099 g_signal_connect ((gpointer) save, "activate",
1100 G_CALLBACK (callbacks_save_project_activate),
1101 NULL);
1102 g_signal_connect ((gpointer) save_as, "activate",
1103 G_CALLBACK (callbacks_generic_save_activate),
1104 (gpointer) CALLBACKS_SAVE_PROJECT_AS);
1105 g_signal_connect ((gpointer) png, "activate",
1106 G_CALLBACK (callbacks_generic_save_activate),
1107 (gpointer) CALLBACKS_SAVE_FILE_PNG);
1109 g_signal_connect ((gpointer) pdf, "activate",
1110 G_CALLBACK (callbacks_generic_save_activate),
1111 (gpointer) CALLBACKS_SAVE_FILE_PDF);
1112 g_signal_connect ((gpointer) svg, "activate",
1113 G_CALLBACK (callbacks_generic_save_activate),
1114 (gpointer) CALLBACKS_SAVE_FILE_SVG);
1115 g_signal_connect ((gpointer) postscript, "activate",
1116 G_CALLBACK (callbacks_generic_save_activate),
1117 (gpointer) CALLBACKS_SAVE_FILE_PS);
1118 g_signal_connect ((gpointer) rs274x, "activate",
1119 G_CALLBACK (callbacks_generic_save_activate),
1120 (gpointer) CALLBACKS_SAVE_FILE_RS274X);
1121 g_signal_connect ((gpointer) drill, "activate",
1122 G_CALLBACK (callbacks_generic_save_activate),
1123 (gpointer) CALLBACKS_SAVE_FILE_DRILL);
1124 g_signal_connect ((gpointer) rs274xm, "activate",
1125 G_CALLBACK (callbacks_generic_save_activate),
1126 (gpointer) CALLBACKS_SAVE_FILE_RS274XM);
1127 g_signal_connect ((gpointer) drillm, "activate",
1128 G_CALLBACK (callbacks_generic_save_activate),
1129 (gpointer) CALLBACKS_SAVE_FILE_DRILLM);
1131 #if GTK_CHECK_VERSION(2,10,0)
1132 g_signal_connect ((gpointer) print, "activate",
1133 G_CALLBACK (callbacks_print_activate),
1134 NULL);
1135 #endif
1136 g_signal_connect ((gpointer) quit, "activate",
1137 G_CALLBACK (callbacks_quit_activate),
1138 NULL);
1140 /* --- Edit menu --- */
1141 g_signal_connect ((gpointer) delete_selected, "activate",
1142 G_CALLBACK (callbacks_delete_objects_clicked),
1143 NULL);
1144 g_signal_connect ((gpointer) properties_selected, "activate",
1145 G_CALLBACK (callbacks_display_object_properties_clicked),
1146 NULL);
1148 /* --- View menu --- */
1149 g_signal_connect ((gpointer) view_fullscreen, "activate",
1150 G_CALLBACK (callbacks_fullscreen_toggled),
1151 GINT_TO_POINTER(0));
1152 g_signal_connect ((gpointer) show_toolbar, "toggled",
1153 G_CALLBACK (callbacks_show_toolbar_toggled),
1154 toolbar_hbox);
1155 g_signal_connect ((gpointer) show_sidepane, "toggled",
1156 G_CALLBACK (callbacks_show_sidepane_toggled),
1157 sidepane_vbox);
1158 g_signal_connect ((gpointer) toggle_layer_visibility_item1, "activate",
1159 G_CALLBACK (callbacks_toggle_layer_visibility_activate),
1160 GINT_TO_POINTER(0));
1161 g_signal_connect ((gpointer) toggle_layer_visibility_item2, "activate",
1162 G_CALLBACK (callbacks_toggle_layer_visibility_activate),
1163 GINT_TO_POINTER(1));
1164 g_signal_connect ((gpointer) toggle_layer_visibility_item3, "activate",
1165 G_CALLBACK (callbacks_toggle_layer_visibility_activate),
1166 GINT_TO_POINTER(2));
1167 g_signal_connect ((gpointer) toggle_layer_visibility_item4, "activate",
1168 G_CALLBACK (callbacks_toggle_layer_visibility_activate),
1169 GINT_TO_POINTER(3));
1170 g_signal_connect ((gpointer) toggle_layer_visibility_item5, "activate",
1171 G_CALLBACK (callbacks_toggle_layer_visibility_activate),
1172 GINT_TO_POINTER(4));
1173 g_signal_connect ((gpointer) toggle_layer_visibility_item6, "activate",
1174 G_CALLBACK (callbacks_toggle_layer_visibility_activate),
1175 GINT_TO_POINTER(5));
1176 g_signal_connect ((gpointer) toggle_layer_visibility_item7, "activate",
1177 G_CALLBACK (callbacks_toggle_layer_visibility_activate),
1178 GINT_TO_POINTER(6));
1179 g_signal_connect ((gpointer) toggle_layer_visibility_item8, "activate",
1180 G_CALLBACK (callbacks_toggle_layer_visibility_activate),
1181 GINT_TO_POINTER(7));
1182 g_signal_connect ((gpointer) toggle_layer_visibility_item9, "activate",
1183 G_CALLBACK (callbacks_toggle_layer_visibility_activate),
1184 GINT_TO_POINTER(8));
1185 g_signal_connect ((gpointer) toggle_layer_visibility_item10, "activate",
1186 G_CALLBACK (callbacks_toggle_layer_visibility_activate),
1187 GINT_TO_POINTER(9));
1188 g_signal_connect ((gpointer) zoom_in, "activate",
1189 G_CALLBACK (callbacks_zoom_in_activate),
1190 NULL);
1191 g_signal_connect ((gpointer) zoom_out, "activate",
1192 G_CALLBACK (callbacks_zoom_out_activate),
1193 NULL);
1194 g_signal_connect ((gpointer) fit_to_window, "activate",
1195 G_CALLBACK (callbacks_fit_to_window_activate),
1196 NULL);
1197 g_signal_connect ((gpointer) backgroundColor, "activate",
1198 G_CALLBACK (callbacks_change_background_color_clicked),
1199 NULL);
1200 g_signal_connect ((gpointer) unit_mil, "activate",
1201 G_CALLBACK (callbacks_viewmenu_units_changed),
1202 GINT_TO_POINTER(GERBV_MILS));
1203 g_signal_connect ((gpointer) unit_mm, "activate",
1204 G_CALLBACK (callbacks_viewmenu_units_changed),
1205 GINT_TO_POINTER(GERBV_MMS));
1206 g_signal_connect ((gpointer) unit_in, "activate",
1207 G_CALLBACK (callbacks_viewmenu_units_changed),
1208 GINT_TO_POINTER(GERBV_INS));
1210 /* --- Current Layer menu --- */
1211 g_signal_connect ((gpointer) layer_visibility, "activate", G_CALLBACK (callbacks_toggle_layer_visibility_activate), GINT_TO_POINTER(-1));
1212 g_signal_connect ((gpointer) layer_invert, "activate", G_CALLBACK (callbacks_invert_layer_clicked), NULL);
1213 g_signal_connect ((gpointer) layer_color, "activate", G_CALLBACK (callbacks_change_layer_color_clicked), NULL);
1214 g_signal_connect ((gpointer) layer_reload, "activate", G_CALLBACK (callbacks_reload_layer_clicked), NULL);
1215 g_signal_connect ((gpointer) layer_orientation, "activate", G_CALLBACK (callbacks_change_layer_orientation_clicked), NULL);
1216 g_signal_connect ((gpointer) layer_format, "activate", G_CALLBACK (callbacks_change_layer_format_clicked), NULL);
1217 g_signal_connect ((gpointer) layer_remove, "activate", G_CALLBACK (callbacks_remove_layer_button_clicked), NULL);
1218 g_signal_connect ((gpointer) layer_up, "activate", G_CALLBACK (callbacks_move_layer_up_menu_activate), NULL);
1219 g_signal_connect ((gpointer) layer_down, "activate", G_CALLBACK (callbacks_move_layer_down_menu_activate), NULL);
1221 /* --- Analyze menu --- */
1222 g_signal_connect ((gpointer) analyze_active_gerbers, "activate",
1223 G_CALLBACK (callbacks_analyze_active_gerbers_activate),
1224 NULL);
1225 g_signal_connect ((gpointer) analyze_active_drill, "activate",
1226 G_CALLBACK (callbacks_analyze_active_drill_activate),
1227 NULL);
1228 g_signal_connect ((gpointer) analyze_benchmark, "activate",
1229 G_CALLBACK (callbacks_benchmark_clicked),
1230 NULL);
1233 /* Wait for 2.1
1234 g_signal_connect ((gpointer) control_gerber_options, "activate",
1235 G_CALLBACK (callbacks_control_gerber_options_activate),
1236 NULL);
1239 /* --- Tools menu --- */
1240 g_signal_connect ((gpointer) pointer_tool, "activate",
1241 G_CALLBACK (callbacks_change_tool), (gpointer) 0);
1242 g_signal_connect ((gpointer) pan_tool, "activate",
1243 G_CALLBACK (callbacks_change_tool), (gpointer) 1);
1244 g_signal_connect ((gpointer) zoom_tool, "activate",
1245 G_CALLBACK (callbacks_change_tool), (gpointer) 2);
1246 g_signal_connect ((gpointer) measure_tool, "activate",
1247 G_CALLBACK (callbacks_change_tool), (gpointer) 3);
1249 /* --- Help menu --- */
1251 g_signal_connect ((gpointer) online_manual, "activate",
1252 G_CALLBACK (callbacks_online_manual_activate),
1253 NULL);
1255 g_signal_connect ((gpointer) about, "activate",
1256 G_CALLBACK (callbacks_about_activate),
1257 NULL);
1259 g_signal_connect ((gpointer) bugs_menuitem, "activate",
1260 G_CALLBACK (callbacks_bugs_activate),
1261 NULL);
1263 /* End of Glade generated code */
1264 g_signal_connect ((gpointer) toolbutton_new, "clicked",
1265 G_CALLBACK (callbacks_new_activate),
1266 NULL);
1267 g_signal_connect ((gpointer) toolbutton_save, "clicked",
1268 G_CALLBACK (callbacks_save_project_activate),
1269 NULL);
1270 g_signal_connect ((gpointer) toolbutton_open, "clicked",
1271 G_CALLBACK (callbacks_open_project_activate),
1272 NULL);
1273 g_signal_connect ((gpointer) toolbutton_revert, "clicked",
1274 G_CALLBACK (callbacks_revert_activate),
1275 NULL);
1276 g_signal_connect ((gpointer) clear_messages_button, "clicked",
1277 G_CALLBACK (callbacks_clear_messages_button_clicked),
1278 NULL);
1279 #if GTK_CHECK_VERSION(2,10,0)
1280 g_signal_connect ((gpointer) toolbutton_print, "clicked",
1281 G_CALLBACK (callbacks_print_activate),
1282 NULL);
1283 #endif
1284 g_signal_connect ((gpointer) toolbutton_zoom_in, "clicked",
1285 G_CALLBACK (callbacks_zoom_in_activate),
1286 NULL);
1287 g_signal_connect ((gpointer) toolbutton_zoom_out, "clicked",
1288 G_CALLBACK (callbacks_zoom_out_activate),
1289 NULL);
1290 g_signal_connect ((gpointer) toolbutton_zoom_fit, "clicked",
1291 G_CALLBACK (callbacks_fit_to_window_activate),
1292 NULL);
1293 g_signal_connect ((gpointer) toggletoolbutton_pointer, "clicked",
1294 G_CALLBACK (callbacks_change_tool), (gpointer) 0);
1295 g_signal_connect ((gpointer) toggletoolbutton_pan, "clicked",
1296 G_CALLBACK (callbacks_change_tool), (gpointer) 1);
1297 g_signal_connect ((gpointer) toggletoolbutton_zoom, "clicked",
1298 G_CALLBACK (callbacks_change_tool), (gpointer) 2);
1299 g_signal_connect ((gpointer) toggletoolbutton_measure, "clicked",
1300 G_CALLBACK (callbacks_change_tool), (gpointer) 3);
1302 g_signal_connect ((gpointer) statusUnitComboBox, "changed",
1303 G_CALLBACK (callbacks_statusbar_unit_combo_box_changed),
1304 NULL);
1306 g_signal_connect ((gpointer) button4, "clicked",
1307 G_CALLBACK (callbacks_add_layer_button_clicked), NULL);
1308 g_signal_connect ((gpointer) button7, "clicked",
1309 G_CALLBACK (callbacks_remove_layer_button_clicked), NULL);
1310 g_signal_connect ((gpointer) button5, "clicked",
1311 G_CALLBACK (callbacks_move_layer_down_button_clicked), NULL);
1312 g_signal_connect ((gpointer) button6, "clicked",
1313 G_CALLBACK (callbacks_move_layer_up_button_clicked), NULL);
1315 g_signal_connect ((gpointer) hAdjustment, "value-changed",
1316 G_CALLBACK (callbacks_hadjustment_value_changed), NULL);
1317 g_signal_connect ((gpointer) vAdjustment, "value-changed",
1318 G_CALLBACK (callbacks_vadjustment_value_changed), NULL);
1319 g_signal_connect ((gpointer) hScrollbar, "button-press-event",
1320 G_CALLBACK (callbacks_scrollbar_button_pressed), NULL);
1321 g_signal_connect ((gpointer) hScrollbar, "button-release-event",
1322 G_CALLBACK (callbacks_scrollbar_button_released), NULL);
1323 g_signal_connect ((gpointer) vScrollbar, "button-press-event",
1324 G_CALLBACK (callbacks_scrollbar_button_pressed), NULL);
1325 g_signal_connect ((gpointer) vScrollbar, "button-release-event",
1326 G_CALLBACK (callbacks_scrollbar_button_released), NULL);
1329 if (screen.unit == GERBV_MILS)
1330 gtk_combo_box_set_active (GTK_COMBO_BOX (statusUnitComboBox), 0);
1331 else if (screen.unit == GERBV_MMS)
1332 gtk_combo_box_set_active (GTK_COMBO_BOX (statusUnitComboBox), 1);
1333 else
1334 gtk_combo_box_set_active (GTK_COMBO_BOX (statusUnitComboBox), 2);
1336 gint width, height;
1338 gtk_window_add_accel_group (GTK_WINDOW (mainWindow), accel_group);
1340 GtkListStore *list_store;
1342 list_store = gtk_list_store_new (4, G_TYPE_BOOLEAN,
1343 GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
1345 GtkWidget *tree;
1347 tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
1348 GtkCellRenderer *renderer;
1349 GtkTreeViewColumn *column;
1351 renderer = gtk_cell_renderer_toggle_new ();
1352 column = gtk_tree_view_column_new_with_attributes ("Visible",
1353 renderer,
1354 "active", 0,
1355 NULL);
1356 gtk_tree_view_column_set_min_width ((GtkTreeViewColumn *)column,25);
1357 gtk_signal_connect(GTK_OBJECT(renderer), "toggled",
1358 GTK_SIGNAL_FUNC(callbacks_layer_tree_visibility_button_toggled), NULL);
1359 gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
1361 renderer = gtk_cell_renderer_pixbuf_new ();
1362 column = gtk_tree_view_column_new_with_attributes ("Color",
1363 renderer,
1364 "pixbuf", 1, NULL);
1365 gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
1367 renderer = gtk_cell_renderer_text_new ();
1368 g_object_set (G_OBJECT (renderer), "foreground", "red", "xalign", 0.5,
1369 "family", "Times", "size-points", 12.0, NULL);
1370 column = gtk_tree_view_column_new_with_attributes ("Modified",
1371 renderer,
1372 "text", 3,
1373 NULL);
1374 gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
1375 gtk_tree_view_column_set_min_width ((GtkTreeViewColumn *)column,20);
1377 renderer = gtk_cell_renderer_text_new ();
1378 column = gtk_tree_view_column_new_with_attributes ("Name",
1379 renderer,
1380 "markup", 2,
1381 NULL);
1382 gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
1384 gtk_tree_view_set_headers_visible ((GtkTreeView *)tree, FALSE);
1385 gtk_signal_connect(GTK_OBJECT(tree), "key-press-event",
1386 GTK_SIGNAL_FUNC(callbacks_layer_tree_key_press), NULL);
1387 gtk_signal_connect(GTK_OBJECT(tree), "button-press-event",
1388 GTK_SIGNAL_FUNC(callbacks_layer_tree_button_press), NULL);
1389 gtk_container_add (GTK_CONTAINER (scrolledwindow1), tree);
1391 GtkTreeSelection *selection;
1392 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
1393 gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
1394 gtk_tree_view_set_enable_search (GTK_TREE_VIEW (tree), FALSE);
1395 gtk_tree_view_set_reorderable (GTK_TREE_VIEW (tree), TRUE);
1397 g_signal_connect (G_OBJECT(list_store), "row-inserted",
1398 G_CALLBACK (callbacks_layer_tree_row_inserted), NULL);
1399 /* steal the focus to the tree to make sure none of the buttons are focused */
1400 gtk_widget_grab_focus (tree);
1402 * Connect all events on drawing area
1404 gtk_signal_connect(GTK_OBJECT(drawingarea), "expose_event",
1405 GTK_SIGNAL_FUNC(callbacks_drawingarea_expose_event), NULL);
1406 gtk_signal_connect(GTK_OBJECT(drawingarea),"configure_event",
1407 GTK_SIGNAL_FUNC(callbacks_drawingarea_configure_event), NULL);
1408 gtk_signal_connect(GTK_OBJECT(drawingarea), "motion_notify_event",
1409 GTK_SIGNAL_FUNC(callbacks_drawingarea_motion_notify_event), NULL);
1410 gtk_signal_connect(GTK_OBJECT(drawingarea), "button_press_event",
1411 GTK_SIGNAL_FUNC(callbacks_drawingarea_button_press_event), NULL);
1412 gtk_signal_connect(GTK_OBJECT(drawingarea), "button_release_event",
1413 GTK_SIGNAL_FUNC(callbacks_drawingarea_button_release_event), NULL);
1414 gtk_signal_connect_after(GTK_OBJECT(mainWindow), "key_press_event",
1415 GTK_SIGNAL_FUNC(callbacks_window_key_press_event), NULL);
1416 gtk_signal_connect_after(GTK_OBJECT(mainWindow), "key_release_event",
1417 GTK_SIGNAL_FUNC(callbacks_window_key_release_event), NULL);
1418 gtk_signal_connect_after(GTK_OBJECT(mainWindow), "scroll_event",
1419 GTK_SIGNAL_FUNC(callbacks_window_scroll_event), NULL);
1420 gtk_signal_connect_after(GTK_OBJECT(mainWindow), "delete_event",
1421 GTK_SIGNAL_FUNC(callbacks_quit_activate), NULL);
1423 gtk_widget_set_events(drawingarea, GDK_EXPOSURE_MASK
1424 | GDK_LEAVE_NOTIFY_MASK
1425 | GDK_ENTER_NOTIFY_MASK
1426 | GDK_BUTTON_PRESS_MASK
1427 | GDK_BUTTON_RELEASE_MASK
1428 | GDK_KEY_PRESS_MASK
1429 | GDK_KEY_RELEASE_MASK
1430 | GDK_POINTER_MOTION_MASK
1431 | GDK_POINTER_MOTION_HINT_MASK
1432 | GDK_SCROLL_MASK
1436 * Set gtk error log handler
1438 g_log_set_handler (NULL,
1439 G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION | G_LOG_LEVEL_MASK,
1440 callbacks_handle_log_messages, NULL);
1443 * Setup some GTK+ defaults.
1444 * These should really be somewhere else.
1446 GdkColor zoom_outline_color = {0, 50000, 50000, 50000};
1447 GdkColor dist_measure_color = {0, 60000, 30000, 65000};
1448 GdkColor selection_color = {0, 65000, 65000, 65000};
1450 screen.zoom_outline_color = zoom_outline_color;
1451 screen.dist_measure_color = dist_measure_color;
1452 screen.selection_color = selection_color;
1454 screen.drawing_area = drawingarea;
1455 screen.win.hAdjustment = hAdjustment;
1456 screen.win.vAdjustment = vAdjustment;
1457 screen.win.hRuler = hRuler;
1458 screen.win.vRuler = vRuler;
1459 screen.win.sidepane_notebook = sidepane_notebook;
1460 screen.win.sidepaneRenderComboBox = GTK_COMBO_BOX(render_combobox);
1461 screen.win.toolButtonPointer = toggletoolbutton_pointer;
1462 screen.win.toolButtonPan = toggletoolbutton_pan;
1463 screen.win.toolButtonZoom = toggletoolbutton_zoom;
1464 screen.win.toolButtonMeasure = toggletoolbutton_measure;
1466 /* make sure tooltips show on gtk <2.12 systems */
1467 gtk_tooltips_enable (tooltips);
1469 * Good defaults according to Ales. Gives aspect ratio of 1.3333...
1471 if ((req_width != -1) && (req_height != -1)) {
1472 width = req_width;
1473 height = req_height;
1475 else {
1476 GdkScreen *screen;
1477 int nmonitors;
1479 screen = gdk_screen_get_default();
1480 nmonitors = gdk_screen_get_n_monitors(screen);
1482 width = gdk_screen_get_width(screen) * 3/4 / nmonitors;
1483 height = gdk_screen_get_height(screen) * 3/4 / nmonitors;
1486 gtk_window_set_default_size((GtkWindow *)mainWindow, width, height);
1488 GtkSettings* gtksettings = gtk_settings_get_default ();
1489 g_object_set (G_OBJECT(gtksettings), "gtk-can-change-accels", TRUE, NULL);
1490 interface_load_accels ();
1491 gtk_widget_show_all (mainWindow);
1492 screen.win.topLevelWindow = mainWindow;
1493 screen.win.messageTextView = message_textview;
1494 screen.win.statusMessageLeft = statusbar_label_left;
1495 screen.win.statusMessageRight = statusbar_label_right;
1496 screen.win.statusUnitComboBox = statusUnitComboBox;
1497 screen.win.layerTree = tree;
1498 screen.win.treeIsUpdating = FALSE;
1500 screen.selectionInfo.selectedNodeArray = g_array_new (FALSE,
1501 FALSE, sizeof(gerbv_selection_item_t));
1502 callbacks_change_tool (NULL, (gpointer) 0);
1503 rename_main_window("",mainWindow);
1505 set_window_icon (mainWindow);
1506 callbacks_update_layer_tree ();
1508 /* connect this signals as late as possible to avoid triggering them before
1509 the gui is drawn */
1510 g_signal_connect ((gpointer) render_fast, "activate",
1511 G_CALLBACK (callbacks_viewmenu_rendertype_changed),
1512 GINT_TO_POINTER(GERBV_RENDER_TYPE_GDK));
1513 g_signal_connect ((gpointer) render_fast_xor, "activate",
1514 G_CALLBACK (callbacks_viewmenu_rendertype_changed),
1515 GINT_TO_POINTER(GERBV_RENDER_TYPE_GDK_XOR));
1516 g_signal_connect ((gpointer) render_normal, "activate",
1517 G_CALLBACK (callbacks_viewmenu_rendertype_changed),
1518 GINT_TO_POINTER(GERBV_RENDER_TYPE_CAIRO_NORMAL));
1519 g_signal_connect ((gpointer) render_hq, "activate",
1520 G_CALLBACK (callbacks_viewmenu_rendertype_changed),
1521 GINT_TO_POINTER(GERBV_RENDER_TYPE_CAIRO_HIGH_QUALITY));
1522 g_signal_connect ((gpointer) render_combobox, "changed",
1523 G_CALLBACK (callbacks_sidepane_render_type_combo_box_changed),
1524 NULL);
1525 gtk_main();
1526 interface_save_accels ();
1529 /* ---------------------------------------------------- */
1530 void
1531 interface_set_render_type (int t)
1533 if (t >= GERBV_RENDER_TYPE_MAX)
1534 return;
1536 screenRenderInfo.renderType = t;
1538 /* make sure the interface is already up before calling
1539 * gtk_combo_box_set_active()
1541 if (!screen.win.sidepaneRenderComboBox)
1542 return;
1544 gtk_combo_box_set_active (GTK_COMBO_BOX (screen.win.sidepaneRenderComboBox), t);
1545 gtk_check_menu_item_set_active (screen.win.menu_view_render_group[t], TRUE);
1548 /* ---------------------------------------------------- */
1550 * This dialog box shows a message and two buttons:
1551 * "OK" and "Cancel". It returns gboolean 1 if the
1552 * user clicked "OK", and gboolean 0 if the user
1553 * clicked "Cancel".
1557 gboolean
1558 interface_get_alert_dialog_response (gchar *primaryText, gchar *secondaryText,
1559 gboolean show_checkbox, gboolean *ask_to_show_again )
1560 /* This fcn returns TRUE if the user presses the OK button,
1561 otherwise it returns FALSE. */
1563 /* Set show_checkbox = TRUE to show "do not show this again" checkbox. */
1564 /* Point ask_to_show_again to the variable to set to not show the checkbox. */
1565 GtkWidget *dialog1;
1566 GtkWidget *dialog_vbox1;
1567 GtkWidget *hbox1;
1568 GtkWidget *image1;
1569 GtkWidget *label1;
1570 GtkWidget *checkbox=NULL;
1571 GtkWidget *dialog_action_area1;
1572 GtkWidget *cancelbutton1;
1573 GtkWidget *okbutton1;
1574 gboolean returnVal = FALSE;
1576 dialog1 = gtk_dialog_new ();
1577 gtk_container_set_border_width (GTK_CONTAINER (dialog1), 6);
1578 gtk_window_set_resizable (GTK_WINDOW (dialog1), FALSE);
1579 gtk_window_set_type_hint (GTK_WINDOW (dialog1), GDK_WINDOW_TYPE_HINT_DIALOG);
1580 gtk_dialog_set_has_separator (GTK_DIALOG (dialog1), FALSE);
1582 dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
1584 hbox1 = gtk_hbox_new (FALSE, 12);
1585 gtk_box_pack_start (GTK_BOX (dialog_vbox1), hbox1, TRUE, TRUE, 0);
1586 gtk_container_set_border_width (GTK_CONTAINER (hbox1), 6);
1588 image1 = gtk_image_new_from_icon_name (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
1589 gtk_box_pack_start (GTK_BOX (hbox1), image1, TRUE, TRUE, 0);
1590 gtk_misc_set_alignment (GTK_MISC (image1), 0.5, 0);
1592 gchar *labelMessage = g_strconcat ("<span weight=\"bold\" size=\"larger\">",primaryText,
1593 "</span>\n<span/>\n",secondaryText,NULL);
1594 label1 = gtk_label_new (labelMessage);
1595 g_free (labelMessage);
1596 GtkWidget *vbox9 = gtk_vbox_new (FALSE, 0);
1597 gtk_box_pack_start (GTK_BOX (vbox9), label1, FALSE, FALSE, 0);
1598 gtk_box_pack_start (GTK_BOX (hbox1), vbox9, FALSE, FALSE, 0);
1599 gtk_label_set_use_markup (GTK_LABEL (label1), TRUE);
1600 gtk_label_set_line_wrap (GTK_LABEL (label1), TRUE);
1602 // even with no checkbox, this extra hbox gives the recommended 24 px space between the
1603 // label and the buttons
1604 GtkWidget *hbox2 = gtk_hbox_new (FALSE, 12);
1605 if (show_checkbox) {
1606 GtkWidget *label3 = gtk_label_new (" ");
1608 checkbox = gtk_check_button_new_with_label("Do not show this dialog again.");
1609 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbox), FALSE);
1610 gtk_box_pack_start (GTK_BOX (hbox2), label3, FALSE, FALSE, 0);
1611 gtk_box_pack_start (GTK_BOX (hbox2), checkbox, FALSE, FALSE, 0);
1613 gtk_box_pack_start (GTK_BOX (vbox9), hbox2, FALSE, FALSE, 12);
1615 dialog_action_area1 = GTK_DIALOG (dialog1)->action_area;
1616 gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
1618 cancelbutton1 = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
1619 gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), cancelbutton1, GTK_RESPONSE_CANCEL);
1620 GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);
1621 gtk_widget_grab_default (cancelbutton1);
1622 gtk_widget_grab_focus (cancelbutton1);
1624 okbutton1 = gtk_button_new_from_stock (GTK_STOCK_OK);
1625 gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), okbutton1, GTK_RESPONSE_OK);
1626 GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);
1628 gtk_widget_show_all (dialog1);
1630 if (gtk_dialog_run ((GtkDialog*)dialog1) == GTK_RESPONSE_OK) {
1631 /* check to see if user clicked on "do not show again" box */
1632 if ((show_checkbox == TRUE) &&
1633 (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox)) == TRUE) &&
1634 (ask_to_show_again != NULL) ) {
1635 /* The user clicked the "do not show again box". Set corresponding
1636 * flag to FALSE. */
1637 *ask_to_show_again = FALSE;
1639 returnVal = TRUE;
1641 gtk_widget_destroy (dialog1);
1643 return returnVal;
1648 /* ---------------------------------------------------- */
1650 * This dialog box shows a textmessage and one button:
1651 * "OK". It does not return anything.
1654 void
1655 interface_show_alert_dialog (gchar *primaryText, gchar *secondaryText,
1656 gboolean show_checkbox, gboolean *ask_to_show_again )
1657 /* This fcn tells the user something, and only displays "OK" */
1659 /* Set show_checkbox = TRUE to show "do not show this again" checkbox. */
1660 /* Point ask_to_show_again to the variable to set to not show the checkbox. */
1661 GtkWidget *dialog1;
1662 GtkWidget *dialog_vbox1;
1663 GtkWidget *hbox1;
1664 GtkWidget *image1;
1665 GtkWidget *label1;
1666 GtkWidget *checkbox=NULL;
1667 GtkWidget *dialog_action_area1;
1668 GtkWidget *okbutton1;
1670 dialog1 = gtk_dialog_new ();
1671 gtk_container_set_border_width (GTK_CONTAINER (dialog1), 6);
1672 gtk_window_set_resizable (GTK_WINDOW (dialog1), FALSE);
1673 gtk_window_set_type_hint (GTK_WINDOW (dialog1), GDK_WINDOW_TYPE_HINT_DIALOG);
1674 gtk_dialog_set_has_separator (GTK_DIALOG (dialog1), FALSE);
1676 dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
1678 hbox1 = gtk_hbox_new (FALSE, 12);
1679 gtk_box_pack_start (GTK_BOX (dialog_vbox1), hbox1, TRUE, TRUE, 0);
1680 gtk_container_set_border_width (GTK_CONTAINER (hbox1), 6);
1682 image1 = gtk_image_new_from_icon_name (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
1683 gtk_box_pack_start (GTK_BOX (hbox1), image1, TRUE, TRUE, 0);
1684 gtk_misc_set_alignment (GTK_MISC (image1), 0.5, 0);
1686 gchar *labelMessage = g_strconcat ("<span weight=\"bold\" size=\"larger\">",primaryText,
1687 "</span>\n<span/>\n",secondaryText,NULL);
1688 label1 = gtk_label_new (labelMessage);
1689 g_free (labelMessage);
1691 GtkWidget *vbox9 = gtk_vbox_new (FALSE, 0);
1692 gtk_box_pack_start (GTK_BOX (vbox9), label1, FALSE, FALSE, 0);
1693 gtk_label_set_use_markup (GTK_LABEL (label1), TRUE);
1694 gtk_label_set_line_wrap (GTK_LABEL (label1), TRUE);
1695 gtk_box_pack_start (GTK_BOX (hbox1), vbox9, FALSE, FALSE, 0);
1697 GtkWidget *hbox2 = gtk_hbox_new (FALSE, 12);
1698 if (show_checkbox) {
1699 GtkWidget *label3 = gtk_label_new (" ");
1701 checkbox = gtk_check_button_new_with_label("Do not show this dialog again.");
1702 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbox), FALSE);
1703 gtk_box_pack_start (GTK_BOX (hbox2), label3, FALSE, FALSE, 0);
1704 gtk_box_pack_start (GTK_BOX (hbox2), checkbox, FALSE, FALSE, 0);
1706 gtk_box_pack_start (GTK_BOX (vbox9), hbox2, FALSE, FALSE, 12);
1708 dialog_action_area1 = GTK_DIALOG (dialog1)->action_area;
1709 gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
1711 okbutton1 = gtk_button_new_from_stock (GTK_STOCK_OK);
1712 gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), okbutton1, GTK_RESPONSE_OK);
1713 GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);
1715 gtk_widget_show_all (dialog1);
1717 /* check to see if user clicked on "do not show again" box */
1718 if ((show_checkbox == TRUE) &&
1719 (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox)) == TRUE) &&
1720 (ask_to_show_again != NULL) ) {
1721 /* The user clicked the "do not show again box". Set corresponding
1722 * flag to FALSE. */
1723 *ask_to_show_again = FALSE;
1726 gtk_dialog_run (GTK_DIALOG(dialog1));
1727 gtk_widget_destroy (dialog1);
1729 return;
1732 void
1733 interface_show_modify_orientation_dialog (gerbv_user_transformation_t *transform,
1734 gerbv_unit_t screenUnit) {
1735 GtkWidget *dialog;
1736 GtkWidget *check1,*check2,*tempWidget,*tempWidget2,*tableWidget;
1737 GtkWidget *spin1,*spin2,*spin3,*spin4,*spin5;
1738 GtkAdjustment *adj;
1739 gerbv_user_transformation_t startTransform = *transform;
1741 dialog = gtk_dialog_new_with_buttons ("Modify layer orientation",
1742 GTK_WINDOW (screen.win.topLevelWindow), GTK_DIALOG_DESTROY_WITH_PARENT,
1743 GTK_STOCK_CANCEL, GTK_RESPONSE_NONE, GTK_STOCK_OK, GTK_RESPONSE_OK,
1744 GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
1745 NULL);
1747 gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
1748 gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
1749 gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
1750 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1752 tableWidget = gtk_table_new (16,3,FALSE);
1753 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), tableWidget, FALSE, FALSE, 0);
1755 tempWidget = gtk_label_new (NULL);
1756 gtk_label_set_markup (GTK_LABEL (tempWidget), "<span weight=\"bold\">Translation</span>");
1757 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1758 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,0,2,0,1,GTK_EXPAND|GTK_FILL,0,0,5);
1760 tempWidget = gtk_label_new (" ");
1761 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,0,1,1,2,0,0,0,0);
1762 gdouble translateX, translateY;
1764 if (screenUnit == (gerbv_unit_t) GERBV_MILS) {
1765 tempWidget = gtk_label_new ("X (mils):");
1766 tempWidget2 = gtk_label_new ("Y (mils):");
1767 translateX = transform->translateX * 1000;
1768 translateY = transform->translateY * 1000;
1770 else if (screen.unit == (gerbv_gui_unit_t) GERBV_MMS) {
1771 tempWidget = gtk_label_new ("X (mms):");
1772 tempWidget2 = gtk_label_new ("Y (mms):");
1773 translateX = transform->translateX * 25.4;
1774 translateY = transform->translateY * 25.4;
1776 else {
1777 tempWidget = gtk_label_new ("X (inches):");
1778 tempWidget2 = gtk_label_new ("Y (inches):");
1779 translateX = transform->translateX;
1780 translateY = transform->translateY;
1783 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1784 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,1,2,1,2,GTK_EXPAND|GTK_FILL,0,0,0);
1785 gtk_misc_set_alignment (GTK_MISC (tempWidget2), 0.0, 0.5);
1786 gtk_table_attach ((GtkTable *) tableWidget, tempWidget2,1,2,2,3,GTK_EXPAND|GTK_FILL,0,0,0);
1787 adj = (GtkAdjustment *) gtk_adjustment_new (translateX, -1000000, 1000000, 1, 10, 0.0);
1788 spin1 = (GtkWidget *) gtk_spin_button_new (adj, 0.1, 4);
1789 gtk_table_attach ((GtkTable *) tableWidget, spin1,2,3,1,2,GTK_FILL,0,0,0);
1790 adj = (GtkAdjustment *) gtk_adjustment_new (translateY, -1000000, 1000000, 1, 10, 0.0);
1791 spin2 = (GtkWidget *) gtk_spin_button_new (adj, 0.1, 4);
1792 gtk_table_attach ((GtkTable *) tableWidget, spin2,2,3,2,3,GTK_FILL,0,0,0);
1794 gtk_table_set_row_spacing ((GtkTable *) tableWidget, 3, 8);
1795 tempWidget = gtk_label_new (NULL);
1796 gtk_label_set_markup (GTK_LABEL (tempWidget), "<span weight=\"bold\">Scale</span>");
1797 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1798 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,0,2,4,5,GTK_EXPAND|GTK_FILL,0,0,5);
1800 tempWidget = gtk_label_new ("X direction:");
1801 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1802 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,1,2,5,6,GTK_EXPAND|GTK_FILL,0,0,0);
1803 tempWidget = gtk_label_new ("Y direction:");
1804 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1805 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,1,2,6,7,GTK_EXPAND|GTK_FILL,0,0,0);
1806 adj = (GtkAdjustment *) gtk_adjustment_new (transform->scaleX, -1000000, 1000000, 1, 10, 0.0);
1807 spin3 = (GtkWidget *) gtk_spin_button_new (adj, 1, 3);
1808 gtk_table_attach ((GtkTable *) tableWidget, spin3,2,3,5,6,GTK_FILL,0,0,0);
1809 adj = (GtkAdjustment *) gtk_adjustment_new (transform->scaleY, -1000000, 1000000, 1, 10, 0.0);
1810 spin4 = (GtkWidget *) gtk_spin_button_new (adj, 1, 3);
1811 gtk_table_attach ((GtkTable *) tableWidget, spin4,2,3,6,7,GTK_FILL,0,0,0);
1813 gtk_table_set_row_spacing ((GtkTable *) tableWidget, 7, 8);
1815 tempWidget = gtk_label_new (NULL);
1816 gtk_label_set_markup (GTK_LABEL (tempWidget), "<span weight=\"bold\">Rotation</span>");
1817 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1818 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,0,2,8,9,GTK_EXPAND|GTK_FILL,0,0,5);
1820 tempWidget = gtk_label_new ("Rotation (degrees): ");
1821 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1822 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,1,2,9,10,GTK_EXPAND|GTK_FILL,0,0,0);
1823 spin5 = gtk_combo_box_new_text();
1824 gtk_combo_box_append_text ((GtkComboBox *)spin5, "None");
1825 gtk_combo_box_append_text ((GtkComboBox *)spin5, "90 deg CCW");
1826 gtk_combo_box_append_text ((GtkComboBox *)spin5, "180 deg CCW");
1827 gtk_combo_box_append_text ((GtkComboBox *)spin5, "270 deg CCW");
1828 gdouble degreeRotation = transform->rotation/M_PI*180;
1829 if ((degreeRotation < 135)&&(degreeRotation >= 45))
1830 gtk_combo_box_set_active ((GtkComboBox *)spin5, 1);
1831 else if ((degreeRotation < 225)&&(degreeRotation >= 135))
1832 gtk_combo_box_set_active ((GtkComboBox *)spin5, 2);
1833 else if ((degreeRotation < 315)&&(degreeRotation >= 225))
1834 gtk_combo_box_set_active ((GtkComboBox *)spin5, 3);
1835 else
1836 gtk_combo_box_set_active ((GtkComboBox *)spin5, 0);
1838 adj = (GtkAdjustment *) gtk_adjustment_new (transform->rotation/M_PI*180, -1000000, 1000000,
1839 1, 10, 0.0);
1840 spin5 = (GtkWidget *) gtk_spin_button_new (adj, 0, 3);
1842 gtk_table_attach ((GtkTable *) tableWidget, spin5,2,3,9,10,GTK_FILL,0,0,0);
1845 gtk_table_set_row_spacing ((GtkTable *) tableWidget, 10, 8);
1846 tempWidget = gtk_label_new (NULL);
1847 gtk_label_set_markup (GTK_LABEL (tempWidget), "<span weight=\"bold\">Mirroring</span>");
1848 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1849 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,0,2,11,12,GTK_EXPAND|GTK_FILL,0,0,5);
1851 tempWidget = gtk_label_new ("About X axis:");
1852 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1853 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,1,2,12,13,GTK_EXPAND|GTK_FILL,0,0,0);
1854 check1 = (GtkWidget *) gtk_check_button_new ();
1855 gtk_toggle_button_set_active ((GtkToggleButton *) check1, transform->mirrorAroundX);
1856 gtk_table_attach ((GtkTable *) tableWidget, check1,2,3,12,13,0,0,0,2);
1858 tempWidget = gtk_label_new ("About Y axis:");
1859 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1860 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,1,2,13,14,GTK_EXPAND|GTK_FILL,0,0,0);
1861 check2 = (GtkWidget *) gtk_check_button_new ();
1862 gtk_toggle_button_set_active ((GtkToggleButton *) check2, transform->mirrorAroundY);
1863 gtk_table_attach ((GtkTable *) tableWidget, check2,2,3,13,14,0,0,0,2);
1865 gtk_table_set_row_spacing ((GtkTable *) tableWidget, 14, 8);
1866 gtk_widget_show_all (dialog);
1867 gint result = GTK_RESPONSE_APPLY;
1869 // each time the user selects "apply", update the screen and re-enter the dialog loop
1870 while (result == GTK_RESPONSE_APPLY) {
1871 result = gtk_dialog_run (GTK_DIALOG(dialog));
1872 if (result != GTK_RESPONSE_NONE) {
1873 /* extract all the parameters */
1874 if (screenUnit == (gerbv_unit_t) GERBV_MILS) {
1875 transform->translateX = gtk_spin_button_get_value ((GtkSpinButton *) spin1)/
1876 1000;
1877 transform->translateY = gtk_spin_button_get_value ((GtkSpinButton *) spin2)/
1878 1000;
1880 else if (screen.unit == (gerbv_gui_unit_t) GERBV_MMS) {
1881 transform->translateX = gtk_spin_button_get_value ((GtkSpinButton *) spin1)/
1882 25.4;
1883 transform->translateY = gtk_spin_button_get_value ((GtkSpinButton *) spin2)/
1884 25.4;
1886 else {
1887 transform->translateX = gtk_spin_button_get_value ((GtkSpinButton *) spin1);
1888 transform->translateY = gtk_spin_button_get_value ((GtkSpinButton *) spin2);
1890 transform->scaleX = gtk_spin_button_get_value ((GtkSpinButton *)spin3);
1891 transform->scaleY = gtk_spin_button_get_value ((GtkSpinButton *)spin4);
1892 gint rotationIndex = gtk_combo_box_get_active ((GtkComboBox *)spin5);
1893 if (rotationIndex == 0)
1894 transform->rotation = 0;
1895 else if (rotationIndex == 1)
1896 transform->rotation = 90.0/180*M_PI;
1897 else if (rotationIndex == 2)
1898 transform->rotation = 180.0/180*M_PI;
1899 else if (rotationIndex == 3)
1900 transform->rotation = 270.0/180*M_PI;
1901 transform->mirrorAroundX = gtk_toggle_button_get_active ((GtkToggleButton *) check1);
1902 transform->mirrorAroundY = gtk_toggle_button_get_active ((GtkToggleButton *) check2);
1904 render_refresh_rendered_image_on_screen ();
1905 callbacks_update_layer_tree ();
1908 if (result == GTK_RESPONSE_NONE) {
1909 // revert back to the start values if the user cancelled
1910 *transform = startTransform;
1912 gtk_widget_destroy (dialog);
1914 return;