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.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
25 \brief GUI building functions for Gerbv
33 #include <sys/types.h>
39 #include <gdk/gdkkeysyms.h>
44 #include "callbacks.h"
45 #include "interface.h"
48 #ifdef RENDER_USING_GDK
54 #include "gerbv_icon.h"
56 extern gerbv_render_info_t screenRenderInfo
;
58 static GtkWidget
*render_combobox
;
60 #define WIN_TITLE "Gerbv -- gEDA's Gerber Viewer"
61 #define _(String) (String)
63 /* ---------------------------------------------- */
65 rename_main_window(char const* filename
, GtkWidget
*main_win
)
67 GString
*win_title
=g_string_new(NULL
);
68 static GtkWidget
*win
=NULL
;
70 if( main_win
!= NULL
)
73 g_assert(win
!= NULL
);
75 g_string_printf (win_title
,"%s version %s: %s", WIN_TITLE
, VERSION
, filename
);
76 gtk_window_set_title(GTK_WINDOW(win
), win_title
->str
);
77 g_string_free(win_title
,TRUE
);
80 /* ---------------------------------------------- */
82 set_window_icon (GtkWidget
* this_window
)
87 pixmap
= gdk_pixmap_create_from_xpm_d (this_window
->window
, &mask
,
88 &this_window
->style
->bg
[GTK_STATE_NORMAL
], gerbv_icon_xpm
);
89 gdk_window_set_icon (this_window
->window
, NULL
, pixmap
, mask
);
94 /* ---------------------------------------------- */
96 interface_create_gui (int req_width
, int req_height
)
98 GtkWidget
*mainWindow
;
102 GtkWidget
*menuitem_file
;
103 GtkWidget
*menuitem_file_menu
;
105 GtkWidget
*open_project
;
107 GtkWidget
*open_layer
;
111 GtkWidget
*save_layer
;
112 GtkWidget
*save_as_layer
;
113 GtkWidget
*separatormenuitem1
;
115 GtkWidget
*export_menu
;
117 GtkWidget
*separator1
;
120 GtkWidget
*menuitem_edit
;
121 GtkWidget
*menuitem_edit_menu
;
122 GtkWidget
*delete_selected
;
124 GtkWidget
*menuitem_view
;
125 GtkWidget
*menuitem_view_menu
;
128 GtkWidget
*separator5
;
129 GtkWidget
*fit_to_window
;
130 GtkWidget
*menuitem_analyze
;
131 GtkWidget
*menuitem_analyze_menu
;
132 GtkWidget
*analyze_active_gerbers
;
133 GtkWidget
*analyze_active_drill
;
134 GtkWidget
*analyze_display_selected_obj_props
;
135 GtkWidget
*analyze_benchmark
;
137 GtkWidget *control_gerber_options;
139 GtkWidget
*menubar_tools
;
140 GtkWidget
*menubar_tools_menu
;
141 #ifndef RENDER_USING_GDK
142 GtkWidget
*toggletoolbutton_pointer
;
143 GtkWidget
*pointer_tool
;
144 GdkPixbuf
*pointerpixbuf
;
145 GtkWidget
*pointerimage
;
148 GtkWidget
*zoom_tool
;
149 GtkWidget
*measure_tool
;
150 GtkWidget
*menuitem10
;
151 GtkWidget
*menuitem10_menu
;
152 /*GtkWidget *online_manual;*/
154 GtkWidget
*bugs_menuitem
;
156 GtkWidget
*toolbar_hbox
;
157 GtkWidget
*handlebox
;
158 GtkWidget
*button_toolbar
;
159 GtkIconSize tmp_toolbar_icon_size
;
160 GtkWidget
*toolbutton_new
;
161 GtkWidget
*toolbutton_open
;
162 GtkWidget
*toolbutton_revert
;
163 GtkWidget
*toolbutton_save
;
164 GtkWidget
*separatortoolitem1
;
165 #ifndef RENDER_USING_GDK
166 #if GTK_CHECK_VERSION(2,10,0)
168 GtkWidget
*toolbutton_print
;
169 GtkWidget
*separator2
;
170 GtkWidget
*separatortoolitem2
;
173 GtkWidget
*toolbutton_zoom_in
;
174 GtkWidget
*toolbutton_zoom_out
;
175 GtkWidget
*toolbutton_zoom_fit
;
176 /* Implement these tool buttons later when we have icons */
177 /* GtkWidget *separatortoolitem3; */
178 /* GtkWidget *toolbutton_analyze; */
179 /* GtkWidget *toolbutton_validate;*/
180 /* GtkWidget *toolbutton_control; */
181 GtkWidget
*separatortoolitem4
;
182 GtkWidget
*toggletoolbutton_pan
;
183 GtkWidget
*toggletoolbutton_zoom
;
184 GtkWidget
*toggletoolbutton_measure
;
186 GtkWidget
*sidepane_vbox
;
187 GtkWidget
*sidepane_notebook
;
191 GtkWidget
*scrolledwindow1
;
201 GtkWidget
*Layer_label
;
203 GtkWidget
*messages_scrolledwindow
;
204 GtkWidget
*message_textview
;
205 GtkWidget
*clear_messages_button
;
206 GtkWidget
*Message_label
;
208 GtkWidget
*main_view_table
;
212 GtkWidget
*statusbar_label_left
;
213 GtkWidget
*combobox2
;
214 GtkWidget
*statusbar_label_right
;
215 GtkWidget
*drawingarea
, *hAdjustment
, *vAdjustment
, *hScrollbar
, *vScrollbar
;
217 GtkAccelGroup
*accel_group
;
218 GtkTooltips
*tooltips
;
221 GdkPixbuf
*zoompixbuf
;
222 GtkWidget
*zoomimage
;
223 GdkPixbuf
*measurepixbuf
;
224 GtkWidget
*measureimage
;
225 GdkPixbuf
*movepixbuf
;
226 GtkWidget
*moveimage
;
228 GtkWidget
*tempImage
;
229 GtkWidget
*tempMenuItem
;
232 #ifndef RENDER_USING_GDK
233 pointerpixbuf
= gdk_pixbuf_new_from_inline(-1, pointer
, FALSE
, NULL
);
235 movepixbuf
= gdk_pixbuf_new_from_inline(-1, move
, FALSE
, NULL
);
236 zoompixbuf
= gdk_pixbuf_new_from_inline(-1, lzoom
, FALSE
, NULL
);
237 measurepixbuf
= gdk_pixbuf_new_from_inline(-1, ruler
, FALSE
, NULL
);
239 tooltips
= gtk_tooltips_new();
240 accel_group
= gtk_accel_group_new ();
242 mainWindow
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
243 gtk_window_set_title (GTK_WINDOW (mainWindow
), _("Gerbv -- gEDA's Gerber Viewer"));
245 vbox1
= gtk_vbox_new (FALSE
, 0);
246 gtk_container_add (GTK_CONTAINER (mainWindow
), vbox1
);
248 menubar1
= gtk_menu_bar_new ();
249 gtk_box_pack_start (GTK_BOX (vbox1
), menubar1
, FALSE
, FALSE
, 0);
251 /* --- File menu --- */
252 menuitem_file
= gtk_menu_item_new_with_mnemonic (_("_File"));
253 gtk_container_add (GTK_CONTAINER (menubar1
), menuitem_file
);
255 /* File menu items dealing with a gerbv project. */
256 menuitem_file_menu
= gtk_menu_new ();
257 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_file
), menuitem_file_menu
);
259 new = gtk_image_menu_item_new_from_stock ("gtk-new", accel_group
);
260 gtk_tooltips_set_tip (tooltips
, new, "Close all layers and start a new project", NULL
);
261 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), new);
262 gtk_widget_add_accelerator (new, "activate", accel_group
,
263 GDK_n
, (GdkModifierType
) GDK_CONTROL_MASK
,
267 open_project
= gtk_image_menu_item_new_with_mnemonic (_("_Open Project..."));
268 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), open_project
);
269 gtk_tooltips_set_tip (tooltips
, open_project
, "Open an existing Gerbv project", NULL
);
270 image33
= gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU
);
271 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (open_project
), image33
);
273 save
= gtk_image_menu_item_new_with_mnemonic ("Save Project");
274 gtk_tooltips_set_tip (tooltips
, save
, "Save the current project", NULL
);
275 tempImage
= gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_MENU
);
276 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (save
), tempImage
);
277 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), save
);
279 save_as
= gtk_image_menu_item_new_with_mnemonic ("Save Project As...");
280 gtk_tooltips_set_tip (tooltips
, save_as
, "Save the current project to a new file", NULL
);
281 tempImage
= gtk_image_new_from_stock ("gtk-save-as", GTK_ICON_SIZE_MENU
);
282 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (save_as
), tempImage
);
283 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), save_as
);
285 revert
= gtk_image_menu_item_new_from_stock ("gtk-revert-to-saved", accel_group
);
286 gtk_tooltips_set_tip (tooltips
, revert
, "Reload all layers", NULL
);
287 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), revert
);
289 /* File menu items dealing individual layers. */
290 separator1
= gtk_separator_menu_item_new ();
291 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), separator1
);
292 gtk_widget_set_sensitive (separator1
, FALSE
);
294 open_layer
= gtk_menu_item_new_with_mnemonic (_("Open _Layer(s)..."));
295 gtk_widget_add_accelerator (open_layer
, "activate", accel_group
, 'O', GDK_CONTROL_MASK
,
297 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), open_layer
);
298 gtk_tooltips_set_tip (tooltips
, open_layer
, "Open Gerber, drill, or pick and place file(s)", NULL
);
300 save_layer
= gtk_menu_item_new_with_mnemonic (_("_Save active layer"));
301 gtk_tooltips_set_tip (tooltips
, save_layer
, "Save the active layer", NULL
);
302 gtk_widget_add_accelerator (save_layer
, "activate", accel_group
, 'S', GDK_CONTROL_MASK
,
304 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), save_layer
);
306 save_as_layer
= gtk_menu_item_new_with_mnemonic (_("Save active layer _As..."));
307 gtk_tooltips_set_tip (tooltips
, save_as_layer
, "Save the active layer to a new file", NULL
);
308 gtk_widget_add_accelerator (save_as_layer
, "activate", accel_group
, 'S',
309 GDK_CONTROL_MASK
| GDK_SHIFT_MASK
, GTK_ACCEL_VISIBLE
);
310 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), save_as_layer
);
312 /* File menu items dealing with exporting different types of files. */
313 separatormenuitem1
= gtk_separator_menu_item_new ();
314 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), separatormenuitem1
);
315 gtk_widget_set_sensitive (separatormenuitem1
, FALSE
);
317 export
= gtk_menu_item_new_with_mnemonic (_("_Export"));
318 gtk_tooltips_set_tip (tooltips
, export
, "Export all visible layers to a new format", NULL
);
319 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), export
);
321 export_menu
= gtk_menu_new ();
322 gtk_menu_item_set_submenu (GTK_MENU_ITEM (export
), export_menu
);
324 png
= gtk_menu_item_new_with_mnemonic (_("PNG..."));
325 gtk_container_add (GTK_CONTAINER (export_menu
), png
);
326 gtk_tooltips_set_tip (tooltips
, png
, _("Export project to a PNG file..."), NULL
);
328 GtkWidget
*rs274x
,*drill
;
329 #ifndef RENDER_USING_GDK
332 GtkWidget
*postscript
;
334 pdf
= gtk_menu_item_new_with_mnemonic (_("PDF..."));
335 gtk_container_add (GTK_CONTAINER (export_menu
), pdf
);
336 gtk_tooltips_set_tip (tooltips
, pdf
, _("Export project to a PDF file..."), NULL
);
338 svg
= gtk_menu_item_new_with_mnemonic (_("SVG..."));
339 gtk_container_add (GTK_CONTAINER (export_menu
), svg
);
340 gtk_tooltips_set_tip (tooltips
, svg
, _("Export project to a SVG file"), NULL
);
342 postscript
= gtk_menu_item_new_with_mnemonic (_("PostScript..."));
343 gtk_container_add (GTK_CONTAINER (export_menu
), postscript
);
344 gtk_tooltips_set_tip (tooltips
, postscript
, _("Export project to a PostScript file"), NULL
);
346 rs274x
= gtk_menu_item_new_with_mnemonic (_("RS-274X (Gerber)..."));
347 gtk_container_add (GTK_CONTAINER (export_menu
), rs274x
);
348 gtk_tooltips_set_tip (tooltips
, rs274x
, _("Export layer to a RS-274X (Gerber) file"), NULL
);
350 drill
= gtk_menu_item_new_with_mnemonic (_("Excellon drill..."));
351 gtk_container_add (GTK_CONTAINER (export_menu
), drill
);
352 gtk_tooltips_set_tip (tooltips
, drill
, _("Export layer to an Excellon drill file"), NULL
);
354 /* File menu items dealing with printing and quitting. */
355 separator1
= gtk_separator_menu_item_new ();
356 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), separator1
);
357 gtk_widget_set_sensitive (separator1
, FALSE
);
358 #ifndef RENDER_USING_GDK
359 #if GTK_CHECK_VERSION(2,10,0)
360 if (gtk_stock_lookup("gtk-print", &item
)) {
361 gchar
new[] = "_Print...";
363 gtk_stock_add(&item
, 1);
366 print
= gtk_image_menu_item_new_from_stock ("gtk-print", accel_group
);
367 gtk_tooltips_set_tip (tooltips
, print
, "Print the visible layers", NULL
);
368 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), print
);
370 separator2
= gtk_separator_menu_item_new ();
371 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), separator2
);
372 gtk_widget_set_sensitive (separator2
, FALSE
);
375 quit
= gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group
);
376 gtk_tooltips_set_tip (tooltips
, quit
, "Quit Gerbv", NULL
);
377 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), quit
);
379 /* --- Next menu item (Edit) --- */
380 menuitem_edit
= gtk_menu_item_new_with_mnemonic (_("_Edit"));
381 gtk_container_add (GTK_CONTAINER (menubar1
), menuitem_edit
);
383 menuitem_edit_menu
= gtk_menu_new ();
384 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_edit
), menuitem_edit_menu
);
386 delete_selected
= gtk_image_menu_item_new_with_mnemonic (_("_Delete selected object(s)"));
387 gtk_tooltips_set_tip (tooltips
, delete_selected
,
388 "Delete selected objects", NULL
);
389 tempImage
= gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_MENU
);
390 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (delete_selected
), tempImage
);
391 gtk_container_add (GTK_CONTAINER (menuitem_edit_menu
), delete_selected
);
392 gtk_widget_add_accelerator (delete_selected
, "activate", accel_group
,
393 GDK_Delete
, (GdkModifierType
) 0, GTK_ACCEL_VISIBLE
);
396 /* --- Next menu item --- */
397 menuitem_view
= gtk_menu_item_new_with_mnemonic (_("_View"));
398 gtk_container_add (GTK_CONTAINER (menubar1
), menuitem_view
);
400 menuitem_view_menu
= gtk_menu_new ();
401 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_view
), menuitem_view_menu
);
403 zoom_in
= gtk_image_menu_item_new_from_stock ("gtk-zoom-in", accel_group
);
404 gtk_tooltips_set_tip (tooltips
, zoom_in
, "Zoom in", NULL
);
405 gtk_container_add (GTK_CONTAINER (menuitem_view_menu
), zoom_in
);
406 gtk_widget_add_accelerator (zoom_in
, "activate", accel_group
,
407 GDK_z
, (GdkModifierType
) 0, GTK_ACCEL_VISIBLE
);
409 zoom_out
= gtk_image_menu_item_new_from_stock ("gtk-zoom-out", accel_group
);
410 gtk_tooltips_set_tip (tooltips
, zoom_out
, "Zoom out", NULL
);
411 gtk_container_add (GTK_CONTAINER (menuitem_view_menu
), zoom_out
);
412 gtk_widget_add_accelerator (zoom_out
, "activate", accel_group
,
413 GDK_z
, (GdkModifierType
) GDK_SHIFT_MASK
,
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 fit_to_window
= gtk_image_menu_item_new_from_stock ("gtk-zoom-fit", accel_group
);
421 gtk_tooltips_set_tip (tooltips
, fit_to_window
, "Zoom to fit all visible layers in the window", NULL
);
422 gtk_container_add (GTK_CONTAINER (menuitem_view_menu
), fit_to_window
);
423 gtk_widget_add_accelerator (fit_to_window
, "activate", accel_group
,
424 GDK_f
, (GdkModifierType
) 0,
427 menuitem_analyze
= gtk_menu_item_new_with_mnemonic (_("_Analyze"));
428 gtk_container_add (GTK_CONTAINER (menubar1
), menuitem_analyze
);
430 menuitem_analyze_menu
= gtk_menu_new ();
431 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_analyze
), menuitem_analyze_menu
);
433 analyze_active_gerbers
= gtk_menu_item_new_with_mnemonic (_("Analyze visible _Gerber layers"));
434 gtk_tooltips_set_tip (tooltips
, analyze_active_gerbers
,
435 "Examine a detailed anaylsis of the contents of all visible Gerber layers", NULL
);
436 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu
), analyze_active_gerbers
);
438 analyze_active_drill
= gtk_menu_item_new_with_mnemonic (_("Analyze visible _drill layers"));
439 gtk_tooltips_set_tip (tooltips
, analyze_active_drill
,
440 "Examine a detailed anaylsis of the contents of all visible drill layers", NULL
);
441 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu
), analyze_active_drill
);
444 analyze_display_selected_obj_props
= gtk_menu_item_new_with_mnemonic (_("Display selected object(s) _properties"));
445 gtk_tooltips_set_tip (tooltips
, analyze_display_selected_obj_props
,
446 "Show the properties of the selected object(s).", NULL
);
447 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu
), analyze_display_selected_obj_props
);
448 gtk_widget_add_accelerator (analyze_display_selected_obj_props
,
449 "activate", accel_group
, GDK_q
, (GdkModifierType
) 0,
452 analyze_benchmark
= gtk_menu_item_new_with_mnemonic (_("_Benchmark"));
453 gtk_tooltips_set_tip (tooltips
, analyze_benchmark
,
454 "Show the properties of the selected object(s).", NULL
);
455 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu
), analyze_benchmark
);
458 /* Wait and add in for 2.1??
459 control_gerber_options = gtk_menu_item_new_with_mnemonic (_("Control Gerber options..."));
460 gtk_tooltips_set_tip (tooltips, control_gerber_options, "Set which Gerber features should be displayed", NULL);
461 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu), control_gerber_options);
463 menubar_tools
= gtk_menu_item_new_with_mnemonic (_("_Tools"));
464 gtk_container_add (GTK_CONTAINER (menubar1
), menubar_tools
);
466 menubar_tools_menu
= gtk_menu_new ();
467 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menubar_tools
), menubar_tools_menu
);
468 #ifndef RENDER_USING_GDK
469 pointer_tool
= gtk_image_menu_item_new_with_mnemonic (_("_Pointer Tool"));
471 GtkWidget *tempImage = gtk_image_new_from_pixbuf (pointerpixbuf);
472 gtk_image_menu_item_set_image ((GtkImageMenuItem *)pointer_tool, tempImage);
474 gtk_container_add (GTK_CONTAINER (menubar_tools_menu
), pointer_tool
);
475 gtk_tooltips_set_tip (tooltips
, pointer_tool
, "Select objects on the screen", NULL
);
476 gtk_widget_add_accelerator (pointer_tool
, "activate", accel_group
,
477 GDK_F1
, (GdkModifierType
) 0,
480 pan_tool
= gtk_image_menu_item_new_with_mnemonic ("Pa_n Tool");
482 tempImage = gtk_image_new_from_pixbuf (movepixbuf);
483 gtk_image_menu_item_set_image ((GtkImageMenuItem *)pan_tool, tempImage);
485 gtk_container_add (GTK_CONTAINER (menubar_tools_menu
), pan_tool
);
486 gtk_tooltips_set_tip (tooltips
, pan_tool
, "Pan by left clicking and dragging", NULL
);
487 gtk_widget_add_accelerator (pan_tool
, "activate", accel_group
,
488 GDK_F2
, (GdkModifierType
) 0,
491 zoom_tool
= gtk_image_menu_item_new_with_mnemonic (_("_Zoom Tool"));
493 tempImage = gtk_image_new_from_pixbuf (zoompixbuf);
494 gtk_image_menu_item_set_image ((GtkImageMenuItem *)zoom_tool, tempImage);
496 gtk_container_add (GTK_CONTAINER (menubar_tools_menu
), zoom_tool
);
497 gtk_tooltips_set_tip (tooltips
, zoom_tool
, "Zoom by left clicking or dragging", NULL
);
498 gtk_widget_add_accelerator (zoom_tool
, "activate", accel_group
,
499 GDK_F3
, (GdkModifierType
) 0,
502 measure_tool
= gtk_image_menu_item_new_with_mnemonic (_("_Measure Tool"));
504 tempImage = gtk_image_new_from_pixbuf (measurepixbuf);
505 gtk_image_menu_item_set_image ((GtkImageMenuItem *)measure_tool, tempImage);
507 gtk_container_add (GTK_CONTAINER (menubar_tools_menu
), measure_tool
);
508 gtk_tooltips_set_tip (tooltips
, measure_tool
, "Measure distances on the screen", NULL
);
509 gtk_widget_add_accelerator (measure_tool
, "activate", accel_group
,
510 GDK_F4
, (GdkModifierType
) 0,
513 menuitem10
= gtk_menu_item_new_with_mnemonic (_("_Help"));
514 gtk_container_add (GTK_CONTAINER (menubar1
), menuitem10
);
516 menuitem10_menu
= gtk_menu_new ();
517 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem10
), menuitem10_menu
);
519 online_manual = gtk_menu_item_new_with_mnemonic (_("_Online Manual..."));
520 gtk_container_add (GTK_CONTAINER (menuitem10_menu), online_manual);
521 gtk_tooltips_set_tip (tooltips, online_manual, "View the online help documentation", NULL);
525 about
= gtk_image_menu_item_new_with_mnemonic (_("_About Gerbv..."));
526 gtk_container_add (GTK_CONTAINER (menuitem10_menu
), about
);
527 gtk_tooltips_set_tip (tooltips
, about
, "View information about gerbv", NULL
);
528 image34
= gtk_image_new_from_stock ("gtk-dialog-info", GTK_ICON_SIZE_MENU
);
529 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (about
), image34
);
531 bugs_menuitem
= gtk_menu_item_new_with_mnemonic (_("Known _bugs in this version..."));
532 gtk_container_add (GTK_CONTAINER (menuitem10_menu
), bugs_menuitem
);
533 gtk_tooltips_set_tip (tooltips
, bugs_menuitem
, "View list of known gerbv bugs", NULL
);
535 /* Create toolbar (button bar) beneath main menu */
536 toolbar_hbox
= gtk_hbox_new (FALSE
, 0);
537 gtk_box_pack_start (GTK_BOX (vbox1
), toolbar_hbox
, FALSE
, FALSE
, 0);
539 handlebox
= gtk_handle_box_new ();
541 gtk_box_pack_start (GTK_BOX (toolbar_hbox
), handlebox
, TRUE
, TRUE
, 0);
543 button_toolbar
= gtk_toolbar_new ();
544 gtk_widget_set_size_request (button_toolbar
, 500, -1);
545 gtk_container_add (GTK_CONTAINER (handlebox
), button_toolbar
);
546 gtk_toolbar_set_style (GTK_TOOLBAR (button_toolbar
), GTK_TOOLBAR_ICONS
);
547 tmp_toolbar_icon_size
= gtk_toolbar_get_icon_size (GTK_TOOLBAR (button_toolbar
));
549 toolbutton_new
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-new");
550 gtk_tooltips_set_tip (tooltips
, toolbutton_new
, "Close all layers and start a new project", NULL
);
551 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_new
);
553 toolbutton_open
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-open");
554 gtk_tooltips_set_tip (tooltips
, toolbutton_open
, "Open a previously saved gerbv project", NULL
);
555 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_open
);
557 toolbutton_revert
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-revert-to-saved");
558 gtk_tooltips_set_tip (tooltips
, toolbutton_revert
, "Reload all layers in project", NULL
);
559 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_revert
);
561 toolbutton_save
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-save");
562 gtk_tooltips_set_tip (tooltips
, toolbutton_save
, "Save the current project", NULL
);
563 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_save
);
565 separatortoolitem1
= (GtkWidget
*) gtk_separator_tool_item_new ();
566 gtk_container_add (GTK_CONTAINER (button_toolbar
), separatortoolitem1
);
567 #ifndef RENDER_USING_GDK
568 #if GTK_CHECK_VERSION(2,10,0)
569 toolbutton_print
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-print");
570 gtk_tooltips_set_tip (tooltips
, toolbutton_print
, "Print the visible layers", NULL
);
571 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_print
);
573 separatortoolitem2
= (GtkWidget
*) gtk_separator_tool_item_new ();
574 gtk_container_add (GTK_CONTAINER (button_toolbar
), separatortoolitem2
);
577 toolbutton_zoom_in
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-zoom-in");
578 gtk_tooltips_set_tip (tooltips
, toolbutton_zoom_in
, "Zoom in", NULL
);
579 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_zoom_in
);
581 toolbutton_zoom_out
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-zoom-out");
582 gtk_tooltips_set_tip (tooltips
, toolbutton_zoom_out
, "Zoom out", NULL
);
583 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_zoom_out
);
585 toolbutton_zoom_fit
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-zoom-fit");
586 gtk_tooltips_set_tip (tooltips
, toolbutton_zoom_fit
, "Zoom to fit all visible layers in the window", NULL
);
587 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_zoom_fit
);
589 /* Turn these on later when we have icons for these buttons */
591 separatortoolitem3 = (GtkWidget*) gtk_separator_tool_item_new ();
592 gtk_container_add (GTK_CONTAINER (button_toolbar), separatortoolitem3);
594 toolbutton_analyze = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-apply");
595 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_analyze);
597 toolbutton_validate = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-apply");
598 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_validate);
600 toolbutton_control = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-apply");
601 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_control);
604 separatortoolitem4
= (GtkWidget
*) gtk_separator_tool_item_new ();
605 gtk_container_add (GTK_CONTAINER (button_toolbar
), separatortoolitem4
);
606 #ifndef RENDER_USING_GDK
607 toggletoolbutton_pointer
= (GtkWidget
*) gtk_toggle_tool_button_new();
608 pointerimage
= gtk_image_new_from_pixbuf(pointerpixbuf
);
609 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_pointer
),
611 gtk_tooltips_set_tip (tooltips
, toggletoolbutton_pointer
, "Select objects on the screen", NULL
);
612 gtk_container_add (GTK_CONTAINER (button_toolbar
), toggletoolbutton_pointer
);
614 toggletoolbutton_pan
= (GtkWidget
*) gtk_toggle_tool_button_new();
615 moveimage
= gtk_image_new_from_pixbuf(movepixbuf
);
616 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_pan
),
618 gtk_tooltips_set_tip (tooltips
, toggletoolbutton_pan
, "Pan by left clicking and dragging", NULL
);
619 gtk_container_add (GTK_CONTAINER (button_toolbar
), toggletoolbutton_pan
);
622 toggletoolbutton_zoom
= (GtkWidget
*) gtk_toggle_tool_button_new();
623 zoomimage
= gtk_image_new_from_pixbuf(zoompixbuf
);
624 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_zoom
),
626 gtk_tooltips_set_tip (tooltips
, toggletoolbutton_zoom
, "Zoom by left clicking or dragging", NULL
);
627 gtk_container_add (GTK_CONTAINER (button_toolbar
), toggletoolbutton_zoom
);
629 toggletoolbutton_measure
= (GtkWidget
*) gtk_toggle_tool_button_new();
630 measureimage
= gtk_image_new_from_pixbuf(measurepixbuf
);
631 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_measure
),
633 gtk_tooltips_set_tip (tooltips
, toggletoolbutton_measure
, "Measure distances on the screen", NULL
);
634 gtk_container_add (GTK_CONTAINER (button_toolbar
), toggletoolbutton_measure
);
636 hpaned1
= gtk_hpaned_new ();
637 gtk_box_pack_start (GTK_BOX (vbox1
), hpaned1
, TRUE
, TRUE
, 0);
638 gtk_paned_set_position (GTK_PANED (hpaned1
), 225);
640 sidepane_vbox
= gtk_vbox_new (FALSE
, 0);
641 gtk_widget_set_size_request (sidepane_vbox
, 150, -1);
643 gtk_paned_pack1 (GTK_PANED (hpaned1
), sidepane_vbox
, TRUE
, FALSE
);
644 gtk_container_set_border_width (GTK_CONTAINER (sidepane_vbox
), 5);
646 sidepane_notebook
= gtk_notebook_new ();
647 gtk_widget_set_size_request (sidepane_notebook
, 100, -1);
648 gtk_box_pack_start (GTK_BOX (sidepane_vbox
), sidepane_notebook
, TRUE
, TRUE
, 0);
650 vbox10
= gtk_vbox_new (FALSE
, 3);
651 gtk_container_add (GTK_CONTAINER (sidepane_notebook
), vbox10
);
652 gtk_widget_set_size_request (vbox10
, 82, -1);
653 gtk_container_set_border_width (GTK_CONTAINER (vbox10
), 4);
655 hbox4
= gtk_hbox_new (FALSE
, 0);
656 gtk_box_pack_start (GTK_BOX (vbox10
), hbox4
, FALSE
, FALSE
, 0);
658 label1
= gtk_label_new (_("Rendering: "));
659 gtk_box_pack_start (GTK_BOX (hbox4
), label1
, FALSE
, FALSE
, 0);
661 render_combobox
= gtk_combo_box_new_text ();
662 gtk_box_pack_start (GTK_BOX (hbox4
), render_combobox
, TRUE
, TRUE
, 0);
663 #ifdef RENDER_USING_GDK
664 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox
), _("Normal"));
665 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox
), _("XOR"));
666 if (screenRenderInfo
.renderType
< 2)
667 gtk_combo_box_set_active (GTK_COMBO_BOX (render_combobox
), screenRenderInfo
.renderType
);
669 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox
), _("Fast"));
670 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox
), _("Fast, with XOR"));
671 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox
), _("Normal"));
672 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox
), _("High quality"));
673 if (screenRenderInfo
.renderType
< 4)
674 gtk_combo_box_set_active (GTK_COMBO_BOX (render_combobox
), screenRenderInfo
.renderType
);
676 scrolledwindow1
= gtk_scrolled_window_new (NULL
, NULL
);
677 gtk_box_pack_start (GTK_BOX (vbox10
), scrolledwindow1
, TRUE
, TRUE
, 0);
678 gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow1
), 2);
679 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1
),
680 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
681 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1
),
684 hbox1
= gtk_hbox_new (TRUE
, 0);
685 gtk_box_pack_start (GTK_BOX (vbox10
), hbox1
, FALSE
, FALSE
, 0);
687 button4
= gtk_button_new ();
688 gtk_box_pack_start (GTK_BOX (hbox1
), button4
, FALSE
, TRUE
, 0);
690 image8
= gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_BUTTON
);
691 gtk_container_add (GTK_CONTAINER (button4
), image8
);
693 button5
= gtk_button_new ();
694 gtk_box_pack_start (GTK_BOX (hbox1
), button5
, FALSE
, TRUE
, 0);
696 image9
= gtk_image_new_from_stock ("gtk-go-down", GTK_ICON_SIZE_BUTTON
);
697 gtk_container_add (GTK_CONTAINER (button5
), image9
);
699 button6
= gtk_button_new ();
700 gtk_box_pack_start (GTK_BOX (hbox1
), button6
, FALSE
, TRUE
, 0);
702 image10
= gtk_image_new_from_stock ("gtk-go-up", GTK_ICON_SIZE_BUTTON
);
703 gtk_container_add (GTK_CONTAINER (button6
), image10
);
705 button7
= gtk_button_new ();
706 gtk_box_pack_start (GTK_BOX (hbox1
), button7
, FALSE
, TRUE
, 0);
708 image11
= gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_BUTTON
);
709 gtk_container_add (GTK_CONTAINER (button7
), image11
);
711 Layer_label
= gtk_label_new (_("Layers"));
712 gtk_notebook_set_tab_label (GTK_NOTEBOOK (sidepane_notebook
),
713 gtk_notebook_get_nth_page (GTK_NOTEBOOK (sidepane_notebook
), 0),
716 vbox11
= gtk_vbox_new (FALSE
, 2);
717 gtk_container_add (GTK_CONTAINER (sidepane_notebook
), vbox11
);
718 gtk_container_set_border_width (GTK_CONTAINER (vbox11
), 3);
720 messages_scrolledwindow
= gtk_scrolled_window_new (NULL
, NULL
);
721 gtk_box_pack_start (GTK_BOX (vbox11
), messages_scrolledwindow
, TRUE
, TRUE
, 0);
722 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (messages_scrolledwindow
),
723 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
725 message_textview
= gtk_text_view_new ();
726 gtk_container_add (GTK_CONTAINER (messages_scrolledwindow
), message_textview
);
727 gtk_text_view_set_editable (GTK_TEXT_VIEW (message_textview
), FALSE
);
728 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (message_textview
), GTK_WRAP_WORD
);
729 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (message_textview
), FALSE
);
731 clear_messages_button
= gtk_button_new_from_stock ("gtk-clear");
732 gtk_box_pack_start (GTK_BOX (vbox11
), clear_messages_button
, FALSE
, FALSE
, 0);
734 Message_label
= gtk_label_new (_("Messages"));
735 gtk_notebook_set_tab_label (GTK_NOTEBOOK (sidepane_notebook
),
736 gtk_notebook_get_nth_page (GTK_NOTEBOOK (sidepane_notebook
), 1),
739 vbox2
= gtk_vbox_new (FALSE
, 4);
740 gtk_paned_pack2 (GTK_PANED (hpaned1
), vbox2
, TRUE
, FALSE
);
741 gtk_container_set_border_width (GTK_CONTAINER (vbox2
), 4);
743 main_view_table
= gtk_table_new (3, 3, FALSE
);
744 gtk_box_pack_start (GTK_BOX (vbox2
), main_view_table
, TRUE
, TRUE
, 0);
746 hRuler
= gtk_hruler_new ();
747 gtk_table_attach (GTK_TABLE (main_view_table
), hRuler
, 1, 2, 0, 1,
748 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
749 (GtkAttachOptions
) (GTK_FILL
), 0, 0);
750 gtk_ruler_set_range (GTK_RULER (hRuler
), 0, 100, 8.56051, 1000);
752 vRuler
= gtk_vruler_new ();
753 gtk_table_attach (GTK_TABLE (main_view_table
), vRuler
, 0, 1, 1, 2,
754 (GtkAttachOptions
) (GTK_FILL
),
755 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
), 0, 0);
756 gtk_ruler_set_range (GTK_RULER (vRuler
), 0, 100, 8.37341, 1000);
758 drawingarea
= gtk_drawing_area_new();
759 gtk_table_attach (GTK_TABLE (main_view_table
), drawingarea
, 1, 2, 1, 2,
760 (GtkAttachOptions
) (GTK_FILL
),
761 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
), 0, 0);
763 hAdjustment
= (GtkWidget
*) gtk_adjustment_new (0.0, -1000.0, 1000.0, 1000.0, 1000.0, 500.0);
764 vAdjustment
= (GtkWidget
*) gtk_adjustment_new (0.0, -1000.0, 1000.0, 1000.0, 1000.0, 500.0);
766 hScrollbar
= gtk_hscrollbar_new (GTK_ADJUSTMENT (hAdjustment
));
767 gtk_table_attach (GTK_TABLE (main_view_table
), hScrollbar
, 1, 2, 2, 3,
768 (GtkAttachOptions
) (GTK_FILL
),
769 (GtkAttachOptions
) (GTK_FILL
), 0, 0);
771 vScrollbar
= gtk_vscrollbar_new (GTK_ADJUSTMENT (vAdjustment
));
772 gtk_table_attach (GTK_TABLE (main_view_table
), vScrollbar
, 2, 3, 1, 2,
773 (GtkAttachOptions
) (GTK_FILL
),
774 (GtkAttachOptions
) (GTK_FILL
), 0, 0);
776 GtkWidget
*frame1
= gtk_frame_new (NULL
);
777 gtk_box_pack_start (GTK_BOX (vbox2
), frame1
, FALSE
, FALSE
, 0);
779 hbox5
= gtk_hbox_new (FALSE
, 10);
780 gtk_container_add (GTK_CONTAINER(frame1
), hbox5
);
782 statusbar_label_left
= gtk_label_new (_("( 0.0, 0.0 )"));
783 gtk_box_pack_start (GTK_BOX (hbox5
), statusbar_label_left
, FALSE
, FALSE
, 0);
784 gtk_widget_set_size_request (statusbar_label_left
, 130, -1);
785 gtk_label_set_justify ((GtkLabel
*) statusbar_label_left
, GTK_JUSTIFY_RIGHT
);
787 combobox2
= gtk_combo_box_new_text ();
788 gtk_box_pack_start (GTK_BOX (hbox5
), combobox2
, FALSE
, FALSE
, 0);
789 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox2
), _("mil"));
790 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox2
), _("mm"));
791 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox2
), _("in"));
793 statusbar_label_right
= gtk_label_new (_(""));
794 gtk_box_pack_start (GTK_BOX (hbox5
), statusbar_label_right
, TRUE
, TRUE
, 0);
795 gtk_label_set_ellipsize ((GtkLabel
*)statusbar_label_right
, PANGO_ELLIPSIZE_END
);
796 gtk_misc_set_alignment (GTK_MISC (statusbar_label_right
), 0, 0.5);
801 * Connect signals to widgets
804 /* --- File menu --- */
805 g_signal_connect ((gpointer
) new, "activate",
806 G_CALLBACK (callbacks_new_activate
),
808 g_signal_connect ((gpointer
) open_project
, "activate",
809 G_CALLBACK (callbacks_open_project_activate
),
811 g_signal_connect ((gpointer
) open_layer
, "activate",
812 G_CALLBACK (callbacks_open_layer_activate
),
814 g_signal_connect ((gpointer
) revert
, "activate",
815 G_CALLBACK (callbacks_revert_activate
),
817 g_signal_connect ((gpointer
) save_layer
, "activate",
818 G_CALLBACK (callbacks_save_layer_activate
),
820 g_signal_connect ((gpointer
) save_as_layer
, "activate",
821 G_CALLBACK (callbacks_generic_save_activate
),
822 (gpointer
) CALLBACKS_SAVE_LAYER_AS
);
823 g_signal_connect ((gpointer
) save
, "activate",
824 G_CALLBACK (callbacks_save_project_activate
),
826 g_signal_connect ((gpointer
) save_as
, "activate",
827 G_CALLBACK (callbacks_generic_save_activate
),
828 (gpointer
) CALLBACKS_SAVE_PROJECT_AS
);
830 g_signal_connect ((gpointer
) png
, "activate",
831 G_CALLBACK (callbacks_generic_save_activate
),
832 (gpointer
) CALLBACKS_SAVE_FILE_PNG
);
835 #ifndef RENDER_USING_GDK
836 g_signal_connect ((gpointer
) pdf
, "activate",
837 G_CALLBACK (callbacks_generic_save_activate
),
838 (gpointer
) CALLBACKS_SAVE_FILE_PDF
);
839 g_signal_connect ((gpointer
) svg
, "activate",
840 G_CALLBACK (callbacks_generic_save_activate
),
841 (gpointer
) CALLBACKS_SAVE_FILE_SVG
);
842 g_signal_connect ((gpointer
) postscript
, "activate",
843 G_CALLBACK (callbacks_generic_save_activate
),
844 (gpointer
) CALLBACKS_SAVE_FILE_PS
);
845 g_signal_connect ((gpointer
) rs274x
, "activate",
846 G_CALLBACK (callbacks_generic_save_activate
),
847 (gpointer
) CALLBACKS_SAVE_FILE_RS274X
);
848 g_signal_connect ((gpointer
) drill
, "activate",
849 G_CALLBACK (callbacks_generic_save_activate
),
850 (gpointer
) CALLBACKS_SAVE_FILE_DRILL
);
852 #if GTK_CHECK_VERSION(2,10,0)
853 g_signal_connect ((gpointer
) print
, "activate",
854 G_CALLBACK (callbacks_print_activate
),
858 g_signal_connect ((gpointer
) quit
, "activate",
859 G_CALLBACK (callbacks_quit_activate
),
862 /* --- Edit menu --- */
863 g_signal_connect ((gpointer
) delete_selected
, "activate",
864 G_CALLBACK (callbacks_delete_objects_clicked
),
867 /* --- View menu --- */
868 g_signal_connect ((gpointer
) zoom_in
, "activate",
869 G_CALLBACK (callbacks_zoom_in_activate
),
871 g_signal_connect ((gpointer
) zoom_out
, "activate",
872 G_CALLBACK (callbacks_zoom_out_activate
),
874 g_signal_connect ((gpointer
) fit_to_window
, "activate",
875 G_CALLBACK (callbacks_fit_to_window_activate
),
878 /* --- Analyze menu --- */
879 g_signal_connect ((gpointer
) analyze_active_gerbers
, "activate",
880 G_CALLBACK (callbacks_analyze_active_gerbers_activate
),
882 g_signal_connect ((gpointer
) analyze_active_drill
, "activate",
883 G_CALLBACK (callbacks_analyze_active_drill_activate
),
885 g_signal_connect ((gpointer
) analyze_display_selected_obj_props
, "activate",
886 G_CALLBACK (callbacks_display_object_properties_clicked
),
888 g_signal_connect ((gpointer
) analyze_benchmark
, "activate",
889 G_CALLBACK (callbacks_benchmark_clicked
),
894 g_signal_connect ((gpointer) control_gerber_options, "activate",
895 G_CALLBACK (callbacks_control_gerber_options_activate),
899 /* --- Tools menu --- */
900 #ifndef RENDER_USING_GDK
901 g_signal_connect ((gpointer
) pointer_tool
, "activate",
902 G_CALLBACK (callbacks_change_tool
), (gpointer
) 0);
904 g_signal_connect ((gpointer
) pan_tool
, "activate",
905 G_CALLBACK (callbacks_change_tool
), (gpointer
) 1);
906 g_signal_connect ((gpointer
) zoom_tool
, "activate",
907 G_CALLBACK (callbacks_change_tool
), (gpointer
) 2);
908 g_signal_connect ((gpointer
) measure_tool
, "activate",
909 G_CALLBACK (callbacks_change_tool
), (gpointer
) 3);
911 /* --- Help menu --- */
913 g_signal_connect ((gpointer) online_manual, "activate",
914 G_CALLBACK (callbacks_online_manual_activate),
917 g_signal_connect ((gpointer
) about
, "activate",
918 G_CALLBACK (callbacks_about_activate
),
921 g_signal_connect ((gpointer
) bugs_menuitem
, "activate",
922 G_CALLBACK (callbacks_bugs_activate
),
925 /* End of Glade generated code */
926 g_signal_connect ((gpointer
) toolbutton_new
, "clicked",
927 G_CALLBACK (callbacks_new_activate
),
929 g_signal_connect ((gpointer
) toolbutton_save
, "clicked",
930 G_CALLBACK (callbacks_save_project_activate
),
932 g_signal_connect ((gpointer
) toolbutton_open
, "clicked",
933 G_CALLBACK (callbacks_open_project_activate
),
935 g_signal_connect ((gpointer
) toolbutton_revert
, "clicked",
936 G_CALLBACK (callbacks_revert_activate
),
938 g_signal_connect ((gpointer
) clear_messages_button
, "clicked",
939 G_CALLBACK (callbacks_clear_messages_button_clicked
),
941 #ifndef RENDER_USING_GDK
942 #if GTK_CHECK_VERSION(2,10,0)
943 g_signal_connect ((gpointer
) toolbutton_print
, "clicked",
944 G_CALLBACK (callbacks_print_activate
),
948 g_signal_connect ((gpointer
) toolbutton_zoom_in
, "clicked",
949 G_CALLBACK (callbacks_zoom_in_activate
),
951 g_signal_connect ((gpointer
) toolbutton_zoom_out
, "clicked",
952 G_CALLBACK (callbacks_zoom_out_activate
),
954 g_signal_connect ((gpointer
) toolbutton_zoom_fit
, "clicked",
955 G_CALLBACK (callbacks_fit_to_window_activate
),
957 #ifndef RENDER_USING_GDK
958 g_signal_connect ((gpointer
) toggletoolbutton_pointer
, "clicked",
959 G_CALLBACK (callbacks_change_tool
), (gpointer
) 0);
961 g_signal_connect ((gpointer
) toggletoolbutton_pan
, "clicked",
962 G_CALLBACK (callbacks_change_tool
), (gpointer
) 1);
963 g_signal_connect ((gpointer
) toggletoolbutton_zoom
, "clicked",
964 G_CALLBACK (callbacks_change_tool
), (gpointer
) 2);
965 g_signal_connect ((gpointer
) toggletoolbutton_measure
, "clicked",
966 G_CALLBACK (callbacks_change_tool
), (gpointer
) 3);
968 g_signal_connect ((gpointer
) combobox2
, "changed",
969 G_CALLBACK (callbacks_statusbar_unit_combo_box_changed
),
972 g_signal_connect ((gpointer
) button4
, "clicked",
973 G_CALLBACK (callbacks_add_layer_button_clicked
), NULL
);
974 g_signal_connect ((gpointer
) button7
, "clicked",
975 G_CALLBACK (callbacks_remove_layer_button_clicked
), NULL
);
976 g_signal_connect ((gpointer
) button5
, "clicked",
977 G_CALLBACK (callbacks_move_layer_down_button_clicked
), NULL
);
978 g_signal_connect ((gpointer
) button6
, "clicked",
979 G_CALLBACK (callbacks_move_layer_up_clicked
), NULL
);
981 g_signal_connect ((gpointer
) hAdjustment
, "value-changed",
982 G_CALLBACK (callbacks_hadjustment_value_changed
), NULL
);
983 g_signal_connect ((gpointer
) vAdjustment
, "value-changed",
984 G_CALLBACK (callbacks_vadjustment_value_changed
), NULL
);
985 g_signal_connect ((gpointer
) hScrollbar
, "button-press-event",
986 G_CALLBACK (callbacks_scrollbar_button_pressed
), NULL
);
987 g_signal_connect ((gpointer
) hScrollbar
, "button-release-event",
988 G_CALLBACK (callbacks_scrollbar_button_released
), NULL
);
989 g_signal_connect ((gpointer
) vScrollbar
, "button-press-event",
990 G_CALLBACK (callbacks_scrollbar_button_pressed
), NULL
);
991 g_signal_connect ((gpointer
) vScrollbar
, "button-release-event",
992 G_CALLBACK (callbacks_scrollbar_button_released
), NULL
);
995 if (screen
.unit
== GERBV_MILS
)
996 gtk_combo_box_set_active (GTK_COMBO_BOX (combobox2
), 0);
997 else if (screen
.unit
== GERBV_MMS
)
998 gtk_combo_box_set_active (GTK_COMBO_BOX (combobox2
), 1);
1000 gtk_combo_box_set_active (GTK_COMBO_BOX (combobox2
), 2);
1004 gtk_window_add_accel_group (GTK_WINDOW (mainWindow
), accel_group
);
1006 GtkListStore
*list_store
;
1008 list_store
= gtk_list_store_new (4, G_TYPE_BOOLEAN
,
1009 GDK_TYPE_PIXBUF
, G_TYPE_STRING
, G_TYPE_STRING
);
1013 tree
= gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store
));
1014 GtkCellRenderer
*renderer
;
1015 GtkTreeViewColumn
*column
;
1017 renderer
= gtk_cell_renderer_toggle_new ();
1018 column
= gtk_tree_view_column_new_with_attributes ("Visible",
1022 gtk_tree_view_column_set_min_width ((GtkTreeViewColumn
*)column
,25);
1023 gtk_signal_connect(GTK_OBJECT(renderer
), "toggled",
1024 GTK_SIGNAL_FUNC(callbacks_layer_tree_visibility_button_toggled
), NULL
);
1026 gtk_tree_view_append_column (GTK_TREE_VIEW (tree
), column
);
1028 renderer
= gtk_cell_renderer_pixbuf_new ();
1029 column
= gtk_tree_view_column_new_with_attributes ("Color",
1032 gtk_tree_view_append_column (GTK_TREE_VIEW (tree
), column
);
1034 renderer
= gtk_cell_renderer_text_new ();
1035 g_object_set (G_OBJECT (renderer
), "foreground", "red", "xalign", 0.5,
1036 "family", "Times", "size-points", 12.0, NULL
);
1037 column
= gtk_tree_view_column_new_with_attributes ("Modified",
1041 gtk_tree_view_append_column (GTK_TREE_VIEW (tree
), column
);
1042 gtk_tree_view_column_set_min_width ((GtkTreeViewColumn
*)column
,20);
1044 renderer
= gtk_cell_renderer_text_new ();
1045 column
= gtk_tree_view_column_new_with_attributes ("Name",
1049 gtk_tree_view_append_column (GTK_TREE_VIEW (tree
), column
);
1051 gtk_tree_view_set_headers_visible ((GtkTreeView
*)tree
, FALSE
);
1052 gtk_signal_connect(GTK_OBJECT(tree
), "button-press-event",
1053 GTK_SIGNAL_FUNC(callbacks_layer_tree_button_press
), NULL
);
1054 gtk_container_add (GTK_CONTAINER (scrolledwindow1
), tree
);
1056 GtkTreeSelection
*selection
;
1057 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(tree
));
1058 gtk_tree_selection_set_mode (selection
, GTK_SELECTION_BROWSE
);
1059 gtk_tree_view_set_enable_search (GTK_TREE_VIEW (tree
), FALSE
);
1060 gtk_tree_view_set_reorderable (GTK_TREE_VIEW (tree
), TRUE
);
1062 g_signal_connect (G_OBJECT(list_store
), "row-inserted",
1063 G_CALLBACK (callbacks_layer_tree_row_inserted
), NULL
);
1064 /* steal the focus to the tree to make sure none of the buttons are focused */
1065 gtk_widget_grab_focus (tree
);
1067 * Connect all events on drawing area
1069 gtk_signal_connect(GTK_OBJECT(drawingarea
), "expose_event",
1070 GTK_SIGNAL_FUNC(callbacks_drawingarea_expose_event
), NULL
);
1071 gtk_signal_connect(GTK_OBJECT(drawingarea
),"configure_event",
1072 GTK_SIGNAL_FUNC(callbacks_drawingarea_configure_event
), NULL
);
1073 gtk_signal_connect(GTK_OBJECT(drawingarea
), "motion_notify_event",
1074 GTK_SIGNAL_FUNC(callbacks_drawingarea_motion_notify_event
), NULL
);
1075 gtk_signal_connect(GTK_OBJECT(drawingarea
), "button_press_event",
1076 GTK_SIGNAL_FUNC(callbacks_drawingarea_button_press_event
), NULL
);
1077 gtk_signal_connect(GTK_OBJECT(drawingarea
), "button_release_event",
1078 GTK_SIGNAL_FUNC(callbacks_drawingarea_button_release_event
), NULL
);
1079 gtk_signal_connect_after(GTK_OBJECT(mainWindow
), "key_press_event",
1080 GTK_SIGNAL_FUNC(callbacks_window_key_press_event
), NULL
);
1081 gtk_signal_connect_after(GTK_OBJECT(mainWindow
), "key_release_event",
1082 GTK_SIGNAL_FUNC(callbacks_window_key_release_event
), NULL
);
1083 gtk_signal_connect_after(GTK_OBJECT(mainWindow
), "scroll_event",
1084 GTK_SIGNAL_FUNC(callbacks_window_scroll_event
), NULL
);
1085 gtk_signal_connect_after(GTK_OBJECT(mainWindow
), "delete_event",
1086 GTK_SIGNAL_FUNC(callbacks_quit_activate
), NULL
);
1088 gtk_widget_set_events(drawingarea
, GDK_EXPOSURE_MASK
1089 | GDK_LEAVE_NOTIFY_MASK
1090 | GDK_ENTER_NOTIFY_MASK
1091 | GDK_BUTTON_PRESS_MASK
1092 | GDK_BUTTON_RELEASE_MASK
1093 | GDK_KEY_PRESS_MASK
1094 | GDK_KEY_RELEASE_MASK
1095 | GDK_POINTER_MOTION_MASK
1096 | GDK_POINTER_MOTION_HINT_MASK
1101 * Set gtk error log handler
1103 g_log_set_handler (NULL
,
1104 G_LOG_FLAG_FATAL
| G_LOG_FLAG_RECURSION
| G_LOG_LEVEL_MASK
,
1105 callbacks_handle_log_messages
, NULL
);
1108 * Setup some GTK+ defaults.
1109 * These should really be somewhere else.
1111 GdkColor zoom_outline_color
= {0, 50000, 50000, 50000};
1112 GdkColor dist_measure_color
= {0, 60000, 30000, 65000};
1113 GdkColor selection_color
= {0, 65000, 65000, 65000};
1115 screen
.zoom_outline_color
= zoom_outline_color
;
1116 screen
.dist_measure_color
= dist_measure_color
;
1117 screen
.selection_color
= selection_color
;
1119 screen
.drawing_area
= drawingarea
;
1120 screen
.win
.hAdjustment
= hAdjustment
;
1121 screen
.win
.vAdjustment
= vAdjustment
;
1122 screen
.win
.hRuler
= hRuler
;
1123 screen
.win
.vRuler
= vRuler
;
1124 screen
.win
.sidepane_notebook
= sidepane_notebook
;
1125 #ifndef RENDER_USING_GDK
1126 screen
.win
.toolButtonPointer
= toggletoolbutton_pointer
;
1128 screen
.win
.toolButtonPan
= toggletoolbutton_pan
;
1129 screen
.win
.toolButtonZoom
= toggletoolbutton_zoom
;
1130 screen
.win
.toolButtonMeasure
= toggletoolbutton_measure
;
1132 /* Create right click popup menu for layer tree */
1133 screen
.win
.layerTreePopupMenu
= gtk_menu_new ();
1134 tempMenuItem
= gtk_image_menu_item_new_with_label ("Invert layer color");
1135 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1136 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Invert the display polarity of the layer", NULL
);
1137 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1138 G_CALLBACK (callbacks_invert_layer_clicked
), NULL
);
1140 tempMenuItem
= gtk_image_menu_item_new_with_label ("Change color");
1141 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1142 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Change the display color of the layer", NULL
);
1143 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1144 G_CALLBACK (callbacks_change_layer_color_clicked
), NULL
);
1146 tempMenuItem
= gtk_image_menu_item_new_with_label ("Reload layer");
1147 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1148 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Reload the layer from disk",
1150 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1151 G_CALLBACK (callbacks_reload_layer_clicked
), NULL
);
1153 tempMenuItem
= gtk_image_menu_item_new_with_label ("Edit file format");
1154 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1155 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "View and edit the numerical format used to parse this layer",
1157 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1158 G_CALLBACK (callbacks_change_layer_format_clicked
), NULL
);
1160 tempMenuItem
= gtk_image_menu_item_new_with_label ("Add layer");
1161 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1162 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Open a new layer and insert it here", NULL
);
1163 tempImage
= gtk_image_new_from_stock ("gtk-add", 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_add_layer_button_clicked
), NULL
);
1168 tempMenuItem
= gtk_image_menu_item_new_with_label ("Move layer down");
1169 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1170 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Move the layer down one in the layer list", NULL
);
1171 tempImage
= gtk_image_new_from_stock ("gtk-go-down", 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_move_layer_down_button_clicked
), NULL
);
1176 tempMenuItem
= gtk_image_menu_item_new_with_label ("Move layer up");
1177 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1178 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Move the layer up one in the layer list", NULL
);
1179 tempImage
= gtk_image_new_from_stock ("gtk-go-up", GTK_ICON_SIZE_MENU
);
1180 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem
), tempImage
);
1181 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1182 G_CALLBACK (callbacks_move_layer_up_clicked
), NULL
);
1184 tempMenuItem
= gtk_image_menu_item_new_with_label ("Delete layer");
1185 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1186 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Remove this layer", NULL
);
1187 tempImage
= gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_MENU
);
1188 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem
), tempImage
);
1189 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1190 G_CALLBACK (callbacks_remove_layer_button_clicked
), NULL
);
1192 gtk_widget_show_all (screen
.win
.layerTreePopupMenu
);
1194 /* Create right click popup menu for draw window */
1195 screen
.win
.drawWindowPopupMenu
= gtk_menu_new ();
1196 tempMenuItem
= gtk_image_menu_item_new_with_label ("Display object properties");
1197 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.drawWindowPopupMenu
, tempMenuItem
);
1198 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Examine the properties of the selected object", NULL
);
1199 tempImage
= gtk_image_new_from_stock ("gtk-info", GTK_ICON_SIZE_MENU
);
1200 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem
), tempImage
);
1201 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1202 G_CALLBACK (callbacks_display_object_properties_clicked
), NULL
);
1204 /* Include these after they are coded.
1205 tempMenuItem = gtk_image_menu_item_new_with_label ("Edit object properties");
1206 gtk_menu_shell_append ((GtkMenuShell *)screen.win.drawWindowPopupMenu, tempMenuItem);
1207 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Edit the properties of the selected object", NULL);
1208 g_signal_connect ((gpointer) tempMenuItem, "activate",
1209 G_CALLBACK (callbacks_edit_object_properties_clicked), NULL);
1211 tempMenuItem = gtk_image_menu_item_new_with_label ("Move object(s)");
1212 gtk_menu_shell_append ((GtkMenuShell *)screen.win.drawWindowPopupMenu, tempMenuItem);
1213 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Move the selected object(s)",NULL);
1214 g_signal_connect ((gpointer) tempMenuItem, "activate",
1215 G_CALLBACK (callbacks_move_objects_clicked), NULL);
1217 tempMenuItem = gtk_image_menu_item_new_with_label ("Reduce area");
1218 gtk_menu_shell_append ((GtkMenuShell *)screen.win.drawWindowPopupMenu, tempMenuItem);
1219 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Reduce the area of the object (e.g. to prevent component floating)",NULL);
1220 g_signal_connect ((gpointer) tempMenuItem, "activate",
1221 G_CALLBACK (callbacks_reduce_object_area_clicked), NULL);
1224 tempMenuItem
= gtk_image_menu_item_new_with_label ("Delete selected objects");
1225 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.drawWindowPopupMenu
, tempMenuItem
);
1226 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Delete the selected object(s)",NULL
);
1227 tempImage
= gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_MENU
);
1228 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem
), tempImage
);
1229 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1230 G_CALLBACK (callbacks_delete_objects_clicked
), NULL
);
1232 gtk_widget_show_all (screen
.win
.drawWindowPopupMenu
);
1234 /* make sure tooltips show on gtk <2.12 systems */
1235 gtk_tooltips_enable (tooltips
);
1237 * Good defaults according to Ales. Gives aspect ratio of 1.3333...
1239 if ((req_width
!= -1) && (req_height
!= -1)) {
1241 height
= req_height
;
1247 screen
= gdk_screen_get_default();
1248 nmonitors
= gdk_screen_get_n_monitors(screen
);
1250 width
= gdk_screen_get_width(screen
) * 3/4 / nmonitors
;
1251 height
= gdk_screen_get_height(screen
) * 3/4 / nmonitors
;
1254 gtk_window_set_default_size((GtkWindow
*)mainWindow
, width
, height
);
1256 gtk_widget_show_all (mainWindow
);
1257 screen
.win
.topLevelWindow
= mainWindow
;
1258 screen
.win
.messageTextView
= message_textview
;
1259 screen
.win
.statusMessageLeft
= statusbar_label_left
;
1260 screen
.win
.statusMessageRight
= statusbar_label_right
;
1261 screen
.win
.statusUnitComboBox
= combobox2
;
1262 screen
.win
.layerTree
= tree
;
1263 screen
.win
.treeIsUpdating
= FALSE
;
1265 screen
.selectionInfo
.selectedNodeArray
= g_array_new (FALSE
,
1266 FALSE
, sizeof(gerbv_selection_item_t
));
1267 #ifndef RENDER_USING_GDK
1268 /* make pointer tool default on cairo builds */
1269 callbacks_change_tool (NULL
, (gpointer
) 0);
1271 /* make pan tool default for GDK only */
1272 callbacks_change_tool (NULL
, (gpointer
) 1);
1274 rename_main_window("",mainWindow
);
1276 set_window_icon (mainWindow
);
1277 callbacks_update_layer_tree ();
1279 /* connect this signal as late as possible to avoid triggering it before
1281 g_signal_connect ((gpointer
) render_combobox
, "changed",
1282 G_CALLBACK (callbacks_sidepane_render_type_combo_box_changed
),
1287 /* ---------------------------------------------------- */
1289 interface_set_render_type (int t
)
1291 #ifdef RENDER_USING_GDK
1298 screenRenderInfo
.renderType
= t
;
1300 /* make sure the interface is already up before calling
1301 * gtk_combo_box_set_active()
1303 if (render_combobox
)
1304 gtk_combo_box_set_active (GTK_COMBO_BOX (render_combobox
), t
);
1307 /* ---------------------------------------------------- */
1309 * This dialog box shows a message and two buttons:
1310 * "OK" and "Cancel". It returns gboolean 1 if the
1311 * user clicked "OK", and gboolean 0 if the user
1317 interface_get_alert_dialog_response (gchar
*primaryText
, gchar
*secondaryText
,
1318 gboolean show_checkbox
, gboolean
*ask_to_show_again
)
1319 /* This fcn returns TRUE if the user presses the OK button,
1320 otherwise it returns FALSE. */
1322 /* Set show_checkbox = TRUE to show "do not show this again" checkbox. */
1323 /* Point ask_to_show_again to the variable to set to not show the checkbox. */
1325 GtkWidget
*dialog_vbox1
;
1329 GtkWidget
*checkbox
=NULL
;
1330 GtkWidget
*dialog_action_area1
;
1331 GtkWidget
*cancelbutton1
;
1332 GtkWidget
*okbutton1
;
1333 gboolean returnVal
= FALSE
;
1335 dialog1
= gtk_dialog_new ();
1336 gtk_container_set_border_width (GTK_CONTAINER (dialog1
), 6);
1337 gtk_window_set_resizable (GTK_WINDOW (dialog1
), FALSE
);
1338 gtk_window_set_type_hint (GTK_WINDOW (dialog1
), GDK_WINDOW_TYPE_HINT_DIALOG
);
1339 gtk_dialog_set_has_separator (GTK_DIALOG (dialog1
), FALSE
);
1341 dialog_vbox1
= GTK_DIALOG (dialog1
)->vbox
;
1343 hbox1
= gtk_hbox_new (FALSE
, 12);
1344 gtk_box_pack_start (GTK_BOX (dialog_vbox1
), hbox1
, TRUE
, TRUE
, 0);
1345 gtk_container_set_border_width (GTK_CONTAINER (hbox1
), 6);
1347 image1
= gtk_image_new_from_icon_name ("gtk-dialog-warning", GTK_ICON_SIZE_DIALOG
);
1348 gtk_box_pack_start (GTK_BOX (hbox1
), image1
, TRUE
, TRUE
, 0);
1349 gtk_misc_set_alignment (GTK_MISC (image1
), 0.5, 0);
1351 gchar
*labelMessage
= g_strconcat ("<span weight=\"bold\" size=\"larger\">",primaryText
,
1352 "</span>\n<span/>\n",secondaryText
,NULL
);
1353 label1
= gtk_label_new (labelMessage
);
1354 g_free (labelMessage
);
1355 GtkWidget
*vbox9
= gtk_vbox_new (FALSE
, 0);
1356 gtk_box_pack_start (GTK_BOX (vbox9
), label1
, FALSE
, FALSE
, 0);
1357 gtk_box_pack_start (GTK_BOX (hbox1
), vbox9
, FALSE
, FALSE
, 0);
1358 gtk_label_set_use_markup (GTK_LABEL (label1
), TRUE
);
1359 gtk_label_set_line_wrap (GTK_LABEL (label1
), TRUE
);
1361 // even with no checkbox, this extra hbox gives the recommended 24 px space between the
1362 // label and the buttons
1363 GtkWidget
*hbox2
= gtk_hbox_new (FALSE
, 12);
1364 if (show_checkbox
) {
1365 GtkWidget
*label3
= gtk_label_new (" ");
1367 checkbox
= gtk_check_button_new_with_label("Do not show this dialog again.");
1368 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbox
), FALSE
);
1369 gtk_box_pack_start (GTK_BOX (hbox2
), label3
, FALSE
, FALSE
, 0);
1370 gtk_box_pack_start (GTK_BOX (hbox2
), checkbox
, FALSE
, FALSE
, 0);
1372 gtk_box_pack_start (GTK_BOX (vbox9
), hbox2
, FALSE
, FALSE
, 12);
1374 dialog_action_area1
= GTK_DIALOG (dialog1
)->action_area
;
1375 gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1
), GTK_BUTTONBOX_END
);
1377 cancelbutton1
= gtk_button_new_from_stock ("gtk-cancel");
1378 gtk_dialog_add_action_widget (GTK_DIALOG (dialog1
), cancelbutton1
, GTK_RESPONSE_CANCEL
);
1379 GTK_WIDGET_SET_FLAGS (cancelbutton1
, GTK_CAN_DEFAULT
);
1380 gtk_widget_grab_default (cancelbutton1
);
1381 gtk_widget_grab_focus (cancelbutton1
);
1383 okbutton1
= gtk_button_new_from_stock ("gtk-ok");
1384 gtk_dialog_add_action_widget (GTK_DIALOG (dialog1
), okbutton1
, GTK_RESPONSE_OK
);
1385 GTK_WIDGET_SET_FLAGS (okbutton1
, GTK_CAN_DEFAULT
);
1387 gtk_widget_show_all (dialog1
);
1389 if (gtk_dialog_run ((GtkDialog
*)dialog1
) == GTK_RESPONSE_OK
) {
1390 /* check to see if user clicked on "do not show again" box */
1391 if ((show_checkbox
== TRUE
) &&
1392 (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox
)) == TRUE
) &&
1393 (ask_to_show_again
!= NULL
) ) {
1394 /* The user clicked the "do not show again box". Set corresponding
1396 *ask_to_show_again
= FALSE
;
1400 gtk_widget_destroy (dialog1
);
1407 /* ---------------------------------------------------- */
1409 * This dialog box shows a textmessage and one buttons:
1410 * "OK". It does not return anything.
1414 interface_show_alert_dialog (gchar
*primaryText
, gchar
*secondaryText
,
1415 gboolean show_checkbox
, gboolean
*ask_to_show_again
)
1416 /* This fcn tells the user something, and only displays "OK" */
1418 /* Set show_checkbox = TRUE to show "do not show this again" checkbox. */
1419 /* Point ask_to_show_again to the variable to set to not show the checkbox. */
1421 GtkWidget
*dialog_vbox1
;
1425 GtkWidget
*checkbox
=NULL
;
1426 GtkWidget
*dialog_action_area1
;
1427 GtkWidget
*okbutton1
;
1429 dialog1
= gtk_dialog_new ();
1430 gtk_container_set_border_width (GTK_CONTAINER (dialog1
), 6);
1431 gtk_window_set_resizable (GTK_WINDOW (dialog1
), FALSE
);
1432 gtk_window_set_type_hint (GTK_WINDOW (dialog1
), GDK_WINDOW_TYPE_HINT_DIALOG
);
1433 gtk_dialog_set_has_separator (GTK_DIALOG (dialog1
), FALSE
);
1435 dialog_vbox1
= GTK_DIALOG (dialog1
)->vbox
;
1437 hbox1
= gtk_hbox_new (FALSE
, 12);
1438 gtk_box_pack_start (GTK_BOX (dialog_vbox1
), hbox1
, TRUE
, TRUE
, 0);
1439 gtk_container_set_border_width (GTK_CONTAINER (hbox1
), 6);
1441 image1
= gtk_image_new_from_icon_name ("gtk-dialog-warning", GTK_ICON_SIZE_DIALOG
);
1442 gtk_box_pack_start (GTK_BOX (hbox1
), image1
, TRUE
, TRUE
, 0);
1443 gtk_misc_set_alignment (GTK_MISC (image1
), 0.5, 0);
1445 gchar
*labelMessage
= g_strconcat ("<span weight=\"bold\" size=\"larger\">",primaryText
,
1446 "</span>\n<span/>\n",secondaryText
,NULL
);
1447 label1
= gtk_label_new (labelMessage
);
1448 g_free (labelMessage
);
1450 GtkWidget
*vbox9
= gtk_vbox_new (FALSE
, 0);
1451 gtk_box_pack_start (GTK_BOX (vbox9
), label1
, FALSE
, FALSE
, 0);
1452 gtk_label_set_use_markup (GTK_LABEL (label1
), TRUE
);
1453 gtk_label_set_line_wrap (GTK_LABEL (label1
), TRUE
);
1454 gtk_box_pack_start (GTK_BOX (hbox1
), vbox9
, FALSE
, FALSE
, 0);
1456 GtkWidget
*hbox2
= gtk_hbox_new (FALSE
, 12);
1457 if (show_checkbox
) {
1458 GtkWidget
*label3
= gtk_label_new (" ");
1460 checkbox
= gtk_check_button_new_with_label("Do not show this dialog again.");
1461 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbox
), FALSE
);
1462 gtk_box_pack_start (GTK_BOX (hbox2
), label3
, FALSE
, FALSE
, 0);
1463 gtk_box_pack_start (GTK_BOX (hbox2
), checkbox
, FALSE
, FALSE
, 0);
1465 gtk_box_pack_start (GTK_BOX (vbox9
), hbox2
, FALSE
, FALSE
, 12);
1467 dialog_action_area1
= GTK_DIALOG (dialog1
)->action_area
;
1468 gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1
), GTK_BUTTONBOX_END
);
1470 okbutton1
= gtk_button_new_from_stock ("gtk-ok");
1471 gtk_dialog_add_action_widget (GTK_DIALOG (dialog1
), okbutton1
, GTK_RESPONSE_OK
);
1472 GTK_WIDGET_SET_FLAGS (okbutton1
, GTK_CAN_DEFAULT
);
1474 gtk_widget_show_all (dialog1
);
1476 /* check to see if user clicked on "do not show again" box */
1477 if ((show_checkbox
== TRUE
) &&
1478 (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox
)) == TRUE
) &&
1479 (ask_to_show_again
!= NULL
) ) {
1480 /* The user clicked the "do not show again box". Set corresponding
1482 *ask_to_show_again
= FALSE
;
1485 gtk_dialog_run (GTK_DIALOG(dialog1
));
1486 gtk_widget_destroy (dialog1
);