Commits

Ali Afshar committed 74b4fdc

proper selectable gadgets

  • Participants
  • Parent commits fe2fa5a

Comments (0)

Files changed (1)

gtkarchitect/view/gadget.py

 from ..controller.command import EntityPropertyChangeCommand
 from .placeholder import Placeholder
 
-class GadgetHolder(gtk.EventBox):
+
+class GadgetEventbox(gtk.EventBox):
+
+    __gtype_name__ = 'ArchitectGadgetEventBox'
+
+
+    def __init__(self):
+        gtk.EventBox.__init__(self)
+        self.set_property('can-focus', True)
+        self.set_above_child(True)
+
+
+
+class GadgetHolder(gtk.Frame):
 
     __gtype_name__ = 'ArchitectGadgetHolder'
 
     gsignal('selected')
 
     def __init__(self):
-        gtk.EventBox.__init__(self)
-        self.set_property('can-focus', True)
-        self.set_above_child(True)
-        self.selected = False
+        gtk.Frame.__init__(self)
+        self.gh = GadgetEventbox()
+        self.gh.connect('button-press-event', self.on_button)
+        self.do_add(self, self.gh)
+        red = gtk.gdk.color_parse("red")
+        self.modify_bg(gtk.STATE_NORMAL, red)
+        self.set_shadow_type(gtk.SHADOW_NONE)
 
-    def do_button_press_event(self, event):
+    def on_button(self, eb, event):
         self.select()
         return True
 
     def select(self):
+        self.set_shadow_type(gtk.SHADOW_IN)
         self.emit('selected')
-        self.selected = True
-        self.drag_highlight()
+
 
     def deselect(self):
-        self.selected = False
-        self.drag_unhighlight()
+        self.set_shadow_type(gtk.SHADOW_NONE)
 
+    def set_above_child(self, above):
+        self.gh.set_above_child(above)
 
-    def do_fiocus_in_event(self, event):
-        self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('red'))
+    def add(self, child):
+        self.gh.add(child)
 
-    def do_fiocus_out_event(self, event):
-        self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('black'))
 
 
 class Gadget(Slave):