* rework export svg/pdf/ps functionality to export images with 1:1 scale. Previously...
[geda-gerbv.git] / src / interface.c
bloba5839db9a8f36e67c8df132d5eb1a31108f39f95
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 static GtkWidget *render_combobox;
58 #define WIN_TITLE "Gerbv -- gEDA's Gerber Viewer"
59 #define _(String) (String)
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_create_gui (int req_width, int req_height)
96 GtkWidget *mainWindow;
97 GtkWidget *vbox1;
98 GtkWidget *menubar1;
100 GtkWidget *menuitem_file;
101 GtkWidget *menuitem_file_menu;
102 GtkWidget *new;
103 GtkWidget *open_project;
104 GtkWidget *image33;
105 GtkWidget *open_layer;
106 GtkWidget *revert;
107 GtkWidget *save;
108 GtkWidget *save_as;
109 GtkWidget *save_layer;
110 GtkWidget *save_as_layer;
111 GtkWidget *separatormenuitem1;
112 GtkWidget *export;
113 GtkWidget *export_menu;
114 GtkWidget *png;
115 GtkWidget *separator1;
116 GtkWidget *quit;
117 GtkWidget *backgroundColor;
119 GtkWidget *menuitem_edit;
120 GtkWidget *menuitem_edit_menu;
121 GtkWidget *delete_selected, *modify_selected;
123 GtkWidget *menuitem_view;
124 GtkWidget *menuitem_view_menu;
125 GtkWidget *zoom_in;
126 GtkWidget *zoom_out;
127 GtkWidget *separator5;
128 GtkWidget *fit_to_window;
129 GtkWidget *menuitem_analyze;
130 GtkWidget *menuitem_analyze_menu;
131 GtkWidget *analyze_active_gerbers;
132 GtkWidget *analyze_active_drill;
133 GtkWidget *analyze_display_selected_obj_props;
134 GtkWidget *analyze_benchmark;
136 GtkWidget *control_gerber_options;
138 GtkWidget *menubar_tools;
139 GtkWidget *menubar_tools_menu;
140 GtkWidget *toggletoolbutton_pointer;
141 GtkWidget *pointer_tool;
142 GdkPixbuf *pointerpixbuf;
143 GtkWidget *pointerimage;
144 GtkWidget *pan_tool;
145 GtkWidget *zoom_tool;
146 GtkWidget *measure_tool;
147 GtkWidget *menuitem10;
148 GtkWidget *menuitem10_menu;
149 /*GtkWidget *online_manual;*/
150 GtkWidget *about;
151 GtkWidget *bugs_menuitem;
152 GtkWidget *image34;
153 GtkWidget *toolbar_hbox;
154 GtkWidget *handlebox;
155 GtkWidget *button_toolbar;
156 GtkIconSize tmp_toolbar_icon_size;
157 GtkWidget *toolbutton_new;
158 GtkWidget *toolbutton_open;
159 GtkWidget *toolbutton_revert;
160 GtkWidget *toolbutton_save;
161 GtkWidget *separatortoolitem1;
162 #if GTK_CHECK_VERSION(2,10,0)
163 GtkWidget *print;
164 GtkWidget *toolbutton_print;
165 GtkWidget *separator2;
166 GtkWidget *separatortoolitem2;
167 #endif
168 GtkWidget *toolbutton_zoom_in;
169 GtkWidget *toolbutton_zoom_out;
170 GtkWidget *toolbutton_zoom_fit;
171 /* Implement these tool buttons later when we have icons */
172 /* GtkWidget *separatortoolitem3; */
173 /* GtkWidget *toolbutton_analyze; */
174 /* GtkWidget *toolbutton_validate;*/
175 /* GtkWidget *toolbutton_control; */
176 GtkWidget *separatortoolitem4;
177 GtkWidget *toggletoolbutton_pan;
178 GtkWidget *toggletoolbutton_zoom;
179 GtkWidget *toggletoolbutton_measure;
180 GtkWidget *hpaned1;
181 GtkWidget *sidepane_vbox;
182 GtkWidget *sidepane_notebook;
183 GtkWidget *vbox10;
184 GtkWidget *hbox4;
185 GtkWidget *label1;
186 GtkWidget *scrolledwindow1;
187 GtkWidget *hbox1;
188 GtkWidget *button4;
189 GtkWidget *image8;
190 GtkWidget *button5;
191 GtkWidget *image9;
192 GtkWidget *button6;
193 GtkWidget *image10;
194 GtkWidget *button7;
195 GtkWidget *image11;
196 GtkWidget *Layer_label;
197 GtkWidget *vbox11;
198 GtkWidget *messages_scrolledwindow;
199 GtkWidget *message_textview;
200 GtkWidget *clear_messages_button;
201 GtkWidget *Message_label;
202 GtkWidget *vbox2;
203 GtkWidget *main_view_table;
204 GtkWidget *hRuler;
205 GtkWidget *vRuler;
206 GtkWidget *hbox5;
207 GtkWidget *statusbar_label_left;
208 GtkWidget *combobox2;
209 GtkWidget *statusbar_label_right;
210 GtkWidget *drawingarea, *hAdjustment, *vAdjustment, *hScrollbar, *vScrollbar;
212 GtkAccelGroup *accel_group;
213 GtkTooltips *tooltips;
215 /* Inline icons */
216 GdkPixbuf *zoompixbuf;
217 GtkWidget *zoomimage;
218 GdkPixbuf *measurepixbuf;
219 GtkWidget *measureimage;
220 GdkPixbuf *movepixbuf;
221 GtkWidget *moveimage;
223 GtkWidget *tempImage;
224 GtkWidget *tempMenuItem;
226 GtkStockItem item;
227 pointerpixbuf = gdk_pixbuf_new_from_inline(-1, pointer, FALSE, NULL);
228 movepixbuf = gdk_pixbuf_new_from_inline(-1, move, FALSE, NULL);
229 zoompixbuf = gdk_pixbuf_new_from_inline(-1, lzoom, FALSE, NULL);
230 measurepixbuf = gdk_pixbuf_new_from_inline(-1, ruler, FALSE, NULL);
232 tooltips = gtk_tooltips_new();
233 accel_group = gtk_accel_group_new ();
235 mainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
236 gtk_window_set_title (GTK_WINDOW (mainWindow), _("Gerbv -- gEDA's Gerber Viewer"));
238 vbox1 = gtk_vbox_new (FALSE, 0);
239 gtk_container_add (GTK_CONTAINER (mainWindow), vbox1);
241 menubar1 = gtk_menu_bar_new ();
242 gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0);
244 /* --- File menu --- */
245 menuitem_file = gtk_menu_item_new_with_mnemonic (_("_File"));
246 gtk_container_add (GTK_CONTAINER (menubar1), menuitem_file);
248 /* File menu items dealing with a gerbv project. */
249 menuitem_file_menu = gtk_menu_new ();
250 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_file), menuitem_file_menu);
252 new = gtk_image_menu_item_new_from_stock ("gtk-new", accel_group);
253 gtk_tooltips_set_tip (tooltips, new, "Close all layers and start a new project", NULL);
254 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), new);
255 gtk_widget_add_accelerator (new, "activate", accel_group,
256 GDK_n, (GdkModifierType) GDK_CONTROL_MASK,
257 GTK_ACCEL_VISIBLE);
260 open_project = gtk_image_menu_item_new_with_mnemonic (_("_Open Project..."));
261 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), open_project);
262 gtk_tooltips_set_tip (tooltips, open_project, "Open an existing Gerbv project", NULL);
263 image33 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU);
264 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (open_project), image33);
266 save = gtk_image_menu_item_new_with_mnemonic ("Save Project");
267 gtk_tooltips_set_tip (tooltips, save, "Save the current project", NULL);
268 tempImage = gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_MENU);
269 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (save), tempImage);
270 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), save);
272 save_as = gtk_image_menu_item_new_with_mnemonic ("Save Project As...");
273 gtk_tooltips_set_tip (tooltips, save_as, "Save the current project to a new file", NULL);
274 tempImage = gtk_image_new_from_stock ("gtk-save-as", GTK_ICON_SIZE_MENU);
275 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (save_as), tempImage);
276 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), save_as);
278 revert = gtk_image_menu_item_new_from_stock ("gtk-revert-to-saved", accel_group);
279 gtk_tooltips_set_tip (tooltips, revert, "Reload all layers", NULL);
280 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), revert);
282 /* File menu items dealing individual layers. */
283 separator1 = gtk_separator_menu_item_new ();
284 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), separator1);
285 gtk_widget_set_sensitive (separator1, FALSE);
287 open_layer = gtk_menu_item_new_with_mnemonic (_("Open _Layer(s)..."));
288 gtk_widget_add_accelerator (open_layer, "activate", accel_group, 'O', GDK_CONTROL_MASK,
289 GTK_ACCEL_VISIBLE);
290 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), open_layer);
291 gtk_tooltips_set_tip (tooltips, open_layer, "Open Gerber, drill, or pick and place file(s)", NULL);
293 save_layer = gtk_menu_item_new_with_mnemonic (_("_Save active layer"));
294 gtk_tooltips_set_tip (tooltips, save_layer, "Save the active layer", NULL);
295 gtk_widget_add_accelerator (save_layer, "activate", accel_group, 'S', GDK_CONTROL_MASK,
296 GTK_ACCEL_VISIBLE);
297 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), save_layer);
299 save_as_layer = gtk_menu_item_new_with_mnemonic (_("Save active layer _As..."));
300 gtk_tooltips_set_tip (tooltips, save_as_layer, "Save the active layer to a new file", NULL);
301 gtk_widget_add_accelerator (save_as_layer, "activate", accel_group, 'S',
302 GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
303 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), save_as_layer);
305 /* File menu items dealing with exporting different types of files. */
306 separatormenuitem1 = gtk_separator_menu_item_new ();
307 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), separatormenuitem1);
308 gtk_widget_set_sensitive (separatormenuitem1, FALSE);
310 export = gtk_menu_item_new_with_mnemonic (_("_Export"));
311 gtk_tooltips_set_tip (tooltips, export, "Export all visible layers to a new format", NULL);
312 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), export);
314 export_menu = gtk_menu_new ();
315 gtk_menu_item_set_submenu (GTK_MENU_ITEM (export), export_menu);
317 png = gtk_menu_item_new_with_mnemonic (_("PNG..."));
318 gtk_container_add (GTK_CONTAINER (export_menu), png);
319 gtk_tooltips_set_tip (tooltips, png, _("Export project to a PNG file..."), NULL);
321 GtkWidget *rs274x,*drill;
322 GtkWidget *pdf;
323 GtkWidget *svg;
324 GtkWidget *postscript;
326 pdf = gtk_menu_item_new_with_mnemonic (_("PDF..."));
327 gtk_container_add (GTK_CONTAINER (export_menu), pdf);
328 gtk_tooltips_set_tip (tooltips, pdf, _("Export project to a PDF file..."), NULL);
330 svg = gtk_menu_item_new_with_mnemonic (_("SVG..."));
331 gtk_container_add (GTK_CONTAINER (export_menu), svg);
332 gtk_tooltips_set_tip (tooltips, svg, _("Export project to a SVG file"), NULL);
334 postscript = gtk_menu_item_new_with_mnemonic (_("PostScript..."));
335 gtk_container_add (GTK_CONTAINER (export_menu), postscript);
336 gtk_tooltips_set_tip (tooltips, postscript, _("Export project to a PostScript file"), NULL);
337 rs274x = gtk_menu_item_new_with_mnemonic (_("RS-274X (Gerber)..."));
338 gtk_container_add (GTK_CONTAINER (export_menu), rs274x);
339 gtk_tooltips_set_tip (tooltips, rs274x, _("Export layer to a RS-274X (Gerber) file"), NULL);
341 drill = gtk_menu_item_new_with_mnemonic (_("Excellon drill..."));
342 gtk_container_add (GTK_CONTAINER (export_menu), drill);
343 gtk_tooltips_set_tip (tooltips, drill, _("Export layer to an Excellon drill file"), NULL);
345 /* File menu items dealing with printing and quitting. */
346 separator1 = gtk_separator_menu_item_new ();
347 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), separator1);
348 gtk_widget_set_sensitive (separator1, FALSE);
349 #if GTK_CHECK_VERSION(2,10,0)
350 if (gtk_stock_lookup("gtk-print", &item)) {
351 gchar new[] = "_Print...";
352 item.label = new;
353 gtk_stock_add(&item, 1);
356 print = gtk_image_menu_item_new_from_stock ("gtk-print", accel_group);
357 gtk_tooltips_set_tip (tooltips, print, "Print the visible layers", NULL);
358 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), print);
360 separator2 = gtk_separator_menu_item_new ();
361 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), separator2);
362 gtk_widget_set_sensitive (separator2, FALSE);
363 #endif
364 quit = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
365 gtk_tooltips_set_tip (tooltips, quit, "Quit Gerbv", NULL);
366 gtk_container_add (GTK_CONTAINER (menuitem_file_menu), quit);
368 /* --- Next menu item (Edit) --- */
369 menuitem_edit = gtk_menu_item_new_with_mnemonic (_("_Edit"));
370 gtk_container_add (GTK_CONTAINER (menubar1), menuitem_edit);
372 menuitem_edit_menu = gtk_menu_new ();
373 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_edit), menuitem_edit_menu);
375 delete_selected = gtk_image_menu_item_new_with_mnemonic (_("_Delete selected object(s)"));
376 gtk_tooltips_set_tip (tooltips, delete_selected,
377 "Delete selected objects", NULL);
378 tempImage = gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_MENU);
379 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (delete_selected), tempImage);
380 gtk_container_add (GTK_CONTAINER (menuitem_edit_menu), delete_selected);
381 gtk_widget_add_accelerator (delete_selected, "activate", accel_group,
382 GDK_Delete, (GdkModifierType) 0, GTK_ACCEL_VISIBLE);
384 modify_selected = gtk_menu_item_new_with_mnemonic (_("_Modify layer orientation"));
385 gtk_tooltips_set_tip (tooltips, delete_selected,
386 "Translate, zoom, rotate, or mirror the active layer", NULL);
387 gtk_container_add (GTK_CONTAINER (menuitem_edit_menu), modify_selected);
389 /* --- Next menu item --- */
390 menuitem_view = gtk_menu_item_new_with_mnemonic (_("_View"));
391 gtk_container_add (GTK_CONTAINER (menubar1), menuitem_view);
393 menuitem_view_menu = gtk_menu_new ();
394 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_view), menuitem_view_menu);
396 zoom_in = gtk_image_menu_item_new_from_stock ("gtk-zoom-in", accel_group);
397 gtk_tooltips_set_tip (tooltips, zoom_in, "Zoom in", NULL);
398 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), zoom_in);
399 gtk_widget_add_accelerator (zoom_in, "activate", accel_group,
400 GDK_z, (GdkModifierType) 0, GTK_ACCEL_VISIBLE);
402 zoom_out = gtk_image_menu_item_new_from_stock ("gtk-zoom-out", accel_group);
403 gtk_tooltips_set_tip (tooltips, zoom_out, "Zoom out", NULL);
404 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), zoom_out);
405 gtk_widget_add_accelerator (zoom_out, "activate", accel_group,
406 GDK_z, (GdkModifierType) GDK_SHIFT_MASK,
407 GTK_ACCEL_VISIBLE);
409 fit_to_window = gtk_image_menu_item_new_from_stock ("gtk-zoom-fit", accel_group);
410 gtk_tooltips_set_tip (tooltips, fit_to_window, "Zoom to fit all visible layers in the window", NULL);
411 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), fit_to_window);
412 gtk_widget_add_accelerator (fit_to_window, "activate", accel_group,
413 GDK_f, (GdkModifierType) 0,
414 GTK_ACCEL_VISIBLE);
416 separator5 = gtk_separator_menu_item_new ();
417 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), separator5);
418 gtk_widget_set_sensitive (separator5, FALSE);
420 backgroundColor = gtk_menu_item_new_with_mnemonic ("Change background color");
421 gtk_tooltips_set_tip (tooltips, backgroundColor, "Change the background color", NULL);
422 gtk_container_add (GTK_CONTAINER (menuitem_view_menu), backgroundColor);
424 menuitem_analyze = gtk_menu_item_new_with_mnemonic (_("_Analyze"));
425 gtk_container_add (GTK_CONTAINER (menubar1), menuitem_analyze);
427 menuitem_analyze_menu = gtk_menu_new ();
428 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_analyze), menuitem_analyze_menu);
430 analyze_active_gerbers = gtk_menu_item_new_with_mnemonic (_("Analyze visible _Gerber layers"));
431 gtk_tooltips_set_tip (tooltips, analyze_active_gerbers,
432 "Examine a detailed anaylsis of the contents of all visible Gerber layers", NULL);
433 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu), analyze_active_gerbers);
435 analyze_active_drill = gtk_menu_item_new_with_mnemonic (_("Analyze visible _drill layers"));
436 gtk_tooltips_set_tip (tooltips, analyze_active_drill,
437 "Examine a detailed anaylsis of the contents of all visible drill layers", NULL);
438 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu), analyze_active_drill);
441 analyze_display_selected_obj_props = gtk_menu_item_new_with_mnemonic (_("Display selected object(s) _properties"));
442 gtk_tooltips_set_tip (tooltips, analyze_display_selected_obj_props,
443 "Show the properties of the selected object(s).", NULL);
444 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu), analyze_display_selected_obj_props);
445 gtk_widget_add_accelerator (analyze_display_selected_obj_props,
446 "activate", accel_group, GDK_q, (GdkModifierType) 0,
447 GTK_ACCEL_VISIBLE);
449 analyze_benchmark = gtk_menu_item_new_with_mnemonic (_("_Benchmark"));
450 gtk_tooltips_set_tip (tooltips, analyze_benchmark,
451 "Show the properties of the selected object(s).", NULL);
452 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu), analyze_benchmark);
455 /* Wait and add in for 2.1??
456 control_gerber_options = gtk_menu_item_new_with_mnemonic (_("Control Gerber options..."));
457 gtk_tooltips_set_tip (tooltips, control_gerber_options, "Set which Gerber features should be displayed", NULL);
458 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu), control_gerber_options);
460 menubar_tools = gtk_menu_item_new_with_mnemonic (_("_Tools"));
461 gtk_container_add (GTK_CONTAINER (menubar1), menubar_tools);
463 menubar_tools_menu = gtk_menu_new ();
464 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menubar_tools), menubar_tools_menu);
465 pointer_tool = gtk_image_menu_item_new_with_mnemonic (_("_Pointer Tool"));
467 GtkWidget *tempImage = gtk_image_new_from_pixbuf (pointerpixbuf);
468 gtk_image_menu_item_set_image ((GtkImageMenuItem *)pointer_tool, tempImage);
470 gtk_container_add (GTK_CONTAINER (menubar_tools_menu), pointer_tool);
471 gtk_tooltips_set_tip (tooltips, pointer_tool, "Select objects on the screen", NULL);
472 gtk_widget_add_accelerator (pointer_tool, "activate", accel_group,
473 GDK_F1, (GdkModifierType) 0,
474 GTK_ACCEL_VISIBLE);
475 pan_tool = gtk_image_menu_item_new_with_mnemonic ("Pa_n Tool");
477 tempImage = gtk_image_new_from_pixbuf (movepixbuf);
478 gtk_image_menu_item_set_image ((GtkImageMenuItem *)pan_tool, tempImage);
480 gtk_container_add (GTK_CONTAINER (menubar_tools_menu), pan_tool);
481 gtk_tooltips_set_tip (tooltips, pan_tool, "Pan by left clicking and dragging", NULL);
482 gtk_widget_add_accelerator (pan_tool, "activate", accel_group,
483 GDK_F2, (GdkModifierType) 0,
484 GTK_ACCEL_VISIBLE);
486 zoom_tool = gtk_image_menu_item_new_with_mnemonic (_("_Zoom Tool"));
488 tempImage = gtk_image_new_from_pixbuf (zoompixbuf);
489 gtk_image_menu_item_set_image ((GtkImageMenuItem *)zoom_tool, tempImage);
491 gtk_container_add (GTK_CONTAINER (menubar_tools_menu), zoom_tool);
492 gtk_tooltips_set_tip (tooltips, zoom_tool, "Zoom by left clicking or dragging", NULL);
493 gtk_widget_add_accelerator (zoom_tool, "activate", accel_group,
494 GDK_F3, (GdkModifierType) 0,
495 GTK_ACCEL_VISIBLE);
497 measure_tool = gtk_image_menu_item_new_with_mnemonic (_("_Measure Tool"));
499 tempImage = gtk_image_new_from_pixbuf (measurepixbuf);
500 gtk_image_menu_item_set_image ((GtkImageMenuItem *)measure_tool, tempImage);
502 gtk_container_add (GTK_CONTAINER (menubar_tools_menu), measure_tool);
503 gtk_tooltips_set_tip (tooltips, measure_tool, "Measure distances on the screen", NULL);
504 gtk_widget_add_accelerator (measure_tool, "activate", accel_group,
505 GDK_F4, (GdkModifierType) 0,
506 GTK_ACCEL_VISIBLE);
508 menuitem10 = gtk_menu_item_new_with_mnemonic (_("_Help"));
509 gtk_container_add (GTK_CONTAINER (menubar1), menuitem10);
511 menuitem10_menu = gtk_menu_new ();
512 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem10), menuitem10_menu);
513 /* Not ready for 2.0
514 online_manual = gtk_menu_item_new_with_mnemonic (_("_Online Manual..."));
515 gtk_container_add (GTK_CONTAINER (menuitem10_menu), online_manual);
516 gtk_tooltips_set_tip (tooltips, online_manual, "View the online help documentation", NULL);
520 about = gtk_image_menu_item_new_with_mnemonic (_("_About Gerbv..."));
521 gtk_container_add (GTK_CONTAINER (menuitem10_menu), about);
522 gtk_tooltips_set_tip (tooltips, about, "View information about gerbv", NULL);
523 image34 = gtk_image_new_from_stock ("gtk-dialog-info", GTK_ICON_SIZE_MENU);
524 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (about), image34);
526 bugs_menuitem = gtk_menu_item_new_with_mnemonic (_("Known _bugs in this version..."));
527 gtk_container_add (GTK_CONTAINER (menuitem10_menu), bugs_menuitem);
528 gtk_tooltips_set_tip (tooltips, bugs_menuitem, "View list of known gerbv bugs", NULL);
530 /* Create toolbar (button bar) beneath main menu */
531 toolbar_hbox = gtk_hbox_new (FALSE, 0);
532 gtk_box_pack_start (GTK_BOX (vbox1), toolbar_hbox, FALSE, FALSE, 0);
534 handlebox = gtk_handle_box_new ();
536 gtk_box_pack_start (GTK_BOX (toolbar_hbox), handlebox, TRUE, TRUE, 0);
538 button_toolbar = gtk_toolbar_new ();
539 gtk_widget_set_size_request (button_toolbar, 500, -1);
540 gtk_container_add (GTK_CONTAINER (handlebox), button_toolbar);
541 gtk_toolbar_set_style (GTK_TOOLBAR (button_toolbar), GTK_TOOLBAR_ICONS);
542 tmp_toolbar_icon_size = gtk_toolbar_get_icon_size (GTK_TOOLBAR (button_toolbar));
544 toolbutton_new = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-new");
545 gtk_tooltips_set_tip (tooltips, toolbutton_new, "Close all layers and start a new project", NULL);
546 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_new);
548 toolbutton_open = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-open");
549 gtk_tooltips_set_tip (tooltips, toolbutton_open, "Open a previously saved gerbv project", NULL);
550 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_open);
552 toolbutton_revert = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-revert-to-saved");
553 gtk_tooltips_set_tip (tooltips, toolbutton_revert, "Reload all layers in project", NULL);
554 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_revert);
556 toolbutton_save = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-save");
557 gtk_tooltips_set_tip (tooltips, toolbutton_save, "Save the current project", NULL);
558 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_save);
560 separatortoolitem1 = (GtkWidget*) gtk_separator_tool_item_new ();
561 gtk_container_add (GTK_CONTAINER (button_toolbar), separatortoolitem1);
562 #if GTK_CHECK_VERSION(2,10,0)
563 toolbutton_print = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-print");
564 gtk_tooltips_set_tip (tooltips, toolbutton_print, "Print the visible layers", NULL);
565 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_print);
567 separatortoolitem2 = (GtkWidget*) gtk_separator_tool_item_new ();
568 gtk_container_add (GTK_CONTAINER (button_toolbar), separatortoolitem2);
569 #endif
570 toolbutton_zoom_in = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-zoom-in");
571 gtk_tooltips_set_tip (tooltips, toolbutton_zoom_in, "Zoom in", NULL);
572 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_zoom_in);
574 toolbutton_zoom_out = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-zoom-out");
575 gtk_tooltips_set_tip (tooltips, toolbutton_zoom_out, "Zoom out", NULL);
576 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_zoom_out);
578 toolbutton_zoom_fit = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-zoom-fit");
579 gtk_tooltips_set_tip (tooltips, toolbutton_zoom_fit, "Zoom to fit all visible layers in the window", NULL);
580 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_zoom_fit);
582 /* Turn these on later when we have icons for these buttons */
584 separatortoolitem3 = (GtkWidget*) gtk_separator_tool_item_new ();
585 gtk_container_add (GTK_CONTAINER (button_toolbar), separatortoolitem3);
587 toolbutton_analyze = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-apply");
588 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_analyze);
590 toolbutton_validate = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-apply");
591 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_validate);
593 toolbutton_control = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-apply");
594 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_control);
597 separatortoolitem4 = (GtkWidget*) gtk_separator_tool_item_new ();
598 gtk_container_add (GTK_CONTAINER (button_toolbar), separatortoolitem4);
599 toggletoolbutton_pointer = (GtkWidget*) gtk_toggle_tool_button_new();
600 pointerimage = gtk_image_new_from_pixbuf(pointerpixbuf);
601 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_pointer),
602 pointerimage);
603 gtk_tooltips_set_tip (tooltips, toggletoolbutton_pointer, "Select objects on the screen", NULL);
604 gtk_container_add (GTK_CONTAINER (button_toolbar), toggletoolbutton_pointer);
605 toggletoolbutton_pan = (GtkWidget*) gtk_toggle_tool_button_new();
606 moveimage = gtk_image_new_from_pixbuf(movepixbuf);
607 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_pan),
608 moveimage);
609 gtk_tooltips_set_tip (tooltips, toggletoolbutton_pan, "Pan by left clicking and dragging", NULL);
610 gtk_container_add (GTK_CONTAINER (button_toolbar), toggletoolbutton_pan);
613 toggletoolbutton_zoom = (GtkWidget*) gtk_toggle_tool_button_new();
614 zoomimage = gtk_image_new_from_pixbuf(zoompixbuf);
615 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_zoom),
616 zoomimage);
617 gtk_tooltips_set_tip (tooltips, toggletoolbutton_zoom, "Zoom by left clicking or dragging", NULL);
618 gtk_container_add (GTK_CONTAINER (button_toolbar), toggletoolbutton_zoom);
620 toggletoolbutton_measure = (GtkWidget*) gtk_toggle_tool_button_new();
621 measureimage = gtk_image_new_from_pixbuf(measurepixbuf);
622 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_measure),
623 measureimage);
624 gtk_tooltips_set_tip (tooltips, toggletoolbutton_measure, "Measure distances on the screen", NULL);
625 gtk_container_add (GTK_CONTAINER (button_toolbar), toggletoolbutton_measure);
627 hpaned1 = gtk_hpaned_new ();
628 gtk_box_pack_start (GTK_BOX (vbox1), hpaned1, TRUE, TRUE, 0);
629 gtk_paned_set_position (GTK_PANED (hpaned1), 225);
631 sidepane_vbox = gtk_vbox_new (FALSE, 0);
632 gtk_widget_set_size_request (sidepane_vbox, 150, -1);
634 gtk_paned_pack1 (GTK_PANED (hpaned1), sidepane_vbox, TRUE, FALSE);
635 gtk_container_set_border_width (GTK_CONTAINER (sidepane_vbox), 5);
637 sidepane_notebook = gtk_notebook_new ();
638 gtk_widget_set_size_request (sidepane_notebook, 100, -1);
639 gtk_box_pack_start (GTK_BOX (sidepane_vbox), sidepane_notebook, TRUE, TRUE, 0);
641 vbox10 = gtk_vbox_new (FALSE, 3);
642 gtk_container_add (GTK_CONTAINER (sidepane_notebook), vbox10);
643 gtk_widget_set_size_request (vbox10, 82, -1);
644 gtk_container_set_border_width (GTK_CONTAINER (vbox10), 4);
646 hbox4 = gtk_hbox_new (FALSE, 0);
647 gtk_box_pack_start (GTK_BOX (vbox10), hbox4, FALSE, FALSE, 0);
649 label1 = gtk_label_new (_("Rendering: "));
650 gtk_box_pack_start (GTK_BOX (hbox4), label1, FALSE, FALSE, 0);
652 render_combobox = gtk_combo_box_new_text ();
653 gtk_box_pack_start (GTK_BOX (hbox4), render_combobox, TRUE, TRUE, 0);
655 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox), _("Fast"));
656 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox), _("Fast, with XOR"));
657 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox), _("Normal"));
658 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox), _("High quality"));
659 if (screenRenderInfo.renderType < 4)
660 gtk_combo_box_set_active (GTK_COMBO_BOX (render_combobox), screenRenderInfo.renderType);
662 scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
663 gtk_box_pack_start (GTK_BOX (vbox10), scrolledwindow1, TRUE, TRUE, 0);
664 gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow1), 2);
665 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1),
666 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
667 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1),
668 GTK_SHADOW_IN);
670 hbox1 = gtk_hbox_new (TRUE, 0);
671 gtk_box_pack_start (GTK_BOX (vbox10), hbox1, FALSE, FALSE, 0);
673 button4 = gtk_button_new ();
674 gtk_box_pack_start (GTK_BOX (hbox1), button4, FALSE, TRUE, 0);
676 image8 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_BUTTON);
677 gtk_container_add (GTK_CONTAINER (button4), image8);
679 button5 = gtk_button_new ();
680 gtk_box_pack_start (GTK_BOX (hbox1), button5, FALSE, TRUE, 0);
682 image9 = gtk_image_new_from_stock ("gtk-go-down", GTK_ICON_SIZE_BUTTON);
683 gtk_container_add (GTK_CONTAINER (button5), image9);
685 button6 = gtk_button_new ();
686 gtk_box_pack_start (GTK_BOX (hbox1), button6, FALSE, TRUE, 0);
688 image10 = gtk_image_new_from_stock ("gtk-go-up", GTK_ICON_SIZE_BUTTON);
689 gtk_container_add (GTK_CONTAINER (button6), image10);
691 button7 = gtk_button_new ();
692 gtk_box_pack_start (GTK_BOX (hbox1), button7, FALSE, TRUE, 0);
694 image11 = gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_BUTTON);
695 gtk_container_add (GTK_CONTAINER (button7), image11);
697 Layer_label = gtk_label_new (_("Layers"));
698 gtk_notebook_set_tab_label (GTK_NOTEBOOK (sidepane_notebook),
699 gtk_notebook_get_nth_page (GTK_NOTEBOOK (sidepane_notebook), 0),
700 Layer_label);
702 vbox11 = gtk_vbox_new (FALSE, 2);
703 gtk_container_add (GTK_CONTAINER (sidepane_notebook), vbox11);
704 gtk_container_set_border_width (GTK_CONTAINER (vbox11), 3);
706 messages_scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
707 gtk_box_pack_start (GTK_BOX (vbox11), messages_scrolledwindow, TRUE, TRUE, 0);
708 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (messages_scrolledwindow),
709 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
711 message_textview = gtk_text_view_new ();
712 gtk_container_add (GTK_CONTAINER (messages_scrolledwindow), message_textview);
713 gtk_text_view_set_editable (GTK_TEXT_VIEW (message_textview), FALSE);
714 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (message_textview), GTK_WRAP_WORD);
715 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (message_textview), FALSE);
717 clear_messages_button = gtk_button_new_from_stock ("gtk-clear");
718 gtk_box_pack_start (GTK_BOX (vbox11), clear_messages_button, FALSE, FALSE, 0);
720 Message_label = gtk_label_new (_("Messages"));
721 gtk_notebook_set_tab_label (GTK_NOTEBOOK (sidepane_notebook),
722 gtk_notebook_get_nth_page (GTK_NOTEBOOK (sidepane_notebook), 1),
723 Message_label);
725 vbox2 = gtk_vbox_new (FALSE, 4);
726 gtk_paned_pack2 (GTK_PANED (hpaned1), vbox2, TRUE, FALSE);
727 gtk_container_set_border_width (GTK_CONTAINER (vbox2), 4);
729 main_view_table = gtk_table_new (3, 3, FALSE);
730 gtk_box_pack_start (GTK_BOX (vbox2), main_view_table, TRUE, TRUE, 0);
732 hRuler = gtk_hruler_new ();
733 gtk_table_attach (GTK_TABLE (main_view_table), hRuler, 1, 2, 0, 1,
734 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
735 (GtkAttachOptions) (GTK_FILL), 0, 0);
736 gtk_ruler_set_range (GTK_RULER (hRuler), 0, 100, 8.56051, 1000);
738 vRuler = gtk_vruler_new ();
739 gtk_table_attach (GTK_TABLE (main_view_table), vRuler, 0, 1, 1, 2,
740 (GtkAttachOptions) (GTK_FILL),
741 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
742 gtk_ruler_set_range (GTK_RULER (vRuler), 0, 100, 8.37341, 1000);
744 drawingarea = gtk_drawing_area_new();
745 gtk_table_attach (GTK_TABLE (main_view_table), drawingarea, 1, 2, 1, 2,
746 (GtkAttachOptions) (GTK_FILL),
747 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
749 hAdjustment = (GtkWidget *) gtk_adjustment_new (0.0, -1000.0, 1000.0, 1000.0, 1000.0, 500.0);
750 vAdjustment = (GtkWidget *) gtk_adjustment_new (0.0, -1000.0, 1000.0, 1000.0, 1000.0, 500.0);
752 hScrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (hAdjustment));
753 gtk_table_attach (GTK_TABLE (main_view_table), hScrollbar, 1, 2, 2, 3,
754 (GtkAttachOptions) (GTK_FILL),
755 (GtkAttachOptions) (GTK_FILL), 0, 0);
757 vScrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (vAdjustment));
758 gtk_table_attach (GTK_TABLE (main_view_table), vScrollbar, 2, 3, 1, 2,
759 (GtkAttachOptions) (GTK_FILL),
760 (GtkAttachOptions) (GTK_FILL), 0, 0);
762 hbox5 = gtk_hbox_new (FALSE, 10);
763 gtk_box_pack_start (GTK_BOX (vbox2), hbox5, FALSE, FALSE, 0);
765 statusbar_label_left = gtk_label_new ("( 0.0, 0.0 )");
766 gtk_box_pack_start (GTK_BOX (hbox5), statusbar_label_left, FALSE, FALSE, 0);
767 gtk_widget_set_size_request (statusbar_label_left, 130, -1);
768 gtk_label_set_justify ((GtkLabel *) statusbar_label_left, GTK_JUSTIFY_RIGHT);
770 combobox2 = gtk_combo_box_new_text ();
771 gtk_box_pack_start (GTK_BOX (hbox5), combobox2, FALSE, FALSE, 0);
772 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox2), _("mil"));
773 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox2), _("mm"));
774 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox2), _("in"));
776 statusbar_label_right = gtk_label_new (_(""));
777 gtk_box_pack_start (GTK_BOX (hbox5), statusbar_label_right, TRUE, TRUE, 0);
778 gtk_label_set_ellipsize ((GtkLabel *)statusbar_label_right, PANGO_ELLIPSIZE_END);
779 gtk_misc_set_alignment (GTK_MISC (statusbar_label_right), 0, 0.5);
784 * Connect signals to widgets
787 /* --- File menu --- */
788 g_signal_connect ((gpointer) new, "activate",
789 G_CALLBACK (callbacks_new_activate),
790 NULL);
791 g_signal_connect ((gpointer) open_project, "activate",
792 G_CALLBACK (callbacks_open_project_activate),
793 NULL);
794 g_signal_connect ((gpointer) open_layer, "activate",
795 G_CALLBACK (callbacks_open_layer_activate),
796 NULL);
797 g_signal_connect ((gpointer) revert, "activate",
798 G_CALLBACK (callbacks_revert_activate),
799 NULL);
800 g_signal_connect ((gpointer) save_layer, "activate",
801 G_CALLBACK (callbacks_save_layer_activate),
802 NULL);
803 g_signal_connect ((gpointer) save_as_layer, "activate",
804 G_CALLBACK (callbacks_generic_save_activate),
805 (gpointer) CALLBACKS_SAVE_LAYER_AS);
806 g_signal_connect ((gpointer) save, "activate",
807 G_CALLBACK (callbacks_save_project_activate),
808 NULL);
809 g_signal_connect ((gpointer) save_as, "activate",
810 G_CALLBACK (callbacks_generic_save_activate),
811 (gpointer) CALLBACKS_SAVE_PROJECT_AS);
812 g_signal_connect ((gpointer) png, "activate",
813 G_CALLBACK (callbacks_generic_save_activate),
814 (gpointer) CALLBACKS_SAVE_FILE_PNG);
816 g_signal_connect ((gpointer) pdf, "activate",
817 G_CALLBACK (callbacks_generic_save_activate),
818 (gpointer) CALLBACKS_SAVE_FILE_PDF);
819 g_signal_connect ((gpointer) svg, "activate",
820 G_CALLBACK (callbacks_generic_save_activate),
821 (gpointer) CALLBACKS_SAVE_FILE_SVG);
822 g_signal_connect ((gpointer) postscript, "activate",
823 G_CALLBACK (callbacks_generic_save_activate),
824 (gpointer) CALLBACKS_SAVE_FILE_PS);
825 g_signal_connect ((gpointer) rs274x, "activate",
826 G_CALLBACK (callbacks_generic_save_activate),
827 (gpointer) CALLBACKS_SAVE_FILE_RS274X);
828 g_signal_connect ((gpointer) drill, "activate",
829 G_CALLBACK (callbacks_generic_save_activate),
830 (gpointer) CALLBACKS_SAVE_FILE_DRILL);
832 #if GTK_CHECK_VERSION(2,10,0)
833 g_signal_connect ((gpointer) print, "activate",
834 G_CALLBACK (callbacks_print_activate),
835 NULL);
836 #endif
837 g_signal_connect ((gpointer) quit, "activate",
838 G_CALLBACK (callbacks_quit_activate),
839 NULL);
841 /* --- Edit menu --- */
842 g_signal_connect ((gpointer) delete_selected, "activate",
843 G_CALLBACK (callbacks_delete_objects_clicked),
844 NULL);
845 g_signal_connect ((gpointer) modify_selected, "activate",
846 G_CALLBACK (callbacks_change_layer_orientation_clicked),
847 NULL);
849 /* --- View menu --- */
850 g_signal_connect ((gpointer) zoom_in, "activate",
851 G_CALLBACK (callbacks_zoom_in_activate),
852 NULL);
853 g_signal_connect ((gpointer) zoom_out, "activate",
854 G_CALLBACK (callbacks_zoom_out_activate),
855 NULL);
856 g_signal_connect ((gpointer) fit_to_window, "activate",
857 G_CALLBACK (callbacks_fit_to_window_activate),
858 NULL);
859 g_signal_connect ((gpointer) backgroundColor, "activate",
860 G_CALLBACK (callbacks_change_background_color_clicked),
861 NULL);
863 /* --- Analyze menu --- */
864 g_signal_connect ((gpointer) analyze_active_gerbers, "activate",
865 G_CALLBACK (callbacks_analyze_active_gerbers_activate),
866 NULL);
867 g_signal_connect ((gpointer) analyze_active_drill, "activate",
868 G_CALLBACK (callbacks_analyze_active_drill_activate),
869 NULL);
870 g_signal_connect ((gpointer) analyze_display_selected_obj_props, "activate",
871 G_CALLBACK (callbacks_display_object_properties_clicked),
872 NULL);
873 g_signal_connect ((gpointer) analyze_benchmark, "activate",
874 G_CALLBACK (callbacks_benchmark_clicked),
875 NULL);
878 /* Wait for 2.1
879 g_signal_connect ((gpointer) control_gerber_options, "activate",
880 G_CALLBACK (callbacks_control_gerber_options_activate),
881 NULL);
884 /* --- Tools menu --- */
885 g_signal_connect ((gpointer) pointer_tool, "activate",
886 G_CALLBACK (callbacks_change_tool), (gpointer) 0);
887 g_signal_connect ((gpointer) pan_tool, "activate",
888 G_CALLBACK (callbacks_change_tool), (gpointer) 1);
889 g_signal_connect ((gpointer) zoom_tool, "activate",
890 G_CALLBACK (callbacks_change_tool), (gpointer) 2);
891 g_signal_connect ((gpointer) measure_tool, "activate",
892 G_CALLBACK (callbacks_change_tool), (gpointer) 3);
894 /* --- Help menu --- */
896 g_signal_connect ((gpointer) online_manual, "activate",
897 G_CALLBACK (callbacks_online_manual_activate),
898 NULL);
900 g_signal_connect ((gpointer) about, "activate",
901 G_CALLBACK (callbacks_about_activate),
902 NULL);
904 g_signal_connect ((gpointer) bugs_menuitem, "activate",
905 G_CALLBACK (callbacks_bugs_activate),
906 NULL);
908 /* End of Glade generated code */
909 g_signal_connect ((gpointer) toolbutton_new, "clicked",
910 G_CALLBACK (callbacks_new_activate),
911 NULL);
912 g_signal_connect ((gpointer) toolbutton_save, "clicked",
913 G_CALLBACK (callbacks_save_project_activate),
914 NULL);
915 g_signal_connect ((gpointer) toolbutton_open, "clicked",
916 G_CALLBACK (callbacks_open_project_activate),
917 NULL);
918 g_signal_connect ((gpointer) toolbutton_revert, "clicked",
919 G_CALLBACK (callbacks_revert_activate),
920 NULL);
921 g_signal_connect ((gpointer) clear_messages_button, "clicked",
922 G_CALLBACK (callbacks_clear_messages_button_clicked),
923 NULL);
924 #if GTK_CHECK_VERSION(2,10,0)
925 g_signal_connect ((gpointer) toolbutton_print, "clicked",
926 G_CALLBACK (callbacks_print_activate),
927 NULL);
928 #endif
929 g_signal_connect ((gpointer) toolbutton_zoom_in, "clicked",
930 G_CALLBACK (callbacks_zoom_in_activate),
931 NULL);
932 g_signal_connect ((gpointer) toolbutton_zoom_out, "clicked",
933 G_CALLBACK (callbacks_zoom_out_activate),
934 NULL);
935 g_signal_connect ((gpointer) toolbutton_zoom_fit, "clicked",
936 G_CALLBACK (callbacks_fit_to_window_activate),
937 NULL);
938 g_signal_connect ((gpointer) toggletoolbutton_pointer, "clicked",
939 G_CALLBACK (callbacks_change_tool), (gpointer) 0);
940 g_signal_connect ((gpointer) toggletoolbutton_pan, "clicked",
941 G_CALLBACK (callbacks_change_tool), (gpointer) 1);
942 g_signal_connect ((gpointer) toggletoolbutton_zoom, "clicked",
943 G_CALLBACK (callbacks_change_tool), (gpointer) 2);
944 g_signal_connect ((gpointer) toggletoolbutton_measure, "clicked",
945 G_CALLBACK (callbacks_change_tool), (gpointer) 3);
947 g_signal_connect ((gpointer) combobox2, "changed",
948 G_CALLBACK (callbacks_statusbar_unit_combo_box_changed),
949 NULL);
951 g_signal_connect ((gpointer) button4, "clicked",
952 G_CALLBACK (callbacks_add_layer_button_clicked), NULL);
953 g_signal_connect ((gpointer) button7, "clicked",
954 G_CALLBACK (callbacks_remove_layer_button_clicked), NULL);
955 g_signal_connect ((gpointer) button5, "clicked",
956 G_CALLBACK (callbacks_move_layer_down_button_clicked), NULL);
957 g_signal_connect ((gpointer) button6, "clicked",
958 G_CALLBACK (callbacks_move_layer_up_clicked), NULL);
960 g_signal_connect ((gpointer) hAdjustment, "value-changed",
961 G_CALLBACK (callbacks_hadjustment_value_changed), NULL);
962 g_signal_connect ((gpointer) vAdjustment, "value-changed",
963 G_CALLBACK (callbacks_vadjustment_value_changed), NULL);
964 g_signal_connect ((gpointer) hScrollbar, "button-press-event",
965 G_CALLBACK (callbacks_scrollbar_button_pressed), NULL);
966 g_signal_connect ((gpointer) hScrollbar, "button-release-event",
967 G_CALLBACK (callbacks_scrollbar_button_released), NULL);
968 g_signal_connect ((gpointer) vScrollbar, "button-press-event",
969 G_CALLBACK (callbacks_scrollbar_button_pressed), NULL);
970 g_signal_connect ((gpointer) vScrollbar, "button-release-event",
971 G_CALLBACK (callbacks_scrollbar_button_released), NULL);
974 if (screen.unit == GERBV_MILS)
975 gtk_combo_box_set_active (GTK_COMBO_BOX (combobox2), 0);
976 else if (screen.unit == GERBV_MMS)
977 gtk_combo_box_set_active (GTK_COMBO_BOX (combobox2), 1);
978 else
979 gtk_combo_box_set_active (GTK_COMBO_BOX (combobox2), 2);
981 gint width, height;
983 gtk_window_add_accel_group (GTK_WINDOW (mainWindow), accel_group);
985 GtkListStore *list_store;
987 list_store = gtk_list_store_new (4, G_TYPE_BOOLEAN,
988 GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
990 GtkWidget *tree;
992 tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
993 GtkCellRenderer *renderer;
994 GtkTreeViewColumn *column;
996 renderer = gtk_cell_renderer_toggle_new ();
997 column = gtk_tree_view_column_new_with_attributes ("Visible",
998 renderer,
999 "active", 0,
1000 NULL);
1001 gtk_tree_view_column_set_min_width ((GtkTreeViewColumn *)column,25);
1002 gtk_signal_connect(GTK_OBJECT(renderer), "toggled",
1003 GTK_SIGNAL_FUNC(callbacks_layer_tree_visibility_button_toggled), NULL);
1005 gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
1007 renderer = gtk_cell_renderer_pixbuf_new ();
1008 column = gtk_tree_view_column_new_with_attributes ("Color",
1009 renderer,
1010 "pixbuf", 1, NULL);
1011 gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
1013 renderer = gtk_cell_renderer_text_new ();
1014 g_object_set (G_OBJECT (renderer), "foreground", "red", "xalign", 0.5,
1015 "family", "Times", "size-points", 12.0, NULL);
1016 column = gtk_tree_view_column_new_with_attributes ("Modified",
1017 renderer,
1018 "text", 3,
1019 NULL);
1020 gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
1021 gtk_tree_view_column_set_min_width ((GtkTreeViewColumn *)column,20);
1023 renderer = gtk_cell_renderer_text_new ();
1024 column = gtk_tree_view_column_new_with_attributes ("Name",
1025 renderer,
1026 "markup", 2,
1027 NULL);
1028 gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
1030 gtk_tree_view_set_headers_visible ((GtkTreeView *)tree, FALSE);
1031 gtk_signal_connect(GTK_OBJECT(tree), "button-press-event",
1032 GTK_SIGNAL_FUNC(callbacks_layer_tree_button_press), NULL);
1033 gtk_container_add (GTK_CONTAINER (scrolledwindow1), tree);
1035 GtkTreeSelection *selection;
1036 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
1037 gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
1038 gtk_tree_view_set_enable_search (GTK_TREE_VIEW (tree), FALSE);
1039 gtk_tree_view_set_reorderable (GTK_TREE_VIEW (tree), TRUE);
1041 g_signal_connect (G_OBJECT(list_store), "row-inserted",
1042 G_CALLBACK (callbacks_layer_tree_row_inserted), NULL);
1043 /* steal the focus to the tree to make sure none of the buttons are focused */
1044 gtk_widget_grab_focus (tree);
1046 * Connect all events on drawing area
1048 gtk_signal_connect(GTK_OBJECT(drawingarea), "expose_event",
1049 GTK_SIGNAL_FUNC(callbacks_drawingarea_expose_event), NULL);
1050 gtk_signal_connect(GTK_OBJECT(drawingarea),"configure_event",
1051 GTK_SIGNAL_FUNC(callbacks_drawingarea_configure_event), NULL);
1052 gtk_signal_connect(GTK_OBJECT(drawingarea), "motion_notify_event",
1053 GTK_SIGNAL_FUNC(callbacks_drawingarea_motion_notify_event), NULL);
1054 gtk_signal_connect(GTK_OBJECT(drawingarea), "button_press_event",
1055 GTK_SIGNAL_FUNC(callbacks_drawingarea_button_press_event), NULL);
1056 gtk_signal_connect(GTK_OBJECT(drawingarea), "button_release_event",
1057 GTK_SIGNAL_FUNC(callbacks_drawingarea_button_release_event), NULL);
1058 gtk_signal_connect_after(GTK_OBJECT(mainWindow), "key_press_event",
1059 GTK_SIGNAL_FUNC(callbacks_window_key_press_event), NULL);
1060 gtk_signal_connect_after(GTK_OBJECT(mainWindow), "key_release_event",
1061 GTK_SIGNAL_FUNC(callbacks_window_key_release_event), NULL);
1062 gtk_signal_connect_after(GTK_OBJECT(mainWindow), "scroll_event",
1063 GTK_SIGNAL_FUNC(callbacks_window_scroll_event), NULL);
1064 gtk_signal_connect_after(GTK_OBJECT(mainWindow), "delete_event",
1065 GTK_SIGNAL_FUNC(callbacks_quit_activate), NULL);
1067 gtk_widget_set_events(drawingarea, GDK_EXPOSURE_MASK
1068 | GDK_LEAVE_NOTIFY_MASK
1069 | GDK_ENTER_NOTIFY_MASK
1070 | GDK_BUTTON_PRESS_MASK
1071 | GDK_BUTTON_RELEASE_MASK
1072 | GDK_KEY_PRESS_MASK
1073 | GDK_KEY_RELEASE_MASK
1074 | GDK_POINTER_MOTION_MASK
1075 | GDK_POINTER_MOTION_HINT_MASK
1076 | GDK_SCROLL_MASK
1080 * Set gtk error log handler
1082 g_log_set_handler (NULL,
1083 G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION | G_LOG_LEVEL_MASK,
1084 callbacks_handle_log_messages, NULL);
1087 * Setup some GTK+ defaults.
1088 * These should really be somewhere else.
1090 GdkColor zoom_outline_color = {0, 50000, 50000, 50000};
1091 GdkColor dist_measure_color = {0, 60000, 30000, 65000};
1092 GdkColor selection_color = {0, 65000, 65000, 65000};
1094 screen.zoom_outline_color = zoom_outline_color;
1095 screen.dist_measure_color = dist_measure_color;
1096 screen.selection_color = selection_color;
1098 screen.drawing_area = drawingarea;
1099 screen.win.hAdjustment = hAdjustment;
1100 screen.win.vAdjustment = vAdjustment;
1101 screen.win.hRuler = hRuler;
1102 screen.win.vRuler = vRuler;
1103 screen.win.sidepane_notebook = sidepane_notebook;
1104 screen.win.toolButtonPointer = toggletoolbutton_pointer;
1105 screen.win.toolButtonPan = toggletoolbutton_pan;
1106 screen.win.toolButtonZoom = toggletoolbutton_zoom;
1107 screen.win.toolButtonMeasure = toggletoolbutton_measure;
1109 /* Create right click popup menu for layer tree */
1110 screen.win.layerTreePopupMenu = gtk_menu_new ();
1111 tempMenuItem = gtk_image_menu_item_new_with_label ("Invert layer color");
1112 gtk_menu_shell_append ((GtkMenuShell *)screen.win.layerTreePopupMenu, tempMenuItem);
1113 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Invert the display polarity of the layer", NULL);
1114 g_signal_connect ((gpointer) tempMenuItem, "activate",
1115 G_CALLBACK (callbacks_invert_layer_clicked), NULL);
1117 tempMenuItem = gtk_image_menu_item_new_with_label ("Change color");
1118 gtk_menu_shell_append ((GtkMenuShell *)screen.win.layerTreePopupMenu, tempMenuItem);
1119 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Change the display color of the layer", NULL);
1120 g_signal_connect ((gpointer) tempMenuItem, "activate",
1121 G_CALLBACK (callbacks_change_layer_color_clicked), NULL);
1123 tempMenuItem = gtk_image_menu_item_new_with_label ("Reload layer");
1124 gtk_menu_shell_append ((GtkMenuShell *)screen.win.layerTreePopupMenu, tempMenuItem);
1125 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Reload the layer from disk",
1126 NULL);
1127 g_signal_connect ((gpointer) tempMenuItem, "activate",
1128 G_CALLBACK (callbacks_reload_layer_clicked), NULL);
1130 tempMenuItem = gtk_image_menu_item_new_with_label ("Modify layer orientation");
1131 gtk_menu_shell_append ((GtkMenuShell *)screen.win.layerTreePopupMenu, tempMenuItem);
1132 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Translate, scale, rotate, or mirror the layer",
1133 NULL);
1134 g_signal_connect ((gpointer) tempMenuItem, "activate",
1135 G_CALLBACK (callbacks_change_layer_orientation_clicked), NULL);
1137 tempMenuItem = gtk_image_menu_item_new_with_label ("Edit file format");
1138 gtk_menu_shell_append ((GtkMenuShell *)screen.win.layerTreePopupMenu, tempMenuItem);
1139 gtk_tooltips_set_tip (tooltips, tempMenuItem, "View and edit the numerical format used to parse this layer",
1140 NULL);
1141 g_signal_connect ((gpointer) tempMenuItem, "activate",
1142 G_CALLBACK (callbacks_change_layer_format_clicked), NULL);
1144 tempMenuItem = gtk_image_menu_item_new_with_label ("Add layer");
1145 gtk_menu_shell_append ((GtkMenuShell *)screen.win.layerTreePopupMenu, tempMenuItem);
1146 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Open a new layer and insert it here", NULL);
1147 tempImage = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
1148 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem), tempImage);
1149 g_signal_connect ((gpointer) tempMenuItem, "activate",
1150 G_CALLBACK (callbacks_add_layer_button_clicked), NULL);
1152 tempMenuItem = gtk_image_menu_item_new_with_label ("Move layer down");
1153 gtk_menu_shell_append ((GtkMenuShell *)screen.win.layerTreePopupMenu, tempMenuItem);
1154 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Move the layer down one in the layer list", NULL);
1155 tempImage = gtk_image_new_from_stock ("gtk-go-down", GTK_ICON_SIZE_MENU);
1156 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem), tempImage);
1157 g_signal_connect ((gpointer) tempMenuItem, "activate",
1158 G_CALLBACK (callbacks_move_layer_down_button_clicked), NULL);
1160 tempMenuItem = gtk_image_menu_item_new_with_label ("Move layer up");
1161 gtk_menu_shell_append ((GtkMenuShell *)screen.win.layerTreePopupMenu, tempMenuItem);
1162 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Move the layer up one in the layer list", NULL);
1163 tempImage = gtk_image_new_from_stock ("gtk-go-up", GTK_ICON_SIZE_MENU);
1164 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem), tempImage);
1165 g_signal_connect ((gpointer) tempMenuItem, "activate",
1166 G_CALLBACK (callbacks_move_layer_up_clicked), NULL);
1168 tempMenuItem = gtk_image_menu_item_new_with_label ("Delete layer");
1169 gtk_menu_shell_append ((GtkMenuShell *)screen.win.layerTreePopupMenu, tempMenuItem);
1170 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Remove this layer", NULL);
1171 tempImage = gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_MENU);
1172 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem), tempImage);
1173 g_signal_connect ((gpointer) tempMenuItem, "activate",
1174 G_CALLBACK (callbacks_remove_layer_button_clicked), NULL);
1176 gtk_widget_show_all (screen.win.layerTreePopupMenu);
1178 /* Create right click popup menu for draw window */
1179 screen.win.drawWindowPopupMenu = gtk_menu_new ();
1180 tempMenuItem = gtk_image_menu_item_new_with_label ("Display object properties");
1181 gtk_menu_shell_append ((GtkMenuShell *)screen.win.drawWindowPopupMenu, tempMenuItem);
1182 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Examine the properties of the selected object", NULL);
1183 tempImage = gtk_image_new_from_stock ("gtk-info", GTK_ICON_SIZE_MENU);
1184 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem), tempImage);
1185 g_signal_connect ((gpointer) tempMenuItem, "activate",
1186 G_CALLBACK (callbacks_display_object_properties_clicked), NULL);
1188 /* Include these after they are coded.
1189 tempMenuItem = gtk_image_menu_item_new_with_label ("Edit object properties");
1190 gtk_menu_shell_append ((GtkMenuShell *)screen.win.drawWindowPopupMenu, tempMenuItem);
1191 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Edit the properties of the selected object", NULL);
1192 g_signal_connect ((gpointer) tempMenuItem, "activate",
1193 G_CALLBACK (callbacks_edit_object_properties_clicked), NULL);
1195 tempMenuItem = gtk_image_menu_item_new_with_label ("Move object(s)");
1196 gtk_menu_shell_append ((GtkMenuShell *)screen.win.drawWindowPopupMenu, tempMenuItem);
1197 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Move the selected object(s)",NULL);
1198 g_signal_connect ((gpointer) tempMenuItem, "activate",
1199 G_CALLBACK (callbacks_move_objects_clicked), NULL);
1201 tempMenuItem = gtk_image_menu_item_new_with_label ("Reduce area");
1202 gtk_menu_shell_append ((GtkMenuShell *)screen.win.drawWindowPopupMenu, tempMenuItem);
1203 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Reduce the area of the object (e.g. to prevent component floating)",NULL);
1204 g_signal_connect ((gpointer) tempMenuItem, "activate",
1205 G_CALLBACK (callbacks_reduce_object_area_clicked), NULL);
1208 tempMenuItem = gtk_image_menu_item_new_with_label ("Delete selected objects");
1209 gtk_menu_shell_append ((GtkMenuShell *)screen.win.drawWindowPopupMenu, tempMenuItem);
1210 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Delete the selected object(s)",NULL);
1211 tempImage = gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_MENU);
1212 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem), tempImage);
1213 g_signal_connect ((gpointer) tempMenuItem, "activate",
1214 G_CALLBACK (callbacks_delete_objects_clicked), NULL);
1216 gtk_widget_show_all (screen.win.drawWindowPopupMenu);
1218 /* make sure tooltips show on gtk <2.12 systems */
1219 gtk_tooltips_enable (tooltips);
1221 * Good defaults according to Ales. Gives aspect ratio of 1.3333...
1223 if ((req_width != -1) && (req_height != -1)) {
1224 width = req_width;
1225 height = req_height;
1227 else {
1228 GdkScreen *screen;
1229 int nmonitors;
1231 screen = gdk_screen_get_default();
1232 nmonitors = gdk_screen_get_n_monitors(screen);
1234 width = gdk_screen_get_width(screen) * 3/4 / nmonitors;
1235 height = gdk_screen_get_height(screen) * 3/4 / nmonitors;
1238 gtk_window_set_default_size((GtkWindow *)mainWindow, width, height);
1240 gtk_widget_show_all (mainWindow);
1241 screen.win.topLevelWindow = mainWindow;
1242 screen.win.messageTextView = message_textview;
1243 screen.win.statusMessageLeft = statusbar_label_left;
1244 screen.win.statusMessageRight = statusbar_label_right;
1245 screen.win.statusUnitComboBox = combobox2;
1246 screen.win.layerTree = tree;
1247 screen.win.treeIsUpdating = FALSE;
1249 screen.selectionInfo.selectedNodeArray = g_array_new (FALSE,
1250 FALSE, sizeof(gerbv_selection_item_t));
1251 callbacks_change_tool (NULL, (gpointer) 0);
1252 rename_main_window("",mainWindow);
1254 set_window_icon (mainWindow);
1255 callbacks_update_layer_tree ();
1257 /* connect this signal as late as possible to avoid triggering it before
1258 the gui is drawn */
1259 g_signal_connect ((gpointer) render_combobox, "changed",
1260 G_CALLBACK (callbacks_sidepane_render_type_combo_box_changed),
1261 NULL);
1262 gtk_main();
1265 /* ---------------------------------------------------- */
1266 void
1267 interface_set_render_type (int t)
1269 if (t >= 4)
1270 return;
1272 screenRenderInfo.renderType = t;
1274 /* make sure the interface is already up before calling
1275 * gtk_combo_box_set_active()
1277 if (render_combobox)
1278 gtk_combo_box_set_active (GTK_COMBO_BOX (render_combobox), t);
1281 /* ---------------------------------------------------- */
1283 * This dialog box shows a message and two buttons:
1284 * "OK" and "Cancel". It returns gboolean 1 if the
1285 * user clicked "OK", and gboolean 0 if the user
1286 * clicked "Cancel".
1290 gboolean
1291 interface_get_alert_dialog_response (gchar *primaryText, gchar *secondaryText,
1292 gboolean show_checkbox, gboolean *ask_to_show_again )
1293 /* This fcn returns TRUE if the user presses the OK button,
1294 otherwise it returns FALSE. */
1296 /* Set show_checkbox = TRUE to show "do not show this again" checkbox. */
1297 /* Point ask_to_show_again to the variable to set to not show the checkbox. */
1298 GtkWidget *dialog1;
1299 GtkWidget *dialog_vbox1;
1300 GtkWidget *hbox1;
1301 GtkWidget *image1;
1302 GtkWidget *label1;
1303 GtkWidget *checkbox=NULL;
1304 GtkWidget *dialog_action_area1;
1305 GtkWidget *cancelbutton1;
1306 GtkWidget *okbutton1;
1307 gboolean returnVal = FALSE;
1309 dialog1 = gtk_dialog_new ();
1310 gtk_container_set_border_width (GTK_CONTAINER (dialog1), 6);
1311 gtk_window_set_resizable (GTK_WINDOW (dialog1), FALSE);
1312 gtk_window_set_type_hint (GTK_WINDOW (dialog1), GDK_WINDOW_TYPE_HINT_DIALOG);
1313 gtk_dialog_set_has_separator (GTK_DIALOG (dialog1), FALSE);
1315 dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
1317 hbox1 = gtk_hbox_new (FALSE, 12);
1318 gtk_box_pack_start (GTK_BOX (dialog_vbox1), hbox1, TRUE, TRUE, 0);
1319 gtk_container_set_border_width (GTK_CONTAINER (hbox1), 6);
1321 image1 = gtk_image_new_from_icon_name ("gtk-dialog-warning", GTK_ICON_SIZE_DIALOG);
1322 gtk_box_pack_start (GTK_BOX (hbox1), image1, TRUE, TRUE, 0);
1323 gtk_misc_set_alignment (GTK_MISC (image1), 0.5, 0);
1325 gchar *labelMessage = g_strconcat ("<span weight=\"bold\" size=\"larger\">",primaryText,
1326 "</span>\n<span/>\n",secondaryText,NULL);
1327 label1 = gtk_label_new (labelMessage);
1328 g_free (labelMessage);
1329 GtkWidget *vbox9 = gtk_vbox_new (FALSE, 0);
1330 gtk_box_pack_start (GTK_BOX (vbox9), label1, FALSE, FALSE, 0);
1331 gtk_box_pack_start (GTK_BOX (hbox1), vbox9, FALSE, FALSE, 0);
1332 gtk_label_set_use_markup (GTK_LABEL (label1), TRUE);
1333 gtk_label_set_line_wrap (GTK_LABEL (label1), TRUE);
1335 // even with no checkbox, this extra hbox gives the recommended 24 px space between the
1336 // label and the buttons
1337 GtkWidget *hbox2 = gtk_hbox_new (FALSE, 12);
1338 if (show_checkbox) {
1339 GtkWidget *label3 = gtk_label_new (" ");
1341 checkbox = gtk_check_button_new_with_label("Do not show this dialog again.");
1342 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbox), FALSE);
1343 gtk_box_pack_start (GTK_BOX (hbox2), label3, FALSE, FALSE, 0);
1344 gtk_box_pack_start (GTK_BOX (hbox2), checkbox, FALSE, FALSE, 0);
1346 gtk_box_pack_start (GTK_BOX (vbox9), hbox2, FALSE, FALSE, 12);
1348 dialog_action_area1 = GTK_DIALOG (dialog1)->action_area;
1349 gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
1351 cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
1352 gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), cancelbutton1, GTK_RESPONSE_CANCEL);
1353 GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);
1354 gtk_widget_grab_default (cancelbutton1);
1355 gtk_widget_grab_focus (cancelbutton1);
1357 okbutton1 = gtk_button_new_from_stock ("gtk-ok");
1358 gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), okbutton1, GTK_RESPONSE_OK);
1359 GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);
1361 gtk_widget_show_all (dialog1);
1363 if (gtk_dialog_run ((GtkDialog*)dialog1) == GTK_RESPONSE_OK) {
1364 /* check to see if user clicked on "do not show again" box */
1365 if ((show_checkbox == TRUE) &&
1366 (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox)) == TRUE) &&
1367 (ask_to_show_again != NULL) ) {
1368 /* The user clicked the "do not show again box". Set corresponding
1369 * flag to FALSE. */
1370 *ask_to_show_again = FALSE;
1372 returnVal = TRUE;
1374 gtk_widget_destroy (dialog1);
1376 return returnVal;
1381 /* ---------------------------------------------------- */
1383 * This dialog box shows a textmessage and one buttons:
1384 * "OK". It does not return anything.
1387 void
1388 interface_show_alert_dialog (gchar *primaryText, gchar *secondaryText,
1389 gboolean show_checkbox, gboolean *ask_to_show_again )
1390 /* This fcn tells the user something, and only displays "OK" */
1392 /* Set show_checkbox = TRUE to show "do not show this again" checkbox. */
1393 /* Point ask_to_show_again to the variable to set to not show the checkbox. */
1394 GtkWidget *dialog1;
1395 GtkWidget *dialog_vbox1;
1396 GtkWidget *hbox1;
1397 GtkWidget *image1;
1398 GtkWidget *label1;
1399 GtkWidget *checkbox=NULL;
1400 GtkWidget *dialog_action_area1;
1401 GtkWidget *okbutton1;
1403 dialog1 = gtk_dialog_new ();
1404 gtk_container_set_border_width (GTK_CONTAINER (dialog1), 6);
1405 gtk_window_set_resizable (GTK_WINDOW (dialog1), FALSE);
1406 gtk_window_set_type_hint (GTK_WINDOW (dialog1), GDK_WINDOW_TYPE_HINT_DIALOG);
1407 gtk_dialog_set_has_separator (GTK_DIALOG (dialog1), FALSE);
1409 dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
1411 hbox1 = gtk_hbox_new (FALSE, 12);
1412 gtk_box_pack_start (GTK_BOX (dialog_vbox1), hbox1, TRUE, TRUE, 0);
1413 gtk_container_set_border_width (GTK_CONTAINER (hbox1), 6);
1415 image1 = gtk_image_new_from_icon_name ("gtk-dialog-warning", GTK_ICON_SIZE_DIALOG);
1416 gtk_box_pack_start (GTK_BOX (hbox1), image1, TRUE, TRUE, 0);
1417 gtk_misc_set_alignment (GTK_MISC (image1), 0.5, 0);
1419 gchar *labelMessage = g_strconcat ("<span weight=\"bold\" size=\"larger\">",primaryText,
1420 "</span>\n<span/>\n",secondaryText,NULL);
1421 label1 = gtk_label_new (labelMessage);
1422 g_free (labelMessage);
1424 GtkWidget *vbox9 = gtk_vbox_new (FALSE, 0);
1425 gtk_box_pack_start (GTK_BOX (vbox9), label1, FALSE, FALSE, 0);
1426 gtk_label_set_use_markup (GTK_LABEL (label1), TRUE);
1427 gtk_label_set_line_wrap (GTK_LABEL (label1), TRUE);
1428 gtk_box_pack_start (GTK_BOX (hbox1), vbox9, FALSE, FALSE, 0);
1430 GtkWidget *hbox2 = gtk_hbox_new (FALSE, 12);
1431 if (show_checkbox) {
1432 GtkWidget *label3 = gtk_label_new (" ");
1434 checkbox = gtk_check_button_new_with_label("Do not show this dialog again.");
1435 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbox), FALSE);
1436 gtk_box_pack_start (GTK_BOX (hbox2), label3, FALSE, FALSE, 0);
1437 gtk_box_pack_start (GTK_BOX (hbox2), checkbox, FALSE, FALSE, 0);
1439 gtk_box_pack_start (GTK_BOX (vbox9), hbox2, FALSE, FALSE, 12);
1441 dialog_action_area1 = GTK_DIALOG (dialog1)->action_area;
1442 gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
1444 okbutton1 = gtk_button_new_from_stock ("gtk-ok");
1445 gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), okbutton1, GTK_RESPONSE_OK);
1446 GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);
1448 gtk_widget_show_all (dialog1);
1450 /* check to see if user clicked on "do not show again" box */
1451 if ((show_checkbox == TRUE) &&
1452 (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox)) == TRUE) &&
1453 (ask_to_show_again != NULL) ) {
1454 /* The user clicked the "do not show again box". Set corresponding
1455 * flag to FALSE. */
1456 *ask_to_show_again = FALSE;
1459 gtk_dialog_run (GTK_DIALOG(dialog1));
1460 gtk_widget_destroy (dialog1);
1462 return;
1465 void
1466 interface_show_modify_orientation_dialog (gerbv_user_transformation_t *transform,
1467 gerbv_unit_t screenUnit) {
1468 GtkWidget *dialog;
1469 GtkWidget *check1,*check2,*tempWidget,*tempWidget2,*tableWidget;
1470 GtkWidget *spin1,*spin2,*spin3,*spin4,*spin5;
1471 GtkAdjustment *adj;
1472 gerbv_user_transformation_t startTransform = *transform;
1474 dialog = gtk_dialog_new_with_buttons ("Modify layer orientation",
1475 GTK_WINDOW (screen.win.topLevelWindow), GTK_DIALOG_DESTROY_WITH_PARENT,
1476 GTK_STOCK_CANCEL, GTK_RESPONSE_NONE, GTK_STOCK_OK, GTK_RESPONSE_OK,
1477 GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
1478 NULL);
1480 gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
1481 gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
1482 gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
1483 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1485 tableWidget = gtk_table_new (16,3,FALSE);
1486 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), tableWidget, FALSE, FALSE, 0);
1488 tempWidget = gtk_label_new (NULL);
1489 gtk_label_set_markup (GTK_LABEL (tempWidget), "<span weight=\"bold\">Translation</span>");
1490 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1491 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,0,2,0,1,GTK_EXPAND|GTK_FILL,0,0,5);
1493 tempWidget = gtk_label_new (" ");
1494 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,0,1,1,2,0,0,0,0);
1495 gdouble translateX, translateY;
1497 if (screenUnit == GERBV_MILS) {
1498 tempWidget = gtk_label_new ("X (mils):");
1499 tempWidget2 = gtk_label_new ("Y (mils):");
1500 translateX = transform->translateX * 1000;
1501 translateY = transform->translateY * 1000;
1503 else if (screen.unit == GERBV_MMS) {
1504 tempWidget = gtk_label_new ("X (mms):");
1505 tempWidget2 = gtk_label_new ("Y (mms):");
1506 translateX = transform->translateX * 25.4;
1507 translateY = transform->translateY * 25.4;
1509 else {
1510 tempWidget = gtk_label_new ("X (inches):");
1511 tempWidget2 = gtk_label_new ("Y (inches):");
1512 translateX = transform->translateX;
1513 translateY = transform->translateY;
1516 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1517 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,1,2,1,2,GTK_EXPAND|GTK_FILL,0,0,0);
1518 gtk_misc_set_alignment (GTK_MISC (tempWidget2), 0.0, 0.5);
1519 gtk_table_attach ((GtkTable *) tableWidget, tempWidget2,1,2,2,3,GTK_EXPAND|GTK_FILL,0,0,0);
1520 adj = (GtkAdjustment *) gtk_adjustment_new (translateX, -1000000, 1000000, 1, 10, 0.0);
1521 spin1 = (GtkWidget *) gtk_spin_button_new (adj, 0.1, 4);
1522 gtk_table_attach ((GtkTable *) tableWidget, spin1,2,3,1,2,GTK_FILL,0,0,0);
1523 adj = (GtkAdjustment *) gtk_adjustment_new (translateY, -1000000, 1000000, 1, 10, 0.0);
1524 spin2 = (GtkWidget *) gtk_spin_button_new (adj, 0.1, 4);
1525 gtk_table_attach ((GtkTable *) tableWidget, spin2,2,3,2,3,GTK_FILL,0,0,0);
1527 gtk_table_set_row_spacing ((GtkTable *) tableWidget, 3, 8);
1528 tempWidget = gtk_label_new (NULL);
1529 gtk_label_set_markup (GTK_LABEL (tempWidget), "<span weight=\"bold\">Scale</span>");
1530 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1531 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,0,2,4,5,GTK_EXPAND|GTK_FILL,0,0,5);
1533 tempWidget = gtk_label_new ("X direction:");
1534 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1535 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,1,2,5,6,GTK_EXPAND|GTK_FILL,0,0,0);
1536 tempWidget = gtk_label_new ("Y direction:");
1537 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1538 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,1,2,6,7,GTK_EXPAND|GTK_FILL,0,0,0);
1539 adj = (GtkAdjustment *) gtk_adjustment_new (transform->scaleX, -1000000, 1000000, 1, 10, 0.0);
1540 spin3 = (GtkWidget *) gtk_spin_button_new (adj, 1, 3);
1541 gtk_table_attach ((GtkTable *) tableWidget, spin3,2,3,5,6,GTK_FILL,0,0,0);
1542 adj = (GtkAdjustment *) gtk_adjustment_new (transform->scaleY, -1000000, 1000000, 1, 10, 0.0);
1543 spin4 = (GtkWidget *) gtk_spin_button_new (adj, 1, 3);
1544 gtk_table_attach ((GtkTable *) tableWidget, spin4,2,3,6,7,GTK_FILL,0,0,0);
1546 gtk_table_set_row_spacing ((GtkTable *) tableWidget, 7, 8);
1548 tempWidget = gtk_label_new (NULL);
1549 gtk_label_set_markup (GTK_LABEL (tempWidget), "<span weight=\"bold\">Rotation</span>");
1550 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1551 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,0,2,8,9,GTK_EXPAND|GTK_FILL,0,0,5);
1553 tempWidget = gtk_label_new ("Rotation (degrees): ");
1554 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1555 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,1,2,9,10,GTK_EXPAND|GTK_FILL,0,0,0);
1556 spin5 = gtk_combo_box_new_text();
1557 gtk_combo_box_append_text ((GtkComboBox *)spin5, "None");
1558 gtk_combo_box_append_text ((GtkComboBox *)spin5, "90 deg CCW");
1559 gtk_combo_box_append_text ((GtkComboBox *)spin5, "180 deg CCW");
1560 gtk_combo_box_append_text ((GtkComboBox *)spin5, "270 deg CCW");
1561 gdouble degreeRotation = transform->rotation/M_PI*180;
1562 if ((degreeRotation < 135)&&(degreeRotation >= 45))
1563 gtk_combo_box_set_active ((GtkComboBox *)spin5, 1);
1564 else if ((degreeRotation < 225)&&(degreeRotation >= 135))
1565 gtk_combo_box_set_active ((GtkComboBox *)spin5, 2);
1566 else if ((degreeRotation < 315)&&(degreeRotation >= 225))
1567 gtk_combo_box_set_active ((GtkComboBox *)spin5, 3);
1568 else
1569 gtk_combo_box_set_active ((GtkComboBox *)spin5, 0);
1571 adj = (GtkAdjustment *) gtk_adjustment_new (transform->rotation/M_PI*180, -1000000, 1000000,
1572 1, 10, 0.0);
1573 spin5 = (GtkWidget *) gtk_spin_button_new (adj, 0, 3);
1575 gtk_table_attach ((GtkTable *) tableWidget, spin5,2,3,9,10,GTK_FILL,0,0,0);
1578 gtk_table_set_row_spacing ((GtkTable *) tableWidget, 10, 8);
1579 tempWidget = gtk_label_new (NULL);
1580 gtk_label_set_markup (GTK_LABEL (tempWidget), "<span weight=\"bold\">Mirroring</span>");
1581 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1582 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,0,2,11,12,GTK_EXPAND|GTK_FILL,0,0,5);
1584 tempWidget = gtk_label_new ("About X axis:");
1585 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1586 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,1,2,12,13,GTK_EXPAND|GTK_FILL,0,0,0);
1587 check1 = (GtkWidget *) gtk_check_button_new ();
1588 gtk_toggle_button_set_active ((GtkToggleButton *) check1, transform->mirrorAroundX);
1589 gtk_table_attach ((GtkTable *) tableWidget, check1,2,3,12,13,0,0,0,2);
1591 tempWidget = gtk_label_new ("About Y axis:");
1592 gtk_misc_set_alignment (GTK_MISC (tempWidget), 0.0, 0.5);
1593 gtk_table_attach ((GtkTable *) tableWidget, tempWidget,1,2,13,14,GTK_EXPAND|GTK_FILL,0,0,0);
1594 check2 = (GtkWidget *) gtk_check_button_new ();
1595 gtk_toggle_button_set_active ((GtkToggleButton *) check2, transform->mirrorAroundY);
1596 gtk_table_attach ((GtkTable *) tableWidget, check2,2,3,13,14,0,0,0,2);
1598 gtk_table_set_row_spacing ((GtkTable *) tableWidget, 14, 8);
1599 gtk_widget_show_all (dialog);
1600 gint result = GTK_RESPONSE_APPLY;
1602 // each time the user selects "apply", update the screen and re-enter the dialog loop
1603 while (result == GTK_RESPONSE_APPLY) {
1604 result = gtk_dialog_run (GTK_DIALOG(dialog));
1605 if (result != GTK_RESPONSE_NONE) {
1606 /* extract all the parameters */
1607 if (screenUnit == GERBV_MILS) {
1608 transform->translateX = gtk_spin_button_get_value ((GtkSpinButton *) spin1)/
1609 1000;
1610 transform->translateY = gtk_spin_button_get_value ((GtkSpinButton *) spin2)/
1611 1000;
1613 else if (screen.unit == GERBV_MMS) {
1614 transform->translateX = gtk_spin_button_get_value ((GtkSpinButton *) spin1)/
1615 25.4;
1616 transform->translateY = gtk_spin_button_get_value ((GtkSpinButton *) spin2)/
1617 25.4;
1619 else {
1620 transform->translateX = gtk_spin_button_get_value ((GtkSpinButton *) spin1);
1621 transform->translateY = gtk_spin_button_get_value ((GtkSpinButton *) spin2);
1623 transform->scaleX = gtk_spin_button_get_value ((GtkSpinButton *)spin3);
1624 transform->scaleY = gtk_spin_button_get_value ((GtkSpinButton *)spin4);
1625 gint rotationIndex = gtk_combo_box_get_active ((GtkComboBox *)spin5);
1626 if (rotationIndex == 0)
1627 transform->rotation = 0;
1628 else if (rotationIndex == 1)
1629 transform->rotation = 90.0/180*M_PI;
1630 else if (rotationIndex == 2)
1631 transform->rotation = 180.0/180*M_PI;
1632 else if (rotationIndex == 3)
1633 transform->rotation = 270.0/180*M_PI;
1634 transform->mirrorAroundX = gtk_toggle_button_get_active ((GtkToggleButton *) check1);
1635 transform->mirrorAroundY = gtk_toggle_button_get_active ((GtkToggleButton *) check2);
1637 render_refresh_rendered_image_on_screen ();
1638 callbacks_update_layer_tree ();
1641 if (result == GTK_RESPONSE_NONE) {
1642 // revert back to the start values if the user cancelled
1643 *transform = startTransform;
1645 gtk_widget_destroy (dialog);
1647 return;