Example #1
0
 def __init__(self, par, action):
     self.par = par
     gtk.Table.__init__(self,4,4,False)
     self.actionId = action.getLocalId()
     
     self.radio_url = gtk.RadioButton(None, _("URL:"))
     self.radio_widgetSpaceConstellation = gtk.RadioButton(self.radio_url, _("Widget into Space:"))
     self.radio_view = gtk.RadioButton(self.radio_url, _("Other View:"))
     
     self.entry_url = DefaultEntry(default_message=_("http://www.example.org"))
     self.entry_widget = ObjectCombo(self, 
                                  Widget,
                                  selectFirst=True,
                                  virtualRootObject=action.getActionList().getMenuItem().getMenu().getSite().getSkarphed())
     self.entry_space = SpaceCombo(self,action.getActionList().getMenuItem().getMenu().getSite())
     self.entry_view = ObjectCombo(self, 
                                View,
                                selectFirst=True,
                                virtualRootObject=action.getActionList().getMenuItem().getMenu().getSite().getSkarphed())
     self.entry_url.connect("focus-in-event",self.focusCallback)
     self.entry_widget.connect("popup",self.focusCallback)
     self.entry_widget.connect("changed",self.focusCallback)
     self.entry_space.connect("focus-in-event",self.focusCallback)
     self.entry_view.connect("popup",self.focusCallback)
     self.entry_widget.connect("changed",self.focusCallback)
     
     self.deleteButton = gtk.Button(stock=gtk.STOCK_DELETE)
     self.increaseOrderButton = gtk.Button(stock=gtk.STOCK_GO_UP)
     self.decreaseOrderButton = gtk.Button(stock=gtk.STOCK_GO_DOWN)
     self.saveButton = gtk.Button(stock=gtk.STOCK_SAVE)
     self.deleteButton.connect("clicked", self.deleteCallback)
     self.increaseOrderButton.connect("clicked", self.increaseOrderCallback)
     self.decreaseOrderButton.connect("clicked", self.decreaseOrderCallback)
     self.saveButton.connect("clicked", self.saveCallback)
     
     self.attach(self.radio_url,0,1,0,1)
     self.attach(self.entry_url,1,3,0,1)
     self.attach(self.radio_widgetSpaceConstellation,0,1,1,2)
     self.attach(self.entry_widget,1,2,1,2)
     self.attach(self.entry_space,2,3,1,2)
     self.attach(self.radio_view,0,1,2,3)
     self.attach(self.entry_view,1,3,2,3)
     self.attach(self.deleteButton,0,1,3,4)
     self.attach(self.increaseOrderButton,1,2,3,4)
     self.attach(self.decreaseOrderButton,2,3,3,4)
     self.attach(self.saveButton,3,4,3,4)
     action.addCallback(self.render)
     self.show_all()
     
     self.render()
Example #2
0
    def __init__(self, parent, widget):
        self.par = parent
        gtk.VBox.__init__(self)
        self.widgetId = widget.getLocalId()

        self._menuId = None
        self._orientation = None

        path = os.path.realpath(__file__)
        path = path.replace("widget.pyc","")
        self._path = path.replace("widget.py","")

        self.builder = gtk.Builder()
        self.builder.add_from_file(self._path+"widget.glade")

        handlers = {'save_cb':self.saveCallback}
        self.builder.connect_signals(handlers)

        self.structure_table = self.builder.get_object("structure_table")
        self.content = self.builder.get_object("widget")
        self.menu_selector = ObjectCombo(self, 
                                    Menu,
                                    selectFirst=True,
                                    virtualRootObject=widget.getModule().getModules().getSkarphed().getSites())
        self.structure_table.attach(self.menu_selector,1,2,1,2, gtk.FILL|gtk.SHRINK, gtk.FILL|gtk.SHRINK,0,0)

        self.menu_selector.connect("changed", self.menuChangedCallback)

        self.add(self.content)
        self.loadContent()
Example #3
0
    def __init__(self, parent,  view, spaceId=None, boxId=None, orderNumber=None):
        gtk.Frame.__init__(self)

        self.par = parent
        self.viewId = view.getLocalId()
        self.spaceId = spaceId
        self.boxId = boxId
        self.orderNumber = orderNumber
        self.widgetId = None

        self.vbox = gtk.VBox()
        self.hbox = gtk.HBox(spacing=10)
        self.framelabel = FrameLabel(self,_("Space: "), IconStock.SPACE)
        self.set_label_widget(self.framelabel)
        self.spacelabel = gtk.Label(_("Widget in this Space:"))

        self.widget_combo = ObjectCombo(self, \
                                Widget, \
                                virtualRootObject=view.getViews().getSkarphed().getModules(), \
                                noneElement=True)
        self.widget_combo.connect("changed", self.cb_changed)
        self.expander = gtk.Expander()
        self.expander.set_label_widget(gtk.Label(_("Edit Widget Parameters")))
        self.param_widget = ParamWidget(self, view)
        self.expander.add(self.param_widget)
        self.hbox.pack_start(self.spacelabel,False)
        self.hbox.pack_start(self.widget_combo,False)
        self.vbox.pack_start(self.hbox,False)
        self.vbox.pack_start(self.expander,False)
        self.add(self.vbox)

        self.show_all()
        self.render()
Example #4
0
    def __init__(self, par, view):
        ObjectPageAbstract.__init__(self, par, view)

        self.view = PageFrame(self, _("View"), IconStock.VIEW)
        self.view_hbox = gtk.HBox(spacing=10)
        self.view_label = gtk.Label(_("Name of this View: "))
        self.view_entry = DefaultEntry()
        self.view_entry.set_default_message(_("name_of_view"))
        self.view_hbox.pack_start(self.view_label,False)
        self.view_hbox.pack_start(self.view_entry,True)
        self.view.add(self.view_hbox)
        self.pack_start(self.view, False)

        self.page = PageFrame(self, _("Site"), IconStock.SITE)
        self.page_hbox = gtk.HBox(spacing=10)
        self.page_label = gtk.Label(_("Site to Render: "))
        self.page_combobox = ObjectCombo(self, \
                                Site, \
                                virtualRootObject=view.getViews().getSkarphed().getSites())
        self.page_hbox.pack_start(self.page_label,False)
        self.page_hbox.pack_start(self.page_combobox,False)
        self.page.add(self.page_hbox)
        self.pack_start(self.page,False)

        self.compose = PageFrame(self, _("Compositing"), IconStock.WIDGET)
        self.compose_dummy = gtk.Label()
        self.compose_scroll = gtk.ScrolledWindow()
        self.compose_scroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
        self.compose_vbox = gtk.VBox(spacing=10)
        self.compose_vbox.set_border_width(10)
        self.compose_spacewidgets = {}
        self.compose_boxwidgets = {}
        self.compose_vbox.pack_end(self.compose_dummy,True)
        self.compose_scroll.add_with_viewport(self.compose_vbox)
        self.compose.add(self.compose_scroll)
        self.pack_start(self.compose, True)

        self.saveframe = gtk.HBox()
        self.savedummy = gtk.Label()
        self.savebutton = gtk.Button(stock=gtk.STOCK_SAVE)
        self.saveframe.pack_start(self.savedummy,True)
        self.saveframe.pack_start(self.savebutton,False)
        self.pack_start(self.saveframe, False)

        self.savebutton.connect("clicked", self.saveCallback)
        self.page_combobox.connect("changed", self.changedPageCallback)

        if not view.isFullyLoaded():
            view.loadFull()
        else:
            self.render()
    def __init__(self, par, widget):
        self.par = par
        gtk.Frame.__init__(self)
        self.widgetId = widget.getLocalId()
        self._change_for_render = False

        self.toggle = gtk.CheckButton(_("Automatically generate Views"))
        self.set_label_widget(self.toggle)

        self.table = gtk.Table(3,3,False)
        self.label_view = gtk.Label(_("Baseview:"))
        self.label_space = gtk.Label(_("Targetspace:"))
        self.combo_view = ObjectCombo(self, 
                                     View,
                                     selectFirst=True,
                                     noneElement=True,
                                     virtualRootObject=widget.getModule().getModules().getSkarphed())
        self.combo_space = gtk.ComboBox()
        self.savebutton = gtk.Button(stock=gtk.STOCK_SAVE)
        self.dummy = gtk.Label("")

        self.table.attach(self.label_view,0,1,0,1,gtk.FILL|gtk.SHRINK, gtk.FILL|gtk.SHRINK)
        self.table.attach(self.combo_view,1,2,0,1,gtk.FILL|gtk.SHRINK, gtk.FILL|gtk.SHRINK)
        self.table.attach(self.label_space,0,1,1,2,gtk.FILL|gtk.SHRINK, gtk.FILL|gtk.SHRINK)
        self.table.attach(self.combo_space,1,2,1,2,gtk.FILL|gtk.SHRINK, gtk.FILL|gtk.SHRINK)
        self.table.attach(self.savebutton,1,2,2,3,gtk.FILL|gtk.SHRINK, gtk.FILL|gtk.SHRINK)
        self.table.attach(self.dummy,2,3,0,3,gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND)

        self.combo_view.connect("changed", self.viewChangedCallback)
        self.savebutton.connect("clicked", self.saveCallback)
        self.toggle.connect("toggled", self.toggleCallback)

        self.add(self.table)

        widget.addCallback(self.render)

        self.render()
class ViewGenerationControl(gtk.Frame):
    def __init__(self, par, widget):
        self.par = par
        gtk.Frame.__init__(self)
        self.widgetId = widget.getLocalId()
        self._change_for_render = False

        self.toggle = gtk.CheckButton(_("Automatically generate Views"))
        self.set_label_widget(self.toggle)

        self.table = gtk.Table(3,3,False)
        self.label_view = gtk.Label(_("Baseview:"))
        self.label_space = gtk.Label(_("Targetspace:"))
        self.combo_view = ObjectCombo(self, 
                                     View,
                                     selectFirst=True,
                                     noneElement=True,
                                     virtualRootObject=widget.getModule().getModules().getSkarphed())
        self.combo_space = gtk.ComboBox()
        self.savebutton = gtk.Button(stock=gtk.STOCK_SAVE)
        self.dummy = gtk.Label("")

        self.table.attach(self.label_view,0,1,0,1,gtk.FILL|gtk.SHRINK, gtk.FILL|gtk.SHRINK)
        self.table.attach(self.combo_view,1,2,0,1,gtk.FILL|gtk.SHRINK, gtk.FILL|gtk.SHRINK)
        self.table.attach(self.label_space,0,1,1,2,gtk.FILL|gtk.SHRINK, gtk.FILL|gtk.SHRINK)
        self.table.attach(self.combo_space,1,2,1,2,gtk.FILL|gtk.SHRINK, gtk.FILL|gtk.SHRINK)
        self.table.attach(self.savebutton,1,2,2,3,gtk.FILL|gtk.SHRINK, gtk.FILL|gtk.SHRINK)
        self.table.attach(self.dummy,2,3,0,3,gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND)

        self.combo_view.connect("changed", self.viewChangedCallback)
        self.savebutton.connect("clicked", self.saveCallback)
        self.toggle.connect("toggled", self.toggleCallback)

        self.add(self.table)

        widget.addCallback(self.render)

        self.render()

    def render(self):
        try:
            widget = self.getApplication().getLocalObjectById(self.widgetId)
        except GenericObjectStoreException:
            self.destroy()
            return

        active = widget.isGeneratingViews()
        self._change_for_render = True
        self.toggle.set_active(active)
        self._change_for_render = False
        self.combo_view.set_sensitive(active)
        self.combo_space.set_sensitive(active)
        self.savebutton.set_sensitive(active)

        if active:
            self.combo_view.setSelected(widget.getBaseView())
            try:
                self.combo_space.setSpaceId(widget.getBaseSpaceId())
            except AttributeError: pass
        else:
            self.combo_view.setSelected(None)
            try:
                self.combo_space.setSpaceId(None)
            except AttributeError: pass

    def toggleCallback(self, widget=None, data=None):
        try:
            widget = self.getApplication().getLocalObjectById(self.widgetId)
        except GenericObjectStoreException:
            self.destroy()
            return

        if self._change_for_render:
            self._change_for_render = False
            return

        if not self.toggle.get_active():
            widget.deactivateGeneratingViews()
        else:
            self.combo_view.set_sensitive(True)
            self.combo_space.set_sensitive(True)
            self.savebutton.set_sensitive(True)


    def saveCallback(self, widget=None, data=None):
        try:
            widget = self.getApplication().getLocalObjectById(self.widgetId)
        except GenericObjectStoreException:
            self.destroy()
            return

        widget.activateGeneratingViews(self.combo_view.getSelected(), self.combo_space.getSpaceId())

    def viewChangedCallback(self, widget=None, data=None):
        self.combo_space.destroy()
        view = self.combo_view.getSelected()
        if view is None:
            return

        if not view.isFullyLoaded():
            view.addCallback(self.viewChangedCallback)
            view.loadFull()
            return 
        view.removeCallback(self.viewChangedCallback)

        page = view.getPage()
        self.combo_space = SpaceCombo(self,page)
        self.combo_space.show()
        self.table.attach(self.combo_space,1,2,1,2,gtk.FILL|gtk.SHRINK, gtk.FILL|gtk.SHRINK)


    def getApplication(self):
        return self.getPar().getApplication()

    def getPar(self):
        return self.par
Example #7
0
class ActionWidgetConfig(gtk.Table):
    def __init__(self, par, action):
        self.par = par
        gtk.Table.__init__(self,4,4,False)
        self.actionId = action.getLocalId()
        
        self.radio_url = gtk.RadioButton(None, _("URL:"))
        self.radio_widgetSpaceConstellation = gtk.RadioButton(self.radio_url, _("Widget into Space:"))
        self.radio_view = gtk.RadioButton(self.radio_url, _("Other View:"))
        
        self.entry_url = DefaultEntry(default_message=_("http://www.example.org"))
        self.entry_widget = ObjectCombo(self, 
                                     Widget,
                                     selectFirst=True,
                                     virtualRootObject=action.getActionList().getMenuItem().getMenu().getSite().getSkarphed())
        self.entry_space = SpaceCombo(self,action.getActionList().getMenuItem().getMenu().getSite())
        self.entry_view = ObjectCombo(self, 
                                   View,
                                   selectFirst=True,
                                   virtualRootObject=action.getActionList().getMenuItem().getMenu().getSite().getSkarphed())
        self.entry_url.connect("focus-in-event",self.focusCallback)
        self.entry_widget.connect("popup",self.focusCallback)
        self.entry_widget.connect("changed",self.focusCallback)
        self.entry_space.connect("focus-in-event",self.focusCallback)
        self.entry_view.connect("popup",self.focusCallback)
        self.entry_widget.connect("changed",self.focusCallback)
        
        self.deleteButton = gtk.Button(stock=gtk.STOCK_DELETE)
        self.increaseOrderButton = gtk.Button(stock=gtk.STOCK_GO_UP)
        self.decreaseOrderButton = gtk.Button(stock=gtk.STOCK_GO_DOWN)
        self.saveButton = gtk.Button(stock=gtk.STOCK_SAVE)
        self.deleteButton.connect("clicked", self.deleteCallback)
        self.increaseOrderButton.connect("clicked", self.increaseOrderCallback)
        self.decreaseOrderButton.connect("clicked", self.decreaseOrderCallback)
        self.saveButton.connect("clicked", self.saveCallback)
        
        self.attach(self.radio_url,0,1,0,1)
        self.attach(self.entry_url,1,3,0,1)
        self.attach(self.radio_widgetSpaceConstellation,0,1,1,2)
        self.attach(self.entry_widget,1,2,1,2)
        self.attach(self.entry_space,2,3,1,2)
        self.attach(self.radio_view,0,1,2,3)
        self.attach(self.entry_view,1,3,2,3)
        self.attach(self.deleteButton,0,1,3,4)
        self.attach(self.increaseOrderButton,1,2,3,4)
        self.attach(self.decreaseOrderButton,2,3,3,4)
        self.attach(self.saveButton,3,4,3,4)
        action.addCallback(self.render)
        self.show_all()
        
        self.render()
        
    def render(self):
        try:
            action = self.getApplication().getLocalObjectById(self.actionId)
        except GenericObjectStoreException:
            self.getPar().destroy()
            return
        if action.data['type'] == 'url':
            self.radio_url.set_active(True)
            self.entry_url.set_text(action.data['url'])
        elif action.data['type'] == 'widgetSpaceConstellation':
            self.radio_widgetSpaceConstellation.set_active(True)
            widget=action.getWidget()
            space=action.getSpaceId()
            self.entry_space.setSpaceId(space)
            self.entry_widget.setSelected(widget)
        elif action.data['type'] == 'view':
            self.radio_view.set_active(True)
            view=action.getView()
            self.entry_view.setSelected(view)
    
    def focusCallback(self,widget=None,event=None):
        if widget == self.entry_url:
            self.radio_url.activate()
        elif widget == self.entry_space or widget == self.entry_widget:
            self.radio_widgetSpaceConstellation.activate()
        elif widget == self.entry_view:
            self.radio_view.activate()
        
    
    def deleteCallback(self, widget=None, data=None):
        action = self.getApplication().getLocalObjectById(self.actionId)
        action.getPar().deleteChildAction(action)
    
    def increaseOrderCallback(self, widget=None, data=None):
        action = self.getApplication().getLocalObjectById(self.actionId)
        action.increaseOrder()
        
    def decreaseOrderCallback(self, widget=None, data=None):
        action = self.getApplication().getLocalObjectById(self.actionId)
        action.decreaseOrder()
        
    def saveCallback(self, widget=None,data=None):
        action = self.getApplication().getLocalObjectById(self.actionId)
        if self.radio_url.get_active():
            action.setUrl(self.entry_url.get_text())
        elif self.radio_widgetSpaceConstellation.get_active():
            widget = self.entry_widget.getSelected()
            action.setWidgetSpaceConstellation(widget.getLocalId(),self.entry_space.getSpaceId())
        elif self.radio_view.get_active():
            action.setView(self.entry_view.getSelected().getLocalId())
    
    def getPar(self):
        return self.par

    def getApplication(self):
        return self.par.getApplication()
Example #8
0
class WidgetPage(gtk.VBox):
    HORIZONTALLY = 0
    VERTICALLY = 1

    def __init__(self, parent, widget):
        self.par = parent
        gtk.VBox.__init__(self)
        self.widgetId = widget.getLocalId()

        self._menuId = None
        self._orientation = None

        path = os.path.realpath(__file__)
        path = path.replace("widget.pyc","")
        self._path = path.replace("widget.py","")

        self.builder = gtk.Builder()
        self.builder.add_from_file(self._path+"widget.glade")

        handlers = {'save_cb':self.saveCallback}
        self.builder.connect_signals(handlers)

        self.structure_table = self.builder.get_object("structure_table")
        self.content = self.builder.get_object("widget")
        self.menu_selector = ObjectCombo(self, 
                                    Menu,
                                    selectFirst=True,
                                    virtualRootObject=widget.getModule().getModules().getSkarphed().getSites())
        self.structure_table.attach(self.menu_selector,1,2,1,2, gtk.FILL|gtk.SHRINK, gtk.FILL|gtk.SHRINK,0,0)

        self.menu_selector.connect("changed", self.menuChangedCallback)

        self.add(self.content)
        self.loadContent()

    def render(self):
        try:
            widget = self.getApplication().getLocalObjectById(self.widgetId)
        except GenericObjectStoreException:
            self.destroy()

        if self._menuId is not None:
            pages = widget.getModule().getModules().getSkarphed().getSites()    
            menu = pages.getMenuById(self._menuId)
            self.menu_selector.setSelected(menu)

        if self._orientation == WidgetPage.HORIZONTALLY:
            self.builder.get_object("radio_horizontal").set_active(True)
            self.builder.get_object("radio_vertical").set_active(False)
        else:
            self.builder.get_object("radio_horizontal").set_active(False)
            self.builder.get_object("radio_vertical").set_active(True)

    def menuChangedCallback(self, widget=None, data=None):
        menu = widget.getSelected()
        if menu is not None:
            self._menuId = menu.getId()

    def loadContentCallback(self, data):
        self._menuId = data['menuId']
        self._orientation = data['orientation']
        self.render()

    @module_rpc(loadContentCallback)
    def get_content(self):
        pass

    def loadContent(self):
        self.get_content()

    def setContentCallback(self, data):
        self.loadContent()

    @module_rpc(setContentCallback)
    def set_content(self, menuId, orientation):
        pass

    def saveCallback(self, widget=None, data=None):
        menu = self.menu_selector.getSelected()
        menuId = menu.getId()
        
        if self.builder.get_object("radio_horizontal").get_active():
            orientation = WidgetPage.HORIZONTALLY
        else:
            orientation = WidgetPage.VERTICALLY

        self.set_content(menuId, orientation)        

    def getPar(self):
        return self.par

    def getApplication(self):
        return self.par.getApplication()
Example #9
0
class ViewPage(ObjectPageAbstract):
    def __init__(self, par, view):
        ObjectPageAbstract.__init__(self, par, view)

        self.view = PageFrame(self, _("View"), IconStock.VIEW)
        self.view_hbox = gtk.HBox(spacing=10)
        self.view_label = gtk.Label(_("Name of this View: "))
        self.view_entry = DefaultEntry()
        self.view_entry.set_default_message(_("name_of_view"))
        self.view_hbox.pack_start(self.view_label,False)
        self.view_hbox.pack_start(self.view_entry,True)
        self.view.add(self.view_hbox)
        self.pack_start(self.view, False)

        self.page = PageFrame(self, _("Site"), IconStock.SITE)
        self.page_hbox = gtk.HBox(spacing=10)
        self.page_label = gtk.Label(_("Site to Render: "))
        self.page_combobox = ObjectCombo(self, \
                                Site, \
                                virtualRootObject=view.getViews().getSkarphed().getSites())
        self.page_hbox.pack_start(self.page_label,False)
        self.page_hbox.pack_start(self.page_combobox,False)
        self.page.add(self.page_hbox)
        self.pack_start(self.page,False)

        self.compose = PageFrame(self, _("Compositing"), IconStock.WIDGET)
        self.compose_dummy = gtk.Label()
        self.compose_scroll = gtk.ScrolledWindow()
        self.compose_scroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
        self.compose_vbox = gtk.VBox(spacing=10)
        self.compose_vbox.set_border_width(10)
        self.compose_spacewidgets = {}
        self.compose_boxwidgets = {}
        self.compose_vbox.pack_end(self.compose_dummy,True)
        self.compose_scroll.add_with_viewport(self.compose_vbox)
        self.compose.add(self.compose_scroll)
        self.pack_start(self.compose, True)

        self.saveframe = gtk.HBox()
        self.savedummy = gtk.Label()
        self.savebutton = gtk.Button(stock=gtk.STOCK_SAVE)
        self.saveframe.pack_start(self.savedummy,True)
        self.saveframe.pack_start(self.savebutton,False)
        self.pack_start(self.saveframe, False)

        self.savebutton.connect("clicked", self.saveCallback)
        self.page_combobox.connect("changed", self.changedPageCallback)

        if not view.isFullyLoaded():
            view.loadFull()
        else:
            self.render()

    def render(self):
        view = self.getMyObject()
        if not view:
            return
            
        self.view_entry.set_text(view.data['name'])
        if view.data['default']:
            self.view_entry.set_sensitive(False)
        site = view.getPage()
        if site is not None:
            self.page_combobox.setSelected(site)
            spaces = site.getSpaces()
            processed_spaces = []
            
            boxes = site.getBoxes()
            processed_boxes =  []

            for spaceId, spaceName in spaces.items():
                if self.compose_spacewidgets.has_key(spaceId):
                    self.compose_spacewidgets[spaceId].render()
                else:
                    self.compose_spacewidgets[spaceId] = SpaceWidget(self,view,spaceId=spaceId)
                    self.compose_vbox.pack_start(self.compose_spacewidgets[spaceId],False)
                processed_spaces.append(spaceId)
            for spaceId in self.compose_spacewidgets.keys():
                if spaceId not in processed_spaces:
                    self.compose_spacewidgets[spaceId].destroy()

            for boxId, boxInfo in boxes.items():
                if self.compose_boxwidgets.has_key(boxId):
                    self.compose_boxwidgets[boxId].render()
                else:
                    self.compose_boxwidgets[boxId] = BoxWidget(self, boxId, view)
                    self.compose_vbox.pack_start(self.compose_boxwidgets[boxId],False)
                processed_boxes.append(boxId)
            for boxId in self.compose_boxwidgets.keys():
                if boxId not in processed_boxes:
                    self.compose_boxwidgets[boxId].destroy()

    def saveCallback(self, widget=None, data=None):
        try:
            view = self.getMyObject()
        except GenericObjectStoreException:
            return
        mapping = {}
        used_widgetIds = []
        for spacewidget in self.compose_spacewidgets.values():
            wgt = spacewidget.getWidget()
            if wgt is not None:
                widgetId = wgt.getId()
                if widgetId in used_widgetIds:
                    raise ViewException(ViewException.get_msg(8,wgt.getName()))
                mapping[spacewidget.getSpaceId()]= widgetId
                used_widgetIds.append(widgetId)
        view.changeSpaceWidgetMapping(mapping)
        
        boxmapping = {}
        for boxwidget in self.compose_boxwidgets.values():
            widgets = boxwidget.getWidgets()
            for wgt in widgets:
                widgetId = wgt.getId()
                if widgetId in used_widgetIds:
                    raise ViewException(ViewException.get_msg(8,wgt.getName()))
                if not boxmapping.has_key(boxwidget.getBoxId()):
                    boxmapping[boxwidget.getBoxId()] = []
                boxmapping[boxwidget.getBoxId()].append(widgetId)
                used_widgetIds.append(widgetId)
        view.changeBoxMapping(boxmapping)
            
    def changedPageCallback(self, widget=None, data=None):
        pass
Example #10
0
class SpaceWidget(gtk.Frame):
    def __init__(self, parent,  view, spaceId=None, boxId=None, orderNumber=None):
        gtk.Frame.__init__(self)

        self.par = parent
        self.viewId = view.getLocalId()
        self.spaceId = spaceId
        self.boxId = boxId
        self.orderNumber = orderNumber
        self.widgetId = None

        self.vbox = gtk.VBox()
        self.hbox = gtk.HBox(spacing=10)
        self.framelabel = FrameLabel(self,_("Space: "), IconStock.SPACE)
        self.set_label_widget(self.framelabel)
        self.spacelabel = gtk.Label(_("Widget in this Space:"))

        self.widget_combo = ObjectCombo(self, \
                                Widget, \
                                virtualRootObject=view.getViews().getSkarphed().getModules(), \
                                noneElement=True)
        self.widget_combo.connect("changed", self.cb_changed)
        self.expander = gtk.Expander()
        self.expander.set_label_widget(gtk.Label(_("Edit Widget Parameters")))
        self.param_widget = ParamWidget(self, view)
        self.expander.add(self.param_widget)
        self.hbox.pack_start(self.spacelabel,False)
        self.hbox.pack_start(self.widget_combo,False)
        self.vbox.pack_start(self.hbox,False)
        self.vbox.pack_start(self.expander,False)
        self.add(self.vbox)

        self.show_all()
        self.render()

    def render(self):
        try:
            view = self.getApplication().getLocalObjectById(self.viewId)
        except GenericObjectStoreException:
            self.destroy()
            return
        site = view.getPage()
        if self.spaceId is not None: # In case, this space is a real space
            spaceName = site.getNameOfSpace(self.spaceId)
            self.framelabel.setText(_("Space: ")+spaceName)
            spaceWidgetMapping = view.getSpaceWidgetMapping()
            try:
                widgetId = spaceWidgetMapping[str(self.spaceId)]
            except KeyError:
                widget = None
                widgetId = None
            else:
                widget = view.getViews().getSkarphed().getModules().getWidgetById(widgetId)
        else: #In case this space is only part of a box
            self.framelabel.setText(_("BoxSpace"))
            boxmapping = self.getPar().getPar().getTemporaryBoxContent()
            try:
                widgetId = boxmapping[self.orderNumber]
            except KeyError:
                widget = None
                widgetId = None
            else:
                widget = view.getViews().getSkarphed().getModules().getWidgetById(widgetId)

        self.widgetId = widgetId
        self.widget_combo.setSelected(widget)
        self.param_widget.setWidget(widget)
        self.param_widget.render()
    
    def cb_changed(self, widget=None, data=None):
        if type(self.getPar()) == BoxSpace:
            self.getPar().tempStoreWidgetId()

    def getWidgetId(self):
        widget = self.widget_combo.getSelected()
        if widget is None:
            return None
        else:
            return widget.getId()

    def getWidget(self):
        widget = self.widget_combo.getSelected()
        if widget is None:
            return None
        else:
            return widget

    def getSpaceId(self):
        return self.spaceId

    def getWidgetCombo(self):
        return self.widget_combo

    def getSpaceId(self):
        return self.spaceId

    def getPar(self):
        return self.par

    def getApplication(self):
        return self.par.getApplication()