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)
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.
14 * This program is distributed in the hope that it will 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
28 #include <sys/types.h>
34 #include <gdk/gdkkeysyms.h>
39 #include "gerb_error.h"
41 #ifdef RENDER_USING_GDK
48 #include "gerbv_screen.h"
49 #include "gerbv_icon.h"
54 #include "callbacks.h"
55 #include "interface.h"
58 #define WIN_TITLE "Gerber Viewer"
59 # define _(String) (String)
62 rename_main_window(char *filename
, GtkWidget
*main_win
)
64 GString
*win_title
=g_string_new(NULL
);
65 static GtkWidget
*win
=NULL
;
67 if( main_win
!= NULL
)
70 g_assert(win
!= NULL
);
72 g_string_printf (win_title
,"%s%s: %s", WIN_TITLE
, VERSION
, filename
);
73 gtk_window_set_title(GTK_WINDOW(win
), win_title
->str
);
74 g_string_free(win_title
,TRUE
);
78 set_window_icon (GtkWidget
* this_window
)
83 pixmap
= gdk_pixmap_create_from_xpm_d (this_window
->window
, &mask
,
84 &this_window
->style
->bg
[GTK_STATE_NORMAL
], gerbv_icon_xpm
);
85 gdk_window_set_icon (this_window
->window
, NULL
, pixmap
, mask
);
91 interface_create_gui (int req_width
, int req_height
)
93 GtkWidget
*mainWindow
;
96 GtkWidget
*menuitem_file
;
97 GtkWidget
*menuitem_file_menu
;
99 GtkWidget
*open_project
;
101 GtkWidget
*open_layer
;
105 GtkWidget
*separatormenuitem1
;
107 GtkWidget
*export_menu
;
109 GtkWidget
*separator1
;
111 GtkWidget
*menuitem_view
;
112 GtkWidget
*menuitem_view_menu
;
115 GtkWidget
*separator5
;
116 GtkWidget
*fit_to_window
;
117 GtkWidget
*menuitem_analyze
;
118 GtkWidget
*menuitem_analyze_menu
;
119 GtkWidget
*analyze_active_gerbers
;
120 GtkWidget
*analyze_active_drill
;
121 GtkWidget
*control_gerber_options
;
122 GtkWidget
*menubar_tools
;
123 GtkWidget
*menubar_tools_menu
;
124 GtkWidget
*pointer_tool
;
125 GtkWidget
*zoom_tool
;
126 GtkWidget
*measure_tool
;
127 GtkWidget
*menuitem10
;
128 GtkWidget
*menuitem10_menu
;
129 GtkWidget
*online_manual
;
132 GtkWidget
*toolbar_hbox
;
133 GtkWidget
*handlebox
;
134 GtkWidget
*button_toolbar
;
135 GtkIconSize tmp_toolbar_icon_size
;
136 GtkWidget
*toolbutton_new
;
137 GtkWidget
*toolbutton_open
;
138 GtkWidget
*toolbutton_revert
;
139 GtkWidget
*toolbutton_save
;
140 GtkWidget
*separatortoolitem1
;
141 #if GTK_CHECK_VERSION(2,10,0)
143 GtkWidget
*toolbutton_print
;
144 GtkWidget
*separator2
;
145 GtkWidget
*separatortoolitem2
;
147 GtkWidget
*toolbutton_zoom_in
;
148 GtkWidget
*toolbutton_zoom_out
;
149 GtkWidget
*toolbutton_zoom_fit
;
150 GtkWidget
*separatortoolitem3
;
151 GtkWidget
*toolbutton_analyze
;
152 GtkWidget
*toolbutton_validate
;
153 GtkWidget
*toolbutton_control
;
154 GtkWidget
*separatortoolitem4
;
155 GtkWidget
*toggletoolbutton_pointer
;
156 GtkWidget
*toggletoolbutton_zoom
;
157 GtkWidget
*toggletoolbutton_measure
;
159 GtkWidget
*sidepane_vbox
;
160 GtkWidget
*sidepane_notebook
;
164 GtkWidget
*combobox1
;
165 GtkWidget
*scrolledwindow1
;
175 GtkWidget
*Layer_label
;
177 GtkWidget
*messages_scrolledwindow
;
178 GtkWidget
*message_textview
;
179 GtkWidget
*clear_messages_button
;
180 GtkWidget
*Message_label
;
182 GtkWidget
*main_view_table
;
186 GtkWidget
*statusbar_label_left
;
187 GtkWidget
*combobox2
;
188 GtkWidget
*statusbar_label_right
;
189 GtkWidget
*drawingarea
, *hAdjustment
, *vAdjustment
, *hScrollbar
, *vScrollbar
;
191 GtkAccelGroup
*accel_group
;
192 GtkTooltips
*tooltips
;
194 tooltips
= gtk_tooltips_new ();
196 accel_group
= gtk_accel_group_new ();
198 mainWindow
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
199 gtk_window_set_title (GTK_WINDOW (mainWindow
), _("Gerber Viewer"));
201 vbox1
= gtk_vbox_new (FALSE
, 0);
202 gtk_widget_show (vbox1
);
203 gtk_container_add (GTK_CONTAINER (mainWindow
), vbox1
);
205 menubar1
= gtk_menu_bar_new ();
206 gtk_widget_show (menubar1
);
207 gtk_box_pack_start (GTK_BOX (vbox1
), menubar1
, FALSE
, FALSE
, 0);
209 menuitem_file
= gtk_menu_item_new_with_mnemonic (_("_File"));
210 gtk_widget_show (menuitem_file
);
211 gtk_container_add (GTK_CONTAINER (menubar1
), menuitem_file
);
213 menuitem_file_menu
= gtk_menu_new ();
214 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_file
), menuitem_file_menu
);
216 new = gtk_image_menu_item_new_from_stock ("gtk-new", accel_group
);
217 gtk_widget_show (new);
218 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), new);
219 gtk_widget_add_accelerator (new, "activate", accel_group
,
220 GDK_n
, (GdkModifierType
) GDK_CONTROL_MASK
,
223 open_project
= gtk_image_menu_item_new_with_mnemonic (_("_Open Project"));
224 gtk_widget_show (open_project
);
225 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), open_project
);
226 gtk_tooltips_set_tip (tooltips
, open_project
, _("Open an existing Gerber Viewer project"), NULL
);
228 image33
= gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU
);
229 gtk_widget_show (image33
);
230 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (open_project
), image33
);
232 open_layer
= gtk_menu_item_new_with_mnemonic (_("Open _Layer(s)"));
233 gtk_widget_show (open_layer
);
234 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), open_layer
);
235 gtk_tooltips_set_tip (tooltips
, open_layer
, _("Open Gerber, drill, or pick and place file(s)"), NULL
);
237 revert
= gtk_image_menu_item_new_from_stock ("gtk-revert-to-saved", accel_group
);
238 gtk_widget_show (revert
);
239 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), revert
);
241 save
= gtk_image_menu_item_new_from_stock ("gtk-save", accel_group
);
242 gtk_widget_show (save
);
243 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), save
);
245 save_as
= gtk_image_menu_item_new_from_stock ("gtk-save-as", accel_group
);
246 gtk_widget_show (save_as
);
247 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), save_as
);
249 separatormenuitem1
= gtk_separator_menu_item_new ();
250 gtk_widget_show (separatormenuitem1
);
251 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), separatormenuitem1
);
252 gtk_widget_set_sensitive (separatormenuitem1
, FALSE
);
254 export
= gtk_menu_item_new_with_mnemonic (_("_Export"));
255 gtk_widget_show (export
);
256 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), export
);
258 export_menu
= gtk_menu_new ();
259 gtk_menu_item_set_submenu (GTK_MENU_ITEM (export
), export_menu
);
261 png
= gtk_menu_item_new_with_mnemonic (_("PNG"));
262 gtk_widget_show (png
);
263 gtk_container_add (GTK_CONTAINER (export_menu
), png
);
264 gtk_tooltips_set_tip (tooltips
, png
, _("Export project to a PNG file"), NULL
);
266 #ifndef RENDER_USING_GDK
269 GtkWidget
*postscript
;
271 pdf
= gtk_menu_item_new_with_mnemonic (_("PDF"));
272 gtk_widget_show (pdf
);
273 gtk_container_add (GTK_CONTAINER (export_menu
), pdf
);
274 gtk_tooltips_set_tip (tooltips
, pdf
, _("Export project to a PDF file"), NULL
);
276 svg
= gtk_menu_item_new_with_mnemonic (_("SVG"));
277 gtk_widget_show (svg
);
278 gtk_container_add (GTK_CONTAINER (export_menu
), svg
);
279 gtk_tooltips_set_tip (tooltips
, svg
, _("Export project to a SVG file"), NULL
);
281 postscript
= gtk_menu_item_new_with_mnemonic (_("PostScript"));
282 gtk_widget_show (postscript
);
283 gtk_container_add (GTK_CONTAINER (export_menu
), postscript
);
284 gtk_tooltips_set_tip (tooltips
, postscript
, _("Export project to a PostScript file"), NULL
);
287 separator1
= gtk_separator_menu_item_new ();
288 gtk_widget_show (separator1
);
289 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), separator1
);
290 gtk_widget_set_sensitive (separator1
, FALSE
);
292 #if GTK_CHECK_VERSION(2,10,0)
293 print
= gtk_image_menu_item_new_from_stock ("gtk-print", accel_group
);
294 gtk_widget_show (print
);
295 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), print
);
297 separator2
= gtk_separator_menu_item_new ();
298 gtk_widget_show (separator2
);
299 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), separator2
);
300 gtk_widget_set_sensitive (separator2
, FALSE
);
303 quit
= gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group
);
304 gtk_widget_show (quit
);
305 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), quit
);
307 menuitem_view
= gtk_menu_item_new_with_mnemonic (_("_View"));
308 gtk_widget_show (menuitem_view
);
309 gtk_container_add (GTK_CONTAINER (menubar1
), menuitem_view
);
311 menuitem_view_menu
= gtk_menu_new ();
312 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_view
), menuitem_view_menu
);
314 zoom_in
= gtk_image_menu_item_new_from_stock ("gtk-zoom-in", accel_group
);
315 gtk_widget_show (zoom_in
);
316 gtk_container_add (GTK_CONTAINER (menuitem_view_menu
), zoom_in
);
318 zoom_out
= gtk_image_menu_item_new_from_stock ("gtk-zoom-out", accel_group
);
319 gtk_widget_show (zoom_out
);
320 gtk_container_add (GTK_CONTAINER (menuitem_view_menu
), zoom_out
);
322 separator5
= gtk_separator_menu_item_new ();
323 gtk_widget_show (separator5
);
324 gtk_container_add (GTK_CONTAINER (menuitem_view_menu
), separator5
);
325 gtk_widget_set_sensitive (separator5
, FALSE
);
327 fit_to_window
= gtk_image_menu_item_new_from_stock ("gtk-zoom-fit", accel_group
);
328 gtk_widget_show (fit_to_window
);
329 gtk_container_add (GTK_CONTAINER (menuitem_view_menu
), fit_to_window
);
331 menuitem_analyze
= gtk_menu_item_new_with_mnemonic (_("_Analyze"));
332 gtk_widget_show (menuitem_analyze
);
333 gtk_container_add (GTK_CONTAINER (menubar1
), menuitem_analyze
);
335 menuitem_analyze_menu
= gtk_menu_new ();
336 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_analyze
), menuitem_analyze_menu
);
338 analyze_active_gerbers
= gtk_menu_item_new_with_mnemonic (_("_Analyze active Gerber layers"));
339 gtk_widget_show (analyze_active_gerbers
);
340 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu
), analyze_active_gerbers
);
342 analyze_active_drill
= gtk_menu_item_new_with_mnemonic (_("_Analyze active drill layers"));
343 gtk_widget_show (analyze_active_drill
);
344 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu
), analyze_active_drill
);
346 control_gerber_options
= gtk_menu_item_new_with_mnemonic (_("Control Gerber options"));
347 gtk_widget_show (control_gerber_options
);
348 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu
), control_gerber_options
);
350 menubar_tools
= gtk_menu_item_new_with_mnemonic (_("_Tools"));
351 gtk_widget_show (menubar_tools
);
352 gtk_container_add (GTK_CONTAINER (menubar1
), menubar_tools
);
354 menubar_tools_menu
= gtk_menu_new ();
355 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menubar_tools
), menubar_tools_menu
);
357 pointer_tool
= gtk_menu_item_new_with_mnemonic (_("_Pointer Tool"));
358 gtk_widget_show (pointer_tool
);
359 gtk_container_add (GTK_CONTAINER (menubar_tools_menu
), pointer_tool
);
360 gtk_tooltips_set_tip (tooltips
, pointer_tool
, _("The default tool"), NULL
);
361 gtk_widget_add_accelerator (pointer_tool
, "activate", accel_group
,
362 GDK_F1
, (GdkModifierType
) 0,
365 zoom_tool
= gtk_menu_item_new_with_mnemonic (_("_Zoom Tool"));
366 gtk_widget_show (zoom_tool
);
367 gtk_container_add (GTK_CONTAINER (menubar_tools_menu
), zoom_tool
);
368 gtk_tooltips_set_tip (tooltips
, zoom_tool
, _("Zoom by drawing a rectangle"), NULL
);
369 gtk_widget_add_accelerator (zoom_tool
, "activate", accel_group
,
370 GDK_F2
, (GdkModifierType
) 0,
373 measure_tool
= gtk_menu_item_new_with_mnemonic (_("_Measure Tool"));
374 gtk_widget_show (measure_tool
);
375 gtk_container_add (GTK_CONTAINER (menubar_tools_menu
), measure_tool
);
376 gtk_tooltips_set_tip (tooltips
, measure_tool
, _("Measure distances"), NULL
);
377 gtk_widget_add_accelerator (measure_tool
, "activate", accel_group
,
378 GDK_F3
, (GdkModifierType
) 0,
381 menuitem10
= gtk_menu_item_new_with_mnemonic (_("_Help"));
382 gtk_widget_show (menuitem10
);
383 gtk_container_add (GTK_CONTAINER (menubar1
), menuitem10
);
385 menuitem10_menu
= gtk_menu_new ();
386 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem10
), menuitem10_menu
);
388 online_manual
= gtk_menu_item_new_with_mnemonic (_("_Online Manual"));
389 gtk_widget_show (online_manual
);
390 gtk_container_add (GTK_CONTAINER (menuitem10_menu
), online_manual
);
391 gtk_tooltips_set_tip (tooltips
, online_manual
, _("View the online help documentation"), NULL
);
393 about
= gtk_image_menu_item_new_with_mnemonic (_("_About GerberViewer"));
394 gtk_widget_show (about
);
395 gtk_container_add (GTK_CONTAINER (menuitem10_menu
), about
);
396 gtk_tooltips_set_tip (tooltips
, about
, _("View information about this software"), NULL
);
398 image34
= gtk_image_new_from_stock ("gtk-dialog-info", GTK_ICON_SIZE_MENU
);
399 gtk_widget_show (image34
);
400 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (about
), image34
);
402 toolbar_hbox
= gtk_hbox_new (FALSE
, 0);
403 gtk_widget_show (toolbar_hbox
);
404 gtk_box_pack_start (GTK_BOX (vbox1
), toolbar_hbox
, FALSE
, FALSE
, 0);
406 handlebox
= gtk_handle_box_new ();
407 gtk_widget_show (handlebox
);
408 gtk_box_pack_start (GTK_BOX (toolbar_hbox
), handlebox
, TRUE
, TRUE
, 0);
410 button_toolbar
= gtk_toolbar_new ();
411 gtk_widget_show (button_toolbar
);
412 gtk_container_add (GTK_CONTAINER (handlebox
), button_toolbar
);
413 gtk_toolbar_set_style (GTK_TOOLBAR (button_toolbar
), GTK_TOOLBAR_ICONS
);
414 tmp_toolbar_icon_size
= gtk_toolbar_get_icon_size (GTK_TOOLBAR (button_toolbar
));
416 toolbutton_new
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-new");
417 gtk_widget_show (toolbutton_new
);
418 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_new
);
420 toolbutton_open
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-open");
421 gtk_widget_show (toolbutton_open
);
422 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_open
);
424 toolbutton_revert
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-revert-to-saved");
425 gtk_widget_show (toolbutton_revert
);
426 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_revert
);
428 toolbutton_save
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-save");
429 gtk_widget_show (toolbutton_save
);
430 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_save
);
432 separatortoolitem1
= (GtkWidget
*) gtk_separator_tool_item_new ();
433 gtk_widget_show (separatortoolitem1
);
434 gtk_container_add (GTK_CONTAINER (button_toolbar
), separatortoolitem1
);
436 #if GTK_CHECK_VERSION(2,10,0)
437 toolbutton_print
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-print");
438 gtk_widget_show (toolbutton_print
);
439 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_print
);
441 separatortoolitem2
= (GtkWidget
*) gtk_separator_tool_item_new ();
442 gtk_widget_show (separatortoolitem2
);
443 gtk_container_add (GTK_CONTAINER (button_toolbar
), separatortoolitem2
);
446 toolbutton_zoom_in
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-zoom-in");
447 gtk_widget_show (toolbutton_zoom_in
);
448 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_zoom_in
);
450 toolbutton_zoom_out
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-zoom-out");
451 gtk_widget_show (toolbutton_zoom_out
);
452 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_zoom_out
);
454 toolbutton_zoom_fit
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-zoom-fit");
455 gtk_widget_show (toolbutton_zoom_fit
);
456 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_zoom_fit
);
458 separatortoolitem3
= (GtkWidget
*) gtk_separator_tool_item_new ();
459 gtk_widget_show (separatortoolitem3
);
460 gtk_container_add (GTK_CONTAINER (button_toolbar
), separatortoolitem3
);
462 toolbutton_analyze
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-apply");
463 gtk_widget_show (toolbutton_analyze
);
464 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_analyze
);
466 toolbutton_validate
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-apply");
467 gtk_widget_show (toolbutton_validate
);
468 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_validate
);
470 toolbutton_control
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-apply");
471 gtk_widget_show (toolbutton_control
);
472 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_control
);
474 separatortoolitem4
= (GtkWidget
*) gtk_separator_tool_item_new ();
475 gtk_widget_show (separatortoolitem4
);
476 gtk_container_add (GTK_CONTAINER (button_toolbar
), separatortoolitem4
);
478 toggletoolbutton_pointer
= (GtkWidget
*) gtk_toggle_tool_button_new_from_stock ("gtk-apply");
479 gtk_widget_show (toggletoolbutton_pointer
);
480 gtk_container_add (GTK_CONTAINER (button_toolbar
), toggletoolbutton_pointer
);
481 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (toggletoolbutton_pointer
), TRUE
);
483 toggletoolbutton_zoom
= (GtkWidget
*) gtk_toggle_tool_button_new_from_stock ("gtk-apply");
484 gtk_widget_show (toggletoolbutton_zoom
);
485 gtk_container_add (GTK_CONTAINER (button_toolbar
), toggletoolbutton_zoom
);
487 toggletoolbutton_measure
= (GtkWidget
*) gtk_toggle_tool_button_new_from_stock ("gtk-apply");
488 gtk_widget_show (toggletoolbutton_measure
);
489 gtk_container_add (GTK_CONTAINER (button_toolbar
), toggletoolbutton_measure
);
491 hpaned1
= gtk_hpaned_new ();
492 gtk_widget_show (hpaned1
);
493 gtk_box_pack_start (GTK_BOX (vbox1
), hpaned1
, TRUE
, TRUE
, 0);
494 gtk_paned_set_position (GTK_PANED (hpaned1
), 225);
496 sidepane_vbox
= gtk_vbox_new (FALSE
, 0);
497 gtk_widget_show (sidepane_vbox
);
498 gtk_paned_pack1 (GTK_PANED (hpaned1
), sidepane_vbox
, FALSE
, TRUE
);
499 gtk_widget_set_size_request (sidepane_vbox
, 92, -1);
500 gtk_container_set_border_width (GTK_CONTAINER (sidepane_vbox
), 5);
502 sidepane_notebook
= gtk_notebook_new ();
503 gtk_widget_show (sidepane_notebook
);
504 gtk_box_pack_start (GTK_BOX (sidepane_vbox
), sidepane_notebook
, TRUE
, TRUE
, 0);
506 vbox10
= gtk_vbox_new (FALSE
, 3);
507 gtk_widget_show (vbox10
);
508 gtk_container_add (GTK_CONTAINER (sidepane_notebook
), vbox10
);
509 gtk_widget_set_size_request (vbox10
, 82, -1);
510 gtk_container_set_border_width (GTK_CONTAINER (vbox10
), 4);
512 hbox4
= gtk_hbox_new (FALSE
, 0);
513 gtk_widget_show (hbox4
);
514 gtk_box_pack_start (GTK_BOX (vbox10
), hbox4
, FALSE
, FALSE
, 0);
516 label1
= gtk_label_new (_("Overlay method: "));
517 gtk_widget_show (label1
);
518 gtk_box_pack_start (GTK_BOX (hbox4
), label1
, FALSE
, FALSE
, 0);
520 combobox1
= gtk_combo_box_new_text ();
521 gtk_widget_show (combobox1
);
522 gtk_box_pack_start (GTK_BOX (hbox4
), combobox1
, TRUE
, TRUE
, 0);
523 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox1
), _("Normal"));
524 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox1
), _("Subtract"));
525 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox1
), _("Overlap"));
526 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox1
), _("Xor"));
528 scrolledwindow1
= gtk_scrolled_window_new (NULL
, NULL
);
529 gtk_widget_show (scrolledwindow1
);
530 gtk_box_pack_start (GTK_BOX (vbox10
), scrolledwindow1
, TRUE
, TRUE
, 0);
531 gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow1
), 2);
532 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1
),
533 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
534 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1
),
537 hbox1
= gtk_hbox_new (TRUE
, 0);
538 gtk_widget_show (hbox1
);
539 gtk_box_pack_start (GTK_BOX (vbox10
), hbox1
, FALSE
, FALSE
, 0);
541 button4
= gtk_button_new ();
542 gtk_widget_show (button4
);
543 gtk_box_pack_start (GTK_BOX (hbox1
), button4
, FALSE
, TRUE
, 0);
545 image8
= gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_BUTTON
);
546 gtk_widget_show (image8
);
547 gtk_container_add (GTK_CONTAINER (button4
), image8
);
549 button5
= gtk_button_new ();
550 gtk_widget_show (button5
);
551 gtk_box_pack_start (GTK_BOX (hbox1
), button5
, FALSE
, TRUE
, 0);
553 image9
= gtk_image_new_from_stock ("gtk-go-down", GTK_ICON_SIZE_BUTTON
);
554 gtk_widget_show (image9
);
555 gtk_container_add (GTK_CONTAINER (button5
), image9
);
557 button6
= gtk_button_new ();
558 gtk_widget_show (button6
);
559 gtk_box_pack_start (GTK_BOX (hbox1
), button6
, FALSE
, TRUE
, 0);
561 image10
= gtk_image_new_from_stock ("gtk-go-up", GTK_ICON_SIZE_BUTTON
);
562 gtk_widget_show (image10
);
563 gtk_container_add (GTK_CONTAINER (button6
), image10
);
565 button7
= gtk_button_new ();
566 gtk_widget_show (button7
);
567 gtk_box_pack_start (GTK_BOX (hbox1
), button7
, FALSE
, TRUE
, 0);
569 image11
= gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_BUTTON
);
570 gtk_widget_show (image11
);
571 gtk_container_add (GTK_CONTAINER (button7
), image11
);
573 Layer_label
= gtk_label_new (_("Layers"));
574 gtk_widget_show (Layer_label
);
575 gtk_notebook_set_tab_label (GTK_NOTEBOOK (sidepane_notebook
),
576 gtk_notebook_get_nth_page (GTK_NOTEBOOK (sidepane_notebook
), 0),
579 vbox11
= gtk_vbox_new (FALSE
, 2);
580 gtk_widget_show (vbox11
);
581 gtk_container_add (GTK_CONTAINER (sidepane_notebook
), vbox11
);
582 gtk_container_set_border_width (GTK_CONTAINER (vbox11
), 3);
584 messages_scrolledwindow
= gtk_scrolled_window_new (NULL
, NULL
);
585 gtk_widget_show (messages_scrolledwindow
);
586 gtk_box_pack_start (GTK_BOX (vbox11
), messages_scrolledwindow
, TRUE
, TRUE
, 0);
587 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (messages_scrolledwindow
),
588 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
590 message_textview
= gtk_text_view_new ();
591 gtk_widget_show (message_textview
);
592 gtk_container_add (GTK_CONTAINER (messages_scrolledwindow
), message_textview
);
593 gtk_text_view_set_editable (GTK_TEXT_VIEW (message_textview
), FALSE
);
594 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (message_textview
), GTK_WRAP_WORD
);
595 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (message_textview
), FALSE
);
597 clear_messages_button
= gtk_button_new_from_stock ("gtk-clear");
598 gtk_widget_show (clear_messages_button
);
599 gtk_box_pack_start (GTK_BOX (vbox11
), clear_messages_button
, FALSE
, FALSE
, 0);
601 Message_label
= gtk_label_new (_("Messages"));
602 gtk_widget_show (Message_label
);
603 gtk_notebook_set_tab_label (GTK_NOTEBOOK (sidepane_notebook
), gtk_notebook_get_nth_page (GTK_NOTEBOOK (sidepane_notebook
), 1), Message_label
);
605 vbox2
= gtk_vbox_new (FALSE
, 0);
606 gtk_widget_show (vbox2
);
607 gtk_paned_pack2 (GTK_PANED (hpaned1
), vbox2
, TRUE
, TRUE
);
609 main_view_table
= gtk_table_new (3, 3, FALSE
);
610 gtk_widget_show (main_view_table
);
611 gtk_box_pack_start (GTK_BOX (vbox2
), main_view_table
, TRUE
, TRUE
, 0);
613 hRuler
= gtk_hruler_new ();
614 gtk_widget_show (hRuler
);
615 gtk_table_attach (GTK_TABLE (main_view_table
), hRuler
, 1, 2, 0, 1,
616 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
617 (GtkAttachOptions
) (GTK_FILL
), 0, 0);
618 gtk_ruler_set_range (GTK_RULER (hRuler
), 0, 100, 8.56051, 10);
620 vRuler
= gtk_vruler_new ();
621 gtk_widget_show (vRuler
);
622 gtk_table_attach (GTK_TABLE (main_view_table
), vRuler
, 0, 1, 1, 2,
623 (GtkAttachOptions
) (GTK_FILL
),
624 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
), 0, 0);
625 gtk_ruler_set_range (GTK_RULER (vRuler
), 0, 100, 8.37341, 10);
627 drawingarea
= gtk_drawing_area_new();
628 gtk_table_attach (GTK_TABLE (main_view_table
), drawingarea
, 1, 2, 1, 2,
629 (GtkAttachOptions
) (GTK_FILL
),
630 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
), 0, 0);
632 hAdjustment
= (GtkWidget
*) gtk_adjustment_new (0.0, -1000.0, 1000.0, 1000.0, 1000.0, 500.0);
633 vAdjustment
= (GtkWidget
*) gtk_adjustment_new (0.0, -1000.0, 1000.0, 1000.0, 1000.0, 500.0);
635 hScrollbar
= gtk_hscrollbar_new (GTK_ADJUSTMENT (hAdjustment
));
636 gtk_table_attach (GTK_TABLE (main_view_table
), hScrollbar
, 1, 2, 2, 3,
637 (GtkAttachOptions
) (GTK_FILL
),
638 (GtkAttachOptions
) (GTK_FILL
), 0, 0);
640 vScrollbar
= gtk_vscrollbar_new (GTK_ADJUSTMENT (vAdjustment
));
641 gtk_table_attach (GTK_TABLE (main_view_table
), vScrollbar
, 2, 3, 1, 2,
642 (GtkAttachOptions
) (GTK_FILL
),
643 (GtkAttachOptions
) (GTK_FILL
), 0, 0);
645 hbox5
= gtk_hbox_new (FALSE
, 10);
646 gtk_widget_show (hbox5
);
647 gtk_box_pack_start (GTK_BOX (vbox2
), hbox5
, FALSE
, FALSE
, 0);
649 statusbar_label_left
= gtk_label_new (_("( 0.0, 0.0 )"));
650 gtk_widget_show (statusbar_label_left
);
651 gtk_box_pack_start (GTK_BOX (hbox5
), statusbar_label_left
, FALSE
, FALSE
, 0);
652 gtk_widget_set_size_request (statusbar_label_left
, 150, -1);
653 gtk_label_set_justify ((GtkLabel
*) statusbar_label_left
, GTK_JUSTIFY_RIGHT
);
655 combobox2
= gtk_combo_box_new_text ();
656 gtk_widget_show (combobox2
);
657 gtk_box_pack_start (GTK_BOX (hbox5
), combobox2
, FALSE
, FALSE
, 0);
658 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox2
), _("mil"));
659 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox2
), _("mm"));
660 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox2
), _("in"));
662 statusbar_label_right
= gtk_label_new (_(""));
663 gtk_widget_show (statusbar_label_right
);
664 gtk_box_pack_start (GTK_BOX (hbox5
), statusbar_label_right
, TRUE
, TRUE
, 0);
665 gtk_misc_set_alignment (GTK_MISC (statusbar_label_right
), 0, 0.5);
668 /* ----------------------------------------------------------------------- */
670 * Connect signals to widgets
672 g_signal_connect ((gpointer
) new, "activate",
673 G_CALLBACK (callbacks_new_activate
),
675 g_signal_connect ((gpointer
) open_project
, "activate",
676 G_CALLBACK (callbacks_open_project_activate
),
678 g_signal_connect ((gpointer
) open_layer
, "activate",
679 G_CALLBACK (callbacks_open_layer_activate
),
681 g_signal_connect ((gpointer
) revert
, "activate",
682 G_CALLBACK (callbacks_revert_activate
),
684 g_signal_connect ((gpointer
) save
, "activate",
685 G_CALLBACK (callbacks_save_activate
),
687 g_signal_connect ((gpointer
) save_as
, "activate",
688 G_CALLBACK (callbacks_generic_save_activate
),
689 (gpointer
) CALLBACKS_SAVE_FILE_AS
);
691 g_signal_connect ((gpointer
) png
, "activate",
692 G_CALLBACK (callbacks_generic_save_activate
),
693 (gpointer
) CALLBACKS_SAVE_FILE_PNG
);
696 #ifndef RENDER_USING_GDK
697 g_signal_connect ((gpointer
) pdf
, "activate",
698 G_CALLBACK (callbacks_generic_save_activate
),
699 (gpointer
) CALLBACKS_SAVE_FILE_PDF
);
700 g_signal_connect ((gpointer
) svg
, "activate",
701 G_CALLBACK (callbacks_generic_save_activate
),
702 (gpointer
) CALLBACKS_SAVE_FILE_SVG
);
703 g_signal_connect ((gpointer
) postscript
, "activate",
704 G_CALLBACK (callbacks_generic_save_activate
),
705 (gpointer
) CALLBACKS_SAVE_FILE_PS
);
708 #if GTK_CHECK_VERSION(2,10,0)
709 g_signal_connect ((gpointer
) print
, "activate",
710 G_CALLBACK (callbacks_print_activate
),
713 g_signal_connect ((gpointer
) quit
, "activate",
714 G_CALLBACK (callbacks_quit_activate
),
716 g_signal_connect ((gpointer
) zoom_in
, "activate",
717 G_CALLBACK (callbacks_zoom_in_activate
),
719 g_signal_connect ((gpointer
) zoom_out
, "activate",
720 G_CALLBACK (callbacks_zoom_out_activate
),
722 g_signal_connect ((gpointer
) fit_to_window
, "activate",
723 G_CALLBACK (callbacks_fit_to_window_activate
),
725 g_signal_connect ((gpointer
) analyze_active_gerbers
, "activate",
726 G_CALLBACK (callbacks_analyze_active_gerbers_activate
),
728 g_signal_connect ((gpointer
) analyze_active_drill
, "activate",
729 G_CALLBACK (callbacks_analyze_active_drill_activate
),
731 g_signal_connect ((gpointer
) control_gerber_options
, "activate",
732 G_CALLBACK (callbacks_control_gerber_options_activate
),
734 g_signal_connect ((gpointer
) pointer_tool
, "activate",
735 G_CALLBACK (callbacks_pointer_tool_activate
),
737 g_signal_connect ((gpointer
) zoom_tool
, "activate",
738 G_CALLBACK (callbacks_zoom_tool_activate
),
740 g_signal_connect ((gpointer
) measure_tool
, "activate",
741 G_CALLBACK (callbacks_measure_tool_activate
),
743 g_signal_connect ((gpointer
) online_manual
, "activate",
744 G_CALLBACK (callbacks_online_manual_activate
),
746 g_signal_connect ((gpointer
) about
, "activate",
747 G_CALLBACK (callbacks_about_activate
),
750 /* End of Glade generated code */
751 g_signal_connect ((gpointer
) toolbutton_new
, "clicked",
752 G_CALLBACK (callbacks_new_activate
),
754 g_signal_connect ((gpointer
) toolbutton_save
, "clicked",
755 G_CALLBACK (callbacks_save_activate
),
757 g_signal_connect ((gpointer
) toolbutton_open
, "clicked",
758 G_CALLBACK (callbacks_open_project_activate
),
760 g_signal_connect ((gpointer
) toolbutton_revert
, "clicked",
761 G_CALLBACK (callbacks_revert_activate
),
763 g_signal_connect ((gpointer
) clear_messages_button
, "clicked",
764 G_CALLBACK (callbacks_clear_messages_button_clicked
),
766 #if GTK_CHECK_VERSION(2,10,0)
767 g_signal_connect ((gpointer
) toolbutton_print
, "clicked",
768 G_CALLBACK (callbacks_print_activate
),
771 g_signal_connect ((gpointer
) toolbutton_zoom_in
, "clicked",
772 G_CALLBACK (callbacks_zoom_in_activate
),
774 g_signal_connect ((gpointer
) toolbutton_zoom_out
, "clicked",
775 G_CALLBACK (callbacks_zoom_out_activate
),
777 g_signal_connect ((gpointer
) toolbutton_zoom_fit
, "clicked",
778 G_CALLBACK (callbacks_fit_to_window_activate
),
780 g_signal_connect ((gpointer
) combobox2
, "changed",
781 G_CALLBACK (callbacks_statusbar_unit_combo_box_changed
),
784 g_signal_connect ((gpointer
) button4
, "clicked",
785 G_CALLBACK (callbacks_add_layer_button_clicked
), NULL
);
786 g_signal_connect ((gpointer
) button7
, "clicked",
787 G_CALLBACK (callbacks_remove_layer_button_clicked
), NULL
);
788 g_signal_connect ((gpointer
) button5
, "clicked",
789 G_CALLBACK (callbacks_move_layer_down_button_clicked
), NULL
);
790 g_signal_connect ((gpointer
) button6
, "clicked",
791 G_CALLBACK (callbacks_move_layer_up_clicked
), NULL
);
793 g_signal_connect ((gpointer
) hAdjustment
, "value-changed",
794 G_CALLBACK (callbacks_hadjustment_value_changed
), NULL
);
795 g_signal_connect ((gpointer
) vAdjustment
, "value-changed",
796 G_CALLBACK (callbacks_vadjustment_value_changed
), NULL
);
798 gtk_combo_box_set_active (GTK_COMBO_BOX (combobox1
), 0);
799 gtk_combo_box_set_active (GTK_COMBO_BOX (combobox2
), 0);
803 gtk_window_add_accel_group (GTK_WINDOW (mainWindow
), accel_group
);
806 GtkListStore
*list_store
;
808 list_store
= gtk_list_store_new (3, G_TYPE_BOOLEAN
,
809 GDK_TYPE_PIXBUF
, G_TYPE_STRING
);
815 tree
= gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store
));
816 GtkCellRenderer
*renderer
;
817 GtkTreeViewColumn
*column
;
819 renderer
= gtk_cell_renderer_toggle_new ();
820 column
= gtk_tree_view_column_new_with_attributes ("Visible",
824 gtk_tree_view_column_set_min_width ((GtkTreeViewColumn
*)column
,25);
825 gtk_signal_connect(GTK_OBJECT(renderer
), "toggled",
826 GTK_SIGNAL_FUNC(callbacks_layer_tree_visibility_button_toggled
), NULL
);
828 gtk_tree_view_append_column (GTK_TREE_VIEW (tree
), column
);
830 renderer
= gtk_cell_renderer_pixbuf_new ();
831 column
= gtk_tree_view_column_new_with_attributes ("Color",
834 gtk_tree_view_append_column (GTK_TREE_VIEW (tree
), column
);
836 renderer
= gtk_cell_renderer_text_new ();
837 column
= gtk_tree_view_column_new_with_attributes ("Name",
841 gtk_tree_view_append_column (GTK_TREE_VIEW (tree
), column
);
843 gtk_tree_view_set_headers_visible ((GtkTreeView
*)tree
, FALSE
);
844 gtk_signal_connect(GTK_OBJECT(tree
), "button-press-event",
845 GTK_SIGNAL_FUNC(callbacks_layer_tree_button_press
), NULL
);
846 gtk_container_add (GTK_CONTAINER (scrolledwindow1
), tree
);
848 GtkTreeSelection
*selection
;
849 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(tree
));
850 gtk_tree_selection_set_mode (selection
, GTK_SELECTION_BROWSE
);
851 gtk_tree_view_set_enable_search (GTK_TREE_VIEW (tree
), FALSE
);
852 gtk_tree_view_set_reorderable (GTK_TREE_VIEW (tree
), TRUE
);
854 g_signal_connect (G_OBJECT(list_store
), "row-inserted",
855 G_CALLBACK (callbacks_layer_tree_row_inserted
), NULL
);
858 * Connect all events on drawing area
860 gtk_signal_connect(GTK_OBJECT(drawingarea
), "expose_event",
861 GTK_SIGNAL_FUNC(callbacks_drawingarea_expose_event
), NULL
);
862 gtk_signal_connect(GTK_OBJECT(drawingarea
),"configure_event",
863 GTK_SIGNAL_FUNC(callbacks_drawingarea_configure_event
), NULL
);
864 gtk_signal_connect(GTK_OBJECT(drawingarea
), "motion_notify_event",
865 GTK_SIGNAL_FUNC(callbacks_drawingarea_motion_notify_event
), NULL
);
866 gtk_signal_connect(GTK_OBJECT(drawingarea
), "button_press_event",
867 GTK_SIGNAL_FUNC(callbacks_drawingarea_button_press_event
), NULL
);
868 gtk_signal_connect(GTK_OBJECT(drawingarea
), "button_release_event",
869 GTK_SIGNAL_FUNC(callbacks_drawingarea_button_release_event
), NULL
);
870 gtk_signal_connect_after(GTK_OBJECT(mainWindow
), "key_press_event",
871 GTK_SIGNAL_FUNC(callbacks_window_key_press_event
), NULL
);
872 gtk_signal_connect_after(GTK_OBJECT(mainWindow
), "key_release_event",
873 GTK_SIGNAL_FUNC(callbacks_window_key_release_event
), NULL
);
874 gtk_signal_connect_after(GTK_OBJECT(mainWindow
), "scroll_event",
875 GTK_SIGNAL_FUNC(callbacks_window_scroll_event
), NULL
);
876 gtk_signal_connect_after(GTK_OBJECT(mainWindow
), "delete_event",
877 GTK_SIGNAL_FUNC(callbacks_quit_activate
), NULL
);
879 gtk_widget_set_events(drawingarea
, GDK_EXPOSURE_MASK
880 | GDK_LEAVE_NOTIFY_MASK
881 | GDK_BUTTON_PRESS_MASK
882 | GDK_BUTTON_RELEASE_MASK
884 | GDK_KEY_RELEASE_MASK
885 | GDK_POINTER_MOTION_MASK
886 | GDK_POINTER_MOTION_HINT_MASK
891 * Set gtk error log handler
893 #if !defined (__MINGW32__)
894 g_log_set_handler (NULL
,
895 G_LOG_FLAG_FATAL
| G_LOG_FLAG_RECURSION
| G_LOG_LEVEL_MASK
,
896 callbacks_handle_log_messages
, NULL
);
900 * Setup some GTK+ defaults
902 screen
.tooltips
= gtk_tooltips_new();
903 GdkColor color1
= {0, 0, 0, 0}, color2
= {0, 5000, 5000, 5000},
904 color3
= {0, 30000, 30000, 65000};
905 screen
.background
= color1
;
906 screen
.zoom_outline_color
= color2
;
907 screen
.dist_measure_color
= color3
;
908 screen
.drawing_area
=drawingarea
;
909 screen
.win
.hAdjustment
= hAdjustment
;
910 screen
.win
.vAdjustment
= vAdjustment
;
911 screen
.win
.hRuler
= hRuler
;
912 screen
.win
.vRuler
= vRuler
;
914 * Good defaults according to Ales. Gives aspect ratio of 1.3333...
916 if ((req_width
!= -1) && (req_height
!= -1)) {
924 screen
= gdk_screen_get_default();
925 nmonitors
= gdk_screen_get_n_monitors(screen
);
927 width
= gdk_screen_get_width(screen
) * 3/4 / nmonitors
;
928 height
= gdk_screen_get_height(screen
) * 3/4 / nmonitors
;
931 gtk_window_set_default_size((GtkWindow
*)mainWindow
, width
, height
);
933 gtk_widget_show_all (mainWindow
);
934 screen
.win
.topLevelWindow
= mainWindow
;
935 screen
.win
.messageTextView
= message_textview
;
936 screen
.win
.statusMessageLeft
= statusbar_label_left
;
937 screen
.win
.statusMessageRight
= statusbar_label_right
;
938 screen
.win
.statusUnitComboBox
= combobox2
;
939 screen
.win
.layerTree
= tree
;
940 screen
.win
.treeIsUpdating
= FALSE
;
942 rename_main_window("",mainWindow
);
944 set_window_icon (mainWindow
);
945 callbacks_update_layer_tree ();