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
;
136 GtkWidget *control_gerber_options;
138 GtkWidget
*menubar_tools
;
139 GtkWidget
*menubar_tools_menu
;
140 #ifndef RENDER_USING_GDK
141 GtkWidget
*toggletoolbutton_pointer
;
142 GtkWidget
*pointer_tool
;
143 GdkPixbuf
*pointerpixbuf
;
144 GtkWidget
*pointerimage
;
147 GtkWidget
*zoom_tool
;
148 GtkWidget
*measure_tool
;
149 GtkWidget
*menuitem10
;
150 GtkWidget
*menuitem10_menu
;
151 /*GtkWidget *online_manual;*/
154 GtkWidget
*toolbar_hbox
;
155 GtkWidget
*handlebox
;
156 GtkWidget
*button_toolbar
;
157 GtkIconSize tmp_toolbar_icon_size
;
158 GtkWidget
*toolbutton_new
;
159 GtkWidget
*toolbutton_open
;
160 GtkWidget
*toolbutton_revert
;
161 GtkWidget
*toolbutton_save
;
162 GtkWidget
*separatortoolitem1
;
163 #ifndef RENDER_USING_GDK
164 #if GTK_CHECK_VERSION(2,10,0)
166 GtkWidget
*toolbutton_print
;
167 GtkWidget
*separator2
;
168 GtkWidget
*separatortoolitem2
;
171 GtkWidget
*toolbutton_zoom_in
;
172 GtkWidget
*toolbutton_zoom_out
;
173 GtkWidget
*toolbutton_zoom_fit
;
174 /* Implement these tool buttons later when we have icons */
175 /* GtkWidget *separatortoolitem3; */
176 /* GtkWidget *toolbutton_analyze; */
177 /* GtkWidget *toolbutton_validate;*/
178 /* GtkWidget *toolbutton_control; */
179 GtkWidget
*separatortoolitem4
;
180 GtkWidget
*toggletoolbutton_pan
;
181 GtkWidget
*toggletoolbutton_zoom
;
182 GtkWidget
*toggletoolbutton_measure
;
184 GtkWidget
*sidepane_vbox
;
185 GtkWidget
*sidepane_notebook
;
189 GtkWidget
*scrolledwindow1
;
199 GtkWidget
*Layer_label
;
201 GtkWidget
*messages_scrolledwindow
;
202 GtkWidget
*message_textview
;
203 GtkWidget
*clear_messages_button
;
204 GtkWidget
*Message_label
;
206 GtkWidget
*main_view_table
;
210 GtkWidget
*statusbar_label_left
;
211 GtkWidget
*combobox2
;
212 GtkWidget
*statusbar_label_right
;
213 GtkWidget
*drawingarea
, *hAdjustment
, *vAdjustment
, *hScrollbar
, *vScrollbar
;
215 GtkAccelGroup
*accel_group
;
216 GtkTooltips
*tooltips
;
219 GdkPixbuf
*zoompixbuf
;
220 GtkWidget
*zoomimage
;
221 GdkPixbuf
*measurepixbuf
;
222 GtkWidget
*measureimage
;
223 GdkPixbuf
*movepixbuf
;
224 GtkWidget
*moveimage
;
226 GtkWidget
*tempImage
;
227 GtkWidget
*tempMenuItem
;
230 #ifndef RENDER_USING_GDK
231 pointerpixbuf
= gdk_pixbuf_new_from_inline(-1, pointer
, FALSE
, NULL
);
233 movepixbuf
= gdk_pixbuf_new_from_inline(-1, move
, FALSE
, NULL
);
234 zoompixbuf
= gdk_pixbuf_new_from_inline(-1, lzoom
, FALSE
, NULL
);
235 measurepixbuf
= gdk_pixbuf_new_from_inline(-1, ruler
, FALSE
, NULL
);
237 tooltips
= gtk_tooltips_new();
238 accel_group
= gtk_accel_group_new ();
240 mainWindow
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
241 gtk_window_set_title (GTK_WINDOW (mainWindow
), _("Gerbv -- gEDA's Gerber Viewer"));
243 vbox1
= gtk_vbox_new (FALSE
, 0);
244 gtk_container_add (GTK_CONTAINER (mainWindow
), vbox1
);
246 menubar1
= gtk_menu_bar_new ();
247 gtk_box_pack_start (GTK_BOX (vbox1
), menubar1
, FALSE
, FALSE
, 0);
249 /* --- File menu --- */
250 menuitem_file
= gtk_menu_item_new_with_mnemonic (_("_File"));
251 gtk_container_add (GTK_CONTAINER (menubar1
), menuitem_file
);
253 /* File menu items dealing with a gerbv project. */
254 menuitem_file_menu
= gtk_menu_new ();
255 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_file
), menuitem_file_menu
);
257 new = gtk_image_menu_item_new_from_stock ("gtk-new", accel_group
);
258 gtk_tooltips_set_tip (tooltips
, new, "Close all layers and start a new project", NULL
);
259 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), new);
260 gtk_widget_add_accelerator (new, "activate", accel_group
,
261 GDK_n
, (GdkModifierType
) GDK_CONTROL_MASK
,
265 open_project
= gtk_image_menu_item_new_with_mnemonic (_("_Open Project..."));
266 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), open_project
);
267 gtk_tooltips_set_tip (tooltips
, open_project
, "Open an existing Gerbv project", NULL
);
268 image33
= gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU
);
269 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (open_project
), image33
);
271 save
= gtk_image_menu_item_new_with_mnemonic ("Save Project");
272 gtk_tooltips_set_tip (tooltips
, save
, "Save the current project", NULL
);
273 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), save
);
275 save_as
= gtk_image_menu_item_new_with_mnemonic ("Save Project As...");
276 gtk_tooltips_set_tip (tooltips
, save_as
, "Save the current project to a new file", NULL
);
277 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), save_as
);
279 revert
= gtk_image_menu_item_new_from_stock ("gtk-revert-to-saved", accel_group
);
280 gtk_tooltips_set_tip (tooltips
, revert
, "Reload all layers", NULL
);
281 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), revert
);
283 /* File menu items dealing individual layers. */
284 separator1
= gtk_separator_menu_item_new ();
285 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), separator1
);
286 gtk_widget_set_sensitive (separator1
, FALSE
);
288 open_layer
= gtk_menu_item_new_with_mnemonic (_("Open _Layer(s)..."));
290 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), open_layer
);
291 gtk_tooltips_set_tip (tooltips
, open_layer
, "Open Gerber, drill, or pick and place file(s)", NULL
);
293 save_layer
= gtk_image_menu_item_new_with_mnemonic (_("_Save active layer"));
294 gtk_tooltips_set_tip (tooltips
, save_layer
, "Save the active layer", NULL
);
295 tempImage
= gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_MENU
);
296 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (save_layer
), tempImage
);
297 gtk_widget_add_accelerator (save_layer
, "activate", accel_group
, 'S', GDK_CONTROL_MASK
,
299 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), save_layer
);
301 save_as_layer
= gtk_image_menu_item_new_with_mnemonic (_("Save active layer _As..."));
302 gtk_tooltips_set_tip (tooltips
, save_as_layer
, "Save the active layer to a new file", NULL
);
303 tempImage
= gtk_image_new_from_stock ("gtk-save-as", GTK_ICON_SIZE_MENU
);
304 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (save_as_layer
), tempImage
);
305 gtk_widget_add_accelerator (save_as_layer
, "activate", accel_group
, 'S',
306 GDK_CONTROL_MASK
| GDK_SHIFT_MASK
, GTK_ACCEL_VISIBLE
);
307 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), save_as_layer
);
309 /* File menu items dealing with exporting different types of files. */
310 separatormenuitem1
= gtk_separator_menu_item_new ();
311 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), separatormenuitem1
);
312 gtk_widget_set_sensitive (separatormenuitem1
, FALSE
);
314 export
= gtk_menu_item_new_with_mnemonic (_("_Export"));
315 gtk_tooltips_set_tip (tooltips
, export
, "Export all visible layers to a new format", NULL
);
316 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), export
);
318 export_menu
= gtk_menu_new ();
319 gtk_menu_item_set_submenu (GTK_MENU_ITEM (export
), export_menu
);
321 png
= gtk_menu_item_new_with_mnemonic (_("PNG..."));
322 gtk_container_add (GTK_CONTAINER (export_menu
), png
);
323 gtk_tooltips_set_tip (tooltips
, png
, _("Export project to a PNG file..."), NULL
);
325 GtkWidget
*rs274x
,*drill
;
326 #ifndef RENDER_USING_GDK
329 GtkWidget
*postscript
;
331 pdf
= gtk_menu_item_new_with_mnemonic (_("PDF..."));
332 gtk_container_add (GTK_CONTAINER (export_menu
), pdf
);
333 gtk_tooltips_set_tip (tooltips
, pdf
, _("Export project to a PDF file..."), NULL
);
335 svg
= gtk_menu_item_new_with_mnemonic (_("SVG..."));
336 gtk_container_add (GTK_CONTAINER (export_menu
), svg
);
337 gtk_tooltips_set_tip (tooltips
, svg
, _("Export project to a SVG file"), NULL
);
339 postscript
= gtk_menu_item_new_with_mnemonic (_("PostScript..."));
340 gtk_container_add (GTK_CONTAINER (export_menu
), postscript
);
341 gtk_tooltips_set_tip (tooltips
, postscript
, _("Export project to a PostScript file"), NULL
);
343 rs274x
= gtk_menu_item_new_with_mnemonic (_("RS-274X (Gerber)..."));
344 gtk_container_add (GTK_CONTAINER (export_menu
), rs274x
);
345 gtk_tooltips_set_tip (tooltips
, rs274x
, _("Export layer to a RS-274X (Gerber) file"), NULL
);
347 drill
= gtk_menu_item_new_with_mnemonic (_("Excellon drill..."));
348 gtk_container_add (GTK_CONTAINER (export_menu
), drill
);
349 gtk_tooltips_set_tip (tooltips
, drill
, _("Export layer to an Excellon drill file"), NULL
);
351 /* File menu items dealing with printing and quitting. */
352 separator1
= gtk_separator_menu_item_new ();
353 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), separator1
);
354 gtk_widget_set_sensitive (separator1
, FALSE
);
355 #ifndef RENDER_USING_GDK
356 #if GTK_CHECK_VERSION(2,10,0)
357 if (gtk_stock_lookup("gtk-print", &item
)) {
358 gchar
new[] = "_Print...";
360 gtk_stock_add(&item
, 1);
363 print
= gtk_image_menu_item_new_from_stock ("gtk-print", accel_group
);
364 gtk_tooltips_set_tip (tooltips
, print
, "Print the visible layers", NULL
);
365 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), print
);
367 separator2
= gtk_separator_menu_item_new ();
368 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), separator2
);
369 gtk_widget_set_sensitive (separator2
, FALSE
);
372 quit
= gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group
);
373 gtk_tooltips_set_tip (tooltips
, quit
, "Quit Gerbv", NULL
);
374 gtk_container_add (GTK_CONTAINER (menuitem_file_menu
), quit
);
376 /* --- Next menu item (Edit) --- */
377 menuitem_edit
= gtk_menu_item_new_with_mnemonic (_("_Edit"));
378 gtk_container_add (GTK_CONTAINER (menubar1
), menuitem_edit
);
380 menuitem_edit_menu
= gtk_menu_new ();
381 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_edit
), menuitem_edit_menu
);
383 delete_selected
= gtk_image_menu_item_new_with_mnemonic (_("_Delete selected object(s)"));
384 gtk_tooltips_set_tip (tooltips
, delete_selected
,
385 "Delete selected objects", NULL
);
386 tempImage
= gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_MENU
);
387 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (delete_selected
), tempImage
);
388 gtk_container_add (GTK_CONTAINER (menuitem_edit_menu
), delete_selected
);
391 /* --- Next menu item --- */
392 menuitem_view
= gtk_menu_item_new_with_mnemonic (_("_View"));
393 gtk_container_add (GTK_CONTAINER (menubar1
), menuitem_view
);
395 menuitem_view_menu
= gtk_menu_new ();
396 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_view
), menuitem_view_menu
);
398 zoom_in
= gtk_image_menu_item_new_from_stock ("gtk-zoom-in", accel_group
);
399 gtk_tooltips_set_tip (tooltips
, zoom_in
, "Zoom in", NULL
);
400 gtk_container_add (GTK_CONTAINER (menuitem_view_menu
), zoom_in
);
402 zoom_out
= gtk_image_menu_item_new_from_stock ("gtk-zoom-out", accel_group
);
403 gtk_tooltips_set_tip (tooltips
, zoom_out
, "Zoom out", NULL
);
404 gtk_container_add (GTK_CONTAINER (menuitem_view_menu
), zoom_out
);
406 separator5
= gtk_separator_menu_item_new ();
407 gtk_container_add (GTK_CONTAINER (menuitem_view_menu
), separator5
);
408 gtk_widget_set_sensitive (separator5
, FALSE
);
410 fit_to_window
= gtk_image_menu_item_new_from_stock ("gtk-zoom-fit", accel_group
);
411 gtk_tooltips_set_tip (tooltips
, fit_to_window
, "Zoom to fit all visible layers in the window", NULL
);
412 gtk_container_add (GTK_CONTAINER (menuitem_view_menu
), fit_to_window
);
414 menuitem_analyze
= gtk_menu_item_new_with_mnemonic (_("_Analyze"));
415 gtk_container_add (GTK_CONTAINER (menubar1
), menuitem_analyze
);
417 menuitem_analyze_menu
= gtk_menu_new ();
418 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_analyze
), menuitem_analyze_menu
);
420 analyze_active_gerbers
= gtk_menu_item_new_with_mnemonic (_("Analyze visible _Gerber layers"));
421 gtk_tooltips_set_tip (tooltips
, analyze_active_gerbers
,
422 "Examine a detailed anaylsis of the contents of all visible Gerber layers", NULL
);
423 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu
), analyze_active_gerbers
);
425 analyze_active_drill
= gtk_menu_item_new_with_mnemonic (_("Analyze visible _drill layers"));
426 gtk_tooltips_set_tip (tooltips
, analyze_active_drill
,
427 "Examine a detailed anaylsis of the contents of all visible drill layers", NULL
);
428 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu
), analyze_active_drill
);
430 analyze_display_selected_obj_props
= gtk_menu_item_new_with_mnemonic (_("Display selected object(s) _properties"));
431 gtk_tooltips_set_tip (tooltips
, analyze_display_selected_obj_props
,
432 "Show the properties of the selected object(s).", NULL
);
433 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu
), analyze_display_selected_obj_props
);
435 /* Wait and add in for 2.1??
436 control_gerber_options = gtk_menu_item_new_with_mnemonic (_("Control Gerber options..."));
437 gtk_tooltips_set_tip (tooltips, control_gerber_options, "Set which Gerber features should be displayed", NULL);
438 gtk_container_add (GTK_CONTAINER (menuitem_analyze_menu), control_gerber_options);
440 menubar_tools
= gtk_menu_item_new_with_mnemonic (_("_Tools"));
441 gtk_container_add (GTK_CONTAINER (menubar1
), menubar_tools
);
443 menubar_tools_menu
= gtk_menu_new ();
444 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menubar_tools
), menubar_tools_menu
);
445 #ifndef RENDER_USING_GDK
446 pointer_tool
= gtk_image_menu_item_new_with_mnemonic (_("_Pointer Tool"));
448 GtkWidget *tempImage = gtk_image_new_from_pixbuf (pointerpixbuf);
449 gtk_image_menu_item_set_image ((GtkImageMenuItem *)pointer_tool, tempImage);
451 gtk_container_add (GTK_CONTAINER (menubar_tools_menu
), pointer_tool
);
452 gtk_tooltips_set_tip (tooltips
, pointer_tool
, "Select objects on the screen", NULL
);
453 gtk_widget_add_accelerator (pointer_tool
, "activate", accel_group
,
454 GDK_F1
, (GdkModifierType
) 0,
457 pan_tool
= gtk_image_menu_item_new_with_mnemonic ("Pa_n Tool");
459 tempImage = gtk_image_new_from_pixbuf (movepixbuf);
460 gtk_image_menu_item_set_image ((GtkImageMenuItem *)pan_tool, tempImage);
462 gtk_container_add (GTK_CONTAINER (menubar_tools_menu
), pan_tool
);
463 gtk_tooltips_set_tip (tooltips
, pan_tool
, "Pan by left clicking and dragging", NULL
);
464 gtk_widget_add_accelerator (pan_tool
, "activate", accel_group
,
465 GDK_F2
, (GdkModifierType
) 0,
468 zoom_tool
= gtk_image_menu_item_new_with_mnemonic (_("_Zoom Tool"));
470 tempImage = gtk_image_new_from_pixbuf (zoompixbuf);
471 gtk_image_menu_item_set_image ((GtkImageMenuItem *)zoom_tool, tempImage);
473 gtk_container_add (GTK_CONTAINER (menubar_tools_menu
), zoom_tool
);
474 gtk_tooltips_set_tip (tooltips
, zoom_tool
, "Zoom by left clicking or dragging", NULL
);
475 gtk_widget_add_accelerator (zoom_tool
, "activate", accel_group
,
476 GDK_F3
, (GdkModifierType
) 0,
479 measure_tool
= gtk_image_menu_item_new_with_mnemonic (_("_Measure Tool"));
481 tempImage = gtk_image_new_from_pixbuf (measurepixbuf);
482 gtk_image_menu_item_set_image ((GtkImageMenuItem *)measure_tool, tempImage);
484 gtk_container_add (GTK_CONTAINER (menubar_tools_menu
), measure_tool
);
485 gtk_tooltips_set_tip (tooltips
, measure_tool
, "Measure distances on the screen", NULL
);
486 gtk_widget_add_accelerator (measure_tool
, "activate", accel_group
,
487 GDK_F4
, (GdkModifierType
) 0,
490 menuitem10
= gtk_menu_item_new_with_mnemonic (_("_Help"));
491 gtk_container_add (GTK_CONTAINER (menubar1
), menuitem10
);
493 menuitem10_menu
= gtk_menu_new ();
494 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem10
), menuitem10_menu
);
496 online_manual = gtk_menu_item_new_with_mnemonic (_("_Online Manual..."));
497 gtk_container_add (GTK_CONTAINER (menuitem10_menu), online_manual);
498 gtk_tooltips_set_tip (tooltips, online_manual, "View the online help documentation", NULL);
500 about
= gtk_image_menu_item_new_with_mnemonic (_("_About Gerbv..."));
501 gtk_container_add (GTK_CONTAINER (menuitem10_menu
), about
);
502 gtk_tooltips_set_tip (tooltips
, about
, "View information about this software", NULL
);
504 image34
= gtk_image_new_from_stock ("gtk-dialog-info", GTK_ICON_SIZE_MENU
);
505 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (about
), image34
);
507 toolbar_hbox
= gtk_hbox_new (FALSE
, 0);
508 gtk_box_pack_start (GTK_BOX (vbox1
), toolbar_hbox
, FALSE
, FALSE
, 0);
510 handlebox
= gtk_handle_box_new ();
512 gtk_box_pack_start (GTK_BOX (toolbar_hbox
), handlebox
, TRUE
, TRUE
, 0);
514 button_toolbar
= gtk_toolbar_new ();
515 gtk_widget_set_size_request (button_toolbar
, 500, -1);
516 gtk_container_add (GTK_CONTAINER (handlebox
), button_toolbar
);
517 gtk_toolbar_set_style (GTK_TOOLBAR (button_toolbar
), GTK_TOOLBAR_ICONS
);
518 tmp_toolbar_icon_size
= gtk_toolbar_get_icon_size (GTK_TOOLBAR (button_toolbar
));
520 toolbutton_new
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-new");
521 gtk_tooltips_set_tip (tooltips
, toolbutton_new
, "Close all layers and start a new project", NULL
);
522 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_new
);
524 toolbutton_open
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-open");
525 gtk_tooltips_set_tip (tooltips
, toolbutton_open
, "Open Gerber, drill, or pick and place file(s)", NULL
);
526 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_open
);
528 toolbutton_revert
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-revert-to-saved");
529 gtk_tooltips_set_tip (tooltips
, toolbutton_revert
, "Reload all layers", NULL
);
530 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_revert
);
532 toolbutton_save
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-save");
533 gtk_tooltips_set_tip (tooltips
, toolbutton_save
, "Save the current project", NULL
);
534 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_save
);
536 separatortoolitem1
= (GtkWidget
*) gtk_separator_tool_item_new ();
537 gtk_container_add (GTK_CONTAINER (button_toolbar
), separatortoolitem1
);
538 #ifndef RENDER_USING_GDK
539 #if GTK_CHECK_VERSION(2,10,0)
540 toolbutton_print
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-print");
541 gtk_tooltips_set_tip (tooltips
, toolbutton_print
, "Print the visible layers", NULL
);
542 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_print
);
544 separatortoolitem2
= (GtkWidget
*) gtk_separator_tool_item_new ();
545 gtk_container_add (GTK_CONTAINER (button_toolbar
), separatortoolitem2
);
548 toolbutton_zoom_in
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-zoom-in");
549 gtk_tooltips_set_tip (tooltips
, toolbutton_zoom_in
, "Zoom in", NULL
);
550 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_zoom_in
);
552 toolbutton_zoom_out
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-zoom-out");
553 gtk_tooltips_set_tip (tooltips
, toolbutton_zoom_out
, "Zoom out", NULL
);
554 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_zoom_out
);
556 toolbutton_zoom_fit
= (GtkWidget
*) gtk_tool_button_new_from_stock ("gtk-zoom-fit");
557 gtk_tooltips_set_tip (tooltips
, toolbutton_zoom_fit
, "Zoom to fit all visible layers in the window", NULL
);
558 gtk_container_add (GTK_CONTAINER (button_toolbar
), toolbutton_zoom_fit
);
560 /* Turn these on later when we have icons for these buttons */
562 separatortoolitem3 = (GtkWidget*) gtk_separator_tool_item_new ();
563 gtk_container_add (GTK_CONTAINER (button_toolbar), separatortoolitem3);
565 toolbutton_analyze = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-apply");
566 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_analyze);
568 toolbutton_validate = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-apply");
569 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_validate);
571 toolbutton_control = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-apply");
572 gtk_container_add (GTK_CONTAINER (button_toolbar), toolbutton_control);
575 separatortoolitem4
= (GtkWidget
*) gtk_separator_tool_item_new ();
576 gtk_container_add (GTK_CONTAINER (button_toolbar
), separatortoolitem4
);
577 #ifndef RENDER_USING_GDK
578 toggletoolbutton_pointer
= (GtkWidget
*) gtk_toggle_tool_button_new();
579 pointerimage
= gtk_image_new_from_pixbuf(pointerpixbuf
);
580 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_pointer
),
582 gtk_tooltips_set_tip (tooltips
, toggletoolbutton_pointer
, "Select objects on the screen", NULL
);
583 gtk_container_add (GTK_CONTAINER (button_toolbar
), toggletoolbutton_pointer
);
585 toggletoolbutton_pan
= (GtkWidget
*) gtk_toggle_tool_button_new();
586 moveimage
= gtk_image_new_from_pixbuf(movepixbuf
);
587 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_pan
),
589 gtk_tooltips_set_tip (tooltips
, toggletoolbutton_pan
, "Pan by left clicking and dragging", NULL
);
590 gtk_container_add (GTK_CONTAINER (button_toolbar
), toggletoolbutton_pan
);
593 toggletoolbutton_zoom
= (GtkWidget
*) gtk_toggle_tool_button_new();
594 zoomimage
= gtk_image_new_from_pixbuf(zoompixbuf
);
595 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_zoom
),
597 gtk_tooltips_set_tip (tooltips
, toggletoolbutton_zoom
, "Zoom by left clicking or dragging", NULL
);
598 gtk_container_add (GTK_CONTAINER (button_toolbar
), toggletoolbutton_zoom
);
600 toggletoolbutton_measure
= (GtkWidget
*) gtk_toggle_tool_button_new();
601 measureimage
= gtk_image_new_from_pixbuf(measurepixbuf
);
602 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggletoolbutton_measure
),
604 gtk_tooltips_set_tip (tooltips
, toggletoolbutton_measure
, "Measure distances on the screen", NULL
);
605 gtk_container_add (GTK_CONTAINER (button_toolbar
), toggletoolbutton_measure
);
607 hpaned1
= gtk_hpaned_new ();
608 gtk_box_pack_start (GTK_BOX (vbox1
), hpaned1
, TRUE
, TRUE
, 0);
609 gtk_paned_set_position (GTK_PANED (hpaned1
), 225);
611 sidepane_vbox
= gtk_vbox_new (FALSE
, 0);
612 gtk_widget_set_size_request (sidepane_vbox
, 150, -1);
614 gtk_paned_pack1 (GTK_PANED (hpaned1
), sidepane_vbox
, TRUE
, FALSE
);
615 gtk_container_set_border_width (GTK_CONTAINER (sidepane_vbox
), 5);
617 sidepane_notebook
= gtk_notebook_new ();
618 gtk_widget_set_size_request (sidepane_notebook
, 100, -1);
619 gtk_box_pack_start (GTK_BOX (sidepane_vbox
), sidepane_notebook
, TRUE
, TRUE
, 0);
621 vbox10
= gtk_vbox_new (FALSE
, 3);
622 gtk_container_add (GTK_CONTAINER (sidepane_notebook
), vbox10
);
623 gtk_widget_set_size_request (vbox10
, 82, -1);
624 gtk_container_set_border_width (GTK_CONTAINER (vbox10
), 4);
626 hbox4
= gtk_hbox_new (FALSE
, 0);
627 gtk_box_pack_start (GTK_BOX (vbox10
), hbox4
, FALSE
, FALSE
, 0);
629 label1
= gtk_label_new (_("Rendering: "));
630 gtk_box_pack_start (GTK_BOX (hbox4
), label1
, FALSE
, FALSE
, 0);
632 render_combobox
= gtk_combo_box_new_text ();
633 gtk_box_pack_start (GTK_BOX (hbox4
), render_combobox
, TRUE
, TRUE
, 0);
634 #ifdef RENDER_USING_GDK
635 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox
), _("Normal"));
636 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox
), _("XOR"));
637 if (screenRenderInfo
.renderType
< 2)
638 gtk_combo_box_set_active (GTK_COMBO_BOX (render_combobox
), screenRenderInfo
.renderType
);
640 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox
), _("Fast"));
641 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox
), _("Fast, with XOR"));
642 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox
), _("Normal"));
643 gtk_combo_box_append_text (GTK_COMBO_BOX (render_combobox
), _("High quality"));
644 if (screenRenderInfo
.renderType
< 4)
645 gtk_combo_box_set_active (GTK_COMBO_BOX (render_combobox
), screenRenderInfo
.renderType
);
647 scrolledwindow1
= gtk_scrolled_window_new (NULL
, NULL
);
648 gtk_box_pack_start (GTK_BOX (vbox10
), scrolledwindow1
, TRUE
, TRUE
, 0);
649 gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow1
), 2);
650 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1
),
651 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
652 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1
),
655 hbox1
= gtk_hbox_new (TRUE
, 0);
656 gtk_box_pack_start (GTK_BOX (vbox10
), hbox1
, FALSE
, FALSE
, 0);
658 button4
= gtk_button_new ();
659 gtk_box_pack_start (GTK_BOX (hbox1
), button4
, FALSE
, TRUE
, 0);
661 image8
= gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_BUTTON
);
662 gtk_container_add (GTK_CONTAINER (button4
), image8
);
664 button5
= gtk_button_new ();
665 gtk_box_pack_start (GTK_BOX (hbox1
), button5
, FALSE
, TRUE
, 0);
667 image9
= gtk_image_new_from_stock ("gtk-go-down", GTK_ICON_SIZE_BUTTON
);
668 gtk_container_add (GTK_CONTAINER (button5
), image9
);
670 button6
= gtk_button_new ();
671 gtk_box_pack_start (GTK_BOX (hbox1
), button6
, FALSE
, TRUE
, 0);
673 image10
= gtk_image_new_from_stock ("gtk-go-up", GTK_ICON_SIZE_BUTTON
);
674 gtk_container_add (GTK_CONTAINER (button6
), image10
);
676 button7
= gtk_button_new ();
677 gtk_box_pack_start (GTK_BOX (hbox1
), button7
, FALSE
, TRUE
, 0);
679 image11
= gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_BUTTON
);
680 gtk_container_add (GTK_CONTAINER (button7
), image11
);
682 Layer_label
= gtk_label_new (_("Layers"));
683 gtk_notebook_set_tab_label (GTK_NOTEBOOK (sidepane_notebook
),
684 gtk_notebook_get_nth_page (GTK_NOTEBOOK (sidepane_notebook
), 0),
687 vbox11
= gtk_vbox_new (FALSE
, 2);
688 gtk_container_add (GTK_CONTAINER (sidepane_notebook
), vbox11
);
689 gtk_container_set_border_width (GTK_CONTAINER (vbox11
), 3);
691 messages_scrolledwindow
= gtk_scrolled_window_new (NULL
, NULL
);
692 gtk_box_pack_start (GTK_BOX (vbox11
), messages_scrolledwindow
, TRUE
, TRUE
, 0);
693 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (messages_scrolledwindow
),
694 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
696 message_textview
= gtk_text_view_new ();
697 gtk_container_add (GTK_CONTAINER (messages_scrolledwindow
), message_textview
);
698 gtk_text_view_set_editable (GTK_TEXT_VIEW (message_textview
), FALSE
);
699 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (message_textview
), GTK_WRAP_WORD
);
700 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (message_textview
), FALSE
);
702 clear_messages_button
= gtk_button_new_from_stock ("gtk-clear");
703 gtk_box_pack_start (GTK_BOX (vbox11
), clear_messages_button
, FALSE
, FALSE
, 0);
705 Message_label
= gtk_label_new (_("Messages"));
706 gtk_notebook_set_tab_label (GTK_NOTEBOOK (sidepane_notebook
),
707 gtk_notebook_get_nth_page (GTK_NOTEBOOK (sidepane_notebook
), 1),
710 vbox2
= gtk_vbox_new (FALSE
, 4);
711 gtk_paned_pack2 (GTK_PANED (hpaned1
), vbox2
, TRUE
, FALSE
);
712 gtk_container_set_border_width (GTK_CONTAINER (vbox2
), 4);
714 main_view_table
= gtk_table_new (3, 3, FALSE
);
715 gtk_box_pack_start (GTK_BOX (vbox2
), main_view_table
, TRUE
, TRUE
, 0);
717 hRuler
= gtk_hruler_new ();
718 gtk_table_attach (GTK_TABLE (main_view_table
), hRuler
, 1, 2, 0, 1,
719 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
720 (GtkAttachOptions
) (GTK_FILL
), 0, 0);
721 gtk_ruler_set_range (GTK_RULER (hRuler
), 0, 100, 8.56051, 1000);
723 vRuler
= gtk_vruler_new ();
724 gtk_table_attach (GTK_TABLE (main_view_table
), vRuler
, 0, 1, 1, 2,
725 (GtkAttachOptions
) (GTK_FILL
),
726 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
), 0, 0);
727 gtk_ruler_set_range (GTK_RULER (vRuler
), 0, 100, 8.37341, 1000);
729 drawingarea
= gtk_drawing_area_new();
730 gtk_table_attach (GTK_TABLE (main_view_table
), drawingarea
, 1, 2, 1, 2,
731 (GtkAttachOptions
) (GTK_FILL
),
732 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
), 0, 0);
734 hAdjustment
= (GtkWidget
*) gtk_adjustment_new (0.0, -1000.0, 1000.0, 1000.0, 1000.0, 500.0);
735 vAdjustment
= (GtkWidget
*) gtk_adjustment_new (0.0, -1000.0, 1000.0, 1000.0, 1000.0, 500.0);
737 hScrollbar
= gtk_hscrollbar_new (GTK_ADJUSTMENT (hAdjustment
));
738 gtk_table_attach (GTK_TABLE (main_view_table
), hScrollbar
, 1, 2, 2, 3,
739 (GtkAttachOptions
) (GTK_FILL
),
740 (GtkAttachOptions
) (GTK_FILL
), 0, 0);
742 vScrollbar
= gtk_vscrollbar_new (GTK_ADJUSTMENT (vAdjustment
));
743 gtk_table_attach (GTK_TABLE (main_view_table
), vScrollbar
, 2, 3, 1, 2,
744 (GtkAttachOptions
) (GTK_FILL
),
745 (GtkAttachOptions
) (GTK_FILL
), 0, 0);
747 GtkWidget
*frame1
= gtk_frame_new (NULL
);
748 gtk_box_pack_start (GTK_BOX (vbox2
), frame1
, FALSE
, FALSE
, 0);
750 hbox5
= gtk_hbox_new (FALSE
, 10);
751 gtk_container_add (GTK_CONTAINER(frame1
), hbox5
);
753 statusbar_label_left
= gtk_label_new (_("( 0.0, 0.0 )"));
754 gtk_box_pack_start (GTK_BOX (hbox5
), statusbar_label_left
, FALSE
, FALSE
, 0);
755 gtk_widget_set_size_request (statusbar_label_left
, 130, -1);
756 gtk_label_set_justify ((GtkLabel
*) statusbar_label_left
, GTK_JUSTIFY_RIGHT
);
758 combobox2
= gtk_combo_box_new_text ();
759 gtk_box_pack_start (GTK_BOX (hbox5
), combobox2
, FALSE
, FALSE
, 0);
760 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox2
), _("mil"));
761 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox2
), _("mm"));
762 gtk_combo_box_append_text (GTK_COMBO_BOX (combobox2
), _("in"));
764 statusbar_label_right
= gtk_label_new (_(""));
765 gtk_box_pack_start (GTK_BOX (hbox5
), statusbar_label_right
, TRUE
, TRUE
, 0);
766 gtk_label_set_ellipsize ((GtkLabel
*)statusbar_label_right
, PANGO_ELLIPSIZE_END
);
767 gtk_misc_set_alignment (GTK_MISC (statusbar_label_right
), 0, 0.5);
772 * Connect signals to widgets
775 /* --- File menu --- */
776 g_signal_connect ((gpointer
) new, "activate",
777 G_CALLBACK (callbacks_new_activate
),
779 g_signal_connect ((gpointer
) open_project
, "activate",
780 G_CALLBACK (callbacks_open_project_activate
),
782 g_signal_connect ((gpointer
) open_layer
, "activate",
783 G_CALLBACK (callbacks_open_layer_activate
),
785 g_signal_connect ((gpointer
) revert
, "activate",
786 G_CALLBACK (callbacks_revert_activate
),
788 g_signal_connect ((gpointer
) save_layer
, "activate",
789 G_CALLBACK (callbacks_save_layer_activate
),
791 g_signal_connect ((gpointer
) save_as_layer
, "activate",
792 G_CALLBACK (callbacks_generic_save_activate
),
793 (gpointer
) CALLBACKS_SAVE_LAYER_AS
);
794 g_signal_connect ((gpointer
) save
, "activate",
795 G_CALLBACK (callbacks_save_project_activate
),
797 g_signal_connect ((gpointer
) save_as
, "activate",
798 G_CALLBACK (callbacks_generic_save_activate
),
799 (gpointer
) CALLBACKS_SAVE_PROJECT_AS
);
801 g_signal_connect ((gpointer
) png
, "activate",
802 G_CALLBACK (callbacks_generic_save_activate
),
803 (gpointer
) CALLBACKS_SAVE_FILE_PNG
);
806 #ifndef RENDER_USING_GDK
807 g_signal_connect ((gpointer
) pdf
, "activate",
808 G_CALLBACK (callbacks_generic_save_activate
),
809 (gpointer
) CALLBACKS_SAVE_FILE_PDF
);
810 g_signal_connect ((gpointer
) svg
, "activate",
811 G_CALLBACK (callbacks_generic_save_activate
),
812 (gpointer
) CALLBACKS_SAVE_FILE_SVG
);
813 g_signal_connect ((gpointer
) postscript
, "activate",
814 G_CALLBACK (callbacks_generic_save_activate
),
815 (gpointer
) CALLBACKS_SAVE_FILE_PS
);
816 g_signal_connect ((gpointer
) rs274x
, "activate",
817 G_CALLBACK (callbacks_generic_save_activate
),
818 (gpointer
) CALLBACKS_SAVE_FILE_RS274X
);
819 g_signal_connect ((gpointer
) drill
, "activate",
820 G_CALLBACK (callbacks_generic_save_activate
),
821 (gpointer
) CALLBACKS_SAVE_FILE_DRILL
);
823 #if GTK_CHECK_VERSION(2,10,0)
824 g_signal_connect ((gpointer
) print
, "activate",
825 G_CALLBACK (callbacks_print_activate
),
829 g_signal_connect ((gpointer
) quit
, "activate",
830 G_CALLBACK (callbacks_quit_activate
),
833 /* --- Edit menu --- */
834 g_signal_connect ((gpointer
) delete_selected
, "activate",
835 G_CALLBACK (callbacks_delete_objects_clicked
),
838 /* --- View menu --- */
839 g_signal_connect ((gpointer
) zoom_in
, "activate",
840 G_CALLBACK (callbacks_zoom_in_activate
),
842 g_signal_connect ((gpointer
) zoom_out
, "activate",
843 G_CALLBACK (callbacks_zoom_out_activate
),
845 g_signal_connect ((gpointer
) fit_to_window
, "activate",
846 G_CALLBACK (callbacks_fit_to_window_activate
),
849 /* --- Analyze menu --- */
850 g_signal_connect ((gpointer
) analyze_active_gerbers
, "activate",
851 G_CALLBACK (callbacks_analyze_active_gerbers_activate
),
853 g_signal_connect ((gpointer
) analyze_active_drill
, "activate",
854 G_CALLBACK (callbacks_analyze_active_drill_activate
),
856 g_signal_connect ((gpointer
) analyze_display_selected_obj_props
, "activate",
857 G_CALLBACK (callbacks_display_object_properties_clicked
),
862 g_signal_connect ((gpointer) control_gerber_options, "activate",
863 G_CALLBACK (callbacks_control_gerber_options_activate),
867 /* --- Tools menu --- */
868 #ifndef RENDER_USING_GDK
869 g_signal_connect ((gpointer
) pointer_tool
, "activate",
870 G_CALLBACK (callbacks_change_tool
), (gpointer
) 0);
872 g_signal_connect ((gpointer
) pan_tool
, "activate",
873 G_CALLBACK (callbacks_change_tool
), (gpointer
) 1);
874 g_signal_connect ((gpointer
) zoom_tool
, "activate",
875 G_CALLBACK (callbacks_change_tool
), (gpointer
) 2);
876 g_signal_connect ((gpointer
) measure_tool
, "activate",
877 G_CALLBACK (callbacks_change_tool
), (gpointer
) 3);
879 /* --- Help menu --- */
881 g_signal_connect ((gpointer) online_manual, "activate",
882 G_CALLBACK (callbacks_online_manual_activate),
885 g_signal_connect ((gpointer
) about
, "activate",
886 G_CALLBACK (callbacks_about_activate
),
889 /* End of Glade generated code */
890 g_signal_connect ((gpointer
) toolbutton_new
, "clicked",
891 G_CALLBACK (callbacks_new_activate
),
893 g_signal_connect ((gpointer
) toolbutton_save
, "clicked",
894 G_CALLBACK (callbacks_save_layer_activate
),
896 g_signal_connect ((gpointer
) toolbutton_open
, "clicked",
897 G_CALLBACK (callbacks_open_layer_activate
),
899 g_signal_connect ((gpointer
) toolbutton_revert
, "clicked",
900 G_CALLBACK (callbacks_revert_activate
),
902 g_signal_connect ((gpointer
) clear_messages_button
, "clicked",
903 G_CALLBACK (callbacks_clear_messages_button_clicked
),
905 #ifndef RENDER_USING_GDK
906 #if GTK_CHECK_VERSION(2,10,0)
907 g_signal_connect ((gpointer
) toolbutton_print
, "clicked",
908 G_CALLBACK (callbacks_print_activate
),
912 g_signal_connect ((gpointer
) toolbutton_zoom_in
, "clicked",
913 G_CALLBACK (callbacks_zoom_in_activate
),
915 g_signal_connect ((gpointer
) toolbutton_zoom_out
, "clicked",
916 G_CALLBACK (callbacks_zoom_out_activate
),
918 g_signal_connect ((gpointer
) toolbutton_zoom_fit
, "clicked",
919 G_CALLBACK (callbacks_fit_to_window_activate
),
921 #ifndef RENDER_USING_GDK
922 g_signal_connect ((gpointer
) toggletoolbutton_pointer
, "clicked",
923 G_CALLBACK (callbacks_change_tool
), (gpointer
) 0);
925 g_signal_connect ((gpointer
) toggletoolbutton_pan
, "clicked",
926 G_CALLBACK (callbacks_change_tool
), (gpointer
) 1);
927 g_signal_connect ((gpointer
) toggletoolbutton_zoom
, "clicked",
928 G_CALLBACK (callbacks_change_tool
), (gpointer
) 2);
929 g_signal_connect ((gpointer
) toggletoolbutton_measure
, "clicked",
930 G_CALLBACK (callbacks_change_tool
), (gpointer
) 3);
932 g_signal_connect ((gpointer
) combobox2
, "changed",
933 G_CALLBACK (callbacks_statusbar_unit_combo_box_changed
),
936 g_signal_connect ((gpointer
) button4
, "clicked",
937 G_CALLBACK (callbacks_add_layer_button_clicked
), NULL
);
938 g_signal_connect ((gpointer
) button7
, "clicked",
939 G_CALLBACK (callbacks_remove_layer_button_clicked
), NULL
);
940 g_signal_connect ((gpointer
) button5
, "clicked",
941 G_CALLBACK (callbacks_move_layer_down_button_clicked
), NULL
);
942 g_signal_connect ((gpointer
) button6
, "clicked",
943 G_CALLBACK (callbacks_move_layer_up_clicked
), NULL
);
945 g_signal_connect ((gpointer
) hAdjustment
, "value-changed",
946 G_CALLBACK (callbacks_hadjustment_value_changed
), NULL
);
947 g_signal_connect ((gpointer
) vAdjustment
, "value-changed",
948 G_CALLBACK (callbacks_vadjustment_value_changed
), NULL
);
949 g_signal_connect ((gpointer
) hScrollbar
, "button-press-event",
950 G_CALLBACK (callbacks_scrollbar_button_pressed
), NULL
);
951 g_signal_connect ((gpointer
) hScrollbar
, "button-release-event",
952 G_CALLBACK (callbacks_scrollbar_button_released
), NULL
);
953 g_signal_connect ((gpointer
) vScrollbar
, "button-press-event",
954 G_CALLBACK (callbacks_scrollbar_button_pressed
), NULL
);
955 g_signal_connect ((gpointer
) vScrollbar
, "button-release-event",
956 G_CALLBACK (callbacks_scrollbar_button_released
), NULL
);
959 if (screen
.unit
== GERBV_MILS
)
960 gtk_combo_box_set_active (GTK_COMBO_BOX (combobox2
), 0);
961 else if (screen
.unit
== GERBV_MMS
)
962 gtk_combo_box_set_active (GTK_COMBO_BOX (combobox2
), 1);
964 gtk_combo_box_set_active (GTK_COMBO_BOX (combobox2
), 2);
968 gtk_window_add_accel_group (GTK_WINDOW (mainWindow
), accel_group
);
970 GtkListStore
*list_store
;
972 list_store
= gtk_list_store_new (4, G_TYPE_BOOLEAN
,
973 GDK_TYPE_PIXBUF
, G_TYPE_STRING
, G_TYPE_STRING
);
977 tree
= gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store
));
978 GtkCellRenderer
*renderer
;
979 GtkTreeViewColumn
*column
;
981 renderer
= gtk_cell_renderer_toggle_new ();
982 column
= gtk_tree_view_column_new_with_attributes ("Visible",
986 gtk_tree_view_column_set_min_width ((GtkTreeViewColumn
*)column
,25);
987 gtk_signal_connect(GTK_OBJECT(renderer
), "toggled",
988 GTK_SIGNAL_FUNC(callbacks_layer_tree_visibility_button_toggled
), NULL
);
990 gtk_tree_view_append_column (GTK_TREE_VIEW (tree
), column
);
992 renderer
= gtk_cell_renderer_pixbuf_new ();
993 column
= gtk_tree_view_column_new_with_attributes ("Color",
996 gtk_tree_view_append_column (GTK_TREE_VIEW (tree
), column
);
998 renderer
= gtk_cell_renderer_text_new ();
999 g_object_set (G_OBJECT (renderer
), "foreground", "red", "xalign", 0.5,
1000 "family", "Times", "size-points", 12.0, NULL
);
1001 column
= gtk_tree_view_column_new_with_attributes ("Modified",
1005 gtk_tree_view_append_column (GTK_TREE_VIEW (tree
), column
);
1006 gtk_tree_view_column_set_min_width ((GtkTreeViewColumn
*)column
,20);
1008 renderer
= gtk_cell_renderer_text_new ();
1009 column
= gtk_tree_view_column_new_with_attributes ("Name",
1013 gtk_tree_view_append_column (GTK_TREE_VIEW (tree
), column
);
1015 gtk_tree_view_set_headers_visible ((GtkTreeView
*)tree
, FALSE
);
1016 gtk_signal_connect(GTK_OBJECT(tree
), "button-press-event",
1017 GTK_SIGNAL_FUNC(callbacks_layer_tree_button_press
), NULL
);
1018 gtk_container_add (GTK_CONTAINER (scrolledwindow1
), tree
);
1020 GtkTreeSelection
*selection
;
1021 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(tree
));
1022 gtk_tree_selection_set_mode (selection
, GTK_SELECTION_BROWSE
);
1023 gtk_tree_view_set_enable_search (GTK_TREE_VIEW (tree
), FALSE
);
1024 gtk_tree_view_set_reorderable (GTK_TREE_VIEW (tree
), TRUE
);
1026 g_signal_connect (G_OBJECT(list_store
), "row-inserted",
1027 G_CALLBACK (callbacks_layer_tree_row_inserted
), NULL
);
1028 /* steal the focus to the tree to make sure none of the buttons are focused */
1029 gtk_widget_grab_focus (tree
);
1031 * Connect all events on drawing area
1033 gtk_signal_connect(GTK_OBJECT(drawingarea
), "expose_event",
1034 GTK_SIGNAL_FUNC(callbacks_drawingarea_expose_event
), NULL
);
1035 gtk_signal_connect(GTK_OBJECT(drawingarea
),"configure_event",
1036 GTK_SIGNAL_FUNC(callbacks_drawingarea_configure_event
), NULL
);
1037 gtk_signal_connect(GTK_OBJECT(drawingarea
), "motion_notify_event",
1038 GTK_SIGNAL_FUNC(callbacks_drawingarea_motion_notify_event
), NULL
);
1039 gtk_signal_connect(GTK_OBJECT(drawingarea
), "button_press_event",
1040 GTK_SIGNAL_FUNC(callbacks_drawingarea_button_press_event
), NULL
);
1041 gtk_signal_connect(GTK_OBJECT(drawingarea
), "button_release_event",
1042 GTK_SIGNAL_FUNC(callbacks_drawingarea_button_release_event
), NULL
);
1043 gtk_signal_connect_after(GTK_OBJECT(mainWindow
), "key_press_event",
1044 GTK_SIGNAL_FUNC(callbacks_window_key_press_event
), NULL
);
1045 gtk_signal_connect_after(GTK_OBJECT(mainWindow
), "key_release_event",
1046 GTK_SIGNAL_FUNC(callbacks_window_key_release_event
), NULL
);
1047 gtk_signal_connect_after(GTK_OBJECT(mainWindow
), "scroll_event",
1048 GTK_SIGNAL_FUNC(callbacks_window_scroll_event
), NULL
);
1049 gtk_signal_connect_after(GTK_OBJECT(mainWindow
), "delete_event",
1050 GTK_SIGNAL_FUNC(callbacks_quit_activate
), NULL
);
1052 gtk_widget_set_events(drawingarea
, GDK_EXPOSURE_MASK
1053 | GDK_LEAVE_NOTIFY_MASK
1054 | GDK_ENTER_NOTIFY_MASK
1055 | GDK_BUTTON_PRESS_MASK
1056 | GDK_BUTTON_RELEASE_MASK
1057 | GDK_KEY_PRESS_MASK
1058 | GDK_KEY_RELEASE_MASK
1059 | GDK_POINTER_MOTION_MASK
1060 | GDK_POINTER_MOTION_HINT_MASK
1065 * Set gtk error log handler
1067 #if !defined (__MINGW32__)
1068 g_log_set_handler (NULL
,
1069 G_LOG_FLAG_FATAL
| G_LOG_FLAG_RECURSION
| G_LOG_LEVEL_MASK
,
1070 callbacks_handle_log_messages
, NULL
);
1074 * Setup some GTK+ defaults.
1075 * These should really be somewhere else.
1077 GdkColor zoom_outline_color
= {0, 50000, 50000, 50000};
1078 GdkColor dist_measure_color
= {0, 60000, 30000, 65000};
1079 GdkColor selection_color
= {0, 65000, 65000, 65000};
1081 screen
.zoom_outline_color
= zoom_outline_color
;
1082 screen
.dist_measure_color
= dist_measure_color
;
1083 screen
.selection_color
= selection_color
;
1085 screen
.drawing_area
= drawingarea
;
1086 screen
.win
.hAdjustment
= hAdjustment
;
1087 screen
.win
.vAdjustment
= vAdjustment
;
1088 screen
.win
.hRuler
= hRuler
;
1089 screen
.win
.vRuler
= vRuler
;
1090 screen
.win
.sidepane_notebook
= sidepane_notebook
;
1091 #ifndef RENDER_USING_GDK
1092 screen
.win
.toolButtonPointer
= toggletoolbutton_pointer
;
1094 screen
.win
.toolButtonPan
= toggletoolbutton_pan
;
1095 screen
.win
.toolButtonZoom
= toggletoolbutton_zoom
;
1096 screen
.win
.toolButtonMeasure
= toggletoolbutton_measure
;
1098 /* Create right click popup menu for layer tree */
1099 screen
.win
.layerTreePopupMenu
= gtk_menu_new ();
1100 tempMenuItem
= gtk_image_menu_item_new_with_label ("Invert layer color");
1101 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1102 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Invert the display polarity of the layer", NULL
);
1103 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1104 G_CALLBACK (callbacks_invert_layer_clicked
), NULL
);
1106 tempMenuItem
= gtk_image_menu_item_new_with_label ("Change color");
1107 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1108 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Change the display color of the layer", NULL
);
1109 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1110 G_CALLBACK (callbacks_change_layer_color_clicked
), NULL
);
1112 tempMenuItem
= gtk_image_menu_item_new_with_label ("Reload layer");
1113 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1114 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Reload the layer from disk",
1116 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1117 G_CALLBACK (callbacks_reload_layer_clicked
), NULL
);
1119 tempMenuItem
= gtk_image_menu_item_new_with_label ("Edit file format");
1120 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1121 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "View and edit the numerical format used to parse this layer",
1123 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1124 G_CALLBACK (callbacks_change_layer_format_clicked
), NULL
);
1126 tempMenuItem
= gtk_image_menu_item_new_with_label ("Add layer");
1127 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1128 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Open a new layer and insert it here", NULL
);
1129 tempImage
= gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU
);
1130 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem
), tempImage
);
1131 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1132 G_CALLBACK (callbacks_add_layer_button_clicked
), NULL
);
1134 tempMenuItem
= gtk_image_menu_item_new_with_label ("Move layer down");
1135 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1136 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Move the layer down one in the layer list", NULL
);
1137 tempImage
= gtk_image_new_from_stock ("gtk-go-down", GTK_ICON_SIZE_MENU
);
1138 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem
), tempImage
);
1139 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1140 G_CALLBACK (callbacks_move_layer_down_button_clicked
), NULL
);
1142 tempMenuItem
= gtk_image_menu_item_new_with_label ("Move layer up");
1143 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1144 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Move the layer up one in the layer list", NULL
);
1145 tempImage
= gtk_image_new_from_stock ("gtk-go-up", GTK_ICON_SIZE_MENU
);
1146 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem
), tempImage
);
1147 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1148 G_CALLBACK (callbacks_move_layer_up_clicked
), NULL
);
1150 tempMenuItem
= gtk_image_menu_item_new_with_label ("Delete layer");
1151 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.layerTreePopupMenu
, tempMenuItem
);
1152 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Remove this layer", NULL
);
1153 tempImage
= gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_MENU
);
1154 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem
), tempImage
);
1155 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1156 G_CALLBACK (callbacks_remove_layer_button_clicked
), NULL
);
1158 gtk_widget_show_all (screen
.win
.layerTreePopupMenu
);
1160 /* Create right click popup menu for draw window */
1161 screen
.win
.drawWindowPopupMenu
= gtk_menu_new ();
1162 tempMenuItem
= gtk_image_menu_item_new_with_label ("Display object properties");
1163 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.drawWindowPopupMenu
, tempMenuItem
);
1164 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Examine the properties of the selected object", NULL
);
1165 tempImage
= gtk_image_new_from_stock ("gtk-info", GTK_ICON_SIZE_MENU
);
1166 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem
), tempImage
);
1167 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1168 G_CALLBACK (callbacks_display_object_properties_clicked
), NULL
);
1170 /* Include these after they are coded.
1171 tempMenuItem = gtk_image_menu_item_new_with_label ("Edit object properties");
1172 gtk_menu_shell_append ((GtkMenuShell *)screen.win.drawWindowPopupMenu, tempMenuItem);
1173 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Edit the properties of the selected object", NULL);
1174 g_signal_connect ((gpointer) tempMenuItem, "activate",
1175 G_CALLBACK (callbacks_edit_object_properties_clicked), NULL);
1177 tempMenuItem = gtk_image_menu_item_new_with_label ("Move object(s)");
1178 gtk_menu_shell_append ((GtkMenuShell *)screen.win.drawWindowPopupMenu, tempMenuItem);
1179 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Move the selected object(s)",NULL);
1180 g_signal_connect ((gpointer) tempMenuItem, "activate",
1181 G_CALLBACK (callbacks_move_objects_clicked), NULL);
1183 tempMenuItem = gtk_image_menu_item_new_with_label ("Reduce area");
1184 gtk_menu_shell_append ((GtkMenuShell *)screen.win.drawWindowPopupMenu, tempMenuItem);
1185 gtk_tooltips_set_tip (tooltips, tempMenuItem, "Reduce the area of the object (e.g. to prevent component floating)",NULL);
1186 g_signal_connect ((gpointer) tempMenuItem, "activate",
1187 G_CALLBACK (callbacks_reduce_object_area_clicked), NULL);
1190 tempMenuItem
= gtk_image_menu_item_new_with_label ("Delete selected objects");
1191 gtk_menu_shell_append ((GtkMenuShell
*)screen
.win
.drawWindowPopupMenu
, tempMenuItem
);
1192 gtk_tooltips_set_tip (tooltips
, tempMenuItem
, "Delete the selected object(s)",NULL
);
1193 tempImage
= gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_MENU
);
1194 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (tempMenuItem
), tempImage
);
1195 g_signal_connect ((gpointer
) tempMenuItem
, "activate",
1196 G_CALLBACK (callbacks_delete_objects_clicked
), NULL
);
1198 gtk_widget_show_all (screen
.win
.drawWindowPopupMenu
);
1200 /* make sure tooltips show on gtk <2.12 systems */
1201 gtk_tooltips_enable (tooltips
);
1203 * Good defaults according to Ales. Gives aspect ratio of 1.3333...
1205 if ((req_width
!= -1) && (req_height
!= -1)) {
1207 height
= req_height
;
1213 screen
= gdk_screen_get_default();
1214 nmonitors
= gdk_screen_get_n_monitors(screen
);
1216 width
= gdk_screen_get_width(screen
) * 3/4 / nmonitors
;
1217 height
= gdk_screen_get_height(screen
) * 3/4 / nmonitors
;
1220 gtk_window_set_default_size((GtkWindow
*)mainWindow
, width
, height
);
1222 gtk_widget_show_all (mainWindow
);
1223 screen
.win
.topLevelWindow
= mainWindow
;
1224 screen
.win
.messageTextView
= message_textview
;
1225 screen
.win
.statusMessageLeft
= statusbar_label_left
;
1226 screen
.win
.statusMessageRight
= statusbar_label_right
;
1227 screen
.win
.statusUnitComboBox
= combobox2
;
1228 screen
.win
.layerTree
= tree
;
1229 screen
.win
.treeIsUpdating
= FALSE
;
1231 screen
.selectionInfo
.selectedNodeArray
= g_array_new (FALSE
,
1232 FALSE
, sizeof(gerbv_selection_item_t
));
1233 /* Make pointer tool default */
1234 callbacks_change_tool (NULL
, (gpointer
) 0);
1236 rename_main_window("",mainWindow
);
1238 set_window_icon (mainWindow
);
1239 callbacks_update_layer_tree ();
1241 /* connect this signal as late as possible to avoid triggering it before
1243 g_signal_connect ((gpointer
) render_combobox
, "changed",
1244 G_CALLBACK (callbacks_sidepane_render_type_combo_box_changed
),
1249 /* ---------------------------------------------------- */
1251 interface_set_render_type (int t
)
1253 #ifdef RENDER_USING_GDK
1260 screenRenderInfo
.renderType
= t
;
1262 /* make sure the interface is already up before calling
1263 * gtk_combo_box_set_active()
1265 if (render_combobox
)
1266 gtk_combo_box_set_active (GTK_COMBO_BOX (render_combobox
), t
);
1269 /* ---------------------------------------------------- */
1271 * This dialog box shows a message and two buttons:
1272 * "OK" and "Cancel". It returns gboolean 1 if the
1273 * user clicked "OK", and gboolean 0 if the user
1279 interface_get_alert_dialog_response (gchar
*primaryText
, gchar
*secondaryText
,
1280 gboolean show_checkbox
, gboolean
*ask_to_show_again
)
1281 /* This fcn returns TRUE if the user presses the OK button,
1282 otherwise it returns FALSE. */
1284 /* Set show_checkbox = TRUE to show "do not show this again" checkbox. */
1285 /* Point ask_to_show_again to the variable to set to not show the checkbox. */
1287 GtkWidget
*dialog_vbox1
;
1291 GtkWidget
*checkbox
=NULL
;
1292 GtkWidget
*dialog_action_area1
;
1293 GtkWidget
*cancelbutton1
;
1294 GtkWidget
*okbutton1
;
1295 gboolean returnVal
= FALSE
;
1297 dialog1
= gtk_dialog_new ();
1298 gtk_container_set_border_width (GTK_CONTAINER (dialog1
), 6);
1299 gtk_window_set_resizable (GTK_WINDOW (dialog1
), FALSE
);
1300 gtk_window_set_type_hint (GTK_WINDOW (dialog1
), GDK_WINDOW_TYPE_HINT_DIALOG
);
1301 gtk_dialog_set_has_separator (GTK_DIALOG (dialog1
), FALSE
);
1303 dialog_vbox1
= GTK_DIALOG (dialog1
)->vbox
;
1305 hbox1
= gtk_hbox_new (FALSE
, 12);
1306 gtk_box_pack_start (GTK_BOX (dialog_vbox1
), hbox1
, TRUE
, TRUE
, 0);
1307 gtk_container_set_border_width (GTK_CONTAINER (hbox1
), 6);
1309 image1
= gtk_image_new_from_icon_name ("gtk-dialog-warning", GTK_ICON_SIZE_DIALOG
);
1310 gtk_box_pack_start (GTK_BOX (hbox1
), image1
, TRUE
, TRUE
, 0);
1311 gtk_misc_set_alignment (GTK_MISC (image1
), 0.5, 0);
1313 gchar
*labelMessage
= g_strconcat ("<span weight=\"bold\" size=\"larger\">",primaryText
,
1314 "</span>\n<span/>\n",secondaryText
,NULL
);
1315 label1
= gtk_label_new (labelMessage
);
1316 g_free (labelMessage
);
1317 GtkWidget
*vbox9
= gtk_vbox_new (FALSE
, 0);
1318 gtk_box_pack_start (GTK_BOX (vbox9
), label1
, FALSE
, FALSE
, 0);
1319 gtk_box_pack_start (GTK_BOX (hbox1
), vbox9
, FALSE
, FALSE
, 0);
1320 gtk_label_set_use_markup (GTK_LABEL (label1
), TRUE
);
1321 gtk_label_set_line_wrap (GTK_LABEL (label1
), TRUE
);
1323 // even with no checkbox, this extra hbox gives the recommended 24 px space between the
1324 // label and the buttons
1325 GtkWidget
*hbox2
= gtk_hbox_new (FALSE
, 12);
1326 if (show_checkbox
) {
1327 GtkWidget
*label3
= gtk_label_new (" ");
1329 checkbox
= gtk_check_button_new_with_label("Do not show this dialog again.");
1330 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbox
), FALSE
);
1331 gtk_box_pack_start (GTK_BOX (hbox2
), label3
, FALSE
, FALSE
, 0);
1332 gtk_box_pack_start (GTK_BOX (hbox2
), checkbox
, FALSE
, FALSE
, 0);
1334 gtk_box_pack_start (GTK_BOX (vbox9
), hbox2
, FALSE
, FALSE
, 12);
1336 dialog_action_area1
= GTK_DIALOG (dialog1
)->action_area
;
1337 gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1
), GTK_BUTTONBOX_END
);
1339 cancelbutton1
= gtk_button_new_from_stock ("gtk-cancel");
1340 gtk_dialog_add_action_widget (GTK_DIALOG (dialog1
), cancelbutton1
, GTK_RESPONSE_CANCEL
);
1341 GTK_WIDGET_SET_FLAGS (cancelbutton1
, GTK_CAN_DEFAULT
);
1342 gtk_widget_grab_default (cancelbutton1
);
1343 gtk_widget_grab_focus (cancelbutton1
);
1345 okbutton1
= gtk_button_new_from_stock ("gtk-ok");
1346 gtk_dialog_add_action_widget (GTK_DIALOG (dialog1
), okbutton1
, GTK_RESPONSE_OK
);
1347 GTK_WIDGET_SET_FLAGS (okbutton1
, GTK_CAN_DEFAULT
);
1349 gtk_widget_show_all (dialog1
);
1351 if (gtk_dialog_run ((GtkDialog
*)dialog1
) == GTK_RESPONSE_OK
) {
1352 /* check to see if user clicked on "do not show again" box */
1353 if ((show_checkbox
== TRUE
) &&
1354 (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox
)) == TRUE
) &&
1355 (ask_to_show_again
!= NULL
) ) {
1356 /* The user clicked the "do not show again box". Set corresponding
1358 *ask_to_show_again
= FALSE
;
1362 gtk_widget_destroy (dialog1
);
1369 /* ---------------------------------------------------- */
1371 * This dialog box shows a textmessage and one buttons:
1372 * "OK". It does not return anything.
1376 interface_show_alert_dialog (gchar
*primaryText
, gchar
*secondaryText
,
1377 gboolean show_checkbox
, gboolean
*ask_to_show_again
)
1378 /* This fcn tells the user something, and only displays "OK" */
1380 /* Set show_checkbox = TRUE to show "do not show this again" checkbox. */
1381 /* Point ask_to_show_again to the variable to set to not show the checkbox. */
1383 GtkWidget
*dialog_vbox1
;
1387 GtkWidget
*checkbox
=NULL
;
1388 GtkWidget
*dialog_action_area1
;
1389 GtkWidget
*okbutton1
;
1391 dialog1
= gtk_dialog_new ();
1392 gtk_container_set_border_width (GTK_CONTAINER (dialog1
), 6);
1393 gtk_window_set_resizable (GTK_WINDOW (dialog1
), FALSE
);
1394 gtk_window_set_type_hint (GTK_WINDOW (dialog1
), GDK_WINDOW_TYPE_HINT_DIALOG
);
1395 gtk_dialog_set_has_separator (GTK_DIALOG (dialog1
), FALSE
);
1397 dialog_vbox1
= GTK_DIALOG (dialog1
)->vbox
;
1399 hbox1
= gtk_hbox_new (FALSE
, 12);
1400 gtk_box_pack_start (GTK_BOX (dialog_vbox1
), hbox1
, TRUE
, TRUE
, 0);
1401 gtk_container_set_border_width (GTK_CONTAINER (hbox1
), 6);
1403 image1
= gtk_image_new_from_icon_name ("gtk-dialog-warning", GTK_ICON_SIZE_DIALOG
);
1404 gtk_box_pack_start (GTK_BOX (hbox1
), image1
, TRUE
, TRUE
, 0);
1405 gtk_misc_set_alignment (GTK_MISC (image1
), 0.5, 0);
1407 gchar
*labelMessage
= g_strconcat ("<span weight=\"bold\" size=\"larger\">",primaryText
,
1408 "</span>\n<span/>\n",secondaryText
,NULL
);
1409 label1
= gtk_label_new (labelMessage
);
1410 g_free (labelMessage
);
1412 GtkWidget
*vbox9
= gtk_vbox_new (FALSE
, 0);
1413 gtk_box_pack_start (GTK_BOX (vbox9
), label1
, FALSE
, FALSE
, 0);
1414 gtk_label_set_use_markup (GTK_LABEL (label1
), TRUE
);
1415 gtk_label_set_line_wrap (GTK_LABEL (label1
), TRUE
);
1416 gtk_box_pack_start (GTK_BOX (hbox1
), vbox9
, FALSE
, FALSE
, 0);
1418 GtkWidget
*hbox2
= gtk_hbox_new (FALSE
, 12);
1419 if (show_checkbox
) {
1420 GtkWidget
*label3
= gtk_label_new (" ");
1422 checkbox
= gtk_check_button_new_with_label("Do not show this dialog again.");
1423 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbox
), FALSE
);
1424 gtk_box_pack_start (GTK_BOX (hbox2
), label3
, FALSE
, FALSE
, 0);
1425 gtk_box_pack_start (GTK_BOX (hbox2
), checkbox
, FALSE
, FALSE
, 0);
1427 gtk_box_pack_start (GTK_BOX (vbox9
), hbox2
, FALSE
, FALSE
, 12);
1429 dialog_action_area1
= GTK_DIALOG (dialog1
)->action_area
;
1430 gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1
), GTK_BUTTONBOX_END
);
1432 okbutton1
= gtk_button_new_from_stock ("gtk-ok");
1433 gtk_dialog_add_action_widget (GTK_DIALOG (dialog1
), okbutton1
, GTK_RESPONSE_OK
);
1434 GTK_WIDGET_SET_FLAGS (okbutton1
, GTK_CAN_DEFAULT
);
1436 gtk_widget_show_all (dialog1
);
1438 /* check to see if user clicked on "do not show again" box */
1439 if ((show_checkbox
== TRUE
) &&
1440 (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox
)) == TRUE
) &&
1441 (ask_to_show_again
!= NULL
) ) {
1442 /* The user clicked the "do not show again box". Set corresponding
1444 *ask_to_show_again
= FALSE
;
1447 gtk_dialog_run (GTK_DIALOG(dialog1
));
1448 gtk_widget_destroy (dialog1
);