Hello all,


I have created a subclassed widget that is derived from GtkHBox and contains
a GtkEntry widget and two GtkButtons with GtkArrows on them (the button thing
had been suggested by James earlier on this list to have clickable arrows. Why
dont they have a "clicked" signal anyway? What are they good for without?)

First question: Since the Tooltips mechanism is somewhat external, is there a
mechanism to set a hook function to "forward" tooltips to the GtkEntry widget
when they are being set on the main widget?

Also, the GtkButtons either are very, very small (compressing the arrows to
their minimum size) or a lot wider than the arrows, depending on the EXPAND
flag. I actually would like the arrows to be as high as the entry widget and
the buttons to be as wide as the arrows are at that desired size. How could I
be able to accomplish that?

The widget is appended below. It is meant to contain an arbitrary host name or
host pattern which can then be manipulated with the arrow buttons.

Two very small screen shots which document the arrow size problem are appended
as well.

Suggestions welcome,


Fionn

self.pack_start(i, TRUE, TRUE, 0)

self.pack_start(i, FALSE, FALSE, 0)

class FHostPattern(GtkHBox):

  def __init__(self,text = None):
    GtkHBox.__init__(self)
    self.h     = GtkHBox
    self.e     = GtkEntry()
    self.l     = GtkButton()
    self.r     = GtkButton()
    al         = GtkArrow(ARROW_LEFT, SHADOW_OUT)
    ar         = GtkArrow(ARROW_RIGHT, SHADOW_OUT)
    self.pack_start(self.e, TRUE, TRUE, 0)
    self.l.add(al)
    self.r.add(ar)
    self.l.connect("clicked", self.shift_left)
    self.r.connect("clicked", self.shift_right)
    for i in [self.e, ar, al]:
      i.show()
    for i in [self.l, self.r]:
      i.set_relief(RELIEF_NONE)
      self.pack_start(i, FALSE, FALSE, 0)
      i.show()
    if text:
      self.set_text(text)

    self.get_text     = self.e.get_text
    self.set_editable = self.e.set_editable
    
  #--------------------------------------------------

  def set_text(self,text):
    if text[0] == ".":
      text = "*" + text
    if text[0] == "*":
      self.minshift = self.pos = 1
    else:
      self.minshift = self.pos = 0
    self.parts    = splitfields(text,".")
    self.e.set_text(text)
    self.text     = text
    self.maxshift = len(self.parts) - 1

  #--------------------------------------------------

  def shift_left(self,widget):
    if self.pos and self.pos > self.minshift:
      self.shift(-1)

  #--------------------------------------------------

  def shift(self,off):
    self.pos = self.pos + off
    if self.pos > 0:
      out = joinfields(["*"]+self.parts[self.pos:], ".")
    else:
      out = self.text
    self.e.set_text(out)

  #--------------------------------------------------

  def shift_right(self,widget):
    if self.pos < self.maxshift:
      self.shift(1)

Reply via email to