Пример #1
0
    def _createWidgets(self):
        self.overrideCB = wx.CheckBox(
            self, wx.ID_ANY,
            _extstr(u"templatesubpage.OverrideAccountTemplate"))  #$NON-NLS-1$

        self.panel = ZTransparentPanel(self, wx.ID_ANY)
        self._createTemplateWidgets(self.panel)
Пример #2
0
 def __init__(self, parent, provider):
     ZTransparentPanel.__init__(self, parent, wx.ID_ANY)
     self.orginalValue = u"" #$NON-NLS-1$
     self.trackbackListProvider = provider
     self._createWidgets()
     self._layoutWidgets()
     self._bindWidgetEvents()
Пример #3
0
    def _createWindowWidgets(self, parent):
        self.headerPanel = self._createHeaderPanel(parent)
        self.headerStaticLine = wx.StaticLine(parent, wx.ID_ANY)

        self.splitterWindow = ZSplitterWindow(parent)
        self.splitterWindow.SetSizeHints(700, 600)

        self.topPanel = ZTransparentPanel(self.splitterWindow, wx.ID_ANY)
        self.topStaticBox = wx.StaticBox(self.topPanel, wx.ID_ANY, _extstr(u"templatemanager.Templates")) #$NON-NLS-1$

        provider = ZTemplateListProvider(self.model)
        self.templateList = ZListViewEx(provider, self.topPanel)

        self.addButton = wx.Button(self.topPanel, wx.ID_ANY, _extstr(u"templatemanager.Add")) #$NON-NLS-1$
        self.removeButton = wx.Button(self.topPanel, wx.ID_ANY, _extstr(u"templatemanager.Remove")) #$NON-NLS-1$
        self.removeButton.Enable(False)

        self.preview = ZHTMLViewControl(self.splitterWindow, wx.ID_ANY, style = wx.NO_FULL_REPAINT_ON_RESIZE | wx.SIMPLE_BORDER)

        self.splitterWindow.SetSashSize(10)
        self.splitterWindow.SplitHorizontally(self.topPanel, self.preview, 150)
        self.splitterWindow.SetMinimumPaneSize(100)

        self.statusBar = self._createStatusBar()
        self.SetStatusBar(self.statusBar)
Пример #4
0
    def _createWidgets(self):
        self.overrideCB = wx.CheckBox(self, wx.ID_ANY,
                                      self._getOverrideLabel())

        self.panel = ZTransparentPanel(self, wx.ID_ANY)

        self.pubOptionsStaticBox = wx.StaticBox(
            self.panel, wx.ID_ANY,
            _extstr(u"pubsubpage.PublishingOptions"))  #$NON-NLS-1$
        self.poweredByCB = wx.CheckBox(
            self.panel, wx.ID_ANY,
            _extstr(u"pubsubpage.AddPoweredByZoundry"))  #$NON-NLS-1$
        self.removeNewLinesCB = wx.CheckBox(
            self.panel, wx.ID_ANY,
            _extstr(u"pubsubpage.RemoveNewLines"))  #$NON-NLS-1$

        self.imageUploadStaticBox = wx.StaticBox(
            self.panel, wx.ID_ANY,
            _extstr(u"pubsubpage.ImageUpload"))  #$NON-NLS-1$
        self.tnsOnlyCB = wx.CheckBox(
            self.panel, wx.ID_ANY,
            _extstr(u"pubsubpage.UploadTNsOnly"))  #$NON-NLS-1$
        self.forceUploadCB = wx.CheckBox(
            self.panel, wx.ID_ANY,
            _extstr(u"pubsubpage.ReUploadImages"))  #$NON-NLS-1$
        self.lightboxCB = wx.CheckBox(
            self.panel, wx.ID_ANY,
            _extstr(u"pubsubpage.AddLightbox"))  #$NON-NLS-1$
Пример #5
0
 def __init__(self, parent, provider):
     ZTransparentPanel.__init__(self, parent, wx.ID_ANY)
     self.orginalValue = u""  #$NON-NLS-1$
     self.trackbackListProvider = provider
     self._createWidgets()
     self._layoutWidgets()
     self._bindWidgetEvents()
Пример #6
0
    def _createWidgets(self):
        self.overrideCB = wx.CheckBox(
            self, wx.ID_ANY,
            _extstr(u"storesubpage.OverrideAccountMediaStorageSetting"
                    ))  #$NON-NLS-1$

        self.panel = ZTransparentPanel(self, wx.ID_ANY)
        self._createStoreWidgets(self.panel)
Пример #7
0
    def __init__(self, parent, model):
        self.blog = None

        ZTransparentPanel.__init__(self, parent, wx.ID_ANY, style = wx.NO_BORDER)
        self.htmlWidget = None
        self.model = model
        self._createWidgets()
        self._bindWidgetEvents()
        self._layoutWidgets()
Пример #8
0
 def __init__(self, parent, id):
     ZTransparentPanel.__init__(self, parent, id)
     self.mshtmlIHtmlDocumentCtrl = None
     self.customDoc = None
     self.uiHandler = None
     self.interactive = False
     self.initialized = False
     self._createWidgets()
     self._layoutWidgets()
     self._bindWidgetEvents()
Пример #9
0
 def __init__(self, parent, id):
     ZTransparentPanel.__init__(self, parent, id)
     self.mshtmlIHtmlDocumentCtrl = None
     self.customDoc = None
     self.uiHandler = None
     self.interactive = False
     self.initialized = False
     self._createWidgets()
     self._layoutWidgets()
     self._bindWidgetEvents()
Пример #10
0
    def _createWidgets(self):
        self.overrideCB = wx.CheckBox(self, wx.ID_ANY,
                                      self._getOverrideTagSitesLabel())
        self.panel = ZTransparentPanel(self, wx.ID_ANY)

        self.staticBox = wx.StaticBox(
            self.panel, wx.ID_ANY,
            _extstr(u"tagsubpage.TagSites"))  #$NON-NLS-1$
        self.contentProvider = ZTagspaceListContentProvider()
        self.tagSites = ZCheckBoxListViewWithButtons(self.contentProvider,
                                                     self.panel, wx.ID_ANY)
Пример #11
0
    def __init__(self, parentModel, task, parent):
        self.parentModel = parentModel
        self.model = ZBackgroundTaskPanelModel()
        self.mutex = ZMutex()
        self.task = task

        ZTransparentPanel.__init__(self, parent, wx.ID_ANY)
        self.task.attachListener(self)

        self._initPanel()
        self.refresh()
Пример #12
0
    def __init__(self, parentModel, task, parent):
        self.parentModel = parentModel
        self.model = ZBackgroundTaskPanelModel()
        self.mutex = ZMutex()
        self.task = task

        ZTransparentPanel.__init__(self, parent, wx.ID_ANY)
        self.task.attachListener(self)

        self._initPanel()
        self.refresh()
Пример #13
0
class ZBlogMediaStoragePrefSubPage(ZMediaStoragePrefSubPage):
    def __init__(self, parent, session):
        ZMediaStoragePrefSubPage.__init__(self, parent, session)

    # end __init__()

    def _createWidgets(self):
        self.overrideCB = wx.CheckBox(
            self, wx.ID_ANY,
            _extstr(u"storesubpage.OverrideAccountMediaStorageSetting"
                    ))  #$NON-NLS-1$

        self.panel = ZTransparentPanel(self, wx.ID_ANY)
        self._createStoreWidgets(self.panel)

    # end _createWidgets()

    def _bindWidgetEvents(self):
        ZMediaStoragePrefSubPage._bindWidgetEvents(self)
        self.Bind(wx.EVT_CHECKBOX, self.onOverrideCB, self.overrideCB)

    # end _bindWidgetEvents()

    def _populateWidgets(self):
        override = self._getSession().isOverrideMediaStorage()
        self.overrideCB.SetValue(override)
        self.panel.Enable(override)

        ZMediaStoragePrefSubPage._populateWidgets(self)

    # end _populateWidgets()

    def _layoutWidgets(self):
        panelBox = self._createStoreLayout()
        self.panel.SetSizer(panelBox)
        self.panel.SetAutoLayout(True)

        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(self.overrideCB, 0, wx.TOP | wx.LEFT, 5)
        box.Add(self.panel, 1, wx.EXPAND | wx.ALL, 5)

        self.SetAutoLayout(True)
        self.SetSizer(box)
        self.Layout()

    # end layoutWidgets()

    def onOverrideCB(self, event):
        override = event.IsChecked()
        self.panel.Enable(override)
        self._getSession().setOverrideMediaStorage(override)
        event.Skip()
Пример #14
0
 def createWidgets(self):
     self.staticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"prefpage.general.proxy.name")) #$NON-NLS-1$
     
     self.enableCB = wx.CheckBox(self, wx.ID_ANY, _extstr(u"prefpage.general.proxy.enable")) #$NON-NLS-1$
     self.controlsPanel = ZTransparentPanel(self, wx.ID_ANY)
     self.hostLabel = wx.StaticText(self.controlsPanel, wx.ID_ANY, _extstr(u"prefpage.general.proxy.host")) #$NON-NLS-1$
     self.hostTxt = wx.TextCtrl(self.controlsPanel, wx.ID_ANY)
     self.portLabel = wx.StaticText(self.controlsPanel, wx.ID_ANY, _extstr(u"prefpage.general.proxy.port")) #$NON-NLS-1$
     flags = ZIntegerSelectionValidator.ALLOW_EMPTY | ZIntegerSelectionValidator.POSITIVE_ONLY
     self.portTxt = ZValidatingTextCtrl(ZIntegerSelectionValidator(flags=flags), self.controlsPanel, wx.ID_ANY)
     
     self.usernameLabel = wx.StaticText(self.controlsPanel, wx.ID_ANY, _extstr(u"prefpage.general.proxy.username")) #$NON-NLS-1$
     self.usernameTxt = wx.TextCtrl(self.controlsPanel, wx.ID_ANY)
     self.passwordLabel = wx.StaticText(self.controlsPanel, wx.ID_ANY, _extstr(u"prefpage.general.proxy.password")) #$NON-NLS-1$
     self.passwordTxt = wx.TextCtrl(self.controlsPanel, wx.ID_ANY, style=wx.TE_PASSWORD)
Пример #15
0
    def __init__(self, parent, dateTime=None, resetTime=None):
        self.resetTuple = self._getDateTupleFromSchemaDateTime(resetTime)
        self.dateTimeFormatType = ZDateTimeChooser.FORMAT_US

        ZTransparentPanel.__init__(self, parent, wx.ID_ANY)

        #        df = (u"blogui.wx_datecontrol") #$NON-NLS-1$
        #        if df and df.lower().strip() == u"ddmmyyyy": #$NON-NLS-1$
        #            self.dateFormatType = ZDateTimeChooser.FORMAT_DDMMYYYY
        #        elif df and df.lower().strip() == u"yyyymmdd": #$NON-NLS-1$
        #            self.dateFormatType = ZDateTimeChooser.FORMAT_YYYYMMDD

        self._createWidgets()
        self._populateWidgets()
        self._layoutWidgets()
        self._bindWidgetEvents()

        self.setDateTime(dateTime)
Пример #16
0
    def __init__(self, parent, dateTime = None, resetTime = None):
        self.resetTuple = self._getDateTupleFromSchemaDateTime(resetTime)
        self.dateTimeFormatType = ZDateTimeChooser.FORMAT_US
        
        ZTransparentPanel.__init__(self, parent, wx.ID_ANY)

#        df = (u"blogui.wx_datecontrol") #$NON-NLS-1$
#        if df and df.lower().strip() == u"ddmmyyyy": #$NON-NLS-1$
#            self.dateFormatType = ZDateTimeChooser.FORMAT_DDMMYYYY
#        elif df and df.lower().strip() == u"yyyymmdd": #$NON-NLS-1$
#            self.dateFormatType = ZDateTimeChooser.FORMAT_YYYYMMDD

        self._createWidgets()
        self._populateWidgets()
        self._layoutWidgets()
        self._bindWidgetEvents()
        
        self.setDateTime(dateTime)
Пример #17
0
    def __init__(self, parent):
        self.currentPage = None
        self.toolIdToPageMap = {}

        ZTransparentPanel.__init__(self, parent, wx.ID_ANY)
        
        self.toolArea = ZToolBookToolArea(self)
        self.separator = wx.StaticLine(self, wx.ID_ANY)
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.toolArea, 0, wx.EXPAND)
        sizer.Add(self.separator, 0, wx.EXPAND)
        
        self.toolPageSizer = wx.BoxSizer(wx.VERTICAL)
        sizer.AddSizer(self.toolPageSizer, 1, wx.EXPAND)

        self.Bind(ZEVT_TOOLBOOK_SELECTED, self.onToolSelected, self)
        
        self.SetAutoLayout(True)
        self.SetSizer(sizer)
        self.Layout()
Пример #18
0
    def createUIPanel(self, parent):
        self.panel = ZTransparentPanel(parent, wx.ID_ANY)
        self.splitterWindow = ZSplitterWindow(self.panel)

        self._createToolBar(self.panel)
        self._createNavigatorView(self.splitterWindow)
        self._createContextInfoView(self.splitterWindow)

        self._doSplit()

        self._bindViewEvents()

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.toolBar, 0, wx.EXPAND)
        self.sizer.Add(self.toolBarStaticLine, 0, wx.EXPAND)
        self.sizer.Add(self.splitterWindow, 1, wx.EXPAND | wx.ALL, 5)

        self.panel.SetAutoLayout(True)
        self.panel.SetSizer(self.sizer)

        self.panel.Layout()
        self._restoreLayout()
        return self.panel
Пример #19
0
    def __init__(self,
                 contentProvider,
                 parent,
                 id=wx.ID_ANY,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=None,
                 validator=wx.DefaultValidator,
                 name=u"ZCheckBoxListView"):  #$NON-NLS-1$
        self.contentProvider = contentProvider
        self.style = style
        self.validator = validator

        ZTransparentPanel.__init__(self,
                                   parent,
                                   id,
                                   pos=pos,
                                   size=size,
                                   name=name)

        self._createWidgets()
        self._layoutWidgets()
        self._bindWidgetEvents()
Пример #20
0
    def _createLeftTreePanel(self):
        panel = ZTransparentPanel(self.splitterWindow,
                                  wx.ID_ANY,
                                  style=wx.NO_BORDER)

        # Create the prefs tree view.
        provider = self._createTreeProvider()
        treeStyle = wx.NO_BORDER | wx.TR_HIDE_ROOT | wx.TR_LINES_AT_ROOT | wx.TR_SINGLE | wx.TR_HAS_BUTTONS
        self.prefsTreeView = ZTreeView(provider, panel, style=treeStyle)
        self.prefsTreeView.refresh()

        self.treeButtons = self._createTreeButtons(panel)

        # Create a little static vertical line (aesthetic only)
        self.middleStaticLine = wx.StaticLine(panel, style=wx.LI_VERTICAL)

        return panel
Пример #21
0
class ZTagSitesPrefSubPage(ZAccountPrefsSubPage):
    def __init__(self, parent, session):
        ZAccountPrefsSubPage.__init__(self, parent, session)

    # end __init__()

    def _createWidgets(self):
        self.overrideCB = wx.CheckBox(self, wx.ID_ANY,
                                      self._getOverrideTagSitesLabel())
        self.panel = ZTransparentPanel(self, wx.ID_ANY)

        self.staticBox = wx.StaticBox(
            self.panel, wx.ID_ANY,
            _extstr(u"tagsubpage.TagSites"))  #$NON-NLS-1$
        self.contentProvider = ZTagspaceListContentProvider()
        self.tagSites = ZCheckBoxListViewWithButtons(self.contentProvider,
                                                     self.panel, wx.ID_ANY)

    # end _createWidgets()

    def _getOverrideTagSitesLabel(self):
        return _extstr(u"tagsubpage.OverrideGlobalTagSettings")  #$NON-NLS-1$

    # end _getOverrideTagSitesLabel()

    def _bindWidgetEvents(self):
        self.Bind(wx.EVT_CHECKBOX, self.onOverrideCB, self.overrideCB)
        self.Bind(ZEVT_CHECKBOX_LIST_CHANGE, self.onCheckListChange,
                  self.tagSites)

    # end _bindWidgetEvents()

    def _populateWidgets(self):
        override = self._getSession().isOverrideTagSites()
        self.overrideCB.SetValue(override)
        self.panel.Enable(override)
        self.contentProvider.setSelectedTagSpaceUrls(
            self._getSession().getSelectedTagSites())
        self.tagSites.refresh()

    # end _populateWidgets()

    def _layoutWidgets(self):
        sbSizer = wx.StaticBoxSizer(self.staticBox, wx.VERTICAL)
        sbSizer.Add(self.tagSites, 1, wx.EXPAND | wx.ALL, 8)

        self.panel.SetSizer(sbSizer)
        self.panel.SetAutoLayout(True)

        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(self.overrideCB, 0, wx.ALL | wx.EXPAND, 5)
        box.Add(self.panel, 1, wx.ALL | wx.EXPAND, 5)

        self.SetAutoLayout(True)
        self.SetSizer(box)
        self.Layout()

    # end layoutWidgets()

    def onOverrideCB(self, event):
        override = event.IsChecked()
        self._getSession().setOverrideTagSites(override)
        if override:
            sites = self.contentProvider.getSelectedTagSpaceUrls()
            self._getSession().setSelectedTagSites(sites)
        self._populateWidgets()
        event.Skip()

    # end onOverrideCB()

    def onCheckListChange(self, event):
        if self.overrideCB.IsChecked():
            sites = self.contentProvider.getSelectedTagSpaceUrls()
            self._getSession().setSelectedTagSites(sites)
        event.Skip()
Пример #22
0
 def __init__(self, *args, **kw):
     ZTransparentPanel.__init__(self, *args, **kw)
Пример #23
0
 def __init__(self, parent):
     ZTransparentPanel.__init__(self, parent, wx.ID_ANY)
     self.wpPublishStatusValue = ZPubMetaDataView.WP_PUBLISHED
     self._createWidgets()
     self._layoutWidgets()
     self._bindWidgetEvents()
Пример #24
0
class ZTemplateManagerWindow(ZBaseWindow, ZPersistentDialogMixin, IZTemplateServiceListener):

    def __init__(self, parent):
        self.model = ZTemplateManagerModel()
        self.selectedTemplate = None

        style = wx.DEFAULT_FRAME_STYLE | wx.FULL_REPAINT_ON_RESIZE | wx.CLIP_CHILDREN
        ZBaseWindow.__init__(self, parent, _extstr(u"templatemanager.BlogTemplateManager"), name = u"ZTemplateManager", style = style) #$NON-NLS-2$ #$NON-NLS-1$
        ZPersistentDialogMixin.__init__(self, IZBlogAppUserPrefsKeys.TEMPLATE_WINDOW)
        self.Layout()

        self._installListener()
    # end __init__()

    def getModel(self):
        return self.model
    # end getModel()

    def _createWindowWidgets(self, parent):
        self.headerPanel = self._createHeaderPanel(parent)
        self.headerStaticLine = wx.StaticLine(parent, wx.ID_ANY)

        self.splitterWindow = ZSplitterWindow(parent)
        self.splitterWindow.SetSizeHints(700, 600)

        self.topPanel = ZTransparentPanel(self.splitterWindow, wx.ID_ANY)
        self.topStaticBox = wx.StaticBox(self.topPanel, wx.ID_ANY, _extstr(u"templatemanager.Templates")) #$NON-NLS-1$

        provider = ZTemplateListProvider(self.model)
        self.templateList = ZListViewEx(provider, self.topPanel)

        self.addButton = wx.Button(self.topPanel, wx.ID_ANY, _extstr(u"templatemanager.Add")) #$NON-NLS-1$
        self.removeButton = wx.Button(self.topPanel, wx.ID_ANY, _extstr(u"templatemanager.Remove")) #$NON-NLS-1$
        self.removeButton.Enable(False)

        self.preview = ZHTMLViewControl(self.splitterWindow, wx.ID_ANY, style = wx.NO_FULL_REPAINT_ON_RESIZE | wx.SIMPLE_BORDER)

        self.splitterWindow.SetSashSize(10)
        self.splitterWindow.SplitHorizontally(self.topPanel, self.preview, 150)
        self.splitterWindow.SetMinimumPaneSize(100)

        self.statusBar = self._createStatusBar()
        self.SetStatusBar(self.statusBar)
    # end _createWindowWidgets()

    def _createHeaderPanel(self, parent):
        panel = wx.Panel(parent, wx.ID_ANY)
        panel.SetBackgroundColour(wx.WHITE)

        self.headerLink = wx.HyperlinkCtrl(panel, wx.ID_ANY, self._getHeaderTitle(), self._getHeaderHelpURL())
        self.headerLink.SetFont(getDefaultFontBold())
        self.headerMessage = wx.StaticText(panel, wx.ID_ANY, self._getHeaderMessage())
        headerImagePath = self._getHeaderImagePath()
        if not headerImagePath:
            headerImagePath = u"images/dialogs/image/header_image.png" #$NON-NLS-1$
        self.headerIcon = ZStaticBitmap(panel, getResourceRegistry().getBitmap(headerImagePath))

        linkAndMsgSizer = wx.BoxSizer(wx.VERTICAL)
        linkAndMsgSizer.Add(self.headerLink, 0, wx.ALL, 2)
        linkAndMsgSizer.Add(self.headerMessage, 1, wx.EXPAND | wx.ALL, 2)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.AddSizer(linkAndMsgSizer, 1, wx.EXPAND | wx.ALL, 5)
        sizer.Add(self.headerIcon, 0, wx.EXPAND | wx.ALL, 10)

        panel.SetAutoLayout(True)
        panel.SetSizer(sizer)

        return panel
    # end _createHeaderPanel()

    def _createStatusBar(self):
        self.statusBarModel = ZStatusBarModel()
        self.statusBarModel.addPane(u"name") #$NON-NLS-1$
        self.statusBarModel.setPaneWidth(u"name", 1) #$NON-NLS-1$
        self.statusBarModel.setPaneText(u"name", u"") #$NON-NLS-1$ #$NON-NLS-2$
        provider = ZStatusBarModelBasedContentProvider(self.statusBarModel)
        statusBar = ZStatusBar(self, provider)
        return statusBar
    # end _createStatusBar()

    def _populateWindowWidgets(self):
        self.SetIcons(getResourceRegistry().getIconBundle(ICON_IMAGES))
        self.refresh()
    # end _populateWindowWidgets()

    def _layoutWindowWidgets(self):
        staticBoxSizer = wx.StaticBoxSizer(self.topStaticBox, wx.VERTICAL)
        staticBoxSizer.Add(self.templateList, 1, wx.ALL | wx.EXPAND, 3)
        buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
        buttonSizer.Add(self.addButton, 0, wx.ALL | wx.EXPAND, 2)
        buttonSizer.Add(self.removeButton, 0, wx.ALL | wx.EXPAND, 2)
        staticBoxSizer.AddSizer(buttonSizer, 0, wx.ALL | wx.EXPAND, 2)

        self.topPanel.SetSizer(staticBoxSizer)
        self.topPanel.SetAutoLayout(True)

        sizer = wx.BoxSizer(wx.VERTICAL)

        sizer.Add(self.headerPanel, 0, wx.EXPAND | wx.ALL, 0)
        sizer.Add(self.headerStaticLine, 0, wx.EXPAND | wx.ALL, 0)
        sizer.Add(self.splitterWindow, 1, wx.EXPAND | wx.ALL, 5)

        return sizer
    # end _layoutWindowWidgets()

    def _bindWidgetEvents(self):
        self.Bind(wx.EVT_BUTTON, self.onAdd, self.addButton)
        self.Bind(wx.EVT_BUTTON, self.onRemove, self.removeButton)
        self.Bind(wx.EVT_CLOSE, self.onClose, self)
        self.Bind(ZEVT_REFRESH, self.onRefresh, self)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onTemplateSelected, self.templateList)
        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.onTemplateRightClick, self.templateList)
    # end _bindWidgetEvents()

    def onRefresh(self, event):
        self.templateList.Refresh()
        event.Skip()
    # end onRefresh()

    def onAdd(self, event):
        action = ZAddTemplateFromBlogAction()
        action.runAction(ZTemplateManagerActionContext(self, self.selectedTemplate))
        event.Skip()
    # end onAdd()

    def onRemove(self, event):
        action = ZRemoveTemplateAction()
        action.runAction(ZTemplateManagerActionContext(self, self.selectedTemplate))
        event.Skip()
    # end onRemove()

    def onTemplateSelected(self, event):
        self.selectedTemplate = self.model.getTemplates()[event.GetItem().GetId()]
        self.removeButton.Enable(True)
        self.refresh()
        event.Skip()
    # end onTemplateSelected()

    def onTemplateRightClick(self, event):
        event.Skip()
    # end onTemplateRightClick()

    def _setInitialFocus(self):
        pass
    # end _setInitialFocus()

    def refresh(self):
        self.templateList.refresh()
        self.statusBar.refresh()
        if self.selectedTemplate is not None:
            document = self.model.getSampleDocument()
            xhtmlDoc = applyTemplateToDocument(self.selectedTemplate, document, APPLY_TEMPLATE_MODE_FULL)
            disableTemplatePreviewJavaScript(xhtmlDoc)
        else:
            xhtmlDoc = loadXhtmlDocumentFromString(u"Select a template to view a preview of it.") #$NON-NLS-1$
        self.preview.setXhtmlDocument(xhtmlDoc, False)
    # end refresh()

    def _getHeaderTitle(self):
        return _extstr(u"templatemanager.BlogTemplateManager") #$NON-NLS-1$
    # end _getHeaderTitle()

    def _getHeaderMessage(self):
        return _extstr(u"templatemanager.BlogTemplateManagerDescription") #$NON-NLS-1$
    # end _getHeaderMessage()

    def _getHeaderImagePath(self):
        return u"images/dialogs/template/manager/header_image.png" #$NON-NLS-1$
    # end _getHeaderImagePath()

    def _getHeaderHelpURL(self):
        return u"http://www.zoundry.com" #$NON-NLS-1$
    # end _getHeaderHelpUrl()

    def onClose(self, event):
        global TEMPLATE_MANAGER_WINDOW
        TEMPLATE_MANAGER_WINDOW = None

        self._uninstallListener()

        event.Skip()
    # end onClose()

    def _installListener(self):
        self.model.getService().addListener(self)
    # end _installListener()

    def _uninstallListener(self):
        self.model.getService().removeListener(self)
    # end _uninstallListener()

    def onTemplateCreated(self, template): #@UnusedVariable
        fireUIExecEvent(ZMethodRunnable(self.refresh), self)
    # end onTemplateCreated()

    def onTemplateDeleted(self, template):
        if self.selectedTemplate.getId() == template.getId():
            self.selectedTemplate = None

        self.refresh()
        self.templateList.deselectAll()
        self.removeButton.Enable(False)
    # end onTemplateDeleted()

    def onTemplateModified(self, template): #@UnusedVariable
        fireUIExecEvent(ZMethodRunnable(self.refresh), self)
Пример #25
0
 def __init__(self, *args, **kw):
     ZTransparentPanel.__init__(self, *args, **kw)
     self.capabilities = self._createCapabilities()
Пример #26
0
class ZBlogPostEditor(ZEditor, IZDataStoreListener, IZTemplateServiceListener):

    def __init__(self, parent, document):
        self.parent = parent
        self.notebook = None
        self.model = ZBlogPostEditorModel()
        self.model.setDocument(document)
        self.wysiwygContentEditor = None
        self.xhtmlContentEditor = None
        self.contentPreviewer = None
        self.activeContentEditor = None
        self.previewMode = False
        self.currentPreviewTemplate = None
        self.dataStoreService = getApplicationModel().getService(IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID)
        self.templateService = getApplicationModel().getService(IZBlogAppServiceIDs.TEMPLATE_SERVICE_ID)

        ZEditor.__init__(self, parent)

        self.bitmap = self._createEditorBitmap()
        self.menuBarModel = self._createMenuBarModel()
        self.toolBarModel = self._createToolBarModel()
        self.statusBarModel = self._createStatusBarModel()

        self._registerAsListener()
        self._startSnapshotTimer()
    # end __init__()

    def getActiveContentEditor(self):
        return self.activeContentEditor
    # end getActiveContentEditor()

    def _setActiveContentEditor(self, editor):
        if not (editor == self.wysiwygContentEditor or editor == self.xhtmlContentEditor):
            return

        # FIXME (PJ) switch only if content is dirty i.e. not to lose current selection info, and cursor/caret position etc.
        # copy current editor ui data (including xhtml content) to the model
        self._updateModel()
        # switch editors
        self.activeContentEditor = editor
        # update ui based on model data
        self._refreshContentEditorUI()
    # end _setActiveContentEditor()

    def _updateModel(self):
        # update model data based on current ui data.
        self.getActiveContentEditor().updateModel()
    # end _updateModel()

    def _refreshContentEditorUI(self):
        # update ui based on current model data
        self.getActiveContentEditor().refreshUI()
    # end _refreshContentEditorUI()

    def _showPreview(self):
        xhtmlDoc = self.getActiveContentEditor()._getContentEditControl().getXhtmlDocument()
        # Get the current blog selection from the UI control.
        if self.currentPreviewTemplate is not None:
            document = ZBlogPostEditorPreviewDocument(self.getTitle(), xhtmlDoc)
            templatedDoc = applyTemplateToDocument(self.currentPreviewTemplate, document, APPLY_TEMPLATE_MODE_FULL)
            if templatedDoc is not None:
                xhtmlDoc = templatedDoc
                disableTemplatePreviewJavaScript(xhtmlDoc)
        self.contentPreviewer.setXhtmlDocument(xhtmlDoc, False)
    # end _showPreview()

    def _isWysiwygActive(self):
        return self.previewMode == False and self.activeContentEditor is not None and self.activeContentEditor == self.wysiwygContentEditor
    # end _isWysiwygActive()

    def _isXhtmlActive(self):
        return self.previewMode == False and self.activeContentEditor is not None and self.activeContentEditor == self.xhtmlContentEditor
    # end _isXhtmlActive()

    def _isPreviewActive(self):
        return self.previewMode
    # end _isPreviewActive()

    def getTitle(self):
        return self.model.getTitle()
    # end getTitle()

    def getBitmap(self):
        return self.bitmap
    # end getBitmap()

    def getMenuBarModel(self):
        return self.menuBarModel
    # end getMenuBarModel()

    def getToolBarModel(self):
        return self.toolBarModel
    # end getToolBarModel()

    def getStatusBarModel(self):
        return self.statusBarModel
    # end getStatusBarModel()

    def getDocumentId(self):
        return self.model.getDocument().getId()
    # end getDocumentId()

    def getDocument(self):
        return self.model.getDocument()
    # end getDocument()

    def getToolBarActionContext(self):
        return ZBlogPostEditorToolBarActionContext(self)
    # end getToolBarActionContext()

    def getMenuActionContext(self):
        return ZBlogPostEditorMenuActionContext(self)
    # end getMenuActionContext

    def getAcceleratorActionContext(self):
        return ZBlogPostEditorMenuActionContext(self)
    # end getAcceleratorActionContext

    def save(self):
        self._clearRecoverySnapshot()
        # Flush data from UI controls to document model
        self._updateModel()
        portableFilesCopies = self._checkForNonPortableFiles()
        # save model documen to data store
        self.model.saveDocument()
        self.getActiveContentEditor().modelSaved()
        self.setDirty(False)
        if portableFilesCopies:
            # refresh editor UI if files were copies to the portable profile resource store
            self.getActiveContentEditor().refreshUI()            
    # end save()

    def _checkForNonPortableFiles(self):
        xhtmlDoc = self.getDocument().getContent().getXhtmlDocument()
        # This method copies non portable files/images to resource store and updates the  img src (href) attribute values.
        # Returns true if files were copies.
        return copyNonPortableFiles(self, xhtmlDoc)
    # end _checkForNonPortableFiles

    def close(self):
        pass
    # end close()

    def destroy(self):
        self._stopSnapshotTimer()
        self._unregisterAsListener()
        self._clearRecoverySnapshot()
    # end destroy()

    def hasCapability(self, capabilityKey): #@UnusedVariable
        if not self._isPreviewActive():
            # delegate to the content editor's edit control
            return self.getActiveContentEditor().hasCapability(capabilityKey)
        else:
            return False
    # end hasCapability()

    def _createMenuBarModel(self):
        return ZBlogPostEditorMenuBarModel(self)
    # end getMenuBarModel()

    def _createToolBarModel(self):
        return ZBlogPostEditorToolBarModel()
    # end _createToolBarModel()

    def _createStatusBarModel(self):
        # FIXME (PJ) need a proper implementation of the status bar model, this is just a sample
        # Instead showing datetime, show word count, current tag name etc.
        sbModel = ZStatusBarModel()
        pane = sbModel.addPane(u"datetime") #$NON-NLS-1$
        pane.text = formatLocalDateAndTime( self.model.getDocument().getCreationTime() )
        
        pane = sbModel.addPane(u"rowcol") #$NON-NLS-1$
        sbModel.setPaneWidth(u"rowcol", 80) #$NON-NLS-1$
        pane.text = u"" #$NON-NLS-1$
        return sbModel
    # end _createStatusBarModel()

    def _createEditorWidgets(self):
        self._createAcceleratorTable()

        self.notebook = fnb.FlatNotebook(self, wx.ID_ANY, style = fnb.FNB_BOTTOM | fnb.FNB_NO_NAV_BUTTONS | fnb.FNB_NO_X_BUTTON | fnb.FNB_NODRAG)
        self.notebook.AddPage(self._createWysiwygPage(), _extstr(u"blogeditor.Design"), True, -1) #$NON-NLS-1$
        self.notebook.AddPage(self._createXHTMLPage(), _extstr(u"blogeditor.XHTML"), False, -1) #$NON-NLS-1$
        self.notebook.AddPage(self._createPreviewPage(), _extstr(u"blogeditor.Preview"), False, -1) #$NON-NLS-1$
    # end _createEditorWidgets()

    def _createWysiwygPage(self):
        self.wysiwygContentEditor = ZBlogPostContentEditorFactory().createContentWysiwygEditor(self.notebook, self, self.model)
        return self.wysiwygContentEditor
    # end _createDesignPage()

    def _createXHTMLPage(self):
        self.xhtmlContentEditor = ZBlogPostContentEditorFactory().createContentXhtmlEditor(self.notebook, self, self.model)
        self.xhtmlContentEditor.SetBackgroundColour(wx.WHITE)
        return self.xhtmlContentEditor
    # end _createXHTMLPage()

    def _createPreviewPage(self):
        self.previewTabPanel = ZTransparentPanel(self.notebook, wx.ID_ANY)
        self._createPreviewTools(self.previewTabPanel)
        self.contentPreviewer = ZBlogPostContentEditorFactory().createContentPreviewer(self.previewTabPanel, self, self.model)
        self.contentPreviewer.SetBackgroundColour(wx.WHITE)
        return self.previewTabPanel
    # end _createPreviewPage()

    def _createPreviewTools(self, parent):
        self.templateChooseLabel = wx.StaticText(parent, wx.ID_ANY, _extstr(u"blogeditor.ViewWithTemplate")) #$NON-NLS-1$
        self.templateChooser = wx.combo.BitmapComboBox(parent, wx.ID_ANY, style = wx.CB_READONLY)
        self.previewStaticLine = wx.StaticLine(parent, wx.ID_ANY)
    # end _createPreviewTools()

    def _createAcceleratorTable(self):
        self.acceleratorTable = ZBlogPostEditorAcceleratorTable(self.getAcceleratorActionContext())
        self.SetAcceleratorTable(self.acceleratorTable)
    # end _createAcceleratorTable()

    def _populateEditorWidgets(self):
        self.activeContentEditor = self.wysiwygContentEditor
        self._refreshContentEditorUI()

        self._updateTemplateUI()
    # end _populateEditorWidgets()

    def _updateTemplateUI(self):
        blog = self._getBlog()
        self.currentPreviewTemplate = None
        currentTemplateId = None
        if blog is not None:
            templateId = blog.getTemplateId()
            if templateId is not None:
                currentTemplateId = templateId
                template = self.templateService.getTemplate(templateId)
                if template:
                    self.currentPreviewTemplate = template
        self._updateTemplateChooser(currentTemplateId)
    # end _updateTemplateUI()

    def _updateTemplateChooser(self, currentTemplateId = None):
        if currentTemplateId is None and self.currentPreviewTemplate is not None:
            currentTemplateId = self.currentPreviewTemplate.getId()
        self.templateChooser.Clear()

        bitmap = getResourceRegistry().getBitmap(u"images/dialogs/template/manager/template.png") #$NON-NLS-1$
        self.templateChooser.Append(_extstr(u"blogeditor.__NoTemplate__"), wx.NullBitmap, u"_no_template_") #$NON-NLS-2$ #$NON-NLS-1$
        idx = 1
        for template in self.templateService.getTemplates():
            self.templateChooser.Append(template.getName(), bitmap, template.getId())
            if template.getId() == currentTemplateId:
                self.templateChooser.Select(idx)
            idx = idx + 1
        (w, h) = self.templateChooser.GetBestSizeTuple()
        self.templateChooser.SetMinSize(wx.Size(w + 18, h))
        if currentTemplateId is None:
            self.templateChooser.Select(0)
    # end _updateTemplateUI()

    def _layoutEditorWidgets(self):
        self._layoutPreviewWidgets()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.notebook, 1, wx.EXPAND)
        return sizer
    # end _layoutEditorWidgets()

    def _layoutPreviewWidgets(self):
        chooserSizer = wx.BoxSizer(wx.HORIZONTAL)
        chooserSizer.Add(self.templateChooseLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 3)
        chooserSizer.Add(self.templateChooser, 0, wx.ALL, 3)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.AddSizer(chooserSizer, 0, wx.ALL | wx.EXPAND)
        sizer.Add(self.previewStaticLine, 0, wx.ALL | wx.EXPAND)
        sizer.Add(self.contentPreviewer, 1, wx.ALL | wx.EXPAND)
        self.previewTabPanel.SetSizer(sizer)
        self.previewTabPanel.SetAutoLayout(True)
    # end _layoutPreviewWidgets()

    def _bindWidgetEvents(self):
        self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CHANGING, self.onTabChanging)
        self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.onTabChanged)
        self.Bind(ZEVT_PUBLISHING_CHANGE, self.onPublishingChange)
        self.Bind(ZEVT_META_DATA_TITLE_CHANGED, self.onTitleChanged)
        self.Bind(wx.EVT_COMBOBOX, self.onTemplateChooser, self.templateChooser)
        self.acceleratorTable.bindTo(self)
    # end _bindWidgetEvents()

    def _setInitialFocus(self):
        document = self.getDocument()
        title = document.getTitle()
        if title:
            self.getActiveContentEditor().focusOnContent()
    # end _setInitialFocus()

    def _createEditorBitmap(self):
        # FIXME (EPW) change the icon for blog posts
        return getApplicationModel().getResourceRegistry().getBitmap(u"images/mainapp/icon/icon16x16.png") #$NON-NLS-1$
    # end _createEditorBitmap()

    def onTabChanging(self, event):
        editorTabId = event.GetSelection()
        self.previewMode = False
        # switch to wysiwyg
        if editorTabId == 0 and not self._isWysiwygActive():
            self._setActiveContentEditor(self.wysiwygContentEditor)
        # switch to xthml text editor
        elif editorTabId == 1 and not self._isXhtmlActive():
            self._setActiveContentEditor(self.xhtmlContentEditor)
        elif editorTabId == 2:
            self.previewMode = True
            self._updateModel()
            self._updateTemplateUI()
            self._showPreview()
            # clear (row, col) text in status bar for preview control
            self.statusBarModel.setPaneText(u"rowcol", u"") #$NON-NLS-1$ #$NON-NLS-2$
        # update toolbar (e.g. disable paste, cut actions )
        self._fireToolBarChangedEvent()
        self._fireMenuBarChangedEvent()
        self._fireStatusBarChangedEvent()
    # end onTabChanging()

    def onTabChanged(self, event):
        event.Skip()
    # end onTabChanged()

    def onTitleChanged(self, event):
        self.model.setTitle(event.getTitle())
        self._fireTitleChangedEvent()
        event.Skip()
    # end onTitleChanged()

    def onPublishingChange(self, event):
        self.setDirty(True)
        event.Skip()
    # end onPublishingChange()

    def onMenuClose(self, menuContext): #@UnusedVariable
        self._fireCloseEvent()
    # end onMenuClose()

    # Likely to happen on a separate thread...
    def onDocumentChanged(self, document, metaDataOnly):
        if document.getId() == self.getDocumentId():
            if metaDataOnly:
                modelDoc = self.getDocument()
                modelDoc.setBlogInfoList(document.getBlogInfoList())
                self._fireUpdateMenu()
            elif not self.isDirty():
                self.model.setDocument(document)
                fireUIExecEvent(ZMethodRunnable(self._refreshContentEditorUI), self)
            else:
                # FIXME (EPW) Editor is dirty, but content changes were made by someone else - prompt the user for what to do
                pass
    # end onDocumentChanged()

    def onDocumentDeleted(self, document):
        u"Called when a specific document has been deleted." #$NON-NLS-1$
        # Note: we should probably do something interesting if the document we are currently
        # editing was deleted.
    # end onDocumentDeleted()

    def onTemplateCreated(self, template): #@UnusedVariable
        self._updateTemplateChooser()
    # end onTemplateCreated()

    def onTemplateDeleted(self, template): #@UnusedVariable
        if self.currentPreviewTemplate is not None:
            if template.getId() == self.currentPreviewTemplate.getId():
                self.currentPreviewTemplate = None
                self._updateTemplateUI()
                self._showPreview()
                return
        self._updateTemplateChooser()
    # end onTemplateDeleted()

    def onTemplateModified(self, template): #@UnusedVariable
        self._updateTemplateChooser()
    # end onTemplateModified()

    def _fireDirtyEvent(self):
        ZEditor._fireDirtyEvent(self)
        self._fireUpdateMenu()
    # end _fireDirtyEvent();

    def _fireUpdateMenu(self):
        self._fireMenuBarChangedEvent()
        self._fireToolBarChangedEvent()
    # end _fireUpdateMenu();

    def _registerAsListener(self):
        self.dataStoreService.addListener(self)
        self.templateService.addListener(self)
    # end _registerAsListener()

    def _unregisterAsListener(self):
        self.dataStoreService.removeListener(self)
        self.templateService.removeListener(self)
    # end _unregisterAsListener()

    def _startSnapshotTimer(self):
        self.snapshotTimerId = wx.NewId()
        self.snapshotTimer = wx.Timer(self, self.snapshotTimerId)
        wx.EVT_TIMER(self, self.snapshotTimerId, self.onSnapshotTimer)
        # Timer will fire every 60 seconds
        self.snapshotTimer.Start(60000)
    # end _startSnapshotTimer()

    def _stopSnapshotTimer(self):
        self.snapshotTimer.Stop()
    # end _stopSnapshotTimer()

    def _clearRecoverySnapshot(self):
        document = self.getDocument()
        crashRecoveryService = getApplicationModel().getService(IZBlogAppServiceIDs.CRASH_RECOVERY_SERVICE_ID)
        crashRecoveryService.clearRecoverySnapshot(document)
    # end _clearRecoverySnapshot()

    def _takeRecoverySnapshot(self):
        try:
            self._updateModel()
            document = self.getDocument()
            crashRecoveryService = getApplicationModel().getService(IZBlogAppServiceIDs.CRASH_RECOVERY_SERVICE_ID)
            crashRecoveryService.takeRecoverySnapshot(document)
        except Exception, e:
            getLoggerService().exception(e)
Пример #27
0
 def __init__(self, *args, **kw):
     ZTransparentPanel.__init__(self, *args, **kw)
     self.capabilities = self._createCapabilities()
Пример #28
0
class ZStandardPerspective(IZPerspective):

    def __init__(self):
        self.currentViewSelection = None
        self.panel = None
        self.splitterWindow = None
        self.navView = None
        self.ctxView = None
        self.sizer = None
    # end __init__()

    def destroy(self):
        self._saveLayout()

        self.navView.destroy()
        self.ctxView.destroy()
    # end destroy()

    def createUIPanel(self, parent):
        self.panel = ZTransparentPanel(parent, wx.ID_ANY)
        self.splitterWindow = ZSplitterWindow(self.panel)

        self._createToolBar(self.panel)
        self._createNavigatorView(self.splitterWindow)
        self._createContextInfoView(self.splitterWindow)

        self._doSplit()

        self._bindViewEvents()

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.toolBar, 0, wx.EXPAND)
        self.sizer.Add(self.toolBarStaticLine, 0, wx.EXPAND)
        self.sizer.Add(self.splitterWindow, 1, wx.EXPAND | wx.ALL, 5)

        self.panel.SetAutoLayout(True)
        self.panel.SetSizer(self.sizer)

        self.panel.Layout()
        self._restoreLayout()
        return self.panel
    # end createUI()

    def _doSplit(self):
        self.splitterWindow.SplitVertically(self.navView, self.ctxView)
        self.splitterWindow.SetMinimumPaneSize(100)
        self.splitterWindow.SetSashSize(8)
        self.splitterWindow.SetSashGravity(0.0)
    # end _doSplit()

    def _createToolBar(self, parent):
        self.toolBarModel = self._createToolBarModel()
        self.toolBarContext = ZStandardPerspectiveToolBarActionContext(parent, self.currentViewSelection)
        contentProvider = ZModelBasedToolBarContentProvider(self.toolBarModel, self.toolBarContext)
        eventHandler = ZModelBasedToolBarEventHandler(self.toolBarModel, self.toolBarContext)
        self.toolBar = ZPersistentToolBar(self._getUserPrefsKey() + u".toolbar", contentProvider, eventHandler, parent, ZToolBar.STYLE_SHOW_TEXT) #$NON-NLS-1$
        self.toolBarStaticLine = wx.StaticLine(parent, wx.ID_ANY)
    # end _createToolBar()

    def _createToolBarModel(self):
        model = ZPluginToolBarModel(IZBlogAppToolBarIds.ZID_STANDARD_PERSPECTIVE_TOOLBAR)
        model.setDefaultToolSize(24)

        # 'Write' Tool
        toolId = model.addItemWithAction(_extstr(u"standard.Write"), 1, ZWriteToolBarAction()) #$NON-NLS-1$
        model.addToolBitmap(toolId, 24, getToolbarBitmap(24, u"file", u"write"))  #$NON-NLS-2$ #$NON-NLS-1$
        model.addToolBitmap(toolId, 32, getToolbarBitmap(32, u"file", u"write"))  #$NON-NLS-2$ #$NON-NLS-1$
        model.addToolDisabledBitmap(toolId, 24, getToolbarBitmap(24, u"file", u"write_disabled")) #$NON-NLS-1$ #$NON-NLS-2$
        model.addToolDisabledBitmap(toolId, 32, getToolbarBitmap(32, u"file", u"write_disabled")) #$NON-NLS-1$ #$NON-NLS-2$
        model.setToolDescription(toolId, _extstr(u"standard.Author_some_new_content_")) #$NON-NLS-1$

        # 'New Account' Tool
        toolId = model.addItemWithAction(_extstr(u"standard.AddAccount"), 3, ZNewAccountToolBarAction()) #$NON-NLS-1$
        model.addToolBitmap(toolId, 24, getToolbarBitmap(24, u"file", u"addAccount"))  #$NON-NLS-2$ #$NON-NLS-1$
        model.addToolBitmap(toolId, 32, getToolbarBitmap(32, u"file", u"addAccount"))  #$NON-NLS-2$ #$NON-NLS-1$
        model.setToolDescription(toolId, _extstr(u"standard.AddAccountDescriton")) #$NON-NLS-1$

        # 'New Storage' Tool
        toolId = model.addItemWithAction(_extstr(u"standard.AddStorage"), 3, ZNewMediaStorageToolBarAction()) #$NON-NLS-1$
        model.addToolBitmap(toolId, 24, getToolbarBitmap(24, u"file", u"addStorage"))  #$NON-NLS-2$ #$NON-NLS-1$
        model.addToolBitmap(toolId, 32, getToolbarBitmap(32, u"file", u"addStorage"))  #$NON-NLS-2$ #$NON-NLS-1$
        model.setToolDescription(toolId, _extstr(u"standard.AddStorageDescription")) #$NON-NLS-1$

        model.addSeparator(10)

        # 'Publish' Tool
        toolId = model.addItemWithAction(_extstr(u"standard.Publish"), 15, ZPublishToolBarAction()) #$NON-NLS-2$ #$NON-NLS-3$ #$NON-NLS-1$
        model.addToolBitmap(toolId, 24, getToolbarBitmap(24, u"api", u"publish"))  #$NON-NLS-2$ #$NON-NLS-1$
        model.addToolBitmap(toolId, 32, getToolbarBitmap(32, u"api", u"publish"))  #$NON-NLS-2$ #$NON-NLS-1$
        model.addToolDisabledBitmap(toolId, 24, getToolbarBitmap(24, u"api", u"publish_disabled")) #$NON-NLS-1$ #$NON-NLS-2$
        model.addToolDisabledBitmap(toolId, 32, getToolbarBitmap(32, u"api", u"publish_disabled")) #$NON-NLS-1$ #$NON-NLS-2$
        model.setToolDescription(toolId, _extstr(u"standard.Publish_some_content_")) #$NON-NLS-1$

        # 'Download' Tool
        toolId = model.addDropDownItemWithAction(_extstr(u"standard.Download"), 20, ZDownloadToolBarAction()) #$NON-NLS-2$ #$NON-NLS-3$ #$NON-NLS-1$
        model.addToolBitmap(toolId, 24, getToolbarBitmap(24, u"api", u"download"))  #$NON-NLS-2$ #$NON-NLS-1$
        model.addToolBitmap(toolId, 32, getToolbarBitmap(32, u"api", u"download"))  #$NON-NLS-2$ #$NON-NLS-1$
        model.addToolDisabledBitmap(toolId, 24, getToolbarBitmap(24, u"api", u"download_disabled")) #$NON-NLS-1$ #$NON-NLS-2$
        model.addToolDisabledBitmap(toolId, 32, getToolbarBitmap(32, u"api", u"download_disabled")) #$NON-NLS-1$ #$NON-NLS-2$
        model.setToolDescription(toolId, _extstr(u"standard.Download_content_")) #$NON-NLS-1$

        # 'View (online)' Tool
        toolId = model.addItemWithAction(_extstr(u"standard.ViewOnline"), 25, ZViewOnlineToolBarAction()) #$NON-NLS-1$
        model.addToolBitmap(toolId, 24, getToolbarBitmap(24, u"api", u"viewOnline"))  #$NON-NLS-2$ #$NON-NLS-1$
        model.addToolBitmap(toolId, 32, getToolbarBitmap(32, u"api", u"viewOnline"))  #$NON-NLS-2$ #$NON-NLS-1$
        model.addToolDisabledBitmap(toolId, 24, getToolbarBitmap(24, u"api", u"viewOnline_disabled")) #$NON-NLS-1$ #$NON-NLS-2$
        model.addToolDisabledBitmap(toolId, 32, getToolbarBitmap(32, u"api", u"viewOnline_disabled")) #$NON-NLS-1$ #$NON-NLS-2$
        model.setToolDescription(toolId, _extstr(u"standard.ViewOnlineDescription")) #$NON-NLS-1$

        model.addSeparator(50)

        # 'Delete' Tool
        toolId = model.addItemWithAction(_extstr(u"standard.Delete"), 55, ZDeleteToolBarAction()) #$NON-NLS-2$ #$NON-NLS-3$ #$NON-NLS-1$
        model.addToolBitmap(toolId, 24, getToolbarBitmap(24, u"file", u"delete"))  #$NON-NLS-2$ #$NON-NLS-1$
        model.addToolBitmap(toolId, 32, getToolbarBitmap(32, u"file", u"delete"))  #$NON-NLS-2$ #$NON-NLS-1$
        model.addToolDisabledBitmap(toolId, 24, getToolbarBitmap(24, u"file", u"delete_disabled")) #$NON-NLS-1$ #$NON-NLS-2$
        model.addToolDisabledBitmap(toolId, 32, getToolbarBitmap(32, u"file", u"delete_disabled")) #$NON-NLS-1$ #$NON-NLS-2$
        model.setToolDescription(toolId, _extstr(u"standard.DeleteDescription")) #$NON-NLS-1$

        return model
    # end _createToolBarModel()

    def _createContextInfoView(self, parent):
        self.ctxView = ZContextInfoView(parent)
    # end _createContextInfoView()

    def _createNavigatorView(self, parent):
        self.navView = ZNavigatorView(parent)
    # end _createNavigatorView()

    def _bindViewEvents(self):
        self.toolBar.Bind(ZEVT_TOOLBAR_RESIZE, self.onToolBarResize, self.toolBar)
        ZEVT_VIEW_SELECTION_CHANGED(self.navView, self.onViewSelectionChanged)
    # end _bindViewEvents()

    def onToolBarResize(self, event):
        self.panel.Layout()
        self.panel.Refresh()
        event.Skip()
    # end onToolBarResize()

    def onViewSelectionChanged(self, event):
        self.toolBarContext.setViewSelection(event.getSelection())
        self.toolBar.refresh()
        event.Skip()
    # end onViewSelectionChanged()

    def _saveLayout(self):
        if self.panel.IsShown():
            key = self._getUserPrefsKey() + u".sash-width" #$NON-NLS-1$
            userPrefs = getApplicationModel().getUserProfile().getPreferences()
            userPrefs.setUserPreference(key, self.splitterWindow.GetSashPosition())
    # end _saveLayout()

    def _restoreLayout(self):
        key = self._getUserPrefsKey() + u".sash-width" #$NON-NLS-1$
        userPrefs = getApplicationModel().getUserProfile().getPreferences()
        sashPos = userPrefs.getUserPreferenceInt(key, 200)
        self.splitterWindow.SetSashPosition(sashPos)
    # end _restoreLayout()

    def _getUserPrefsKey(self):
        return IZBlogAppUserPrefsKeys.STANDARD_PERSPECTIVE_LAYOUT
Пример #29
0
 def _createPreviewPage(self):
     self.previewTabPanel = ZTransparentPanel(self.notebook, wx.ID_ANY)
     self._createPreviewTools(self.previewTabPanel)
     self.contentPreviewer = ZBlogPostContentEditorFactory().createContentPreviewer(self.previewTabPanel, self, self.model)
     self.contentPreviewer.SetBackgroundColour(wx.WHITE)
     return self.previewTabPanel
Пример #30
0
 def SetFocus(self):
     try:
         self.getIHTMLDocument().focus()
     except:
         ZTransparentPanel.SetFocus(self)
Пример #31
0
class ZBlogConfigPopup(wx.combo.ComboPopup):

    def __init__(self, combo, blog):
        self.combo = combo
        self.blog = blog
        self.catListCtrl = None
        self.pdColor = getDefaultPopdownDialogBackgroundColor()
        wx.combo.ComboPopup.__init__(self)
    # end __init__()

    def Init(self):
        pass
    # end Init()

    def Create(self, parent):
        self.parent = parent
        self._createWidgets()
        self._layoutWidgets()
        self._bindWidgetEvents()
    # end Create()

    def GetControl(self):
        return self.panel
    # end GetControl()

    def GetStringValue(self):
        return _extstr(u"blogconfig.Configure") #$NON-NLS-1$
    # end GetStringValue()

    def OnPopup(self):
        userPrefs = getApplicationModel().getUserProfile().getPreferences()
        tabId = userPrefs.getUserPreferenceInt(IZAppUserPrefsKeys.BLOGPUB_CONFIG_POPUP + u".tab-id", 0) #$NON-NLS-1$
        if tabId >= 0 and tabId < self.notebook.GetPageCount():
            self.notebook.SetSelection(tabId)
    # end OnPopup()

    def OnDismiss(self):
        userPrefs = getApplicationModel().getUserProfile().getPreferences()
        tabId = self.notebook.GetSelection()
        userPrefs.setUserPreference(IZAppUserPrefsKeys.BLOGPUB_CONFIG_POPUP + u".tab-id", tabId) #$NON-NLS-1$
    # end OnDismiss()

    def SetStringValue(self, value): #@UnusedVariable
        pass
    # end SetStringValue()

    def _createWidgets(self):
        self.panel = wx.Panel(self.parent, wx.ID_ANY, style = wx.SIMPLE_BORDER)
        self.panel.SetBackgroundColour(self.pdColor)
        self.notebook = fnb.FlatNotebook(self.panel, wx.ID_ANY, style = fnb.FNB_BOTTOM | fnb.FNB_NO_NAV_BUTTONS | fnb.FNB_NO_X_BUTTON | fnb.FNB_NODRAG)
        self.notebook.SetBackgroundColour(self.pdColor)
        self.notebook.SetActiveTabColour(self.pdColor)
        self.notebook.AddPage(self._createCategoriesPage(), _extstr(u"blogconfig.Categories"), False, -1) #$NON-NLS-1$
        self.notebook.AddPage(self._createCommonPage(), _extstr(u"blogconfig.General"), True, -1) #$NON-NLS-1$
        self.notebook.AddPage(self._createPingPage(), _extstr(u"blogconfig.WeblogPing"), False, -1) #$NON-NLS-1$
        self.notebook.AddPage(self._createTagsPage(), _extstr(u"blogconfig.TagSites"), False, -1) #$NON-NLS-1$
        self.notebook.AddPage(self._createTrackbackPage(), _extstr(u"blogconfig.Trackbacks"), False, -1) #$NON-NLS-1$
    # end _createWidgets()

    def _createCommonPage(self):
        self.commonPanel = ZTransparentPanel(self.notebook, wx.ID_ANY)
        self.commonCtrls = ZPubMetaDataView(self.commonPanel)
        return self.commonPanel
    # end _createCommonPage()

    def _createCategoriesPage(self):
        self.categoriesPanel = ZSmartTransparentPanel(self.notebook, wx.ID_ANY)
        self.catListProvider = ZCategoryListContentProvider()
        self.catListCtrl = ZCategoryMultiSelectListView(self.categoriesPanel, self.catListProvider)
        return self.categoriesPanel
    # end _createCategoriesPage()

    def _createPingPage(self):
        self.pingPanel = ZSmartTransparentPanel(self.notebook, wx.ID_ANY)
        self.pingListProvider = ZPingListContentProvider()
        self.pingListCtrl = ZCheckBoxListViewWithButtons(self.pingListProvider, self.pingPanel)
        return self.pingPanel
    # end _createPingPage()

    def _createTrackbackPage(self):
        self.trackbackPanel = ZSmartTransparentPanel(self.notebook, wx.ID_ANY)
        self.trackbackListProvider = ZTrackbackListContentProvider()
        self.tracbackListView = ZTrackbackUrlsView(self.trackbackPanel, self.trackbackListProvider)
        return self.trackbackPanel
    # end _createTrackbackPage()

    def _createTagsPage(self):
        self.tagspacePanel = ZSmartTransparentPanel(self.notebook, wx.ID_ANY)
        self.tagspaceListProvider = ZTagspaceListContentProvider()
        self.tagspaceListCtrl = ZTagspaceListView(self.tagspacePanel, self.tagspaceListProvider)
        return self.tagspacePanel
    # end _createTagsPage()

    def _layoutWidgets(self):
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.notebook, 1, wx.EXPAND | wx.ALL, 0)

        self._layoutCommonPage()
        self._layoutPingPage()
        self._layoutTagsPage()
        self._layoutTrackbackPage()

        self.panel.SetSizer(self.sizer)
        self.panel.SetAutoLayout(True)
        self.panel.Layout()
    # end _layoutWidgets()

    def _layoutCommonPage(self):
        spaceSizer = wx.BoxSizer(wx.VERTICAL)
        spaceSizer.Add(self.commonCtrls, 1, wx.EXPAND | wx.ALL, 5)
        self.commonPanel.SetSizer(spaceSizer)
        self.commonPanel.SetAutoLayout(True)
        self.commonPanel.Layout()
    # end _layoutCommonPage()

    def _layoutCategoriesPage(self):
        # 'Categories' section
        sbSizer = wx.StaticBoxSizer(wx.StaticBox(self.categoriesPanel, wx.ID_ANY, _extstr(u"blogconfig.Categories")), wx.HORIZONTAL) #$NON-NLS-1$
        sbSizer.Add(self.catListCtrl, 1, wx.EXPAND | wx.ALL, 3)
        spaceSizer = wx.BoxSizer(wx.VERTICAL)
        spaceSizer.AddSizer(sbSizer, 1, wx.EXPAND | wx.ALL, 5)
        self.categoriesPanel.SetSizer(spaceSizer)
        self.categoriesPanel.SetAutoLayout(True)
        self.categoriesPanel.Layout()
    # end _layoutCategoriesPage()

    def _layoutPingPage(self):
        # 'Weblog Ping' section
        sbSizer = wx.StaticBoxSizer(wx.StaticBox(self.pingPanel, wx.ID_ANY, _extstr(u"blogconfig.WeblogPing")), wx.HORIZONTAL) #$NON-NLS-1$
        sbSizer.Add(self.pingListCtrl, 1, wx.EXPAND | wx.ALL, 3)

        spaceSizer = wx.BoxSizer(wx.VERTICAL)
        spaceSizer.AddSizer(sbSizer, 1, wx.EXPAND | wx.ALL, 5)

        self.pingPanel.SetSizer(spaceSizer)
        self.pingPanel.SetAutoLayout(True)
        self.pingPanel.Layout()
    # end _layoutPingPage()

    def _layoutTagsPage(self):
        # 'Tagging section
        sbSizer = wx.StaticBoxSizer(wx.StaticBox(self.tagspacePanel, wx.ID_ANY, _extstr(u"blogconfig.TagSites")), wx.HORIZONTAL) #$NON-NLS-1$
        sbSizer.Add(self.tagspaceListCtrl, 1, wx.EXPAND | wx.ALL, 3)

        spaceSizer = wx.BoxSizer(wx.VERTICAL)
        spaceSizer.AddSizer(sbSizer, 1, wx.EXPAND | wx.ALL, 5)

        self.tagspacePanel.SetSizer(spaceSizer)
        self.tagspacePanel.SetAutoLayout(True)
        self.tagspacePanel.Layout()
    # end _layoutTagsPage()

    def _layoutTrackbackPage(self):
        # 'Trackback section
        sbSizer = wx.StaticBoxSizer(wx.StaticBox(self.trackbackPanel, wx.ID_ANY, _extstr(u"blogconfig.Trackbacks")), wx.HORIZONTAL) #$NON-NLS-1$
        sbSizer.Add(self.tracbackListView, 1, wx.EXPAND | wx.ALL, 3)

        spaceSizer = wx.BoxSizer(wx.VERTICAL)
        spaceSizer.AddSizer(sbSizer, 1, wx.EXPAND | wx.ALL, 5)

        self.trackbackPanel.SetSizer(spaceSizer)
        self.trackbackPanel.SetAutoLayout(True)
        self.trackbackPanel.Layout()
    # end _layoutTrackbackPage()

    def _bindWidgetEvents(self):
        # Events that will cause a 'publishing change' event
        self.commonPanel.Bind(wx.EVT_CHECKBOX, self.onPublishingChange)
        self.commonPanel.Bind(ZEVT_DATE_CHANGE, self.onPublishingChange)
        self.pingPanel.Bind(ZEVT_CHECKBOX_LIST_CHANGE, self.onPublishingChange)
        self.tagspacePanel.Bind(ZEVT_CHECKBOX_LIST_CHANGE, self.onPublishingChange)
        self.trackbackPanel.Bind(ZEVT_CONTENT_MODIFIED, self.onPublishingChange)
        self.categoriesPanel.Bind(ZEVT_CHECKBOX_LIST_CHANGE, self.onPublishingChange)
    # end _bindWidgetEvents()

    def _createAndLayoutCategoriesControl(self):
        for child in self.categoriesPanel.GetChildren():
            self.categoriesPanel.RemoveChild(child)
        if self.catListCtrl:
            self.catListCtrl.Show(False)
            self.catListCtrl.Destroy()
            self.catListCtrl = None

        if self.catListProvider.isMultiselect():
            self.catListCtrl = ZCategoryMultiSelectListView(self.categoriesPanel, self.catListProvider)
        else:
            self.catListCtrl = ZCategorySingleSelectListView(self.categoriesPanel, self.catListProvider)
        self._layoutCategoriesPage()
        self.categoriesPanel.GetParent().Layout()
        self.categoriesPanel.GetParent().Refresh()
    # end _createAndLayoutCategoriesControl()

    def setBlog(self, blog):
        self.blog = blog
        if not blog:
            return
        self.catListProvider.setBlog(blog)
        self._createAndLayoutCategoriesControl()
        self.catListCtrl.refresh()
        self.commonCtrls.enableDraftCheckbox(self._blogSupportsDraft(blog))
    # end setBlog()

    def _blogSupportsDraft(self, blog):
        return isCapabilitySupportedByBlog(IZBlogApiCapabilityConstants.DRAFT_POSTS, blog)
    # end _blogSupportsDraft()

    def setPubMetaData(self, pubMetaData):
        if pubMetaData:
            self._populateWidgets(pubMetaData)
    # end setPubMetaData()

    def getPubMetaData(self):
        pubMetaData = ZPubMetaData()
        self.commonCtrls.updatePubMetaData(pubMetaData)

        # categories
        categories  = self.catListProvider.getSelectedCategories()
        pubMetaData.setCategories( categories )

        # weblog ping list
        pingSites  = self.pingListProvider.getSelectedPingSites()
        pubMetaData.setPingServices(pingSites)

        # tagspaces
        tagspaceUrls = self.tagspaceListProvider.getSelectedTagSpaceUrls()
        pubMetaData.setTagspaceUrls( tagspaceUrls )

        # trackbacks
        trackbacks = self.trackbackListProvider.getTrackbacks()
        pubMetaData.setTrackbacks(trackbacks)

        return pubMetaData
    # end getPubMetaData()

    def _populateWidgets(self, pubMetaData):
        self.commonCtrls.setPubMetaData(pubMetaData)
        self.catListProvider.setSelectedCategories( pubMetaData.getCategories() )
        self.catListCtrl.refresh()
        self.pingListProvider.setSelectedPingSites( pubMetaData.getPingServices())
        self.pingListCtrl.refresh()
        self.tagspaceListProvider.setSelectedTagSpaceUrls( pubMetaData.getTagspaceUrls() )
        self.tagspaceListCtrl.refresh()
        self.trackbackListProvider.setTrackbacks( pubMetaData.getTrackbacks() )
        self.tracbackListView.refresh()
    # end _populateWidgets()

    def getPreferredHeight(self):
        return self.notebook.GetBestSizeTuple()[1]
    # end getPreferredHeight()

    def onOverridePubTime(self, event):
        self.dateCtrl.Enable(event.IsChecked())
        self.commonPanel.Layout()
        event.Skip()
    # end onOverridePubTime()

    def onPublishingChange(self, event): #@UnusedVariable
        firePublishingChangeEvent(self.combo)
        event.Skip()
Пример #32
0
 def _createCommonPage(self):
     self.commonPanel = ZTransparentPanel(self.notebook, wx.ID_ANY)
     self.commonCtrls = ZPubMetaDataView(self.commonPanel)
     return self.commonPanel
Пример #33
0
class ZPublishingPrefSubPage(ZAccountPrefsSubPage):
    def __init__(self, parent, session):
        ZAccountPrefsSubPage.__init__(self, parent, session)

    # end __init__()

    def _createWidgets(self):
        self.overrideCB = wx.CheckBox(self, wx.ID_ANY,
                                      self._getOverrideLabel())

        self.panel = ZTransparentPanel(self, wx.ID_ANY)

        self.pubOptionsStaticBox = wx.StaticBox(
            self.panel, wx.ID_ANY,
            _extstr(u"pubsubpage.PublishingOptions"))  #$NON-NLS-1$
        self.poweredByCB = wx.CheckBox(
            self.panel, wx.ID_ANY,
            _extstr(u"pubsubpage.AddPoweredByZoundry"))  #$NON-NLS-1$
        self.removeNewLinesCB = wx.CheckBox(
            self.panel, wx.ID_ANY,
            _extstr(u"pubsubpage.RemoveNewLines"))  #$NON-NLS-1$

        self.imageUploadStaticBox = wx.StaticBox(
            self.panel, wx.ID_ANY,
            _extstr(u"pubsubpage.ImageUpload"))  #$NON-NLS-1$
        self.tnsOnlyCB = wx.CheckBox(
            self.panel, wx.ID_ANY,
            _extstr(u"pubsubpage.UploadTNsOnly"))  #$NON-NLS-1$
        self.forceUploadCB = wx.CheckBox(
            self.panel, wx.ID_ANY,
            _extstr(u"pubsubpage.ReUploadImages"))  #$NON-NLS-1$
        self.lightboxCB = wx.CheckBox(
            self.panel, wx.ID_ANY,
            _extstr(u"pubsubpage.AddLightbox"))  #$NON-NLS-1$

    # end _createWidgets()

    def _getOverrideLabel(self):
        return _extstr(u"pubsubpage.OverridePublishingSettings")  #$NON-NLS-1$

    # end _getOverrideLabel()

    def _bindWidgetEvents(self):
        self.Bind(wx.EVT_CHECKBOX, self.onOverrideCB, self.overrideCB)

        self.Bind(wx.EVT_CHECKBOX, self.onPoweredByCB, self.poweredByCB)
        self.Bind(wx.EVT_CHECKBOX, self.onRemoveNewLinesCB,
                  self.removeNewLinesCB)
        self.Bind(wx.EVT_CHECKBOX, self.onTnsOnlyCB, self.tnsOnlyCB)
        self.Bind(wx.EVT_CHECKBOX, self.onForceUploadCB, self.forceUploadCB)
        self.Bind(wx.EVT_CHECKBOX, self.onLightboxCB, self.lightboxCB)

    # end _bindWidgetEvents()

    def _populateWidgets(self):
        override = self._getSession().isOverridePublishingSettings()
        self.overrideCB.SetValue(override)
        self.panel.Enable(override)

        self.poweredByCB.SetValue(self._getSession().isAddPoweredByZoundry())
        self.removeNewLinesCB.SetValue(self._getSession().isRemoveNewLines())
        self.tnsOnlyCB.SetValue(self._getSession().isUploadThumbnailsOnly())
        self.forceUploadCB.SetValue(self._getSession().isForceReupload())
        self.lightboxCB.SetValue(self._getSession().isAddLightbox())

    # end _populateWidgets()

    def _layoutWidgets(self):
        panelBox = wx.BoxSizer(wx.VERTICAL)

        # pub options
        sbSizer = wx.StaticBoxSizer(self.pubOptionsStaticBox, wx.VERTICAL)
        internalBox = wx.BoxSizer(wx.VERTICAL)
        internalBox.Add(self.poweredByCB, 0, wx.EXPAND | wx.ALL, 2)
        internalBox.Add(self.removeNewLinesCB, 0, wx.EXPAND | wx.ALL, 2)
        sbSizer.AddSizer(internalBox, 0, wx.EXPAND | wx.ALL, 8)
        panelBox.Add(sbSizer, 0)

        # image upload
        sbSizer = wx.StaticBoxSizer(self.imageUploadStaticBox, wx.VERTICAL)
        internalBox = wx.BoxSizer(wx.VERTICAL)
        internalBox.Add(self.tnsOnlyCB, 0, wx.EXPAND | wx.ALL, 2)
        internalBox.Add(self.forceUploadCB, 0, wx.EXPAND | wx.ALL, 2)
        internalBox.Add(self.lightboxCB, 0, wx.EXPAND | wx.ALL, 2)
        sbSizer.AddSizer(internalBox, 0, wx.EXPAND | wx.ALL, 8)
        panelBox.Add(sbSizer, 0, wx.TOP, 8)

        self.panel.SetSizer(panelBox)
        self.panel.SetAutoLayout(True)

        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(self.overrideCB, 0, wx.ALL, 5)
        box.Add(self.panel, 0, wx.ALL, 5)

        self.SetAutoLayout(True)
        self.SetSizer(box)
        self.Layout()

    # end layoutWidgets()

    def onOverrideCB(self, event):
        override = event.IsChecked()
        self._getSession().setOverridePublishingSettings(override)
        if override:
            self._getSession().setAddPoweredByZoundry(
                self.poweredByCB.IsChecked())
            self._getSession().setRemoveNewLines(
                self.removeNewLinesCB.IsChecked())
            self._getSession().setUploadThumbnailsOnly(
                self.tnsOnlyCB.IsChecked())
            self._getSession().setForceReupload(self.forceUploadCB.IsChecked())
            self._getSession().setAddLightbox(self.lightboxCB.IsChecked())
        self._populateWidgets()
        event.Skip()

    # end onOverrideCB()

    def onPoweredByCB(self, event):
        self._getSession().setAddPoweredByZoundry(event.IsChecked())
        event.Skip()

    # end onPoweredByCB()

    def onRemoveNewLinesCB(self, event):
        self._getSession().setRemoveNewLines(event.IsChecked())
        event.Skip()

    # end onRemoveNewLinesCB()

    def onTnsOnlyCB(self, event):
        self._getSession().setUploadThumbnailsOnly(event.IsChecked())
        event.Skip()

    # end onTnsOnlyCB()

    def onForceUploadCB(self, event):
        self._getSession().setForceReupload(event.IsChecked())
        event.Skip()

    # end onForceUploadCB()

    def onLightboxCB(self, event):
        self._getSession().setAddLightbox(event.IsChecked())
        event.Skip()
Пример #34
0
class ZProxyPreferencePage(ZApplicationPreferencesPrefPage):
    
    def __init__(self, parent):
        ZApplicationPreferencesPrefPage.__init__(self, parent)
    # end __init__()

    def createWidgets(self):
        self.staticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"prefpage.general.proxy.name")) #$NON-NLS-1$
        
        self.enableCB = wx.CheckBox(self, wx.ID_ANY, _extstr(u"prefpage.general.proxy.enable")) #$NON-NLS-1$
        self.controlsPanel = ZTransparentPanel(self, wx.ID_ANY)
        self.hostLabel = wx.StaticText(self.controlsPanel, wx.ID_ANY, _extstr(u"prefpage.general.proxy.host")) #$NON-NLS-1$
        self.hostTxt = wx.TextCtrl(self.controlsPanel, wx.ID_ANY)
        self.portLabel = wx.StaticText(self.controlsPanel, wx.ID_ANY, _extstr(u"prefpage.general.proxy.port")) #$NON-NLS-1$
        flags = ZIntegerSelectionValidator.ALLOW_EMPTY | ZIntegerSelectionValidator.POSITIVE_ONLY
        self.portTxt = ZValidatingTextCtrl(ZIntegerSelectionValidator(flags=flags), self.controlsPanel, wx.ID_ANY)
        
        self.usernameLabel = wx.StaticText(self.controlsPanel, wx.ID_ANY, _extstr(u"prefpage.general.proxy.username")) #$NON-NLS-1$
        self.usernameTxt = wx.TextCtrl(self.controlsPanel, wx.ID_ANY)
        self.passwordLabel = wx.StaticText(self.controlsPanel, wx.ID_ANY, _extstr(u"prefpage.general.proxy.password")) #$NON-NLS-1$
        self.passwordTxt = wx.TextCtrl(self.controlsPanel, wx.ID_ANY, style=wx.TE_PASSWORD)
    # end createWidgets()

    def populateWidgets(self):
        enable = self.session.getUserPreferenceBool(IZAppUserPrefsKeys.PROXY_ENABLE, False) #$NON-NLS-1$
        self.enableCB.SetValue(enable)
        self.controlsPanel.Enable(enable)
        
        host = self.session.getUserPreference(IZAppUserPrefsKeys.PROXY_HOST, u"") #$NON-NLS-1$
        port = self.session.getUserPreferenceInt(IZAppUserPrefsKeys.PROXY_PORT, 0) #$NON-NLS-1$
        if not host:
            # get data from os registry
            proxy = getOSUtil().getProxyConfig()
            if proxy and proxy.isConfigured():
                host = proxy.getHost()            
                port = proxy.getPortInt()
        self.hostTxt.SetValue(host)        
        if port > 0:
            self.portTxt.SetValue( unicode(port) )
        username = self.session.getUserPreference(IZAppUserPrefsKeys.PROXY_USERNAME, u"") #$NON-NLS-1$
        self.usernameTxt.SetValue(username)

        cyppass = self.session.getUserPreference(IZAppUserPrefsKeys.PROXY_PASSWORD, u"") #$NON-NLS-1$
        cyppass = getNoneString(cyppass)
        if cyppass:
            password = crypt.decryptCipherText(cyppass, PASSWORD_ENCRYPTION_KEY)
            self.passwordTxt.SetValue(password)
    # end populateWidgets()

    def bindWidgetEvents(self):
        self.Bind(wx.EVT_CHECKBOX, self.onEnableCB, self.enableCB)
        self.Bind(wx.EVT_TEXT, self.onDataChanged, self.hostTxt)
        self.Bind(wx.EVT_TEXT, self.onDataChanged, self.portTxt)
        self.Bind(wx.EVT_TEXT, self.onDataChanged, self.usernameTxt)
        self.Bind(wx.EVT_TEXT, self.onPasswordChanged, self.passwordTxt)
    # end bindWidgetEvents()

    def layoutWidgets(self):        
        flexGridSizer = wx.FlexGridSizer(4, 2, 5, 5)
        flexGridSizer.AddGrowableCol(1)
        flexGridSizer.Add(self.hostLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5)
        flexGridSizer.Add(self.hostTxt, 0, wx.EXPAND | wx.RIGHT, 5)
        flexGridSizer.Add(self.portLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5)
        flexGridSizer.Add(self.portTxt, 0, wx.RIGHT, 5)
        flexGridSizer.Add(self.usernameLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5)
        flexGridSizer.Add(self.usernameTxt, 0, wx.EXPAND | wx.RIGHT, 5)
        flexGridSizer.Add(self.passwordLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5)
        flexGridSizer.Add(self.passwordTxt, 0, wx.EXPAND | wx.RIGHT, 5)     
        self.controlsPanel.SetAutoLayout(True)
        self.controlsPanel.SetSizer(flexGridSizer)
                 
        staticBoxSizer = wx.StaticBoxSizer(self.staticBox, wx.VERTICAL)
        staticBoxSizer.Add(self.enableCB, 0, wx.EXPAND | wx.ALL, 2)
        staticBoxSizer.Add(self.controlsPanel, 1, wx.EXPAND | wx.ALL, 2)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.AddSizer(staticBoxSizer, 1, wx.EXPAND | wx.ALL, 5)
        self.SetAutoLayout(True)
        self.SetSizer(sizer)
        self.Layout()
    # end layoutWidgets()
    
    def onDataChanged(self, event):
        if self.enableCB.GetValue():
            (h, p) = self._getHostPortFromUI()
            self.session.setUserPreference(IZAppUserPrefsKeys.PROXY_HOST, h)
            self.session.setUserPreference(IZAppUserPrefsKeys.PROXY_PORT, p)
            self.session.setUserPreference(IZAppUserPrefsKeys.PROXY_USERNAME, getSafeString(self.usernameTxt.GetValue()))
            self.onSessionChange()            
        event.Skip()
    # end  onDataChanged
    
    def onPasswordChanged(self, event):
        if self.enableCB.GetValue():
            s = getSafeString(self.passwordTxt.GetValue())
            if s:
                s = crypt.encryptPlainText(s, PASSWORD_ENCRYPTION_KEY)
            self.session.setUserPreference(IZAppUserPrefsKeys.PROXY_PASSWORD, s)            
            self.onSessionChange()            
        event.Skip()
    # end  onPasswordChanged   
           
    def onEnableCB(self, event):
        self.session.setUserPreference(IZAppUserPrefsKeys.PROXY_ENABLE, event.IsChecked())
        self.controlsPanel.Enable(event.IsChecked())
        self.onSessionChange()
        event.Skip()
    # end onDebugCB() 
    
    def _getHostPortFromUI(self):        
        host = getSafeString( self.hostTxt.GetValue() )
        port = getSafeString( self.portTxt.GetValue() )
        if host.lower().startswith(u"http"): #$NON-NLS-1$
            (scheme, netloc, path, query, fragment) = urlsplit(host, u"http") #$NON-NLS-1$ @UnusedVariable
            desHostPort = netloc.split(u":") #$NON-NLS-1$
            h = desHostPort[0]
            p = u"80" #$NON-NLS-1$
            if len(desHostPort) == 2:
                p = desHostPort[1]
            if scheme == u"ssl" and p == u"80": #$NON-NLS-1$ #$NON-NLS-2$
                p = u"443" #$NON-NLS-1$
            if h:
                host = h
            if not port and p:
                port = p
        return (host, port)
    # end _getHostPortFromUI
    
    def apply(self):
        # also set changes to the global value
        (h, p) = self._getHostPortFromUI()
        proxy = ZHttpProxyConfiguration()
        proxy.setEnable( self.enableCB.GetValue() )
        proxy.setHost( h )
        port = 8080
        try:
            port  = int( p )
        except:
            pass
        proxy.setPort( port )
        proxy.setProxyAuthorization( getSafeString(self.usernameTxt.GetValue()), getSafeString(self.passwordTxt.GetValue()) )
        return ZApplicationPreferencesPrefPage.apply(self)
Пример #35
0
 def __init__(self, parent):
     ZTransparentPanel.__init__(self, parent, wx.ID_ANY)
     self.wpPublishStatusValue = ZPubMetaDataView.WP_PUBLISHED
     self._createWidgets()
     self._layoutWidgets()
     self._bindWidgetEvents()
Пример #36
0
 def __init__(self, *args, **kw):
     ZTransparentPanel.__init__(self, *args, **kw)