示例#1
0
def makeWidget(
    obj
):  ## obj is an instance of Event, EventRule, EventNotifier or EventGroup
    cls = obj.__class__
    try:
        WidgetClass = cls.WidgetClass
    except AttributeError:
        try:
            module = __import__(
                '.'.join([
                    modPrefix,
                    cls.tname,
                    cls.name,
                ]),
                fromlist=['WidgetClass'],
            )
            WidgetClass = cls.WidgetClass = module.WidgetClass
        except:
            myRaise()
            return
    widget = WidgetClass(obj)
    try:
        widget.show_all()
    except AttributeError:
        widget.show()
    widget.updateWidget()  ## FIXME
    return widget
示例#2
0
 def statusIconUpdateIcon(self, ddate):  ## FIXME
     imagePath = ui.statusIconImageHoli if ui.todayCell.holiday else ui.statusIconImage
     ext = os.path.splitext(imagePath)[1][1:].lower()
     loader = gdk.pixbuf_loader_new_with_mime_type('image/%s' % ext)
     if ui.statusIconFixedSizeEnable:
         try:
             width, height = ui.statusIconFixedSizeWH
             loader.set_size(width, height)
         except:
             myRaise()
     data = open(imagePath).read()
     if ext == 'svg':
         dayNum = _(ddate[2])
         if ui.statusIconFontFamilyEnable:
             if ui.statusIconFontFamily:
                 family = ui.statusIconFontFamily
             else:
                 family = ui.getFont()[0]
             dayNum = '<tspan style="font-family:%s">%s</tspan>' % (family,
                                                                    dayNum)
         data = data.replace(
             'TX',
             dayNum,
         )
     loader.write(data)
     loader.close()
     pixbuf = loader.get_pixbuf()
     self.sicon.set_from_pixbuf(pixbuf)
示例#3
0
 def statusIconUpdateIcon(self, ddate):## FIXME
     imagePath = ui.statusIconImageHoli if ui.todayCell.holiday else ui.statusIconImage
     ext = os.path.splitext(imagePath)[1][1:].lower()
     loader = gdk.pixbuf_loader_new_with_mime_type('image/%s'%ext)
     if ui.statusIconFixedSizeEnable:
         try:
             width, height = ui.statusIconFixedSizeWH
             loader.set_size(width, height)
         except:
             myRaise()
     data = open(imagePath).read()
     if ext == 'svg':
         dayNum = _(ddate[2])
         if ui.statusIconFontFamilyEnable:
             if ui.statusIconFontFamily:
                 family = ui.statusIconFontFamily
             else:
                 family = ui.getFont()[0]
             dayNum = '<tspan style="font-family:%s">%s</tspan>'%(family, dayNum)
         data = data.replace(
             'TX',
             dayNum,
         )
     loader.write(data)
     loader.close()
     pixbuf = loader.get_pixbuf()
     self.sicon.set_from_pixbuf(pixbuf)
示例#4
0
 def add(self, t0, t1, eid, debug=False):
     if debug:
         from time import strftime, localtime
         f = "%F, %T"
         print("EventSearchTree.add: %s\t%s\t%s" % (
             eid,
             strftime(f, localtime(t0)),
             strftime(f, localtime(t1)),
         ))
     ###
     if t0 == t1:
         t1 += epsTm  ## needed? FIXME
     mt = (t0 + t1) / 2.0
     dt = (t1 - t0) / 2.0
     ###
     try:
         self.root = self.addStep(
             self.root,
             t0,
             t1,
             mt,
             dt,
             eid,
         )
     except:
         myRaise()
     hp = self.byId.get(eid)
     if hp is None:
         hp = self.byId[eid] = MaxHeap()
     hp.push(mt, dt)  ## FIXME
示例#5
0
 def quit(self, widget=None, event=None):
     try:
         ui.saveLiveConf()
     except:
         myRaise()
     if self.trayMode>1 and self.sicon:
         self.sicon.set_visible(False) ## needed for windows ## before or after main_quit ?
     return gtk.main_quit()
示例#6
0
	def cleanup(self):
		for fname in os.listdir(tmpDir):
			if not fname.startswith(self.imNamePrefix):
				continue
			try:
				os.remove(join(tmpDir, fname))
			except:
				myRaise()
示例#7
0
文件: utils.py 项目: ilius/starcal2
def set_tooltip(widget, text):
    try:
        widget.set_tooltip_text(text)  ## PyGTK 2.12 or above
    except AttributeError:
        try:
            widget.set_tooltip(gtk.Tooltips(), text)
        except:
            myRaise(__file__)
示例#8
0
def set_tooltip(widget, text):
    try:
        widget.set_tooltip_text(text)  ## PyGTK 2.12 or above
    except AttributeError:
        try:
            widget.set_tooltip(gtk.Tooltips(), text)
        except:
            myRaise(__file__)
示例#9
0
 def setText(self, text):
     try:
         num = float(textNumDecode(text))
     except:
         myRaise()
         self.setDefault()
     else:
         self.setValue(num)
示例#10
0
 def setText(self, text):
     try:
         num = int(float(textNumDecode(text)))
     except:
         myRaise()
         self.setDefault()
     else:
         self.setValue(num)
示例#11
0
def imageFromFile(path):  ## the file must exist
    if not isabs(path):
        path = join(pixDir, path)
    im = gtk.Image()
    try:
        im.set_from_file(path)
    except:
        myRaise()
    return im
示例#12
0
文件: utils.py 项目: ilius/starcal2
def imageFromFile(path):  ## the file must exist
    if not isabs(path):
        path = join(pixDir, path)
    im = gtk.Image()
    try:
        im.set_from_file(path)
    except:
        myRaise()
    return im
示例#13
0
文件: utils.py 项目: ilius/starcal2
def pixbufFromFile(path):  ## the file may not exist
    if not path:
        return None
    if not isabs(path):
        path = join(pixDir, path)
    try:
        return gdk.pixbuf_new_from_file(path)
    except:
        myRaise()
        return None
示例#14
0
文件: utils.py 项目: karoon/starcal2
def pixbufFromFile(path):## the file may not exist
    if not path:
        return None
    if os.sep=='/' and not path.startswith('/'):
        path = join(pixDir, path)
    try:
        return gdk.pixbuf_new_from_file(path)
    except:
        myRaise()
        return None
示例#15
0
def pixbufFromFile(path):  ## the file may not exist
    if not path:
        return None
    if not isabs(path):
        path = join(pixDir, path)
    try:
        return gdk.pixbuf_new_from_file(path)
    except:
        myRaise()
        return None
示例#16
0
 def quit(self, widget=None, event=None):
     try:
         ui.saveLiveConf()
     except:
         myRaise()
     if self.statusIconMode>1 and self.sicon:
         self.sicon.set_visible(False) ## needed for windows ## before or after main_quit ?
     ######
     core.stopRunningThreads()
     ######
     return gtk.main_quit()
示例#17
0
 def quit(self, widget=None, event=None):
     try:
         ui.saveLiveConf()
     except:
         myRaise()
     if self.statusIconMode > 1 and self.sicon:
         self.sicon.set_visible(
             False)  ## needed for windows ## before or after main_quit ?
     ######
     core.stopRunningThreads()
     ######
     return gtk.main_quit()
示例#18
0
 def getLoadedObj(self):
     try:
         module = __import__(
             self.moduleName,
             fromlist=['CalObj'],
         )
         CalObj = module.CalObj
     except:
         myRaise()
         return
     obj = CalObj()
     return obj
示例#19
0
	def getLoadedObj(self):
		try:
			module = __import__(
				self.moduleName,
				fromlist=['CalObj'],
			)
			CalObj = module.CalObj
		except:
			myRaise()
			return
		obj = CalObj()
		obj.enable = self.enable
		return obj
示例#20
0
 def confStr(self):
     text = ''
     for mod_attr in self.params:
         try:
             value = eval(mod_attr)
         except:
             myRaise()
         else:
             text += '%s=%s\n'%(mod_attr, repr(value))
     for item in self.items:
         if item.customizable:
             text += item.confStr()
     return text
示例#21
0
	def confStr(self):
		text = ''
		for mod_attr in self.params:
			try:
				value = eval(mod_attr)
			except:
				myRaise()
			else:
				text += '%s=%s\n'%(mod_attr, repr(value))
		for item in self.items:
			if item.customizable:
				text += item.confStr()
		return text
示例#22
0
 def doAction(self):
     container = self._container
     if self.iconRadio.get_active():
         chType = self.iconChangeCombo.get_active()
         if chType != 0:
             icon = self.iconSelect.get_filename()
             for event in container:
                 if not (chType == 2 and event.icon):
                     event.icon = icon
                     event.afterModify()
                     event.save()
     elif self.timeZoneRadio.get_active():
         chType = self.timeZoneChangeCombo.get_active()
         timeZone = self.timeZoneInput.get_text()
         if chType != 0:
             try:
                 natz.timezone(timeZone)
             except:
                 myRaise('Invalid Time Zone "%s"' % timeZone)
             else:
                 for event in container:
                     if not (chType == 2 and event.timeZone):
                         event.timeZone = timeZone
                         event.afterModify()
                         event.save()
     else:
         chType = self.textChangeCombo.get_active()
         if chType != 0:
             text1 = self.textInput1.get_text()
             text2 = self.textInput2.get_text()
             if self.summaryRadio.get_active():
                 for event in container:
                     if chType == 1:
                         event.summary = text1 + event.summary
                     elif chType == 2:
                         event.summary = event.summary + text1
                     elif chType == 3:
                         event.summary = event.summary.replace(text1, text2)
                     event.afterModify()
                     event.save()
             elif self.descriptionRadio.get_active():
                 for event in container:
                     if chType == 1:
                         event.description = text1 + event.description
                     elif chType == 2:
                         event.description = event.description + text1
                     elif chType == 3:
                         event.description = event.description.replace(
                             text1, text2)
                     event.afterModify()
                     event.save()
示例#23
0
文件: ui.py 项目: ilius/starcal2
def parseDroppedDate(text):
    part = text.split('/')
    if len(part) == 3:
        try:
            part[0] = numDecode(part[0])
            part[1] = numDecode(part[1])
            part[2] = numDecode(part[2])
        except:
            myRaise(__file__)
            return None
        maxPart = max(part)
        if maxPart > 999:
            minMax = (
                (1000, 2100),
                (1, 12),
                (1, 31),
            )
            formats = (
                [0, 1, 2],
                [1, 2, 0],
                [2, 1, 0],
            )
            for format in formats:
                for i in range(3):
                    valid = True
                    f = format[i]
                    if not (minMax[f][0] <= part[i] <= minMax[f][1]):
                        valid = False
                        #print('format %s was not valid, part[%s]=%s'%(format, i, part[i]))
                        break
                if valid:
                    year = part[format.index(
                        0)]  ## "format" must be list because of method "index"
                    month = part[format.index(1)]
                    day = part[format.index(2)]
                    break
        else:
            valid = 0 <= part[0] <= 99 and 1 <= part[1] <= 12 and 1 <= part[
                2] <= 31
            ###
            year = 2000 + part[0]  ## FIXME
            month = part[1]
            day = part[2]
        if not valid:
            return None
    else:
        return None
    ##??????????? when drag from a persian GtkCalendar with format %y/%m/%d
    #if year < 100:
    #	year += 2000
    return (year, month, day)
示例#24
0
 def doAction(self):
     container = self._container
     if self.iconRadio.get_active():
         chType = self.iconChangeCombo.get_active()
         if chType!=0:
             icon = self.iconSelect.get_filename()
             for event in container:
                 if not (chType==2 and event.icon):
                     event.icon = icon
                     event.afterModify()
                     event.save()
     elif self.timeZoneRadio.get_active():
         chType = self.timeZoneChangeCombo.get_active()
         timeZone = self.timeZoneInput.get_text()
         if chType!=0:
             try:
                 natz.timezone(timeZone)
             except:
                 myRaise('Invalid Time Zone "%s"'%timeZone)
             else:
                 for event in container:
                     if not (chType==2 and event.timeZone):
                         event.timeZone = timeZone
                         event.afterModify()
                         event.save()
     else:
         chType = self.textChangeCombo.get_active()
         if chType!=0:
             text1 = self.textInput1.get_text()
             text2 = self.textInput2.get_text()
             if self.summaryRadio.get_active():
                 for event in container:
                     if chType==1:
                         event.summary = text1 + event.summary
                     elif chType==2:
                         event.summary = event.summary + text1
                     elif chType==3:
                         event.summary = event.summary.replace(text1, text2)
                     event.afterModify()
                     event.save()
             elif self.descriptionRadio.get_active():
                 for event in container:
                     if chType==1:
                         event.description = text1 + event.description
                     elif chType==2:
                         event.description = event.description + text1
                     elif chType==3:
                         event.description = event.description.replace(text1, text2)
                     event.afterModify()
                     event.save()
示例#25
0
文件: ui.py 项目: amirkarimi/starcal
def parseDroppedDate(text):
    part = text.split('/')
    if len(part)==3:
        try:
            part[0] = numDecode(part[0])
            part[1] = numDecode(part[1])
            part[2] = numDecode(part[2])
        except:
            myRaise(__file__)
            return None
        maxPart = max(part)
        if maxPart > 999:
            minMax = (
                (1000, 2100),
                (1, 12),
                (1, 31),
            )
            formats = (
                [0, 1, 2],
                [1, 2, 0],
                [2, 1, 0],
            )
            for format in formats:
                for i in range(3):
                    valid = True
                    f = format[i]
                    if not (minMax[f][0] <= part[i] <= minMax[f][1]):
                        valid = False
                        #print('format %s was not valid, part[%s]=%s'%(format, i, part[i]))
                        break
                if valid:
                    year = part[format.index(0)] ## "format" must be list because of method "index"
                    month = part[format.index(1)]
                    day = part[format.index(2)]
                    break
        else:
            valid = 0 <= part[0] <= 99 and 1 <= part[1] <= 12 and 1 <= part[2] <= 31
            ###
            year = 2000 + part[0] ## FIXME
            month = part[1]
            day = part[2]
        if not valid:
            return None
    else:
        return None
    ##??????????? when drag from a persian GtkCalendar with format %y/%m/%d
    #if year < 100:
    #    year += 2000
    return (year, month, day)
示例#26
0
 def delete(self, eid):
     try:
         hp = self.byId[eid]
     except KeyError:
         return 0
     else:
         n = 0
         for mt, dt in hp.getAll():
             try:
                 self.root = self.deleteStep(self.root, mt, dt, eid)
             except:
                 myRaise()
             else:
                 n += 1
         return n
示例#27
0
 def delete(self, eid):
     hp = self.byId.get(eid)
     if hp is None:
         return 0
     else:
         n = 0
         for mt, dt in hp.getAll():
             try:
                 self.root = self.deleteStep(self.root, mt, dt, eid)
             except:
                 myRaise()
             else:
                 n += 1
         del self.byId[eid]
         return n
示例#28
0
 def treevCursorChanged(self, selection):
     if self.activeOptionsWidget:
         try:
             self.vbox_l.remove(self.activeOptionsWidget)
         except:
             myRaise(__file__)
         self.activeOptionsWidget = None
     index_list = self.treev.get_cursor()[0]
     if not index_list:
         return
     item = self.getItemByPath(index_list)
     item.optionsWidgetCreate()
     if item.optionsWidget:
         self.activeOptionsWidget = item.optionsWidget
         pack(self.vbox_l, item.optionsWidget)
         item.optionsWidget.show()
示例#29
0
 def treevCursorChanged(self, selection):
     if self.activeOptionsWidget:
         try:
             self.vbox_l.remove(self.activeOptionsWidget)
         except:
             myRaise(__file__)
         self.activeOptionsWidget = None
     index_list = self.treev.get_cursor()[0]
     if not index_list:
         return
     item = self.getItemByPath(index_list)
     item.optionsWidgetCreate()
     if item.optionsWidget:
         self.activeOptionsWidget = item.optionsWidget
         pack(self.vbox_l, item.optionsWidget)
         item.optionsWidget.show()
示例#30
0
 def add(self, t0, t1, eid, debug=False):
     if debug:
         from time import strftime, localtime
         f = '%F, %T'
         print 'EventSearchTree.add: %s\t%s'%(
             strftime(f, localtime(t0)),
             strftime(f, localtime(t1)),
         )
     try:
         mt = (t0 + t1)/2.0
         dt = (t1 - t0)/2.0
         self.root = self.addStep(self.root, t0, t1, mt, dt, eid)
         try:
             hp = self.byId[eid]
         except KeyError:
             hp = self.byId[eid] = MaxHeap()
         hp.add(mt, dt)## FIXME
     except:
         myRaise()
示例#31
0
 def onExposeEvent(self, widget=None, event=None):
     cr = self.getContext()
     self.drawBg(cr)
     ###
     w = self.get_allocation().width
     h = self.get_allocation().height
     ###
     rowH = h/7.0
     itemW = w - ui.wcalPadding
     for i in range(7):
         c = self.wcal.status[i]
         iconList = c.getWeekEventIcons()
         if not iconList:
             continue
         n = len(iconList)
         scaleFact = min(
             1.0,
             h / self.maxPixH,
             w / (n * self.maxPixW),
         )
         x0 = (w/scaleFact - (n-1)*self.maxPixW) / 2.0
         y0 = (2*i + 1) * h / (14.0*scaleFact)
         if rtl:
             iconList.reverse()## FIXME
         for iconIndex, icon in enumerate(iconList):
             try:
                 pix = gdk.pixbuf_new_from_file(icon)
             except:
                 myRaise(__file__)
                 continue
             pix_w = pix.get_width()
             pix_h = pix.get_height()
             x1 = x0 + iconIndex*self.maxPixW - pix_w/2.0
             y1 = y0 - pix_h/2.0
             cr.scale(scaleFact, scaleFact)
             cr.set_source_pixbuf(pix, x1, y1)
             cr.rectangle(x1, y1, pix_w, pix_h)
             cr.fill()
             cr.scale(1.0/scaleFact, 1.0/scaleFact)
示例#32
0
def importAndDeleteCustomDB(mode, groupTitle):
    customDB = loadCustomDB()
    if customDB:
        group = event_lib.EventGroup()
        group.mode = mode
        group.title = groupTitle
        for item in customDB:
            event = group.createEvent('yearly')
            event.mode = mode
            try:
                event.setMonth(item['month'])
                event.setDay(item['day'])
                event.summary = item['desc']  ## desc could be multi-line FIXME
                event.icon = join(pixDir, customdayModes[item['type']][1])
                group.append(event)
                event.save()
            except:
                myRaise()
            group.save()
        ui.eventGroups.append(group)
        ui.eventGroups.save()
    os.remove(customFile)
示例#33
0
def importAndDeleteCustomDB(mode, groupTitle):
    customDB = loadCustomDB()
    if customDB:
        group = event_lib.EventGroup()
        group.mode = mode
        group.title = groupTitle
        for item in customDB:
            event = group.createEvent('yearly')
            event.mode = mode
            try:
                event.setMonth(item['month'])
                event.setDay(item['day'])
                event.summary = item['desc']## desc could be multi-line FIXME
                event.icon = join(pixDir, customdayModes[item['type']][1])
                group.append(event)
                event.save()
            except:
                myRaise()
            group.save()
        ui.eventGroups.append(group)
        ui.eventGroups.save()
    os.remove(customFile)
示例#34
0
	def onExposeEvent(self, widget=None, event=None):
		cr = self.getContext()
		self.drawBg(cr)
		###
		w = self.get_allocation().width
		h = self.get_allocation().height
		###
		rowH = h/7.0
		itemW = w - ui.wcalPadding
		for i in range(7):
			c = self.wcal.status[i]
			iconList = c.getWeekEventIcons()
			if not iconList:
				continue
			n = len(iconList)
			scaleFact = min(
				1.0,
				h / self.maxPixH,
				w / (n * self.maxPixW),
			)
			x0 = (w/scaleFact - (n-1)*self.maxPixW) / 2.0
			y0 = (2*i + 1) * h / (14.0*scaleFact)
			if rtl:
				iconList.reverse()## FIXME
			for iconIndex, icon in enumerate(iconList):
				try:
					pix = gdk.pixbuf_new_from_file(icon)
				except:
					myRaise(__file__)
					continue
				pix_w = pix.get_width()
				pix_h = pix.get_height()
				x1 = x0 + iconIndex*self.maxPixW - pix_w/2.0
				y1 = y0 - pix_h/2.0
				cr.scale(scaleFact, scaleFact)
				cr.set_source_pixbuf(pix, x1, y1)
				cr.rectangle(x1, y1, pix_w, pix_h)
				cr.fill()
				cr.scale(1.0/scaleFact, 1.0/scaleFact)
示例#35
0
 def setData(self, data):
     for (name, enable) in data['items']:
         try:
             item = self.defaultItemsDict[name]
         except KeyError:
             myRaise()
         else:
             item.enable = enable
             self.setupItemSignals(item)
             self.appendItem(item)
     ###
     iconSize = data['iconSize']
     for (i, item) in enumerate(ud.iconSizeList):
         if item[0] == iconSize:
             self.iconSizeCombo.set_active(i)
     self.setIconSizeName(iconSize)
     ###
     styleNum = self.styleList.index(data['style'])
     self.styleCombo.set_active(styleNum)
     self.set_style(styleNum)
     ###
     bb = data.get('buttonsBorder', 0)
     self.buttonsBorderSpin.set_value(bb)
     self.setButtonsBorder(bb)
示例#36
0
 def setData(self, data):
     for (name, enable) in data['items']:
         try:
             item = self.defaultItemsDict[name]
         except KeyError:
             myRaise()
         else:
             item.enable = enable
             self.setupItemSignals(item)
             self.appendItem(item)
     ###
     iconSize = data['iconSize']
     for (i, item) in enumerate(ud.iconSizeList):
         if item[0]==iconSize:
             self.iconSizeCombo.set_active(i)
     self.setIconSizeName(iconSize)
     ###
     styleNum = self.styleList.index(data['style'])
     self.styleCombo.set_active(styleNum)
     self.set_style(styleNum)
     ###
     bb = data.get('buttonsBorder', 0)
     self.buttonsBorderSpin.set_value(bb)
     self.setButtonsBorder(bb)
示例#37
0
 def add(self, t0, t1, eid, debug=False):
     if debug:
         from time import strftime, localtime
         f = '%F, %T'
         print('EventSearchTree.add: %s\t%s\t%s'%(
             eid,
             strftime(f, localtime(t0)),
             strftime(f, localtime(t1)),
         ))
     ###
     if t0 == t1:
         t1 += epsTm ## needed? FIXME
     mt = (t0 + t1)/2.0
     dt = (t1 - t0)/2.0
     ###
     try:
         self.root = self.addStep(self.root, t0, t1, mt, dt, eid)
     except:
         myRaise()
     try:
         hp = self.byId[eid]
     except KeyError:
         hp = self.byId[eid] = MaxHeap()
     hp.push(mt, dt)## FIXME
示例#38
0
lang = ''
langActive = ''
## langActive==lang except when lang=='' (in that case, langActive will be taken from system)
## langActive will not get changed while the program is running
## (because it needs to restart program to apply new language)
langSh = ''  ## short language name, for example 'en', 'fa', 'fr', ...
rtl = False  ## right to left

enableNumLocale = True

localeConfPath = join(confDir, 'locale.conf')
if isfile(localeConfPath):
    try:
        exec(open(localeConfPath).read())
    except:
        myRaise(__file__)

## translator
tr = lambda s, *a, **ka: numEncode(s, *a, **ka) if isinstance(s, (int, long)
                                                              ) else str(s)


class LangData:
    def __init__(self, code, name, nativeName, fileName, flag, rtl):
        self.code = code
        self.name = name
        self.nativeName = nativeName
        ###
        #self.fileName = fileName## FIXME
        transPath = ''
        path = join(rootDir, 'locale.d', fileName + '.mo')
示例#39
0
    def __init__(self, statusIconMode=2):
        gtk.Window.__init__(self)  ##, gtk.WINDOW_POPUP) ## ????????????
        self.initVars()
        ud.windowList.appendItem(self)
        ui.mainWin = self
        ##################
        ## statusIconMode:
        ## ('none', 'none')
        ## ('statusIcon', 'normal')
        ## ('applet', 'gnome')
        ## ('applet', 'kde')
        ##
        ## 0: none (simple window)
        ## 1: applet
        ## 2: standard status icon
        self.statusIconMode = statusIconMode
        ###
        #ui.eventManDialog = None
        #ui.timeLineWin = None
        ###
        #ui.weekCalWin = WeekCalWindow()
        #ud.windowList.appendItem(ui.weekCalWin)
        ###
        self.dayInfoDialog = None
        #print('windowList.items', [item._name for item in ud.windowList.items])
        ###########
        ##self.connect('window-state-event', selfStateEvent)
        self.set_title('%s %s' % (core.APP_DESC, core.VERSION))
        #self.connect('main-show', lambda arg: self.present())
        #self.connect('main-hide', lambda arg: self.hide())
        self.set_decorated(False)
        self.set_property(
            'skip-taskbar-hint',
            not ui.winTaskbar)  ## self.set_skip_taskbar_hint  ## FIXME
        self.set_role('starcal2')
        #self.set_focus_on_map(True)#????????
        #self.set_type_hint(gdk.WINDOW_TYPE_HINT_NORMAL)
        #self.connect('realize', self.onRealize)
        self.set_default_size(ui.winWidth, 1)
        try:
            self.move(ui.winX, ui.winY)
        except:
            pass
        #############################################################
        self.connect('focus-in-event', self.focusIn, 'Main')
        self.connect('focus-out-event', self.focusOut, 'Main')
        self.connect('button-press-event', self.buttonPress)
        self.connect('key-press-event', self.keyPress)
        self.connect('configure-event', self.configureEvent)
        self.connect('destroy', self.quit)
        #############################################################
        """
		#self.add_events(gdk.VISIBILITY_NOTIFY_MASK)
		#self.connect('frame-event', show_event)
		## Compiz does not send configure-event(or any event) when MOVING window(sends in last point,
		## when moving completed)
		#self.connect('drag-motion', show_event)
		ud.rootWindow.set_events(...
		ud.rootWindow.add_filter(self.onRootWinEvent)
		#self.realize()
		#gdk.flush()
		#self.configureEvent(None, None)
		#self.connect('drag-motion', show_event)
		######################
		## ????????????????????????????????????????????????
		## when button is down(before button-release-event), motion-notify-event does not recived!
		"""
        ##################################################################
        self.focus = False
        #self.focusOutTime = 0
        #self.clockTr = None
        ############################################################################
        self.winCon = None
        ############
        self.vbox = MainWinVbox()
        ui.checkMainWinItems()
        itemsPkg = 'scal2.ui_gtk.mainwin_items'
        for (name, enable) in ui.mainWinItems:
            #print(name, enable)
            if enable:
                try:
                    module = __import__(
                        '.'.join([
                            itemsPkg,
                            name,
                        ]),
                        fromlist=['CalObj'],
                    )
                    CalObj = module.CalObj
                except:
                    myRaise()
                    continue
                item = CalObj()
                item.enable = enable
                item.connect('size-request',
                             self.childSizeRequest)  ## or item.connect
                #modify_bg_all(item, gtk.STATE_NORMAL, rgbToGdkColor(*ui.bgColor))
            else:
                desc = mainWinItemsDesc[name]
                item = DummyCalObj(name, desc, itemsPkg, True)
                ## what about size-request FIXME
            self.vbox.appendItem(item)
        self.appendItem(self.vbox)
        self.vbox.show()
        self.customizeDialog = None
        #######
        self.add(self.vbox)
        ####################
        if ui.winMaximized:
            self.maximize()
        ####################
        #ui.prefDialog = None
        self.exportDialog = None
        self.selectDateDialog = None
        ############### Building About Dialog
        self.aboutDialog = None
        ###############
        self.menuMain = None
        #####
        check = gtk.CheckMenuItem(label=_('_On Top'))
        check.connect('activate', self.keepAboveClicked)
        check.set_active(ui.winKeepAbove)
        self.set_keep_above(ui.winKeepAbove)
        self.checkAbove = check
        #####
        check = gtk.CheckMenuItem(label=_('_Sticky'))
        check.connect('activate', self.stickyClicked)
        check.set_active(ui.winSticky)
        if ui.winSticky:
            self.stick()
        self.checkSticky = check
        ############################################################
        self.statusIconInit()
        listener.dateChange.add(self)
        #if self.statusIconMode!=1:
        #	gobject.timeout_add_seconds(self.timeout, self.statusIconUpdate)
        #########
        self.connect('delete-event', self.onDeleteEvent)
        #########################################
        for plug in core.allPlugList:
            if plug.external:
                try:
                    plug.set_dialog(self)
                except AttributeError:
                    pass
        ###########################
        self.onConfigChange()
示例#40
0
 def __init__(self, trayMode=2):
     gtk.Window.__init__(self)##, gtk.WINDOW_POPUP) ## ????????????
     self.initVars()
     ud.windowList.appendItem(self)
     ui.mainWin = self
     ##################
     ## trayMode:
         ## ('none', 'none')
         ## ('tray', 'normal')
         ## ('applet', 'gnome')
         ## ('applet', 'kde')
         ##
         ## 0: none (simple window)
         ## 1: applet
         ## 2: standard tray icon
     self.trayMode = trayMode
     ###
     ui.eventManDialog = EventManagerDialog()
     ###
     ui.timeLineWin = TimeLineWindow()
     ###
     #ui.weekCalWin = WeekCalWindow()
     #ud.windowList.appendItem(ui.weekCalWin)
     ###
     self.dayInfoDialog = DayInfoDialog()
     #print 'windowList.items', [item._name for item in ud.windowList.items]
     ###########
     ##self.connect('window-state-event', selfStateEvent)
     self.set_title('%s %s'%(core.APP_DESC, core.VERSION))
     #self.connect('main-show', lambda arg: self.present())
     #self.connect('main-hide', lambda arg: self.hide())
     self.set_decorated(False)
     self.set_property('skip-taskbar-hint', not ui.winTaskbar) ## self.set_skip_taskbar_hint  ## FIXME
     self.set_role('starcal2')
     #self.set_focus_on_map(True)#????????
     #self.set_type_hint(gdk.WINDOW_TYPE_HINT_NORMAL)
     #self.connect('realize', self.onRealize)
     self.set_default_size(ui.winWidth, 1)
     try:
         self.move(ui.winX, ui.winY)
     except:
         pass
     #############################################################
     self.connect('focus-in-event', self.focusIn, 'Main')
     self.connect('focus-out-event', self.focusOut, 'Main')
     self.connect('button-press-event', self.buttonPress)
     self.connect('key-press-event', self.keyPress)
     self.connect('configure-event', self.configureEvent)
     self.connect('destroy', self.quit)
     #############################################################
     """
     #self.add_events(gdk.VISIBILITY_NOTIFY_MASK)
     #self.connect('frame-event', show_event)
     ## Compiz does not send configure-event(or any event) when MOVING window(sends in last point,
     ## when moving completed)
     #self.connect('drag-motion', show_event)
     ud.rootWindow.set_events(...
     ud.rootWindow.add_filter(self.onRootWinEvent)
     #self.realize()
     #gdk.flush()
     #self.configureEvent(None, None)
     #self.connect('drag-motion', show_event)
     ######################
     ## ????????????????????????????????????????????????
     ## when button is down(before button-release-event), motion-notify-event does not recived!
     """
     ##################################################################
     self.focus = False
     #self.focusOutTime = 0
     #self.clockTr = None
     ############################################################################
     self.winCon = MainWinController()
     ############
     defaultItems = [
         self.winCon,
         MainWinToolbar(),
         YearMonthLabelBox(),
         MonthCal(),
         WeekCal(),
         StatusBox(),
         PluginsTextBox(),
         EventViewMainWinItem(),
     ]
     defaultItemsDict = dict([(obj._name, obj) for obj in defaultItems])
     ui.checkMainWinItems()
     self.vbox = MainWinVbox()
     for (name, enable) in ui.mainWinItems:
         #print name, enable
         try:
             item = defaultItemsDict[name]
         except:
             myRaise()
             continue
         item.enable = enable
         item.connect('size-request', self.childSizeRequest) ## or item.connect
         #modify_bg_all(item, gtk.STATE_NORMAL, rgbToGdkColor(*ui.bgColor))
         self.vbox.appendItem(item)
     self.appendItem(self.vbox)
     self.vbox.show()
     self.customizeDialog = CustomizeDialog(self.vbox)
     #######
     self.add(self.vbox)
     ####################
     self.isMaximized = False
     ####################
     ui.prefDialog = preferences.PrefDialog(self.trayMode)
     self.exportDialog = scal2.ui_gtk.export.ExportDialog()
     self.selectDateDialog = scal2.ui_gtk.selectdate.SelectDateDialog()
     self.selectDateDialog.connect('response-date', self.selectDateResponse)
     selectDateShow = self.selectDateShow
     ############### Building About Dialog
     about = AboutDialog(
         name=core.APP_DESC,
         version=core.VERSION,
         title=_('About ')+core.APP_DESC,
         authors=[_(line) for line in open(join(rootDir, 'authors-dialog')).read().splitlines()],
         comments=core.aboutText,
         license=core.licenseText,
         website=core.homePage,
     )
     ## add Donate button ## FIXME
     about.connect('delete-event', self.aboutHide)
     about.connect('response', self.aboutHide)
     #about.set_logo(gdk.pixbuf_new_from_file(ui.logo))
     #about.set_skip_taskbar_hint(True)
     self.about = about
     ########################################### Building main menu
     menu = gtk.Menu()
     ####
     item = gtk.ImageMenuItem(_('Resize'))
     item.set_image(imageFromFile('resize.png'))
     item.connect('button-press-event', self.startResize)
     menu.add(item)
     ####
     check = gtk.CheckMenuItem(label=_('_On Top'))
     check.connect('activate', self.keepAboveClicked)
     menu.add(check)
     check.set_active(ui.winKeepAbove)
     self.set_keep_above(ui.winKeepAbove)
     self.checkAbove = check
     #####
     check = gtk.CheckMenuItem(label=_('_Sticky'))
     check.connect('activate', self.stickyClicked)
     menu.add(check)
     check.set_active(ui.winSticky)
     if ui.winSticky:
         self.stick()
     self.checkSticky = check
     #####
     menu.add(labelStockMenuItem('Select _Today', gtk.STOCK_HOME, self.goToday))
     menu.add(labelStockMenuItem('Select _Date...', gtk.STOCK_INDEX, selectDateShow))
     menu.add(labelStockMenuItem('Day Info', gtk.STOCK_INFO, self.dayInfoShow))
     menu.add(labelStockMenuItem('_Customize', gtk.STOCK_EDIT, self.customizeShow))
     menu.add(labelStockMenuItem('_Preferences', gtk.STOCK_PREFERENCES, self.prefShow))
     #menu.add(labelStockMenuItem('_Add Event', gtk.STOCK_ADD, ui.eventManDialog.addCustomEvent))
     menu.add(labelStockMenuItem('_Event Manager', gtk.STOCK_ADD, self.eventManShow))
     menu.add(labelImageMenuItem('Time Line', 'timeline-18.png', self.timeLineShow))
     #menu.add(labelImageMenuItem('Week Calendar', 'weekcal-18.png', self.weekCalShow))
     menu.add(labelStockMenuItem(_('Export to %s')%'HTML', gtk.STOCK_CONVERT, self.exportClicked))
     menu.add(labelStockMenuItem('_About', gtk.STOCK_ABOUT, self.aboutShow))
     if self.trayMode!=1:
         menu.add(labelStockMenuItem('_Quit', gtk.STOCK_QUIT, self.quit))
     menu.show_all()
     self.menuMain = menu
     ############################################################
     self.trayInit()
     listener.dateChange.add(self)
     #if self.trayMode!=1:
     #    timeout_add_seconds(self.timeout, self.trayUpdate)
     #########
     self.connect('delete-event', self.dialogClose)
     ######################
     self.updateMenuSize()
     ui.prefDialog.updatePrefGui()
     self.clipboard = gtk.clipboard_get(gdk.SELECTION_CLIPBOARD)
     #########################################
     for plug in core.allPlugList:
         if plug.external and hasattr(plug, 'set_dialog'):
             plug.set_dialog(self)
     ###########################
     self.onConfigChange()
示例#41
0
	def drawAll(self, widget=None, gevent=None, cr=None, cursor=True):
		#?????? Must enhance (only draw few cells, not all cells)
		#print(now(), 'drawAll'#, tuple(gevent.area), tuple(self.get_allocation()))
		if gevent:
			xu, yu, wu, hu = tuple(gevent.area)
			#print('expose-event area:', xu, yu, wu, hu)
		self.calcCoord()
		w = self.get_allocation().width
		h = self.get_allocation().height
		if not cr:
			cr = self.get_window().cairo_create()
			#cr.set_line_width(0)#??????????????
			#cr.scale(0.5, 0.5)
		wx = ui.winX
		wy = ui.winY
		if ui.bgUseDesk:## FIXME
			### ????????????????? Need for mainWin !!!!!
			coord = self.translate_coordinates(self, wx, wy)
			if len(coord)==2:
				from scal2.ui_gtk import desktop
				x0, y0 = coord
				try:
					bg = desktop.get_wallpaper(x0, y0, w, h)
				except:
					print('Could not get wallpaper!')
					myRaise(__file__)
					#os.popen('gnome-settings-daemon')
					ui.bgUseDesk = False ##??????????????????
					#if ui.prefDialog
					#	ui.prefDialog.checkDeskBg.set_active(False)##??????????????????
				else:
					cr.set_source_pixbuf(bg, 0, 0)
					cr.paint()
			#else:
			#	print(coord)
		cr.rectangle(0, 0, w, h)
		fillColor(cr, ui.bgColor)
		status = getCurrentMonthStatus()
		#################################### Drawing Border
		if ui.mcalTopMargin>0:
			##### Drawing border top background
			##menuBgColor == borderColor ##???????????????
			cr.rectangle(0, 0, w, ui.mcalTopMargin)
			fillColor(cr, ui.borderColor)
			######## Drawing weekDays names
			setColor(cr, ui.borderTextColor)
			dx = 0
			wdayAb = (self.wdaysWidth > w)
			for i in range(7):
				wday = newTextLayout(self, core.getWeekDayAuto(i, wdayAb))
				try:
					fontw, fonth = wday.get_pixel_size()
				except:
					myRaise(__file__)
					fontw, fonth = wday.get_pixel_size()
				cr.move_to(
					self.cx[i]-fontw/2.0,
					(ui.mcalTopMargin-fonth)/2.0-1,
				)
				cr.show_layout(wday)
			######## Drawing "Menu" label
			setColor(cr, ui.menuTextColor)
			text = newTextLayout(self, _('Menu'))
			fontw, fonth = text.get_pixel_size()
			if rtl:
				cr.move_to(
					w-(ui.mcalLeftMargin+fontw)/2.0 - 3,
					(ui.mcalTopMargin-fonth)/2.0 - 1,
				)
			else:
				cr.move_to(
					(ui.mcalLeftMargin-fontw)/2.0,
					(ui.mcalTopMargin-fonth)/2.0 - 1,
				)
			cr.show_layout(text)
		if ui.mcalLeftMargin>0:
			##### Drawing border left background
			if rtl:
				cr.rectangle(
					w - ui.mcalLeftMargin,
					ui.mcalTopMargin,
					ui.mcalLeftMargin,
					h - ui.mcalTopMargin,
				)
			else:
				cr.rectangle(
					0,
					ui.mcalTopMargin,
					ui.mcalLeftMargin,
					h - ui.mcalTopMargin,
				)
			fillColor(cr, ui.borderColor)
			##### Drawing week numbers
			setColor(cr, ui.borderTextColor)
			for i in range(6):
				lay = newTextLayout(self, _(status.weekNum[i]))
				fontw, fonth = lay.get_pixel_size()
				if rtl:
					cr.move_to(
						w - (ui.mcalLeftMargin+fontw)/2.0,
						self.cy[i]-fonth/2.0 + 2,
					)
				else:
					cr.move_to(
						(ui.mcalLeftMargin-fontw)/2.0,
						self.cy[i]-fonth/2.0 + 2,
					)
				cr.show_layout(lay)
		selectedCellPos = ui.cell.monthPos
		if ui.todayCell.inSameMonth(ui.cell):
			tx, ty = ui.todayCell.monthPos ## today x and y
			x0 = self.cx[tx] - self.dx/2.0
			y0 = self.cy[ty] - self.dy/2.0
			cr.rectangle(x0, y0, self.dx, self.dy)
			fillColor(cr, ui.todayCellColor)
		for yPos in range(6):
			for xPos in range(7):
				c = status[yPos][xPos]
				x0 = self.cx[xPos]
				y0 = self.cy[yPos]
				cellInactive = (c.month != ui.cell.month)
				cellHasCursor = (cursor and (xPos, yPos) == selectedCellPos)
				if cellHasCursor:
					##### Drawing Cursor
					cx0 = x0 - self.dx/2.0 + 1
					cy0 = y0 - self.dy/2.0 + 1
					cw = self.dx - 1
					ch = self.dy - 1
					######### Circular Rounded
					drawCursorBg(cr, cx0, cy0, cw, ch)
					fillColor(cr, ui.cursorBgColor)
				######## end of Drawing Cursor
				if not cellInactive:
					iconList = c.getMonthEventIcons()
					if iconList:
						iconsN = len(iconList)
						scaleFact = 1.0 / sqrt(iconsN)
						fromRight = 0
						for index, icon in enumerate(iconList):
							## if len(iconList) > 1 ## FIXME
							try:
								pix = gdk.pixbuf_new_from_file(icon)
							except:
								myRaise(__file__)
								continue
							pix_w = pix.get_width()
							pix_h = pix.get_height()
							## right buttom corner ?????????????????????
							x1 = (self.cx[xPos] + self.dx/2.0)/scaleFact - fromRight - pix_w # right side
							y1 = (self.cy[yPos] + self.dy/2.0)/scaleFact - pix_h # buttom side
							cr.scale(scaleFact, scaleFact)
							cr.set_source_pixbuf(pix, x1, y1)
							cr.rectangle(x1, y1, pix_w, pix_h)
							cr.fill()
							cr.scale(1.0/scaleFact, 1.0/scaleFact)
							fromRight += pix_w
				#### Drawing numbers inside every cell
				#cr.rectangle(
				#	x0-self.dx/2.0+1,
				#	y0-self.dy/2.0+1,
				#	self.dx-1,
				#	self.dy-1,
				#)
				mode = calTypes.primary
				params = ui.mcalTypeParams[0]
				daynum = newTextLayout(self, _(c.dates[mode][2], mode), params['font'])
				fontw, fonth = daynum.get_pixel_size()
				if cellInactive:
					setColor(cr, ui.inactiveColor)
				elif c.holiday:
					setColor(cr, ui.holidayColor)
				else:
					setColor(cr, params['color'])
				cr.move_to(
					x0 - fontw/2.0 + params['pos'][0],
					y0 - fonth/2.0 + params['pos'][1],
				)
				cr.show_layout(daynum)
				if not cellInactive:
					for mode, params in ui.getMcalMinorTypeParams()[1:]:
						daynum = newTextLayout(self, _(c.dates[mode][2], mode), params['font'])
						fontw, fonth = daynum.get_pixel_size()
						setColor(cr, params['color'])
						cr.move_to(
							x0 - fontw/2.0 + params['pos'][0],
							y0 - fonth/2.0 + params['pos'][1],
						)
						cr.show_layout(daynum)
					if cellHasCursor:
						##### Drawing Cursor Outline
						cx0 = x0-self.dx/2.0+1
						cy0 = y0-self.dy/2.0+1
						cw = self.dx-1
						ch = self.dy-1
						######### Circular Rounded
						drawCursorOutline(cr, cx0, cy0, cw, ch)
						fillColor(cr, ui.cursorOutColor)
						##### end of Drawing Cursor Outline
		################ end of drawing cells
		##### drawGrid
		if ui.mcalGrid:
			setColor(cr, ui.mcalGridColor)
			for i in range(7):
				cr.rectangle(self.cx[i]+rtlSgn()*self.dx/2.0, 0, 1, h)
				cr.fill()
			for i in range(6):
				cr.rectangle(0, self.cy[i]-self.dy/2.0, w, 1)
				cr.fill()
		return False
示例#42
0
    sys.exit(1)

import os
from os.path import join, dirname, isfile, isdir
from subprocess import Popen
from pprint import pprint, pformat

sys.path.insert(0, dirname(dirname(dirname(__file__))))
from scal2.path import *
from scal2.utils import myRaise, restartLow

if not isdir(confDir):
    try:
        __import__('scal2.ui_gtk.import_config_1to2')
    except:
        myRaise()
    restartLow()

from scal2.utils import toStr, toUnicode
from scal2.cal_types import calTypes
from scal2 import core

from scal2 import locale_man
from scal2.locale_man import rtl, lang ## import scal2.locale_man after core
#_ = locale_man.loadTranslator(False)## FIXME
from scal2.locale_man import tr as _

from scal2.core import rootDir, pixDir, deskDir, myRaise, getMonthName, APP_DESC

#core.showInfo()
示例#43
0
lang = ''
langActive = ''
## langActive==lang except when lang=='' (that langActive will taken from system)
## langActive will not changed via program (because need for restart program to apply new language)
langSh = '' ## short language name, for example 'en', 'fa', 'fr', ...
rtl = False ## right to left

enableNumLocale = True


localeConfPath = join(confDir, 'locale.conf')
if isfile(localeConfPath):
    try:
        exec(open(localeConfPath).read())
    except:
        myRaise(__file__)

## translator
tr = lambda s, *a, **ka: numEncode(s, *a, **ka) if isinstance(s, (int, long)) else str(s)

class LangData:
    def __init__(self, code, name, nativeName, fileName, flag, rtl):
        self.code = code
        self.name = name
        self.nativeName = nativeName
        ###
        #self.fileName = fileName## FIXME
        transPath = ''
        path = join(rootDir, 'locale.d', fileName+'.mo')
        #print('path=%s'%path)
        if isfile(path):
示例#44
0
 def __init__(self, statusIconMode=2):
     gtk.Window.__init__(self)##, gtk.WINDOW_POPUP) ## ????????????
     self.initVars()
     ud.windowList.appendItem(self)
     ui.mainWin = self
     ##################
     ## statusIconMode:
         ## ('none', 'none')
         ## ('statusIcon', 'normal')
         ## ('applet', 'gnome')
         ## ('applet', 'kde')
         ##
         ## 0: none (simple window)
         ## 1: applet
         ## 2: standard status icon
     self.statusIconMode = statusIconMode
     ###
     #ui.eventManDialog = None
     #ui.timeLineWin = None
     ###
     #ui.weekCalWin = WeekCalWindow()
     #ud.windowList.appendItem(ui.weekCalWin)
     ###
     self.dayInfoDialog = None
     #print('windowList.items', [item._name for item in ud.windowList.items])
     ###########
     ##self.connect('window-state-event', selfStateEvent)
     self.set_title('%s %s'%(core.APP_DESC, core.VERSION))
     #self.connect('main-show', lambda arg: self.present())
     #self.connect('main-hide', lambda arg: self.hide())
     self.set_decorated(False)
     self.set_property('skip-taskbar-hint', not ui.winTaskbar) ## self.set_skip_taskbar_hint  ## FIXME
     self.set_role('starcal2')
     #self.set_focus_on_map(True)#????????
     #self.set_type_hint(gdk.WINDOW_TYPE_HINT_NORMAL)
     #self.connect('realize', self.onRealize)
     self.set_default_size(ui.winWidth, 1)
     try:
         self.move(ui.winX, ui.winY)
     except:
         pass
     #############################################################
     self.connect('focus-in-event', self.focusIn, 'Main')
     self.connect('focus-out-event', self.focusOut, 'Main')
     self.connect('button-press-event', self.buttonPress)
     self.connect('key-press-event', self.keyPress)
     self.connect('configure-event', self.configureEvent)
     self.connect('destroy', self.quit)
     #############################################################
     """
     #self.add_events(gdk.VISIBILITY_NOTIFY_MASK)
     #self.connect('frame-event', show_event)
     ## Compiz does not send configure-event(or any event) when MOVING window(sends in last point,
     ## when moving completed)
     #self.connect('drag-motion', show_event)
     ud.rootWindow.set_events(...
     ud.rootWindow.add_filter(self.onRootWinEvent)
     #self.realize()
     #gdk.flush()
     #self.configureEvent(None, None)
     #self.connect('drag-motion', show_event)
     ######################
     ## ????????????????????????????????????????????????
     ## when button is down(before button-release-event), motion-notify-event does not recived!
     """
     ##################################################################
     self.focus = False
     #self.focusOutTime = 0
     #self.clockTr = None
     ############################################################################
     self.winCon = None
     ############
     self.vbox = MainWinVbox()
     ui.checkMainWinItems()
     itemsPkg = 'scal2.ui_gtk.mainwin_items'
     for (name, enable) in ui.mainWinItems:
         #print(name, enable)
         if enable:
             try:
                 module = __import__(
                     '.'.join([
                         itemsPkg,
                         name,
                     ]),
                     fromlist=['CalObj'],
                 )
                 CalObj = module.CalObj
             except:
                 myRaise()
                 continue
             item = CalObj()
             item.enable = enable
             item.connect('size-request', self.childSizeRequest) ## or item.connect
             #modify_bg_all(item, gtk.STATE_NORMAL, rgbToGdkColor(*ui.bgColor))
         else:
             desc = mainWinItemsDesc[name]
             item = DummyCalObj(name, desc, itemsPkg, True)
             ## what about size-request FIXME
         self.vbox.appendItem(item)
     self.appendItem(self.vbox)
     self.vbox.show()
     self.customizeDialog = None
     #######
     self.add(self.vbox)
     ####################
     self.isMaximized = False
     ####################
     #ui.prefDialog = None
     self.exportDialog = None
     self.selectDateDialog = None
     ############### Building About Dialog
     self.aboutDialog = None
     ###############
     self.menuMain = None
     #####
     check = gtk.CheckMenuItem(label=_('_On Top'))
     check.connect('activate', self.keepAboveClicked)
     check.set_active(ui.winKeepAbove)
     self.set_keep_above(ui.winKeepAbove)
     self.checkAbove = check
     #####
     check = gtk.CheckMenuItem(label=_('_Sticky'))
     check.connect('activate', self.stickyClicked)
     check.set_active(ui.winSticky)
     if ui.winSticky:
         self.stick()
     self.checkSticky = check
     ############################################################
     self.statusIconInit()
     listener.dateChange.add(self)
     #if self.statusIconMode!=1:
     #    gobject.timeout_add_seconds(self.timeout, self.statusIconUpdate)
     #########
     self.connect('delete-event', self.onDeleteEvent)
     #########################################
     for plug in core.allPlugList:
         if plug.external:
             try:
                 plug.set_dialog(self)
             except AttributeError:
                 pass
     ###########################
     self.onConfigChange()
示例#45
0
from time import localtime
import os
import os.path
from os.path import join, dirname

sys.path.insert(0, dirname(dirname(dirname(__file__))))

from scal2.path import *
from scal2.utils import myRaise

if not os.path.isdir(confDir):
    from scal2.utils import restartLow
    try:
        __import__('scal2.ui_gtk.import_config_1to2')
    except:
        myRaise()
    restartLow()

from scal2.utils import versionLessThan
from scal2.cal_types import calTypes
from scal2 import core

from scal2 import locale_man
from scal2.locale_man import rtl, lang  ## import scal2.locale_man after core
#_ = locale_man.loadTranslator(False)## FIXME
from scal2.locale_man import tr as _
from scal2 import event_lib
from scal2 import ui

import gobject
示例#46
0
	def __init__(self, statusIconMode):
		gtk.Dialog.__init__(self, title=_('Preferences'))
		self.connect('delete-event', self.onDelete)
		self.set_has_separator(False)
		#self.set_skip_taskbar_hint(True)
		###
		dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), 1, self.cancel)
		dialog_add_button(self, gtk.STOCK_APPLY, _('_Apply'), 2, self.apply)
		okB = dialog_add_button(self, gtk.STOCK_OK, _('_OK'), 3, self.ok, tooltip=_('Apply and Close'))
		okB.grab_default()## FIXME
		#okB.grab_focus()## FIXME
		##############################################
		self.localePrefItems = []
		self.corePrefItems = []
		self.uiPrefItems = []
		self.gtkPrefItems = [] ## FIXME
		#####
		self.prefPages = []
		################################ Tab 1 (General) ############################################
		vbox = gtk.VBox()
		vbox.label = _('_General')
		vbox.icon = 'preferences-other.png'
		self.prefPages.append(vbox)
		hbox = gtk.HBox(spacing=3)
		pack(hbox, gtk.Label(_('Language')))
		itemLang = LangPrefItem()
		self.localePrefItems.append(itemLang)
		###
		pack(hbox, itemLang._widget)
		if langSh!='en':
			pack(hbox, gtk.Label('Language'))
		pack(vbox, hbox)
		##########################
		hbox = gtk.HBox()
		frame = gtk.Frame(_('Calendar Types'))
		itemCals = AICalsPrefItem()
		self.corePrefItems.append(itemCals)
		frame.add(itemCals._widget)
		pack(hbox, frame)
		pack(hbox, gtk.Label(''), 1, 1)
		hbox.set_border_width(5)
		#frame.set_border_width(5)
		pack(vbox, hbox, 1, 1)
		##########################
		if statusIconMode!=1:
			hbox = gtk.HBox(spacing=3)
			item = CheckStartupPrefItem()
			self.uiPrefItems.append(item)
			pack(hbox, item._widget, 1, 1)
			pack(vbox, hbox)
			########################
			item = CheckPrefItem(ui, 'showMain', _('Show main window on start'))
			self.uiPrefItems.append(item)
			pack(vbox, item._widget)
		##########################
		item = CheckPrefItem(ui, 'winTaskbar', _('Window in Taskbar'))
		self.uiPrefItems.append(item)
		hbox = gtk.HBox(spacing=3)
		pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		###########
		pack(vbox, hbox)
		##########################
		try:
			import appindicator
		except ImportError:
			pass
		else:
			item = CheckPrefItem(ui, 'useAppIndicator', _('Use AppIndicator'))
			self.uiPrefItems.append(item)
			hbox = gtk.HBox(spacing=3)
			pack(hbox, item._widget)
			pack(hbox, gtk.Label(''), 1, 1)
			pack(vbox, hbox)
		##########################
		hbox = gtk.HBox(spacing=3)
		pack(hbox, gtk.Label(_('Show Digital Clock:')))
		pack(hbox, gtk.Label(''), 1, 1)
		#item = CheckPrefItem(ui, 'showDigClockTb', _('On Toolbar'))## FIXME
		#self.uiPrefItems.append(item)
		#pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		if statusIconMode==1:
			item = CheckPrefItem(ui, 'showDigClockTr', _('On Applet'), 'Panel Applet')
		else:
			item = CheckPrefItem(ui, 'showDigClockTr', _('On Status Icon'), 'Notification Area')
		self.uiPrefItems.append(item)
		pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		pack(vbox, hbox)
		################################ Tab 2 (Appearance) ###########################################
		vbox = gtk.VBox()
		vbox.label = _('Appeara_nce')
		vbox.icon = 'preferences-desktop-theme.png'
		self.prefPages.append(vbox)
		########
		hbox = gtk.HBox(spacing=2)
		###
		customCheckItem = CheckPrefItem(ui, 'fontCustomEnable', _('Application Font'))
		self.uiPrefItems.append(customCheckItem)
		pack(hbox, customCheckItem._widget)
		###
		customItem = FontPrefItem(ui, 'fontCustom', self)
		self.uiPrefItems.append(customItem)
		pack(hbox, customItem._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		customCheckItem.syncSensitive(customItem._widget)
		pack(vbox, hbox)
		########################### Theme #####################
		hbox = gtk.HBox(spacing=3)
		item = CheckPrefItem(ui, 'bgUseDesk', _('Use Desktop Background'))
		self.uiPrefItems.append(item)
		pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		pack(vbox, hbox)
		#####################
		hbox = gtk.HBox(spacing=3)
		lab = gtk.Label('<b>%s:</b> '%_('Colors'))
		lab.set_use_markup(True)
		pack(hbox, lab)
		pack(hbox, gtk.Label(''), 1, 1)
		###
		pack(hbox, gtk.Label(_('Background')))
		item = ColorPrefItem(ui, 'bgColor', True)
		self.uiPrefItems.append(item)
		self.colorbBg = item._widget ## FIXME
		pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		###
		pack(hbox, gtk.Label(_('Border')))
		item = ColorPrefItem(ui, 'borderColor', True)
		self.uiPrefItems.append(item)
		pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		###
		pack(hbox, gtk.Label(_('Cursor')))
		item = ColorPrefItem(ui, 'cursorOutColor', False)
		self.uiPrefItems.append(item)
		pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		###
		pack(hbox, gtk.Label(_('Cursor BG')))
		item = ColorPrefItem(ui, 'cursorBgColor', True)
		self.uiPrefItems.append(item)
		pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		###
		pack(hbox, gtk.Label(_('Today')))
		item = ColorPrefItem(ui, 'todayCellColor', True)
		self.uiPrefItems.append(item)
		pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		###
		pack(vbox, hbox)
		####################
		hbox = gtk.HBox(spacing=3)
		lab = gtk.Label('<b>%s:</b> '%_('Font Colors'))
		lab.set_use_markup(True)
		pack(hbox, lab)
		pack(hbox, gtk.Label(''), 1, 1)
		####
		pack(hbox, gtk.Label(_('Normal')))
		item = ColorPrefItem(ui, 'textColor', False)
		self.uiPrefItems.append(item)
		pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		###
		pack(hbox, gtk.Label(_('Holiday')))
		item = ColorPrefItem(ui, 'holidayColor', False)
		self.uiPrefItems.append(item)
		pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		###
		pack(hbox, gtk.Label(_('Inactive Day')))
		item = ColorPrefItem(ui, 'inactiveColor', True)
		self.uiPrefItems.append(item)
		pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		####
		pack(hbox, gtk.Label(_('Border')))
		item = ColorPrefItem(ui, 'borderTextColor', False)
		self.uiPrefItems.append(item)
		pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		####
		pack(vbox, hbox)
		###################
		hbox = gtk.HBox(spacing=1)
		label = gtk.Label('<b>%s</b>:'%_('Cursor'))
		label.set_use_markup(True)
		pack(hbox, label)
		pack(hbox, gtk.Label(''), 1, 1)
		pack(hbox, gtk.Label(_('Diameter Factor')))
		item = SpinPrefItem(ui, 'cursorDiaFactor', 0, 1, 2)
		self.uiPrefItems.append(item)
		pack(hbox, item._widget)
		###
		pack(hbox, gtk.Label(''), 1, 1)
		pack(hbox, gtk.Label(_('Rounding Factor')))
		item = SpinPrefItem(ui, 'cursorRoundingFactor', 0, 1, 2)
		self.uiPrefItems.append(item)
		pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		###
		pack(vbox, hbox)
		###################
		exp = gtk.Expander()
		label = gtk.Label('<b>%s</b>'%_('Status Icon'))
		label.set_use_markup(True)
		exp.set_label_widget(label)
		expVbox = gtk.VBox(spacing=1)
		exp.add(expVbox)
		exp.set_expanded(True)
		sgroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
		####
		hbox = gtk.HBox(spacing=1)
		pack(hbox, gtk.Label('   '))
		label = gtk.Label(_('Normal Days'))
		sgroup.add_widget(label)
		pack(hbox, label)
		item = FileChooserPrefItem(
			ui,
			'statusIconImage',
			_('Select Icon'),
			pixDir,
			defaultVarName='statusIconImageDefault',
		)
		self.uiPrefItems.append(item)
		pack(hbox, item._widget, 1, 1)
		pack(expVbox, hbox)
		####
		hbox = gtk.HBox(spacing=1)
		pack(hbox, gtk.Label('   '))
		label = gtk.Label(_('Holidays'))
		sgroup.add_widget(label)
		pack(hbox, label)
		item = FileChooserPrefItem(
			ui,
			'statusIconImageHoli',
			_('Select Icon'),
			pixDir,
			defaultVarName='statusIconImageHoliDefault',
		)
		self.uiPrefItems.append(item)
		pack(hbox, item._widget, 1, 1)
		pack(expVbox, hbox)
		####
		hbox = gtk.HBox(spacing=1)
		pack(hbox, gtk.Label('   '))
		checkItem = CheckPrefItem(
			ui,
			'statusIconFontFamilyEnable',
			label=_('Change font family to'),
			#tooltip=_('In SVG files'),
		)
		self.uiPrefItems.append(checkItem)
		#sgroup.add_widget(checkItem._widget)
		pack(hbox, checkItem._widget)
		item = FontFamilyPrefItem(
			ui,
			'statusIconFontFamily',
		)
		self.uiPrefItems.append(item)
		pack(hbox, item._widget, 1, 1)
		pack(expVbox, hbox)
		####
		hbox = gtk.HBox(spacing=1)
		pack(hbox, gtk.Label('   '))
		checkItem = CheckPrefItem(
			ui,
			'statusIconFixedSizeEnable',
			label=_('Fixed Size'),
			#tooltip=_(''),
		)
		self.uiPrefItems.append(checkItem)
		#sgroup.add_widget(checkItem._widget)
		pack(hbox, checkItem._widget)
		pack(hbox, gtk.Label('  '))
		item = WidthHeightPrefItem(
			ui,
			'statusIconFixedSizeWH',
			999,
		)
		self.uiPrefItems.append(item)
		pack(hbox, item._widget, 1, 1)      
		pack(expVbox, hbox)
		########
		checkItem.syncSensitive(item._widget, reverse=False)
		####
		pack(vbox, exp)
		################################ Tab 3 (Advanced) ###########################################
		vbox = gtk.VBox()
		vbox.label = _('A_dvanced')
		vbox.icon = 'applications-system.png'
		self.prefPages.append(vbox)
		######
		sgroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
		######
		hbox = gtk.HBox(spacing=5)
		label = gtk.Label(_('Date Format'))
		label.set_alignment(0, 0.5)
		pack(hbox, label)
		sgroup.add_widget(label)
		#pack(hbox, gtk.Label(''), 1, 1)
		item = ComboEntryTextPrefItem(ud, 'dateFormat', (
			'%Y/%m/%d',
			'%Y-%m-%d',
			'%y/%m/%d',
			'%y-%m-%d',
			'%OY/%Om/%Od',
			'%OY-%Om-%Od',
			'%m/%d',
			'%m/%d/%Y',
		))
		self.gtkPrefItems.append(item)
		pack(hbox, item._widget, 1, 1)
		pack(vbox, hbox)
		###
		hbox = gtk.HBox(spacing=5)
		#pack(hbox, gtk.Label(''), 1, 1)
		label = gtk.Label(_('Digital Clock Format'))
		label.set_alignment(0, 0.5)
		pack(hbox, label)
		sgroup.add_widget(label)
		item = ComboEntryTextPrefItem(ud, 'clockFormat', (
			'%T',
			'%X',
			'%Y/%m/%d - %T',
			'%OY/%Om/%Od - %X',
			'<i>%Y/%m/%d</i> - %T',
			'<b>%T</b>',
			'<b>%X</b>',
			'%H:%M',
			'<b>%H:%M</b>',
			'<span size="smaller">%OY/%Om/%Od</span>,%X'
			'%OY/%Om/%Od,<span color="#ff0000">%X</span>',
			'<span font="bold">%X</span>',
			'%OH:%OM',
			'<b>%OH:%OM</b>',
		))
		self.gtkPrefItems.append(item)
		pack(hbox, item._widget, 1, 1)
		pack(vbox, hbox)
		######
		hbox = gtk.HBox(spacing=5)
		label = gtk.Label(_('Days maximum cache size'))
		label.set_alignment(0, 0.5)
		pack(hbox, label)
		##sgroup.add_widget(label)
		item = SpinPrefItem(ui, 'maxDayCacheSize', 100, 9999, 0)
		self.uiPrefItems.append(item)
		pack(hbox, item._widget)
		pack(vbox, hbox)
		vbox4 = vbox
		########
		hbox = gtk.HBox(spacing=3)
		pack(hbox, gtk.Label(_('First day of week')))
		##item = ComboTextPrefItem( ## FIXME
		self.comboFirstWD = gtk.combo_box_new_text()
		for item in core.weekDayName:
			self.comboFirstWD.append_text(item)
		self.comboFirstWD.append_text(_('Automatic'))
		self.comboFirstWD.connect('changed', self.comboFirstWDChanged)
		pack(hbox, self.comboFirstWD)
		pack(vbox, hbox)
		#########
		hbox0 = gtk.HBox(spacing=0)
		pack(hbox0, gtk.Label(_('Holidays')+'    '))
		item = WeekDayCheckListPrefItem(core, 'holidayWeekDays')
		self.corePrefItems.append(item)
		self.holiWDItem = item ## Holiday Week Days Item
		pack(hbox0, item._widget, 1, 1)
		pack(vbox, hbox0)
		#########
		hbox = gtk.HBox(spacing=3)
		pack(hbox, gtk.Label(_('First week of year containts')))
		combo = gtk.combo_box_new_text()
		texts = [_('First %s of year')%name for name in core.weekDayName]+[_('First day of year')]
		texts[4] += ' (ISO 8601)' ## FIXME
		for text in texts:
			combo.append_text(text)
		#combo.append_text(_('Automatic'))## (as Locale)## FIXME
		pack(hbox, combo)
		pack(hbox, gtk.Label(''), 1, 1)
		pack(vbox, hbox)
		self.comboWeekYear = combo
		#########
		hbox = gtk.HBox(spacing=3)
		item = CheckPrefItem(locale_man, 'enableNumLocale', _('Numbers Localization'))
		self.localePrefItems.append(item)
		pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		pack(vbox, hbox)
		##################################################
		################################
		options = []
		for mod in calTypes:
			for opt in mod.options:
				if opt[0]=='button':
					try:
						optl = ModuleOptionButton(opt[1:])
					except:
						myRaise()
						continue
				else:
					optl = ModuleOptionItem(mod, opt)
				options.append(optl)
				pack(vbox, optl._widget)
		self.moduleOptions = options
		################################ Tab 4 (Plugins) ############################################
		vbox = gtk.VBox()
		vbox.label = _('_Plugins')
		vbox.icon = 'preferences-plugin.png'
		self.prefPages.append(vbox)
		#####
		##pluginsTextStatusIcon:
		hbox = gtk.HBox()
		if statusIconMode==1:
			item = CheckPrefItem(ui, 'pluginsTextStatusIcon', _('Show in applet (for today)'))
		else:
			item = CheckPrefItem(ui, 'pluginsTextStatusIcon', _('Show in Status Icon (for today)'))
		self.uiPrefItems.append(item)
		pack(hbox, item._widget)
		pack(hbox, gtk.Label(''), 1, 1)
		pack(vbox, hbox)
		#####
		treev = gtk.TreeView()
		treev.set_headers_clickable(True)
		trees = gtk.ListStore(int, bool, bool, str)
		treev.set_model(trees)
		treev.enable_model_drag_source(gdk.BUTTON1_MASK, [('row', gtk.TARGET_SAME_WIDGET, 0)], gdk.ACTION_MOVE)
		treev.enable_model_drag_dest([('row', gtk.TARGET_SAME_WIDGET, 0)], gdk.ACTION_MOVE)
		treev.connect('drag_data_received', self.plugTreevDragReceived)
		treev.get_selection().connect('changed', self.plugTreevCursorChanged)
		treev.connect('row-activated', self.plugTreevRActivate)
		treev.connect('button-press-event', self.plugTreevButtonPress)
		###
		#treev.drag_source_set_icon_stock(gtk.STOCK_CLOSE)
		#treev.drag_source_add_text_targets()
		#treev.drag_source_add_uri_targets()
		#treev.drag_source_unset()
		###
		swin = gtk.ScrolledWindow()
		swin.add(treev)
		swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		######
		cell = gtk.CellRendererToggle()
		#cell.set_property('activatable', True)
		cell.connect('toggled', self.plugTreeviewCellToggled)
		col = gtk.TreeViewColumn(_('Enable'), cell)
		col.add_attribute(cell, 'active', 1)
		#cell.set_active(False)
		col.set_resizable(True)
		treev.append_column(col)
		######
		cell = gtk.CellRendererToggle()
		#cell.set_property('activatable', True)
		cell.connect('toggled', self.plugTreeviewCellToggled2)
		col = gtk.TreeViewColumn(_('Show Date'), cell)
		col.add_attribute(cell, 'active', 2)
		#cell.set_active(False)
		col.set_resizable(True)
		treev.append_column(col)
		######
		#cell = gtk.CellRendererText()
		#col = gtk.TreeViewColumn(_('File Name'), cell, text=2)
		#col.set_resizable(True)
		#treev.append_column(col)
		#treev.set_search_column(1)
		######
		cell = gtk.CellRendererText()
		#cell.set_property('wrap-mode', gtk.WRAP_WORD)
		#cell.set_property('editable', True)
		#cell.set_property('wrap-width', 200)
		col = gtk.TreeViewColumn(_('Description'), cell, text=3)
		#treev.connect('expose-event', self.plugTreevExpose)
		#self.plugDescCell = cell
		#self.plugDescCol = col
		#col.set_resizable(True)## No need!
		treev.append_column(col)
		######
		#for i in xrange(len(core.plugIndex)):
		#	x = core.plugIndex[i]
		#	trees.append([x[0], x[1], x[2], core.allPlugList[x[0]].desc])
		######
		self.plugTreeview = treev
		self.plugTreestore = trees
		#######################
		hbox = gtk.HBox()
		vboxPlug = gtk.VBox()
		pack(vboxPlug, swin, 1, 1)
		pack(hbox, vboxPlug, 1, 1)
		###
		hboxBut = gtk.HBox()
		###
		button = gtk.Button(_('_About Plugin'))
		button.set_image(gtk.image_new_from_stock(gtk.STOCK_ABOUT, gtk.ICON_SIZE_BUTTON))
		button.set_sensitive(False)
		button.connect('clicked', self.plugAboutClicked)
		self.plugButtonAbout = button
		pack(hboxBut, button)
		pack(hboxBut, gtk.Label(''), 1, 1)
		###
		button = gtk.Button(_('C_onfigure Plugin'))
		button.set_image(gtk.image_new_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_BUTTON))
		button.set_sensitive(False)
		button.connect('clicked', self.plugConfClicked)
		self.plugButtonConf = button
		pack(hboxBut, button)
		pack(hboxBut, gtk.Label(''), 1, 1)
		###
		pack(vboxPlug, hboxBut)
		###
		toolbar = gtk.Toolbar()
		toolbar.set_orientation(gtk.ORIENTATION_VERTICAL)
		#try:## DeprecationWarning ## FIXME
			#toolbar.set_icon_size(gtk.ICON_SIZE_SMALL_TOOLBAR)
			### no different (argument to set_icon_size does not affect) FIXME
		#except:
		#	pass
		size = gtk.ICON_SIZE_SMALL_TOOLBAR
		##no different(argument2 to image_new_from_stock does not affect) FIXME
		######## gtk.ICON_SIZE_SMALL_TOOLBAR or gtk.ICON_SIZE_MENU
		tb = toolButtonFromStock(gtk.STOCK_GOTO_TOP, size)
		set_tooltip(tb, _('Move to top'))
		tb.connect('clicked', self.plugTreeviewTop)
		toolbar.insert(tb, -1)
		########
		tb = toolButtonFromStock(gtk.STOCK_GO_UP, size)
		set_tooltip(tb, _('Move up'))
		tb.connect('clicked', self.plugTreeviewUp)
		toolbar.insert(tb, -1)
		#########
		tb = toolButtonFromStock(gtk.STOCK_GO_DOWN, size)
		set_tooltip(tb, _('Move down'))
		tb.connect('clicked', self.plugTreeviewDown)
		toolbar.insert(tb, -1)
		########
		tb = toolButtonFromStock(gtk.STOCK_GOTO_BOTTOM, size)
		set_tooltip(tb, _('Move to bottom'))
		tb.connect('clicked', self.plugTreeviewBottom)
		toolbar.insert(tb, -1)
		##########
		tb = toolButtonFromStock(gtk.STOCK_ADD, size)
		set_tooltip(tb, _('Add'))
		#tb.connect('clicked', lambda obj: self.plugAddDialog.run())
		tb.connect('clicked', self.plugAddClicked)
		#if len(self.plugAddItems)==0:
		#	tb.set_sensitive(False)
		toolbar.insert(tb, -1)
		self.plugButtonAdd = tb
		###########
		tb = toolButtonFromStock(gtk.STOCK_DELETE, size)
		set_tooltip(tb, _('Delete'))
		tb.connect('clicked', self.plugTreeviewDel)
		toolbar.insert(tb, -1)
		###########
		pack(hbox, toolbar)
		#####
		'''
		vpan = gtk.VPaned()
		vpan.add1(hbox)
		vbox2 = gtk.VBox()
		pack(vbox2, gtk.Label('Test Label'))
		vpan.add2(vbox2)
		vpan.set_position(100)
		pack(vbox, vpan)
		'''
		pack(vbox, hbox, 1, 1)
		##########################
		d = gtk.Dialog()
		d.set_transient_for(self)
		## dialog.set_transient_for(parent) makes the window on top of parent and at the center point of parent
		## but if you call dialog.show() or dialog.present(), the parent is still active(clickabel widgets) before closing child "dialog"
		## you may call dialog.run() to realy make it transient for parent
		d.set_has_separator(False)
		d.connect('delete-event', self.plugAddDialogClose)
		d.set_title(_('Add Plugin'))
		###
		dialog_add_button(d, gtk.STOCK_CANCEL, _('_Cancel'), 1, self.plugAddDialogClose)
		dialog_add_button(d, gtk.STOCK_OK, _('_OK'), 2, self.plugAddDialogOK)
		###
		treev = gtk.TreeView()
		trees = gtk.ListStore(str)
		treev.set_model(trees)
		#treev.enable_model_drag_source(gdk.BUTTON1_MASK, [('', 0, 0)], gdk.ACTION_MOVE)## FIXME
		#treev.enable_model_drag_dest([('', 0, 0)], gdk.ACTION_MOVE)## FIXME
		treev.connect('drag_data_received', self.plugTreevDragReceived)
		treev.connect('row-activated', self.plugAddTreevRActivate)
		####
		cell = gtk.CellRendererText()
		col = gtk.TreeViewColumn(_('Description'), cell, text=0)
		#col.set_resizable(True)# no need when have only one column!
		treev.append_column(col)
		####
		swin = gtk.ScrolledWindow()
		swin.add(treev)
		swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		pack(d.vbox, swin, 1, 1)
		d.vbox.show_all()
		self.plugAddDialog = d
		self.plugAddTreeview = treev
		self.plugAddTreestore = trees
		#############
		##treev.set_resize_mode(gtk.RESIZE_IMMEDIATE)
		##self.plugAddItems = []
		####################################### Tab 5 (Accounts)
		vbox = gtk.VBox()
		vbox.label = _('Accounts')
		vbox.icon = 'web-settings.png'
		self.prefPages.append(vbox)
		#####
		treev = gtk.TreeView()
		treev.set_headers_clickable(True)
		trees = gtk.ListStore(int, bool, str)## id (hidden), enable, title
		treev.set_model(trees)
		treev.enable_model_drag_source(gdk.BUTTON1_MASK, [('row', gtk.TARGET_SAME_WIDGET, 0)], gdk.ACTION_MOVE)
		treev.enable_model_drag_dest([('row', gtk.TARGET_SAME_WIDGET, 0)], gdk.ACTION_MOVE)
		treev.connect('row-activated', self.accountsTreevRActivate)
		treev.connect('button-press-event', self.accountsTreevButtonPress)
		###
		swin = gtk.ScrolledWindow()
		swin.add(treev)
		swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		######
		cell = gtk.CellRendererToggle()
		#cell.set_property('activatable', True)
		cell.connect('toggled', self.accountsTreeviewCellToggled)
		col = gtk.TreeViewColumn(_('Enable'), cell)
		col.add_attribute(cell, 'active', 1)
		#cell.set_active(False)
		col.set_resizable(True)
		treev.append_column(col)
		######
		cell = gtk.CellRendererText()
		col = gtk.TreeViewColumn(_('Title'), cell, text=2)
		#col.set_resizable(True)## No need!
		treev.append_column(col)
		######
		self.accountsTreeview = treev
		self.accountsTreestore = trees
		#######################
		hbox = gtk.HBox()
		vboxPlug = gtk.VBox()
		pack(vboxPlug, swin, 1, 1)
		pack(hbox, vboxPlug, 1, 1)
		###
		toolbar = gtk.Toolbar()
		toolbar.set_orientation(gtk.ORIENTATION_VERTICAL)
		#try:## DeprecationWarning ## FIXME
			#toolbar.set_icon_size(gtk.ICON_SIZE_SMALL_TOOLBAR)
			### no different (argument to set_icon_size does not affect) FIXME
		#except:
		#	pass
		size = gtk.ICON_SIZE_SMALL_TOOLBAR
		##no different(argument2 to image_new_from_stock does not affect) FIXME
		######## gtk.ICON_SIZE_SMALL_TOOLBAR or gtk.ICON_SIZE_MENU
		tb = toolButtonFromStock(gtk.STOCK_EDIT, size)
		set_tooltip(tb, _('Edit'))
		tb.connect('clicked', self.accountsEditClicked)
		toolbar.insert(tb, -1)
		###########
		tb = toolButtonFromStock(gtk.STOCK_ADD, size)
		set_tooltip(tb, _('Add'))
		tb.connect('clicked', self.accountsAddClicked)
		toolbar.insert(tb, -1)
		###########
		tb = toolButtonFromStock(gtk.STOCK_DELETE, size)
		set_tooltip(tb, _('Delete'))
		tb.connect('clicked', self.accountsDelClicked)
		toolbar.insert(tb, -1)
		##########
		tb = toolButtonFromStock(gtk.STOCK_GO_UP, size)
		set_tooltip(tb, _('Move up'))
		tb.connect('clicked', self.accountsUpClicked)
		toolbar.insert(tb, -1)
		#########
		tb = toolButtonFromStock(gtk.STOCK_GO_DOWN, size)
		set_tooltip(tb, _('Move down'))
		tb.connect('clicked', self.accountsDownClicked)
		toolbar.insert(tb, -1)
		###########
		pack(hbox, toolbar)
		pack(vbox, hbox, 1, 1)
		###################################################################################################
		notebook = gtk.Notebook()
		self.notebook = notebook
		#####################################
		for vbox in self.prefPages:
			l = gtk.Label(vbox.label)
			l.set_use_underline(True)
			vb = gtk.VBox(spacing=3)
			pack(vb, imageFromFile(vbox.icon))
			pack(vb, l)
			vb.show_all()
			notebook.append_page(vbox, vb)
			try:
				notebook.set_tab_reorderable(vbox, True)
			except AttributeError:
				pass
		#######################
		notebook.set_property('homogeneous', True)
		notebook.set_property('tab-border', 5)
		notebook.set_property('tab-hborder', 15)
		pack(self.vbox, notebook)
		self.vbox.show_all()
		for i in ui.prefPagesOrder:
			try:
				j = ui.prefPagesOrder[i]
			except IndexError:
				continue
			notebook.reorder_child(self.prefPages[i], j)