public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* PluginWindow class and a revamped plug-in sample code
@ 2001-01-31 21:04 Fernando Nasser
  2001-02-02 13:47 ` Tom Tromey
  0 siblings, 1 reply; 6+ messages in thread
From: Fernando Nasser @ 2001-01-31 21:04 UTC (permalink / raw)
  To: Insight List

I found an old Jim Ingham's definition of a PluginWindow class (at least 
someone told me that he wrote it) saying that it should have menu and
tollbar facilities and a running and a stopped methods.  This class
would
be inherited by plug-ins making it easier for the developer.

I added some automatic control of the menus and toolbar buttons (so they
will
be disabled and enabled automatically according to their category) with
code
stolen from the Source Window and here is the result.  

I also revamped the sample code to use this class.


	* library/pluginwin.itcl: New file.  Implements the PluginWindow
	class that provides some basic functionality for plug-ins.
	* library/plugins/rhabout/rhabout.itcl: Inherit from the new
	PluginWindow class.  Remove code dependent on ModalDlg.
	(constructor): Creates menus and a toolbar to show how these
	PluginWindow components are used.
	* library/tclIndex: Regenerate.


-- 
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9
# PluginWindow
# Copyright 2001 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License (GPL) 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.

# ----------------------------------------------------------------------
# Implements a menu and a toolbar that are attached to a source window.
#
#   PUBLIC ATTRIBUTES:
#
#
#   METHODS:
#
#     configure ....... used to change public attributes
#
#   PRIVATE METHODS
#
#   X11 OPTION DATABASE ATTRIBUTES
#
#
# ----------------------------------------------------------------------

class PluginWindow {
  inherit ManagedWin

  # ------------------------------------------------------------------
  #  CONSTRUCTOR - create widget
  # ------------------------------------------------------------------
  constructor {args} {

    # Create a menu widget for the plug-in window
    set menubar [GDBMenuBar $itk_interior.menubar]

    # Create a toolbar widget for the plug-in window
    set toolbar [GDBToolBar $itk_interior.toolbar]

    # Pack the toolbar
    pack $toolbar -expand 1 -fill both

    # Create a frame for the subclass to use
    set child [frame $itk_interior.child]

    # Pack the childsite
    pack $child -expand 1 -fill both

    eval itk_initialize $args
    add_hook gdb_idle_hook "$this stopped"
    add_hook gdb_busy_hook "$this running"
    add_hook gdb_no_inferior_hook "$this no_inferior"
  }

  # ------------------------------------------------------------------
  #  DESTRUCTOR - destroy window containing widget
  # ------------------------------------------------------------------
  destructor {
    remove_hook gdb_idle_hook "$this stopped"
    remove_hook gdb_busy_hook "$this running"
    remove_hook gdb_no_inferior_hook "$this no_inferior"

    #destroy $this
  }

  # ------------------------------------------------------------------
  #  ACCESSOR METHOD - Retrieve childsite
  # ------------------------------------------------------------------
  method childsite {} {
    return $child
  }

  ####################################################################
  #
  # State control methods used by both the menu and the toolbar
  # 
  ####################################################################

  # ------------------------------------------------------------------
  #  METHOD:  stopped
  #             Invoked when there is an inferior and it has stopped
  # ------------------------------------------------------------------
  method stopped {} {
    debug 
    enable_ui 1
  }

  # ------------------------------------------------------------------
  #  METHOD:  running
  #             Invoked when gdb is going to run the inferior
  # ------------------------------------------------------------------
  method running {} {
    debug 
    enable_ui 0
  }

  # ------------------------------------------------------------------
  #  METHOD:  no_inferior
  #             Invoked when gdb detects the inferior is gone 
  # ------------------------------------------------------------------
  method no_inferior {} {
    debug 
    enable_ui 2
  }

  ####################################################################
  # The following method enables/disables both menus and buttons.
  ####################################################################

  # ------------------------------------------------------------------
  # METHOD:  enable_ui - enable/disable the appropriate buttons and menus
  # Called from the busy, idle, and no_inferior hooks.
  #
  # on must be:
  # value      Control    Other     State
  #   0          off       off      gdb is busy
  #   1          on        on       gdb has inferior, and is idle
  #   2          off       on       gdb has no inferior, and is idle
  # ------------------------------------------------------------------
  public method enable_ui {on} {
    global tcl_platform
    debug "$on"

    # Do the enabling so that all the disabling happens first, this way if a
    # button belongs to two groups, enabling takes precedence, which is
    #  probably right.

    switch $on {
      0 {
        # Busy
	set enable_list {Control disabled \
			   Other disabled}
      }
      1 {
        # Idle, with inferior
	set enable_list {Control normal \
			   Other normal}
      }
      2 {
        # Idle, no inferior
	set enable_list {Control disabled \
			   Other normal}
      }
      default {
	debug "Unknown type: $on in enable_ui"
	return
      }
    }

    $menubar set_class_state $enable_list
    $toolbar set_class_state $enable_list
  }

  ####################################################################
  #
  #  PRIVATE DATA
  #
  ####################################################################

  # The childsite
  private variable child

  ####################################################################
  #
  #  PROTECTED DATA
  #
  ####################################################################

  # The GdbMenuBar component
  protected variable menubar

  # The GdbToolBar component
  protected variable toolbar

  ####################################################################
  #
  #  PUBLIC DATA
  #
  ####################################################################

  # None.
}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PluginWindow class and a revamped plug-in sample code
  2001-01-31 21:04 PluginWindow class and a revamped plug-in sample code Fernando Nasser
@ 2001-02-02 13:47 ` Tom Tromey
  2001-02-02 13:58   ` Fernando Nasser
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2001-02-02 13:47 UTC (permalink / raw)
  To: Fernando Nasser; +Cc: Insight List

>>>>> "Fernando" == Fernando Nasser <fnasser@redhat.com> writes:

Fernando> I added some automatic control of the menus and toolbar
Fernando> buttons (so they will be disabled and enabled automatically
Fernando> according to their category) with code stolen from the
Fernando> Source Window and here is the result.

How about introducing a new base class so that both the plugin code
and the source window use the same code, rather than duplicating it?

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PluginWindow class and a revamped plug-in sample code
  2001-02-02 13:47 ` Tom Tromey
@ 2001-02-02 13:58   ` Fernando Nasser
  0 siblings, 0 replies; 6+ messages in thread
From: Fernando Nasser @ 2001-02-02 13:58 UTC (permalink / raw)
  To: tromey; +Cc: Fernando Nasser, Insight List, Keith Seitz

Tom Tromey wrote:
> 
> >>>>> "Fernando" == Fernando Nasser <fnasser@redhat.com> writes:
> 
> Fernando> I added some automatic control of the menus and toolbar
> Fernando> buttons (so they will be disabled and enabled automatically
> Fernando> according to their category) with code stolen from the
> Fernando> Source Window and here is the result.
> 
> How about introducing a new base class so that both the plugin code
> and the source window use the same code, rather than duplicating it?
> 

Keith just suggested the same on a private message last evening.
He is a little more ambitious and want us to get rid of the 
indiscriminate use of hooks by many windows.  So, I guess this
would be a class that would be inherited by many other windows as well.

Sure thing.  I will get a base class out of it and see if I can go
around doing what you guys want.

Maybe I can expand that GDBWin class... What do you think?


-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PluginWindow class and a revamped plug-in sample code
  2001-02-05 10:21 ` Jim Ingham
@ 2001-02-05 10:30   ` Fernando Nasser
  0 siblings, 0 replies; 6+ messages in thread
From: Fernando Nasser @ 2001-02-05 10:30 UTC (permalink / raw)
  To: Jim Ingham; +Cc: insight

Jim Ingham wrote:
> 
> Fernando,
> 
> >
> > Maybe I can expand that GDBWin class... What do you think?
> >
> 
> This is what Martin & I originally intended for that class.  However, as
> you can tell from the paucity of code in it, Martin left before he could
> get around to fleshing it out, and the rest is history...  This sounds
> like a really good idea.
> 

So let's do it.  I can't promise doing it this week as it is a very busy
one around here, but I will tackle it next week.



-- 
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PluginWindow class and a revamped plug-in sample code
       [not found] <981320309.29300.ezmlm@sources.redhat.com>
  2001-02-05 10:21 ` Jim Ingham
@ 2001-02-05 10:26 ` Jim Ingham
  1 sibling, 0 replies; 6+ messages in thread
From: Jim Ingham @ 2001-02-05 10:26 UTC (permalink / raw)
  To: insight

Fernando,

>
> Maybe I can expand that GDBWin class... What do you think?
>
>

This is what Martin & I originally intended for that class.  However, as
you can tell from the paucity of code in it, Martin left before he could
get around to fleshing it out, and the rest is history...  This sounds
like a really good idea.

Jim
--
Jim Ingham                                   jingham@apple.com
Developer Tools - gdb
Apple Computer

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PluginWindow class and a revamped plug-in sample code
       [not found] <981320309.29300.ezmlm@sources.redhat.com>
@ 2001-02-05 10:21 ` Jim Ingham
  2001-02-05 10:30   ` Fernando Nasser
  2001-02-05 10:26 ` Jim Ingham
  1 sibling, 1 reply; 6+ messages in thread
From: Jim Ingham @ 2001-02-05 10:21 UTC (permalink / raw)
  To: insight-digest-help; +Cc: insight

Fernando,

>
> Maybe I can expand that GDBWin class... What do you think?
>

This is what Martin & I originally intended for that class.  However, as 
you can tell from the paucity of code in it, Martin left before he could 
get around to fleshing it out, and the rest is history...  This sounds 
like a really good idea.

Jim
--
Jim Ingham                                   jingham@apple.com
Developer Tools - gdb
Apple Computer

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-02-05 10:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-31 21:04 PluginWindow class and a revamped plug-in sample code Fernando Nasser
2001-02-02 13:47 ` Tom Tromey
2001-02-02 13:58   ` Fernando Nasser
     [not found] <981320309.29300.ezmlm@sources.redhat.com>
2001-02-05 10:21 ` Jim Ingham
2001-02-05 10:30   ` Fernando Nasser
2001-02-05 10:26 ` Jim Ingham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).