예제 #1
0
 def statusIconUpdate(self, gdate=None, checkStatusIconMode=True):
     if checkStatusIconMode and self.statusIconMode < 1:
         return
     if gdate is None:
         gdate = localtime()[:3]
     if calTypes.primary==core.DATE_GREG:
         ddate = gdate
     else:
         ddate = core.convert(gdate[0], gdate[1], gdate[2], core.DATE_GREG, calTypes.primary)
     #######
     self.sicon.set_from_file(join(pixDir, 'starcal2-24.png'))
     self.statusIconUpdateIcon(ddate)
     #######
     set_tooltip(self.sicon, self.getStatusIconTooltip())
     return True
예제 #2
0
 def trayUpdate(self, gdate=None, checkTrayMode=True):
     if checkTrayMode and self.trayMode < 1:
         return
     if gdate is None:
         gdate = localtime()[:3]
     if core.primaryMode==core.DATE_GREG:
         ddate = gdate
     else:
         ddate = core.convert(gdate[0], gdate[1], gdate[2], core.DATE_GREG, core.primaryMode)
     imagePath = ui.trayImageHoli if ui.todayCell.holiday else ui.trayImage
     ######################################
     '''
     import Image, ImageDraw, ImageFont
     im = Image.open(imagePath)
     w, h = im.size
     draw = ImageDraw.Draw(im)
     text = _(ddate[2]).decode('utf8')
     font = ImageFont.truetype('/usr/share/fonts/TTF/DejaVuSans.ttf', 15)
     fw, fh = font.getsize(text)
     draw.text(
         ((w-fw)/2, (h-fh)/2),
         text,
         font=font,
         fill=ui.trayTextColor,
     )
     self.sicon.set_from_pixbuf(gdk.pixbuf_new_from_data(im.tostring(), gdk.COLORSPACE_RGB, True, 8, w, h, 4*w))
     '''
     try:
         pixbuf = gdk.pixbuf_new_from_file(imagePath)
     except:
         pixbuf = gdk.pixbuf_new_from_file(join(pixDir, 'tray-blue.png'))
     ##pixbuf.scale() #????????????
     ###################### PUTTING A TEXT ON A PIXBUF
     pmap = pixbuf.render_pixmap_and_mask(alpha_threshold=127)[0] ## pixmap is also a drawable
     textLay = newTextLayout(self, _(ddate[2]), ui.trayFont)
     w, h = textLay.get_pixel_size()
     s = ui.traySize
     if ui.trayY0 == None:
         y = s/4+int((0.9*s-h)/2)
     else:
         y = ui.trayY0
     pmap.draw_layout(pmap.new_gc(), (s-w)/2, y, textLay, gdk.Color(*ui.trayTextColor))## , foreground, background)
     self.trayPix.get_from_drawable(pmap, self.get_screen().get_system_colormap(), 0, 0, 0, 0, s, s)
     ######################################
     self.sicon.set_from_pixbuf(self.trayPix)
     ######################################
     set_tooltip(self.sicon, self.getTrayTooltip())
     return True
예제 #3
0
파일: starcal2.py 프로젝트: ilius/starcal2
 def statusIconUpdate(self, gdate=None, checkStatusIconMode=True):
     if checkStatusIconMode and self.statusIconMode < 1:
         return
     if gdate is None:
         gdate = localtime()[:3]
     if calTypes.primary == core.DATE_GREG:
         ddate = gdate
     else:
         ddate = core.convert(gdate[0], gdate[1], gdate[2], core.DATE_GREG,
                              calTypes.primary)
     #######
     self.sicon.set_from_file(join(pixDir, 'starcal2-24.png'))
     self.statusIconUpdateIcon(ddate)
     #######
     set_tooltip(self.sicon, self.getStatusIconTooltip())
     return True
예제 #4
0
파일: yearly.py 프로젝트: karoon/starcal2
 def modeComboChanged(self, obj=None):  ## overwrite method from common.EventWidget
     newMode = self.modeCombo.get_active()
     module = core.modules[newMode]
     monthCombo = self.monthCombo
     active = monthCombo.get_active()
     for i in range(len(monthCombo.get_model())):
         monthCombo.remove_text(0)
     for i in range(12):
         monthCombo.append_text(_(module.getMonthName(i + 1)))
     # monthCombo.set_active(active)
     y2, m2, d2 = convert(
         int(self.startYearSpin.get_value()), active + 1, int(self.daySpin.get_value()), self.event.mode, newMode
     )
     self.startYearSpin.set_value(y2)
     monthCombo.set_active(m2 - 1)
     self.daySpin.set_value(d2)
     self.event.mode = newMode
예제 #5
0
 def modeComboChanged(self, obj=None):## overwrite method from common.EventWidget
     newMode = self.modeCombo.get_active()
     module = calTypes[newMode]
     monthCombo = self.monthCombo
     month = monthCombo.getValue()
     monthCombo.build(newMode)
     y2, m2, d2 = convert(
         int(self.startYearSpin.get_value()),
         month,
         int(self.daySpin.get_value()),
         self.event.mode,
         newMode,
     )
     self.startYearSpin.set_value(y2)
     monthCombo.setValue(m2)
     self.daySpin.set_value(d2)
     self.event.mode = newMode
예제 #6
0
 def ok(self):
     mode = self.comboMode.currentIndex()
     if mode==None:
         return
     get = self.get()
     if get==None:
         return
     y0, m0, d0 = get
     if mode==core.primaryMode:
         y, m, d = (y0, m0, d0)
     else:
         y, m, d = convert(y0, m0, d0, mode, core.primaryMode)
     if not core.validDate(mode, y, m, d):
         print 'bad date: %s'%dateStr(mode, y, m, d)
         return
     self.emit(qc.SIGNAL('response-date'), y, m, d)
     self.hide()
예제 #7
0
 def dragRec(self, obj, context, x, y, selection, target_id, etime):
     text = selection.get_text()
     if text==None:
         return
     date = ui.parseDroppedDate(text)
     if date==None:
         print 'selectDateDialog: dropped text "%s"'%text
         return
     print 'selectDateDialog: dropped date: %d/%d/%d'%date
     mode = self.comboMode.currentIndex()
     if mode!=ui.dragGetMode:
         date = convert(date[0], date[1], date[2], ui.dragGetMode, mode)
     y, m, d = date
     self.spinY.setValue(y)
     self.comboMonth.setCurrentIndex(m-1)
     self.spinD.setValue(d)
     self.dateInput.setDate(y, m, d)
     #self.dateInput.addHistory()
     return True
예제 #8
0
 def comboModeChanged(self, mode):
     #print 'comboModeChanged, index="%s"'%index
     pMode = self.mode
     pDate = self.get()
     module = core.modules[mode]
     if pDate==None:
         y, m, d = ui.cell.dates[mode]
     else:
         y0, m0, d0 = pDate
         y, m, d = convert(y0, m0, d0, pMode, mode)
     combo = self.comboMonth
     self.disconnect(combo, qc.SIGNAL('currentIndexChanged(int)'), self.comboMonthChanged)
     combo.clear()
     for i in xrange(12):
         combo.addItem(_(module.getMonthName(i+1, y)))
     self.connect(combo, qc.SIGNAL('currentIndexChanged(int)'), self.comboMonthChanged)
     self.spinD.setRange(1, module.maxMonthLen)
     self.dateInput.maxs = (9999, 12, module.maxMonthLen)
     self.set(y, m, d)
     self.mode = mode
예제 #9
0
파일: dateTime.py 프로젝트: karoon/starcal2
 def changeMode(self, mode):
     curMode = self.rule.getMode()
     if mode!=curMode:
         (y, m, d) = self.dateInput.get_value()
         self.dateInput.set_value(core.convert(y, m, d, curMode, mode))
예제 #10
0
파일: date.py 프로젝트: Noori/starcal
 def changeMode(self, mode):
     curMode = self.rule.getMode()
     if mode!=curMode:
         y, m, d = self.get_value()
         self.set_value(core.convert(y, m, d, curMode, mode))