def __init__(self, par, menu): ObjectPageAbstract.__init__(self, par, menu) self.info = PageFrame(self, _("Name"), IconStock.SITE) self.infobox = gtk.HBox() self.info_labelName = gtk.Label(_("Name:")) self.info_entryName = gtk.Entry() self.info_saveName = gtk.Button(stock=gtk.STOCK_SAVE) self.infobox.pack_start(self.info_labelName, False) self.infobox.pack_start(self.info_entryName, True) self.infobox.pack_start(self.info_saveName, False) self.info_saveName.connect("clicked", self.renameCallback) self.info.add(self.infobox) self.pack_start(self.info, False) self.edit = PageFrame(self, _("Edit Items"), IconStock.MENU) self.editbox = gtk.HPaned() self.edit_left_box = gtk.VBox() self.edit_toolbar = gtk.Toolbar() self.addbutton = gtk.ToolButton() self.addbutton.set_stock_id(gtk.STOCK_ADD) self.addbutton.connect("clicked", self.cb_Add) self.removebutton = gtk.ToolButton() self.removebutton.set_stock_id(gtk.STOCK_REMOVE) self.removebutton.connect("clicked", self.cb_Remove) self.increasebutton = gtk.ToolButton() self.increasebutton.set_stock_id(gtk.STOCK_GO_UP) self.increasebutton.connect("clicked", self.cb_Increase) self.decreasebutton = gtk.ToolButton() self.decreasebutton.set_stock_id(gtk.STOCK_GO_DOWN) self.decreasebutton.connect("clicked", self.cb_Decrease) self.topbutton = gtk.ToolButton() self.topbutton.set_stock_id(gtk.STOCK_GOTO_TOP) self.topbutton.connect("clicked", self.cb_Top) self.bottombutton = gtk.ToolButton() self.bottombutton.set_stock_id(gtk.STOCK_GOTO_BOTTOM) self.bottombutton.connect("clicked", self.cb_Bottom) self.edit_toolbar.add(self.addbutton) self.edit_toolbar.add(self.removebutton) self.edit_toolbar.add(self.increasebutton) self.edit_toolbar.add(self.decreasebutton) self.edit_toolbar.add(self.topbutton) self.edit_toolbar.add(self.bottombutton) self.edit_menutree = MenuItemTree(self, menu) self.edit_right_box = gtk.Frame(_("Actions")) self.actionListItem = None self.edit_left_box.pack_start(self.edit_toolbar, False) self.edit_left_box.pack_start(self.edit_menutree, True) self.editbox.add(self.edit_left_box) self.editbox.add(self.edit_right_box) self.edit.add(self.editbox) self.pack_start(self.edit) self.edit_menutree.connect("cursor-changed", self.menuItemChangeCallback) self.show_all()
def __init__(self, par, menu): ObjectPageAbstract.__init__(self,par,menu) self.info = PageFrame(self, _("Name"), IconStock.SITE) self.infobox = gtk.HBox() self.info_labelName = gtk.Label(_("Name:")) self.info_entryName = gtk.Entry() self.info_saveName = gtk.Button(stock=gtk.STOCK_SAVE) self.infobox.pack_start(self.info_labelName,False) self.infobox.pack_start(self.info_entryName,True) self.infobox.pack_start(self.info_saveName,False) self.info_saveName.connect("clicked",self.renameCallback) self.info.add(self.infobox) self.pack_start(self.info,False) self.edit = PageFrame(self, _("Edit Items"), IconStock.MENU) self.editbox = gtk.HPaned() self.edit_left_box = gtk.VBox() self.edit_toolbar = gtk.Toolbar() self.addbutton=gtk.ToolButton() self.addbutton.set_stock_id(gtk.STOCK_ADD) self.addbutton.connect("clicked", self.cb_Add) self.removebutton=gtk.ToolButton() self.removebutton.set_stock_id(gtk.STOCK_REMOVE) self.removebutton.connect("clicked", self.cb_Remove) self.increasebutton=gtk.ToolButton() self.increasebutton.set_stock_id(gtk.STOCK_GO_UP) self.increasebutton.connect("clicked", self.cb_Increase) self.decreasebutton=gtk.ToolButton() self.decreasebutton.set_stock_id(gtk.STOCK_GO_DOWN) self.decreasebutton.connect("clicked", self.cb_Decrease) self.topbutton=gtk.ToolButton() self.topbutton.set_stock_id(gtk.STOCK_GOTO_TOP) self.topbutton.connect("clicked", self.cb_Top) self.bottombutton=gtk.ToolButton() self.bottombutton.set_stock_id(gtk.STOCK_GOTO_BOTTOM) self.bottombutton.connect("clicked", self.cb_Bottom) self.edit_toolbar.add(self.addbutton) self.edit_toolbar.add(self.removebutton) self.edit_toolbar.add(self.increasebutton) self.edit_toolbar.add(self.decreasebutton) self.edit_toolbar.add(self.topbutton) self.edit_toolbar.add(self.bottombutton) self.edit_menutree = MenuItemTree(self,menu) self.edit_right_box = gtk.Frame(_("Actions")) self.actionListItem = None self.edit_left_box.pack_start(self.edit_toolbar,False) self.edit_left_box.pack_start(self.edit_menutree,True) self.editbox.add(self.edit_left_box) self.editbox.add(self.edit_right_box) self.edit.add(self.editbox) self.pack_start(self.edit) self.edit_menutree.connect("cursor-changed",self.menuItemChangeCallback) self.show_all()
def __init__(self,parent,role): ObjectPageAbstract.__init__(self,parent,role) role.fetchPermissions() self.headline = gtk.Label() self.pack_start(self.headline,False) self.info = PageFrame(self,_("Information"), gui.IconStock.ROLE) self.infobox = gtk.VBox() self.info.add(self.infobox) self.pack_start(self.info,False) self.perm = PageFrame(self,_("Permissions"), gui.IconStock.PERMISSION) self.permbox = gtk.Table(1,2,False) self.permbox.set_row_spacings(10) self.permbox.set_col_spacings(10) self.permbox.set_border_width(10) self.perm_permlabel = FrameLabel(self,_("Please choose the Permissions you want to assign to the user here:"), gui.IconStock.PERMISSION) self.perm_permlistview = gtk.TreeView() self.perm_permlist = gtk.ListStore(int, str,str) self.perm_permlistview.set_model(self.perm_permlist) self.perm_permlist_col_checkbox = gtk.TreeViewColumn('') self.perm_permlist_col_identifier = gtk.TreeViewColumn(_('Permission Identifier')) self.perm_permlist_col_name = gtk.TreeViewColumn(_('Permission Name')) self.perm_permlistview.append_column(self.perm_permlist_col_checkbox) self.perm_permlistview.append_column(self.perm_permlist_col_identifier) self.perm_permlistview.append_column(self.perm_permlist_col_name) self.perm_permlist_renderer_checkbox= gtk.CellRendererToggle() self.perm_permlist_renderer_identifier = gtk.CellRendererText() self.perm_permlist_renderer_name = gtk.CellRendererText() self.perm_permlist_col_checkbox.pack_start(self.perm_permlist_renderer_checkbox) self.perm_permlist_col_identifier.pack_start(self.perm_permlist_renderer_identifier) self.perm_permlist_col_name.pack_start(self.perm_permlist_renderer_name) self.perm_permlist_col_checkbox.add_attribute(self.perm_permlist_renderer_checkbox,'active',0) self.perm_permlist_col_identifier.add_attribute(self.perm_permlist_renderer_identifier,'text',1) self.perm_permlist_col_name.add_attribute(self.perm_permlist_renderer_name,'text',2) self.perm_permlist_renderer_checkbox.set_activatable(True) self.perm_permlist_renderer_checkbox.connect("toggled",self.toggledRight) self.permbox.attach(self.perm_permlabel,0,1,0,1) self.permbox.attach(self.perm_permlistview,0,1,1,2) self.perm.add(self.permbox) self.pack_start(self.perm,False) self.show_all() self.render()
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, opdaemon): PageFrame.__init__(self, par, _("Operation Daemon"), gui.IconStock.OPERATION) self.par = par self.operationdaemonId = opdaemon.getLocalId() self.opdLabel = gtk.Label( _("Control the status of the OperationDaemon here:")) self.opdStatusLabel = gtk.Label(_("Current status:")) self.opdStatusDisplay = gtk.Label("") self.opdStartButton = gtk.Button(_("Start")) self.opdStopButton = gtk.Button(_("Stop")) self.opdRestartButton = gtk.Button(_("Restart")) self.opdRefreshButton = gtk.Button(_("Refresh")) self.opdVBox = gtk.VBox() self.opdLabelBox = gtk.HBox() self.opdStatusBox = gtk.HBox() self.opdButtonBox = gtk.HBox() self.opdLabelBox.pack_start(self.opdLabel, False) self.opdStatusBox.pack_start(self.opdStatusLabel, False) self.opdStatusBox.pack_start(self.opdStatusDisplay, False) self.opdButtonBox.pack_start(self.opdStartButton, False) self.opdButtonBox.pack_start(self.opdStopButton, False) self.opdButtonBox.pack_start(self.opdRestartButton, False) self.opdButtonBox.pack_start(self.opdRefreshButton, False) self.opdVBox.pack_start(self.opdLabelBox, False) self.opdVBox.pack_start(self.opdStatusBox, False) self.opdVBox.pack_start(self.opdButtonBox, False) self.add(self.opdVBox) self.opdStartButton.connect("clicked", self.cb_op, "start") self.opdStopButton.connect("clicked", self.cb_op, "stop") self.opdRestartButton.connect("clicked", self.cb_op, "restart") self.opdRefreshButton.connect("clicked", self.cb_op, "refresh") self.render() opdaemon.addCallback(self.render)
def __init__(self, par, opdaemon): PageFrame.__init__(self, par,_("Operation Daemon"), IconStock.OPERATION) self.par = par self.operationdaemonId = opdaemon.getLocalId() self.opdLabel = gtk.Label(_("Control the status of the OperationDaemon here:")) self.opdStatusLabel = gtk.Label(_("Current status:")) self.opdStatusDisplay = gtk.Label("") self.opdStartButton = gtk.Button(_("Start")) self.opdStopButton = gtk.Button(_("Stop")) self.opdRestartButton = gtk.Button(_("Restart")) self.opdRefreshButton = gtk.Button(_("Refresh")) self.opdVBox = gtk.VBox() self.opdLabelBox = gtk.HBox() self.opdStatusBox = gtk.HBox() self.opdButtonBox = gtk.HBox() self.opdLabelBox.pack_start(self.opdLabel,False) self.opdStatusBox.pack_start(self.opdStatusLabel,False) self.opdStatusBox.pack_start(self.opdStatusDisplay,False) self.opdButtonBox.pack_start(self.opdStartButton,False) self.opdButtonBox.pack_start(self.opdStopButton,False) self.opdButtonBox.pack_start(self.opdRestartButton,False) self.opdButtonBox.pack_start(self.opdRefreshButton,False) self.opdVBox.pack_start(self.opdLabelBox,False) self.opdVBox.pack_start(self.opdStatusBox,False) self.opdVBox.pack_start(self.opdButtonBox,False) self.add(self.opdVBox) self.opdStartButton.connect("clicked",self.cb_op, "start") self.opdStopButton.connect("clicked",self.cb_op, "stop") self.opdRestartButton.connect("clicked",self.cb_op, "restart") self.opdRefreshButton.connect("clicked",self.cb_op, "refresh") self.render() opdaemon.addCallback(self.render)
def __init__(self, par, view): ObjectPageAbstract.__init__(self, par, view) self.view = PageFrame(self, _("View"), 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"), 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"), 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()
class MenuPage(ObjectPageAbstract): def __init__(self, par, menu): ObjectPageAbstract.__init__(self, par, menu) self.info = PageFrame(self, _("Name"), IconStock.SITE) self.infobox = gtk.HBox() self.info_labelName = gtk.Label(_("Name:")) self.info_entryName = gtk.Entry() self.info_saveName = gtk.Button(stock=gtk.STOCK_SAVE) self.infobox.pack_start(self.info_labelName, False) self.infobox.pack_start(self.info_entryName, True) self.infobox.pack_start(self.info_saveName, False) self.info_saveName.connect("clicked", self.renameCallback) self.info.add(self.infobox) self.pack_start(self.info, False) self.edit = PageFrame(self, _("Edit Items"), IconStock.MENU) self.editbox = gtk.HPaned() self.edit_left_box = gtk.VBox() self.edit_toolbar = gtk.Toolbar() self.addbutton = gtk.ToolButton() self.addbutton.set_stock_id(gtk.STOCK_ADD) self.addbutton.connect("clicked", self.cb_Add) self.removebutton = gtk.ToolButton() self.removebutton.set_stock_id(gtk.STOCK_REMOVE) self.removebutton.connect("clicked", self.cb_Remove) self.increasebutton = gtk.ToolButton() self.increasebutton.set_stock_id(gtk.STOCK_GO_UP) self.increasebutton.connect("clicked", self.cb_Increase) self.decreasebutton = gtk.ToolButton() self.decreasebutton.set_stock_id(gtk.STOCK_GO_DOWN) self.decreasebutton.connect("clicked", self.cb_Decrease) self.topbutton = gtk.ToolButton() self.topbutton.set_stock_id(gtk.STOCK_GOTO_TOP) self.topbutton.connect("clicked", self.cb_Top) self.bottombutton = gtk.ToolButton() self.bottombutton.set_stock_id(gtk.STOCK_GOTO_BOTTOM) self.bottombutton.connect("clicked", self.cb_Bottom) self.edit_toolbar.add(self.addbutton) self.edit_toolbar.add(self.removebutton) self.edit_toolbar.add(self.increasebutton) self.edit_toolbar.add(self.decreasebutton) self.edit_toolbar.add(self.topbutton) self.edit_toolbar.add(self.bottombutton) self.edit_menutree = MenuItemTree(self, menu) self.edit_right_box = gtk.Frame(_("Actions")) self.actionListItem = None self.edit_left_box.pack_start(self.edit_toolbar, False) self.edit_left_box.pack_start(self.edit_menutree, True) self.editbox.add(self.edit_left_box) self.editbox.add(self.edit_right_box) self.edit.add(self.editbox) self.pack_start(self.edit) self.edit_menutree.connect("cursor-changed", self.menuItemChangeCallback) self.show_all() def render(self): menu = self.getMyObject() if not menu: return self.info_labelName.set_text(menu.getName()) def renameCallback(self, widget=None, data=None): menu = self.getMyObject() if not menu: return menu.rename(self.info_entryName.get_text()) def menuItemChangeCallback(self, *args, **kwargs): self.addbutton.set_sensitive(False) self.removebutton.set_sensitive(False) self.increasebutton.set_sensitive(False) self.decreasebutton.set_sensitive(False) self.topbutton.set_sensitive(False) self.bottombutton.set_sensitive(False) try: obj = self.edit_menutree.getSelectedMenuItem() except TypeError: return if obj.__class__.__name__ == 'MenuItem': self.addbutton.set_sensitive(True) self.removebutton.set_sensitive(True) self.increasebutton.set_sensitive(True) self.decreasebutton.set_sensitive(True) self.topbutton.set_sensitive(True) self.bottombutton.set_sensitive(True) self.showActionList(obj.getActionList()) elif obj.__class__.__name__ == 'Menu': self.addbutton.set_sensitive(True) def cb_Add(self, widget=None, data=None): self.edit_menutree.getSelectedMenuItem().createMenuItem() def cb_Remove(self, widget=None, data=None): item = self.edit_menutree.getSelectedMenuItem() item.getPar().deleteMenuItem(item) def cb_Increase(self, widget=None, data=None): self.edit_menutree.getSelectedMenuItem().increaseOrder() def cb_Decrease(self, widget=None, data=None): self.edit_menutree.getSelectedMenuItem().decreaseOrder() def cb_Top(self, widget=None, data=None): self.edit_menutree.getSelectedMenuItem().moveToTop() def cb_Bottom(self, widget=None, data=None): self.edit_menutree.getSelectedMenuItem().moveToBottom() def showActionList(self, actionList): if self.actionListItem is not None: self.actionListItem.destroy() self.actionListItem = ActionListWidget(self, actionList) self.edit_right_box.add(self.actionListItem) def getPar(self): return self.par def getApplication(self): return self.par.getApplication()
def __init__(self,par,user): ObjectPageAbstract.__init__(self,par,user) user.fetchRightsData() user.fetchRoleData() self.headline = gtk.Label() self.pack_start(self.headline,False) self.info = PageFrame(self,_("Information"), gui.IconStock.USER) self.infobox = gtk.VBox() self.info.add(self.infobox) self.pack_start(self.info,False) self.perm = PageFrame(self,_("Permissions / Roles"), gui.IconStock.ROLE) self.permbox = gtk.Table(2,2,False) self.permbox.set_row_spacings(10) self.permbox.set_col_spacings(10) self.permbox.set_border_width(10) self.perm_permlabel = FrameLabel(self,_("Please choose the Permissions you want to assign to the user here:"),gui.IconStock.PERMISSION) self.perm_rolelabel = FrameLabel(self,_("Please choose the Rights you want to assign to the user here:"),gui.IconStock.ROLE) self.perm_permlistview = gtk.TreeView() self.perm_permlist = gtk.ListStore(int, str,str) self.perm_permlistview.set_model(self.perm_permlist) self.perm_permlist_col_checkbox = gtk.TreeViewColumn('') self.perm_permlist_col_identifier = gtk.TreeViewColumn(_('Permission Identifier')) self.perm_permlist_col_name = gtk.TreeViewColumn(_('Permission Name')) self.perm_permlistview.append_column(self.perm_permlist_col_checkbox) self.perm_permlistview.append_column(self.perm_permlist_col_identifier) self.perm_permlistview.append_column(self.perm_permlist_col_name) self.perm_permlist_renderer_checkbox= gtk.CellRendererToggle() self.perm_permlist_renderer_identifier = gtk.CellRendererText() self.perm_permlist_renderer_name = gtk.CellRendererText() self.perm_permlist_col_checkbox.pack_start(self.perm_permlist_renderer_checkbox) self.perm_permlist_col_identifier.pack_start(self.perm_permlist_renderer_identifier) self.perm_permlist_col_name.pack_start(self.perm_permlist_renderer_name) self.perm_permlist_col_checkbox.add_attribute(self.perm_permlist_renderer_checkbox,'active',0) self.perm_permlist_col_identifier.add_attribute(self.perm_permlist_renderer_identifier,'text',1) self.perm_permlist_col_name.add_attribute(self.perm_permlist_renderer_name,'text',2) self.perm_permlist_renderer_checkbox.set_activatable(True) self.perm_permlist_renderer_checkbox.connect("toggled",self.toggledRight) self.perm_rolelistview = gtk.TreeView() self.perm_rolelist = gtk.ListStore(int, str,str,int) self.perm_rolelistview.set_model(self.perm_rolelist) self.perm_rolelist_col_checkbox = gtk.TreeViewColumn('') self.perm_rolelist_col_identifier = gtk.TreeViewColumn(_('Role Identifier')) self.perm_rolelist_col_name = gtk.TreeViewColumn(_('RoleName')) self.perm_rolelistview.append_column(self.perm_rolelist_col_checkbox) self.perm_rolelistview.append_column(self.perm_rolelist_col_identifier) self.perm_rolelistview.append_column(self.perm_rolelist_col_name) self.perm_rolelist_renderer_checkbox= gtk.CellRendererToggle() self.perm_rolelist_renderer_identifier = gtk.CellRendererText() self.perm_rolelist_renderer_name = gtk.CellRendererText() self.perm_rolelist_col_checkbox.pack_start(self.perm_rolelist_renderer_checkbox) self.perm_rolelist_col_identifier.pack_start(self.perm_rolelist_renderer_identifier) self.perm_rolelist_col_name.pack_start(self.perm_rolelist_renderer_name) self.perm_rolelist_col_checkbox.add_attribute(self.perm_rolelist_renderer_checkbox,'active',0) self.perm_rolelist_col_identifier.add_attribute(self.perm_rolelist_renderer_identifier,'text',1) self.perm_rolelist_col_name.add_attribute(self.perm_rolelist_renderer_name,'text',2) self.perm_rolelist_renderer_checkbox.set_activatable(True) self.perm_rolelist_renderer_checkbox.connect("toggled",self.toggledRole) self.permbox.attach(self.perm_permlabel,0,1,0,1) self.permbox.attach(self.perm_permlistview,0,1,1,2) self.permbox.attach(self.perm_rolelabel,1,2,0,1) self.permbox.attach(self.perm_rolelistview,1,2,1,2) self.perm.add(self.permbox) self.pack_start(self.perm,False) self.alterpw = PageFrame(self, _("Alter Password"), gui.IconStock.CREDENTIAL) self.alterpwhbox = gtk.HBox() self.alterpwdummy = gtk.Label("") self.alterpwbox = gtk.Table(2,4,False) self.alterpwbox.set_row_spacings(10) self.alterpwbox.set_col_spacings(10) self.alterpwbox.set_border_width(10) self.alterpw_oldpw_label = gtk.Label(_("Old Password:"******"New Password:"******"Repeat Password:"******"●") self.alterpw_oldpw_entry.set_visibility(False) self.alterpw_newpw1_entry = gtk.Entry() self.alterpw_newpw1_entry.set_invisible_char("●") self.alterpw_newpw1_entry.set_visibility(False) self.alterpw_newpw2_entry = gtk.Entry() self.alterpw_newpw2_entry.set_invisible_char("●") self.alterpw_newpw2_entry.set_visibility(False) self.alterpw_ok = gtk.Button(_("Alter Password")) self.alterpwbox.attach(self.alterpw_oldpw_label,0,1,0,1) self.alterpwbox.attach(self.alterpw_oldpw_entry,1,2,0,1) self.alterpwbox.attach(self.alterpw_newpw1_label,0,1,1,2) self.alterpwbox.attach(self.alterpw_newpw1_entry,1,2,1,2) self.alterpwbox.attach(self.alterpw_newpw2_label,0,1,2,3) self.alterpwbox.attach(self.alterpw_newpw2_entry,1,2,2,3) self.alterpwbox.attach(self.alterpw_ok,1,2,3,4) self.alterpwhbox.pack_start(self.alterpwbox,False) self.alterpwhbox.pack_start(self.alterpwdummy,True) self.alterpw.add(self.alterpwhbox) self.alterpw_ok.connect("clicked", self.alterPassword) self.pack_start(self.alterpw,False) self.show_all() self.render()
class SkarphedPage(ObjectPageAbstract): RENDER_PURE = 0 RENDER_AJAX = 1 def __init__(self,par,skarphed): ObjectPageAbstract.__init__(self,par,skarphed) self.headline = gtk.Label(_("Skarphed Instance")) self.pack_start(self.headline,False) self.repo = PageFrame(self,_("Repository"), gui.IconStock.REPO) self.repoDummy = gtk.Label("") self.repoHBox = gtk.HBox() self.repotable = gtk.Table(2,3) self.repoLabel = gtk.Label(_("Repository")) self.repoEntry = DefaultEntry(default_message=_("example_repo.org:80")) self.repoInfoLabel = gtk.Label(_("Please enter Repository URL here:")) self.repoOkButton = gtk.Button(stock=gtk.STOCK_OK) self.repoOkButton.connect("clicked", self.cb_changeRepo) self.repotable.attach(self.repoInfoLabel,0,2,0,1) self.repotable.attach(self.repoLabel,0,1,1,2) self.repotable.attach(self.repoEntry,1,2,1,2) self.repotable.attach(self.repoOkButton,1,2,2,3) self.repoHBox.pack_start(self.repotable,False) self.repoHBox.pack_start(self.repoDummy,True) self.repo.add(self.repoHBox) self.pack_start(self.repo,False) self.opd = OperationDaemonControl(self,skarphed.getOperationDaemon()) self.pack_start(self.opd,False) self.pki = PageFrame(self, _("Public Key"), gui.IconStock.CREDENTIAL) self.pki_label = gtk.Label(_("Instance Public Key:")) self.pki_textview = gtk.TextView() self.pki_textbuffer = gtk.TextBuffer() self.pki_textview.set_buffer(self.pki_textbuffer) self.pki_vbox = gtk.VBox() self.pki_vbox.pack_start(self.pki_label,False) self.pki_vbox.pack_start(self.pki_textview,True) self.pki.add(self.pki_vbox) self.pack_start(self.pki, False) self.settings = PageFrame(self, _("Server Settings"), gui.IconStock.SKARPHED) self.settings_vbox = gtk.VBox() self.settings_maintenance_toggle_lock = False self.settings_maintenance_hbox = gtk.HBox() self.settings_maintenance_checkbox = gtk.CheckButton(label=_("Maintenancemode active")) self.settings_maintenance_dummy = gtk.Label() self.settings_maintenance_hbox.pack_start(self.settings_maintenance_checkbox,False) self.settings_maintenance_hbox.pack_start(self.settings_maintenance_dummy,True) self.settings_maintenance_checkbox.connect("toggled", self.cb_maintenance) self.settings_vbox.pack_start(self.settings_maintenance_hbox,False) self.settings_rendermode_toggle_lock = False self.settings_rendermode_table = gtk.Table(2,2,False) self.settings_rendermode_pure = gtk.RadioButton(label=_("Pure (only static HTML)")) self.settings_rendermode_ajax = gtk.RadioButton(group=self.settings_rendermode_pure,label=_("AJAX (requires JS)")) self.settings_rendermode_dummy = gtk.Label("") self.settings_rendermode_pure.connect("toggled", self.cb_rendermode, SkarphedPage.RENDER_PURE) self.settings_rendermode_ajax.connect("toggled", self.cb_rendermode, SkarphedPage.RENDER_AJAX) self.settings_rendermode_table.attach(self.settings_rendermode_pure,0,1,0,1,gtk.FILL|gtk.SHRINK,gtk.FILL|gtk.SHRINK) self.settings_rendermode_table.attach(self.settings_rendermode_ajax,0,1,1,2,gtk.FILL|gtk.SHRINK,gtk.FILL|gtk.SHRINK) self.settings_rendermode_table.attach(self.settings_rendermode_dummy,1,2,0,2,gtk.FILL|gtk.EXPAND,gtk.FILL|gtk.EXPAND) self.settings_vbox.pack_start(self.settings_rendermode_table,False) self.settings.add(self.settings_vbox) self.pack_start(self.settings,False) self.show_all() self.render() def render(self): skarphed = self.getMyObject() if not skarphed: return self.repoEntry.set_text(skarphed.getRepoURL()) public_key = skarphed.getPublicKey() if public_key is not None: self.pki_textbuffer.set_text(public_key) else: self.pki_textbuffer.set_text("") self.settings_maintenance_toggle_lock = True self.settings_maintenance_checkbox.set_active(skarphed.isMaintenanceMode()) self.settings_maintenance_toggle_lock = False rendermode = skarphed.getRendermode() if rendermode is not None: self.settings_rendermode_toggle_lock = True self.settings_rendermode_pure.set_active(rendermode == "pure") self.settings_rendermode_toggle_lock = True self.settings_rendermode_ajax.set_active(rendermode == "ajax") def cb_maintenance(self,widget=None,data=None): if self.settings_maintenance_toggle_lock: self.settings_maintenance_toggle_lock = False return skarphed = self.getMyObject() if not skarphed: self.destroy() return state = self.settings_maintenance_checkbox.get_active() skarphed.setMaintenanceMode(state) def cb_rendermode(self,widget=None,data=None): if self.settings_rendermode_toggle_lock: self.settings_rendermode_toggle_lock = False return skarphed = self.getMyObject() if not skarphed: self.destroy() return rendermode = skarphed.getRendermode() if data == SkarphedPage.RENDER_PURE and rendermode != "pure": skarphed.setRendermode("pure") if data == SkarphedPage.RENDER_AJAX and rendermode != "ajax": skarphed.setRendermode("ajax") def cb_changeRepo(self, widget=None, data=None): skarphed = self.getMyObject() if not skarphed: return repostring = self.repoEntry.get_text() skarphed.setRepository(repostring)
class TemplatePage(ObjectPageAbstract): def __init__(self, parent, template): ObjectPageAbstract.__init__(self, parent, template) self.headline = gtk.Label() self.pack_start(self.headline, False) self.info = PageFrame(self, _("Currently Installed"), gui.IconStock.TEMPLATE) self.infobox = gtk.VBox() self.info_table = gtk.Table(2, 3, False) self.info_labelName = gtk.Label(_("Name:")) self.info_labelDescription = gtk.Label(_("Description:")) self.info_labelAuthor = gtk.Label(_("Author:")) self.info_displayName = gtk.Label() self.info_displayDescription = gtk.Label() self.info_displayAuthor = gtk.Label() self.info_table.attach(self.info_labelName, 0, 1, 0, 1) self.info_table.attach(self.info_displayName, 1, 2, 0, 1) self.info_table.attach(self.info_labelDescription, 0, 1, 1, 2) self.info_table.attach(self.info_displayDescription, 1, 2, 1, 2) self.info_table.attach(self.info_labelAuthor, 0, 1, 2, 3) self.info_table.attach(self.info_displayAuthor, 1, 2, 2, 3) self.infobox.pack_start(self.info_table, False) self.info.add(self.infobox) self.pack_start(self.info, False) self.upload = PageFrame(self, _("Upload new Template"), gui.IconStock.TEMPLATE) self.uploadbox = gtk.HBox() self.uploadbox.set_border_width(10) self.upload_label = gtk.Label( _("Please choose the template and click OK")) self.upload_filechoose = gtk.FileChooserButton("Select Template", None) self.upload_filechoose.connect("file-set", self.fileChosen) self.upload_filechoose.set_size_request(200, 30) self.upload_enter = gtk.Button(stock=gtk.STOCK_OK) self.upload_enter.connect("clicked", self.uploadTemplate) self.upload_dummy = gtk.Label("") self.uploadbox.pack_start(self.upload_label, False) self.uploadbox.pack_start(self.upload_filechoose, False) self.uploadbox.pack_start(self.upload_enter, False) self.uploadbox.pack_start(self.upload_dummy, True) self.upload.add(self.uploadbox) self.pack_start(self.upload, False) self.repo = PageFrame(self, _("Install Template from Repository"), gui.IconStock.TEMPLATE) self.repoVBox = gtk.VBox() self.repoButtonbox = gtk.HBox() self.repoDummy = gtk.Label("") self.repoInstallButton = gtk.Button(_("Install")) self.repoRefreshButton = gtk.Button(stock=gtk.STOCK_REFRESH) self.repostore = gtk.ListStore(gtk.gdk.Pixbuf, str, str, str, int) self.repotree = gtk.TreeView() self.repotree.set_model(self.repostore) self.reposcroll = gtk.ScrolledWindow() self.reposcroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.repocol_name = gtk.TreeViewColumn(_("Template")) self.repocol_description = gtk.TreeViewColumn(_("Description")) self.repocol_author = gtk.TreeViewColumn(_("Author")) self.reporen_icon = gtk.CellRendererPixbuf() self.reporen_name = gtk.CellRendererText() self.reporen_description = gtk.CellRendererText() self.reporen_author = gtk.CellRendererText() self.repocol_name.pack_start(self.reporen_icon, False) self.repocol_name.pack_start(self.reporen_name, False) self.repocol_description.pack_start(self.reporen_description, True) self.repocol_author.pack_start(self.reporen_author, False) self.repocol_name.add_attribute(self.reporen_icon, 'pixbuf', 0) self.repocol_name.add_attribute(self.reporen_name, 'text', 1) self.repocol_description.add_attribute(self.reporen_description, 'text', 2) self.repocol_author.add_attribute(self.reporen_author, 'text', 3) self.repotree.append_column(self.repocol_name) self.repotree.append_column(self.repocol_description) self.repotree.append_column(self.repocol_author) self.repotree.connect("row-activated", self.installRowCallback) self.reposcroll.add(self.repotree) self.repoButtonbox.pack_start(self.repoDummy, True) self.repoButtonbox.pack_start(self.repoRefreshButton, False) self.repoButtonbox.pack_start(self.repoInstallButton, False) self.repoVBox.pack_start(self.reposcroll, True) self.repoVBox.pack_start(self.repoButtonbox, False) self.repoRefreshButton.connect("clicked", self.refreshAvailableTemplates) self.repoInstallButton.connect("clicked", self.installButtonCallback) self.repo.add(self.repoVBox) self.pack_start(self.repo) self.show_all() self.render() def render(self): template = self.getMyObject() if not template: return self.info_displayName.set_text(template.data['name']) self.info_displayDescription.set_text(template.data['description']) self.info_displayAuthor.set_text(template.data['author']) self.repostore.clear() for available_template in template.getAvailableTemplates(): self.repostore.append( (gui.IconStock.TEMPLATE, available_template['name'], available_template['description'], available_template['author'], available_template['id'])) def fileChosen(self, widget=None, data=None): self.fileToUpload = widget.get_filename() def uploadTemplate(self, widget=None, data=None): template = self.getMyObject() if not template: return if self.fileToUpload is not None and self.fileToUpload != "": template.upload(self.fileToUpload) else: raise Exception(_("No File specified")) def installRowCallback(self, treeview=None, iter=None, path=None, data=None): template = self.getMyObject() if not template: return selection = self.repotree.get_selection() rowiter = selection.get_selected()[1] if rowiter is None: raise TemplatePageException( _("You must select a Template to install it")) nr = self.repostore.get_value(rowiter, 4) template.installFromRepo(nr) def installButtonCallback(self, widget=None, data=None): self.installRowCallback() def refreshAvailableTemplates(self, widget=None, data=None): template = self.getMyObject() if not template: return template.getRepoTemplates()
class ViewPage(ObjectPageAbstract): def __init__(self, par, view): ObjectPageAbstract.__init__(self, par, view) self.view = PageFrame(self, _("View"), 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"), 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"), 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.setSpaceWidgetMapping(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.setBoxMapping(boxmapping) def changedPageCallback(self, widget=None, data=None): pass
class ViewPage(ObjectPageAbstract): def __init__(self, par, view): ObjectPageAbstract.__init__(self, par, view) self.view = PageFrame(self, _("View"), 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"), 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"), 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.setSpaceWidgetMapping(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.setBoxMapping(boxmapping) def changedPageCallback(self, widget=None, data=None): pass
class RolePage(ObjectPageAbstract): def __init__(self, parent, role): ObjectPageAbstract.__init__(self, parent, role) role.fetchPermissions() self.headline = gtk.Label() self.pack_start(self.headline, False) self.info = PageFrame(self, _("Information"), gui.IconStock.ROLE) self.infobox = gtk.VBox() self.info.add(self.infobox) self.pack_start(self.info, False) self.perm = PageFrame(self, _("Permissions"), gui.IconStock.PERMISSION) self.permbox = gtk.Table(1, 2, False) self.permbox.set_row_spacings(10) self.permbox.set_col_spacings(10) self.permbox.set_border_width(10) self.perm_permlabel = FrameLabel( self, _("Please choose the Permissions you want to assign to the user here:" ), gui.IconStock.PERMISSION) self.perm_permlistview = gtk.TreeView() self.perm_permlist = gtk.ListStore(int, str, str) self.perm_permlistview.set_model(self.perm_permlist) self.perm_permlist_col_checkbox = gtk.TreeViewColumn('') self.perm_permlist_col_identifier = gtk.TreeViewColumn( _('Permission Identifier')) self.perm_permlist_col_name = gtk.TreeViewColumn(_('Permission Name')) self.perm_permlistview.append_column(self.perm_permlist_col_checkbox) self.perm_permlistview.append_column(self.perm_permlist_col_identifier) self.perm_permlistview.append_column(self.perm_permlist_col_name) self.perm_permlist_renderer_checkbox = gtk.CellRendererToggle() self.perm_permlist_renderer_identifier = gtk.CellRendererText() self.perm_permlist_renderer_name = gtk.CellRendererText() self.perm_permlist_col_checkbox.pack_start( self.perm_permlist_renderer_checkbox) self.perm_permlist_col_identifier.pack_start( self.perm_permlist_renderer_identifier) self.perm_permlist_col_name.pack_start( self.perm_permlist_renderer_name) self.perm_permlist_col_checkbox.add_attribute( self.perm_permlist_renderer_checkbox, 'active', 0) self.perm_permlist_col_identifier.add_attribute( self.perm_permlist_renderer_identifier, 'text', 1) self.perm_permlist_col_name.add_attribute( self.perm_permlist_renderer_name, 'text', 2) self.perm_permlist_renderer_checkbox.set_activatable(True) self.perm_permlist_renderer_checkbox.connect("toggled", self.toggledRight) self.permbox.attach(self.perm_permlabel, 0, 1, 0, 1) self.permbox.attach(self.perm_permlistview, 0, 1, 1, 2) self.perm.add(self.permbox) self.pack_start(self.perm, False) self.show_all() self.render() def render(self): role = self.getMyObject() if not role: return self.headline.set_markup(_("<b>Edit Role: " + role.getName() + "</b>")) if role.permissiondata is not None: self.perm_permlist.clear() for permission in role.permissiondata: self.perm_permlist.append( (int(permission['granted']), str(permission['right']), '')) def toggledRight(self, renderer=None, path=None): rowiter = self.perm_permlist.get_iter(path) perm = self.perm_permlist.get_value(rowiter, 1) val = 1 - self.perm_permlist.get_value(rowiter, 0) role = self.getApplication().getLocalObjectById(self.roleId) if val == 1: role.assignPermission(perm) else: role.removePermission(perm)
def __init__(self, par, user): ObjectPageAbstract.__init__(self, par, user) user.fetchRightsData() user.fetchRoleData() self.headline = gtk.Label() self.pack_start(self.headline, False) self.info = PageFrame(self, _("Information"), gui.IconStock.USER) self.infobox = gtk.VBox() self.info.add(self.infobox) self.pack_start(self.info, False) self.perm = PageFrame(self, _("Permissions / Roles"), gui.IconStock.ROLE) self.permbox = gtk.Table(2, 2, False) self.permbox.set_row_spacings(10) self.permbox.set_col_spacings(10) self.permbox.set_border_width(10) self.perm_permlabel = FrameLabel( self, _("Please choose the Permissions you want to assign to the user here:" ), gui.IconStock.PERMISSION) self.perm_rolelabel = FrameLabel( self, _("Please choose the Rights you want to assign to the user here:"), gui.IconStock.ROLE) self.perm_permlistview = gtk.TreeView() self.perm_permlist = gtk.ListStore(int, str, str) self.perm_permlistview.set_model(self.perm_permlist) self.perm_permlist_col_checkbox = gtk.TreeViewColumn('') self.perm_permlist_col_identifier = gtk.TreeViewColumn( _('Permission Identifier')) self.perm_permlist_col_name = gtk.TreeViewColumn(_('Permission Name')) self.perm_permlistview.append_column(self.perm_permlist_col_checkbox) self.perm_permlistview.append_column(self.perm_permlist_col_identifier) self.perm_permlistview.append_column(self.perm_permlist_col_name) self.perm_permlist_renderer_checkbox = gtk.CellRendererToggle() self.perm_permlist_renderer_identifier = gtk.CellRendererText() self.perm_permlist_renderer_name = gtk.CellRendererText() self.perm_permlist_col_checkbox.pack_start( self.perm_permlist_renderer_checkbox) self.perm_permlist_col_identifier.pack_start( self.perm_permlist_renderer_identifier) self.perm_permlist_col_name.pack_start( self.perm_permlist_renderer_name) self.perm_permlist_col_checkbox.add_attribute( self.perm_permlist_renderer_checkbox, 'active', 0) self.perm_permlist_col_identifier.add_attribute( self.perm_permlist_renderer_identifier, 'text', 1) self.perm_permlist_col_name.add_attribute( self.perm_permlist_renderer_name, 'text', 2) self.perm_permlist_renderer_checkbox.set_activatable(True) self.perm_permlist_renderer_checkbox.connect("toggled", self.toggledRight) self.perm_rolelistview = gtk.TreeView() self.perm_rolelist = gtk.ListStore(int, str, str, int) self.perm_rolelistview.set_model(self.perm_rolelist) self.perm_rolelist_col_checkbox = gtk.TreeViewColumn('') self.perm_rolelist_col_identifier = gtk.TreeViewColumn( _('Role Identifier')) self.perm_rolelist_col_name = gtk.TreeViewColumn(_('RoleName')) self.perm_rolelistview.append_column(self.perm_rolelist_col_checkbox) self.perm_rolelistview.append_column(self.perm_rolelist_col_identifier) self.perm_rolelistview.append_column(self.perm_rolelist_col_name) self.perm_rolelist_renderer_checkbox = gtk.CellRendererToggle() self.perm_rolelist_renderer_identifier = gtk.CellRendererText() self.perm_rolelist_renderer_name = gtk.CellRendererText() self.perm_rolelist_col_checkbox.pack_start( self.perm_rolelist_renderer_checkbox) self.perm_rolelist_col_identifier.pack_start( self.perm_rolelist_renderer_identifier) self.perm_rolelist_col_name.pack_start( self.perm_rolelist_renderer_name) self.perm_rolelist_col_checkbox.add_attribute( self.perm_rolelist_renderer_checkbox, 'active', 0) self.perm_rolelist_col_identifier.add_attribute( self.perm_rolelist_renderer_identifier, 'text', 1) self.perm_rolelist_col_name.add_attribute( self.perm_rolelist_renderer_name, 'text', 2) self.perm_rolelist_renderer_checkbox.set_activatable(True) self.perm_rolelist_renderer_checkbox.connect("toggled", self.toggledRole) self.permbox.attach(self.perm_permlabel, 0, 1, 0, 1) self.permbox.attach(self.perm_permlistview, 0, 1, 1, 2) self.permbox.attach(self.perm_rolelabel, 1, 2, 0, 1) self.permbox.attach(self.perm_rolelistview, 1, 2, 1, 2) self.perm.add(self.permbox) self.pack_start(self.perm, False) self.alterpw = PageFrame(self, _("Alter Password"), gui.IconStock.CREDENTIAL) self.alterpwhbox = gtk.HBox() self.alterpwdummy = gtk.Label("") self.alterpwbox = gtk.Table(2, 4, False) self.alterpwbox.set_row_spacings(10) self.alterpwbox.set_col_spacings(10) self.alterpwbox.set_border_width(10) self.alterpw_oldpw_label = gtk.Label(_("Old Password:"******"New Password:"******"Repeat Password:"******"●") self.alterpw_oldpw_entry.set_visibility(False) self.alterpw_newpw1_entry = gtk.Entry() self.alterpw_newpw1_entry.set_invisible_char("●") self.alterpw_newpw1_entry.set_visibility(False) self.alterpw_newpw2_entry = gtk.Entry() self.alterpw_newpw2_entry.set_invisible_char("●") self.alterpw_newpw2_entry.set_visibility(False) self.alterpw_ok = gtk.Button(_("Alter Password")) self.alterpwbox.attach(self.alterpw_oldpw_label, 0, 1, 0, 1) self.alterpwbox.attach(self.alterpw_oldpw_entry, 1, 2, 0, 1) self.alterpwbox.attach(self.alterpw_newpw1_label, 0, 1, 1, 2) self.alterpwbox.attach(self.alterpw_newpw1_entry, 1, 2, 1, 2) self.alterpwbox.attach(self.alterpw_newpw2_label, 0, 1, 2, 3) self.alterpwbox.attach(self.alterpw_newpw2_entry, 1, 2, 2, 3) self.alterpwbox.attach(self.alterpw_ok, 1, 2, 3, 4) self.alterpwhbox.pack_start(self.alterpwbox, False) self.alterpwhbox.pack_start(self.alterpwdummy, True) self.alterpw.add(self.alterpwhbox) self.alterpw_ok.connect("clicked", self.alterPassword) self.pack_start(self.alterpw, False) self.show_all() self.render()
class UserPage(ObjectPageAbstract): def __init__(self, par, user): ObjectPageAbstract.__init__(self, par, user) user.fetchRightsData() user.fetchRoleData() self.headline = gtk.Label() self.pack_start(self.headline, False) self.info = PageFrame(self, _("Information"), gui.IconStock.USER) self.infobox = gtk.VBox() self.info.add(self.infobox) self.pack_start(self.info, False) self.perm = PageFrame(self, _("Permissions / Roles"), gui.IconStock.ROLE) self.permbox = gtk.Table(2, 2, False) self.permbox.set_row_spacings(10) self.permbox.set_col_spacings(10) self.permbox.set_border_width(10) self.perm_permlabel = FrameLabel( self, _("Please choose the Permissions you want to assign to the user here:" ), gui.IconStock.PERMISSION) self.perm_rolelabel = FrameLabel( self, _("Please choose the Rights you want to assign to the user here:"), gui.IconStock.ROLE) self.perm_permlistview = gtk.TreeView() self.perm_permlist = gtk.ListStore(int, str, str) self.perm_permlistview.set_model(self.perm_permlist) self.perm_permlist_col_checkbox = gtk.TreeViewColumn('') self.perm_permlist_col_identifier = gtk.TreeViewColumn( _('Permission Identifier')) self.perm_permlist_col_name = gtk.TreeViewColumn(_('Permission Name')) self.perm_permlistview.append_column(self.perm_permlist_col_checkbox) self.perm_permlistview.append_column(self.perm_permlist_col_identifier) self.perm_permlistview.append_column(self.perm_permlist_col_name) self.perm_permlist_renderer_checkbox = gtk.CellRendererToggle() self.perm_permlist_renderer_identifier = gtk.CellRendererText() self.perm_permlist_renderer_name = gtk.CellRendererText() self.perm_permlist_col_checkbox.pack_start( self.perm_permlist_renderer_checkbox) self.perm_permlist_col_identifier.pack_start( self.perm_permlist_renderer_identifier) self.perm_permlist_col_name.pack_start( self.perm_permlist_renderer_name) self.perm_permlist_col_checkbox.add_attribute( self.perm_permlist_renderer_checkbox, 'active', 0) self.perm_permlist_col_identifier.add_attribute( self.perm_permlist_renderer_identifier, 'text', 1) self.perm_permlist_col_name.add_attribute( self.perm_permlist_renderer_name, 'text', 2) self.perm_permlist_renderer_checkbox.set_activatable(True) self.perm_permlist_renderer_checkbox.connect("toggled", self.toggledRight) self.perm_rolelistview = gtk.TreeView() self.perm_rolelist = gtk.ListStore(int, str, str, int) self.perm_rolelistview.set_model(self.perm_rolelist) self.perm_rolelist_col_checkbox = gtk.TreeViewColumn('') self.perm_rolelist_col_identifier = gtk.TreeViewColumn( _('Role Identifier')) self.perm_rolelist_col_name = gtk.TreeViewColumn(_('RoleName')) self.perm_rolelistview.append_column(self.perm_rolelist_col_checkbox) self.perm_rolelistview.append_column(self.perm_rolelist_col_identifier) self.perm_rolelistview.append_column(self.perm_rolelist_col_name) self.perm_rolelist_renderer_checkbox = gtk.CellRendererToggle() self.perm_rolelist_renderer_identifier = gtk.CellRendererText() self.perm_rolelist_renderer_name = gtk.CellRendererText() self.perm_rolelist_col_checkbox.pack_start( self.perm_rolelist_renderer_checkbox) self.perm_rolelist_col_identifier.pack_start( self.perm_rolelist_renderer_identifier) self.perm_rolelist_col_name.pack_start( self.perm_rolelist_renderer_name) self.perm_rolelist_col_checkbox.add_attribute( self.perm_rolelist_renderer_checkbox, 'active', 0) self.perm_rolelist_col_identifier.add_attribute( self.perm_rolelist_renderer_identifier, 'text', 1) self.perm_rolelist_col_name.add_attribute( self.perm_rolelist_renderer_name, 'text', 2) self.perm_rolelist_renderer_checkbox.set_activatable(True) self.perm_rolelist_renderer_checkbox.connect("toggled", self.toggledRole) self.permbox.attach(self.perm_permlabel, 0, 1, 0, 1) self.permbox.attach(self.perm_permlistview, 0, 1, 1, 2) self.permbox.attach(self.perm_rolelabel, 1, 2, 0, 1) self.permbox.attach(self.perm_rolelistview, 1, 2, 1, 2) self.perm.add(self.permbox) self.pack_start(self.perm, False) self.alterpw = PageFrame(self, _("Alter Password"), gui.IconStock.CREDENTIAL) self.alterpwhbox = gtk.HBox() self.alterpwdummy = gtk.Label("") self.alterpwbox = gtk.Table(2, 4, False) self.alterpwbox.set_row_spacings(10) self.alterpwbox.set_col_spacings(10) self.alterpwbox.set_border_width(10) self.alterpw_oldpw_label = gtk.Label(_("Old Password:"******"New Password:"******"Repeat Password:"******"●") self.alterpw_oldpw_entry.set_visibility(False) self.alterpw_newpw1_entry = gtk.Entry() self.alterpw_newpw1_entry.set_invisible_char("●") self.alterpw_newpw1_entry.set_visibility(False) self.alterpw_newpw2_entry = gtk.Entry() self.alterpw_newpw2_entry.set_invisible_char("●") self.alterpw_newpw2_entry.set_visibility(False) self.alterpw_ok = gtk.Button(_("Alter Password")) self.alterpwbox.attach(self.alterpw_oldpw_label, 0, 1, 0, 1) self.alterpwbox.attach(self.alterpw_oldpw_entry, 1, 2, 0, 1) self.alterpwbox.attach(self.alterpw_newpw1_label, 0, 1, 1, 2) self.alterpwbox.attach(self.alterpw_newpw1_entry, 1, 2, 1, 2) self.alterpwbox.attach(self.alterpw_newpw2_label, 0, 1, 2, 3) self.alterpwbox.attach(self.alterpw_newpw2_entry, 1, 2, 2, 3) self.alterpwbox.attach(self.alterpw_ok, 1, 2, 3, 4) self.alterpwhbox.pack_start(self.alterpwbox, False) self.alterpwhbox.pack_start(self.alterpwdummy, True) self.alterpw.add(self.alterpwhbox) self.alterpw_ok.connect("clicked", self.alterPassword) self.pack_start(self.alterpw, False) self.show_all() self.render() def render(self): user = self.getMyObject() if not user: return self.headline.set_markup( _("<b>Settings for User: "******"</b>") if user.permissiondata is not None: self.perm_permlist.clear() for permission in user.permissiondata: self.perm_permlist.append( (int(permission['granted']), str(permission['right']), '')) if user.roledata is not None: self.perm_rolelist.clear() for role in user.roledata: self.perm_rolelist.append( (int(role['granted']), str(role['name']), '', role['id'])) alter_pw_permitted = user.getUsers().getSkarphed().checkPermission( "skarphed.users.alter_password") is_active_user = user.getUsers().getSkarphed().getUsername( ) == user.getName() if alter_pw_permitted or is_active_user: self.alterpw.set_visible(True) self.alterpw_oldpw_entry.set_visible(is_active_user) self.alterpw_oldpw_label.set_visible(is_active_user) else: self.alterpw.set_visible(False) def alterPassword(self, widget=None, data=None): user = self.getMyObject() if not user: return alter_pw_permitted = user.getUsers().getSkarphed().checkPermission( "skarphed.users.alter_password") is_active_user = user.getUsers().getSkarphed().getUsername( ) == user.getName() if alter_pw_permitted or is_active_user: if is_active_user: oldpw = self.alterpw_oldpw_entry.get_text() newpw1 = self.alterpw_newpw1_entry.get_text() newpw2 = self.alterpw_newpw2_entry.get_text() if newpw2 != newpw1: return False # Password repeat not successful if newpw1 == "": return False # New password is empty if is_active_user: user.alterPassword(newpw1, oldpw) else: user.alterPassword(newpw1) def toggledRole(self, render=None, path=None): rowiter = self.perm_rolelist.get_iter(path) roleId = self.perm_rolelist.get_value(rowiter, 3) val = 1 - self.perm_rolelist.get_value(rowiter, 0) user = self.getMyObject() if not user: return if val == 1: user.assignRole(roleId) else: user.removeRole(roleId) def toggledRight(self, render=None, path=None): rowiter = self.perm_permlist.get_iter(path) perm = self.perm_permlist.get_value(rowiter, 1) val = 1 - self.perm_permlist.get_value(rowiter, 0) user = self.getMyObject() if not user: return if val == 1: user.assignPermission(perm) else: user.removePermission(perm)
def __init__(self, parent, modules): ObjectPageAbstract.__init__(self, parent, modules) self.info = PageFrame(self, _("Information"), gui.IconStock.REPO) self.infobox = gtk.VBox() self.info_table = gtk.Table(2, 2, False) self.info_labelName = gtk.Label(_("Name:")) self.info_labelHost = gtk.Label(_("Host:")) self.info_displayName = gtk.Label() self.info_displayHost = gtk.Label() self.info_table.attach(self.info_labelName, 0, 1, 0, 1) self.info_table.attach(self.info_displayName, 1, 2, 0, 1) self.info_table.attach(self.info_labelHost, 0, 1, 1, 2) self.info_table.attach(self.info_displayHost, 1, 2, 1, 2) self.infobox.pack_start(self.info_table, False) self.info.add(self.infobox) self.pack_start(self.info, False) self.mod = PageFrame(self, _("Available and installed modules"), gui.IconStock.MODULE) self.modbox = gtk.Table(5, 2, False) self.modbox.set_row_spacings(10) self.modbox.set_col_spacings(10) self.modbox.set_border_width(10) self.mod_label = gtk.Label( _("Please drag a module into the opposing list to install/uninstall it:\n" )) self.mod_norepo_label = gtk.Label(_("Repository not reachable")) self.mod_labelInstalled = gtk.Label(_("Installed modules")) self.mod_labelAvailable = gtk.Label(_("Available modules")) self.mod_labelProcessed = gtk.Label(_("Currently processed modules")) self.mod_IListScroll = gtk.ScrolledWindow() self.mod_IListScroll.set_size_request(200, 250) self.mod_IListScroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.mod_IList = gtk.TreeView() self.mod_IListStore = gtk.ListStore(gtk.gdk.Pixbuf, str, gtk.gdk.Pixbuf, int) self.mod_IList.set_model(self.mod_IListStore) self.mod_IList_col_module = gtk.TreeViewColumn(_('Modulename')) self.mod_IList_col_js = gtk.TreeViewColumn(_('JS')) self.mod_IList_ren_icon = gtk.CellRendererPixbuf() self.mod_IList_ren_name = gtk.CellRendererText() self.mod_IList_ren_js = gtk.CellRendererPixbuf() self.mod_IList.append_column(self.mod_IList_col_module) self.mod_IList.append_column(self.mod_IList_col_js) self.mod_IList_col_module.pack_start(self.mod_IList_ren_icon, False) self.mod_IList_col_module.pack_start(self.mod_IList_ren_name, True) self.mod_IList_col_js.pack_start(self.mod_IList_ren_js, False) self.mod_IList_col_module.add_attribute(self.mod_IList_ren_icon, 'pixbuf', 0) self.mod_IList_col_module.add_attribute(self.mod_IList_ren_name, 'text', 1) self.mod_IList_col_js.add_attribute(self.mod_IList_ren_js, 'pixbuf', 2) self.mod_IList_col_module.set_sort_column_id(1) self.mod_IListScroll.add(self.mod_IList) self.mod_AListScroll = gtk.ScrolledWindow() self.mod_AListScroll.set_size_request(200, 250) self.mod_AListScroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.mod_AList = gtk.TreeView() self.mod_AListStore = gtk.ListStore(gtk.gdk.Pixbuf, str, gtk.gdk.Pixbuf, int) self.mod_AList.set_model(self.mod_AListStore) self.mod_AList_col_module = gtk.TreeViewColumn(_('Modulename')) self.mod_AList_col_js = gtk.TreeViewColumn(_('JS')) self.mod_AList_ren_icon = gtk.CellRendererPixbuf() self.mod_AList_ren_name = gtk.CellRendererText() self.mod_AList_ren_js = gtk.CellRendererPixbuf() self.mod_AList.append_column(self.mod_AList_col_module) self.mod_AList.append_column(self.mod_AList_col_js) self.mod_AList_col_module.pack_start(self.mod_AList_ren_icon, False) self.mod_AList_col_module.pack_start(self.mod_AList_ren_name, True) self.mod_AList_col_js.pack_start(self.mod_AList_ren_js, False) self.mod_AList_col_module.add_attribute(self.mod_AList_ren_icon, 'pixbuf', 0) self.mod_AList_col_module.add_attribute(self.mod_AList_ren_name, 'text', 1) self.mod_AList_col_js.add_attribute(self.mod_AList_ren_js, 'pixbuf', 2) self.mod_AList_col_module.set_sort_column_id(1) self.mod_AListScroll.add(self.mod_AList) self.mod_CList = OperationTool(self, modules.getSkarphed()) self.modbox.attach(self.mod_label, 0, 2, 0, 1) self.modbox.attach(self.mod_labelInstalled, 0, 1, 1, 2) self.modbox.attach(self.mod_labelAvailable, 1, 2, 1, 2) self.modbox.attach(self.mod_IListScroll, 0, 1, 2, 3) self.modbox.attach(self.mod_AListScroll, 1, 2, 2, 3) self.modbox.attach(self.mod_labelProcessed, 0, 2, 3, 4) self.modbox.attach(self.mod_CList, 0, 2, 4, 5) self.mod_AList.enable_model_drag_dest([('text/plain', 0, 0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_IList.enable_model_drag_dest([('text/plain', 0, 0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_AList.enable_model_drag_source( gtk.gdk.BUTTON1_MASK, [('text/plain', 0, 0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_IList.enable_model_drag_source( gtk.gdk.BUTTON1_MASK, [('text/plain', 0, 0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_AList.connect("drag-data-received", self.aListReceiveCallback) self.mod_IList.connect("drag-data-received", self.iListReceiveCallback) self.mod_AList.connect("drag-data-get", self.aListGetDataCallback) self.mod_IList.connect("drag-data-get", self.iListGetDataCallback) self.mod_AList.set_name("AList") self.mod_IList.set_name("IList") self.mod.add(self.modbox) self.pack_start(self.mod, False) self.show_all() self.render() modules.getSkarphed().getOperationManager().addCallback(self.render) self.getApplication().getObjectStore().addCallback(self.render)
class ModulesPage(ObjectPageAbstract): def __init__(self, parent, modules): ObjectPageAbstract.__init__(self, parent, modules) self.info = PageFrame(self, _("Information"), gui.IconStock.REPO) self.infobox = gtk.VBox() self.info_table = gtk.Table(2, 2, False) self.info_labelName = gtk.Label(_("Name:")) self.info_labelHost = gtk.Label(_("Host:")) self.info_displayName = gtk.Label() self.info_displayHost = gtk.Label() self.info_table.attach(self.info_labelName, 0, 1, 0, 1) self.info_table.attach(self.info_displayName, 1, 2, 0, 1) self.info_table.attach(self.info_labelHost, 0, 1, 1, 2) self.info_table.attach(self.info_displayHost, 1, 2, 1, 2) self.infobox.pack_start(self.info_table, False) self.info.add(self.infobox) self.pack_start(self.info, False) self.mod = PageFrame(self, _("Available and installed modules"), gui.IconStock.MODULE) self.modbox = gtk.Table(5, 2, False) self.modbox.set_row_spacings(10) self.modbox.set_col_spacings(10) self.modbox.set_border_width(10) self.mod_label = gtk.Label( _("Please drag a module into the opposing list to install/uninstall it:\n" )) self.mod_norepo_label = gtk.Label(_("Repository not reachable")) self.mod_labelInstalled = gtk.Label(_("Installed modules")) self.mod_labelAvailable = gtk.Label(_("Available modules")) self.mod_labelProcessed = gtk.Label(_("Currently processed modules")) self.mod_IListScroll = gtk.ScrolledWindow() self.mod_IListScroll.set_size_request(200, 250) self.mod_IListScroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.mod_IList = gtk.TreeView() self.mod_IListStore = gtk.ListStore(gtk.gdk.Pixbuf, str, gtk.gdk.Pixbuf, int) self.mod_IList.set_model(self.mod_IListStore) self.mod_IList_col_module = gtk.TreeViewColumn(_('Modulename')) self.mod_IList_col_js = gtk.TreeViewColumn(_('JS')) self.mod_IList_ren_icon = gtk.CellRendererPixbuf() self.mod_IList_ren_name = gtk.CellRendererText() self.mod_IList_ren_js = gtk.CellRendererPixbuf() self.mod_IList.append_column(self.mod_IList_col_module) self.mod_IList.append_column(self.mod_IList_col_js) self.mod_IList_col_module.pack_start(self.mod_IList_ren_icon, False) self.mod_IList_col_module.pack_start(self.mod_IList_ren_name, True) self.mod_IList_col_js.pack_start(self.mod_IList_ren_js, False) self.mod_IList_col_module.add_attribute(self.mod_IList_ren_icon, 'pixbuf', 0) self.mod_IList_col_module.add_attribute(self.mod_IList_ren_name, 'text', 1) self.mod_IList_col_js.add_attribute(self.mod_IList_ren_js, 'pixbuf', 2) self.mod_IList_col_module.set_sort_column_id(1) self.mod_IListScroll.add(self.mod_IList) self.mod_AListScroll = gtk.ScrolledWindow() self.mod_AListScroll.set_size_request(200, 250) self.mod_AListScroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.mod_AList = gtk.TreeView() self.mod_AListStore = gtk.ListStore(gtk.gdk.Pixbuf, str, gtk.gdk.Pixbuf, int) self.mod_AList.set_model(self.mod_AListStore) self.mod_AList_col_module = gtk.TreeViewColumn(_('Modulename')) self.mod_AList_col_js = gtk.TreeViewColumn(_('JS')) self.mod_AList_ren_icon = gtk.CellRendererPixbuf() self.mod_AList_ren_name = gtk.CellRendererText() self.mod_AList_ren_js = gtk.CellRendererPixbuf() self.mod_AList.append_column(self.mod_AList_col_module) self.mod_AList.append_column(self.mod_AList_col_js) self.mod_AList_col_module.pack_start(self.mod_AList_ren_icon, False) self.mod_AList_col_module.pack_start(self.mod_AList_ren_name, True) self.mod_AList_col_js.pack_start(self.mod_AList_ren_js, False) self.mod_AList_col_module.add_attribute(self.mod_AList_ren_icon, 'pixbuf', 0) self.mod_AList_col_module.add_attribute(self.mod_AList_ren_name, 'text', 1) self.mod_AList_col_js.add_attribute(self.mod_AList_ren_js, 'pixbuf', 2) self.mod_AList_col_module.set_sort_column_id(1) self.mod_AListScroll.add(self.mod_AList) self.mod_CList = OperationTool(self, modules.getSkarphed()) self.modbox.attach(self.mod_label, 0, 2, 0, 1) self.modbox.attach(self.mod_labelInstalled, 0, 1, 1, 2) self.modbox.attach(self.mod_labelAvailable, 1, 2, 1, 2) self.modbox.attach(self.mod_IListScroll, 0, 1, 2, 3) self.modbox.attach(self.mod_AListScroll, 1, 2, 2, 3) self.modbox.attach(self.mod_labelProcessed, 0, 2, 3, 4) self.modbox.attach(self.mod_CList, 0, 2, 4, 5) self.mod_AList.enable_model_drag_dest([('text/plain', 0, 0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_IList.enable_model_drag_dest([('text/plain', 0, 0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_AList.enable_model_drag_source( gtk.gdk.BUTTON1_MASK, [('text/plain', 0, 0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_IList.enable_model_drag_source( gtk.gdk.BUTTON1_MASK, [('text/plain', 0, 0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_AList.connect("drag-data-received", self.aListReceiveCallback) self.mod_IList.connect("drag-data-received", self.iListReceiveCallback) self.mod_AList.connect("drag-data-get", self.aListGetDataCallback) self.mod_IList.connect("drag-data-get", self.iListGetDataCallback) self.mod_AList.set_name("AList") self.mod_IList.set_name("IList") self.mod.add(self.modbox) self.pack_start(self.mod, False) self.show_all() self.render() modules.getSkarphed().getOperationManager().addCallback(self.render) self.getApplication().getObjectStore().addCallback(self.render) def iListGetDataCallback(self, treeview, context, selection, info, timestamp): treeselection = treeview.get_selection() model, rowiter = treeselection.get_selected() text = model.get_value(rowiter, 3) selection.set('text/plain', 8, str(text)) def aListGetDataCallback(self, treeview, context, selection, info, timestamp): treeselection = treeview.get_selection() model, rowiter = treeselection.get_selected() text = model.get_value(rowiter, 3) selection.set('text/plain', 8, str(text)) def iListReceiveCallback(self, treeview, context, x, y, selection, info, timestamp): if context.get_source_widget().get_name() != "AList": return module = self.getApplication().getLocalObjectById(int(selection.data)) modules = self.getMyObject() if not modules: return modules.installModule(module) def aListReceiveCallback(self, treeview, context, x, y, selection, info, timestamp): if context.get_source_widget().get_name() != "IList": return module = self.getApplication().getLocalObjectById(int(selection.data)) modules = self.getMyObject() if not modules: return modules.uninstallModule(module) def getModuleIterById(self, moduleList, moduleId): def search(model, path, rowiter, moduleId): val = model.get_value(rowiter, 3) if val == moduleId: model.tempiter = rowiter moduleList.tempiter = None moduleList.foreach(search, moduleId) rowiter = moduleList.tempiter if rowiter is not None: return rowiter else: return None def render(self): def search(model, path, rowiter, processed): val = model.get_value(rowiter, 3) if val not in processed: model.itersToRemove.append(rowiter) js_iconmap = { JSMandatory.NO: gui.IconStock.JS_NO, JSMandatory.SUPPORTED: gui.IconStock.JS_SUPPORTED, JSMandatory.MANDATORY: gui.IconStock.JS_MANDATORY } modules = self.getMyObject() if not modules: self.destroy() return if modules.getRepoState(): self.modbox.remove(self.mod_norepo_label) self.modbox.attach(self.mod_AListScroll, 1, 2, 2, 3) else: self.modbox.remove(self.mod_AListScroll) self.modbox.attach(self.mod_norepo_label, 1, 2, 2, 3) self.processedIListIds = [] self.processedAListIds = [] for module in modules.getAllModules(): if module.data.has_key( 'installed') and module.data['installed'] == True: rowiter = self.getModuleIterById(self.mod_IListStore, module.getLocalId()) if rowiter is None: self.mod_IListStore.append( (gui.IconStock.getAppropriateIcon(module), module.getName(), js_iconmap[module.getJSMandatory()], module.getLocalId())) else: self.mod_IListStore.set_value( rowiter, 0, gui.IconStock.getAppropriateIcon(module)) self.mod_IListStore.set_value(rowiter, 1, module.getName()) self.mod_IListStore.set_value( rowiter, 2, js_iconmap[module.getJSMandatory()]) self.processedIListIds.append(module.getLocalId()) else: rowiter = self.getModuleIterById(self.mod_AListStore, module.getLocalId()) if rowiter is None: self.mod_AListStore.append( (gui.IconStock.MODULE, module.getName(), js_iconmap[module.getJSMandatory()], module.getLocalId())) else: self.mod_AListStore.set_value( rowiter, 0, gui.IconStock.getAppropriateIcon(module)) self.mod_IListStore.set_value(rowiter, 1, module.getName()) self.mod_IListStore.set_value( rowiter, 2, js_iconmap[module.getJSMandatory()]) self.processedAListIds.append(module.getLocalId()) self.mod_IListStore.itersToRemove = [] self.mod_AListStore.itersToRemove = [] self.mod_IListStore.foreach(search, self.processedIListIds) self.mod_AListStore.foreach(search, self.processedAListIds) for rowiter in self.mod_IListStore.itersToRemove: self.mod_IListStore.remove(rowiter) for rowiter in self.mod_AListStore.itersToRemove: self.mod_AListStore.remove(rowiter)
def __init__(self, parent, template): ObjectPageAbstract.__init__(self, parent, template) self.headline = gtk.Label() self.pack_start(self.headline, False) self.info = PageFrame(self, _("Currently Installed"), gui.IconStock.TEMPLATE) self.infobox = gtk.VBox() self.info_table = gtk.Table(2, 3, False) self.info_labelName = gtk.Label(_("Name:")) self.info_labelDescription = gtk.Label(_("Description:")) self.info_labelAuthor = gtk.Label(_("Author:")) self.info_displayName = gtk.Label() self.info_displayDescription = gtk.Label() self.info_displayAuthor = gtk.Label() self.info_table.attach(self.info_labelName, 0, 1, 0, 1) self.info_table.attach(self.info_displayName, 1, 2, 0, 1) self.info_table.attach(self.info_labelDescription, 0, 1, 1, 2) self.info_table.attach(self.info_displayDescription, 1, 2, 1, 2) self.info_table.attach(self.info_labelAuthor, 0, 1, 2, 3) self.info_table.attach(self.info_displayAuthor, 1, 2, 2, 3) self.infobox.pack_start(self.info_table, False) self.info.add(self.infobox) self.pack_start(self.info, False) self.upload = PageFrame(self, _("Upload new Template"), gui.IconStock.TEMPLATE) self.uploadbox = gtk.HBox() self.uploadbox.set_border_width(10) self.upload_label = gtk.Label( _("Please choose the template and click OK")) self.upload_filechoose = gtk.FileChooserButton("Select Template", None) self.upload_filechoose.connect("file-set", self.fileChosen) self.upload_filechoose.set_size_request(200, 30) self.upload_enter = gtk.Button(stock=gtk.STOCK_OK) self.upload_enter.connect("clicked", self.uploadTemplate) self.upload_dummy = gtk.Label("") self.uploadbox.pack_start(self.upload_label, False) self.uploadbox.pack_start(self.upload_filechoose, False) self.uploadbox.pack_start(self.upload_enter, False) self.uploadbox.pack_start(self.upload_dummy, True) self.upload.add(self.uploadbox) self.pack_start(self.upload, False) self.repo = PageFrame(self, _("Install Template from Repository"), gui.IconStock.TEMPLATE) self.repoVBox = gtk.VBox() self.repoButtonbox = gtk.HBox() self.repoDummy = gtk.Label("") self.repoInstallButton = gtk.Button(_("Install")) self.repoRefreshButton = gtk.Button(stock=gtk.STOCK_REFRESH) self.repostore = gtk.ListStore(gtk.gdk.Pixbuf, str, str, str, int) self.repotree = gtk.TreeView() self.repotree.set_model(self.repostore) self.reposcroll = gtk.ScrolledWindow() self.reposcroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.repocol_name = gtk.TreeViewColumn(_("Template")) self.repocol_description = gtk.TreeViewColumn(_("Description")) self.repocol_author = gtk.TreeViewColumn(_("Author")) self.reporen_icon = gtk.CellRendererPixbuf() self.reporen_name = gtk.CellRendererText() self.reporen_description = gtk.CellRendererText() self.reporen_author = gtk.CellRendererText() self.repocol_name.pack_start(self.reporen_icon, False) self.repocol_name.pack_start(self.reporen_name, False) self.repocol_description.pack_start(self.reporen_description, True) self.repocol_author.pack_start(self.reporen_author, False) self.repocol_name.add_attribute(self.reporen_icon, 'pixbuf', 0) self.repocol_name.add_attribute(self.reporen_name, 'text', 1) self.repocol_description.add_attribute(self.reporen_description, 'text', 2) self.repocol_author.add_attribute(self.reporen_author, 'text', 3) self.repotree.append_column(self.repocol_name) self.repotree.append_column(self.repocol_description) self.repotree.append_column(self.repocol_author) self.repotree.connect("row-activated", self.installRowCallback) self.reposcroll.add(self.repotree) self.repoButtonbox.pack_start(self.repoDummy, True) self.repoButtonbox.pack_start(self.repoRefreshButton, False) self.repoButtonbox.pack_start(self.repoInstallButton, False) self.repoVBox.pack_start(self.reposcroll, True) self.repoVBox.pack_start(self.repoButtonbox, False) self.repoRefreshButton.connect("clicked", self.refreshAvailableTemplates) self.repoInstallButton.connect("clicked", self.installButtonCallback) self.repo.add(self.repoVBox) self.pack_start(self.repo) self.show_all() self.render()
class TemplatePage(ObjectPageAbstract): def __init__(self,parent,template): ObjectPageAbstract.__init__(self,parent,template) self.headline = gtk.Label() self.pack_start(self.headline,False) self.info = PageFrame(self,_("Currently Installed"), gui.IconStock.TEMPLATE) self.infobox = gtk.VBox() self.info_table = gtk.Table(2,3,False) self.info_labelName = gtk.Label(_("Name:")) self.info_labelDescription = gtk.Label(_("Description:")) self.info_labelAuthor = gtk.Label(_("Author:")) self.info_displayName = gtk.Label() self.info_displayDescription = gtk.Label() self.info_displayAuthor = gtk.Label() self.info_table.attach(self.info_labelName,0,1,0,1) self.info_table.attach(self.info_displayName,1,2,0,1) self.info_table.attach(self.info_labelDescription,0,1,1,2) self.info_table.attach(self.info_displayDescription,1,2,1,2) self.info_table.attach(self.info_labelAuthor,0,1,2,3) self.info_table.attach(self.info_displayAuthor,1,2,2,3) self.infobox.pack_start(self.info_table,False) self.info.add(self.infobox) self.pack_start(self.info,False) self.upload = PageFrame(self,_("Upload new Template"), gui.IconStock.TEMPLATE) self.uploadbox = gtk.HBox() self.uploadbox.set_border_width(10) self.upload_label = gtk.Label(_("Please choose the template and click OK")) self.upload_filechoose = gtk.FileChooserButton("Select Template", None) self.upload_filechoose.connect("file-set", self.fileChosen) self.upload_filechoose.set_size_request(200,30) self.upload_enter = gtk.Button(stock=gtk.STOCK_OK) self.upload_enter.connect("clicked", self.uploadTemplate) self.upload_dummy = gtk.Label("") self.uploadbox.pack_start(self.upload_label,False) self.uploadbox.pack_start(self.upload_filechoose,False) self.uploadbox.pack_start(self.upload_enter,False) self.uploadbox.pack_start(self.upload_dummy,True) self.upload.add(self.uploadbox) self.pack_start(self.upload,False) self.repo = PageFrame(self,_("Install Template from Repository"), gui.IconStock.TEMPLATE) self.repoVBox = gtk.VBox() self.repoButtonbox = gtk.HBox() self.repoDummy = gtk.Label("") self.repoInstallButton = gtk.Button(_("Install")) self.repoRefreshButton = gtk.Button(stock=gtk.STOCK_REFRESH) self.repostore = gtk.ListStore(gtk.gdk.Pixbuf, str, str, str, int) self.repotree = gtk.TreeView() self.repotree.set_model(self.repostore) self.reposcroll = gtk.ScrolledWindow() self.reposcroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.repocol_name = gtk.TreeViewColumn(_("Template")) self.repocol_description = gtk.TreeViewColumn(_("Description")) self.repocol_author = gtk.TreeViewColumn(_("Author")) self.reporen_icon = gtk.CellRendererPixbuf() self.reporen_name = gtk.CellRendererText() self.reporen_description = gtk.CellRendererText() self.reporen_author = gtk.CellRendererText() self.repocol_name.pack_start(self.reporen_icon,False) self.repocol_name.pack_start(self.reporen_name,False) self.repocol_description.pack_start(self.reporen_description,True) self.repocol_author.pack_start(self.reporen_author,False) self.repocol_name.add_attribute(self.reporen_icon,'pixbuf',0) self.repocol_name.add_attribute(self.reporen_name,'text',1) self.repocol_description.add_attribute(self.reporen_description,'text',2) self.repocol_author.add_attribute(self.reporen_author,'text',3) self.repotree.append_column(self.repocol_name) self.repotree.append_column(self.repocol_description) self.repotree.append_column(self.repocol_author) self.repotree.connect("row-activated",self.installRowCallback) self.reposcroll.add(self.repotree) self.repoButtonbox.pack_start(self.repoDummy,True) self.repoButtonbox.pack_start(self.repoRefreshButton,False) self.repoButtonbox.pack_start(self.repoInstallButton,False) self.repoVBox.pack_start(self.reposcroll,True) self.repoVBox.pack_start(self.repoButtonbox,False) self.repoRefreshButton.connect("clicked",self.refreshAvailableTemplates) self.repoInstallButton.connect("clicked",self.installButtonCallback) self.repo.add(self.repoVBox) self.pack_start(self.repo) self.show_all() self.render() def render(self): template = self.getMyObject() if not template: return self.info_displayName.set_text(template.data['name']) self.info_displayDescription.set_text(template.data['description']) self.info_displayAuthor.set_text(template.data['author']) self.repostore.clear() for available_template in template.getAvailableTemplates(): self.repostore.append((gui.IconStock.TEMPLATE, available_template['name'], available_template['description'], available_template['author'], available_template['id'])) def fileChosen(self, widget=None, data=None): self.fileToUpload = widget.get_filename() def uploadTemplate(self, widget=None, data=None): template = self.getMyObject() if not template: return if self.fileToUpload is not None and self.fileToUpload != "": template.upload(self.fileToUpload) else: raise Exception(_("No File specified")) def installRowCallback(self,treeview=None,iter=None,path=None,data=None): template = self.getMyObject() if not template: return selection = self.repotree.get_selection() rowiter = selection.get_selected()[1] if rowiter is None: raise TemplatePageException(_("You must select a Template to install it")) nr = self.repostore.get_value(rowiter,4) template.installFromRepo(nr) def installButtonCallback(self,widget=None,data=None): self.installRowCallback() def refreshAvailableTemplates(self,widget=None,data=None): template = self.getMyObject() if not template: return template.getRepoTemplates()
def __init__(self,parent,template): ObjectPageAbstract.__init__(self,parent,template) self.headline = gtk.Label() self.pack_start(self.headline,False) self.info = PageFrame(self,_("Currently Installed"), gui.IconStock.TEMPLATE) self.infobox = gtk.VBox() self.info_table = gtk.Table(2,3,False) self.info_labelName = gtk.Label(_("Name:")) self.info_labelDescription = gtk.Label(_("Description:")) self.info_labelAuthor = gtk.Label(_("Author:")) self.info_displayName = gtk.Label() self.info_displayDescription = gtk.Label() self.info_displayAuthor = gtk.Label() self.info_table.attach(self.info_labelName,0,1,0,1) self.info_table.attach(self.info_displayName,1,2,0,1) self.info_table.attach(self.info_labelDescription,0,1,1,2) self.info_table.attach(self.info_displayDescription,1,2,1,2) self.info_table.attach(self.info_labelAuthor,0,1,2,3) self.info_table.attach(self.info_displayAuthor,1,2,2,3) self.infobox.pack_start(self.info_table,False) self.info.add(self.infobox) self.pack_start(self.info,False) self.upload = PageFrame(self,_("Upload new Template"), gui.IconStock.TEMPLATE) self.uploadbox = gtk.HBox() self.uploadbox.set_border_width(10) self.upload_label = gtk.Label(_("Please choose the template and click OK")) self.upload_filechoose = gtk.FileChooserButton("Select Template", None) self.upload_filechoose.connect("file-set", self.fileChosen) self.upload_filechoose.set_size_request(200,30) self.upload_enter = gtk.Button(stock=gtk.STOCK_OK) self.upload_enter.connect("clicked", self.uploadTemplate) self.upload_dummy = gtk.Label("") self.uploadbox.pack_start(self.upload_label,False) self.uploadbox.pack_start(self.upload_filechoose,False) self.uploadbox.pack_start(self.upload_enter,False) self.uploadbox.pack_start(self.upload_dummy,True) self.upload.add(self.uploadbox) self.pack_start(self.upload,False) self.repo = PageFrame(self,_("Install Template from Repository"), gui.IconStock.TEMPLATE) self.repoVBox = gtk.VBox() self.repoButtonbox = gtk.HBox() self.repoDummy = gtk.Label("") self.repoInstallButton = gtk.Button(_("Install")) self.repoRefreshButton = gtk.Button(stock=gtk.STOCK_REFRESH) self.repostore = gtk.ListStore(gtk.gdk.Pixbuf, str, str, str, int) self.repotree = gtk.TreeView() self.repotree.set_model(self.repostore) self.reposcroll = gtk.ScrolledWindow() self.reposcroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.repocol_name = gtk.TreeViewColumn(_("Template")) self.repocol_description = gtk.TreeViewColumn(_("Description")) self.repocol_author = gtk.TreeViewColumn(_("Author")) self.reporen_icon = gtk.CellRendererPixbuf() self.reporen_name = gtk.CellRendererText() self.reporen_description = gtk.CellRendererText() self.reporen_author = gtk.CellRendererText() self.repocol_name.pack_start(self.reporen_icon,False) self.repocol_name.pack_start(self.reporen_name,False) self.repocol_description.pack_start(self.reporen_description,True) self.repocol_author.pack_start(self.reporen_author,False) self.repocol_name.add_attribute(self.reporen_icon,'pixbuf',0) self.repocol_name.add_attribute(self.reporen_name,'text',1) self.repocol_description.add_attribute(self.reporen_description,'text',2) self.repocol_author.add_attribute(self.reporen_author,'text',3) self.repotree.append_column(self.repocol_name) self.repotree.append_column(self.repocol_description) self.repotree.append_column(self.repocol_author) self.repotree.connect("row-activated",self.installRowCallback) self.reposcroll.add(self.repotree) self.repoButtonbox.pack_start(self.repoDummy,True) self.repoButtonbox.pack_start(self.repoRefreshButton,False) self.repoButtonbox.pack_start(self.repoInstallButton,False) self.repoVBox.pack_start(self.reposcroll,True) self.repoVBox.pack_start(self.repoButtonbox,False) self.repoRefreshButton.connect("clicked",self.refreshAvailableTemplates) self.repoInstallButton.connect("clicked",self.installButtonCallback) self.repo.add(self.repoVBox) self.pack_start(self.repo) self.show_all() self.render()
def __init__(self, parent, role): ObjectPageAbstract.__init__(self, parent, role) role.fetchPermissions() self.headline = gtk.Label() self.pack_start(self.headline, False) self.info = PageFrame(self, _("Information"), gui.IconStock.ROLE) self.infobox = gtk.VBox() self.info.add(self.infobox) self.pack_start(self.info, False) self.perm = PageFrame(self, _("Permissions"), gui.IconStock.PERMISSION) self.permbox = gtk.Table(1, 2, False) self.permbox.set_row_spacings(10) self.permbox.set_col_spacings(10) self.permbox.set_border_width(10) self.perm_permlabel = FrameLabel( self, _("Please choose the Permissions you want to assign to the user here:" ), gui.IconStock.PERMISSION) self.perm_permlistview = gtk.TreeView() self.perm_permlist = gtk.ListStore(int, str, str) self.perm_permlistview.set_model(self.perm_permlist) self.perm_permlist_col_checkbox = gtk.TreeViewColumn('') self.perm_permlist_col_identifier = gtk.TreeViewColumn( _('Permission Identifier')) self.perm_permlist_col_name = gtk.TreeViewColumn(_('Permission Name')) self.perm_permlistview.append_column(self.perm_permlist_col_checkbox) self.perm_permlistview.append_column(self.perm_permlist_col_identifier) self.perm_permlistview.append_column(self.perm_permlist_col_name) self.perm_permlist_renderer_checkbox = gtk.CellRendererToggle() self.perm_permlist_renderer_identifier = gtk.CellRendererText() self.perm_permlist_renderer_name = gtk.CellRendererText() self.perm_permlist_col_checkbox.pack_start( self.perm_permlist_renderer_checkbox) self.perm_permlist_col_identifier.pack_start( self.perm_permlist_renderer_identifier) self.perm_permlist_col_name.pack_start( self.perm_permlist_renderer_name) self.perm_permlist_col_checkbox.add_attribute( self.perm_permlist_renderer_checkbox, 'active', 0) self.perm_permlist_col_identifier.add_attribute( self.perm_permlist_renderer_identifier, 'text', 1) self.perm_permlist_col_name.add_attribute( self.perm_permlist_renderer_name, 'text', 2) self.perm_permlist_renderer_checkbox.set_activatable(True) self.perm_permlist_renderer_checkbox.connect("toggled", self.toggledRight) self.permbox.attach(self.perm_permlabel, 0, 1, 0, 1) self.permbox.attach(self.perm_permlistview, 0, 1, 1, 2) self.perm.add(self.permbox) self.pack_start(self.perm, False) self.show_all() self.render()
class ModulesPage(ObjectPageAbstract): def __init__(self,parent,modules): ObjectPageAbstract.__init__(self,parent,modules) self.info = PageFrame(self,_("Information"), gui.IconStock.REPO) self.infobox = gtk.VBox() self.info_table = gtk.Table(2,2,False) self.info_labelName = gtk.Label(_("Name:")) self.info_labelHost = gtk.Label(_("Host:")) self.info_displayName = gtk.Label() self.info_displayHost = gtk.Label() self.info_table.attach(self.info_labelName,0,1,0,1) self.info_table.attach(self.info_displayName,1,2,0,1) self.info_table.attach(self.info_labelHost,0,1,1,2) self.info_table.attach(self.info_displayHost,1,2,1,2) self.infobox.pack_start(self.info_table,False) self.info.add(self.infobox) self.pack_start(self.info,False) self.mod = PageFrame(self,_("Available and installed modules"), gui.IconStock.MODULE) self.modbox = gtk.Table(5,2,False) self.modbox.set_row_spacings(10) self.modbox.set_col_spacings(10) self.modbox.set_border_width(10) self.mod_label = gtk.Label(_("Please drag a module into the opposing list to install/uninstall it:\n")) self.mod_norepo_label = gtk.Label(_("Repository not reachable")) self.mod_labelInstalled = gtk.Label(_("Installed modules")) self.mod_labelAvailable = gtk.Label(_("Available modules")) self.mod_labelProcessed = gtk.Label(_("Currently processed modules")) self.mod_IListScroll = gtk.ScrolledWindow() self.mod_IListScroll.set_size_request(200,250) self.mod_IListScroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) self.mod_IList = gtk.TreeView() self.mod_IListStore = gtk.ListStore(gtk.gdk.Pixbuf, str, gtk.gdk.Pixbuf, int) self.mod_IList.set_model(self.mod_IListStore) self.mod_IList_col_module = gtk.TreeViewColumn(_('Modulename')) self.mod_IList_col_js = gtk.TreeViewColumn(_('JS')) self.mod_IList_ren_icon = gtk.CellRendererPixbuf() self.mod_IList_ren_name = gtk.CellRendererText() self.mod_IList_ren_js = gtk.CellRendererPixbuf() self.mod_IList.append_column(self.mod_IList_col_module) self.mod_IList.append_column(self.mod_IList_col_js) self.mod_IList_col_module.pack_start(self.mod_IList_ren_icon,False) self.mod_IList_col_module.pack_start(self.mod_IList_ren_name,True) self.mod_IList_col_js.pack_start(self.mod_IList_ren_js,False) self.mod_IList_col_module.add_attribute(self.mod_IList_ren_icon,'pixbuf',0) self.mod_IList_col_module.add_attribute(self.mod_IList_ren_name,'text',1) self.mod_IList_col_js.add_attribute(self.mod_IList_ren_js,'pixbuf',2) self.mod_IList_col_module.set_sort_column_id(1) self.mod_IListScroll.add(self.mod_IList) self.mod_AListScroll = gtk.ScrolledWindow() self.mod_AListScroll.set_size_request(200,250) self.mod_AListScroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) self.mod_AList = gtk.TreeView() self.mod_AListStore = gtk.ListStore(gtk.gdk.Pixbuf, str, gtk.gdk.Pixbuf, int) self.mod_AList.set_model(self.mod_AListStore) self.mod_AList_col_module = gtk.TreeViewColumn(_('Modulename')) self.mod_AList_col_js = gtk.TreeViewColumn(_('JS')) self.mod_AList_ren_icon = gtk.CellRendererPixbuf() self.mod_AList_ren_name = gtk.CellRendererText() self.mod_AList_ren_js = gtk.CellRendererPixbuf() self.mod_AList.append_column(self.mod_AList_col_module) self.mod_AList.append_column(self.mod_AList_col_js) self.mod_AList_col_module.pack_start(self.mod_AList_ren_icon,False) self.mod_AList_col_module.pack_start(self.mod_AList_ren_name,True) self.mod_AList_col_js.pack_start(self.mod_AList_ren_js,False) self.mod_AList_col_module.add_attribute(self.mod_AList_ren_icon,'pixbuf',0) self.mod_AList_col_module.add_attribute(self.mod_AList_ren_name,'text',1) self.mod_AList_col_js.add_attribute(self.mod_AList_ren_js,'pixbuf',2) self.mod_AList_col_module.set_sort_column_id(1) self.mod_AListScroll.add(self.mod_AList) self.mod_CList = OperationTool(self,modules.getSkarphed()) self.modbox.attach(self.mod_label,0,2,0,1) self.modbox.attach(self.mod_labelInstalled,0,1,1,2) self.modbox.attach(self.mod_labelAvailable,1,2,1,2) self.modbox.attach(self.mod_IListScroll,0,1,2,3) self.modbox.attach(self.mod_AListScroll,1,2,2,3) self.modbox.attach(self.mod_labelProcessed,0,2,3,4) self.modbox.attach(self.mod_CList,0,2,4,5) self.mod_AList.enable_model_drag_dest([('text/plain',0,0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_IList.enable_model_drag_dest([('text/plain',0,0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_AList.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, [('text/plain',0,0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_IList.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, [('text/plain',0,0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_AList.connect("drag-data-received", self.aListReceiveCallback) self.mod_IList.connect("drag-data-received", self.iListReceiveCallback) self.mod_AList.connect("drag-data-get", self.aListGetDataCallback) self.mod_IList.connect("drag-data-get", self.iListGetDataCallback) self.mod_AList.set_name("AList") self.mod_IList.set_name("IList") self.mod.add(self.modbox) self.pack_start(self.mod,False) self.show_all() self.render() modules.getSkarphed().getOperationManager().addCallback(self.render) self.getApplication().getObjectStore().addCallback(self.render) def iListGetDataCallback(self, treeview, context, selection, info, timestamp): treeselection = treeview.get_selection() model, rowiter = treeselection.get_selected() text = model.get_value(rowiter, 3) selection.set('text/plain', 8, str(text)) def aListGetDataCallback(self, treeview, context, selection, info, timestamp): treeselection = treeview.get_selection() model, rowiter = treeselection.get_selected() text = model.get_value(rowiter, 3) selection.set('text/plain', 8, str(text)) def iListReceiveCallback(self, treeview, context, x, y, selection, info , timestamp): if context.get_source_widget().get_name() != "AList": return module = self.getApplication().getLocalObjectById(int(selection.data)) modules = self.getMyObject() if not modules: return modules.installModule(module) def aListReceiveCallback(self, treeview, context, x, y, selection, info , timestamp): if context.get_source_widget().get_name() != "IList": return module = self.getApplication().getLocalObjectById(int(selection.data)) modules = self.getMyObject() if not modules: return modules.uninstallModule(module) def getModuleIterById(self, moduleList, moduleId): def search(model, path, rowiter, moduleId): val = model.get_value(rowiter,3) if val == moduleId: model.tempiter = rowiter moduleList.tempiter = None moduleList.foreach(search, moduleId) rowiter=moduleList.tempiter if rowiter is not None: return rowiter else: return None def render(self): def search(model, path, rowiter, processed): val = model.get_value(rowiter,3) if val not in processed: model.itersToRemove.append(rowiter) js_iconmap = { JSMandatory.NO : gui.IconStock.JS_NO, JSMandatory.SUPPORTED : gui.IconStock.JS_SUPPORTED, JSMandatory.MANDATORY : gui.IconStock.JS_MANDATORY } modules = self.getMyObject() if not modules: self.destroy() return if modules.getRepoState(): self.modbox.remove(self.mod_norepo_label) self.modbox.attach(self.mod_AListScroll,1,2,2,3) else: self.modbox.remove(self.mod_AListScroll) self.modbox.attach(self.mod_norepo_label,1,2,2,3) self.processedIListIds = [] self.processedAListIds = [] for module in modules.getAllModules(): if module.data.has_key('installed') and module.data['installed'] == True: rowiter = self.getModuleIterById(self.mod_IListStore,module.getLocalId()) if rowiter is None: self.mod_IListStore.append((gui.IconStock.getAppropriateIcon(module), module.getName(), js_iconmap[module.getJSMandatory()], module.getLocalId() )) else: self.mod_IListStore.set_value(rowiter,0,gui.IconStock.getAppropriateIcon(module)) self.mod_IListStore.set_value(rowiter,1,module.getName()) self.mod_IListStore.set_value(rowiter,2,js_iconmap[module.getJSMandatory()]) self.processedIListIds.append(module.getLocalId()) else: rowiter = self.getModuleIterById(self.mod_AListStore,module.getLocalId()) if rowiter is None: self.mod_AListStore.append((gui.IconStock.MODULE, module.getName(), js_iconmap[module.getJSMandatory()], module.getLocalId() )) else: self.mod_AListStore.set_value(rowiter,0,gui.IconStock.getAppropriateIcon(module)) self.mod_IListStore.set_value(rowiter,1,module.getName()) self.mod_IListStore.set_value(rowiter,2,js_iconmap[module.getJSMandatory()]) self.processedAListIds.append(module.getLocalId()) self.mod_IListStore.itersToRemove = [] self.mod_AListStore.itersToRemove = [] self.mod_IListStore.foreach(search, self.processedIListIds) self.mod_AListStore.foreach(search, self.processedAListIds) for rowiter in self.mod_IListStore.itersToRemove: self.mod_IListStore.remove(rowiter) for rowiter in self.mod_AListStore.itersToRemove: self.mod_AListStore.remove(rowiter)
class MenuPage(ObjectPageAbstract): def __init__(self, par, menu): ObjectPageAbstract.__init__(self,par,menu) self.info = PageFrame(self, _("Name"), IconStock.SITE) self.infobox = gtk.HBox() self.info_labelName = gtk.Label(_("Name:")) self.info_entryName = gtk.Entry() self.info_saveName = gtk.Button(stock=gtk.STOCK_SAVE) self.infobox.pack_start(self.info_labelName,False) self.infobox.pack_start(self.info_entryName,True) self.infobox.pack_start(self.info_saveName,False) self.info_saveName.connect("clicked",self.renameCallback) self.info.add(self.infobox) self.pack_start(self.info,False) self.edit = PageFrame(self, _("Edit Items"), IconStock.MENU) self.editbox = gtk.HPaned() self.edit_left_box = gtk.VBox() self.edit_toolbar = gtk.Toolbar() self.addbutton=gtk.ToolButton() self.addbutton.set_stock_id(gtk.STOCK_ADD) self.addbutton.connect("clicked", self.cb_Add) self.removebutton=gtk.ToolButton() self.removebutton.set_stock_id(gtk.STOCK_REMOVE) self.removebutton.connect("clicked", self.cb_Remove) self.increasebutton=gtk.ToolButton() self.increasebutton.set_stock_id(gtk.STOCK_GO_UP) self.increasebutton.connect("clicked", self.cb_Increase) self.decreasebutton=gtk.ToolButton() self.decreasebutton.set_stock_id(gtk.STOCK_GO_DOWN) self.decreasebutton.connect("clicked", self.cb_Decrease) self.topbutton=gtk.ToolButton() self.topbutton.set_stock_id(gtk.STOCK_GOTO_TOP) self.topbutton.connect("clicked", self.cb_Top) self.bottombutton=gtk.ToolButton() self.bottombutton.set_stock_id(gtk.STOCK_GOTO_BOTTOM) self.bottombutton.connect("clicked", self.cb_Bottom) self.edit_toolbar.add(self.addbutton) self.edit_toolbar.add(self.removebutton) self.edit_toolbar.add(self.increasebutton) self.edit_toolbar.add(self.decreasebutton) self.edit_toolbar.add(self.topbutton) self.edit_toolbar.add(self.bottombutton) self.edit_menutree = MenuItemTree(self,menu) self.edit_right_box = gtk.Frame(_("Actions")) self.actionListItem = None self.edit_left_box.pack_start(self.edit_toolbar,False) self.edit_left_box.pack_start(self.edit_menutree,True) self.editbox.add(self.edit_left_box) self.editbox.add(self.edit_right_box) self.edit.add(self.editbox) self.pack_start(self.edit) self.edit_menutree.connect("cursor-changed",self.menuItemChangeCallback) self.show_all() def render(self): menu = self.getMyObject() if not menu: return self.info_labelName.set_text(menu.getName()) def renameCallback(self,widget=None,data=None): menu = self.getMyObject() if not menu: return menu.rename(self.info_entryName.get_text()) def menuItemChangeCallback(self,*args,**kwargs): self.addbutton.set_sensitive(False) self.removebutton.set_sensitive(False) self.increasebutton.set_sensitive(False) self.decreasebutton.set_sensitive(False) self.topbutton.set_sensitive(False) self.bottombutton.set_sensitive(False) try: obj = self.edit_menutree.getSelectedMenuItem() except TypeError: return if obj.__class__.__name__ == 'MenuItem': self.addbutton.set_sensitive(True) self.removebutton.set_sensitive(True) self.increasebutton.set_sensitive(True) self.decreasebutton.set_sensitive(True) self.topbutton.set_sensitive(True) self.bottombutton.set_sensitive(True) self.showActionList(obj.getActionList()) elif obj.__class__.__name__ == 'Menu': self.addbutton.set_sensitive(True) def cb_Add(self,widget=None,data=None): self.edit_menutree.getSelectedMenuItem().createNewMenuItem() def cb_Remove(self,widget=None,data=None): item = self.edit_menutree.getSelectedMenuItem() item.getPar().deleteChildItem(item) def cb_Increase(self,widget=None,data=None): self.edit_menutree.getSelectedMenuItem().increaseOrder() def cb_Decrease(self,widget=None,data=None): self.edit_menutree.getSelectedMenuItem().decreaseOrder() def cb_Top(self,widget=None,data=None): self.edit_menutree.getSelectedMenuItem().moveToTop() def cb_Bottom(self,widget=None,data=None): self.edit_menutree.getSelectedMenuItem().moveToBottom() def showActionList(self,actionList): if self.actionListItem is not None: self.actionListItem.destroy() self.actionListItem = ActionListWidget(self,actionList) self.edit_right_box.add(self.actionListItem) def getPar(self): return self.par def getApplication(self): return self.par.getApplication()
class RolePage(ObjectPageAbstract): def __init__(self,parent,role): ObjectPageAbstract.__init__(self,parent,role) role.fetchPermissions() self.headline = gtk.Label() self.pack_start(self.headline,False) self.info = PageFrame(self,_("Information"), gui.IconStock.ROLE) self.infobox = gtk.VBox() self.info.add(self.infobox) self.pack_start(self.info,False) self.perm = PageFrame(self,_("Permissions"), gui.IconStock.PERMISSION) self.permbox = gtk.Table(1,2,False) self.permbox.set_row_spacings(10) self.permbox.set_col_spacings(10) self.permbox.set_border_width(10) self.perm_permlabel = FrameLabel(self,_("Please choose the Permissions you want to assign to the user here:"), gui.IconStock.PERMISSION) self.perm_permlistview = gtk.TreeView() self.perm_permlist = gtk.ListStore(int, str,str) self.perm_permlistview.set_model(self.perm_permlist) self.perm_permlist_col_checkbox = gtk.TreeViewColumn('') self.perm_permlist_col_identifier = gtk.TreeViewColumn(_('Permission Identifier')) self.perm_permlist_col_name = gtk.TreeViewColumn(_('Permission Name')) self.perm_permlistview.append_column(self.perm_permlist_col_checkbox) self.perm_permlistview.append_column(self.perm_permlist_col_identifier) self.perm_permlistview.append_column(self.perm_permlist_col_name) self.perm_permlist_renderer_checkbox= gtk.CellRendererToggle() self.perm_permlist_renderer_identifier = gtk.CellRendererText() self.perm_permlist_renderer_name = gtk.CellRendererText() self.perm_permlist_col_checkbox.pack_start(self.perm_permlist_renderer_checkbox) self.perm_permlist_col_identifier.pack_start(self.perm_permlist_renderer_identifier) self.perm_permlist_col_name.pack_start(self.perm_permlist_renderer_name) self.perm_permlist_col_checkbox.add_attribute(self.perm_permlist_renderer_checkbox,'active',0) self.perm_permlist_col_identifier.add_attribute(self.perm_permlist_renderer_identifier,'text',1) self.perm_permlist_col_name.add_attribute(self.perm_permlist_renderer_name,'text',2) self.perm_permlist_renderer_checkbox.set_activatable(True) self.perm_permlist_renderer_checkbox.connect("toggled",self.toggledRight) self.permbox.attach(self.perm_permlabel,0,1,0,1) self.permbox.attach(self.perm_permlistview,0,1,1,2) self.perm.add(self.permbox) self.pack_start(self.perm,False) self.show_all() self.render() def render(self): role = self.getMyObject() if not role: return self.headline.set_markup(_("<b>Edit Role: "+role.getName()+"</b>")) if role.permissiondata is not None: self.perm_permlist.clear() for permission in role.permissiondata: self.perm_permlist.append((int(permission['granted']),str(permission['right']),'')) def toggledRight(self,renderer = None, path = None): rowiter = self.perm_permlist.get_iter(path) perm = self.perm_permlist.get_value(rowiter,1) val = 1-self.perm_permlist.get_value(rowiter,0) role = self.getApplication().getLocalObjectById(self.roleId) if val == 1: role.assignPermission(perm) else: role.removePermission(perm)
def __init__(self,par,skarphed): ObjectPageAbstract.__init__(self,par,skarphed) self.headline = gtk.Label(_("Skarphed Instance")) self.pack_start(self.headline,False) self.repo = PageFrame(self,_("Repository"), gui.IconStock.REPO) self.repoDummy = gtk.Label("") self.repoHBox = gtk.HBox() self.repotable = gtk.Table(2,3) self.repoLabel = gtk.Label(_("Repository")) self.repoEntry = DefaultEntry(default_message=_("example_repo.org:80")) self.repoInfoLabel = gtk.Label(_("Please enter Repository URL here:")) self.repoOkButton = gtk.Button(stock=gtk.STOCK_OK) self.repoOkButton.connect("clicked", self.cb_changeRepo) self.repotable.attach(self.repoInfoLabel,0,2,0,1) self.repotable.attach(self.repoLabel,0,1,1,2) self.repotable.attach(self.repoEntry,1,2,1,2) self.repotable.attach(self.repoOkButton,1,2,2,3) self.repoHBox.pack_start(self.repotable,False) self.repoHBox.pack_start(self.repoDummy,True) self.repo.add(self.repoHBox) self.pack_start(self.repo,False) self.opd = OperationDaemonControl(self,skarphed.getOperationDaemon()) self.pack_start(self.opd,False) self.pki = PageFrame(self, _("Public Key"), gui.IconStock.CREDENTIAL) self.pki_label = gtk.Label(_("Instance Public Key:")) self.pki_textview = gtk.TextView() self.pki_textbuffer = gtk.TextBuffer() self.pki_textview.set_buffer(self.pki_textbuffer) self.pki_vbox = gtk.VBox() self.pki_vbox.pack_start(self.pki_label,False) self.pki_vbox.pack_start(self.pki_textview,True) self.pki.add(self.pki_vbox) self.pack_start(self.pki, False) self.settings = PageFrame(self, _("Server Settings"), gui.IconStock.SKARPHED) self.settings_vbox = gtk.VBox() self.settings_maintenance_toggle_lock = False self.settings_maintenance_hbox = gtk.HBox() self.settings_maintenance_checkbox = gtk.CheckButton(label=_("Maintenancemode active")) self.settings_maintenance_dummy = gtk.Label() self.settings_maintenance_hbox.pack_start(self.settings_maintenance_checkbox,False) self.settings_maintenance_hbox.pack_start(self.settings_maintenance_dummy,True) self.settings_maintenance_checkbox.connect("toggled", self.cb_maintenance) self.settings_vbox.pack_start(self.settings_maintenance_hbox,False) self.settings_rendermode_toggle_lock = False self.settings_rendermode_table = gtk.Table(2,2,False) self.settings_rendermode_pure = gtk.RadioButton(label=_("Pure (only static HTML)")) self.settings_rendermode_ajax = gtk.RadioButton(group=self.settings_rendermode_pure,label=_("AJAX (requires JS)")) self.settings_rendermode_dummy = gtk.Label("") self.settings_rendermode_pure.connect("toggled", self.cb_rendermode, SkarphedPage.RENDER_PURE) self.settings_rendermode_ajax.connect("toggled", self.cb_rendermode, SkarphedPage.RENDER_AJAX) self.settings_rendermode_table.attach(self.settings_rendermode_pure,0,1,0,1,gtk.FILL|gtk.SHRINK,gtk.FILL|gtk.SHRINK) self.settings_rendermode_table.attach(self.settings_rendermode_ajax,0,1,1,2,gtk.FILL|gtk.SHRINK,gtk.FILL|gtk.SHRINK) self.settings_rendermode_table.attach(self.settings_rendermode_dummy,1,2,0,2,gtk.FILL|gtk.EXPAND,gtk.FILL|gtk.EXPAND) self.settings_vbox.pack_start(self.settings_rendermode_table,False) self.settings.add(self.settings_vbox) self.pack_start(self.settings,False) self.show_all() self.render()
def __init__(self,parent,modules): ObjectPageAbstract.__init__(self,parent,modules) self.info = PageFrame(self,_("Information"), gui.IconStock.REPO) self.infobox = gtk.VBox() self.info_table = gtk.Table(2,2,False) self.info_labelName = gtk.Label(_("Name:")) self.info_labelHost = gtk.Label(_("Host:")) self.info_displayName = gtk.Label() self.info_displayHost = gtk.Label() self.info_table.attach(self.info_labelName,0,1,0,1) self.info_table.attach(self.info_displayName,1,2,0,1) self.info_table.attach(self.info_labelHost,0,1,1,2) self.info_table.attach(self.info_displayHost,1,2,1,2) self.infobox.pack_start(self.info_table,False) self.info.add(self.infobox) self.pack_start(self.info,False) self.mod = PageFrame(self,_("Available and installed modules"), gui.IconStock.MODULE) self.modbox = gtk.Table(5,2,False) self.modbox.set_row_spacings(10) self.modbox.set_col_spacings(10) self.modbox.set_border_width(10) self.mod_label = gtk.Label(_("Please drag a module into the opposing list to install/uninstall it:\n")) self.mod_norepo_label = gtk.Label(_("Repository not reachable")) self.mod_labelInstalled = gtk.Label(_("Installed modules")) self.mod_labelAvailable = gtk.Label(_("Available modules")) self.mod_labelProcessed = gtk.Label(_("Currently processed modules")) self.mod_IListScroll = gtk.ScrolledWindow() self.mod_IListScroll.set_size_request(200,250) self.mod_IListScroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) self.mod_IList = gtk.TreeView() self.mod_IListStore = gtk.ListStore(gtk.gdk.Pixbuf, str, gtk.gdk.Pixbuf, int) self.mod_IList.set_model(self.mod_IListStore) self.mod_IList_col_module = gtk.TreeViewColumn(_('Modulename')) self.mod_IList_col_js = gtk.TreeViewColumn(_('JS')) self.mod_IList_ren_icon = gtk.CellRendererPixbuf() self.mod_IList_ren_name = gtk.CellRendererText() self.mod_IList_ren_js = gtk.CellRendererPixbuf() self.mod_IList.append_column(self.mod_IList_col_module) self.mod_IList.append_column(self.mod_IList_col_js) self.mod_IList_col_module.pack_start(self.mod_IList_ren_icon,False) self.mod_IList_col_module.pack_start(self.mod_IList_ren_name,True) self.mod_IList_col_js.pack_start(self.mod_IList_ren_js,False) self.mod_IList_col_module.add_attribute(self.mod_IList_ren_icon,'pixbuf',0) self.mod_IList_col_module.add_attribute(self.mod_IList_ren_name,'text',1) self.mod_IList_col_js.add_attribute(self.mod_IList_ren_js,'pixbuf',2) self.mod_IList_col_module.set_sort_column_id(1) self.mod_IListScroll.add(self.mod_IList) self.mod_AListScroll = gtk.ScrolledWindow() self.mod_AListScroll.set_size_request(200,250) self.mod_AListScroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) self.mod_AList = gtk.TreeView() self.mod_AListStore = gtk.ListStore(gtk.gdk.Pixbuf, str, gtk.gdk.Pixbuf, int) self.mod_AList.set_model(self.mod_AListStore) self.mod_AList_col_module = gtk.TreeViewColumn(_('Modulename')) self.mod_AList_col_js = gtk.TreeViewColumn(_('JS')) self.mod_AList_ren_icon = gtk.CellRendererPixbuf() self.mod_AList_ren_name = gtk.CellRendererText() self.mod_AList_ren_js = gtk.CellRendererPixbuf() self.mod_AList.append_column(self.mod_AList_col_module) self.mod_AList.append_column(self.mod_AList_col_js) self.mod_AList_col_module.pack_start(self.mod_AList_ren_icon,False) self.mod_AList_col_module.pack_start(self.mod_AList_ren_name,True) self.mod_AList_col_js.pack_start(self.mod_AList_ren_js,False) self.mod_AList_col_module.add_attribute(self.mod_AList_ren_icon,'pixbuf',0) self.mod_AList_col_module.add_attribute(self.mod_AList_ren_name,'text',1) self.mod_AList_col_js.add_attribute(self.mod_AList_ren_js,'pixbuf',2) self.mod_AList_col_module.set_sort_column_id(1) self.mod_AListScroll.add(self.mod_AList) self.mod_CList = OperationTool(self,modules.getSkarphed()) self.modbox.attach(self.mod_label,0,2,0,1) self.modbox.attach(self.mod_labelInstalled,0,1,1,2) self.modbox.attach(self.mod_labelAvailable,1,2,1,2) self.modbox.attach(self.mod_IListScroll,0,1,2,3) self.modbox.attach(self.mod_AListScroll,1,2,2,3) self.modbox.attach(self.mod_labelProcessed,0,2,3,4) self.modbox.attach(self.mod_CList,0,2,4,5) self.mod_AList.enable_model_drag_dest([('text/plain',0,0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_IList.enable_model_drag_dest([('text/plain',0,0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_AList.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, [('text/plain',0,0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_IList.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, [('text/plain',0,0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.mod_AList.connect("drag-data-received", self.aListReceiveCallback) self.mod_IList.connect("drag-data-received", self.iListReceiveCallback) self.mod_AList.connect("drag-data-get", self.aListGetDataCallback) self.mod_IList.connect("drag-data-get", self.iListGetDataCallback) self.mod_AList.set_name("AList") self.mod_IList.set_name("IList") self.mod.add(self.modbox) self.pack_start(self.mod,False) self.show_all() self.render() modules.getSkarphed().getOperationManager().addCallback(self.render) self.getApplication().getObjectStore().addCallback(self.render)
class Skarphed_repoPage (ObjectPageAbstract): def __init__(self,par,repo): ObjectPageAbstract.__init__(self,par,repo) self.table = gtk.Table(2,4,False) self.moduleFrame=PageFrame(self, _("Modules"), IconStock.MODULE) self.moduleList = ModuleList(self,repo) self.moduleFrame.add(self.moduleList) self.pack_start(self.moduleFrame,False) self.mUploadFrame=PageFrame(self, _("Upload Module"), IconStock.MODULE) self.mUploadbox = gtk.HBox() self.mUploadbox.set_border_width(10) self.mUpload_label = gtk.Label(_("Please choose the Module and click OK")) self.mUpload_filechoose = gtk.FileChooserButton(_("Select Module"), None) self.mUpload_filechoose.connect("file-set", self.moduleFileChosen) self.mUpload_filechoose.set_size_request(200,30) self.mUpload_enter = gtk.Button(stock=gtk.STOCK_OK) self.mUpload_enter.connect("clicked", self.uploadModule) self.mUpload_dummy = gtk.Label("") self.mUploadbox.pack_start(self.mUpload_label,False) self.mUploadbox.pack_start(self.mUpload_filechoose,False) self.mUploadbox.pack_start(self.mUpload_enter,False) self.mUploadbox.pack_start(self.mUpload_dummy,True) self.mUploadFrame.add(self.mUploadbox) self.pack_start(self.mUploadFrame,False) self.templateFrame=PageFrame(self, _("Templates"), IconStock.TEMPLATE) self.templateVBox = gtk.VBox() self.templateButtonBox = gtk.HBox() self.templateDeleteButton = gtk.Button(stock=gtk.STOCK_DELETE) self.templateDummy = gtk.Label("") self.templateList = TemplateList(self,repo) self.templateVBox.pack_start(self.templateList,True) self.templateVBox.pack_start(self.templateButtonBox,False) self.templateButtonBox.pack_start(self.templateDummy,True) self.templateButtonBox.pack_start(self.templateDeleteButton,False) self.templateDeleteButton.connect("clicked",self.cb_DeleteTemplate) self.templateFrame.add(self.templateVBox) self.pack_start(self.templateFrame,False) self.tUploadFrame=PageFrame(self, _("Upload Template"), IconStock.TEMPLATE) self.tUploadbox = gtk.HBox() self.tUploadbox.set_border_width(10) self.tUpload_label = gtk.Label(_("Please choose the Template and click OK")) self.tUpload_filechoose = gtk.FileChooserButton(_("Select Template"), None) self.tUpload_filechoose.connect("file-set", self.templateFileChosen) self.tUpload_filechoose.set_size_request(200,30) self.tUpload_enter = gtk.Button(stock=gtk.STOCK_OK) self.tUpload_enter.connect("clicked", self.uploadTemplate) self.tUpload_dummy = gtk.Label("") self.tUploadbox.pack_start(self.tUpload_label,False) self.tUploadbox.pack_start(self.tUpload_filechoose,False) self.tUploadbox.pack_start(self.tUpload_enter,False) self.tUploadbox.pack_start(self.tUpload_dummy,True) self.tUploadFrame.add(self.tUploadbox) self.pack_start(self.tUploadFrame,False) self.adminFrame= PageFrame(self, _("Change Password"), IconStock.CREDENTIAL) self.adminHBox = gtk.HBox() self.adminHBoxDummy = gtk.Label("") self.adminTable= gtk.Table(2,4,False) self.adminLabel = gtk.Label(_("Change admin-password here:")) self.adminPasswordLabel = gtk.Label(_("New password")) self.adminRepeatLabel = gtk.Label(_("New password (repeat)")) self.adminPasswordEntry = gtk.Entry() self.adminPasswordEntry.set_visibility(False) self.adminPasswordEntry.set_invisible_char("●") self.adminRepeatEntry = gtk.Entry() self.adminRepeatEntry.set_visibility(False) self.adminRepeatEntry.set_invisible_char("●") self.adminButtonDummy = gtk.Label() self.adminButtonHBox = gtk.HBox() self.adminButtonChange = gtk.Button(stock=gtk.STOCK_OK) self.adminButtonHBox.pack_start(self.adminButtonDummy,True) self.adminButtonHBox.pack_start(self.adminButtonChange,False) self.adminTable.attach(self.adminLabel,0,2,0,1) self.adminTable.attach(self.adminPasswordLabel,0,1,1,2) self.adminTable.attach(self.adminPasswordEntry,1,2,1,2) self.adminTable.attach(self.adminRepeatLabel,0,1,2,3) self.adminTable.attach(self.adminRepeatEntry,1,2,2,3) self.adminTable.attach(self.adminButtonHBox,0,2,3,4) self.adminHBox.pack_start(self.adminTable,False) self.adminHBox.pack_start(self.adminHBoxDummy,True) self.adminFrame.add(self.adminHBox) self.adminButtonChange.connect("clicked", self.cb_ChangePassword) self.pack_start(self.adminFrame,False) self.developerFrame = PageFrame(self, _("Developers"), IconStock.USER) self.developerHBox= gtk.HBox() self.developerList= DeveloperList(self,repo) self.developerHBox.pack_start(self.developerList,True) self.developerTable = gtk.Table(2,5,False) self.developerButtonHBox = gtk.HBox() self.developerButtonHBoxDummy = gtk.Label() self.developerLabel = gtk.Label(_("Please enter the information for a new Developer here:")) self.developerNameLabel = gtk.Label(_("Nickname:")) self.developerFullnameLabel = gtk.Label(_("Full Name:")) self.developerPublicKeyLabel = gtk.Label(_("Public Key:")) self.developerNameEntry = DefaultEntry(default_message=_("nickname")) self.developerFullnameEntry = DefaultEntry(default_message=_("Firstname Lastname")) self.developerPublicKeyEntry = gtk.TextView() self.developerAddButton = gtk.Button(stock=gtk.STOCK_ADD) self.developerAddButton.connect("clicked", self.cb_Add) self.developerButtonHBox.pack_start(self.developerButtonHBoxDummy,True) self.developerButtonHBox.pack_start(self.developerAddButton,False) self.developerTable.attach(self.developerLabel,0,2,0,1) self.developerTable.attach(self.developerNameLabel,0,1,1,2) self.developerTable.attach(self.developerNameEntry,1,2,1,2) self.developerTable.attach(self.developerFullnameLabel,0,1,2,3) self.developerTable.attach(self.developerFullnameEntry,1,2,2,3) self.developerTable.attach(self.developerPublicKeyLabel,0,1,3,4) self.developerTable.attach(self.developerPublicKeyEntry,1,2,3,4) self.developerTable.attach(self.developerButtonHBox,0,2,4,5) self.developerHBox.pack_start(self.developerTable,False) self.developerFrame.add(self.developerHBox) self.pack_start(self.developerFrame,False) self.show_all() def render(self): repo = self.getMyObject() if not repo: return auth = repo.isAuthenticated() self.adminFrame.set_visible(auth) self.developerFrame.set_visible(auth) self.templateDeleteButton.set_visible(auth) self.moduleList.render() self.developerList.render() def cb_ChangePassword(self, widget=None, data=None): pw1 = self.adminPasswordEntry.get_text() pw2 = self.adminRepeatEntry.get_text() if pw1 == pw2: repo = self.getMyObject() repo.changePassword(pw1) else: pass #TODO: Implement error behaviour def cb_DeleteTemplate(self,widget=None,data=None): def execute(): repo = self.getMyObject() repo.deleteTemplate(self.templateToDelete) self.templateToDelete = None selection = self.templateList.treeview.get_selection() rowiter = selection.get_selected()[1] nr = self.templateList.store.get_value(rowiter,4) self.templateToDelete = nr YesNoPage(self.getApplication().getMainWindow(), _("Do you really want to delete this Template from the Repository?"), execute) def cb_Add(self,widget=None,data=None): name = self.developerNameEntry.get_text() fullName = self.developerFullnameEntry.get_text() textBuffer = self.developerPublicKeyEntry.get_buffer() publicKey = textBuffer.get_text(textBuffer.get_start_iter(),textBuffer.get_end_iter()) repo = self.getMyObject() if not repo: return repo.registerDeveloper(name,fullName,publicKey) def moduleFileChosen(self, widget=None, data=None): self.moduleFileToUpload = widget.get_filename() def templateFileChosen(self, widget=None, data=None): self.templateFileToUpload = widget.get_filename() def uploadModule(self,widget=None,data=None): repo = self.getMyObject() if not repo: return repo.uploadModule(self.moduleFileToUpload) def uploadTemplate(self,widget=None,data=None): repo = self.getMyObject() if not repo: return repo.uploadTemplate(self.templateFileToUpload)
class UserPage(ObjectPageAbstract): def __init__(self,par,user): ObjectPageAbstract.__init__(self,par,user) user.fetchRightsData() user.fetchRoleData() self.headline = gtk.Label() self.pack_start(self.headline,False) self.info = PageFrame(self,_("Information"), gui.IconStock.USER) self.infobox = gtk.VBox() self.info.add(self.infobox) self.pack_start(self.info,False) self.perm = PageFrame(self,_("Permissions / Roles"), gui.IconStock.ROLE) self.permbox = gtk.Table(2,2,False) self.permbox.set_row_spacings(10) self.permbox.set_col_spacings(10) self.permbox.set_border_width(10) self.perm_permlabel = FrameLabel(self,_("Please choose the Permissions you want to assign to the user here:"),gui.IconStock.PERMISSION) self.perm_rolelabel = FrameLabel(self,_("Please choose the Rights you want to assign to the user here:"),gui.IconStock.ROLE) self.perm_permlistview = gtk.TreeView() self.perm_permlist = gtk.ListStore(int, str,str) self.perm_permlistview.set_model(self.perm_permlist) self.perm_permlist_col_checkbox = gtk.TreeViewColumn('') self.perm_permlist_col_identifier = gtk.TreeViewColumn(_('Permission Identifier')) self.perm_permlist_col_name = gtk.TreeViewColumn(_('Permission Name')) self.perm_permlistview.append_column(self.perm_permlist_col_checkbox) self.perm_permlistview.append_column(self.perm_permlist_col_identifier) self.perm_permlistview.append_column(self.perm_permlist_col_name) self.perm_permlist_renderer_checkbox= gtk.CellRendererToggle() self.perm_permlist_renderer_identifier = gtk.CellRendererText() self.perm_permlist_renderer_name = gtk.CellRendererText() self.perm_permlist_col_checkbox.pack_start(self.perm_permlist_renderer_checkbox) self.perm_permlist_col_identifier.pack_start(self.perm_permlist_renderer_identifier) self.perm_permlist_col_name.pack_start(self.perm_permlist_renderer_name) self.perm_permlist_col_checkbox.add_attribute(self.perm_permlist_renderer_checkbox,'active',0) self.perm_permlist_col_identifier.add_attribute(self.perm_permlist_renderer_identifier,'text',1) self.perm_permlist_col_name.add_attribute(self.perm_permlist_renderer_name,'text',2) self.perm_permlist_renderer_checkbox.set_activatable(True) self.perm_permlist_renderer_checkbox.connect("toggled",self.toggledRight) self.perm_rolelistview = gtk.TreeView() self.perm_rolelist = gtk.ListStore(int, str,str,int) self.perm_rolelistview.set_model(self.perm_rolelist) self.perm_rolelist_col_checkbox = gtk.TreeViewColumn('') self.perm_rolelist_col_identifier = gtk.TreeViewColumn(_('Role Identifier')) self.perm_rolelist_col_name = gtk.TreeViewColumn(_('RoleName')) self.perm_rolelistview.append_column(self.perm_rolelist_col_checkbox) self.perm_rolelistview.append_column(self.perm_rolelist_col_identifier) self.perm_rolelistview.append_column(self.perm_rolelist_col_name) self.perm_rolelist_renderer_checkbox= gtk.CellRendererToggle() self.perm_rolelist_renderer_identifier = gtk.CellRendererText() self.perm_rolelist_renderer_name = gtk.CellRendererText() self.perm_rolelist_col_checkbox.pack_start(self.perm_rolelist_renderer_checkbox) self.perm_rolelist_col_identifier.pack_start(self.perm_rolelist_renderer_identifier) self.perm_rolelist_col_name.pack_start(self.perm_rolelist_renderer_name) self.perm_rolelist_col_checkbox.add_attribute(self.perm_rolelist_renderer_checkbox,'active',0) self.perm_rolelist_col_identifier.add_attribute(self.perm_rolelist_renderer_identifier,'text',1) self.perm_rolelist_col_name.add_attribute(self.perm_rolelist_renderer_name,'text',2) self.perm_rolelist_renderer_checkbox.set_activatable(True) self.perm_rolelist_renderer_checkbox.connect("toggled",self.toggledRole) self.permbox.attach(self.perm_permlabel,0,1,0,1) self.permbox.attach(self.perm_permlistview,0,1,1,2) self.permbox.attach(self.perm_rolelabel,1,2,0,1) self.permbox.attach(self.perm_rolelistview,1,2,1,2) self.perm.add(self.permbox) self.pack_start(self.perm,False) self.alterpw = PageFrame(self, _("Alter Password"), gui.IconStock.CREDENTIAL) self.alterpwhbox = gtk.HBox() self.alterpwdummy = gtk.Label("") self.alterpwbox = gtk.Table(2,4,False) self.alterpwbox.set_row_spacings(10) self.alterpwbox.set_col_spacings(10) self.alterpwbox.set_border_width(10) self.alterpw_oldpw_label = gtk.Label(_("Old Password:"******"New Password:"******"Repeat Password:"******"●") self.alterpw_oldpw_entry.set_visibility(False) self.alterpw_newpw1_entry = gtk.Entry() self.alterpw_newpw1_entry.set_invisible_char("●") self.alterpw_newpw1_entry.set_visibility(False) self.alterpw_newpw2_entry = gtk.Entry() self.alterpw_newpw2_entry.set_invisible_char("●") self.alterpw_newpw2_entry.set_visibility(False) self.alterpw_ok = gtk.Button(_("Alter Password")) self.alterpwbox.attach(self.alterpw_oldpw_label,0,1,0,1) self.alterpwbox.attach(self.alterpw_oldpw_entry,1,2,0,1) self.alterpwbox.attach(self.alterpw_newpw1_label,0,1,1,2) self.alterpwbox.attach(self.alterpw_newpw1_entry,1,2,1,2) self.alterpwbox.attach(self.alterpw_newpw2_label,0,1,2,3) self.alterpwbox.attach(self.alterpw_newpw2_entry,1,2,2,3) self.alterpwbox.attach(self.alterpw_ok,1,2,3,4) self.alterpwhbox.pack_start(self.alterpwbox,False) self.alterpwhbox.pack_start(self.alterpwdummy,True) self.alterpw.add(self.alterpwhbox) self.alterpw_ok.connect("clicked", self.alterPassword) self.pack_start(self.alterpw,False) self.show_all() self.render() def render(self): user = self.getMyObject() if not user: return self.headline.set_markup(_("<b>Settings for User: "******"</b>") if user.permissiondata is not None: self.perm_permlist.clear() for permission in user.permissiondata: self.perm_permlist.append((int(permission['granted']),str(permission['right']),'')) if user.roledata is not None: self.perm_rolelist.clear() for role in user.roledata: self.perm_rolelist.append((int(role['granted']), str(role['name']), '', role['id'])) alter_pw_permitted = user.getUsers().getSkarphed().checkPermission("skarphed.users.alter_password") is_active_user = user.getUsers().getSkarphed().getUsername() == user.getName() if alter_pw_permitted or is_active_user: self.alterpw.set_visible(True) self.alterpw_oldpw_entry.set_visible(is_active_user) self.alterpw_oldpw_label.set_visible(is_active_user) else: self.alterpw.set_visible(False) def alterPassword(self, widget=None, data=None): user = self.getMyObject() if not user: return alter_pw_permitted = user.getUsers().getSkarphed().checkPermission("skarphed.users.alter_password") is_active_user = user.getUsers().getSkarphed().getUsername() == user.getName() if alter_pw_permitted or is_active_user: if is_active_user: oldpw = self.alterpw_oldpw_entry.get_text() newpw1 = self.alterpw_newpw1_entry.get_text() newpw2 = self.alterpw_newpw2_entry.get_text() if newpw2 != newpw1: return False # Password repeat not successful if newpw1 == "": return False # New password is empty if is_active_user: user.alterPassword(newpw1,oldpw) else: user.alterPassword(newpw1) def toggledRole(self,render=None,path=None): rowiter = self.perm_rolelist.get_iter(path) roleId = self.perm_rolelist.get_value(rowiter,3) val = 1-self.perm_rolelist.get_value(rowiter,0) user = self.getMyObject() if not user: return if val == 1: user.assignRole(roleId) else: user.removeRole(roleId) def toggledRight(self,render=None,path=None): rowiter = self.perm_permlist.get_iter(path) perm = self.perm_permlist.get_value(rowiter,1) val = 1-self.perm_permlist.get_value(rowiter,0) user = self.getMyObject() if not user: return if val == 1: user.assignPermission(perm) else: user.removePermission(perm)
def __init__(self, par, repo): ObjectPageAbstract.__init__(self, par, repo) self.table = gtk.Table(2, 4, False) self.moduleFrame = PageFrame(self, _("Modules"), IconStock.MODULE) self.moduleList = ModuleList(self, repo) self.moduleFrame.add(self.moduleList) self.pack_start(self.moduleFrame, False) self.mUploadFrame = PageFrame(self, _("Upload Module"), IconStock.MODULE) self.mUploadbox = gtk.HBox() self.mUploadbox.set_border_width(10) self.mUpload_label = gtk.Label( _("Please choose the Module and click OK")) self.mUpload_filechoose = gtk.FileChooserButton( _("Select Module"), None) self.mUpload_filechoose.connect("file-set", self.moduleFileChosen) self.mUpload_filechoose.set_size_request(200, 30) self.mUpload_enter = gtk.Button(stock=gtk.STOCK_OK) self.mUpload_enter.connect("clicked", self.uploadModule) self.mUpload_dummy = gtk.Label("") self.mUploadbox.pack_start(self.mUpload_label, False) self.mUploadbox.pack_start(self.mUpload_filechoose, False) self.mUploadbox.pack_start(self.mUpload_enter, False) self.mUploadbox.pack_start(self.mUpload_dummy, True) self.mUploadFrame.add(self.mUploadbox) self.pack_start(self.mUploadFrame, False) self.templateFrame = PageFrame(self, _("Templates"), IconStock.TEMPLATE) self.templateVBox = gtk.VBox() self.templateButtonBox = gtk.HBox() self.templateDeleteButton = gtk.Button(stock=gtk.STOCK_DELETE) self.templateDummy = gtk.Label("") self.templateList = TemplateList(self, repo) self.templateVBox.pack_start(self.templateList, True) self.templateVBox.pack_start(self.templateButtonBox, False) self.templateButtonBox.pack_start(self.templateDummy, True) self.templateButtonBox.pack_start(self.templateDeleteButton, False) self.templateDeleteButton.connect("clicked", self.cb_DeleteTemplate) self.templateFrame.add(self.templateVBox) self.pack_start(self.templateFrame, False) self.tUploadFrame = PageFrame(self, _("Upload Template"), IconStock.TEMPLATE) self.tUploadbox = gtk.HBox() self.tUploadbox.set_border_width(10) self.tUpload_label = gtk.Label( _("Please choose the Template and click OK")) self.tUpload_filechoose = gtk.FileChooserButton( _("Select Template"), None) self.tUpload_filechoose.connect("file-set", self.templateFileChosen) self.tUpload_filechoose.set_size_request(200, 30) self.tUpload_enter = gtk.Button(stock=gtk.STOCK_OK) self.tUpload_enter.connect("clicked", self.uploadTemplate) self.tUpload_dummy = gtk.Label("") self.tUploadbox.pack_start(self.tUpload_label, False) self.tUploadbox.pack_start(self.tUpload_filechoose, False) self.tUploadbox.pack_start(self.tUpload_enter, False) self.tUploadbox.pack_start(self.tUpload_dummy, True) self.tUploadFrame.add(self.tUploadbox) self.pack_start(self.tUploadFrame, False) self.adminFrame = PageFrame(self, _("Change Password"), IconStock.CREDENTIAL) self.adminHBox = gtk.HBox() self.adminHBoxDummy = gtk.Label("") self.adminTable = gtk.Table(2, 4, False) self.adminLabel = gtk.Label(_("Change admin-password here:")) self.adminPasswordLabel = gtk.Label(_("New password")) self.adminRepeatLabel = gtk.Label(_("New password (repeat)")) self.adminPasswordEntry = gtk.Entry() self.adminPasswordEntry.set_visibility(False) self.adminPasswordEntry.set_invisible_char("●") self.adminRepeatEntry = gtk.Entry() self.adminRepeatEntry.set_visibility(False) self.adminRepeatEntry.set_invisible_char("●") self.adminButtonDummy = gtk.Label() self.adminButtonHBox = gtk.HBox() self.adminButtonChange = gtk.Button(stock=gtk.STOCK_OK) self.adminButtonHBox.pack_start(self.adminButtonDummy, True) self.adminButtonHBox.pack_start(self.adminButtonChange, False) self.adminTable.attach(self.adminLabel, 0, 2, 0, 1) self.adminTable.attach(self.adminPasswordLabel, 0, 1, 1, 2) self.adminTable.attach(self.adminPasswordEntry, 1, 2, 1, 2) self.adminTable.attach(self.adminRepeatLabel, 0, 1, 2, 3) self.adminTable.attach(self.adminRepeatEntry, 1, 2, 2, 3) self.adminTable.attach(self.adminButtonHBox, 0, 2, 3, 4) self.adminHBox.pack_start(self.adminTable, False) self.adminHBox.pack_start(self.adminHBoxDummy, True) self.adminFrame.add(self.adminHBox) self.adminButtonChange.connect("clicked", self.cb_ChangePassword) self.pack_start(self.adminFrame, False) self.developerFrame = PageFrame(self, _("Developers"), IconStock.USER) self.developerHBox = gtk.HBox() self.developerList = DeveloperList(self, repo) self.developerHBox.pack_start(self.developerList, True) self.developerTable = gtk.Table(2, 5, False) self.developerButtonHBox = gtk.HBox() self.developerButtonHBoxDummy = gtk.Label() self.developerLabel = gtk.Label( _("Please enter the information for a new Developer here:")) self.developerNameLabel = gtk.Label(_("Nickname:")) self.developerFullnameLabel = gtk.Label(_("Full Name:")) self.developerPublicKeyLabel = gtk.Label(_("Public Key:")) self.developerNameEntry = DefaultEntry(default_message=_("nickname")) self.developerFullnameEntry = DefaultEntry( default_message=_("Firstname Lastname")) self.developerPublicKeyEntry = gtk.TextView() self.developerAddButton = gtk.Button(stock=gtk.STOCK_ADD) self.developerAddButton.connect("clicked", self.cb_Add) self.developerButtonHBox.pack_start(self.developerButtonHBoxDummy, True) self.developerButtonHBox.pack_start(self.developerAddButton, False) self.developerTable.attach(self.developerLabel, 0, 2, 0, 1) self.developerTable.attach(self.developerNameLabel, 0, 1, 1, 2) self.developerTable.attach(self.developerNameEntry, 1, 2, 1, 2) self.developerTable.attach(self.developerFullnameLabel, 0, 1, 2, 3) self.developerTable.attach(self.developerFullnameEntry, 1, 2, 2, 3) self.developerTable.attach(self.developerPublicKeyLabel, 0, 1, 3, 4) self.developerTable.attach(self.developerPublicKeyEntry, 1, 2, 3, 4) self.developerTable.attach(self.developerButtonHBox, 0, 2, 4, 5) self.developerHBox.pack_start(self.developerTable, False) self.developerFrame.add(self.developerHBox) self.pack_start(self.developerFrame, False) self.show_all()
def __init__(self,par,repo): ObjectPageAbstract.__init__(self,par,repo) self.table = gtk.Table(2,4,False) self.moduleFrame=PageFrame(self, _("Modules"), IconStock.MODULE) self.moduleList = ModuleList(self,repo) self.moduleFrame.add(self.moduleList) self.pack_start(self.moduleFrame,False) self.mUploadFrame=PageFrame(self, _("Upload Module"), IconStock.MODULE) self.mUploadbox = gtk.HBox() self.mUploadbox.set_border_width(10) self.mUpload_label = gtk.Label(_("Please choose the Module and click OK")) self.mUpload_filechoose = gtk.FileChooserButton(_("Select Module"), None) self.mUpload_filechoose.connect("file-set", self.moduleFileChosen) self.mUpload_filechoose.set_size_request(200,30) self.mUpload_enter = gtk.Button(stock=gtk.STOCK_OK) self.mUpload_enter.connect("clicked", self.uploadModule) self.mUpload_dummy = gtk.Label("") self.mUploadbox.pack_start(self.mUpload_label,False) self.mUploadbox.pack_start(self.mUpload_filechoose,False) self.mUploadbox.pack_start(self.mUpload_enter,False) self.mUploadbox.pack_start(self.mUpload_dummy,True) self.mUploadFrame.add(self.mUploadbox) self.pack_start(self.mUploadFrame,False) self.templateFrame=PageFrame(self, _("Templates"), IconStock.TEMPLATE) self.templateVBox = gtk.VBox() self.templateButtonBox = gtk.HBox() self.templateDeleteButton = gtk.Button(stock=gtk.STOCK_DELETE) self.templateDummy = gtk.Label("") self.templateList = TemplateList(self,repo) self.templateVBox.pack_start(self.templateList,True) self.templateVBox.pack_start(self.templateButtonBox,False) self.templateButtonBox.pack_start(self.templateDummy,True) self.templateButtonBox.pack_start(self.templateDeleteButton,False) self.templateDeleteButton.connect("clicked",self.cb_DeleteTemplate) self.templateFrame.add(self.templateVBox) self.pack_start(self.templateFrame,False) self.tUploadFrame=PageFrame(self, _("Upload Template"), IconStock.TEMPLATE) self.tUploadbox = gtk.HBox() self.tUploadbox.set_border_width(10) self.tUpload_label = gtk.Label(_("Please choose the Template and click OK")) self.tUpload_filechoose = gtk.FileChooserButton(_("Select Template"), None) self.tUpload_filechoose.connect("file-set", self.templateFileChosen) self.tUpload_filechoose.set_size_request(200,30) self.tUpload_enter = gtk.Button(stock=gtk.STOCK_OK) self.tUpload_enter.connect("clicked", self.uploadTemplate) self.tUpload_dummy = gtk.Label("") self.tUploadbox.pack_start(self.tUpload_label,False) self.tUploadbox.pack_start(self.tUpload_filechoose,False) self.tUploadbox.pack_start(self.tUpload_enter,False) self.tUploadbox.pack_start(self.tUpload_dummy,True) self.tUploadFrame.add(self.tUploadbox) self.pack_start(self.tUploadFrame,False) self.adminFrame= PageFrame(self, _("Change Password"), IconStock.CREDENTIAL) self.adminHBox = gtk.HBox() self.adminHBoxDummy = gtk.Label("") self.adminTable= gtk.Table(2,4,False) self.adminLabel = gtk.Label(_("Change admin-password here:")) self.adminPasswordLabel = gtk.Label(_("New password")) self.adminRepeatLabel = gtk.Label(_("New password (repeat)")) self.adminPasswordEntry = gtk.Entry() self.adminPasswordEntry.set_visibility(False) self.adminPasswordEntry.set_invisible_char("●") self.adminRepeatEntry = gtk.Entry() self.adminRepeatEntry.set_visibility(False) self.adminRepeatEntry.set_invisible_char("●") self.adminButtonDummy = gtk.Label() self.adminButtonHBox = gtk.HBox() self.adminButtonChange = gtk.Button(stock=gtk.STOCK_OK) self.adminButtonHBox.pack_start(self.adminButtonDummy,True) self.adminButtonHBox.pack_start(self.adminButtonChange,False) self.adminTable.attach(self.adminLabel,0,2,0,1) self.adminTable.attach(self.adminPasswordLabel,0,1,1,2) self.adminTable.attach(self.adminPasswordEntry,1,2,1,2) self.adminTable.attach(self.adminRepeatLabel,0,1,2,3) self.adminTable.attach(self.adminRepeatEntry,1,2,2,3) self.adminTable.attach(self.adminButtonHBox,0,2,3,4) self.adminHBox.pack_start(self.adminTable,False) self.adminHBox.pack_start(self.adminHBoxDummy,True) self.adminFrame.add(self.adminHBox) self.adminButtonChange.connect("clicked", self.cb_ChangePassword) self.pack_start(self.adminFrame,False) self.developerFrame = PageFrame(self, _("Developers"), IconStock.USER) self.developerHBox= gtk.HBox() self.developerList= DeveloperList(self,repo) self.developerHBox.pack_start(self.developerList,True) self.developerTable = gtk.Table(2,5,False) self.developerButtonHBox = gtk.HBox() self.developerButtonHBoxDummy = gtk.Label() self.developerLabel = gtk.Label(_("Please enter the information for a new Developer here:")) self.developerNameLabel = gtk.Label(_("Nickname:")) self.developerFullnameLabel = gtk.Label(_("Full Name:")) self.developerPublicKeyLabel = gtk.Label(_("Public Key:")) self.developerNameEntry = DefaultEntry(default_message=_("nickname")) self.developerFullnameEntry = DefaultEntry(default_message=_("Firstname Lastname")) self.developerPublicKeyEntry = gtk.TextView() self.developerAddButton = gtk.Button(stock=gtk.STOCK_ADD) self.developerAddButton.connect("clicked", self.cb_Add) self.developerButtonHBox.pack_start(self.developerButtonHBoxDummy,True) self.developerButtonHBox.pack_start(self.developerAddButton,False) self.developerTable.attach(self.developerLabel,0,2,0,1) self.developerTable.attach(self.developerNameLabel,0,1,1,2) self.developerTable.attach(self.developerNameEntry,1,2,1,2) self.developerTable.attach(self.developerFullnameLabel,0,1,2,3) self.developerTable.attach(self.developerFullnameEntry,1,2,2,3) self.developerTable.attach(self.developerPublicKeyLabel,0,1,3,4) self.developerTable.attach(self.developerPublicKeyEntry,1,2,3,4) self.developerTable.attach(self.developerButtonHBox,0,2,4,5) self.developerHBox.pack_start(self.developerTable,False) self.developerFrame.add(self.developerHBox) self.pack_start(self.developerFrame,False) self.show_all()
class Skarphed_repoPage(ObjectPageAbstract): def __init__(self, par, repo): ObjectPageAbstract.__init__(self, par, repo) self.table = gtk.Table(2, 4, False) self.moduleFrame = PageFrame(self, _("Modules"), IconStock.MODULE) self.moduleList = ModuleList(self, repo) self.moduleFrame.add(self.moduleList) self.pack_start(self.moduleFrame, False) self.mUploadFrame = PageFrame(self, _("Upload Module"), IconStock.MODULE) self.mUploadbox = gtk.HBox() self.mUploadbox.set_border_width(10) self.mUpload_label = gtk.Label( _("Please choose the Module and click OK")) self.mUpload_filechoose = gtk.FileChooserButton( _("Select Module"), None) self.mUpload_filechoose.connect("file-set", self.moduleFileChosen) self.mUpload_filechoose.set_size_request(200, 30) self.mUpload_enter = gtk.Button(stock=gtk.STOCK_OK) self.mUpload_enter.connect("clicked", self.uploadModule) self.mUpload_dummy = gtk.Label("") self.mUploadbox.pack_start(self.mUpload_label, False) self.mUploadbox.pack_start(self.mUpload_filechoose, False) self.mUploadbox.pack_start(self.mUpload_enter, False) self.mUploadbox.pack_start(self.mUpload_dummy, True) self.mUploadFrame.add(self.mUploadbox) self.pack_start(self.mUploadFrame, False) self.templateFrame = PageFrame(self, _("Templates"), IconStock.TEMPLATE) self.templateVBox = gtk.VBox() self.templateButtonBox = gtk.HBox() self.templateDeleteButton = gtk.Button(stock=gtk.STOCK_DELETE) self.templateDummy = gtk.Label("") self.templateList = TemplateList(self, repo) self.templateVBox.pack_start(self.templateList, True) self.templateVBox.pack_start(self.templateButtonBox, False) self.templateButtonBox.pack_start(self.templateDummy, True) self.templateButtonBox.pack_start(self.templateDeleteButton, False) self.templateDeleteButton.connect("clicked", self.cb_DeleteTemplate) self.templateFrame.add(self.templateVBox) self.pack_start(self.templateFrame, False) self.tUploadFrame = PageFrame(self, _("Upload Template"), IconStock.TEMPLATE) self.tUploadbox = gtk.HBox() self.tUploadbox.set_border_width(10) self.tUpload_label = gtk.Label( _("Please choose the Template and click OK")) self.tUpload_filechoose = gtk.FileChooserButton( _("Select Template"), None) self.tUpload_filechoose.connect("file-set", self.templateFileChosen) self.tUpload_filechoose.set_size_request(200, 30) self.tUpload_enter = gtk.Button(stock=gtk.STOCK_OK) self.tUpload_enter.connect("clicked", self.uploadTemplate) self.tUpload_dummy = gtk.Label("") self.tUploadbox.pack_start(self.tUpload_label, False) self.tUploadbox.pack_start(self.tUpload_filechoose, False) self.tUploadbox.pack_start(self.tUpload_enter, False) self.tUploadbox.pack_start(self.tUpload_dummy, True) self.tUploadFrame.add(self.tUploadbox) self.pack_start(self.tUploadFrame, False) self.adminFrame = PageFrame(self, _("Change Password"), IconStock.CREDENTIAL) self.adminHBox = gtk.HBox() self.adminHBoxDummy = gtk.Label("") self.adminTable = gtk.Table(2, 4, False) self.adminLabel = gtk.Label(_("Change admin-password here:")) self.adminPasswordLabel = gtk.Label(_("New password")) self.adminRepeatLabel = gtk.Label(_("New password (repeat)")) self.adminPasswordEntry = gtk.Entry() self.adminPasswordEntry.set_visibility(False) self.adminPasswordEntry.set_invisible_char("●") self.adminRepeatEntry = gtk.Entry() self.adminRepeatEntry.set_visibility(False) self.adminRepeatEntry.set_invisible_char("●") self.adminButtonDummy = gtk.Label() self.adminButtonHBox = gtk.HBox() self.adminButtonChange = gtk.Button(stock=gtk.STOCK_OK) self.adminButtonHBox.pack_start(self.adminButtonDummy, True) self.adminButtonHBox.pack_start(self.adminButtonChange, False) self.adminTable.attach(self.adminLabel, 0, 2, 0, 1) self.adminTable.attach(self.adminPasswordLabel, 0, 1, 1, 2) self.adminTable.attach(self.adminPasswordEntry, 1, 2, 1, 2) self.adminTable.attach(self.adminRepeatLabel, 0, 1, 2, 3) self.adminTable.attach(self.adminRepeatEntry, 1, 2, 2, 3) self.adminTable.attach(self.adminButtonHBox, 0, 2, 3, 4) self.adminHBox.pack_start(self.adminTable, False) self.adminHBox.pack_start(self.adminHBoxDummy, True) self.adminFrame.add(self.adminHBox) self.adminButtonChange.connect("clicked", self.cb_ChangePassword) self.pack_start(self.adminFrame, False) self.developerFrame = PageFrame(self, _("Developers"), IconStock.USER) self.developerHBox = gtk.HBox() self.developerList = DeveloperList(self, repo) self.developerHBox.pack_start(self.developerList, True) self.developerTable = gtk.Table(2, 5, False) self.developerButtonHBox = gtk.HBox() self.developerButtonHBoxDummy = gtk.Label() self.developerLabel = gtk.Label( _("Please enter the information for a new Developer here:")) self.developerNameLabel = gtk.Label(_("Nickname:")) self.developerFullnameLabel = gtk.Label(_("Full Name:")) self.developerPublicKeyLabel = gtk.Label(_("Public Key:")) self.developerNameEntry = DefaultEntry(default_message=_("nickname")) self.developerFullnameEntry = DefaultEntry( default_message=_("Firstname Lastname")) self.developerPublicKeyEntry = gtk.TextView() self.developerAddButton = gtk.Button(stock=gtk.STOCK_ADD) self.developerAddButton.connect("clicked", self.cb_Add) self.developerButtonHBox.pack_start(self.developerButtonHBoxDummy, True) self.developerButtonHBox.pack_start(self.developerAddButton, False) self.developerTable.attach(self.developerLabel, 0, 2, 0, 1) self.developerTable.attach(self.developerNameLabel, 0, 1, 1, 2) self.developerTable.attach(self.developerNameEntry, 1, 2, 1, 2) self.developerTable.attach(self.developerFullnameLabel, 0, 1, 2, 3) self.developerTable.attach(self.developerFullnameEntry, 1, 2, 2, 3) self.developerTable.attach(self.developerPublicKeyLabel, 0, 1, 3, 4) self.developerTable.attach(self.developerPublicKeyEntry, 1, 2, 3, 4) self.developerTable.attach(self.developerButtonHBox, 0, 2, 4, 5) self.developerHBox.pack_start(self.developerTable, False) self.developerFrame.add(self.developerHBox) self.pack_start(self.developerFrame, False) self.show_all() def render(self): repo = self.getMyObject() if not repo: return auth = repo.isAuthenticated() self.adminFrame.set_visible(auth) self.developerFrame.set_visible(auth) self.templateDeleteButton.set_visible(auth) self.moduleList.render() self.developerList.render() def cb_ChangePassword(self, widget=None, data=None): pw1 = self.adminPasswordEntry.get_text() pw2 = self.adminRepeatEntry.get_text() if pw1 == pw2: repo = self.getMyObject() repo.changePassword(pw1) else: pass #TODO: Implement error behaviour def cb_DeleteTemplate(self, widget=None, data=None): def execute(): repo = self.getMyObject() repo.deleteTemplate(self.templateToDelete) self.templateToDelete = None selection = self.templateList.treeview.get_selection() rowiter = selection.get_selected()[1] nr = self.templateList.store.get_value(rowiter, 4) self.templateToDelete = nr YesNoPage( self.getApplication().getMainWindow(), _("Do you really want to delete this Template from the Repository?" ), execute) def cb_Add(self, widget=None, data=None): name = self.developerNameEntry.get_text() fullName = self.developerFullnameEntry.get_text() textBuffer = self.developerPublicKeyEntry.get_buffer() publicKey = textBuffer.get_text(textBuffer.get_start_iter(), textBuffer.get_end_iter()) repo = self.getMyObject() if not repo: return repo.registerDeveloper(name, fullName, publicKey) def moduleFileChosen(self, widget=None, data=None): self.moduleFileToUpload = widget.get_filename() def templateFileChosen(self, widget=None, data=None): self.templateFileToUpload = widget.get_filename() def uploadModule(self, widget=None, data=None): repo = self.getMyObject() if not repo: return repo.uploadModule(self.moduleFileToUpload) def uploadTemplate(self, widget=None, data=None): repo = self.getMyObject() if not repo: return repo.uploadTemplate(self.templateFileToUpload)