コード例 #1
0
 def addClicked(self, button):
     fcd = gtk.FileChooserDialog(
         buttons=(
             toStr(_('_OK')),
             gtk.RESPONSE_OK,
             toStr(_('_Cancel')),
             gtk.RESPONSE_CANCEL,
         ),
         title=_('Add File'),
     )
     fcd.set_local_only(True)
     fcd.connect('response', lambda w, e: fcd.hide())
     if fcd.run() == gtk.RESPONSE_OK:
         from shutil import copy
         fpath = fcd.get_filename()
         fname = split(fpath)[-1]
         dstDir = self.event.filesDir
         ## os.makedirs(dstDir, exist_ok=True)## only on new pythons FIXME
         try:
             os.makedirs(dstDir)
         except:
             myRaise()
         copy(fpath, join(dstDir, fname))
         self.event.files.append(fname)
         self.newFiles.append(fname)
         self.showFile(fname)
コード例 #2
0
ファイル: ui.py プロジェクト: ErfanBagheri/starcal
def addStartup():
    if osName=='win':
        makeDir(winStartupDir)
        #fname = APP_NAME + ('-qt' if uiName=='qt' else '') + '.pyw'
        fname = core.COMMAND + '.pyw'
        fpath = join(rootDir, fname)
        #open(winStartupFile, 'w').write('execfile(%r, {"__file__":%r})'%(fpath, fpath))
        try:
            winMakeShortcut(fpath, winStartupFile)
        except:
            return False
        else:
            return True
    elif isdir('%s/.config'%homeDir):## osName in ('linux', 'mac') ## maybe Gnome/KDE on Solaris, *BSD, ...
        text = '''[Desktop Entry]
Type=Application
Name=%s %s
Icon=%s
Exec=%s'''%(core.APP_DESC, core.VERSION, APP_NAME, core.COMMAND)## double quotes needed when the exec path has space
        makeDir(comDeskDir)
        try:
            fp = open(comDesk, 'w')
        except:
            core.myRaise(__file__)
            return False
        else:
            fp.write(text)
            return True
    elif osName=='mac':## FIXME
        pass
    return False
コード例 #3
0
ファイル: startup.py プロジェクト: ilius/starcal2
def addStartup():
	if osName=='win':
		from scal2.windows import winMakeShortcut
		makeDir(winStartupDir)
		#fname = APP_NAME + ('-qt' if uiName=='qt' else '') + '.pyw'
		fname = core.COMMAND + '.pyw'
		fpath = join(rootDir, fname)
		#open(winStartupFile, 'w').write('execfile(%r, {"__file__":%r})'%(fpath, fpath))
		try:
			winMakeShortcut(fpath, winStartupFile)
		except:
			return False
		else:
			return True
	elif isdir('%s/.config'%homeDir):## osName in ('linux', 'mac') ## maybe Gnome/KDE on Solaris, *BSD, ...
		text = '''[Desktop Entry]
Type=Application
Name=%s %s
Icon=%s
Exec=%s'''%(core.APP_DESC, core.VERSION, APP_NAME, core.COMMAND)## double quotes needed when the exec path has space
		makeDir(comDeskDir)
		try:
			fp = open(comDesk, 'w')
		except:
			core.myRaise(__file__)
			return False
		else:
			fp.write(text)
			return True
	elif osName=='mac':## FIXME
		pass
	return False
コード例 #4
0
ファイル: main.py プロジェクト: ErfanBagheri/starcal
 def _do_onGroupModify(self, group, groupIter):
     group.afterModify()
     group.save()
     try:
         if group.name == 'universityTerm':## FIXME
             n = self.trees.iter_n_children(groupIter)
             for i in range(n):
                 eventIter = self.trees.iter_nth_child(groupIter, i)
                 eid = self.trees.get(eventIter, 0)[0]
                 self.trees.set(eventIter, 2, group[eid].summary)
     except:
         myRaise()
コード例 #5
0
ファイル: customize.py プロジェクト: seacgroup/starcal
 def treevCursorChanged(self, treev):
     if self.activeOptionsWidget:
         try:
             self.vbox_l.remove(self.activeOptionsWidget)
         except:
             myRaise(__file__)
         self.activeOptionsWidget = None
     index_list = treev.get_cursor()[0]
     if not index_list:
         return
     item = self.getItemByPath(index_list)
     if item.optionsWidget:
         self.activeOptionsWidget = item.optionsWidget
         self.vbox_l.pack_start(item.optionsWidget, 0, 0)
         item.optionsWidget.show()
コード例 #6
0
ファイル: ui.py プロジェクト: Noori/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)
コード例 #7
0
 def trayClicked(self, toggle):
     ##print tuple(self.menu.allocation)
     if toggle.get_active():
         if ui.winX, ui.winY == (-1, -1):
             try:
                 x0, y0 = self.applet.window.get_origin()
                 ui.winX = x0 + (self.applet.allocation.width-ui.winWidth)/2
                 ui.winY = y0 + self.applet.allocation.height - 3
             except:
                 core.myRaise(__file__)
         self.move(ui.winX, ui.winY)
         ## every calling of .hide() and .present(), makes dialog not on top (forgets being on top)
         act = self.checkAbove.get_active()
         self.set_keep_above(act)
         if self.checkSticky.get_active():
             self.stick()
         self.deiconify()
         self.present()
コード例 #8
0
 def statusIconClicked(self, toggle):
     if toggle.get_active():
         if (ui.winX, ui.winY) == (-1, -1):
             try:
                 x0, y0 = self.applet.get_window().get_origin()
                 width, height = self.applet.size_request()
                 ui.winX = x0 + (width - ui.winWidth) / 2
                 ui.winY = y0 + height - 3
             except:
                 core.myRaise(__file__)
         self.move(ui.winX, ui.winY)
         ## every calling of .hide() and .present(), makes dialog not on top (forgets being on top)
         act = self.checkAbove.get_active()
         self.set_keep_above(act)
         if self.checkSticky.get_active():
             self.stick()
         self.deiconify()
         self.present()
     else:
         ui.winX, ui.winY = self.get_position()
         self.hide()
コード例 #9
0
ファイル: common.py プロジェクト: ErfanBagheri/starcal
 def addClicked(self, button):
     fcd = gtk.FileChooserDialog(
         buttons=(
             toStr(_('_OK')), gtk.RESPONSE_OK,
             toStr(_('_Cancel')), gtk.RESPONSE_CANCEL,
         ),
         title=_('Add File'),
     )
     fcd.connect('response', lambda w, e: fcd.hide())
     if fcd.run() == gtk.RESPONSE_OK:
         fpath = fcd.get_filename()
         fname = split(fpath)[-1]
         dstDir = self.event.filesDir
         ## os.makedirs(dstDir, exist_ok=True)## only on new pythons FIXME
         try:
             os.makedirs(dstDir)
         except:
             myRaise()
         shutil.copy(fpath, join(dstDir, fname))
         self.event.files.append(fname)
         self.newFiles.append(fname)
         self.showFile(fname)
コード例 #10
0
ファイル: weekcal.py プロジェクト: Noori/starcal
 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)
コード例 #11
0
ファイル: preferences.py プロジェクト: ilius/starcal2
	def apply(self, widget=None):
		from scal2.ui_gtk.font_utils import gfontDecode
		####### FIXME
		#print('fontDefault = %s'%ui.fontDefault)
		ui.fontDefault = gfontDecode(ud.settings.get_property('gtk-font-name'))
		#print('fontDefault = %s'%ui.fontDefault)
		############################################## Updating pref variables
		for opt in self.getAllPrefItems():
			opt.updateVar()
		###### DB Manager (Plugin Manager)
		index = []
		for row in self.plugTreestore:
			plugI = row[0]
			enable = row[1]
			show_date = row[2]
			index.append(plugI)
			plug = core.allPlugList[plugI]
			if plug.loaded:
				try:
					plug.enable = enable
					plug.show_date = show_date
				except:
					core.myRaise(__file__)
					print(i, core.plugIndex)
			else:
				if enable:
					plug = plugin_man.loadPlugin(plug.path)
					assert plug.loaded
					core.allPlugList[plugI] = plug
		core.plugIndex = index
		core.updatePlugins()
		######
		first = self.comboFirstWD.get_active()
		if first==7:
			core.firstWeekDayAuto = True
			try:
				core.firstWeekDay = core.getLocaleFirstWeekDay()
			except:
				pass
		else:
			core.firstWeekDayAuto = False
			core.firstWeekDay = first
		######
		mode = self.comboWeekYear.get_active()
		if mode==8:
			core.weekNumberModeAuto = True
			core.weekNumberMode = core.getLocaleweekNumberMode()
		else:
			core.weekNumberModeAuto = False
			core.weekNumberMode = mode
		######
		ui.cellCache.clear() ## Very important, specially when calTypes.primary will be changed
		######
		ud.updateFormatsBin()
		#################################################### Saving Preferences
		for mod in calTypes:
			mod.save()
		##################### Saving locale config
		text = ''
		for item in self.localePrefItems:
			text += item.confStr()
		open(locale_man.localeConfPath, 'w').write(text)
		##################### Saving core config
		text = ''
		text += 'version=%r\n\n'%core.VERSION
		text += 'allPlugList=%s\n\n'%core.getAllPlugListRepr()
		text += 'plugIndex=%r\n'%core.plugIndex
		for item in self.corePrefItems:
			text += item.confStr()
		for key in (
			'firstWeekDayAuto',
			'firstWeekDay',
			'weekNumberModeAuto',
			'weekNumberMode',
			'debugMode',
		):
			value = eval('core.'+key)
			text += '%s=%r\n'%(key, value)
		open(core.confPath, 'w').write(text)
		##################### Saving ui config
		text = ''
		for item in self.uiPrefItems:
			text += item.confStr()
		for key in (
			#'localTzHist',## FIXME
			'showYmArrows',
		):
			value = eval('ui.'+key)
			text += '%s=%r\n'%(key, value)
		text += 'prefPagesOrder=%s\n'%repr(
			tuple(
				[self.notebook.page_num(page) for page in self.prefPages]
			)
		)
		open(ui.confPath, 'w').write(text)
		##################### Saving here config
		text = ''
		for item in self.gtkPrefItems:
			text += item.confStr()
		text += 'adjustTimeCmd=%r\n'%ud.adjustTimeCmd ## FIXME
		open(ud.confPath, 'w').write(text)
		################################################### Updating GUI
		ud.windowList.onConfigChange()
		if ui.mainWin:
			"""
			if ui.bgUseDesk and ui.bgColor[3]==255:
				msg = gtk.MessageDialog(buttons=gtk.BUTTONS_OK_CANCEL, message_format=_(
				'If you want to have a transparent calendar (and see your desktop),'+\
				'change the opacity of calendar background color!'))
				if msg.run()==gtk.RESPONSE_OK:
					self.colorbBg.emit('clicked')
				msg.destroy()
			"""
			if ui.checkNeedRestart():
				d = gtk.Dialog(_('Need Restart '+core.APP_DESC), self,
					gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR,
					(gtk.STOCK_CANCEL, 0))
				d.set_keep_above(True)
				label = gtk.Label(_('Some preferences need for restart %s to apply.'%core.APP_DESC))
				label.set_line_wrap(True)
				pack(d.vbox, label)
				resBut = d.add_button(_('_Restart'), 1)
				resBut.set_image(gtk.image_new_from_stock(gtk.STOCK_REFRESH,gtk.ICON_SIZE_BUTTON))
				resBut.grab_default()
				d.vbox.show_all()
				if d.run()==1:
					core.restart()
				else:
					d.destroy()
コード例 #12
0
ファイル: preferences.py プロジェクト: ErfanBagheri/starcal
 def apply(self, widget=None):
     ####### ?????????????????
     #print 'fontDefault =', ui.fontDefault
     ui.fontDefault = gfontDecode(ud.settings.get_property('gtk-font-name'))
     #print 'fontDefault =', ui.fontDefault
     ############################################## Updating pref variables
     for opt in self.getAllPrefItems():
         opt.updateVar()
     ###### DB Manager (Plugin Manager)
     index = []
     for row in self.plugTreestore:
         index.append(row[0])
         plug = core.allPlugList[row[0]]
         try:
             plug.enable = row[1]
             plug.show_date = row[2]
         except:
             core.myRaise(__file__)
             print i, core.plugIndex
     core.plugIndex = index
     ######
     first = self.comboFirstWD.get_active()
     if first==7:
         core.firstWeekDayAuto = True
         try:
             core.firstWeekDay = core.getLocaleFirstWeekDay()
         except:
             pass
     else:
         core.firstWeekDayAuto = False
         core.firstWeekDay = first
     ######
     mode = self.comboWeekYear.get_active()
     if mode==8:
         core.weekNumberModeAuto = True
         core.weekNumberMode = core.getLocaleweekNumberMode()
     else:
         core.weekNumberModeAuto = False
         core.weekNumberMode = mode
     ######
     ui.cellCache.clear() ## Very important, specially when core.primaryMode will be changed
     ######
     ud.updateFormatsBin()
     #################################################### Saving Preferences
     for mod in calTypes:
         mod.save()
     ##################### Saving locale config
     text = ''
     for item in self.localePrefItems:
         text += item.confStr()
     open(locale_man.localeConfPath, 'w').write(text)
     ##################### Saving core config
     text = ''
     text += 'allPlugList=%s\n\n'%core.getAllPlugListRepr()
     text += 'plugIndex=%r\n'%core.plugIndex
     for item in self.corePrefItems:
         text += item.confStr()
     for key in (
         'firstWeekDayAuto',
         'firstWeekDay',
         'weekNumberModeAuto',
         'weekNumberMode',
         'debugMode',
     ):
         value = eval('core.'+key)
         text += '%s=%r\n'%(key, value)
     open(core.confPath, 'w').write(text)
     ##################### Saving ui config
     text = ''
     for item in self.uiPrefItems:
         text += item.confStr()
     text += 'showYmArrows=%r\n'%ui.showYmArrows
     text += 'prefPagesOrder=%s'%repr(tuple(
         [self.notebook.page_num(page) for page in self.prefPages]))
     open(ui.confPath, 'w').write(text)
     ##################### Saving here config
     text = ''
     for item in self.gtkPrefItems:
         text += item.confStr()
     text += 'adjustTimeCmd=%r\n'%ud.adjustTimeCmd ## FIXME
     open(ud.confPath, 'w').write(text)
     ################################################### Updating GUI
     ud.windowList.onConfigChange()
     if ui.mainWin:
         """
         if ui.bgUseDesk and ui.bgColor[3]==255:
             msg = gtk.MessageDialog(buttons=gtk.BUTTONS_OK_CANCEL, message_format=_(
             'If you want to have a transparent calendar (and see your desktop),'+\
             'change the opacity of calendar background color!'))
             if msg.run()==gtk.RESPONSE_OK:
                 self.colorbBg.emit('clicked')
             msg.destroy()
         """
         if ui.checkNeedRestart():
             d = gtk.Dialog(_('Need Restart '+APP_DESC), self,
                 gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR,
                 (gtk.STOCK_CANCEL, 0))
             d.set_keep_above(True)
             label = gtk.Label(_('Some preferences need for restart %s to apply.'%APP_DESC))
             label.set_line_wrap(True)
             d.vbox.pack_start(label)
             resBut = d.add_button(_('_Restart'), 1)
             resBut.set_image(gtk.image_new_from_stock(gtk.STOCK_REFRESH,gtk.ICON_SIZE_BUTTON))
             resBut.grab_default()
             d.vbox.show_all()
             if d.run()==1:
                 core.restart()
             else:
                 d.destroy()
コード例 #13
0
ファイル: preferences.py プロジェクト: ErfanBagheri/starcal
 def __init__(self, trayMode):
     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)
     hbox.pack_start(gtk.Label(_('Language')), 0, 0)
     itemLang = LangPrefItem()
     self.localePrefItems.append(itemLang)
     ###
     hbox.pack_start(itemLang.widget, 0, 0)
     if langSh!='en':
         hbox.pack_start(gtk.Label('Language'), 0, 0)
     vbox.pack_start(hbox, 0, 0)
     ##########################
     hbox = gtk.HBox()
     frame = gtk.Frame(_('Calendar Types'))
     itemCals = AICalsPrefItem()
     self.corePrefItems.append(itemCals)
     frame.add(itemCals.widget)
     hbox.pack_start(frame, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     hbox.set_border_width(5)
     #frame.set_border_width(5)
     vbox.pack_start(hbox, 1, 1)
     ##########################
     if trayMode!=1:
         hbox = gtk.HBox(spacing=3)
         item = CheckStartupPrefItem()
         self.uiPrefItems.append(item)
         hbox.pack_start(item.widget, 1, 1)
         vbox.pack_start(hbox, 0, 0)
         ########################
         item = CheckPrefItem(ui, 'showMain', _('Show main window on start'))
         self.uiPrefItems.append(item)
         vbox.pack_start(item.widget, 0, 0)
     ##########################
     item = CheckPrefItem(ui, 'winTaskbar', _('Window in Taskbar'))
     self.uiPrefItems.append(item)
     hbox = gtk.HBox(spacing=3)
     hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     ###########
     vbox.pack_start(hbox, 0, 0)
     ##########################
     try:
         import appindicator
     except ImportError:
         pass
     else:
         item = CheckPrefItem(ui, 'useAppIndicator', _('Use AppIndicator'))
         self.uiPrefItems.append(item)
         hbox = gtk.HBox(spacing=3)
         hbox.pack_start(item.widget, 0, 0)
         hbox.pack_start(gtk.Label(''), 1, 1)
         vbox.pack_start(hbox, 0, 0)
     ##########################
     hbox = gtk.HBox(spacing=3)
     hbox.pack_start(gtk.Label(_('Show Digital Clock:')), 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     #item = CheckPrefItem(ui, 'showDigClockTb', _('On Toolbar'))## FIXME
     #self.uiPrefItems.append(item)
     #hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     if trayMode==1:
         item = CheckPrefItem(ui, 'showDigClockTr', _('On Applet'), 'Panel Applet')
     else:
         item = CheckPrefItem(ui, 'showDigClockTr', _('On Tray'), 'Notification Area')
     self.uiPrefItems.append(item)
     hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     vbox.pack_start(hbox, 0, 0)
     ################################ Tab 2 (Appearance) ###########################################
     vbox = gtk.VBox()
     vbox.label = _('A_ppearance')
     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)
     hbox.pack_start(customCheckItem.widget, 0, 0)
     ###
     customItem = FontPrefItem(ui, 'fontCustom', self)
     self.uiPrefItems.append(customItem)
     hbox.pack_start(customItem.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     customItem.widget.set_sensitive(ui.fontCustomEnable)
     #customItem.widget.connect('clicked', self.checkbFontClicked)
     customCheckItem.widget.connect('clicked', lambda w: customItem.widget.set_sensitive(w.get_active()))## FIXME
     vbox.pack_start(hbox, 0, 0)
     ########################### Theme #####################
     hbox = gtk.HBox(spacing=3)
     item = CheckPrefItem(ui, 'bgUseDesk', _('Use Desktop Background'))
     self.uiPrefItems.append(item)
     hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     vbox.pack_start(hbox, 0, 0)
     #####################
     hbox = gtk.HBox(spacing=3)
     lab = gtk.Label('<b>%s:</b> '%_('Colors'))
     lab.set_use_markup(True)
     hbox.pack_start(lab, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     ###
     hbox.pack_start(gtk.Label(_('Background')), 0, 0)
     item = ColorPrefItem(ui, 'bgColor', True)
     self.uiPrefItems.append(item)
     self.colorbBg = item.widget ## FIXME
     hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     ###
     hbox.pack_start(gtk.Label(_('Border')), 0, 0)
     item = ColorPrefItem(ui, 'borderColor', True)
     self.uiPrefItems.append(item)
     hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     ###
     hbox.pack_start(gtk.Label(_('Cursor')), 0, 0)
     item = ColorPrefItem(ui, 'cursorOutColor', False)
     self.uiPrefItems.append(item)
     hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     ###
     hbox.pack_start(gtk.Label(_('Cursor BG')), 0, 0)
     item = ColorPrefItem(ui, 'cursorBgColor', True)
     self.uiPrefItems.append(item)
     hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     ###
     hbox.pack_start(gtk.Label(_('Today')), 0, 0)
     item = ColorPrefItem(ui, 'todayCellColor', True)
     self.uiPrefItems.append(item)
     hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     ###
     vbox.pack_start(hbox, 0, 0)
     ####################
     hbox = gtk.HBox(spacing=3)
     lab = gtk.Label('<b>%s:</b> '%_('Font Colors'))
     lab.set_use_markup(True)
     hbox.pack_start(lab, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     ####
     hbox.pack_start(gtk.Label(_('Normal')), 0, 0)
     item = ColorPrefItem(ui, 'textColor', False)
     self.uiPrefItems.append(item)
     hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     ###
     hbox.pack_start(gtk.Label(_('Holiday')), 0, 0)
     item = ColorPrefItem(ui, 'holidayColor', False)
     self.uiPrefItems.append(item)
     hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     ###
     hbox.pack_start(gtk.Label(_('Inactive Day')), 0, 0)
     item = ColorPrefItem(ui, 'inactiveColor', True)
     self.uiPrefItems.append(item)
     hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     ####
     hbox.pack_start(gtk.Label(_('Border')), 0, 0)
     item = ColorPrefItem(ui, 'borderTextColor', False)
     self.uiPrefItems.append(item)
     hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     ####
     vbox.pack_start(hbox, 0, 0)
     ###################
     hbox = gtk.HBox(spacing=1)
     label = gtk.Label('<b>%s</b>:'%_('Cursor'))
     label.set_use_markup(True)
     hbox.pack_start(label, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     hbox.pack_start(gtk.Label(_('Diameter Factor')), 0, 0)
     item = SpinPrefItem(ui, 'cursorDiaFactor', 0, 1, 2)
     self.uiPrefItems.append(item)
     hbox.pack_start(item.widget, 0, 0)
     ###
     hbox.pack_start(gtk.Label(''), 1, 1)
     hbox.pack_start(gtk.Label(_('Rounding Factor')), 0, 0)
     item = SpinPrefItem(ui, 'cursorRoundingFactor', 0, 1, 2)
     self.uiPrefItems.append(item)
     hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     ###
     vbox.pack_start(hbox, 0, 0)
     ################################ 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)
     hbox.pack_start(label, 0, 0)
     sgroup.add_widget(label)
     #hbox.pack_start(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)
     hbox.pack_start(item.widget, 1, 1)
     vbox.pack_start(hbox, 0, 0)
     ###
     hbox = gtk.HBox(spacing=5)
     #hbox.pack_start(gtk.Label(''), 1, 1)
     label = gtk.Label(_('Digital Clock Format'))
     label.set_alignment(0, 0.5)
     hbox.pack_start(label, 0, 0)
     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)
     hbox.pack_start(item.widget, 1, 1)
     vbox.pack_start(hbox, 0, 0)
     ######
     hbox = gtk.HBox(spacing=5)
     label = gtk.Label(_('Days maximum cache size'))
     label.set_alignment(0, 0.5)
     hbox.pack_start(label, 0, 0)
     ##sgroup.add_widget(label)
     item = SpinPrefItem(ui, 'maxDayCacheSize', 100, 9999, 0)
     self.uiPrefItems.append(item)
     hbox.pack_start(item.widget, 0, 0)
     vbox.pack_start(hbox, 0, 0)
     vbox4 = vbox
     ########
     hbox = gtk.HBox(spacing=3)
     hbox.pack_start(gtk.Label(_('First day of week')), 0, 0)
     ##item = ComboTextPrefItem( ##?????????
     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)
     hbox.pack_start(self.comboFirstWD, 0, 0)
     vbox.pack_start(hbox, 0, 0)
     #########
     hbox0 = gtk.HBox(spacing=0)
     hbox0.pack_start(gtk.Label(_('Holidays')+'    '), 0, 0)
     item = WeekDayCheckListPrefItem(core, 'holidayWeekDays')
     self.corePrefItems.append(item)
     self.holiWDItem = item ## Holiday Week Days Item
     hbox0.pack_start(item.widget, 1, 1)
     vbox.pack_start(hbox0, 0, 0)
     #########
     hbox = gtk.HBox(spacing=3)
     hbox.pack_start(gtk.Label(_('First week of year containts')), 0, 0)
     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)' ##??????
     for text in texts:
         combo.append_text(text)
     #combo.append_text(_('Automatic'))## (as Locale)#?????????????????
     hbox.pack_start(combo, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     vbox.pack_start(hbox, 0, 0)
     self.comboWeekYear = combo
     #########
     hbox = gtk.HBox(spacing=3)
     item = CheckPrefItem(locale_man, 'enableNumLocale', _('Numbers Localization'))
     self.localePrefItems.append(item)
     hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     vbox.pack_start(hbox, 0, 0)
     ##################################################
     ################################
     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)
             vbox.pack_start(optl.widget, 0, 0)
     self.moduleOptions = options
     ################################ Tab 4 (Plugins) ############################################
     vbox = gtk.VBox()
     vbox.label = _('_Plugins')
     vbox.icon = 'preferences-plugin.png'
     self.prefPages.append(vbox)
     #####
     ##pluginsTextTray:
     hbox = gtk.HBox()
     if trayMode==1:
         item = CheckPrefItem(ui, 'pluginsTextTray', _('Show in applet (for today)'))
     else:
         item = CheckPrefItem(ui, 'pluginsTextTray', _('Show in tray (for today)'))
     self.uiPrefItems.append(item)
     hbox.pack_start(item.widget, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     vbox.pack_start(hbox, 0, 0)
     #####
     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.connect('cursor-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()
     vboxPlug.pack_start(swin, 1, 1)
     hbox.pack_start(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
     hboxBut.pack_start(button, 0, 0)
     hboxBut.pack_start(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
     hboxBut.pack_start(button, 0, 0)
     hboxBut.pack_start(gtk.Label(''), 1, 1)
     ###
     vboxPlug.pack_start(hboxBut, 0, 0)
     ###
     toolbar = gtk.Toolbar()
     toolbar.set_orientation(gtk.ORIENTATION_VERTICAL)
     #try:## DeprecationWarning #?????????????
         #toolbar.set_icon_size(gtk.ICON_SIZE_SMALL_TOOLBAR)
         ### no different (argument to set_icon_size does not affect) ?????????
     #except:
     #    pass
     size = gtk.ICON_SIZE_SMALL_TOOLBAR
     ##no different(argument2 to image_new_from_stock does not affect) ?????????
     ######## 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)
     ###########
     hbox.pack_start(toolbar, 0, 0)
     #####
     '''
     vpan = gtk.VPaned()
     vpan.add1(hbox)
     vbox2 = gtk.VBox()
     vbox2.pack_start(gtk.Label('Test Label'))
     vpan.add2(vbox2)
     vpan.set_position(100)
     vbox.pack_start(vpan)
     '''
     vbox.pack_start(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)#?????
     #treev.enable_model_drag_dest([('', 0, 0)], gdk.ACTION_MOVE)#?????
     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)
     d.vbox.pack_start(swin)
     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()
     vboxPlug.pack_start(swin, 1, 1)
     hbox.pack_start(vboxPlug, 1, 1)
     ###
     toolbar = gtk.Toolbar()
     toolbar.set_orientation(gtk.ORIENTATION_VERTICAL)
     #try:## DeprecationWarning #?????????????
         #toolbar.set_icon_size(gtk.ICON_SIZE_SMALL_TOOLBAR)
         ### no different (argument to set_icon_size does not affect) ?????????
     #except:
     #    pass
     size = gtk.ICON_SIZE_SMALL_TOOLBAR
     ##no different(argument2 to image_new_from_stock does not affect) ?????????
     ######## 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)
     ###########
     hbox.pack_start(toolbar, 0, 0)
     vbox.pack_start(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)
         vb.pack_start(imageFromFile(vbox.icon))
         vb.pack_start(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)
     self.vbox.pack_start(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)
コード例 #14
0
ファイル: ui.py プロジェクト: ErfanBagheri/starcal
saveLiveConfDelay = 0.5 ## seconds
timeout_initial = 200
timeout_repeat = 50


def updateFocusTime(*args):
    global focusTime
    focusTime = time()


sysConfPath = join(sysConfDir, 'ui.conf') ## also includes LIVE config
if os.path.isfile(sysConfPath):
    try:
        exec(open(sysConfPath).read())
    except:
        myRaise(__file__)

confPath = join(confDir, 'ui.conf')
if os.path.isfile(confPath):
    try:
        exec(open(confPath).read())
    except:
        myRaise(__file__)

confPathLive = join(confDir, 'ui-live.conf')
if os.path.isfile(confPathLive):
    try:
        exec(open(confPathLive).read())
    except:
        myRaise(__file__)
################################
コード例 #15
0
ファイル: monthcal.py プロジェクト: karoon/starcal2
 def drawAll(self, widget=None, event=None, cr=None, cursor=True):
     #?????? Must enhance (only draw few cells, not all cells)
     #print time(), 'drawAll'#, tuple(event.area), tuple(self.allocation)
     if event:
         (xu, yu, wu, hu) = tuple(event.area)
         #print 'expose-event area:', xu, yu, wu, hu
     self.calcCoord()
     x, y, w, h = self.allocation
     if not cr:
         cr = self.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:
             (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 ##??????????????????
                 #self.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 xrange(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 xrange(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
     shown = self.shownCals
     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 xrange(6):
         for xPos in xrange(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.getEventIcons()
                 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,
             #)
             if shown[0]['enable']:
                 mode = shown[0]['mode']
                 daynum = newTextLayout(self, _(c.dates[mode][2], mode), shown[0]['font'])
                 (fontw, fonth) = daynum.get_pixel_size()
                 if cellInactive:
                     setColor(cr, ui.inactiveColor)
                 elif c.holiday:
                     setColor(cr, ui.holidayColor)
                 else:
                     setColor(cr, shown[0]['color'])
                 cr.move_to(
                     x0 - fontw/2.0 + shown[0]['x'],
                     y0 - fonth/2.0 + shown[0]['y'],
                 )
                 cr.show_layout(daynum)
             if not cellInactive:
                 for item in shown[1:]:
                     if item['enable']:
                         mode = item['mode']
                         daynum = newTextLayout(self, _(c.dates[mode][2], mode), item['font'])
                         (fontw, fonth) = daynum.get_pixel_size()
                         setColor(cr, item['color'])
                         cr.move_to(
                             x0 - fontw/2.0 + item['x'],
                             y0 - fonth/2.0 + item['y'],
                         )
                         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.gridColor)
         for i in xrange(7):
             cr.rectangle(self.cx[i]+rtlSgn()*self.dx/2.0, 0, 1, h)
             cr.fill()
         for i in xrange(6):
             cr.rectangle(0, self.cy[i]-self.dy/2.0, w, 1)
             cr.fill()
     return False
コード例 #16
0
ファイル: main.py プロジェクト: Noori/starcal
        widget.updateWidget()## FIXME
        return widget
    else:
        return None


##############################################################################

modPrefix = 'scal2.ui_gtk.event.'

for cls in event_lib.classes.event:
    try:
        module = __import__(modPrefix + cls.name, fromlist=['EventWidget'])
        cls.WidgetClass = module.EventWidget
    except:
        myRaise()

for cls in event_lib.classes.rule:
    try:
        module = __import__(modPrefix + 'rules.' + cls.name, fromlist=['RuleWidget'])
    except:
        #if not cls.name.startswith('ex_'):
        myRaise()
        continue
    try:
        cls.WidgetClass = module.RuleWidget
    except AttributeError:
        print('no class RuleWidget defined in module "%s"'%cls.name)

for cls in event_lib.classes.notifier:
    try: