Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 26695) +++ trunk/scconfig/plugins.h (revision 26696) @@ -8,7 +8,6 @@ plugin_def("lib_compat_help", "#compatibility helper functions", sbuildin, 1, 0) plugin_def("lib_gensexpr", "#s-expression library", sdisable, 0, 0) plugin_def("lib_gtk_common", "all-hid_gtk common code", sdisable, 0, 0) -plugin_def("lib_gtk_hid", "hid_gtk generic part", sdisable, 0, 0) plugin_def("lib_hid_common", "all-gui-hid common code", sdisable, 0, 0) plugin_def("lib_hid_gl", "openGL rendering", sdisable, 0, 0) plugin_def("lib_hid_pcbui", "common PCB-related GUI elements", sdisable, 0, 0) @@ -153,9 +152,7 @@ plugin_dep("fp_wget", "fp_fs", 0) plugin_dep("fp_wget", "lib_wget", 0) plugin_dep("hid_gtk2_gdk", "lib_gtk_common", 01) -plugin_dep("hid_gtk2_gdk", "lib_gtk_hid", 01) plugin_dep("hid_gtk2_gl", "lib_gtk_common", 01) -plugin_dep("hid_gtk2_gl", "lib_gtk_hid", 01) plugin_dep("hid_gtk2_gl", "lib_hid_gl", 01) plugin_dep("hid_gtk3_cairo", "lib_gtk_common", 0) plugin_dep("hid_gtk3_cairo", "lib_gtk_hid", 0) @@ -178,7 +175,6 @@ plugin_dep("io_tedax", "lib_compat_help", 0) plugin_dep("io_tedax", "lib_netmap", 0) plugin_dep("lib_gtk_common", "lib_hid_common", 0) -plugin_dep("lib_gtk_hid", "lib_hid_common", 0) plugin_dep("lib_vfs", "propedit", 0) plugin_dep("millpath", "lib_polyhelp", 0) plugin_dep("order_pcbway", "order", 0) Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 26695) +++ trunk/src/Makefile.dep (revision 26696) @@ -1968,7 +1968,7 @@ obj_text.h font.h ../src_3rd/genht/htip.h box.h math_helper.h \ misc_util.h route.h draw.h grid.h board.h vtroutestyle.h layer_grp.h \ rats_patch.h hidlib.h hid_attrib.h hid_color.h funchash_core.h \ - funchash.h funchash_core_list.h ../src_plugins/lib_gtk_hid/gui.h hid.h \ + funchash.h funchash_core_list.h ../src_plugins/lib_gtk_common/gui.h hid.h \ ../src_plugins/lib_gtk_common/ui_zoompan.h pcb_bool.h \ ../src_plugins/lib_gtk_common/in_mouse.h hid_cfg_input.h \ ../src_3rd/genht/htpp.h hid_cfg.h ../src_plugins/lib_gtk_common/glue.h \ @@ -1979,9 +1979,9 @@ ../src_plugins/lib_gtk_common/bu_command.h \ ../src_plugins/lib_gtk_common/in_mouse.h \ ../src_plugins/lib_gtk_common/glue.h event.h \ - ../src_plugins/lib_gtk_hid/render.h ../src_plugins/lib_gtk_hid/gui.h \ - ../src_plugins/lib_gtk_hid/coord_conv.h compat_misc.h \ - ../src_plugins/lib_gtk_hid/preview_helper.h \ + ../src_plugins/lib_gtk_common/render.h ../src_plugins/lib_gtk_common/gui.h \ + ../src_plugins/lib_gtk_common/coord_conv.h compat_misc.h \ + ../src_plugins/lib_gtk_common/preview_helper.h \ ../src_plugins/lib_gtk_common/hid_gtk_conf.h \ ../src_plugins/lib_gtk_common/lib_gtk_config.h \ ../src_plugins/lib_hid_common/clip.h global_typedefs.h @@ -2001,12 +2001,12 @@ obj_line_list.h obj_line.h obj_poly_list.h obj_poly.h polyarea.h \ obj_text_list.h obj_text.h font.h ../src_3rd/genht/htip.h box.h \ math_helper.h misc_util.h ../src_3rd/genvector/gds_char.h \ - ../src_plugins/lib_gtk_hid/glue_common.h hid.h \ - ../src_plugins/lib_gtk_hid/glue_hid.h \ - ../src_plugins/lib_gtk_hid/glue_conf.h conf.h pcb-printf.h \ + ../src_plugins/lib_gtk_common/glue_common.h hid.h \ + ../src_plugins/lib_gtk_common/glue_hid.h \ + ../src_plugins/lib_gtk_common/glue_conf.h conf.h pcb-printf.h \ ../src_3rd/liblihata/lihata.h list_conf.h conf.h \ - ../src_plugins/lib_gtk_hid/glue_win32.h \ - ../src_plugins/lib_gtk_hid/common.h event.h hidlib.h \ + ../src_plugins/lib_gtk_common/glue_win32.h \ + ../src_plugins/lib_gtk_common/common.h event.h hidlib.h \ ../src_plugins/lib_gtk_common/dlg_topwin.h hid_cfg.h hid_dad.h \ compat_misc.h hid_attrib.h hid_dad_spin.h \ ../src_plugins/lib_gtk_common/bu_menu.h hid_cfg_input.h \ @@ -2014,11 +2014,11 @@ ../src_plugins/lib_gtk_common/glue.h \ ../src_plugins/lib_gtk_common/compat.h \ ../src_plugins/lib_gtk_common/bu_command.h pcb_bool.h \ - ../src_plugins/lib_gtk_hid/render.h ../src_plugins/lib_gtk_hid/gui.h \ + ../src_plugins/lib_gtk_common/render.h ../src_plugins/lib_gtk_common/gui.h \ ../src_plugins/lib_gtk_common/ui_zoompan.h \ ../src_plugins/lib_gtk_common/in_mouse.h \ ../src_plugins/lib_gtk_common/in_mouse.h \ - ../src_plugins/lib_gtk_common/glue.h ../src_plugins/lib_gtk_hid/render.h + ../src_plugins/lib_gtk_common/glue.h ../src_plugins/lib_gtk_common/render.h ../src_plugins/hid_gtk2_gl/gtkhid-gl.o: \ ../src_plugins/hid_gtk2_gl/gtkhid-gl.c ../config.h crosshair.h \ vtonpoint.h global_typedefs.h pcb_bool.h unit.h \ @@ -2038,7 +2038,7 @@ funchash_core_list.h ../src_plugins/lib_hid_common/clip.h \ global_typedefs.h ../src_plugins/lib_gtk_common/hid_gtk_conf.h conf.h \ ../src_plugins/lib_gtk_common/lib_gtk_config.h hid.h event.h hidlib.h \ - conf_hid.h ../src_plugins/lib_gtk_hid/gui.h \ + conf_hid.h ../src_plugins/lib_gtk_common/gui.h \ ../src_plugins/lib_gtk_common/ui_zoompan.h pcb_bool.h \ ../src_plugins/lib_gtk_common/in_mouse.h hid_cfg_input.h \ ../src_3rd/genht/htpp.h hid_cfg.h ../src_plugins/lib_gtk_common/glue.h \ @@ -2048,10 +2048,10 @@ ../src_plugins/lib_gtk_common/bu_menu.h \ ../src_plugins/lib_gtk_common/bu_command.h \ ../src_plugins/lib_gtk_common/in_mouse.h \ - ../src_plugins/lib_gtk_common/glue.h ../src_plugins/lib_gtk_hid/render.h \ - ../src_plugins/lib_gtk_hid/gui.h ../src_plugins/lib_gtk_hid/coord_conv.h \ - compat_misc.h ../src_plugins/lib_gtk_hid/render.h \ - ../src_plugins/lib_gtk_hid/preview_helper.h \ + ../src_plugins/lib_gtk_common/glue.h ../src_plugins/lib_gtk_common/render.h \ + ../src_plugins/lib_gtk_common/gui.h ../src_plugins/lib_gtk_common/coord_conv.h \ + compat_misc.h ../src_plugins/lib_gtk_common/render.h \ + ../src_plugins/lib_gtk_common/preview_helper.h \ ../src_plugins/lib_hid_gl/opengl.h ../src_plugins/lib_hid_gl/draw_gl.h \ ../src_plugins/lib_hid_gl/opengl.h ../src_plugins/lib_hid_gl/hidgl.h \ ../src_plugins/lib_hid_gl/stencil_gl.h @@ -2073,11 +2073,11 @@ math_helper.h misc_util.h ../src_3rd/genvector/gds_char.h hidlib_conf.h \ conf.h pcb-printf.h ../src_3rd/liblihata/lihata.h list_conf.h \ ../src_plugins/lib_hid_gl/draw_gl.h ../src_plugins/lib_hid_gl/opengl.h \ - ../src_plugins/lib_gtk_hid/glue_common.h hid.h \ - ../src_plugins/lib_gtk_hid/glue_hid.h \ - ../src_plugins/lib_gtk_hid/glue_conf.h conf.h \ - ../src_plugins/lib_gtk_hid/glue_win32.h \ - ../src_plugins/lib_gtk_hid/common.h event.h hidlib.h \ + ../src_plugins/lib_gtk_common/glue_common.h hid.h \ + ../src_plugins/lib_gtk_common/glue_hid.h \ + ../src_plugins/lib_gtk_common/glue_conf.h conf.h \ + ../src_plugins/lib_gtk_common/glue_win32.h \ + ../src_plugins/lib_gtk_common/common.h event.h hidlib.h \ ../src_plugins/lib_gtk_common/dlg_topwin.h hid_cfg.h hid_dad.h \ compat_misc.h hid_attrib.h hid_dad_spin.h \ ../src_plugins/lib_gtk_common/bu_menu.h hid_cfg_input.h \ @@ -2085,11 +2085,11 @@ ../src_plugins/lib_gtk_common/glue.h \ ../src_plugins/lib_gtk_common/compat.h \ ../src_plugins/lib_gtk_common/bu_command.h pcb_bool.h \ - ../src_plugins/lib_gtk_hid/render.h ../src_plugins/lib_gtk_hid/gui.h \ + ../src_plugins/lib_gtk_common/render.h ../src_plugins/lib_gtk_common/gui.h \ ../src_plugins/lib_gtk_common/ui_zoompan.h \ ../src_plugins/lib_gtk_common/in_mouse.h \ ../src_plugins/lib_gtk_common/in_mouse.h \ - ../src_plugins/lib_gtk_common/glue.h ../src_plugins/lib_gtk_hid/render.h + ../src_plugins/lib_gtk_common/glue.h ../src_plugins/lib_gtk_common/render.h ../src_plugins/hid_gtk3_cairo/gtkhid-cairo.o: \ ../src_plugins/hid_gtk3_cairo/gtkhid-cairo.c ../config.h hidlib_conf.h \ conf.h global_typedefs.h pcb_bool.h unit.h pcb-printf.h \ @@ -2106,7 +2106,7 @@ obj_text.h font.h ../src_3rd/genht/htip.h box.h math_helper.h \ misc_util.h route.h draw.h grid.h board.h vtroutestyle.h layer_grp.h \ rats_patch.h hidlib.h hid_attrib.h hid_color.h funchash_core.h \ - funchash.h funchash_core_list.h ../src_plugins/lib_gtk_hid/gui.h hid.h \ + funchash.h funchash_core_list.h ../src_plugins/lib_gtk_common/gui.h hid.h \ ../src_plugins/lib_gtk_common/ui_zoompan.h pcb_bool.h \ ../src_plugins/lib_gtk_common/in_mouse.h hid_cfg_input.h \ ../src_3rd/genht/htpp.h hid_cfg.h ../src_plugins/lib_gtk_common/glue.h \ @@ -2117,9 +2117,9 @@ ../src_plugins/lib_gtk_common/bu_command.h \ ../src_plugins/lib_gtk_common/in_mouse.h \ ../src_plugins/lib_gtk_common/glue.h event.h \ - ../src_plugins/lib_gtk_hid/render.h ../src_plugins/lib_gtk_hid/gui.h \ - ../src_plugins/lib_gtk_hid/coord_conv.h compat_misc.h \ - ../src_plugins/lib_gtk_hid/preview_helper.h \ + ../src_plugins/lib_gtk_common/render.h ../src_plugins/lib_gtk_common/gui.h \ + ../src_plugins/lib_gtk_common/coord_conv.h compat_misc.h \ + ../src_plugins/lib_gtk_common/preview_helper.h \ ../src_plugins/lib_gtk_common/hid_gtk_conf.h \ ../src_plugins/lib_gtk_common/lib_gtk_config.h \ ../src_plugins/lib_hid_common/clip.h global_typedefs.h @@ -2139,12 +2139,12 @@ obj_line_list.h obj_line.h obj_poly_list.h obj_poly.h polyarea.h \ obj_text_list.h obj_text.h font.h ../src_3rd/genht/htip.h box.h \ math_helper.h misc_util.h ../src_3rd/genvector/gds_char.h \ - ../src_plugins/lib_gtk_hid/glue_common.h hid.h \ - ../src_plugins/lib_gtk_hid/glue_hid.h \ - ../src_plugins/lib_gtk_hid/glue_conf.h conf.h pcb-printf.h \ + ../src_plugins/lib_gtk_common/glue_common.h hid.h \ + ../src_plugins/lib_gtk_common/glue_hid.h \ + ../src_plugins/lib_gtk_common/glue_conf.h conf.h pcb-printf.h \ ../src_3rd/liblihata/lihata.h list_conf.h conf.h \ - ../src_plugins/lib_gtk_hid/glue_win32.h \ - ../src_plugins/lib_gtk_hid/common.h event.h hidlib.h \ + ../src_plugins/lib_gtk_common/glue_win32.h \ + ../src_plugins/lib_gtk_common/common.h event.h hidlib.h \ ../src_plugins/lib_gtk_common/dlg_topwin.h hid_cfg.h hid_dad.h \ compat_misc.h hid_attrib.h hid_dad_spin.h \ ../src_plugins/lib_gtk_common/bu_menu.h hid_cfg_input.h \ @@ -2152,11 +2152,11 @@ ../src_plugins/lib_gtk_common/glue.h \ ../src_plugins/lib_gtk_common/compat.h \ ../src_plugins/lib_gtk_common/bu_command.h pcb_bool.h \ - ../src_plugins/lib_gtk_hid/render.h ../src_plugins/lib_gtk_hid/gui.h \ + ../src_plugins/lib_gtk_common/render.h ../src_plugins/lib_gtk_common/gui.h \ ../src_plugins/lib_gtk_common/ui_zoompan.h \ ../src_plugins/lib_gtk_common/in_mouse.h \ ../src_plugins/lib_gtk_common/in_mouse.h \ - ../src_plugins/lib_gtk_common/glue.h ../src_plugins/lib_gtk_hid/render.h + ../src_plugins/lib_gtk_common/glue.h ../src_plugins/lib_gtk_common/render.h ../src_plugins/hid_lesstif/FillBox.o: \ ../src_plugins/hid_lesstif/FillBox.c ../config.h \ ../src_plugins/hid_lesstif/FillBoxP.h \ @@ -4198,7 +4198,7 @@ ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h draw.h \ compat_misc.h -../src_plugins/lib_gtk_hid/common.o: ../src_plugins/lib_gtk_hid/common.c \ +../src_plugins/lib_gtk_common/common.o: ../src_plugins/lib_gtk_common/common.c \ ../config.h crosshair.h vtonpoint.h global_typedefs.h pcb_bool.h unit.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h ../src_3rd/liblihata/dom.h \ @@ -4210,7 +4210,7 @@ ../src_3rd/genlist/gentdlist_undef.h obj_line_list.h obj_line.h \ obj_poly_list.h obj_poly.h polyarea.h obj_text_list.h obj_text.h font.h \ ../src_3rd/genht/htip.h box.h math_helper.h misc_util.h \ - ../src_3rd/genvector/gds_char.h route.h ../src_plugins/lib_gtk_hid/gui.h \ + ../src_3rd/genvector/gds_char.h route.h ../src_plugins/lib_gtk_common/gui.h \ hid.h ../src_plugins/lib_gtk_common/ui_zoompan.h pcb_bool.h \ ../src_plugins/lib_gtk_common/in_mouse.h hid_cfg_input.h \ ../src_3rd/genht/htpp.h hid_cfg.h ../src_plugins/lib_gtk_common/glue.h \ @@ -4223,13 +4223,13 @@ ../src_plugins/lib_gtk_common/bu_command.h \ ../src_plugins/lib_gtk_common/in_mouse.h \ ../src_plugins/lib_gtk_common/glue.h event.h hidlib.h \ - ../src_plugins/lib_gtk_hid/render.h ../src_plugins/lib_gtk_hid/common.h \ + ../src_plugins/lib_gtk_common/render.h ../src_plugins/lib_gtk_common/common.h \ ../src_plugins/lib_gtk_common/in_keyboard.h \ ../src_plugins/lib_gtk_common/ui_zoompan.h \ ../src_plugins/lib_gtk_common/hid_gtk_conf.h -../src_plugins/lib_gtk_hid/glue_common.o: \ - ../src_plugins/lib_gtk_hid/glue_common.c ../config.h \ - ../src_plugins/lib_gtk_hid/glue_common.h hid.h \ +../src_plugins/lib_gtk_common/glue_common.o: \ + ../src_plugins/lib_gtk_common/glue_common.c ../config.h \ + ../src_plugins/lib_gtk_common/glue_common.h hid.h \ ../src_3rd/liblihata/dom.h ../src_3rd/liblihata/lihata.h \ ../src_3rd/liblihata/parser.h ../src_3rd/genht/htsp.h \ ../src_3rd/genht/ht.h error.h global_typedefs.h pcb_bool.h unit.h \ @@ -4241,7 +4241,7 @@ ../src_3rd/genlist/gentdlist_undef.h obj_line_list.h obj_line.h \ obj_poly_list.h obj_poly.h polyarea.h obj_text_list.h obj_text.h font.h \ ../src_3rd/genht/htip.h box.h math_helper.h misc_util.h \ - ../src_3rd/genvector/gds_char.h ../src_plugins/lib_gtk_hid/gui.h \ + ../src_3rd/genvector/gds_char.h ../src_plugins/lib_gtk_common/gui.h \ ../src_plugins/lib_gtk_common/ui_zoompan.h pcb_bool.h \ ../src_plugins/lib_gtk_common/in_mouse.h hid_cfg_input.h \ ../src_3rd/genht/htpp.h hid_cfg.h hid.h \ @@ -4254,11 +4254,11 @@ ../src_plugins/lib_gtk_common/bu_command.h \ ../src_plugins/lib_gtk_common/in_mouse.h \ ../src_plugins/lib_gtk_common/glue.h event.h hidlib.h \ - ../src_plugins/lib_gtk_hid/render.h ../src_plugins/lib_gtk_hid/common.h \ + ../src_plugins/lib_gtk_common/render.h ../src_plugins/lib_gtk_common/common.h \ hidlib.h ../src_plugins/lib_gtk_common/hid_gtk_conf.h -../src_plugins/lib_gtk_hid/glue_conf.o: \ - ../src_plugins/lib_gtk_hid/glue_conf.c ../config.h \ - ../src_plugins/lib_gtk_hid/glue_conf.h conf.h global_typedefs.h \ +../src_plugins/lib_gtk_common/glue_conf.o: \ + ../src_plugins/lib_gtk_common/glue_conf.c ../config.h \ + ../src_plugins/lib_gtk_common/glue_conf.h conf.h global_typedefs.h \ pcb_bool.h unit.h pcb-printf.h ../src_3rd/genvector/gds_char.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h ../src_3rd/liblihata/lihata.h \ @@ -4266,7 +4266,7 @@ ../src_3rd/liblihata/parser.h ../src_3rd/genht/htsp.h \ ../src_3rd/genht/ht.h ../src_3rd/genvector/vtp0.h list_conf.h conf.h \ ../src_3rd/genlist/gentdlist_undef.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h ../src_plugins/lib_gtk_hid/gui.h hid.h \ + ../src_3rd/genlist/gendlist.h ../src_plugins/lib_gtk_common/gui.h hid.h \ error.h attrib.h layer.h globalconst.h color.h obj_common.h flag.h \ data_parent.h obj_arc_list.h obj_arc.h ../src_3rd/genlist/gendlist.h \ obj_line_list.h obj_line.h obj_poly_list.h obj_poly.h polyarea.h \ @@ -4282,10 +4282,10 @@ ../src_plugins/lib_gtk_common/bu_command.h \ ../src_plugins/lib_gtk_common/in_mouse.h \ ../src_plugins/lib_gtk_common/glue.h event.h hidlib.h \ - ../src_plugins/lib_gtk_hid/render.h -../src_plugins/lib_gtk_hid/glue_hid.o: \ - ../src_plugins/lib_gtk_hid/glue_hid.c ../config.h \ - ../src_plugins/lib_gtk_hid/glue_hid.h hid.h ../src_3rd/liblihata/dom.h \ + ../src_plugins/lib_gtk_common/render.h +../src_plugins/lib_gtk_common/glue_hid.o: \ + ../src_plugins/lib_gtk_common/glue_hid.c ../config.h \ + ../src_plugins/lib_gtk_common/glue_hid.h hid.h ../src_3rd/liblihata/dom.h \ ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h error.h global_typedefs.h \ pcb_bool.h unit.h attrib.h layer.h globalconst.h color.h \ @@ -4296,7 +4296,7 @@ ../src_3rd/genlist/gentdlist_undef.h obj_line_list.h obj_line.h \ obj_poly_list.h obj_poly.h polyarea.h obj_text_list.h obj_text.h font.h \ ../src_3rd/genht/htip.h box.h math_helper.h misc_util.h \ - ../src_3rd/genvector/gds_char.h ../src_plugins/lib_gtk_hid/gui.h \ + ../src_3rd/genvector/gds_char.h ../src_plugins/lib_gtk_common/gui.h \ ../src_plugins/lib_gtk_common/ui_zoompan.h pcb_bool.h \ ../src_plugins/lib_gtk_common/in_mouse.h hid_cfg_input.h \ ../src_3rd/genht/htpp.h hid_cfg.h hid.h \ @@ -4309,9 +4309,9 @@ ../src_plugins/lib_gtk_common/bu_command.h \ ../src_plugins/lib_gtk_common/in_mouse.h \ ../src_plugins/lib_gtk_common/glue.h event.h hidlib.h \ - ../src_plugins/lib_gtk_hid/render.h actions.h \ - ../src_3rd/libfungw/fungw.h ../src_plugins/lib_gtk_hid/common.h \ - hid_nogui.h hid_attrib.h ../src_plugins/lib_gtk_hid/coord_conv.h \ + ../src_plugins/lib_gtk_common/render.h actions.h \ + ../src_3rd/libfungw/fungw.h ../src_plugins/lib_gtk_common/common.h \ + hid_nogui.h hid_attrib.h ../src_plugins/lib_gtk_common/coord_conv.h \ compat_misc.h hidlib_conf.h ../src_plugins/lib_gtk_common/in_keyboard.h \ ../src_plugins/lib_gtk_common/ui_zoompan.h \ ../src_plugins/lib_gtk_common/bu_dwg_tooltip.h \ @@ -4325,16 +4325,16 @@ ../src_plugins/lib_gtk_common/hid_gtk_conf.h \ ../src_plugins/lib_gtk_common/lib_gtk_config.h \ ../src_plugins/lib_hid_common/menu_helper.h -../src_plugins/lib_gtk_hid/glue_win32.o: \ - ../src_plugins/lib_gtk_hid/glue_win32.c ../config.h \ - ../src_plugins/lib_gtk_hid/glue_win32.h -../src_plugins/lib_gtk_hid/lib_gtk_hid.o: \ - ../src_plugins/lib_gtk_hid/lib_gtk_hid.c ../config.h plugins.h \ +../src_plugins/lib_gtk_common/glue_win32.o: \ + ../src_plugins/lib_gtk_common/glue_win32.c ../config.h \ + ../src_plugins/lib_gtk_common/glue_win32.h +../src_plugins/lib_gtk_common/lib_gtk_common.o: \ + ../src_plugins/lib_gtk_common/lib_gtk_common.c ../config.h plugins.h \ ../src_3rd/puplug/puplug.h ../src_3rd/puplug/libs.h \ ../src_3rd/puplug/os_dep.h ../src_3rd/puplug/config.h \ ../src_3rd/puplug/libs.h ../src_3rd/puplug/error.h -../src_plugins/lib_gtk_hid/render.o: ../src_plugins/lib_gtk_hid/render.c \ - ../config.h ../src_plugins/lib_gtk_hid/gui.h hid.h \ +../src_plugins/lib_gtk_common/render.o: ../src_plugins/lib_gtk_common/render.c \ + ../config.h ../src_plugins/lib_gtk_common/gui.h hid.h \ ../src_3rd/liblihata/dom.h ../src_3rd/liblihata/lihata.h \ ../src_3rd/liblihata/parser.h ../src_3rd/genht/htsp.h \ ../src_3rd/genht/ht.h error.h global_typedefs.h pcb_bool.h unit.h \ @@ -4359,7 +4359,7 @@ ../src_plugins/lib_gtk_common/bu_command.h \ ../src_plugins/lib_gtk_common/in_mouse.h \ ../src_plugins/lib_gtk_common/glue.h event.h hidlib.h \ - ../src_plugins/lib_gtk_hid/render.h \ + ../src_plugins/lib_gtk_common/render.h \ ../src_plugins/lib_gtk_common/wt_preview.h \ ../src_plugins/lib_gtk_common/ui_zoompan.h ../src_plugins/lib_hid_common/act_dad.o: \ Index: trunk/src_plugins/hid_gtk2_gdk/gtkhid-gdk.c =================================================================== --- trunk/src_plugins/hid_gtk2_gdk/gtkhid-gdk.c (revision 26695) +++ trunk/src_plugins/hid_gtk2_gdk/gtkhid-gdk.c (revision 26696) @@ -10,9 +10,9 @@ #include "hid_color.h" #include "funchash_core.h" -#include "../src_plugins/lib_gtk_hid/gui.h" -#include "../src_plugins/lib_gtk_hid/coord_conv.h" -#include "../src_plugins/lib_gtk_hid/preview_helper.h" +#include "../src_plugins/lib_gtk_common/gui.h" +#include "../src_plugins/lib_gtk_common/coord_conv.h" +#include "../src_plugins/lib_gtk_common/preview_helper.h" #include "../src_plugins/lib_gtk_common/hid_gtk_conf.h" #include "../src_plugins/lib_gtk_common/lib_gtk_config.h" Index: trunk/src_plugins/hid_gtk2_gdk/gtkhid-main.c =================================================================== --- trunk/src_plugins/hid_gtk2_gdk/gtkhid-main.c (revision 26695) +++ trunk/src_plugins/hid_gtk2_gdk/gtkhid-main.c (revision 26696) @@ -5,12 +5,12 @@ #include "plugins.h" #include "hid_init.h" -#include "../src_plugins/lib_gtk_hid/glue_common.h" -#include "../src_plugins/lib_gtk_hid/glue_hid.h" -#include "../src_plugins/lib_gtk_hid/glue_conf.h" -#include "../src_plugins/lib_gtk_hid/glue_win32.h" -#include "../src_plugins/lib_gtk_hid/common.h" -#include "../src_plugins/lib_gtk_hid/render.h" +#include "../src_plugins/lib_gtk_common/glue_common.h" +#include "../src_plugins/lib_gtk_common/glue_hid.h" +#include "../src_plugins/lib_gtk_common/glue_conf.h" +#include "../src_plugins/lib_gtk_common/glue_win32.h" +#include "../src_plugins/lib_gtk_common/common.h" +#include "../src_plugins/lib_gtk_common/render.h" const char *ghid_cookie = "gtk2 hid, gdk"; const char *ghid_menu_cookie = "gtk2 hid menu, gdk"; Index: trunk/src_plugins/hid_gtk2_gdk/hid_gtk2_gdk.pup =================================================================== --- trunk/src_plugins/hid_gtk2_gdk/hid_gtk2_gdk.pup (revision 26695) +++ trunk/src_plugins/hid_gtk2_gdk/hid_gtk2_gdk.pup (revision 26696) @@ -6,5 +6,4 @@ $hidlib 1 default buildin dep lib_gtk_common -dep lib_gtk_hid autoload 1 Index: trunk/src_plugins/hid_gtk2_gl/gtkhid-gl.c =================================================================== --- trunk/src_plugins/hid_gtk2_gl/gtkhid-gl.c (revision 26695) +++ trunk/src_plugins/hid_gtk2_gl/gtkhid-gl.c (revision 26696) @@ -13,10 +13,10 @@ #include "../src_plugins/lib_gtk_common/hid_gtk_conf.h" #include "../src_plugins/lib_gtk_common/lib_gtk_config.h" -#include "../src_plugins/lib_gtk_hid/gui.h" -#include "../src_plugins/lib_gtk_hid/coord_conv.h" -#include "../src_plugins/lib_gtk_hid/render.h" -#include "../src_plugins/lib_gtk_hid/preview_helper.h" +#include "../src_plugins/lib_gtk_common/gui.h" +#include "../src_plugins/lib_gtk_common/coord_conv.h" +#include "../src_plugins/lib_gtk_common/render.h" +#include "../src_plugins/lib_gtk_common/preview_helper.h" #include "../src_plugins/lib_hid_gl/opengl.h" #include "../src_plugins/lib_hid_gl/draw_gl.h" Index: trunk/src_plugins/hid_gtk2_gl/gtkhid-main.c =================================================================== --- trunk/src_plugins/hid_gtk2_gl/gtkhid-main.c (revision 26695) +++ trunk/src_plugins/hid_gtk2_gl/gtkhid-main.c (revision 26696) @@ -8,12 +8,12 @@ #include "../src_plugins/lib_hid_gl/draw_gl.h" -#include "../src_plugins/lib_gtk_hid/glue_common.h" -#include "../src_plugins/lib_gtk_hid/glue_hid.h" -#include "../src_plugins/lib_gtk_hid/glue_conf.h" -#include "../src_plugins/lib_gtk_hid/glue_win32.h" -#include "../src_plugins/lib_gtk_hid/common.h" -#include "../src_plugins/lib_gtk_hid/render.h" +#include "../src_plugins/lib_gtk_common/glue_common.h" +#include "../src_plugins/lib_gtk_common/glue_hid.h" +#include "../src_plugins/lib_gtk_common/glue_conf.h" +#include "../src_plugins/lib_gtk_common/glue_win32.h" +#include "../src_plugins/lib_gtk_common/common.h" +#include "../src_plugins/lib_gtk_common/render.h" const char *ghid_gl_cookie = "gtk2 hid, gl"; const char *ghid_gl_menu_cookie = "gtk2 hid menu, gl"; Index: trunk/src_plugins/hid_gtk2_gl/hid_gtk2_gl.pup =================================================================== --- trunk/src_plugins/hid_gtk2_gl/hid_gtk2_gl.pup (revision 26695) +++ trunk/src_plugins/hid_gtk2_gl/hid_gtk2_gl.pup (revision 26696) @@ -6,6 +6,5 @@ $hidlib 1 default buildin dep lib_gtk_common -dep lib_gtk_hid dep lib_hid_gl autoload 1 Index: trunk/src_plugins/lib_gtk_common/Plug.tmpasm =================================================================== --- trunk/src_plugins/lib_gtk_common/Plug.tmpasm (revision 26695) +++ trunk/src_plugins/lib_gtk_common/Plug.tmpasm (revision 26696) @@ -22,6 +22,13 @@ $(PLUGDIR)/lib_gtk_common/util_timer.o $(PLUGDIR)/lib_gtk_common/util_watch.o $(PLUGDIR)/lib_gtk_common/wt_preview.o + + $(PLUGDIR)/lib_gtk_common/glue_common.o + $(PLUGDIR)/lib_gtk_common/glue_conf.o + $(PLUGDIR)/lib_gtk_common/glue_hid.o + $(PLUGDIR)/lib_gtk_common/glue_win32.o + $(PLUGDIR)/lib_gtk_common/common.o + $(PLUGDIR)/lib_gtk_common/render.o @] switch /local/pcb/hid_gtk3_cairo/controls Index: trunk/src_plugins/lib_gtk_common/common.c =================================================================== --- trunk/src_plugins/lib_gtk_common/common.c (nonexistent) +++ trunk/src_plugins/lib_gtk_common/common.c (revision 26696) @@ -0,0 +1,146 @@ +#include "config.h" + +#include "crosshair.h" + +#include "gui.h" +#include "common.h" + +#include "../src_plugins/lib_gtk_common/dlg_topwin.h" +#include "../src_plugins/lib_gtk_common/in_keyboard.h" +#include "../src_plugins/lib_gtk_common/hid_gtk_conf.h" + +GhidGui _ghidgui, *ghidgui = &_ghidgui; +GHidPort ghid_port, *gport; + +/* Do scrollbar scaling based on current port drawing area size and + | overall PCB board size. + */ +void pcb_gtk_tw_ranges_scale(pcb_gtk_topwin_t *tw) +{ + /* Update the scrollbars with PCB units. So Scale the current + | drawing area size in pixels to PCB units and that will be + | the page size for the Gtk adjustment. + */ + pcb_gtk_zoom_post(&gport->view); + + pcb_gtk_zoom_adjustment(gtk_range_get_adjustment(GTK_RANGE(tw->h_range)), gport->view.width, tw->com->hidlib->size_x); + pcb_gtk_zoom_adjustment(gtk_range_get_adjustment(GTK_RANGE(tw->v_range)), gport->view.height, tw->com->hidlib->size_y); +} + +void ghid_note_event_location(GdkEventButton *ev) +{ + gint event_x, event_y; + + if (!ev) { + gdkc_window_get_pointer(ghid_port.drawing_area, &event_x, &event_y, NULL); + } + else { + event_x = ev->x; + event_y = ev->y; + } + + pcb_gtk_coords_event2pcb(&gport->view, event_x, event_y, &gport->view.pcb_x, &gport->view.pcb_y); + + pcb_hidlib_crosshair_move_to(gport->view.pcb_x, gport->view.pcb_y, 1); +} + +static void kbd_input_signals_connect(int idx, void *obj) +{ + ghidgui->key_press_handler[idx] = g_signal_connect(G_OBJECT(obj), "key_press_event", G_CALLBACK(ghid_port_key_press_cb), &ghid_port.view); + ghidgui->key_release_handler[idx] = g_signal_connect(G_OBJECT(obj), "key_release_event", G_CALLBACK(ghid_port_key_release_cb), &ghidgui->topwin); +} + +static void kbd_input_signals_disconnect(int idx, void *obj) +{ + if (ghidgui->key_press_handler[idx] != 0) { + g_signal_handler_disconnect(G_OBJECT(obj), ghidgui->key_press_handler[idx]); + ghidgui->key_press_handler[idx] = 0; + } + if (ghidgui->key_release_handler[idx] != 0) { + g_signal_handler_disconnect(G_OBJECT(obj), ghidgui->key_release_handler[idx]); + ghidgui->key_release_handler[idx] = 0; + } +} + + /* Connect and disconnect just the signals a g_main_loop() will need. + | Cursor and motion events still need to be handled by the top level + | loop, so don't connect/reconnect these. + | A g_main_loop will be running when PCB wants the user to select a + | location or if command entry is needed in the status line hbox. + | During these times normal button/key presses are intercepted, either + | by new signal handlers or the command_combo_box entry. + */ + +void ghid_interface_input_signals_connect(void) +{ + ghidgui->button_press_handler = g_signal_connect(G_OBJECT(gport->drawing_area), "button_press_event", G_CALLBACK(ghid_port_button_press_cb), &gport->mouse); + ghidgui->button_release_handler = g_signal_connect(G_OBJECT(gport->drawing_area), "button_release_event", G_CALLBACK(ghid_port_button_release_cb), &gport->mouse); + kbd_input_signals_connect(0, gport->drawing_area); + kbd_input_signals_connect(3, ghidgui->topwin.left_toolbar); +} + +void ghid_interface_input_signals_disconnect(void) +{ + kbd_input_signals_disconnect(0, gport->drawing_area); + kbd_input_signals_disconnect(3, ghidgui->topwin.left_toolbar); + + if (ghidgui->button_press_handler != 0) + g_signal_handler_disconnect(G_OBJECT(gport->drawing_area), ghidgui->button_press_handler); + + if (ghidgui->button_release_handler != 0) + g_signal_handler_disconnect(gport->drawing_area, ghidgui->button_release_handler); + + ghidgui->button_press_handler = ghidgui->button_release_handler = 0; +} + +int ghid_shift_is_pressed() +{ + GdkModifierType mask; + GHidPort *out = &ghid_port; + + if (!ghidgui->gui_is_up) + return 0; + + gdkc_window_get_pointer(out->drawing_area, NULL, NULL, &mask); + +#ifdef PCB_WORKAROUND_GTK_SHIFT + /* On some systems the above query fails and we need to return the last known state instead */ + return pcb_gtk_glob_mask & GDK_SHIFT_MASK; +#else + return (mask & GDK_SHIFT_MASK) ? TRUE : FALSE; +#endif +} + +int ghid_control_is_pressed() +{ + GdkModifierType mask; + GHidPort *out = &ghid_port; + + if (!ghidgui->gui_is_up) + return 0; + + gdkc_window_get_pointer(out->drawing_area, NULL, NULL, &mask); + +#ifdef PCB_WORKAROUND_GTK_CTRL + /* On some systems the above query fails and we need to return the last known state instead */ + return pcb_gtk_glob_mask & GDK_CONTROL_MASK; +#else + return (mask & GDK_CONTROL_MASK) ? TRUE : FALSE; +#endif +} + +int ghid_mod1_is_pressed() +{ + GdkModifierType mask; + GHidPort *out = &ghid_port; + + if (!ghidgui->gui_is_up) + return 0; + + gdkc_window_get_pointer(out->drawing_area, NULL, NULL, &mask); +#ifdef __APPLE__ + return (mask & (1 << 13)) ? TRUE : FALSE; /* The option key is not MOD1, although it should be... */ +#else + return (mask & GDK_MOD1_MASK) ? TRUE : FALSE; +#endif +} Index: trunk/src_plugins/lib_gtk_common/common.h =================================================================== --- trunk/src_plugins/lib_gtk_common/common.h (nonexistent) +++ trunk/src_plugins/lib_gtk_common/common.h (revision 26696) @@ -0,0 +1,14 @@ +#include "event.h" + +#include "../src_plugins/lib_gtk_common/dlg_topwin.h" + +/* code used by multiple different glue layers */ +void pcb_gtk_tw_ranges_scale(pcb_gtk_topwin_t *tw); +void ghid_note_event_location(GdkEventButton *ev); + +void ghid_interface_input_signals_connect(void); +void ghid_interface_input_signals_disconnect(void); + +int ghid_shift_is_pressed(); +int ghid_control_is_pressed(); +int ghid_mod1_is_pressed(); Index: trunk/src_plugins/lib_gtk_common/coord_conv.h =================================================================== --- trunk/src_plugins/lib_gtk_common/coord_conv.h (nonexistent) +++ trunk/src_plugins/lib_gtk_common/coord_conv.h (revision 26696) @@ -0,0 +1,91 @@ +/* Coordinate conversions */ +#include "compat_misc.h" +#include "hidlib_conf.h" + +/* Px converts view->pcb, Vx converts pcb->view */ +static inline int Vx(pcb_coord_t x) +{ + double rv; + if (pcbhl_conf.editor.view.flip_x) + rv = (gport->view.com->hidlib->size_x - x - gport->view.x0) / gport->view.coord_per_px + 0.5; + else + rv = (x - gport->view.x0) / gport->view.coord_per_px + 0.5; + return pcb_round(rv); +} + +static inline int Vy(pcb_coord_t y) +{ + double rv; + if (pcbhl_conf.editor.view.flip_y) + rv = (gport->view.com->hidlib->size_y - y - gport->view.y0) / gport->view.coord_per_px + 0.5; + else + rv = (y - gport->view.y0) / gport->view.coord_per_px + 0.5; + return pcb_round(rv); +} + +static inline int Vz(pcb_coord_t z) +{ + return pcb_round((double)z / gport->view.coord_per_px + 0.5); +} + +static inline double Vxd(pcb_coord_t x) +{ + double rv; + if (pcbhl_conf.editor.view.flip_x) + rv = (gport->view.com->hidlib->size_x - x - gport->view.x0) / gport->view.coord_per_px; + else + rv = (x - gport->view.x0) / gport->view.coord_per_px; + return rv; +} + +static inline double Vyd(pcb_coord_t y) +{ + double rv; + if (pcbhl_conf.editor.view.flip_y) + rv = (gport->view.com->hidlib->size_y - y - gport->view.y0) / gport->view.coord_per_px; + else + rv = (y - gport->view.y0) / gport->view.coord_per_px; + return rv; +} + +static inline double Vzd(pcb_coord_t z) +{ + return (double)z / gport->view.coord_per_px; +} + +static inline pcb_coord_t Px(int x) +{ + pcb_coord_t rv = x * gport->view.coord_per_px + gport->view.x0; + if (pcbhl_conf.editor.view.flip_x) + rv = gport->view.com->hidlib->size_x - (x * gport->view.coord_per_px + gport->view.x0); + return rv; +} + +static inline pcb_coord_t Py(int y) +{ + pcb_coord_t rv = y * gport->view.coord_per_px + gport->view.y0; + if (pcbhl_conf.editor.view.flip_y) + rv = gport->view.com->hidlib->size_y - (y * gport->view.coord_per_px + gport->view.y0); + return rv; +} + +static inline pcb_coord_t Pz(int z) +{ + return (z * gport->view.coord_per_px); +} + +/* Return non-zero if box would be rendered into a single dot */ +static inline int pcb_gtk_1dot(pcb_coord_t penwidth, pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2) +{ + double minw = gport->view.coord_per_px; + double dx = PCB_ABS(x1-x2) + penwidth, dy = PCB_ABS(y1-y2) + penwidth; + return ((dx < minw) && (dy < minw)); +} + +/* Return non-zero if dot coords are within canvas extents */ +static inline int pcb_gtk_dot_in_canvas(pcb_coord_t penwidth, double dx1, double dy1) +{ + penwidth/=2; + return ((dx1+penwidth >= 0) && (dx1-penwidth <= gport->view.canvas_width) && (dy1+penwidth >= 0) && (dy1-penwidth <= gport->view.canvas_height)); +} + Index: trunk/src_plugins/lib_gtk_common/glue_common.c =================================================================== --- trunk/src_plugins/lib_gtk_common/glue_common.c (nonexistent) +++ trunk/src_plugins/lib_gtk_common/glue_common.c (revision 26696) @@ -0,0 +1,143 @@ +#include "config.h" + +#include "glue_common.h" + +#include "gui.h" +#include "render.h" +#include "common.h" +#include "hidlib.h" +#include "../src_plugins/lib_gtk_common/dlg_topwin.h" +#include "../src_plugins/lib_gtk_common/hid_gtk_conf.h" + +static void ghid_interface_set_sensitive(gboolean sensitive); + + +/*** drawing widget - output ***/ + +static void ghid_port_ranges_scale(void) +{ + pcb_gtk_tw_ranges_scale(&ghidgui->topwin); +} + +static void ghid_port_ranges_changed(void) +{ + GtkAdjustment *h_adj, *v_adj; + + h_adj = gtk_range_get_adjustment(GTK_RANGE(ghidgui->topwin.h_range)); + v_adj = gtk_range_get_adjustment(GTK_RANGE(ghidgui->topwin.v_range)); + gport->view.x0 = gtk_adjustment_get_value(h_adj); + gport->view.y0 = gtk_adjustment_get_value(v_adj); + + ghid_invalidate_all(ghidgui->common.hidlib); +} + +static void ghid_pan_common(void) +{ + ghidgui->topwin.adjustment_changed_holdoff = TRUE; + gtk_range_set_value(GTK_RANGE(ghidgui->topwin.h_range), gport->view.x0); + gtk_range_set_value(GTK_RANGE(ghidgui->topwin.v_range), gport->view.y0); + ghidgui->topwin.adjustment_changed_holdoff = FALSE; + + ghid_port_ranges_changed(); +} + +int ghid_command_entry_is_active(void) +{ + return ghidgui->topwin.cmd.command_entry_status_line_active; +} + +static void command_post_entry(void) +{ +#if PCB_GTK_DISABLE_MOUSE_DURING_CMD_ENTRY + ghid_interface_input_signals_connect(); +#endif + ghid_interface_set_sensitive(TRUE); + ghid_install_accel_groups(GTK_WINDOW(gport->top_window), &ghidgui->topwin); + gtk_widget_grab_focus(gport->drawing_area); +} + +static void command_pre_entry(void) +{ + ghid_remove_accel_groups(GTK_WINDOW(gport->top_window), &ghidgui->topwin); +#if PCB_GTK_DISABLE_MOUSE_DURING_CMD_ENTRY + ghid_interface_input_signals_disconnect(); +#endif + ghid_interface_set_sensitive(FALSE); +} + +/*** input ***/ + +static void ghid_interface_set_sensitive(gboolean sensitive) +{ + pcb_gtk_tw_interface_set_sensitive(&ghidgui->topwin, sensitive); +} + +static void ghid_port_button_press_main(void) +{ + ghid_invalidate_all(ghidgui->common.hidlib); + if (!gport->view.panning) + g_idle_add(ghid_idle_cb, &ghidgui->topwin); +} + +static void ghid_port_button_release_main(void) +{ + pcb_hidlib_adjust_attached_objects(); + ghid_invalidate_all(ghidgui->common.hidlib); + + g_idle_add(ghid_idle_cb, &ghidgui->topwin); +} + +static void ghid_mode_cursor_main(void) +{ + ghid_mode_cursor(&gport->mouse); +} + +/*** misc ***/ +static void ghid_load_bg_image(void) +{ + GError *err = NULL; + + if (conf_hid_gtk.plugins.hid_gtk.bg_image) + ghidgui->bg_pixbuf = gdk_pixbuf_new_from_file(conf_hid_gtk.plugins.hid_gtk.bg_image, &err); + + if (err) { + g_error("%s", err->message); + g_error_free(err); + } +} + +static void ghid_main_destroy(void *port) +{ + ghidgui->common.shutdown_renderer(port); + gtk_main_quit(); +} + +/*** init ***/ + +void ghid_glue_common_init(void) +{ + /* Set up the glue struct to lib_gtk_common */ + ghidgui->common.gport = &ghid_port; + ghidgui->common.note_event_location = ghid_note_event_location; + ghidgui->common.shift_is_pressed = ghid_shift_is_pressed; + ghidgui->common.interface_input_signals_disconnect = ghid_interface_input_signals_disconnect; + ghidgui->common.interface_input_signals_connect = ghid_interface_input_signals_connect; + ghidgui->common.interface_set_sensitive = ghid_interface_set_sensitive; + ghidgui->common.port_button_press_main = ghid_port_button_press_main; + ghidgui->common.port_button_release_main = ghid_port_button_release_main; + ghidgui->common.mode_cursor_main = ghid_mode_cursor_main; + ghidgui->common.pan_common = ghid_pan_common; + ghidgui->common.port_ranges_scale = ghid_port_ranges_scale; + + ghidgui->common.command_entry_is_active = ghid_command_entry_is_active; + ghidgui->common.load_bg_image = ghid_load_bg_image; + ghidgui->common.main_destroy = ghid_main_destroy; + ghidgui->common.port_ranges_changed = ghid_port_ranges_changed; + + ghidgui->topwin.cmd.com = &ghidgui->common; + ghidgui->topwin.cmd.post_entry = command_post_entry; + ghidgui->topwin.cmd.pre_entry = command_pre_entry; + + ghid_port.view.com = &ghidgui->common; + ghid_port.mouse.com = &ghidgui->common; +} Index: trunk/src_plugins/lib_gtk_common/glue_common.h =================================================================== --- trunk/src_plugins/lib_gtk_common/glue_common.h (nonexistent) +++ trunk/src_plugins/lib_gtk_common/glue_common.h (revision 26696) @@ -0,0 +1,2 @@ +#include "hid.h" +void ghid_glue_common_init(void); Index: trunk/src_plugins/lib_gtk_common/glue_conf.c =================================================================== --- trunk/src_plugins/lib_gtk_common/glue_conf.c (nonexistent) +++ trunk/src_plugins/lib_gtk_common/glue_conf.c (revision 26696) @@ -0,0 +1,88 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * (this file is based on PCB, interactive printed circuit board design) + * Copyright (C) 1994,1995,1996,1997,1998,1999 Thomas Nau + * pcb-rnd Copyright (C) 2016, 2017 Tibor 'Igor2' Palinkas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + */ + +#include "config.h" +#include "glue_conf.h" +#include "conf.h" +#include "gui.h" + +static void ghid_confchg_fullscreen(conf_native_t *cfg, int arr_idx) +{ + if (ghidgui->hid_active) + ghid_fullscreen_apply(&ghidgui->topwin); +} + + +void ghid_confchg_checkbox(conf_native_t *cfg, int arr_idx) +{ + if (ghidgui->hid_active) + ghid_update_toggle_flags(&ghidgui->topwin, NULL); +} + +static void ghid_confchg_cli(conf_native_t *cfg, int arr_idx) +{ + ghid_command_update_prompt(&ghidgui->topwin.cmd); +} + +static void ghid_confchg_spec_color(conf_native_t *cfg, int arr_idx) +{ + if (!ghidgui->hid_active) + return; + + if (ghidgui->common.set_special_colors != NULL) + ghidgui->common.set_special_colors(cfg); +} + + + +static void init_conf_watch(conf_hid_callbacks_t *cbs, const char *path, void (*func)(conf_native_t *, int)) +{ + conf_native_t *n = conf_get_field(path); + if (n != NULL) { + memset(cbs, 0, sizeof(conf_hid_callbacks_t)); + cbs->val_change_post = func; + conf_hid_set_cb(n, ghidgui->conf_id, cbs); + } +} + +void ghid_conf_regs(const char *cookie) +{ + static conf_hid_callbacks_t cbs_fullscreen, cbs_cli[2], cbs_color[3]; + + ghidgui->conf_id = conf_hid_reg(cookie, NULL); + + init_conf_watch(&cbs_fullscreen, "editor/fullscreen", ghid_confchg_fullscreen); + + init_conf_watch(&cbs_cli[0], "rc/cli_prompt", ghid_confchg_cli); + init_conf_watch(&cbs_cli[1], "rc/cli_backend", ghid_confchg_cli); + + init_conf_watch(&cbs_color[0], "appearance/color/background", ghid_confchg_spec_color); + init_conf_watch(&cbs_color[1], "appearance/color/off_limit", ghid_confchg_spec_color); + init_conf_watch(&cbs_color[2], "appearance/color/grid", ghid_confchg_spec_color); +} Index: trunk/src_plugins/lib_gtk_common/glue_conf.h =================================================================== --- trunk/src_plugins/lib_gtk_common/glue_conf.h (nonexistent) +++ trunk/src_plugins/lib_gtk_common/glue_conf.h (revision 26696) @@ -0,0 +1,5 @@ +#include "conf.h" + +void ghid_confchg_checkbox(conf_native_t *cfg, int arr_idx); + +void ghid_conf_regs(const char *cookie); Index: trunk/src_plugins/lib_gtk_common/glue_hid.c =================================================================== --- trunk/src_plugins/lib_gtk_common/glue_hid.c (nonexistent) +++ trunk/src_plugins/lib_gtk_common/glue_hid.c (revision 26696) @@ -0,0 +1,642 @@ +#include "config.h" +#include "glue_hid.h" + +#include + +#include "gui.h" +#include "actions.h" +#include "glue_hid.h" +#include "render.h" +#include "common.h" +#include "hid_nogui.h" +#include "hid_attrib.h" +#include "coord_conv.h" + +#include "../src_plugins/lib_gtk_common/in_keyboard.h" +#include "../src_plugins/lib_gtk_common/bu_dwg_tooltip.h" +#include "../src_plugins/lib_gtk_common/ui_crosshair.h" +#include "../src_plugins/lib_gtk_common/dlg_fileselect.h" +#include "../src_plugins/lib_gtk_common/dlg_attribute.h" +#include "../src_plugins/lib_gtk_common/dlg_attributes.h" +#include "../src_plugins/lib_gtk_common/util_listener.h" +#include "../src_plugins/lib_gtk_common/util_timer.h" +#include "../src_plugins/lib_gtk_common/util_watch.h" +#include "../src_plugins/lib_gtk_common/hid_gtk_conf.h" +#include "../src_plugins/lib_gtk_common/lib_gtk_config.h" +#include "../src_plugins/lib_hid_common/menu_helper.h" + +extern pcb_hid_cfg_keys_t ghid_keymap; + +void gtkhid_begin(pcb_hidlib_t *hidlib) +{ + ghidgui->common.hidlib = hidlib; + ghidgui->hid_active = 1; +} + +void gtkhid_end(void) +{ + ghidgui->hid_active = 0; +} + +static inline void ghid_screen_update(void) { ghidgui->common.screen_update(); } + +static gint ghid_port_window_enter_cb(GtkWidget * widget, GdkEventCrossing * ev, void * out_) +{ + GHidPort *out = out_; + int force_update = 0; + + /* printf("enter: mode: %d detail: %d\n", ev->mode, ev->detail); */ + + /* See comment in ghid_port_window_leave_cb() */ + + if (ev->mode != GDK_CROSSING_NORMAL && ev->detail != GDK_NOTIFY_NONLINEAR) { + return FALSE; + } + + if (!ghidgui->topwin.cmd.command_entry_status_line_active) { + out->view.has_entered = TRUE; + force_update = 1; /* force a redraw for the crosshair */ + /* Make sure drawing area has keyboard focus when we are in it. + */ + gtk_widget_grab_focus(out->drawing_area); + } + + /* Following expression is true if a you open a menu from the menu bar, + * move the mouse to the viewport and click on it. This closes the menu + * and moves the pointer to the viewport without the pointer going over + * the edge of the viewport */ + if (force_update || (ev->mode == GDK_CROSSING_UNGRAB && ev->detail == GDK_NOTIFY_NONLINEAR)) { + ghid_screen_update(); + } + return FALSE; +} + +static gint ghid_port_window_leave_cb(GtkWidget * widget, GdkEventCrossing * ev, void * out_) +{ + GHidPort *out = out_; + + /* printf("leave mode: %d detail: %d\n", ev->mode, ev->detail); */ + + /* Window leave events can also be triggered because of focus grabs. Some + * X applications occasionally grab the focus and so trigger this function. + * At least GNOME's window manager is known to do this on every mouse click. + * + * See http://bugzilla.gnome.org/show_bug.cgi?id=102209 + */ + + if (ev->mode != GDK_CROSSING_NORMAL) { + return FALSE; + } + + out->view.has_entered = FALSE; + + ghid_screen_update(); + + return FALSE; +} + +static gboolean check_object_tooltips(GHidPort *out) +{ + return pcb_gtk_dwg_tooltip_check_object(out->drawing_area, out->view.crosshair_x, out->view.crosshair_y); +} + +static gint ghid_port_window_motion_cb(GtkWidget * widget, GdkEventMotion * ev, void * out_) +{ + GHidPort *out = out_; + gdouble dx, dy; + static gint x_prev = -1, y_prev = -1; + + gdk_event_request_motions(ev); + + if (out->view.panning) { + dx = gport->view.coord_per_px * (x_prev - ev->x); + dy = gport->view.coord_per_px * (y_prev - ev->y); + if (x_prev > 0) + pcb_gtk_pan_view_rel(&gport->view, dx, dy); + x_prev = ev->x; + y_prev = ev->y; + return FALSE; + } + x_prev = y_prev = -1; + ghid_note_event_location((GdkEventButton *) ev); + + pcb_gtk_dwg_tooltip_queue(out->drawing_area, (GSourceFunc)check_object_tooltips, out); + + return FALSE; +} + +static void ghdi_gui_inited(int main, int conf) +{ + static int im = 0, ic = 0, first = 1; + if (main) im = 1; + if (conf) ic = 1; + + if (im && ic && first) { + first = 0; + pcb_event(ghidgui->common.hidlib, PCB_EVENT_GUI_INIT, NULL); + pcb_gtk_zoom_view_win_side(&gport->view, 0, 0, ghidgui->common.hidlib->size_x, ghidgui->common.hidlib->size_y, 0); + } +} + +static gboolean ghid_port_drawing_area_configure_event_cb(GtkWidget * widget, GdkEventConfigure * ev, void * out) +{ + gport->view.canvas_width = ev->width; + gport->view.canvas_height = ev->height; + + ghid_drawing_area_configure_hook(out); + ghdi_gui_inited(0, 1); + + pcb_gtk_tw_ranges_scale(&ghidgui->topwin); + ghid_invalidate_all(ghidgui->common.hidlib); + return 0; +} + + +void gtkhid_do_export(pcb_hidlib_t *hidlib, pcb_hid_attr_val_t *options) +{ + gtkhid_begin(hidlib); + + pcb_hid_cfg_keys_init(&ghid_keymap); + ghid_keymap.translate_key = ghid_translate_key; + ghid_keymap.key_name = ghid_key_name; + ghid_keymap.auto_chr = 1; + ghid_keymap.auto_tr = hid_cfg_key_default_trans; + + ghid_create_pcb_widgets(&ghidgui->topwin, gport->top_window); + + /* assume pcb_gui is us */ + pcb_gui->hid_cfg = ghidgui->topwin.ghid_cfg; + + gport->mouse.drawing_area = ghidgui->topwin.drawing_area; + gport->drawing_area = ghidgui->topwin.drawing_area; + gport->mouse.top_window = ghidgui->common.top_window; + +TODO(": move this to render init") + /* Mouse and key events will need to be intercepted when PCB needs a + | location from the user. + */ + g_signal_connect(G_OBJECT(gport->drawing_area), "scroll_event", G_CALLBACK(ghid_port_window_mouse_scroll_cb), &gport->mouse); + g_signal_connect(G_OBJECT(gport->drawing_area), "motion_notify_event", G_CALLBACK(ghid_port_window_motion_cb), gport); + g_signal_connect(G_OBJECT(gport->drawing_area), "configure_event", G_CALLBACK(ghid_port_drawing_area_configure_event_cb), gport); + g_signal_connect(G_OBJECT(gport->drawing_area), "enter_notify_event", G_CALLBACK(ghid_port_window_enter_cb), gport); + g_signal_connect(G_OBJECT(gport->drawing_area), "leave_notify_event", G_CALLBACK(ghid_port_window_leave_cb), gport); + + ghid_interface_input_signals_connect(); + + if (conf_hid_gtk.plugins.hid_gtk.listen) + pcb_gtk_create_listener(); + + ghidgui->gui_is_up = 1; + + ghdi_gui_inited(1, 0); + + /* Make sure drawing area has keyboard focus so that keys are handled + while the mouse cursor is over the top window or children widgets, + before first entering the drawing area */ + gtk_widget_grab_focus(gport->drawing_area); + + gtk_main(); + pcb_hid_cfg_keys_uninit(&ghid_keymap); + gtkhid_end(); + + ghidgui->gui_is_up = 0; + pcb_gui->hid_cfg = NULL; +} + +static void ghid_do_exit(pcb_hid_t * hid) +{ + /* Need to force-close the command entry first because it has its own main + loop that'd block the exit until the user closes the entry */ + ghid_cmd_close(&ghidgui->topwin.cmd); + + gtk_main_quit(); +} + +static void pcb_gtk_topwinplace(pcb_hidlib_t *hidlib, GtkWidget *dialog, const char *id) +{ + int plc[4] = {-1, -1, -1, -1}; + + pcb_event(hidlib, PCB_EVENT_DAD_NEW_DIALOG, "psp", NULL, id, plc); + + if (pcbhl_conf.editor.auto_place) { + if ((plc[2] > 0) && (plc[3] > 0)) + gtk_window_resize(GTK_WINDOW(dialog), plc[2], plc[3]); + if ((plc[0] >= 0) && (plc[1] >= 0)) + gtk_window_move(GTK_WINDOW(dialog), plc[0], plc[1]); + } +} + +/* Create top level window for routines that will need top_window before ghid_create_pcb_widgets() is called. */ +int gtkhid_parse_arguments(int *argc, char ***argv) +{ + GtkWidget *window; + + /* on windows we need to figure out the installation directory */ +TODO("This needs to be done centrally, and should not use PCB_PACKAGE but pcbhl_app_*") +#ifdef WIN32 + char *tmps; + char *libdir; + tmps = g_win32_get_package_installation_directory(PCB_PACKAGE "-" PCB_VERSION, NULL); +#define REST_OF_PATH G_DIR_SEPARATOR_S "share" G_DIR_SEPARATOR_S PCB_PACKAGE G_DIR_SEPARATOR_S "pcblib" + libdir = (char *) malloc(strlen(tmps) + strlen(REST_OF_PATH) + 1); + sprintf(libdir, "%s%s", tmps, REST_OF_PATH); + free(tmps); + +#undef REST_OF_PATH + +#endif + + conf_parse_arguments("plugins/hid_gtk/", argc, argv); + + if (!gtk_init_check(argc, argv)) { + fprintf(stderr, "gtk_init_check() fail - maybe $DISPLAY not set or X/GUI not accessible?\n"); + return 1; /* recoverable error - try another HID */ + } + + gport = &ghid_port; + gport->view.use_max_pcb = 1; + gport->view.coord_per_px = 300.0; + pcb_pixel_slop = 300; + + ghidgui->common.init_renderer(argc, argv, gport); + + ghidgui->topwin.com = &ghidgui->common; + ghidgui->common.top_window = window = gport->top_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + + pcb_gtk_topwinplace(ghidgui->common.hidlib, window, "top"); + gtk_window_set_title(GTK_WINDOW(window), "pcb-rnd"); + + gtk_widget_show_all(gport->top_window); + return 0; +} + +static void ghid_calibrate(double xval, double yval) +{ + printf("ghid_calibrate() -- not implemented\n"); +} + +static void ghid_set_crosshair(pcb_coord_t x, pcb_coord_t y, int action) +{ + int offset_x, offset_y; + + if ((gport->drawing_area == NULL) || (ghidgui->common.hidlib == NULL)) + return; + + ghidgui->common.draw_grid_local(ghidgui->common.hidlib, x, y); + gdk_window_get_origin(gtk_widget_get_window(gport->drawing_area), &offset_x, &offset_y); + pcb_gtk_crosshair_set(x, y, action, offset_x, offset_y, &gport->view); +} + +static void ghid_get_coords(const char *msg, pcb_coord_t *x, pcb_coord_t *y, int force) +{ + pcb_gtk_get_coords(&gport->mouse, &gport->view, msg, x, y, force); +} + +pcb_hidval_t ghid_add_timer(void (*func) (pcb_hidval_t user_data), unsigned long milliseconds, pcb_hidval_t user_data) +{ + return pcb_gtk_add_timer(&ghidgui->common, func, milliseconds, user_data); +} + +static pcb_hidval_t ghid_watch_file(int fd, unsigned int condition, + pcb_bool (*func)(pcb_hidval_t watch, int fd, unsigned int condition, pcb_hidval_t user_data), + pcb_hidval_t user_data) +{ + return pcb_gtk_watch_file(&ghidgui->common, fd, condition, func, user_data); +} + +static char *ghid_fileselect(const char *title, const char *descr, const char *default_file, const char *default_ext, const pcb_hid_fsd_filter_t *flt, const char *history_tag, pcb_hid_fsd_flags_t flags, pcb_hid_dad_subdialog_t *sub) +{ + return pcb_gtk_fileselect(&ghidgui->common, title, descr, default_file, default_ext, flt, history_tag, flags, sub); +} + +static void *ghid_attr_dlg_new_(const char *id, pcb_hid_attribute_t *attrs, int n_attrs, pcb_hid_attr_val_t *results, const char *title, void *caller_data, pcb_bool modal, void (*button_cb)(void *caller_data, pcb_hid_attr_ev_t ev), int defx, int defy, int minx, int miny) +{ + return ghid_attr_dlg_new(&ghidgui->common, id, attrs, n_attrs, results, title, caller_data, modal, button_cb, defx, defy, minx, miny); +} + +static void ghid_beep() +{ + gdk_beep(); +} + +static void ghid_attributes(const char *owner, pcb_attribute_list_t * attrs) +{ + pcb_gtk_dlg_attributes(ghid_port.top_window, owner, attrs); +} + +static void PointCursor(pcb_bool grabbed) +{ + if (!ghidgui) + return; + + ghid_point_cursor(&gport->mouse, grabbed); +} + +/* Create a new menu by path */ +static int ghid_remove_menu(const char *menu_path) +{ + if (ghidgui->topwin.ghid_cfg == NULL) + return -1; + return pcb_hid_cfg_remove_menu(ghidgui->topwin.ghid_cfg, menu_path, ghid_remove_menu_widget, ghidgui->topwin.menu.menu_bar); +} + +static int ghid_remove_menu_node(lht_node_t *node) +{ + return pcb_hid_cfg_remove_menu_node(ghidgui->topwin.ghid_cfg, node, ghid_remove_menu_widget, ghidgui->topwin.menu.menu_bar); +} + +static void ghid_create_menu(const char *menu_path, const pcb_menu_prop_t *props) +{ + pcb_hid_cfg_create_menu(ghidgui->topwin.ghid_cfg, menu_path, props, ghid_create_menu_widget, &ghidgui->topwin.menu); +} + +static void ghid_update_menu_checkbox(const char *cookie) +{ + if (ghidgui->hid_active) + ghid_update_toggle_flags(&ghidgui->topwin, cookie); +} + +pcb_hid_cfg_t *ghid_get_menu_cfg(void) +{ + if (!ghidgui->hid_active) + return NULL; + return ghidgui->topwin.ghid_cfg; +} + +static int ghid_usage(const char *topic) +{ + fprintf(stderr, "\nGTK GUI command line arguments:\n\n"); + conf_usage("plugins/hid_gtk", pcb_hid_usage_option); + fprintf(stderr, "\nInvocation:\n"); + fprintf(stderr, " pcb-rnd --gui gtk2_gdk [options]\n"); + fprintf(stderr, " pcb-rnd --gui gtk2_gl [options]\n"); + fprintf(stderr, " (depending on which gtk plugin(s) are compiled and installed)\n"); + return 0; +} + +static const char *ghid_command_entry(const char *ovr, int *cursor) +{ + return pcb_gtk_cmd_command_entry(&ghidgui->topwin.cmd, ovr, cursor); +} + +static int ghid_clip_set(pcb_hid_clipfmt_t format, const void *data, size_t len) +{ + GtkClipboard *cbrd = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); + + switch(format) { + case PCB_HID_CLIPFMT_TEXT: + gtk_clipboard_set_text(cbrd, data, len); + break; + } + return 0; +} + + + +int ghid_clip_get(pcb_hid_clipfmt_t *format, void **data, size_t *len) +{ + GtkClipboard *cbrd = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); + + if (gtk_clipboard_wait_is_text_available(cbrd)) { + gchar *txt = gtk_clipboard_wait_for_text(cbrd); + *format = PCB_HID_CLIPFMT_TEXT; + *data = txt; + *len = strlen(txt) + 1; + return 0; + } + + return -1; +} + +void ghid_clip_free(pcb_hid_clipfmt_t format, void *data, size_t len) +{ + switch(format) { + case PCB_HID_CLIPFMT_TEXT: + g_free(data); + break; + } +} + +static void ghid_iterate(pcb_hid_t *hid) +{ + while(gtk_events_pending()) + gtk_main_iteration_do(0); +} + +static double ghid_benchmark(void) +{ + int i = 0; + time_t start, end; + GdkDisplay *display; + GdkWindow *window; + + window = gtk_widget_get_window(gport->drawing_area); + display = gtk_widget_get_display(gport->drawing_area); + + gdk_display_sync(display); + time(&start); + do { + ghid_invalidate_all(ghidgui->common.hidlib); + gdk_window_process_updates(window, FALSE); + time(&end); + i++; + } + while (end - start < 10); + + return i/10.0; +} + +static int ghid_dock_enter(pcb_hid_dad_subdialog_t *sub, pcb_hid_dock_t where, const char *id) +{ + return pcb_gtk_tw_dock_enter(&ghidgui->topwin, sub, where, id); +} + +static void ghid_dock_leave(pcb_hid_dad_subdialog_t *sub) +{ + pcb_gtk_tw_dock_leave(&ghidgui->topwin, sub); +} + +static void ghid_zoom_win(pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2, pcb_bool set_crosshair) +{ + pcb_gtk_zoom_view_win_side(&gport->view, x1, y1, x2, y2, set_crosshair); +} + +static void ghid_zoom(pcb_coord_t center_x, pcb_coord_t center_y, double factor, int relative) +{ + if (relative) + pcb_gtk_zoom_view_rel(&gport->view, center_x, center_y, factor); + else + pcb_gtk_zoom_view_abs(&gport->view, center_x, center_y, factor); +} + +static void ghid_pan(pcb_coord_t x, pcb_coord_t y, int relative) +{ + if (relative) + pcb_gtk_pan_view_rel(&gport->view, x, y); + else + pcb_gtk_pan_view_abs(&gport->view, x, y, gport->view.canvas_width/2.0, gport->view.canvas_height/2.0); +} + +static void ghid_pan_mode(pcb_coord_t x, pcb_coord_t y, pcb_bool mode) +{ + gport->view.panning = mode; +} + +static void ghid_view_get(pcb_hidlib_t *hidlib, pcb_box_t *viewbox) +{ + viewbox->X1 = gport->view.x0; + viewbox->Y1 = gport->view.y0; + viewbox->X2 = pcb_round((double)gport->view.x0 + (double)gport->view.canvas_width * gport->view.coord_per_px); + viewbox->Y2 = pcb_round((double)gport->view.y0 + (double)gport->view.canvas_height * gport->view.coord_per_px); +} + +static void ghid_open_command(void) +{ + ghid_handle_user_command(&ghidgui->topwin.cmd, TRUE); +} + +static int ghid_open_popup(const char *menupath) +{ + GtkWidget *menu = NULL; + lht_node_t *menu_node = pcb_hid_cfg_get_menu(ghidgui->topwin.ghid_cfg, menupath); + + if (menu_node == NULL) + return 1; + + menu = pcb_gtk_menu_widget(menu_node); + if (!GTK_IS_MENU(menu)) { + pcb_message(PCB_MSG_ERROR, "The specified popup menu \"%s\" has not been defined.\n", menupath); + return 1; + } + + gtk_widget_grab_focus(ghid_port.drawing_area); + gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time()); + gtk_window_set_transient_for(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(menu))), GTK_WINDOW(gtk_widget_get_toplevel(ghid_port.drawing_area))); + return 0; +} + +static void ghid_set_hidlib(pcb_hidlib_t *hidlib) +{ + ghidgui->common.hidlib = hidlib; + + if (ghidgui == NULL) + return; + + ghidgui->common.hidlib = hidlib; + + if(!ghidgui->hid_active) + return; + + if (hidlib == NULL) + return; + + if (!gport->drawing_allowed) + return; + + pcb_gtk_tw_ranges_scale(&ghidgui->topwin); + pcb_gtk_zoom_view_win_side(&gport->view, 0, 0, hidlib->size_x, hidlib->size_y, 0); +} + +static void ghid_reg_mouse_cursor(pcb_hidlib_t *hidlib, int idx, const char *name, const unsigned char *pixel, const unsigned char *mask) +{ + ghid_port_reg_mouse_cursor(&gport->mouse, idx, name, pixel, mask); +} + +static void ghid_set_mouse_cursor(pcb_hidlib_t *hidlib, int idx) +{ + ghid_port_set_mouse_cursor(&gport->mouse, idx); +} + +static void ghid_set_top_title(pcb_hidlib_t *hidlib, const char *title) +{ + pcb_gtk_tw_set_title(&ghidgui->topwin, title); +} + +static void ghid_busy(pcb_hidlib_t *hidlib, pcb_bool busy) +{ + if ((gport == NULL) || (!ghidgui->hid_active)) + return; + if (busy) + ghid_watch_cursor(&gport->mouse); + else + ghid_restore_cursor(&gport->mouse); +} + + +void ghid_glue_hid_init(pcb_hid_t *dst) +{ + memset(dst, 0, sizeof(pcb_hid_t)); + + pcb_hid_nogui_init(dst); + + dst->struct_size = sizeof(pcb_hid_t); + dst->gui = 1; + dst->heavy_term_layer_ind = 1; + dst->allow_dad_before_init = 1; + + dst->do_export = gtkhid_do_export; + dst->do_exit = ghid_do_exit; + dst->iterate = ghid_iterate; + dst->parse_arguments = gtkhid_parse_arguments; + + dst->calibrate = ghid_calibrate; + dst->shift_is_pressed = ghid_shift_is_pressed; + dst->control_is_pressed = ghid_control_is_pressed; + dst->mod1_is_pressed = ghid_mod1_is_pressed; + dst->get_coords = ghid_get_coords; + dst->set_crosshair = ghid_set_crosshair; + dst->add_timer = ghid_add_timer; + dst->stop_timer = ghid_stop_timer; + dst->watch_file = ghid_watch_file; + dst->unwatch_file = pcb_gtk_unwatch_file; + + dst->fileselect = ghid_fileselect; + dst->attr_dlg_new = ghid_attr_dlg_new_; + dst->attr_dlg_run = ghid_attr_dlg_run; + dst->attr_dlg_raise = ghid_attr_dlg_raise; + dst->attr_dlg_free = ghid_attr_dlg_free; + dst->attr_dlg_property = ghid_attr_dlg_property; + dst->attr_dlg_widget_state = ghid_attr_dlg_widget_state; + dst->attr_dlg_widget_hide = ghid_attr_dlg_widget_hide; + dst->attr_dlg_set_value = ghid_attr_dlg_set_value; + dst->attr_dlg_set_help = ghid_attr_dlg_set_help; + dst->supports_dad_text_markup = 1; + + dst->dock_enter = ghid_dock_enter; + dst->dock_leave = ghid_dock_leave; + + dst->beep = ghid_beep; + dst->edit_attributes = ghid_attributes; + dst->point_cursor = PointCursor; + dst->benchmark = ghid_benchmark; + + dst->command_entry = ghid_command_entry; + + dst->create_menu = ghid_create_menu; + dst->remove_menu = ghid_remove_menu; + dst->remove_menu_node = ghid_remove_menu_node; + dst->update_menu_checkbox = ghid_update_menu_checkbox; + dst->get_menu_cfg = ghid_get_menu_cfg; + + dst->clip_set = ghid_clip_set; + dst->clip_get = ghid_clip_get; + dst->clip_free = ghid_clip_free; + + dst->zoom_win = ghid_zoom_win; + dst->zoom = ghid_zoom; + dst->pan = ghid_pan; + dst->pan_mode = ghid_pan_mode; + dst->view_get = ghid_view_get; + dst->open_command = ghid_open_command; + dst->open_popup = ghid_open_popup; + dst->reg_mouse_cursor = ghid_reg_mouse_cursor; + dst->set_mouse_cursor = ghid_set_mouse_cursor; + dst->set_top_title = ghid_set_top_title; + dst->busy = ghid_busy; + + dst->set_hidlib = ghid_set_hidlib; + + dst->key_state = &ghid_keymap; + + dst->usage = ghid_usage; +} Index: trunk/src_plugins/lib_gtk_common/glue_hid.h =================================================================== --- trunk/src_plugins/lib_gtk_common/glue_hid.h (nonexistent) +++ trunk/src_plugins/lib_gtk_common/glue_hid.h (revision 26696) @@ -0,0 +1,6 @@ +#include "hid.h" + +void ghid_glue_hid_init(pcb_hid_t *dst); +void gtkhid_do_export(pcb_hidlib_t *hidlib, pcb_hid_attr_val_t *options); +int gtkhid_parse_arguments(int *argc, char ***argv); + Index: trunk/src_plugins/lib_gtk_common/glue_win32.c =================================================================== --- trunk/src_plugins/lib_gtk_common/glue_win32.c (nonexistent) +++ trunk/src_plugins/lib_gtk_common/glue_win32.c (revision 26696) @@ -0,0 +1,34 @@ +#include "config.h" + +#include +#include "glue_win32.h" + +void ghid_win32_init(void) +{ +TODO("Should not use PCB_PACKAGE but pcbhl_app_*"); +#ifdef WIN32 + char *tmps; + char *share_dir; + char *loader_cache; + FILE *loader_file; + + tmps = g_win32_get_package_installation_directory(PCB_PACKAGE "-" PCB_VERSION, NULL); +#define REST_OF_PATH G_DIR_SEPARATOR_S "share" G_DIR_SEPARATOR_S PCB_PACKAGE +#define REST_OF_CACHE G_DIR_SEPARATOR_S "loaders.cache" + share_dir = (char *) malloc(strlen(tmps) + strlen(REST_OF_PATH) + 1); + sprintf(share_dir, "%s%s", tmps, REST_OF_PATH); + + /* Point to our gdk-pixbuf loader cache. */ + loader_cache = (char *) malloc(strlen("bindir_todo12") + strlen(REST_OF_CACHE) + 1); + sprintf(loader_cache, "%s%s", "bindir_todo12", REST_OF_CACHE); + loader_file = fopen(loader_cache, "r"); + if (loader_file) { + fclose(loader_file); + g_setenv("GDK_PIXBUF_MODULE_FILE", loader_cache, TRUE); + } + + free(tmps); +#undef REST_OF_PATH + printf("\"Share\" installation path is \"%s\"\n", "share_dir_todo12"); +#endif +} Index: trunk/src_plugins/lib_gtk_common/glue_win32.h =================================================================== --- trunk/src_plugins/lib_gtk_common/glue_win32.h (nonexistent) +++ trunk/src_plugins/lib_gtk_common/glue_win32.h (revision 26696) @@ -0,0 +1,12 @@ +/* + * We will need these for finding the windows installation + * directory. Without that we can't find our fonts and + * footprint libraries. + */ +#ifdef WIN32 +#include +#include +#endif + +void ghid_win32_init(void); + Index: trunk/src_plugins/lib_gtk_common/gui.h =================================================================== --- trunk/src_plugins/lib_gtk_common/gui.h (nonexistent) +++ trunk/src_plugins/lib_gtk_common/gui.h (revision 26696) @@ -0,0 +1,81 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * (this file is based on PCB, interactive printed circuit board design) + * Copyright (C) 1994,1995,1996 Thomas Nau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +#ifndef PCB_HID_GTK_GHID_H +#define PCB_HID_GTK_GHID_H + +#include "hid.h" + +typedef struct GHidPort_s GHidPort; +typedef struct GhidGui_s GhidGui; +extern GhidGui _ghidgui, *ghidgui; + +#include + +/* needed for a type in GhidGui - DO NOT ADD .h files that are not requred for the structs! */ +#include "../src_plugins/lib_gtk_common/ui_zoompan.h" +#include "../src_plugins/lib_gtk_common/dlg_topwin.h" +#include "../src_plugins/lib_gtk_common/in_mouse.h" +#include "../src_plugins/lib_gtk_common/glue.h" + +#include "event.h" +#include "conf_hid.h" +#include "render.h" +#include "pcb_bool.h" + +struct GhidGui_s { + GtkActionGroup *main_actions; + + pcb_gtk_topwin_t topwin; + pcb_gtk_common_t common; + conf_hid_id_t conf_id; + + GdkPixbuf *bg_pixbuf; /* -> renderer */ + + int hid_active; /* 1 if the currently running hid (pcb_gui) is us */ + int gui_is_up; /*1 if all parts of the gui is up and running */ + + gulong button_press_handler, button_release_handler, key_press_handler[5], key_release_handler[5]; +}; + +/* The output viewport */ +struct GHidPort_s { + GtkWidget *top_window, /* toplevel widget */ + *drawing_area; /* and its drawing area */ + + pcb_bool drawing_allowed; /* track if a drawing area is available for rendering */ + + struct render_priv_s *render_priv; + + pcb_gtk_mouse_t mouse; + + pcb_gtk_view_t view; +}; + +extern GHidPort ghid_port, *gport; + +#endif /* PCB_HID_GTK_GHID_GUI_H */ Index: trunk/src_plugins/lib_gtk_common/lib_gtk_common.pup =================================================================== --- trunk/src_plugins/lib_gtk_common/lib_gtk_common.pup (revision 26695) +++ trunk/src_plugins/lib_gtk_common/lib_gtk_common.pup (revision 26696) @@ -1,6 +1,6 @@ $class lib $short all-hid_gtk common code -$long hid_gtk* common code (regardless of gtk version or drawing mechanism: for both gtk2 and gtk3 and for both sw rendering and gl) +$long hid_gtk* common code (regardless of rendering mechanism: for both gdk sw rendering and gl) $state works $package lib-gtk dep lib_hid_common Index: trunk/src_plugins/lib_gtk_common/preview_helper.h =================================================================== --- trunk/src_plugins/lib_gtk_common/preview_helper.h (nonexistent) +++ trunk/src_plugins/lib_gtk_common/preview_helper.h (revision 26696) @@ -0,0 +1,33 @@ +#ifndef PCB_GTK_PREVIEW_HELPER_H +#define PCB_GTK_PREVIEW_HELPER_H + +/* make sure the context is set to draw the whole widget size, which might + be slightly larger than the original request */ +#define PCB_GTK_PREVIEW_TUNE_EXTENT(ctx, allocation) \ +do { \ + pcb_coord_t nx1, ny1, nx2, ny2; \ + nx1 = Px(0); nx2 = Px(allocation.width); \ + ny1 = Py(0); ny2 = Py(allocation.height); \ + if (nx1 < nx2) { \ + ctx->view.X1 = nx1; \ + ctx->view.X2 = nx2; \ + } \ + else { \ + ctx->view.X1 = nx2; \ + ctx->view.X2 = nx1; \ + } \ + if (ny1 < ny2) { \ + ctx->view.Y1 = ny1; \ + ctx->view.Y2 = ny2; \ + } \ + else { \ + ctx->view.Y1 = ny2; \ + ctx->view.Y2 = ny1; \ + } \ +} while(0) + +/* Redraw all previews intersecting the specified screenbox (in case of lr) */ +void pcb_gtk_previews_invalidate_lr(pcb_coord_t left, pcb_coord_t right, pcb_coord_t top, pcb_coord_t bottom); +void pcb_gtk_previews_invalidate_all(void); + +#endif Index: trunk/src_plugins/lib_gtk_common/render.c =================================================================== --- trunk/src_plugins/lib_gtk_common/render.c (nonexistent) +++ trunk/src_plugins/lib_gtk_common/render.c (revision 26696) @@ -0,0 +1,30 @@ +#include "config.h" +#include +#include "gui.h" +#include "render.h" +#include "../src_plugins/lib_gtk_common/wt_preview.h" + + +void ghid_draw_area_update(GHidPort *port, GdkRectangle *rect) +{ + gdk_window_invalidate_rect(gtk_widget_get_window(port->drawing_area), rect, FALSE); +} + +void ghid_drawing_area_configure_hook(void *out) +{ + ghidgui->common.drawing_area_configure_hook(out); +} + +void pcb_gtk_previews_invalidate_lr(pcb_coord_t left, pcb_coord_t right, pcb_coord_t top, pcb_coord_t bottom) +{ + pcb_box_t screen; + screen.X1 = left; screen.X2 = right; + screen.Y1 = top; screen.Y1 = bottom; + pcb_gtk_preview_invalidate(&ghidgui->common, &screen); +} + +void pcb_gtk_previews_invalidate_all(void) +{ + pcb_gtk_preview_invalidate(&ghidgui->common, NULL); +} + Index: trunk/src_plugins/lib_gtk_common/render.h =================================================================== --- trunk/src_plugins/lib_gtk_common/render.h (nonexistent) +++ trunk/src_plugins/lib_gtk_common/render.h (revision 26696) @@ -0,0 +1,20 @@ +#ifndef PCB_GTK_RENDER_H +#define PCB_GTK_RENDER_H + +#include +#include +#include "gui.h" +#include "conf.h" +#include "pcb_bool.h" + +/* the only entry points we should see from the actual renderers */ +void ghid_gdk_install(pcb_gtk_common_t *common, pcb_hid_t *hid); +void ghid_gl_install(pcb_gtk_common_t *common, pcb_hid_t *hid); + +/* Utility functions for renderers to call ***/ +void ghid_draw_area_update(GHidPort *out, GdkRectangle *rect); + +static inline void ghid_invalidate_all(pcb_hidlib_t *hidlib) { pcb_gui->invalidate_all(hidlib); } +void ghid_drawing_area_configure_hook(void *out); + +#endif Index: trunk/src_plugins/lib_gtk_hid/preview_helper.h =================================================================== --- trunk/src_plugins/lib_gtk_hid/preview_helper.h (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/preview_helper.h (nonexistent) @@ -1,33 +0,0 @@ -#ifndef PCB_GTK_PREVIEW_HELPER_H -#define PCB_GTK_PREVIEW_HELPER_H - -/* make sure the context is set to draw the whole widget size, which might - be slightly larger than the original request */ -#define PCB_GTK_PREVIEW_TUNE_EXTENT(ctx, allocation) \ -do { \ - pcb_coord_t nx1, ny1, nx2, ny2; \ - nx1 = Px(0); nx2 = Px(allocation.width); \ - ny1 = Py(0); ny2 = Py(allocation.height); \ - if (nx1 < nx2) { \ - ctx->view.X1 = nx1; \ - ctx->view.X2 = nx2; \ - } \ - else { \ - ctx->view.X1 = nx2; \ - ctx->view.X2 = nx1; \ - } \ - if (ny1 < ny2) { \ - ctx->view.Y1 = ny1; \ - ctx->view.Y2 = ny2; \ - } \ - else { \ - ctx->view.Y1 = ny2; \ - ctx->view.Y2 = ny1; \ - } \ -} while(0) - -/* Redraw all previews intersecting the specified screenbox (in case of lr) */ -void pcb_gtk_previews_invalidate_lr(pcb_coord_t left, pcb_coord_t right, pcb_coord_t top, pcb_coord_t bottom); -void pcb_gtk_previews_invalidate_all(void); - -#endif Index: trunk/src_plugins/lib_gtk_hid/gui.h =================================================================== --- trunk/src_plugins/lib_gtk_hid/gui.h (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/gui.h (nonexistent) @@ -1,81 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * (this file is based on PCB, interactive printed circuit board design) - * Copyright (C) 1994,1995,1996 Thomas Nau - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - */ - -#ifndef PCB_HID_GTK_GHID_H -#define PCB_HID_GTK_GHID_H - -#include "hid.h" - -typedef struct GHidPort_s GHidPort; -typedef struct GhidGui_s GhidGui; -extern GhidGui _ghidgui, *ghidgui; - -#include - -/* needed for a type in GhidGui - DO NOT ADD .h files that are not requred for the structs! */ -#include "../src_plugins/lib_gtk_common/ui_zoompan.h" -#include "../src_plugins/lib_gtk_common/dlg_topwin.h" -#include "../src_plugins/lib_gtk_common/in_mouse.h" -#include "../src_plugins/lib_gtk_common/glue.h" - -#include "event.h" -#include "conf_hid.h" -#include "render.h" -#include "pcb_bool.h" - -struct GhidGui_s { - GtkActionGroup *main_actions; - - pcb_gtk_topwin_t topwin; - pcb_gtk_common_t common; - conf_hid_id_t conf_id; - - GdkPixbuf *bg_pixbuf; /* -> renderer */ - - int hid_active; /* 1 if the currently running hid (pcb_gui) is us */ - int gui_is_up; /*1 if all parts of the gui is up and running */ - - gulong button_press_handler, button_release_handler, key_press_handler[5], key_release_handler[5]; -}; - -/* The output viewport */ -struct GHidPort_s { - GtkWidget *top_window, /* toplevel widget */ - *drawing_area; /* and its drawing area */ - - pcb_bool drawing_allowed; /* track if a drawing area is available for rendering */ - - struct render_priv_s *render_priv; - - pcb_gtk_mouse_t mouse; - - pcb_gtk_view_t view; -}; - -extern GHidPort ghid_port, *gport; - -#endif /* PCB_HID_GTK_GHID_GUI_H */ Index: trunk/src_plugins/lib_gtk_hid/glue_common.h =================================================================== --- trunk/src_plugins/lib_gtk_hid/glue_common.h (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/glue_common.h (nonexistent) @@ -1,2 +0,0 @@ -#include "hid.h" -void ghid_glue_common_init(void); Index: trunk/src_plugins/lib_gtk_hid/glue_hid.c =================================================================== --- trunk/src_plugins/lib_gtk_hid/glue_hid.c (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/glue_hid.c (nonexistent) @@ -1,642 +0,0 @@ -#include "config.h" -#include "glue_hid.h" - -#include - -#include "gui.h" -#include "actions.h" -#include "glue_hid.h" -#include "render.h" -#include "common.h" -#include "hid_nogui.h" -#include "hid_attrib.h" -#include "coord_conv.h" - -#include "../src_plugins/lib_gtk_common/in_keyboard.h" -#include "../src_plugins/lib_gtk_common/bu_dwg_tooltip.h" -#include "../src_plugins/lib_gtk_common/ui_crosshair.h" -#include "../src_plugins/lib_gtk_common/dlg_fileselect.h" -#include "../src_plugins/lib_gtk_common/dlg_attribute.h" -#include "../src_plugins/lib_gtk_common/dlg_attributes.h" -#include "../src_plugins/lib_gtk_common/util_listener.h" -#include "../src_plugins/lib_gtk_common/util_timer.h" -#include "../src_plugins/lib_gtk_common/util_watch.h" -#include "../src_plugins/lib_gtk_common/hid_gtk_conf.h" -#include "../src_plugins/lib_gtk_common/lib_gtk_config.h" -#include "../src_plugins/lib_hid_common/menu_helper.h" - -extern pcb_hid_cfg_keys_t ghid_keymap; - -void gtkhid_begin(pcb_hidlib_t *hidlib) -{ - ghidgui->common.hidlib = hidlib; - ghidgui->hid_active = 1; -} - -void gtkhid_end(void) -{ - ghidgui->hid_active = 0; -} - -static inline void ghid_screen_update(void) { ghidgui->common.screen_update(); } - -static gint ghid_port_window_enter_cb(GtkWidget * widget, GdkEventCrossing * ev, void * out_) -{ - GHidPort *out = out_; - int force_update = 0; - - /* printf("enter: mode: %d detail: %d\n", ev->mode, ev->detail); */ - - /* See comment in ghid_port_window_leave_cb() */ - - if (ev->mode != GDK_CROSSING_NORMAL && ev->detail != GDK_NOTIFY_NONLINEAR) { - return FALSE; - } - - if (!ghidgui->topwin.cmd.command_entry_status_line_active) { - out->view.has_entered = TRUE; - force_update = 1; /* force a redraw for the crosshair */ - /* Make sure drawing area has keyboard focus when we are in it. - */ - gtk_widget_grab_focus(out->drawing_area); - } - - /* Following expression is true if a you open a menu from the menu bar, - * move the mouse to the viewport and click on it. This closes the menu - * and moves the pointer to the viewport without the pointer going over - * the edge of the viewport */ - if (force_update || (ev->mode == GDK_CROSSING_UNGRAB && ev->detail == GDK_NOTIFY_NONLINEAR)) { - ghid_screen_update(); - } - return FALSE; -} - -static gint ghid_port_window_leave_cb(GtkWidget * widget, GdkEventCrossing * ev, void * out_) -{ - GHidPort *out = out_; - - /* printf("leave mode: %d detail: %d\n", ev->mode, ev->detail); */ - - /* Window leave events can also be triggered because of focus grabs. Some - * X applications occasionally grab the focus and so trigger this function. - * At least GNOME's window manager is known to do this on every mouse click. - * - * See http://bugzilla.gnome.org/show_bug.cgi?id=102209 - */ - - if (ev->mode != GDK_CROSSING_NORMAL) { - return FALSE; - } - - out->view.has_entered = FALSE; - - ghid_screen_update(); - - return FALSE; -} - -static gboolean check_object_tooltips(GHidPort *out) -{ - return pcb_gtk_dwg_tooltip_check_object(out->drawing_area, out->view.crosshair_x, out->view.crosshair_y); -} - -static gint ghid_port_window_motion_cb(GtkWidget * widget, GdkEventMotion * ev, void * out_) -{ - GHidPort *out = out_; - gdouble dx, dy; - static gint x_prev = -1, y_prev = -1; - - gdk_event_request_motions(ev); - - if (out->view.panning) { - dx = gport->view.coord_per_px * (x_prev - ev->x); - dy = gport->view.coord_per_px * (y_prev - ev->y); - if (x_prev > 0) - pcb_gtk_pan_view_rel(&gport->view, dx, dy); - x_prev = ev->x; - y_prev = ev->y; - return FALSE; - } - x_prev = y_prev = -1; - ghid_note_event_location((GdkEventButton *) ev); - - pcb_gtk_dwg_tooltip_queue(out->drawing_area, (GSourceFunc)check_object_tooltips, out); - - return FALSE; -} - -static void ghdi_gui_inited(int main, int conf) -{ - static int im = 0, ic = 0, first = 1; - if (main) im = 1; - if (conf) ic = 1; - - if (im && ic && first) { - first = 0; - pcb_event(ghidgui->common.hidlib, PCB_EVENT_GUI_INIT, NULL); - pcb_gtk_zoom_view_win_side(&gport->view, 0, 0, ghidgui->common.hidlib->size_x, ghidgui->common.hidlib->size_y, 0); - } -} - -static gboolean ghid_port_drawing_area_configure_event_cb(GtkWidget * widget, GdkEventConfigure * ev, void * out) -{ - gport->view.canvas_width = ev->width; - gport->view.canvas_height = ev->height; - - ghid_drawing_area_configure_hook(out); - ghdi_gui_inited(0, 1); - - pcb_gtk_tw_ranges_scale(&ghidgui->topwin); - ghid_invalidate_all(ghidgui->common.hidlib); - return 0; -} - - -void gtkhid_do_export(pcb_hidlib_t *hidlib, pcb_hid_attr_val_t *options) -{ - gtkhid_begin(hidlib); - - pcb_hid_cfg_keys_init(&ghid_keymap); - ghid_keymap.translate_key = ghid_translate_key; - ghid_keymap.key_name = ghid_key_name; - ghid_keymap.auto_chr = 1; - ghid_keymap.auto_tr = hid_cfg_key_default_trans; - - ghid_create_pcb_widgets(&ghidgui->topwin, gport->top_window); - - /* assume pcb_gui is us */ - pcb_gui->hid_cfg = ghidgui->topwin.ghid_cfg; - - gport->mouse.drawing_area = ghidgui->topwin.drawing_area; - gport->drawing_area = ghidgui->topwin.drawing_area; - gport->mouse.top_window = ghidgui->common.top_window; - -TODO(": move this to render init") - /* Mouse and key events will need to be intercepted when PCB needs a - | location from the user. - */ - g_signal_connect(G_OBJECT(gport->drawing_area), "scroll_event", G_CALLBACK(ghid_port_window_mouse_scroll_cb), &gport->mouse); - g_signal_connect(G_OBJECT(gport->drawing_area), "motion_notify_event", G_CALLBACK(ghid_port_window_motion_cb), gport); - g_signal_connect(G_OBJECT(gport->drawing_area), "configure_event", G_CALLBACK(ghid_port_drawing_area_configure_event_cb), gport); - g_signal_connect(G_OBJECT(gport->drawing_area), "enter_notify_event", G_CALLBACK(ghid_port_window_enter_cb), gport); - g_signal_connect(G_OBJECT(gport->drawing_area), "leave_notify_event", G_CALLBACK(ghid_port_window_leave_cb), gport); - - ghid_interface_input_signals_connect(); - - if (conf_hid_gtk.plugins.hid_gtk.listen) - pcb_gtk_create_listener(); - - ghidgui->gui_is_up = 1; - - ghdi_gui_inited(1, 0); - - /* Make sure drawing area has keyboard focus so that keys are handled - while the mouse cursor is over the top window or children widgets, - before first entering the drawing area */ - gtk_widget_grab_focus(gport->drawing_area); - - gtk_main(); - pcb_hid_cfg_keys_uninit(&ghid_keymap); - gtkhid_end(); - - ghidgui->gui_is_up = 0; - pcb_gui->hid_cfg = NULL; -} - -static void ghid_do_exit(pcb_hid_t * hid) -{ - /* Need to force-close the command entry first because it has its own main - loop that'd block the exit until the user closes the entry */ - ghid_cmd_close(&ghidgui->topwin.cmd); - - gtk_main_quit(); -} - -static void pcb_gtk_topwinplace(pcb_hidlib_t *hidlib, GtkWidget *dialog, const char *id) -{ - int plc[4] = {-1, -1, -1, -1}; - - pcb_event(hidlib, PCB_EVENT_DAD_NEW_DIALOG, "psp", NULL, id, plc); - - if (pcbhl_conf.editor.auto_place) { - if ((plc[2] > 0) && (plc[3] > 0)) - gtk_window_resize(GTK_WINDOW(dialog), plc[2], plc[3]); - if ((plc[0] >= 0) && (plc[1] >= 0)) - gtk_window_move(GTK_WINDOW(dialog), plc[0], plc[1]); - } -} - -/* Create top level window for routines that will need top_window before ghid_create_pcb_widgets() is called. */ -int gtkhid_parse_arguments(int *argc, char ***argv) -{ - GtkWidget *window; - - /* on windows we need to figure out the installation directory */ -TODO("This needs to be done centrally, and should not use PCB_PACKAGE but pcbhl_app_*") -#ifdef WIN32 - char *tmps; - char *libdir; - tmps = g_win32_get_package_installation_directory(PCB_PACKAGE "-" PCB_VERSION, NULL); -#define REST_OF_PATH G_DIR_SEPARATOR_S "share" G_DIR_SEPARATOR_S PCB_PACKAGE G_DIR_SEPARATOR_S "pcblib" - libdir = (char *) malloc(strlen(tmps) + strlen(REST_OF_PATH) + 1); - sprintf(libdir, "%s%s", tmps, REST_OF_PATH); - free(tmps); - -#undef REST_OF_PATH - -#endif - - conf_parse_arguments("plugins/hid_gtk/", argc, argv); - - if (!gtk_init_check(argc, argv)) { - fprintf(stderr, "gtk_init_check() fail - maybe $DISPLAY not set or X/GUI not accessible?\n"); - return 1; /* recoverable error - try another HID */ - } - - gport = &ghid_port; - gport->view.use_max_pcb = 1; - gport->view.coord_per_px = 300.0; - pcb_pixel_slop = 300; - - ghidgui->common.init_renderer(argc, argv, gport); - - ghidgui->topwin.com = &ghidgui->common; - ghidgui->common.top_window = window = gport->top_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - - pcb_gtk_topwinplace(ghidgui->common.hidlib, window, "top"); - gtk_window_set_title(GTK_WINDOW(window), "pcb-rnd"); - - gtk_widget_show_all(gport->top_window); - return 0; -} - -static void ghid_calibrate(double xval, double yval) -{ - printf("ghid_calibrate() -- not implemented\n"); -} - -static void ghid_set_crosshair(pcb_coord_t x, pcb_coord_t y, int action) -{ - int offset_x, offset_y; - - if ((gport->drawing_area == NULL) || (ghidgui->common.hidlib == NULL)) - return; - - ghidgui->common.draw_grid_local(ghidgui->common.hidlib, x, y); - gdk_window_get_origin(gtk_widget_get_window(gport->drawing_area), &offset_x, &offset_y); - pcb_gtk_crosshair_set(x, y, action, offset_x, offset_y, &gport->view); -} - -static void ghid_get_coords(const char *msg, pcb_coord_t *x, pcb_coord_t *y, int force) -{ - pcb_gtk_get_coords(&gport->mouse, &gport->view, msg, x, y, force); -} - -pcb_hidval_t ghid_add_timer(void (*func) (pcb_hidval_t user_data), unsigned long milliseconds, pcb_hidval_t user_data) -{ - return pcb_gtk_add_timer(&ghidgui->common, func, milliseconds, user_data); -} - -static pcb_hidval_t ghid_watch_file(int fd, unsigned int condition, - pcb_bool (*func)(pcb_hidval_t watch, int fd, unsigned int condition, pcb_hidval_t user_data), - pcb_hidval_t user_data) -{ - return pcb_gtk_watch_file(&ghidgui->common, fd, condition, func, user_data); -} - -static char *ghid_fileselect(const char *title, const char *descr, const char *default_file, const char *default_ext, const pcb_hid_fsd_filter_t *flt, const char *history_tag, pcb_hid_fsd_flags_t flags, pcb_hid_dad_subdialog_t *sub) -{ - return pcb_gtk_fileselect(&ghidgui->common, title, descr, default_file, default_ext, flt, history_tag, flags, sub); -} - -static void *ghid_attr_dlg_new_(const char *id, pcb_hid_attribute_t *attrs, int n_attrs, pcb_hid_attr_val_t *results, const char *title, void *caller_data, pcb_bool modal, void (*button_cb)(void *caller_data, pcb_hid_attr_ev_t ev), int defx, int defy, int minx, int miny) -{ - return ghid_attr_dlg_new(&ghidgui->common, id, attrs, n_attrs, results, title, caller_data, modal, button_cb, defx, defy, minx, miny); -} - -static void ghid_beep() -{ - gdk_beep(); -} - -static void ghid_attributes(const char *owner, pcb_attribute_list_t * attrs) -{ - pcb_gtk_dlg_attributes(ghid_port.top_window, owner, attrs); -} - -static void PointCursor(pcb_bool grabbed) -{ - if (!ghidgui) - return; - - ghid_point_cursor(&gport->mouse, grabbed); -} - -/* Create a new menu by path */ -static int ghid_remove_menu(const char *menu_path) -{ - if (ghidgui->topwin.ghid_cfg == NULL) - return -1; - return pcb_hid_cfg_remove_menu(ghidgui->topwin.ghid_cfg, menu_path, ghid_remove_menu_widget, ghidgui->topwin.menu.menu_bar); -} - -static int ghid_remove_menu_node(lht_node_t *node) -{ - return pcb_hid_cfg_remove_menu_node(ghidgui->topwin.ghid_cfg, node, ghid_remove_menu_widget, ghidgui->topwin.menu.menu_bar); -} - -static void ghid_create_menu(const char *menu_path, const pcb_menu_prop_t *props) -{ - pcb_hid_cfg_create_menu(ghidgui->topwin.ghid_cfg, menu_path, props, ghid_create_menu_widget, &ghidgui->topwin.menu); -} - -static void ghid_update_menu_checkbox(const char *cookie) -{ - if (ghidgui->hid_active) - ghid_update_toggle_flags(&ghidgui->topwin, cookie); -} - -pcb_hid_cfg_t *ghid_get_menu_cfg(void) -{ - if (!ghidgui->hid_active) - return NULL; - return ghidgui->topwin.ghid_cfg; -} - -static int ghid_usage(const char *topic) -{ - fprintf(stderr, "\nGTK GUI command line arguments:\n\n"); - conf_usage("plugins/hid_gtk", pcb_hid_usage_option); - fprintf(stderr, "\nInvocation:\n"); - fprintf(stderr, " pcb-rnd --gui gtk2_gdk [options]\n"); - fprintf(stderr, " pcb-rnd --gui gtk2_gl [options]\n"); - fprintf(stderr, " (depending on which gtk plugin(s) are compiled and installed)\n"); - return 0; -} - -static const char *ghid_command_entry(const char *ovr, int *cursor) -{ - return pcb_gtk_cmd_command_entry(&ghidgui->topwin.cmd, ovr, cursor); -} - -static int ghid_clip_set(pcb_hid_clipfmt_t format, const void *data, size_t len) -{ - GtkClipboard *cbrd = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); - - switch(format) { - case PCB_HID_CLIPFMT_TEXT: - gtk_clipboard_set_text(cbrd, data, len); - break; - } - return 0; -} - - - -int ghid_clip_get(pcb_hid_clipfmt_t *format, void **data, size_t *len) -{ - GtkClipboard *cbrd = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); - - if (gtk_clipboard_wait_is_text_available(cbrd)) { - gchar *txt = gtk_clipboard_wait_for_text(cbrd); - *format = PCB_HID_CLIPFMT_TEXT; - *data = txt; - *len = strlen(txt) + 1; - return 0; - } - - return -1; -} - -void ghid_clip_free(pcb_hid_clipfmt_t format, void *data, size_t len) -{ - switch(format) { - case PCB_HID_CLIPFMT_TEXT: - g_free(data); - break; - } -} - -static void ghid_iterate(pcb_hid_t *hid) -{ - while(gtk_events_pending()) - gtk_main_iteration_do(0); -} - -static double ghid_benchmark(void) -{ - int i = 0; - time_t start, end; - GdkDisplay *display; - GdkWindow *window; - - window = gtk_widget_get_window(gport->drawing_area); - display = gtk_widget_get_display(gport->drawing_area); - - gdk_display_sync(display); - time(&start); - do { - ghid_invalidate_all(ghidgui->common.hidlib); - gdk_window_process_updates(window, FALSE); - time(&end); - i++; - } - while (end - start < 10); - - return i/10.0; -} - -static int ghid_dock_enter(pcb_hid_dad_subdialog_t *sub, pcb_hid_dock_t where, const char *id) -{ - return pcb_gtk_tw_dock_enter(&ghidgui->topwin, sub, where, id); -} - -static void ghid_dock_leave(pcb_hid_dad_subdialog_t *sub) -{ - pcb_gtk_tw_dock_leave(&ghidgui->topwin, sub); -} - -static void ghid_zoom_win(pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2, pcb_bool set_crosshair) -{ - pcb_gtk_zoom_view_win_side(&gport->view, x1, y1, x2, y2, set_crosshair); -} - -static void ghid_zoom(pcb_coord_t center_x, pcb_coord_t center_y, double factor, int relative) -{ - if (relative) - pcb_gtk_zoom_view_rel(&gport->view, center_x, center_y, factor); - else - pcb_gtk_zoom_view_abs(&gport->view, center_x, center_y, factor); -} - -static void ghid_pan(pcb_coord_t x, pcb_coord_t y, int relative) -{ - if (relative) - pcb_gtk_pan_view_rel(&gport->view, x, y); - else - pcb_gtk_pan_view_abs(&gport->view, x, y, gport->view.canvas_width/2.0, gport->view.canvas_height/2.0); -} - -static void ghid_pan_mode(pcb_coord_t x, pcb_coord_t y, pcb_bool mode) -{ - gport->view.panning = mode; -} - -static void ghid_view_get(pcb_hidlib_t *hidlib, pcb_box_t *viewbox) -{ - viewbox->X1 = gport->view.x0; - viewbox->Y1 = gport->view.y0; - viewbox->X2 = pcb_round((double)gport->view.x0 + (double)gport->view.canvas_width * gport->view.coord_per_px); - viewbox->Y2 = pcb_round((double)gport->view.y0 + (double)gport->view.canvas_height * gport->view.coord_per_px); -} - -static void ghid_open_command(void) -{ - ghid_handle_user_command(&ghidgui->topwin.cmd, TRUE); -} - -static int ghid_open_popup(const char *menupath) -{ - GtkWidget *menu = NULL; - lht_node_t *menu_node = pcb_hid_cfg_get_menu(ghidgui->topwin.ghid_cfg, menupath); - - if (menu_node == NULL) - return 1; - - menu = pcb_gtk_menu_widget(menu_node); - if (!GTK_IS_MENU(menu)) { - pcb_message(PCB_MSG_ERROR, "The specified popup menu \"%s\" has not been defined.\n", menupath); - return 1; - } - - gtk_widget_grab_focus(ghid_port.drawing_area); - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time()); - gtk_window_set_transient_for(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(menu))), GTK_WINDOW(gtk_widget_get_toplevel(ghid_port.drawing_area))); - return 0; -} - -static void ghid_set_hidlib(pcb_hidlib_t *hidlib) -{ - ghidgui->common.hidlib = hidlib; - - if (ghidgui == NULL) - return; - - ghidgui->common.hidlib = hidlib; - - if(!ghidgui->hid_active) - return; - - if (hidlib == NULL) - return; - - if (!gport->drawing_allowed) - return; - - pcb_gtk_tw_ranges_scale(&ghidgui->topwin); - pcb_gtk_zoom_view_win_side(&gport->view, 0, 0, hidlib->size_x, hidlib->size_y, 0); -} - -static void ghid_reg_mouse_cursor(pcb_hidlib_t *hidlib, int idx, const char *name, const unsigned char *pixel, const unsigned char *mask) -{ - ghid_port_reg_mouse_cursor(&gport->mouse, idx, name, pixel, mask); -} - -static void ghid_set_mouse_cursor(pcb_hidlib_t *hidlib, int idx) -{ - ghid_port_set_mouse_cursor(&gport->mouse, idx); -} - -static void ghid_set_top_title(pcb_hidlib_t *hidlib, const char *title) -{ - pcb_gtk_tw_set_title(&ghidgui->topwin, title); -} - -static void ghid_busy(pcb_hidlib_t *hidlib, pcb_bool busy) -{ - if ((gport == NULL) || (!ghidgui->hid_active)) - return; - if (busy) - ghid_watch_cursor(&gport->mouse); - else - ghid_restore_cursor(&gport->mouse); -} - - -void ghid_glue_hid_init(pcb_hid_t *dst) -{ - memset(dst, 0, sizeof(pcb_hid_t)); - - pcb_hid_nogui_init(dst); - - dst->struct_size = sizeof(pcb_hid_t); - dst->gui = 1; - dst->heavy_term_layer_ind = 1; - dst->allow_dad_before_init = 1; - - dst->do_export = gtkhid_do_export; - dst->do_exit = ghid_do_exit; - dst->iterate = ghid_iterate; - dst->parse_arguments = gtkhid_parse_arguments; - - dst->calibrate = ghid_calibrate; - dst->shift_is_pressed = ghid_shift_is_pressed; - dst->control_is_pressed = ghid_control_is_pressed; - dst->mod1_is_pressed = ghid_mod1_is_pressed; - dst->get_coords = ghid_get_coords; - dst->set_crosshair = ghid_set_crosshair; - dst->add_timer = ghid_add_timer; - dst->stop_timer = ghid_stop_timer; - dst->watch_file = ghid_watch_file; - dst->unwatch_file = pcb_gtk_unwatch_file; - - dst->fileselect = ghid_fileselect; - dst->attr_dlg_new = ghid_attr_dlg_new_; - dst->attr_dlg_run = ghid_attr_dlg_run; - dst->attr_dlg_raise = ghid_attr_dlg_raise; - dst->attr_dlg_free = ghid_attr_dlg_free; - dst->attr_dlg_property = ghid_attr_dlg_property; - dst->attr_dlg_widget_state = ghid_attr_dlg_widget_state; - dst->attr_dlg_widget_hide = ghid_attr_dlg_widget_hide; - dst->attr_dlg_set_value = ghid_attr_dlg_set_value; - dst->attr_dlg_set_help = ghid_attr_dlg_set_help; - dst->supports_dad_text_markup = 1; - - dst->dock_enter = ghid_dock_enter; - dst->dock_leave = ghid_dock_leave; - - dst->beep = ghid_beep; - dst->edit_attributes = ghid_attributes; - dst->point_cursor = PointCursor; - dst->benchmark = ghid_benchmark; - - dst->command_entry = ghid_command_entry; - - dst->create_menu = ghid_create_menu; - dst->remove_menu = ghid_remove_menu; - dst->remove_menu_node = ghid_remove_menu_node; - dst->update_menu_checkbox = ghid_update_menu_checkbox; - dst->get_menu_cfg = ghid_get_menu_cfg; - - dst->clip_set = ghid_clip_set; - dst->clip_get = ghid_clip_get; - dst->clip_free = ghid_clip_free; - - dst->zoom_win = ghid_zoom_win; - dst->zoom = ghid_zoom; - dst->pan = ghid_pan; - dst->pan_mode = ghid_pan_mode; - dst->view_get = ghid_view_get; - dst->open_command = ghid_open_command; - dst->open_popup = ghid_open_popup; - dst->reg_mouse_cursor = ghid_reg_mouse_cursor; - dst->set_mouse_cursor = ghid_set_mouse_cursor; - dst->set_top_title = ghid_set_top_title; - dst->busy = ghid_busy; - - dst->set_hidlib = ghid_set_hidlib; - - dst->key_state = &ghid_keymap; - - dst->usage = ghid_usage; -} Index: trunk/src_plugins/lib_gtk_hid/render.c =================================================================== --- trunk/src_plugins/lib_gtk_hid/render.c (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/render.c (nonexistent) @@ -1,30 +0,0 @@ -#include "config.h" -#include -#include "gui.h" -#include "render.h" -#include "../src_plugins/lib_gtk_common/wt_preview.h" - - -void ghid_draw_area_update(GHidPort *port, GdkRectangle *rect) -{ - gdk_window_invalidate_rect(gtk_widget_get_window(port->drawing_area), rect, FALSE); -} - -void ghid_drawing_area_configure_hook(void *out) -{ - ghidgui->common.drawing_area_configure_hook(out); -} - -void pcb_gtk_previews_invalidate_lr(pcb_coord_t left, pcb_coord_t right, pcb_coord_t top, pcb_coord_t bottom) -{ - pcb_box_t screen; - screen.X1 = left; screen.X2 = right; - screen.Y1 = top; screen.Y1 = bottom; - pcb_gtk_preview_invalidate(&ghidgui->common, &screen); -} - -void pcb_gtk_previews_invalidate_all(void) -{ - pcb_gtk_preview_invalidate(&ghidgui->common, NULL); -} - Index: trunk/src_plugins/lib_gtk_hid/render.h =================================================================== --- trunk/src_plugins/lib_gtk_hid/render.h (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/render.h (nonexistent) @@ -1,20 +0,0 @@ -#ifndef PCB_GTK_RENDER_H -#define PCB_GTK_RENDER_H - -#include -#include -#include "gui.h" -#include "conf.h" -#include "pcb_bool.h" - -/* the only entry points we should see from the actual renderers */ -void ghid_gdk_install(pcb_gtk_common_t *common, pcb_hid_t *hid); -void ghid_gl_install(pcb_gtk_common_t *common, pcb_hid_t *hid); - -/* Utility functions for renderers to call ***/ -void ghid_draw_area_update(GHidPort *out, GdkRectangle *rect); - -static inline void ghid_invalidate_all(pcb_hidlib_t *hidlib) { pcb_gui->invalidate_all(hidlib); } -void ghid_drawing_area_configure_hook(void *out); - -#endif Index: trunk/src_plugins/lib_gtk_hid/lib_gtk_hid.pup =================================================================== --- trunk/src_plugins/lib_gtk_hid/lib_gtk_hid.pup (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/lib_gtk_hid.pup (nonexistent) @@ -1,8 +0,0 @@ -$class lib -$short hid_gtk generic part -$long Generic gtk HID implementation, independent of GTK version (2 vs. 3) and rendering engine. Mostly a dispatcher that fills in all the glue to connect the parts. An actual gtk HID implementation may use this lib or replace parts of it or the whole with local implementation. -$state works -$package lib-gtk -default disable-all -dep lib_hid_common - Index: trunk/src_plugins/lib_gtk_hid/glue_hid.h =================================================================== --- trunk/src_plugins/lib_gtk_hid/glue_hid.h (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/glue_hid.h (nonexistent) @@ -1,6 +0,0 @@ -#include "hid.h" - -void ghid_glue_hid_init(pcb_hid_t *dst); -void gtkhid_do_export(pcb_hidlib_t *hidlib, pcb_hid_attr_val_t *options); -int gtkhid_parse_arguments(int *argc, char ***argv); - Index: trunk/src_plugins/lib_gtk_hid/glue_conf.c =================================================================== --- trunk/src_plugins/lib_gtk_hid/glue_conf.c (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/glue_conf.c (nonexistent) @@ -1,88 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * (this file is based on PCB, interactive printed circuit board design) - * Copyright (C) 1994,1995,1996,1997,1998,1999 Thomas Nau - * pcb-rnd Copyright (C) 2016, 2017 Tibor 'Igor2' Palinkas - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - */ - -#include "config.h" -#include "glue_conf.h" -#include "conf.h" -#include "gui.h" - -static void ghid_confchg_fullscreen(conf_native_t *cfg, int arr_idx) -{ - if (ghidgui->hid_active) - ghid_fullscreen_apply(&ghidgui->topwin); -} - - -void ghid_confchg_checkbox(conf_native_t *cfg, int arr_idx) -{ - if (ghidgui->hid_active) - ghid_update_toggle_flags(&ghidgui->topwin, NULL); -} - -static void ghid_confchg_cli(conf_native_t *cfg, int arr_idx) -{ - ghid_command_update_prompt(&ghidgui->topwin.cmd); -} - -static void ghid_confchg_spec_color(conf_native_t *cfg, int arr_idx) -{ - if (!ghidgui->hid_active) - return; - - if (ghidgui->common.set_special_colors != NULL) - ghidgui->common.set_special_colors(cfg); -} - - - -static void init_conf_watch(conf_hid_callbacks_t *cbs, const char *path, void (*func)(conf_native_t *, int)) -{ - conf_native_t *n = conf_get_field(path); - if (n != NULL) { - memset(cbs, 0, sizeof(conf_hid_callbacks_t)); - cbs->val_change_post = func; - conf_hid_set_cb(n, ghidgui->conf_id, cbs); - } -} - -void ghid_conf_regs(const char *cookie) -{ - static conf_hid_callbacks_t cbs_fullscreen, cbs_cli[2], cbs_color[3]; - - ghidgui->conf_id = conf_hid_reg(cookie, NULL); - - init_conf_watch(&cbs_fullscreen, "editor/fullscreen", ghid_confchg_fullscreen); - - init_conf_watch(&cbs_cli[0], "rc/cli_prompt", ghid_confchg_cli); - init_conf_watch(&cbs_cli[1], "rc/cli_backend", ghid_confchg_cli); - - init_conf_watch(&cbs_color[0], "appearance/color/background", ghid_confchg_spec_color); - init_conf_watch(&cbs_color[1], "appearance/color/off_limit", ghid_confchg_spec_color); - init_conf_watch(&cbs_color[2], "appearance/color/grid", ghid_confchg_spec_color); -} Index: trunk/src_plugins/lib_gtk_hid/Plug.tmpasm =================================================================== --- trunk/src_plugins/lib_gtk_hid/Plug.tmpasm (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/Plug.tmpasm (nonexistent) @@ -1,29 +0,0 @@ -put /local/pcb/mod {lib_gtk_hid} - -put /local/pcb/mod/OBJS [@ - $(PLUGDIR)/lib_gtk_hid/lib_gtk_hid.o -@] - -put /local/pcb/mod/OBJS_C99 [@ - $(PLUGDIR)/lib_gtk_hid/glue_common.o - $(PLUGDIR)/lib_gtk_hid/glue_conf.o - $(PLUGDIR)/lib_gtk_hid/glue_hid.o - $(PLUGDIR)/lib_gtk_hid/glue_win32.o - $(PLUGDIR)/lib_gtk_hid/common.o - $(PLUGDIR)/lib_gtk_hid/render.o -@] - -switch /local/pcb/lib_gtk_hid/controls - case {disable} end; - default - put /local/pcb/mod/CFLAGS /target/libs/gui/gtkx/cflags - put /local/pcb/mod/LDFLAGS /target/libs/gui/gtkx/ldflags - end -end - -switch /local/pcb/lib_gtk_hid/controls - case {buildin} include /local/pcb/tmpasm/buildin; end; - case {plugin} include /local/pcb/tmpasm/plugin; end; - case {disable} include /local/pcb/tmpasm/disable; end; -end - Index: trunk/src_plugins/lib_gtk_hid/glue_conf.h =================================================================== --- trunk/src_plugins/lib_gtk_hid/glue_conf.h (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/glue_conf.h (nonexistent) @@ -1,5 +0,0 @@ -#include "conf.h" - -void ghid_confchg_checkbox(conf_native_t *cfg, int arr_idx); - -void ghid_conf_regs(const char *cookie); Index: trunk/src_plugins/lib_gtk_hid/coord_conv.h =================================================================== --- trunk/src_plugins/lib_gtk_hid/coord_conv.h (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/coord_conv.h (nonexistent) @@ -1,91 +0,0 @@ -/* Coordinate conversions */ -#include "compat_misc.h" -#include "hidlib_conf.h" - -/* Px converts view->pcb, Vx converts pcb->view */ -static inline int Vx(pcb_coord_t x) -{ - double rv; - if (pcbhl_conf.editor.view.flip_x) - rv = (gport->view.com->hidlib->size_x - x - gport->view.x0) / gport->view.coord_per_px + 0.5; - else - rv = (x - gport->view.x0) / gport->view.coord_per_px + 0.5; - return pcb_round(rv); -} - -static inline int Vy(pcb_coord_t y) -{ - double rv; - if (pcbhl_conf.editor.view.flip_y) - rv = (gport->view.com->hidlib->size_y - y - gport->view.y0) / gport->view.coord_per_px + 0.5; - else - rv = (y - gport->view.y0) / gport->view.coord_per_px + 0.5; - return pcb_round(rv); -} - -static inline int Vz(pcb_coord_t z) -{ - return pcb_round((double)z / gport->view.coord_per_px + 0.5); -} - -static inline double Vxd(pcb_coord_t x) -{ - double rv; - if (pcbhl_conf.editor.view.flip_x) - rv = (gport->view.com->hidlib->size_x - x - gport->view.x0) / gport->view.coord_per_px; - else - rv = (x - gport->view.x0) / gport->view.coord_per_px; - return rv; -} - -static inline double Vyd(pcb_coord_t y) -{ - double rv; - if (pcbhl_conf.editor.view.flip_y) - rv = (gport->view.com->hidlib->size_y - y - gport->view.y0) / gport->view.coord_per_px; - else - rv = (y - gport->view.y0) / gport->view.coord_per_px; - return rv; -} - -static inline double Vzd(pcb_coord_t z) -{ - return (double)z / gport->view.coord_per_px; -} - -static inline pcb_coord_t Px(int x) -{ - pcb_coord_t rv = x * gport->view.coord_per_px + gport->view.x0; - if (pcbhl_conf.editor.view.flip_x) - rv = gport->view.com->hidlib->size_x - (x * gport->view.coord_per_px + gport->view.x0); - return rv; -} - -static inline pcb_coord_t Py(int y) -{ - pcb_coord_t rv = y * gport->view.coord_per_px + gport->view.y0; - if (pcbhl_conf.editor.view.flip_y) - rv = gport->view.com->hidlib->size_y - (y * gport->view.coord_per_px + gport->view.y0); - return rv; -} - -static inline pcb_coord_t Pz(int z) -{ - return (z * gport->view.coord_per_px); -} - -/* Return non-zero if box would be rendered into a single dot */ -static inline int pcb_gtk_1dot(pcb_coord_t penwidth, pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2) -{ - double minw = gport->view.coord_per_px; - double dx = PCB_ABS(x1-x2) + penwidth, dy = PCB_ABS(y1-y2) + penwidth; - return ((dx < minw) && (dy < minw)); -} - -/* Return non-zero if dot coords are within canvas extents */ -static inline int pcb_gtk_dot_in_canvas(pcb_coord_t penwidth, double dx1, double dy1) -{ - penwidth/=2; - return ((dx1+penwidth >= 0) && (dx1-penwidth <= gport->view.canvas_width) && (dy1+penwidth >= 0) && (dy1-penwidth <= gport->view.canvas_height)); -} - Index: trunk/src_plugins/lib_gtk_hid/lib_gtk_hid.c =================================================================== --- trunk/src_plugins/lib_gtk_hid/lib_gtk_hid.c (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/lib_gtk_hid.c (nonexistent) @@ -1,48 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 2017 Tibor Palinkas - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - */ - -#include "config.h" - -#include -#include - -#include "plugins.h" - -static const char *lib_gtk_hid_cookie = "lib_gtk_hid"; - -int pplg_check_ver_lib_gtk_hid(int ver_needed) { return 0; } - -void pplg_uninit_lib_gtk_hid(void) -{ -} - -int pplg_init_lib_gtk_hid(void) -{ - PCB_API_CHK_VER; - return 0; -} - Index: trunk/src_plugins/lib_gtk_hid/glue_win32.h =================================================================== --- trunk/src_plugins/lib_gtk_hid/glue_win32.h (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/glue_win32.h (nonexistent) @@ -1,12 +0,0 @@ -/* - * We will need these for finding the windows installation - * directory. Without that we can't find our fonts and - * footprint libraries. - */ -#ifdef WIN32 -#include -#include -#endif - -void ghid_win32_init(void); - Index: trunk/src_plugins/lib_gtk_hid/glue_win32.c =================================================================== --- trunk/src_plugins/lib_gtk_hid/glue_win32.c (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/glue_win32.c (nonexistent) @@ -1,34 +0,0 @@ -#include "config.h" - -#include -#include "glue_win32.h" - -void ghid_win32_init(void) -{ -TODO("Should not use PCB_PACKAGE but pcbhl_app_*"); -#ifdef WIN32 - char *tmps; - char *share_dir; - char *loader_cache; - FILE *loader_file; - - tmps = g_win32_get_package_installation_directory(PCB_PACKAGE "-" PCB_VERSION, NULL); -#define REST_OF_PATH G_DIR_SEPARATOR_S "share" G_DIR_SEPARATOR_S PCB_PACKAGE -#define REST_OF_CACHE G_DIR_SEPARATOR_S "loaders.cache" - share_dir = (char *) malloc(strlen(tmps) + strlen(REST_OF_PATH) + 1); - sprintf(share_dir, "%s%s", tmps, REST_OF_PATH); - - /* Point to our gdk-pixbuf loader cache. */ - loader_cache = (char *) malloc(strlen("bindir_todo12") + strlen(REST_OF_CACHE) + 1); - sprintf(loader_cache, "%s%s", "bindir_todo12", REST_OF_CACHE); - loader_file = fopen(loader_cache, "r"); - if (loader_file) { - fclose(loader_file); - g_setenv("GDK_PIXBUF_MODULE_FILE", loader_cache, TRUE); - } - - free(tmps); -#undef REST_OF_PATH - printf("\"Share\" installation path is \"%s\"\n", "share_dir_todo12"); -#endif -} Index: trunk/src_plugins/lib_gtk_hid/glue_common.c =================================================================== --- trunk/src_plugins/lib_gtk_hid/glue_common.c (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/glue_common.c (nonexistent) @@ -1,143 +0,0 @@ -#include "config.h" - -#include "glue_common.h" - -#include "gui.h" -#include "render.h" -#include "common.h" -#include "hidlib.h" -#include "../src_plugins/lib_gtk_common/dlg_topwin.h" -#include "../src_plugins/lib_gtk_common/hid_gtk_conf.h" - -static void ghid_interface_set_sensitive(gboolean sensitive); - - -/*** drawing widget - output ***/ - -static void ghid_port_ranges_scale(void) -{ - pcb_gtk_tw_ranges_scale(&ghidgui->topwin); -} - -static void ghid_port_ranges_changed(void) -{ - GtkAdjustment *h_adj, *v_adj; - - h_adj = gtk_range_get_adjustment(GTK_RANGE(ghidgui->topwin.h_range)); - v_adj = gtk_range_get_adjustment(GTK_RANGE(ghidgui->topwin.v_range)); - gport->view.x0 = gtk_adjustment_get_value(h_adj); - gport->view.y0 = gtk_adjustment_get_value(v_adj); - - ghid_invalidate_all(ghidgui->common.hidlib); -} - -static void ghid_pan_common(void) -{ - ghidgui->topwin.adjustment_changed_holdoff = TRUE; - gtk_range_set_value(GTK_RANGE(ghidgui->topwin.h_range), gport->view.x0); - gtk_range_set_value(GTK_RANGE(ghidgui->topwin.v_range), gport->view.y0); - ghidgui->topwin.adjustment_changed_holdoff = FALSE; - - ghid_port_ranges_changed(); -} - -int ghid_command_entry_is_active(void) -{ - return ghidgui->topwin.cmd.command_entry_status_line_active; -} - -static void command_post_entry(void) -{ -#if PCB_GTK_DISABLE_MOUSE_DURING_CMD_ENTRY - ghid_interface_input_signals_connect(); -#endif - ghid_interface_set_sensitive(TRUE); - ghid_install_accel_groups(GTK_WINDOW(gport->top_window), &ghidgui->topwin); - gtk_widget_grab_focus(gport->drawing_area); -} - -static void command_pre_entry(void) -{ - ghid_remove_accel_groups(GTK_WINDOW(gport->top_window), &ghidgui->topwin); -#if PCB_GTK_DISABLE_MOUSE_DURING_CMD_ENTRY - ghid_interface_input_signals_disconnect(); -#endif - ghid_interface_set_sensitive(FALSE); -} - -/*** input ***/ - -static void ghid_interface_set_sensitive(gboolean sensitive) -{ - pcb_gtk_tw_interface_set_sensitive(&ghidgui->topwin, sensitive); -} - -static void ghid_port_button_press_main(void) -{ - ghid_invalidate_all(ghidgui->common.hidlib); - if (!gport->view.panning) - g_idle_add(ghid_idle_cb, &ghidgui->topwin); -} - -static void ghid_port_button_release_main(void) -{ - pcb_hidlib_adjust_attached_objects(); - ghid_invalidate_all(ghidgui->common.hidlib); - - g_idle_add(ghid_idle_cb, &ghidgui->topwin); -} - -static void ghid_mode_cursor_main(void) -{ - ghid_mode_cursor(&gport->mouse); -} - -/*** misc ***/ -static void ghid_load_bg_image(void) -{ - GError *err = NULL; - - if (conf_hid_gtk.plugins.hid_gtk.bg_image) - ghidgui->bg_pixbuf = gdk_pixbuf_new_from_file(conf_hid_gtk.plugins.hid_gtk.bg_image, &err); - - if (err) { - g_error("%s", err->message); - g_error_free(err); - } -} - -static void ghid_main_destroy(void *port) -{ - ghidgui->common.shutdown_renderer(port); - gtk_main_quit(); -} - -/*** init ***/ - -void ghid_glue_common_init(void) -{ - /* Set up the glue struct to lib_gtk_common */ - ghidgui->common.gport = &ghid_port; - ghidgui->common.note_event_location = ghid_note_event_location; - ghidgui->common.shift_is_pressed = ghid_shift_is_pressed; - ghidgui->common.interface_input_signals_disconnect = ghid_interface_input_signals_disconnect; - ghidgui->common.interface_input_signals_connect = ghid_interface_input_signals_connect; - ghidgui->common.interface_set_sensitive = ghid_interface_set_sensitive; - ghidgui->common.port_button_press_main = ghid_port_button_press_main; - ghidgui->common.port_button_release_main = ghid_port_button_release_main; - ghidgui->common.mode_cursor_main = ghid_mode_cursor_main; - ghidgui->common.pan_common = ghid_pan_common; - ghidgui->common.port_ranges_scale = ghid_port_ranges_scale; - - ghidgui->common.command_entry_is_active = ghid_command_entry_is_active; - ghidgui->common.load_bg_image = ghid_load_bg_image; - ghidgui->common.main_destroy = ghid_main_destroy; - ghidgui->common.port_ranges_changed = ghid_port_ranges_changed; - - ghidgui->topwin.cmd.com = &ghidgui->common; - ghidgui->topwin.cmd.post_entry = command_post_entry; - ghidgui->topwin.cmd.pre_entry = command_pre_entry; - - ghid_port.view.com = &ghidgui->common; - ghid_port.mouse.com = &ghidgui->common; -} Index: trunk/src_plugins/lib_gtk_hid/common.h =================================================================== --- trunk/src_plugins/lib_gtk_hid/common.h (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/common.h (nonexistent) @@ -1,14 +0,0 @@ -#include "event.h" - -#include "../src_plugins/lib_gtk_common/dlg_topwin.h" - -/* code used by multiple different glue layers */ -void pcb_gtk_tw_ranges_scale(pcb_gtk_topwin_t *tw); -void ghid_note_event_location(GdkEventButton *ev); - -void ghid_interface_input_signals_connect(void); -void ghid_interface_input_signals_disconnect(void); - -int ghid_shift_is_pressed(); -int ghid_control_is_pressed(); -int ghid_mod1_is_pressed(); Index: trunk/src_plugins/lib_gtk_hid/common.c =================================================================== --- trunk/src_plugins/lib_gtk_hid/common.c (revision 26695) +++ trunk/src_plugins/lib_gtk_hid/common.c (nonexistent) @@ -1,146 +0,0 @@ -#include "config.h" - -#include "crosshair.h" - -#include "gui.h" -#include "common.h" - -#include "../src_plugins/lib_gtk_common/dlg_topwin.h" -#include "../src_plugins/lib_gtk_common/in_keyboard.h" -#include "../src_plugins/lib_gtk_common/hid_gtk_conf.h" - -GhidGui _ghidgui, *ghidgui = &_ghidgui; -GHidPort ghid_port, *gport; - -/* Do scrollbar scaling based on current port drawing area size and - | overall PCB board size. - */ -void pcb_gtk_tw_ranges_scale(pcb_gtk_topwin_t *tw) -{ - /* Update the scrollbars with PCB units. So Scale the current - | drawing area size in pixels to PCB units and that will be - | the page size for the Gtk adjustment. - */ - pcb_gtk_zoom_post(&gport->view); - - pcb_gtk_zoom_adjustment(gtk_range_get_adjustment(GTK_RANGE(tw->h_range)), gport->view.width, tw->com->hidlib->size_x); - pcb_gtk_zoom_adjustment(gtk_range_get_adjustment(GTK_RANGE(tw->v_range)), gport->view.height, tw->com->hidlib->size_y); -} - -void ghid_note_event_location(GdkEventButton *ev) -{ - gint event_x, event_y; - - if (!ev) { - gdkc_window_get_pointer(ghid_port.drawing_area, &event_x, &event_y, NULL); - } - else { - event_x = ev->x; - event_y = ev->y; - } - - pcb_gtk_coords_event2pcb(&gport->view, event_x, event_y, &gport->view.pcb_x, &gport->view.pcb_y); - - pcb_hidlib_crosshair_move_to(gport->view.pcb_x, gport->view.pcb_y, 1); -} - -static void kbd_input_signals_connect(int idx, void *obj) -{ - ghidgui->key_press_handler[idx] = g_signal_connect(G_OBJECT(obj), "key_press_event", G_CALLBACK(ghid_port_key_press_cb), &ghid_port.view); - ghidgui->key_release_handler[idx] = g_signal_connect(G_OBJECT(obj), "key_release_event", G_CALLBACK(ghid_port_key_release_cb), &ghidgui->topwin); -} - -static void kbd_input_signals_disconnect(int idx, void *obj) -{ - if (ghidgui->key_press_handler[idx] != 0) { - g_signal_handler_disconnect(G_OBJECT(obj), ghidgui->key_press_handler[idx]); - ghidgui->key_press_handler[idx] = 0; - } - if (ghidgui->key_release_handler[idx] != 0) { - g_signal_handler_disconnect(G_OBJECT(obj), ghidgui->key_release_handler[idx]); - ghidgui->key_release_handler[idx] = 0; - } -} - - /* Connect and disconnect just the signals a g_main_loop() will need. - | Cursor and motion events still need to be handled by the top level - | loop, so don't connect/reconnect these. - | A g_main_loop will be running when PCB wants the user to select a - | location or if command entry is needed in the status line hbox. - | During these times normal button/key presses are intercepted, either - | by new signal handlers or the command_combo_box entry. - */ - -void ghid_interface_input_signals_connect(void) -{ - ghidgui->button_press_handler = g_signal_connect(G_OBJECT(gport->drawing_area), "button_press_event", G_CALLBACK(ghid_port_button_press_cb), &gport->mouse); - ghidgui->button_release_handler = g_signal_connect(G_OBJECT(gport->drawing_area), "button_release_event", G_CALLBACK(ghid_port_button_release_cb), &gport->mouse); - kbd_input_signals_connect(0, gport->drawing_area); - kbd_input_signals_connect(3, ghidgui->topwin.left_toolbar); -} - -void ghid_interface_input_signals_disconnect(void) -{ - kbd_input_signals_disconnect(0, gport->drawing_area); - kbd_input_signals_disconnect(3, ghidgui->topwin.left_toolbar); - - if (ghidgui->button_press_handler != 0) - g_signal_handler_disconnect(G_OBJECT(gport->drawing_area), ghidgui->button_press_handler); - - if (ghidgui->button_release_handler != 0) - g_signal_handler_disconnect(gport->drawing_area, ghidgui->button_release_handler); - - ghidgui->button_press_handler = ghidgui->button_release_handler = 0; -} - -int ghid_shift_is_pressed() -{ - GdkModifierType mask; - GHidPort *out = &ghid_port; - - if (!ghidgui->gui_is_up) - return 0; - - gdkc_window_get_pointer(out->drawing_area, NULL, NULL, &mask); - -#ifdef PCB_WORKAROUND_GTK_SHIFT - /* On some systems the above query fails and we need to return the last known state instead */ - return pcb_gtk_glob_mask & GDK_SHIFT_MASK; -#else - return (mask & GDK_SHIFT_MASK) ? TRUE : FALSE; -#endif -} - -int ghid_control_is_pressed() -{ - GdkModifierType mask; - GHidPort *out = &ghid_port; - - if (!ghidgui->gui_is_up) - return 0; - - gdkc_window_get_pointer(out->drawing_area, NULL, NULL, &mask); - -#ifdef PCB_WORKAROUND_GTK_CTRL - /* On some systems the above query fails and we need to return the last known state instead */ - return pcb_gtk_glob_mask & GDK_CONTROL_MASK; -#else - return (mask & GDK_CONTROL_MASK) ? TRUE : FALSE; -#endif -} - -int ghid_mod1_is_pressed() -{ - GdkModifierType mask; - GHidPort *out = &ghid_port; - - if (!ghidgui->gui_is_up) - return 0; - - gdkc_window_get_pointer(out->drawing_area, NULL, NULL, &mask); -#ifdef __APPLE__ - return (mask & (1 << 13)) ? TRUE : FALSE; /* The option key is not MOD1, although it should be... */ -#else - return (mask & GDK_MOD1_MASK) ? TRUE : FALSE; -#endif -} Index: trunk/src_plugins/plugins_ALL.tmpasm =================================================================== --- trunk/src_plugins/plugins_ALL.tmpasm (revision 26695) +++ trunk/src_plugins/plugins_ALL.tmpasm (revision 26696) @@ -79,7 +79,6 @@ include {../src_plugins/lib_compat_help/Plug.tmpasm} include {../src_plugins/lib_gensexpr/Plug.tmpasm} include {../src_plugins/lib_gtk_common/Plug.tmpasm} -include {../src_plugins/lib_gtk_hid/Plug.tmpasm} include {../src_plugins/lib_hid_common/Plug.tmpasm} include {../src_plugins/lib_hid_gl/Plug.tmpasm} include {../src_plugins/lib_hid_pcbui/Plug.tmpasm}