From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fernando Nasser To: Insight List Subject: Insight plug-ins are born Date: Sun, 28 Jan 2001 11:09:00 -0000 Message-id: <3A746DFF.D7FA1E4@redhat.com> X-SW-Source: 2001-q1/msg00105.html Eray, Jim (was it you?) and some others have asked for a plugin facility that would allow people to add their own custom windows to Insight. Note that these windows are not to be distributed with Insight sources, but downloaded from the authors web site, maybe accompanying some development board or embedded OS or anything else that could benefit from a custom window being added to the standard Insight. I checked in the patch below adding the basic support for a "PlugIn" menu to be conditionally added to the Source Window menu bar. This, of course, is just a first step. I have a sample plug-in directory ready and I am writing the README file explaining how (and in which conditions) one can add a plugin window to Insight. I will also create a PlugIn class for people to inherit from so that their windows fit in more nicely without they having to understand the internals of Insight. This maybe what will take longer. My sample is still a very simple one. I just got the About window and created a plug-in incarnation of it. It only has Tcl code though, and do not call GDB or try to get data from the target. I will write a more complete sample. * library/main.tcl: Add plugin subdirectory, if existent, to auto_path. * library/srcbar.itcl (create_plugin_menu): New method. Create a pull down menu for plugins if there are any for this target configuration. (create_menu_items): Invoke the new method above. -- Fernando Nasser Red Hat Canada Ltd. E-Mail: fnasser@redhat.com 2323 Yonge Street, Suite #300 Toronto, Ontario M4P 2C9 Index: main.tcl =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/library/main.tcl,v retrieving revision 1.1.1.1 diff -c -p -r1.1.1.1 main.tcl *** main.tcl 2000/02/07 00:19:42 1.1.1.1 --- main.tcl 2001/01/28 17:54:56 *************** *** 28,40 **** #set tcl_traceCompile 1 # Add gdb's Tcl library directory to the end of the auto-load search path, if ! # it isn't already on the path: # Note: GDBTK_LIBRARY will be set in tcl_findLibrary before main.tcl is called. if {[info exists auto_path]} { if {[lsearch -exact $auto_path $GDBTK_LIBRARY] < 0} { lappend auto_path $GDBTK_LIBRARY } } # Require the packages we need. Most are loaded already, but this will catch --- 28,48 ---- #set tcl_traceCompile 1 # Add gdb's Tcl library directory to the end of the auto-load search path, if ! # it isn't already on the path. ! # Also, add the plugins directory if it exists. # Note: GDBTK_LIBRARY will be set in tcl_findLibrary before main.tcl is called. + set gdb_plugins "" + if {[info exists auto_path]} { if {[lsearch -exact $auto_path $GDBTK_LIBRARY] < 0} { lappend auto_path $GDBTK_LIBRARY } + # In any case, add the plugins directory if it exists + if {[file exists [file join $GDBTK_LIBRARY plugins]]} { + set gdb_plugins [file join $GDBTK_LIBRARY plugins] + lappend auto_path $gdb_plugins + } } # Require the packages we need. Most are loaded already, but this will catch Index: srcbar.itcl =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/library/srcbar.itcl,v retrieving revision 1.1 diff -c -p -r1.1 srcbar.itcl *** srcbar.itcl 2001/01/25 17:49:22 1.1 --- srcbar.itcl 2001/01/28 17:54:56 *************** class SrcBar { *** 115,120 **** --- 115,122 ---- create_trace_menu } + create_plugin_menu + create_pref_menu create_help_menu *************** class SrcBar { *** 384,389 **** --- 386,410 ---- $Menu menubar_add_menu_command Trace "Tfind Frame..." \ "ManagedWin::open TfindArgs -Type FR" \ -underline 6 -accelerator F + } + + # ------------------------------------------------------------------ + # METHOD: create_plugin_menu - Creates the optional plugin menu + # ------------------------------------------------------------------ + private method create_plugin_menu {} { + global gdb_plugins + + if {$gdb_plugins != ""} { + $Menu menubar_new_menu plugin "PlugIn" 4 + set plugins_available 0 + source [file join $gdb_plugins plugins.tcl] + if {! $plugins_available} { + # No plugins are available for this configuration, + # so remove the menu + debug "No plugins configured, go remove the PlugIn menu..." + $Menu menubar_delete_menu plugin + } + } } # ------------------------------------------------------------------