示例#1
0
 def GetLicenseNameString(self):
     """
     This method returns:
     - the license name if possible
     - the license url if the name can't be found
     - (unlicensed) if no license info
     """
     if self.GetLicenseURI() == None:
         return _('(unlicensed)')
     elif liblicense.get_name(self.GetLicenseURI()) != None:
         return liblicense.get_name(self.GetLicenseURI())
     else :
         return self.GetLicenseURIString()
示例#2
0
 def UpdateLicenseName(self):
     newname = liblicense.get_name(self.licenseURI)
     if newname:
         self.licenseName = newname
         self.licenseNameText.SetLabel(self.licenseName)
     else:
         self.licenseNameText.SetLabel('')
    def license_name(self):
        if self.license == None:
            return '(unlicensed)'

        return liblicense.get_name(self.license)
示例#4
0
 def _format_tooltip(self,uri):
     if uri:
         s = _("Current")+": "+ll.get_name(uri)
     else:
         s = _("Current")+": "+_("None")
     return s
示例#5
0
    def __init__(self, parent, license):
        wx.Dialog.__init__(self,parent, -1, _('Choose your license'))

        self.license = license  
        self.licenseURI = self.license.GetLicenseURIString()
        if liblicense.get_name(self.licenseURI) :
            self.licenseName = self.license.GetLicenseNameString()
        else :
            self.licenseName = ''

        self.SetSize((500, 235))
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        #Sharing
        ashLine = wx.BoxSizer(wx.HORIZONTAL)
        self.cb_ash = wx.CheckBox(self, -1, _("Allow Sharing"))
        ashLine.Add(self.cb_ash,1,wx.EXPAND)
        self.cb_ash.Bind(wx.EVT_CHECKBOX, self.OnCheck_ash )

        #Attribution
        byLine = wx.BoxSizer(wx.HORIZONTAL)
        self.cb_by = wx.CheckBox(self, -1, _("Require Attribution"))
        self.cb_by.Enable(False)
        byLine.Add(self.cb_by,1,wx.EXPAND)
        self.cb_by.Bind(wx.EVT_CHECKBOX, self.OnCheck_by )

        #Remixing
        arLine = wx.BoxSizer(wx.HORIZONTAL)
        self.cb_ar = wx.CheckBox(self, -1, _("Allow Remixing"))
        arLine.Add(self.cb_ar,1,wx.EXPAND)
        self.cb_ar.Bind(wx.EVT_CHECKBOX, self.OnCheck_ar )

        #Prohibit Commercial Works
        pcwLine = wx.BoxSizer(wx.HORIZONTAL)
        self.cb_pcw = wx.CheckBox(self, -1, _("Prohibit Commercial Works"))
        pcwLine.Add(self.cb_pcw,1,wx.EXPAND)
        self.cb_pcw.Bind(wx.EVT_CHECKBOX, self.OnCheck_pcw )

        #Share Alike
        saLine = wx.BoxSizer(wx.HORIZONTAL)
        self.cb_sa = wx.CheckBox(self, -1, _("Require Others to Share-Alike"))
        saLine.Add(self.cb_sa,1,wx.EXPAND)
        self.cb_sa.Bind(wx.EVT_CHECKBOX, self.OnCheck_sa )

        #License name and URI
        licenseNameLine = wx.BoxSizer(wx.HORIZONTAL)
        licenseNameLine.Add(wx.StaticText(self, -1, _("License:")),1,wx.EXPAND)
        self.licenseNameText = wx.StaticText(self, -1, self.licenseName)
        licenseNameLine.Add(self.licenseNameText,3,wx.EXPAND)
        
        licenseURILine = wx.BoxSizer(wx.HORIZONTAL)
        licenseURILine.Add(wx.StaticText(self, -1, _("URI:")),1,wx.EXPAND)
        self.licenseURIText = wx.TextCtrl(self, -1, self.licenseURI)
        self.licenseURIText.Bind(wx.EVT_TEXT, self.OnURIChanged)
        licenseURILine.Add(self.licenseURIText,3,wx.EXPAND)

        btnsizer = wx.StdDialogButtonSizer()
        cancelbtn = wx.Button(self, wx.ID_CANCEL)
        cancelbtn.SetToolTipString(_("Go back to the previous windows without saving your changes."))
        cancelbtn.Bind(wx.EVT_BUTTON, self.OnCancel)
        applybtn = wx.Button(self, wx.ID_OK)
        applybtn.SetToolTipString(_("Select this Creative Commons license for the file."))
        applybtn.Bind(wx.EVT_BUTTON, self.OnApply)
        applybtn.SetDefault()
        btnsizer.AddButton(applybtn)
        btnsizer.AddButton(cancelbtn)
        btnsizer.Realize()

        #Sizer
        sizer=wx.BoxSizer(wx.VERTICAL)  
        sizer.AddMany([ ashLine, byLine, arLine,
                            pcwLine, saLine ])
        sizer.Add((20,20))
        sizer.Add(licenseNameLine,0,wx.EXPAND)    
        sizer.Add(licenseURILine,0,wx.EXPAND)
        sizer.Add((20,20))
        sizer.Add(btnsizer, 0, wx.EXPAND)   

        #Border
        border=wx.BoxSizer(wx.HORIZONTAL) 
        border.Add(sizer, 1, wx.ALL, 5)

        self.SetSizer(border)

        #We define the attributes URI        
        self.attributes = ["http://creativecommons.org/ns#Attribution",
              "http://creativecommons.org/ns#Distribution",
              "http://creativecommons.org/ns#DerivativeWorks",
              "http://creativecommons.org/ns#CommercialUse",
              "http://creativecommons.org/ns#ShareAlike"]
        #We create the license chooser object : it returns license URI when we provide it some attributes.
        self.ll_chooser = liblicense.LicenseChooser(None,self.attributes)

        #We check/uncheck the checkboxes considering the license
        self.UpdateCheckboxes()