示例#1
0
 def __init__(self, parent=None):
     qt.QWidget.__init__(self, parent)
     #####################
     hbox = HBox()
     spin = qt.QSpinBox()
     spin.setRange(1, 999)
     spin.setSingleStep(1)
     spin.setLayoutDirection(qc.Qt.LeftToRight)
     spin.setValue(ui.mcalHeight)
     self.connect(spin, qc.SIGNAL('valueChanged (int)'), self.heightSpinChanged)
     hbox.addWidget(qt.QLabel(_('Height')))
     hbox.addWidget(spin)
     MainWinItem.__init__(self, 'monthCal', _('Month Calendar'), optionsWidget=hbox)
     self.setFixedHeight(ui.mcalHeight)
     self.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)
     ######################
     ## self.supports_alpha = ## ??????????
     #self.kTime = 0
     ######################
     ## Define drag and drop
     ######################
     self.myKeys = (
         qc.Qt.Key_Up, qc.Qt.Key_Down, qc.Qt.Key_Right, qc.Qt.Key_Left, qc.Qt.Key_Space, qc.Qt.Key_Home, qc.Qt.Key_End,
         qc.Qt.Key_PageUp, qc.Qt.Key_PageDown, qc.Qt.Key_Menu, qc.Qt.Key_F10, qc.Qt.Key_M
     )
     ######################
     self.updateTextWidth()
示例#2
0
文件: hijri.py 项目: karoon/starcal2
 def updateWidget(self):
     #for index, module in enumerate(core.modules):
     #    if module.name != 'hijri':
     for item in ui.shownCals:
         mode = item['mode']
         modeDesc = moduleDescNames[mode]
         if not 'hijri' in modeDesc.lower():
             self.altMode = mode
             self.altModeDesc = modeDesc
             break
     self.topLabel.set_label(_('Start')+': '+dateLocale(*monthDb.startDate)+' '+_('Equals to')+' %s'%_(self.altModeDesc))
     self.startDateInput.set_value(jd_to(monthDb.startJd, self.altMode))
     ###########
     selectYm = getCurrentYm() - 1 ## previous month
     selectIndex = None
     self.trees.clear()
     for index, ym, mLen in monthDb.getMonthLenList():
         if ym == selectYm:
             selectIndex = index
         (year, month0) = divmod(ym, 12)
         self.trees.append([
             ym,
             _(year),
             _(monthName[month0]),
             mLen,
             '',
         ])
     self.updateEndDates()
     ########
     if selectIndex is not None:
         self.treev.scroll_to_cell(str(selectIndex))
         self.treev.set_cursor(str(selectIndex))
示例#3
0
 def __init__(self, group):
     BaseWidgetClass.__init__(self, group)
     ######
     sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_('Scale'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     pack(hbox, label)
     self.scaleCombo = common.Scale10PowerComboBox()
     pack(hbox, self.scaleCombo)
     pack(self, hbox)
     ####
     hbox = gtk.HBox()
     label = gtk.Label(_('Start'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     pack(hbox, label)
     self.startSpin = IntSpinButton(-maxStartEnd, maxStartEnd)
     pack(hbox, self.startSpin)
     pack(self, hbox)
     ####
     hbox = gtk.HBox()
     label = gtk.Label(_('End'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     pack(hbox, label)
     self.endSpin = IntSpinButton(-maxStartEnd, maxStartEnd)
     pack(hbox, self.endSpin)
     pack(self, hbox)
示例#4
0
 def __init__(self, event):
     gtk.Expander.__init__(self, _('Notification'))
     self.event = event
     self.hboxDict = {}
     totalVbox = gtk.VBox()
     ###
     hbox = gtk.HBox()
     pack(hbox, gtk.Label(_('Notify')+' '))
     self.notifyBeforeInput = DurationInputBox()
     pack(hbox, self.notifyBeforeInput, 0, 0)
     pack(hbox, gtk.Label(' '+_('before event')))
     pack(hbox, gtk.Label(), 1, 1)
     pack(totalVbox, hbox)
     ###
     for cls in event_lib.classes.notifier:
         notifier = cls(self.event)
         inputWidget = makeWidget(notifier)
         if not inputWidget:
             printError('notifier %s, inputWidget = %r'%(cls.name, inputWidget))
             continue
         hbox = gtk.HBox()
         cb = gtk.CheckButton(notifier.desc)
         cb.inputWidget = inputWidget
         cb.connect('clicked', lambda check: check.inputWidget.set_sensitive(check.get_active()))
         cb.set_active(False)
         pack(hbox, cb)
         hbox.cb = cb
         #pack(hbox, gtk.Label(''), 1, 1)
         pack(hbox, inputWidget, 1, 1)
         hbox.inputWidget = inputWidget
         self.hboxDict[notifier.name] = hbox
         pack(totalVbox, hbox)
     self.add(totalVbox)
示例#5
0
 def __init__(self, group=None):
     gtk.Dialog.__init__(self)
     self.isNew = (group is None)
     self.set_title(_('Add New Group') if self.isNew else _('Edit Group'))
     #self.connect('delete-event', lambda obj, e: self.destroy())
     #self.resize(800, 600)
     ###
     dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'),
                       gtk.RESPONSE_CANCEL)
     dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.RESPONSE_OK)
     self.connect('response', lambda w, e: self.hide())
     #######
     self.activeWidget = None
     #######
     hbox = gtk.HBox()
     combo = gtk.combo_box_new_text()
     for cls in event_lib.classes.group:
         combo.append_text(cls.desc)
     pack(hbox, gtk.Label(_('Group Type')))
     pack(hbox, combo)
     pack(hbox, gtk.Label(''), 1, 1)
     pack(self.vbox, hbox)
     ####
     if self.isNew:
         self._group = event_lib.classes.group[
             event_lib.defaultGroupTypeIndex]()
         combo.set_active(event_lib.defaultGroupTypeIndex)
     else:
         self._group = group
         combo.set_active(event_lib.classes.group.names.index(group.name))
     self.activeWidget = None
     combo.connect('changed', self.typeChanged)
     self.comboType = combo
     self.vbox.show_all()
     self.typeChanged()
示例#6
0
 def menuMainCreate(self):
     if self.menuMain:
         return
     menu = gtk.Menu()
     ####
     item = gtk.ImageMenuItem(_('Resize'))
     item.set_image(imageFromFile('resize.png'))
     item.connect('button-press-event', self.startResize)
     menu.add(item)
     #######
     menu.add(self.checkAbove)
     menu.add(self.checkSticky)
     #######
     menu.add(labelStockMenuItem('Select _Today', gtk.STOCK_HOME, self.goToday))
     menu.add(labelStockMenuItem('Select _Date...', gtk.STOCK_INDEX, self.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.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.statusIconMode!=1:
         menu.add(labelStockMenuItem('_Quit', gtk.STOCK_QUIT, self.quit))
     menu.show_all()
     self.menuMain = menu
示例#7
0
	def __init__(self):
		gtk.Dialog.__init__(self)
		self.initVars()
		ud.windowList.appendItem(self)
		###
		self.set_title(_('Day Info'))
		self.connect('delete-event', self.onClose)
		self.vbox.set_spacing(15)
		###
		dialog_add_button(self, gtk.STOCK_CLOSE, _('Close'), 0, self.onClose)
		dialog_add_button(self, '', _('Previous'), 1, self.goBack)
		dialog_add_button(self, '', _('Today'), 2, self.goToday)
		dialog_add_button(self, '', _('Next'), 3, self.goNext)
		###
		self.allDateLabels = AllDateLabelsVBox()
		self.pluginsTextView = PluginsTextView()
		self.eventsView = DayOccurrenceView()
		###
		for item in (self.allDateLabels, self.pluginsTextView, self.eventsView):
			self.appendItem(item)
			###
			exp = gtk.Expander(item.desc)
			exp.add(item)
			exp.set_expanded(True)
			pack(self.vbox, exp)
		self.vbox.show_all()
示例#8
0
 def __init__(self, abrivateWeekDays=False):
     self.abrivateWeekDays = abrivateWeekDays
     self.absWeekNumber = core.getAbsWeekNumberFromJd(ui.cell.jd)  ## FIXME
     gtk.TreeView.__init__(self)
     self.set_headers_visible(False)
     self.ls = gtk.ListStore(gdk.Pixbuf, str, str,
                             str)  ## icon, weekDay, time, text
     self.set_model(self.ls)
     ###
     cell = gtk.CellRendererPixbuf()
     col = gtk.TreeViewColumn(_('Icon'), cell)
     col.add_attribute(cell, 'pixbuf', 0)
     self.append_column(col)
     ###
     cell = gtk.CellRendererText()
     col = gtk.TreeViewColumn(_('Week Day'), cell)
     col.add_attribute(cell, 'text', 1)
     col.set_resizable(True)
     self.append_column(col)
     ###
     cell = gtk.CellRendererText()
     col = gtk.TreeViewColumn(_('Time'), cell)
     col.add_attribute(cell, 'text', 2)
     col.set_resizable(True)  ## FIXME
     self.append_column(col)
     ###
     cell = gtk.CellRendererText()
     col = gtk.TreeViewColumn(_('Description'), cell)
     col.add_attribute(cell, 'text', 3)
     col.set_resizable(True)
     self.append_column(col)
示例#9
0
 def __init__(self, event):  ## FIXME
     common.WidgetClass.__init__(self, event)
     ######
     sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
     ######
     try:
         seperated = event.parent.showSeperatedYmdInputs
     except AttributeError:
         seperated = False
     if seperated:
         self.startDateInput = YearMonthDayBox()
         self.endDateInput = YearMonthDayBox()
     else:
         self.startDateInput = DateButton()
         self.endDateInput = DateButton()
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_('Start') + ': ')
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     pack(hbox, label)
     pack(hbox, self.startDateInput)
     pack(self, hbox)
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_('End') + ': ')
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     pack(hbox, label)
     pack(hbox, self.endDateInput)
     pack(self, hbox)
示例#10
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)
示例#11
0
def readLocationData():
    lines = open(dataDir+'/locations.txt').read().split('\n')
    cityData = []
    country = ''
    for l in lines:
        p = l.split('\t')
        if len(p)<2:
            #print(p)
            continue
        if p[0]=='':
            if p[1]=='':
                city, lat, lng = p[2:5]
                #if country=='Iran':
                #    print(city)
                if len(p)>4:
                    cityData.append((
                        country + '/' + city,
                        _(country) + '/' + _(city),
                        float(lat),
                        float(lng)
                    ))
                else:
                    print(country, p)
            else:
                country = p[1]
    return cityData
示例#12
0
 def __init__(self, group):
     BaseWidgetClass.__init__(self, group)
     ######
     sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_('Scale'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     pack(hbox, label)
     self.scaleCombo = common.Scale10PowerComboBox()
     pack(hbox, self.scaleCombo)
     pack(self, hbox)
     ####
     hbox = gtk.HBox()
     label = gtk.Label(_('Start'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     pack(hbox, label)
     self.startSpin = IntSpinButton(-maxStartEnd, maxStartEnd)
     pack(hbox, self.startSpin)
     pack(self, hbox)
     ####
     hbox = gtk.HBox()
     label = gtk.Label(_('End'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     pack(hbox, label)
     self.endSpin = IntSpinButton(-maxStartEnd, maxStartEnd)
     pack(hbox, self.endSpin)
     pack(self, hbox)
示例#13
0
 def __init__(self):
     from scal2.ui_gtk.mywidgets.cal_type_combo import CalTypeCombo
     gtk.Dialog.__init__(self)
     ####
     dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.RESPONSE_OK)
     self.connect('response', self.onResponse)
     ####
     sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
     ####
     hbox = gtk.HBox()
     label = gtk.Label(_('Calendar Type'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     pack(hbox, label)
     combo = CalTypeCombo()
     combo.set_active(calTypes.primary)
     pack(hbox, combo)
     pack(hbox, gtk.Label(''), 1, 1)
     pack(self.vbox, hbox)
     self.modeCombo = combo
     ####
     hbox = gtk.HBox()
     hbox = gtk.HBox()
     label = gtk.Label(_('Group Title'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     pack(hbox, label)
     self.groupTitleEntry = gtk.Entry()
     self.groupTitleEntry.set_text(_('Imported Events'))
     pack(hbox, self.groupTitleEntry)
     pack(self.vbox, hbox)
     ####
     self.vbox.show_all()
示例#14
0
	def __init__(self, module, opt):
		t = opt[1]
		self.opt = opt ## needed??
		self.module = module
		self.type = t
		self.var_name = opt[0]
		hbox = gtk.HBox()
		if t==bool:
			w = gtk.CheckButton(_(opt[2]))
			self.get_value = w.get_active
			self.set_value = w.set_active
		elif t==list:
			pack(hbox, gtk.Label(_(opt[2])))
			w = gtk.combo_box_new_text() ### or RadioButton
			for s in opt[3]:
				w.append_text(_(s))
			self.get_value = w.get_active
			self.set_value = w.set_active
		elif t==int:
			pack(hbox, gtk.Label(_(opt[2])))
			w = IntSpinButton(opt[3], opt[4])
			self.get_value = w.get_value
			self.set_value = w.set_value
		elif t==float:
			pack(hbox, gtk.Label(_(opt[2])))
			w = FloatSpinButton(opt[3], opt[4], opt[5])
			self.get_value = w.get_value
			self.set_value = w.set_value
		else:
			raise RuntimeError('bad option type "%s"'%t)
		pack(hbox, w)
		self._widget = hbox
		####
		self.updateVar = lambda: setattr(self.module, self.var_name, self.get_value())
		self.updateWidget = lambda: self.set_value(getattr(self.module, self.var_name))
示例#15
0
	def __init__(self, account=None):
		gtk.Dialog.__init__(self)
		self.set_title(_('Edit Account') if account else _('Add New Account'))
		###
		dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), gtk.RESPONSE_CANCEL)
		dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.RESPONSE_OK)
		##
		self.connect('response', lambda w, e: self.hide())
		#######
		self.account = account
		self.activeWidget = None
		#######
		hbox = gtk.HBox()
		combo = gtk.combo_box_new_text()
		for cls in event_lib.classes.account:
			combo.append_text(cls.desc)
		pack(hbox, gtk.Label(_('Account Type')))
		pack(hbox, combo)
		pack(hbox, gtk.Label(''), 1, 1)
		pack(self.vbox, hbox)
		####
		if self.account:
			self.isNew = False
			combo.set_active(event_lib.classes.account.names.index(self.account.name))
		else:
			self.isNew = True
			defaultAccountTypeIndex = 0
			combo.set_active(defaultAccountTypeIndex)
			self.account = event_lib.classes.account[defaultAccountTypeIndex]()
		self.activeWidget = None
		combo.connect('changed', self.typeChanged)
		self.comboType = combo
		self.vbox.show_all()
		self.typeChanged()
示例#16
0
 def onEventLabelPopup(self, label, menu, ids):
     menu = gtk.Menu()
     self.labelMenuAddCopyItems(label, menu)
     ####
     groupId, eventId = ids
     event = ui.getEvent(groupId, eventId)
     if not event.readOnly:
         menu.add(gtk.SeparatorMenuItem())
         ###
         winTitle = _('Edit ') + event.desc
         menu.add(labelStockMenuItem(
             winTitle,
             gtk.STOCK_EDIT,
             self.editEventClicked,
             winTitle,
             event,
             groupId,
         ))
         ###
         menu.add(gtk.SeparatorMenuItem())
         ###
         menu.add(labelImageMenuItem(
             _('Move to %s') % ui.eventTrash.title,
             ui.eventTrash.icon,
             self.moveEventToTrash,
             event,
             groupId,
         ))
     ####
     menu.show_all()
     menu.popup(None, None, None, 3, 0)
     ui.updateFocusTime()
示例#17
0
 def __init__(self, event):  ## FIXME
     common.WidgetClass.__init__(self, event)
     ################
     hbox = gtk.HBox()
     pack(hbox, gtk.Label(_('Month')))
     self.monthCombo = MonthComboBox()
     self.monthCombo.build(event.mode)
     pack(hbox, self.monthCombo)
     pack(hbox, gtk.Label(''), 1, 1)
     #pack(self, hbox)
     ###
     #hbox = gtk.HBox()
     pack(hbox, gtk.Label(_('Day')))
     self.daySpin = DaySpinButton()
     pack(hbox, self.daySpin)
     pack(hbox, gtk.Label(''), 1, 1)
     pack(self, hbox)
     ###
     hbox = gtk.HBox()
     self.startYearCheck = gtk.CheckButton(_('Start Year'))
     pack(hbox, self.startYearCheck)
     self.startYearSpin = YearSpinButton()
     pack(hbox, self.startYearSpin)
     pack(hbox, gtk.Label(''), 1, 1)
     pack(self, hbox)
     self.startYearCheck.connect('clicked', self.startYearCheckClicked)
     ####
     self.notificationBox = common.NotificationBox(event)
     pack(self, self.notificationBox)
示例#18
0
class DirectionComboBox(gtk.ComboBox):
    keys = ['ltr', 'rtl', 'auto']
    descs = [
        _('Left to Right'),
        _('Right to Left'),
        _('Auto'),
    ]

    def __init__(self):
        ls = gtk.ListStore(str)
        gtk.ComboBox.__init__(self)
        self.set_model(ls)
        ###
        cell = gtk.CellRendererText()
        pack(self, cell, True)
        self.add_attribute(cell, 'text', 0)
        ###
        for d in self.descs:
            ls.append([d])
        self.set_active(0)

    getValue = lambda self: self.keys[self.get_active()]

    def setValue(self, value):
        self.set_active(self.keys.index(value))
示例#19
0
 def __init__(self, module, opt):
     t = opt[1]
     self.opt = opt ## needed??
     self.module = module
     self.type = t
     self.var_name = opt[0]
     hbox = gtk.HBox()
     if t==bool:
         w = gtk.CheckButton(_(opt[2]))
         self.get_value = w.get_active
         self.set_value = w.set_active
     elif t==list:
         hbox.pack_start(gtk.Label(_(opt[2])), 0, 0)
         w = gtk.combo_box_new_text() ### or RadioButton
         for s in opt[3]:
             w.append_text(_(s))
         self.get_value = w.get_active
         self.set_value = w.set_active
     elif t==int:
         hbox.pack_start(gtk.Label(_(opt[2])), 0, 0)
         w = IntSpinButton(opt[3], opt[4])
         self.get_value = w.get_value
         self.set_value = w.set_value
     elif t==float:
         hbox.pack_start(gtk.Label(_(opt[2])), 0, 0)
         w = FloatSpinButton(opt[3], opt[4], opt[5])
         self.get_value = w.get_value
         self.set_value = w.set_value
     else:
         raise RuntimeError('bad option type "%s"'%t)
     hbox.pack_start(w, 0, 0)
     self.widget = hbox
     ####
     self.updateVar = lambda: setattr(self.module, self.var_name, self.get_value())
     self.updateWidget = lambda: self.set_value(getattr(self.module, self.var_name))
示例#20
0
文件: yearly.py 项目: karoon/starcal2
 def __init__(self, event):  ## FIXME
     common.EventWidget.__init__(self, event)
     ################
     hbox = gtk.HBox()
     hbox.pack_start(gtk.Label(_("Month")), 0, 0)
     self.monthCombo = gtk.combo_box_new_text()
     hbox.pack_start(self.monthCombo, 0, 0)
     hbox.pack_start(gtk.Label(""), 1, 1)
     # self.pack_start(hbox, 0, 0)
     ###
     # hbox = gtk.HBox()
     hbox.pack_start(gtk.Label(_("Day")), 0, 0)
     self.daySpin = DaySpinButton()
     hbox.pack_start(self.daySpin, 0, 0)
     hbox.pack_start(gtk.Label(""), 1, 1)
     self.pack_start(hbox, 0, 0)
     ###
     hbox = gtk.HBox()
     self.startYearCheck = gtk.CheckButton(_("Start Year"))
     hbox.pack_start(self.startYearCheck, 0, 0)
     self.startYearSpin = YearSpinButton()
     hbox.pack_start(self.startYearSpin, 0, 0)
     hbox.pack_start(gtk.Label(""), 1, 1)
     self.pack_start(hbox, 0, 0)
     self.startYearCheck.connect("clicked", self.startYearCheckClicked)
     ####
     self.notificationBox = common.NotificationBox(event)
     self.pack_start(self.notificationBox, 0, 0)
示例#21
0
 def __init__(self,
              name,
              stockName,
              method,
              desc='',
              shortDesc='',
              enableTooltip=True):
     #print('ToolbarItem', name, stockName, method, desc, text)
     self.method = method
     ######
     if not desc:
         desc = name.capitalize()
     ##
     if not shortDesc:
         shortDesc = desc
     ##
     desc = _(desc)
     shortDesc = _(shortDesc)
     ######
     gtk.ToolButton.__init__(
         self,
         gtk.image_new_from_stock(
             getattr(gtk, 'STOCK_%s' % (stockName.upper())),
             gtk.ICON_SIZE_DIALOG,
         ) if stockName else None,
         shortDesc,
     )
     self._name = name
     self.desc = desc
     #self.shortDesc = shortDesc## FIXME
     self.initVars()
     if enableTooltip:
         set_tooltip(self, desc)  ## FIXME
     self.set_is_important(True)  ## FIXME
示例#22
0
class CalObj(CustomizableToolbar):
    defaultItems = [
        ToolbarItem('today', 'home', 'goToday', 'Select Today', 'Today'),
        ToolbarItem('date', 'index', 'selectDateShow', 'Select Date...',
                    'Date'),
        ToolbarItem('customize', 'edit', 'customizeShow'),
        ToolbarItem('preferences', 'preferences', 'prefShow'),
        ToolbarItem('add', 'add', 'eventManShow', 'Event Manager', 'Event'),
        ToolbarItem('export', 'convert', 'exportClicked',
                    _('Export to %s') % 'HTML', 'Export'),
        ToolbarItem('about', 'about', 'aboutShow',
                    _('About ') + core.APP_DESC, 'About'),
        ToolbarItem('quit', 'quit', 'quit'),
    ]
    defaultItemsDict = dict([(item._name, item) for item in defaultItems])

    def __init__(self):
        CustomizableToolbar.__init__(self, ui.mainWin, vertical=False)
        if not ud.mainToolbarData['items']:
            ud.mainToolbarData['items'] = [(item._name, True)
                                           for item in self.defaultItems]
        self.setData(ud.mainToolbarData)

    def updateVars(self):
        CustomizableToolbar.updateVars(self)
        ud.mainToolbarData = self.getData()
示例#23
0
 def __init__(self, event):## FIXME
     common.WidgetClass.__init__(self, event)
     ################
     hbox = gtk.HBox()
     pack(hbox, gtk.Label(_('Month')))
     self.monthCombo = MonthComboBox()
     self.monthCombo.build(event.mode)
     pack(hbox, self.monthCombo)
     pack(hbox, gtk.Label(''), 1, 1)
     #pack(self, hbox)
     ###
     #hbox = gtk.HBox()
     pack(hbox, gtk.Label(_('Day')))
     self.daySpin = DaySpinButton()
     pack(hbox, self.daySpin)
     pack(hbox, gtk.Label(''), 1, 1)
     pack(self, hbox)
     ###
     hbox = gtk.HBox()
     self.startYearCheck = gtk.CheckButton(_('Start Year'))
     pack(hbox, self.startYearCheck)
     self.startYearSpin = YearSpinButton()
     pack(hbox, self.startYearSpin)
     pack(hbox, gtk.Label(''), 1, 1)
     pack(self, hbox)
     self.startYearCheck.connect('clicked', self.startYearCheckClicked)
     ####
     self.notificationBox = common.NotificationBox(event)
     pack(self, self.notificationBox)
示例#24
0
 def run(self, format, fpath):
     self.redirectStdOutErr()
     try:
         if format=='json':
             try:
                 text = open(fpath, 'rb').read()
             except Exception as e:
                 sys.stderr.write(_('Error in reading file')+'\n%s\n'%e)
             else:
                 try:
                     data = jsonToData(text)
                 except Exception as e:
                     sys.stderr.write(_('Error in loading JSON data')+'\n%s\n'%e)
                 else:
                     try:
                         newGroups = ui.eventGroups.importData(data)
                     except Exception as e:
                         sys.stderr.write(_('Error in importing events')+'\n%s\n'%e)
                     else:
                         for group in newGroups:
                             self.win.manager.appendGroupTree(group)
                         print(_('%s groups imported successfully')%_(len(newGroups)))
         else:
             raise ValueError('invalid format %r'%format)
     finally:
         self.restoreStdOutErr()
示例#25
0
 def updateWidget(self):
     # for index, module in calTypes.iterIndexModule():
     #    if module.name != 'hijri':
     for mode in calTypes.active:
         modeDesc = calTypes[mode].desc
         if not "hijri" in modeDesc.lower():
             self.altMode = mode
             self.altModeDesc = modeDesc
             break
     self.topLabel.set_label(
         _("Start") + ": " + dateLocale(*monthDb.startDate) + " " + _("Equals to") + " %s" % _(self.altModeDesc)
     )
     self.startDateInput.set_value(jd_to(monthDb.startJd, self.altMode))
     ###########
     selectYm = getCurrentYm() - 1  ## previous month
     selectIndex = None
     self.trees.clear()
     for index, ym, mLen in monthDb.getMonthLenList():
         if ym == selectYm:
             selectIndex = index
         year, month0 = divmod(ym, 12)
         self.trees.append([ym, _(year), _(monthName[month0]), mLen, ""])
     self.updateEndDates()
     ########
     if selectIndex is not None:
         self.treev.scroll_to_cell(str(selectIndex))
         self.treev.set_cursor(str(selectIndex))
示例#26
0
 def __init__(self, event):## FIXME
     common.EventWidget.__init__(self, event)
     ######
     sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
     ######
     try:
         seperated = event.parent.showSeperatedYmdInputs
     except AttributeError:
         seperated = False
     if seperated:
         self.startDateInput = YearMonthDayBox()
         self.endDateInput = YearMonthDayBox()
     else:
         self.startDateInput = DateButton()
         self.endDateInput = DateButton()
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_('Start')+': ')
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     hbox.pack_start(self.startDateInput, 0, 0)
     self.pack_start(hbox, 0, 0)
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_('End')+': ')
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     hbox.pack_start(self.endDateInput, 0, 0)
     self.pack_start(hbox, 0, 0)
示例#27
0
	def __init__(self, group):
		from scal2.ui_gtk.mywidgets.cal_type_combo import CalTypeCombo
		self._group = group
		gtk.Dialog.__init__(self)
		self.set_title(_('Convert Calendar Type'))
		####
		dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), gtk.RESPONSE_CANCEL)
		dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.RESPONSE_OK)
		##
		self.connect('response', lambda w, e: self.hide())
		####
		hbox = gtk.HBox()
		label = gtk.Label(_('This is going to convert calendar types of all events inside group \"%s\" to a specific type. This operation does not work for Yearly events and also some of Custom events. You have to edit those events manually to change calendar type.')%group.title)
		label.set_line_wrap(True)
		pack(hbox, label)
		pack(hbox, gtk.Label(''), 1, 1)
		pack(self.vbox, hbox)
		###
		hbox = gtk.HBox()
		pack(hbox, gtk.Label(_('Calendar Type')+':'))
		combo = CalTypeCombo()
		combo.set_active(group.mode)
		pack(hbox, combo)
		pack(hbox, gtk.Label(''), 1, 1)
		self.modeCombo = combo
		pack(self.vbox, hbox)
		####
		self.vbox.show_all()
示例#28
0
 def __init__(self, term, **kwargs):
     self.term = term
     gtk.Dialog.__init__(self, **kwargs)
     self.resize(800, 500)
     self.set_title(_('View Weekly Schedule'))
     self.connect('delete-event', self.onDeleteEvent)
     #####
     hbox = gtk.HBox()
     self.currentWOnlyCheck = gtk.CheckButton(_('Current Week Only'))
     self.currentWOnlyCheck.connect('clicked', lambda obj: self.updateWidget())
     hbox.pack_start(self.currentWOnlyCheck, 0, 0)
     ##
     hbox.pack_start(gtk.Label(''), 1, 1)
     ##
     button = gtk.Button(_('Export to ')+'SVG')
     button.connect('clicked', self.exportToSvgClicked)
     hbox.pack_start(button, 0, 0)
     ##
     self.vbox.pack_start(hbox, 0, 0)
     #####
     self.widget = WeeklyScheduleWidget(term)
     self.vbox.pack_start(self.widget, 1, 1)
     #####
     self.vbox.show_all()
     self.updateWidget()
示例#29
0
 def optionsWidgetCreate(self):
     from scal2.ui_gtk.mywidgets.multi_spin.integer import IntSpinButton
     if self.optionsWidget:
         return
     self.optionsWidget = gtk.VBox()
     ####
     if self.customizeWidth:
         value = self.getWidthValue()
         ###
         hbox = gtk.HBox()
         pack(hbox, gtk.Label(_('Width')))
         spin = IntSpinButton(0, 999)
         pack(hbox, spin)
         spin.set_value(value)
         spin.connect('changed', self.widthSpinChanged)
         pack(self.optionsWidget, hbox)
     ####
     if self.customizeFont:
         hbox = gtk.HBox()
         pack(hbox, gtk.Label(_('Font Family')))
         combo = FontFamilyCombo(hasAuto=True)
         combo.set_value(self.getFontValue())
         pack(hbox, combo)
         combo.connect('changed', self.fontFamilyComboChanged)
         pack(self.optionsWidget, hbox)
     ####
     self.optionsWidget.show_all()
示例#30
0
 def __init__(self, group=None):
     gtk.Dialog.__init__(self)
     self.isNew = (group is None)
     self.set_title(_('Add New Group') if self.isNew else _('Edit Group'))
     #self.connect('delete-event', lambda obj, e: self.destroy())
     #self.resize(800, 600)
     ###
     dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), gtk.RESPONSE_CANCEL)
     dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.RESPONSE_OK)
     self.connect('response', lambda w, e: self.hide())
     #######
     self.activeWidget = None
     #######
     hbox = gtk.HBox()
     combo = gtk.combo_box_new_text()
     for cls in event_lib.classes.group:
         combo.append_text(cls.desc)
     hbox.pack_start(gtk.Label(_('Group Type')), 0, 0)
     hbox.pack_start(combo, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     self.vbox.pack_start(hbox, 0, 0)
     ####
     if self.isNew:
         self._group = event_lib.classes.group[event_lib.defaultGroupTypeIndex]()
         combo.set_active(event_lib.defaultGroupTypeIndex)
     else:
         self._group = group
         combo.set_active(event_lib.classes.group.names.index(group.name))
     self.activeWidget = None
     combo.connect('changed', self.typeChanged)
     self.comboType = combo
     self.vbox.show_all()
     self.typeChanged()
示例#31
0
 def __init__(self, group):
     NormalGroupWidget.__init__(self, group)
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_('VCS Type'))
     label.set_alignment(0, 0.5)
     self.sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     self.vcsTypeCombo = gtk.combo_box_new_text()
     for name in vcsModuleNames:
         self.vcsTypeCombo.append_text(name)## descriptive name FIXME
     hbox.pack_start(self.vcsTypeCombo, 0, 0)
     self.pack_start(hbox, 0, 0)
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_('Directory'))
     label.set_alignment(0, 0.5)
     self.sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     self.dirEntry = gtk.Entry()
     hbox.pack_start(self.dirEntry, 0, 0)
     ##
     #self.dirBrowse = gtk.Button(_('Browse'))
     ##
     self.pack_start(hbox, 0, 0)
示例#32
0
 def set_value(self, value):
     for i, row in enumerate(self.ls):
         if row[0] == value:
             self.set_active(i)
             return
     self.ls.append((value, _('%s Years')%_(value)))
     self.set_active(len(self.ls)-1)
示例#33
0
 def __init__(self, event):
     gtk.Expander.__init__(self, _('Notification'))
     self.event = event
     self.hboxDict = {}
     totalVbox = gtk.VBox()
     ###
     hbox = gtk.HBox()
     hbox.pack_start(gtk.Label(_('Notify Before')), 0, 0)## or at the end?
     self.notifyBeforeInput = DurationInputBox()
     hbox.pack_start(self.notifyBeforeInput, 1, 1)
     totalVbox.pack_start(hbox, 0, 0)
     ###
     for cls in event_lib.classes.notifier:
         notifier = cls(self.event)
         inputWidget = notifier.makeWidget()
         hbox = gtk.HBox()
         cb = gtk.CheckButton(notifier.desc)
         cb.inputWidget = inputWidget
         cb.connect('clicked', lambda check: check.inputWidget.set_sensitive(check.get_active()))
         cb.set_active(False)
         hbox.pack_start(cb, 0, 0)
         hbox.cb = cb
         #hbox.pack_start(gtk.Label(''), 1, 1)
         hbox.pack_start(inputWidget, 1, 1)
         hbox.inputWidget = inputWidget
         self.hboxDict[notifier.name] = hbox
         totalVbox.pack_start(hbox, 0, 0)
     self.add(totalVbox)
示例#34
0
 def __init__(self, group):
     BaseGroupWidget.__init__(self, group)
     ######
     sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_('Scale'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     self.scaleCombo = common.Scale10PowerComboBox()
     hbox.pack_start(self.scaleCombo, 0, 0)
     self.pack_start(hbox, 0, 0)
     ####
     hbox = gtk.HBox()
     label = gtk.Label(_('Start'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     self.startSpin = IntSpinButton(-maxStartEnd, maxStartEnd)
     hbox.pack_start(self.startSpin, 0, 0)
     self.pack_start(hbox, 0, 0)
     ####
     hbox = gtk.HBox()
     label = gtk.Label(_('End'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     self.endSpin = IntSpinButton(-maxStartEnd, maxStartEnd)
     hbox.pack_start(self.endSpin, 0, 0)
     self.pack_start(hbox, 0, 0)
示例#35
0
 def updateWidget(self):
     #for index, module in calTypes.iterIndexModule():
     #	if module.name != 'hijri':
     for mode in calTypes.active:
         modeDesc = calTypes[mode].desc
         if not 'hijri' in modeDesc.lower():
             self.altMode = mode
             self.altModeDesc = modeDesc
             break
     self.topLabel.set_label(
         _('Start') + ': ' + dateLocale(*monthDb.startDate) + ' ' +
         _('Equals to') + ' %s' % _(self.altModeDesc))
     self.startDateInput.set_value(jd_to(monthDb.startJd, self.altMode))
     ###########
     selectYm = getCurrentYm() - 1  ## previous month
     selectIndex = None
     self.trees.clear()
     for index, ym, mLen in monthDb.getMonthLenList():
         if ym == selectYm:
             selectIndex = index
         year, month0 = divmod(ym, 12)
         self.trees.append([
             ym,
             _(year),
             _(monthName[month0]),
             mLen,
             '',
         ])
     self.updateEndDates()
     ########
     if selectIndex is not None:
         self.treev.scroll_to_cell(str(selectIndex))
         self.treev.set_cursor(str(selectIndex))
示例#36
0
		def run(self, format, fpath):
			self.redirectStdOutErr()
			try:
				if format=='json':
					try:
						text = open(fpath, 'rb').read()
					except Exception as e:
						sys.stderr.write(_('Error in reading file')+'\n%s\n'%e)
					else:
						try:
							data = jsonToData(text)
						except Exception as e:
							sys.stderr.write(_('Error in loading JSON data')+'\n%s\n'%e)
						else:
							try:
								newGroups = ui.eventGroups.importData(data)
							except Exception as e:
								sys.stderr.write(_('Error in importing events')+'\n%s\n'%e)
							else:
								for group in newGroups:
									self.win.manager.appendGroupTree(group)
								print(_('%s groups imported successfully')%_(len(newGroups)))
				else:
					raise ValueError('invalid format %r'%format)
			finally:
				self.restoreStdOutErr()
示例#37
0
 def __init__(self, event):## FIXME
     common.EventWidget.__init__(self, event)
     ################
     hbox = gtk.HBox()
     hbox.pack_start(gtk.Label(_('Month')), 0, 0)
     self.monthCombo = MonthComboBox()
     self.monthCombo.build(event.mode)
     hbox.pack_start(self.monthCombo, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     #self.pack_start(hbox, 0, 0)
     ###
     #hbox = gtk.HBox()
     hbox.pack_start(gtk.Label(_('Day')), 0, 0)
     self.daySpin = DaySpinButton()
     hbox.pack_start(self.daySpin, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     self.pack_start(hbox, 0, 0)
     ###
     hbox = gtk.HBox()
     self.startYearCheck = gtk.CheckButton(_('Start Year'))
     hbox.pack_start(self.startYearCheck, 0, 0)
     self.startYearSpin = YearSpinButton()
     hbox.pack_start(self.startYearSpin, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     self.pack_start(hbox, 0, 0)
     self.startYearCheck.connect('clicked', self.startYearCheckClicked)
     ####
     self.notificationBox = common.NotificationBox(event)
     self.pack_start(self.notificationBox, 0, 0)
示例#38
0
	def optionsWidgetCreate(self):
		from scal2.ui_gtk.mywidgets.multi_spin.integer import IntSpinButton
		if self.optionsWidget:
			return
		self.optionsWidget = gtk.VBox()
		####
		if self.customizeWidth:
			value = self.getWidthValue()
			###
			hbox = gtk.HBox()
			pack(hbox, gtk.Label(_('Width')))
			spin = IntSpinButton(0, 999)
			pack(hbox, spin)
			spin.set_value(value)
			spin.connect('changed', self.widthSpinChanged)
			pack(self.optionsWidget, hbox)
		####
		if self.customizeFont:
			hbox = gtk.HBox()
			pack(hbox, gtk.Label(_('Font Family')))
			combo = FontFamilyCombo(hasAuto=True)
			combo.set_value(self.getFontValue())
			pack(hbox, combo)
			combo.connect('changed', self.fontFamilyComboChanged)
			pack(self.optionsWidget, hbox)
		####
		self.optionsWidget.show_all()
示例#39
0
 def __init__(self):
     from scal2.ui_gtk.mywidgets.cal_type_combo import CalTypeCombo
     gtk.Dialog.__init__(self)
     ####
     dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.RESPONSE_OK)
     self.connect('response', self.onResponse)
     ####
     sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
     ####
     hbox = gtk.HBox()
     label = gtk.Label(_('Calendar Type'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     pack(hbox, label)
     combo = CalTypeCombo()
     combo.set_active(calTypes.primary)
     pack(hbox, combo)
     pack(hbox, gtk.Label(''), 1, 1)
     pack(self.vbox, hbox)
     self.modeCombo = combo
     ####
     hbox = gtk.HBox()
     hbox = gtk.HBox()
     label = gtk.Label(_('Group Title'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     pack(hbox, label)
     self.groupTitleEntry = gtk.Entry()
     self.groupTitleEntry.set_text(_('Imported Events'))
     pack(hbox, self.groupTitleEntry)
     pack(self.vbox, hbox)
     ####
     self.vbox.show_all()
示例#40
0
文件: about.py 项目: ilius/starcal2
	def __init__(
		self,
		name='',
		version='',
		title='',
		authors=[],
		comments='',
		license='',
		website='',
	):
		gtk.AboutDialog.__init__(self)
		self.set_name(name)## or set_program_name FIXME
		self.set_version(version)
		self.set_title(title) ## must call after set_name and set_version !
		self.set_authors(authors)
		self.set_comments(comments)
		if license:
			self.set_license(license)
			self.set_wrap_license(True)
		if website:
			self.set_website(website) ## A plain label (not link)
		if ui.autoLocale:
			buttonbox = self.vbox.get_children()[1]
			buttons = buttonbox.get_children()## List of buttons of about dialogs
			buttons[1].set_label(_('C_redits'))
			buttons[2].set_label(_('_Close'))
			buttons[2].set_image(gtk.image_new_from_stock(gtk.STOCK_CLOSE,gtk.ICON_SIZE_BUTTON))
			buttons[0].set_label(_('_License'))
示例#41
0
 def __init__(self, abrivateWeekDays=False):
     self.abrivateWeekDays = abrivateWeekDays
     self.absWeekNumber = core.getAbsWeekNumberFromJd(ui.cell.jd)## FIXME
     gtk.TreeView.__init__(self)
     self.set_headers_visible(False)
     self.ls = gtk.ListStore(gdk.Pixbuf, str, str, str)## icon, weekDay, time, text
     self.set_model(self.ls)
     ###
     cell = gtk.CellRendererPixbuf()
     col = gtk.TreeViewColumn(_('Icon'), cell)
     col.add_attribute(cell, 'pixbuf', 0)
     self.append_column(col)
     ###
     cell = gtk.CellRendererText()
     col = gtk.TreeViewColumn(_('Week Day'), cell)
     col.add_attribute(cell, 'text', 1)
     col.set_resizable(True)
     self.append_column(col)
     ###
     cell = gtk.CellRendererText()
     col = gtk.TreeViewColumn(_('Time'), cell)
     col.add_attribute(cell, 'text', 2)
     col.set_resizable(True)## FIXME
     self.append_column(col)
     ###
     cell = gtk.CellRendererText()
     col = gtk.TreeViewColumn(_('Description'), cell)
     col.add_attribute(cell, 'text', 3)
     col.set_resizable(True)
     self.append_column(col)
示例#42
0
def confirm(msg, parent=None):
    win = gtk.MessageDialog(parent=parent, flags=0, type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_NONE, message_format=msg)
    dialog_add_button(win, gtk.STOCK_CANCEL, _("_Cancel"), gtk.RESPONSE_CANCEL)
    dialog_add_button(win, gtk.STOCK_OK, _("_OK"), gtk.RESPONSE_OK)
    ok = win.run() == gtk.RESPONSE_OK
    win.destroy()
    return ok
示例#43
0
文件: group_op.py 项目: Noori/starcal
 def __init__(self, group):
     self._group = group
     gtk.Dialog.__init__(self)
     self.set_title(_('Convert Calendar Type'))
     ####
     dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), gtk.RESPONSE_CANCEL)
     dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.RESPONSE_OK)
     ##
     self.connect('response', lambda w, e: self.hide())
     ####
     hbox = gtk.HBox()
     label = gtk.Label(_('This is going to convert calendar types of all events inside group \"%s\" to a specific type. This operation does not work for Yearly events and also some of Custom events. You have to edit those events manually to change calendar type.')%group.title)
     label.set_line_wrap(True)
     pack(hbox, label)
     pack(hbox, gtk.Label(''), 1, 1)
     pack(self.vbox, hbox)
     ###
     hbox = gtk.HBox()
     pack(hbox, gtk.Label(_('Calendar Type')+':'))
     combo = CalTypeCombo()
     combo.set_active(group.mode)
     pack(hbox, combo)
     pack(hbox, gtk.Label(''), 1, 1)
     self.modeCombo = combo
     pack(self.vbox, hbox)
     ####
     self.vbox.show_all()
示例#44
0
 def __init__(self):
     gtk.Dialog.__init__(self)
     ####
     dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.RESPONSE_OK)
     self.connect('response', self.onResponse)
     ####
     sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
     ####
     hbox = gtk.HBox()
     label = gtk.Label(_('Calendar Type'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     combo = gtk.combo_box_new_text()
     for module in core.modules:
         combo.append_text(_(module.desc))
     combo.set_active(core.primaryMode)
     hbox.pack_start(combo, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     self.vbox.pack_start(hbox, 0, 0)
     self.modeCombo = combo
     ####
     hbox = gtk.HBox()
     hbox = gtk.HBox()
     label = gtk.Label(_('Group Title'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     self.groupTitleEntry = gtk.Entry()
     self.groupTitleEntry.set_text(_('Imported Events'))
     hbox.pack_start(self.groupTitleEntry, 0, 0)
     self.vbox.pack_start(hbox, 0, 0)
     ####
     self.vbox.show_all()
示例#45
0
 def __init__(self, account=None):
     gtk.Dialog.__init__(self)
     self.set_title(_('Edit Account') if account else _('Add New Account'))
     ###
     dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), gtk.RESPONSE_CANCEL)
     dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.RESPONSE_OK)
     ##
     self.connect('response', lambda w, e: self.hide())
     #######
     self.account = account
     self.activeWidget = None
     #######
     hbox = gtk.HBox()
     combo = gtk.combo_box_new_text()
     for cls in event_lib.classes.account:
         combo.append_text(cls.desc)
     hbox.pack_start(gtk.Label(_('Account Type')), 0, 0)
     hbox.pack_start(combo, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     self.vbox.pack_start(hbox, 0, 0)
     ####
     if self.account:
         self.isNew = False
         combo.set_active(event_lib.classes.account.names.index(self.account.name))
     else:
         self.isNew = True
         defaultAccountTypeIndex = 0
         combo.set_active(defaultAccountTypeIndex)
         self.account = event_lib.classes.account[defaultAccountTypeIndex]()
     self.activeWidget = None
     combo.connect('changed', self.typeChanged)
     self.comboType = combo
     self.vbox.show_all()
     self.typeChanged()
示例#46
0
 def __init__(self, term, **kwargs):
     self.term = term
     gtk.Dialog.__init__(self, **kwargs)
     self.resize(800, 500)
     self.set_title(_('View Weekly Schedule'))
     self.connect('delete-event', self.onDeleteEvent)
     #####
     hbox = gtk.HBox()
     self.currentWOnlyCheck = gtk.CheckButton(_('Current Week Only'))
     self.currentWOnlyCheck.connect('clicked',
                                    lambda obj: self.updateWidget())
     pack(hbox, self.currentWOnlyCheck)
     ##
     pack(hbox, gtk.Label(''), 1, 1)
     ##
     button = gtk.Button(_('Export to ') + 'SVG')
     button.connect('clicked', self.exportToSvgClicked)
     pack(hbox, button)
     ##
     pack(self.vbox, hbox)
     #####
     self._widget = WeeklyScheduleWidget(term)
     pack(self.vbox, self._widget, 1, 1)
     #####
     self.vbox.show_all()
     self.updateWidget()
示例#47
0
文件: export.py 项目: Noori/starcal
 def save(self, widget=None):
     self.get_window().set_cursor(gdk.Cursor(gdk.WATCH))
     while gtk.events_pending():
         gtk.main_iteration_do(False)
     path = self.fcw.get_filename()
     if path in (None, ''):
         return
     print('Exporting to html file "%s"'%path)
     i = self.combo.get_active()
     months = []
     module = calTypes.primaryModule()
     if i==0:
         s = getCurrentMonthStatus()
         months = [s]
         title = '%s %s'%(core.getMonthName(calTypes.primary, s.month, s.year), _(s.year))
     elif i==1:
         for i in range(1, 13):
             months.append(getMonthStatus(ui.cell.year, i))
         title = '%s %s'%(_('Calendar'), _(ui.cell.year))
     elif i==2:
         y0, m0 = self.ymBox0.get_value()
         y1, m1 = self.ymBox1.get_value()
         for ym in range(y0*12+m0-1, y1*12+m1):
             y, m = divmod(ym, 12)
             m += 1
             months.append(getMonthStatus(y, m))
         title = _('Calendar')
     exportToHtml(path, months, title)
     self.get_window().set_cursor(gdk.Cursor(gdk.LEFT_PTR))
     self.hide()
示例#48
0
 def __init__(self, name, stockName, method, desc='', shortDesc='', enableTooltip=True):
     #print('ToolbarItem', name, stockName, method, desc, text)
     self.method = method
     ######
     if not desc:
         desc = name.capitalize()
     ##
     if not shortDesc:
         shortDesc = desc
     ##
     desc = _(desc)
     shortDesc = _(shortDesc)
     ######
     gtk.ToolButton.__init__(
         self,
         gtk.image_new_from_stock(
             getattr(gtk, 'STOCK_%s'%(stockName.upper())),
             gtk.ICON_SIZE_DIALOG,
         ) if stockName else None,
         shortDesc,
     )
     self._name = name
     self.desc = desc
     #self.shortDesc = shortDesc## FIXME
     self.initVars()
     if enableTooltip:
         set_tooltip(self, desc)## FIXME
     self.set_is_important(True)## FIXME
示例#49
0
 def __init__(
     self,
     name='',
     version='',
     title='',
     authors=[],
     comments='',
     license='',
     website='',
 ):
     gtk.AboutDialog.__init__(self)
     self.set_name(name)## or set_program_name FIXME
     self.set_version(version)
     self.set_title(title) ## must call after set_name and set_version !
     self.set_authors(authors)
     self.set_comments(comments)
     if license:
         self.set_license(license)
         self.set_wrap_license(True)
     if website:
         self.set_website(website) ## A plain label (not link)
     if ui.autoLocale:
         buttonbox = self.vbox.get_children()[1]
         buttons = buttonbox.get_children()## List of buttons of about dialogs
         buttons[1].set_label(_('C_redits'))
         buttons[2].set_label(_('_Close'))
         buttons[2].set_image(gtk.image_new_from_stock(gtk.STOCK_CLOSE,gtk.ICON_SIZE_BUTTON))
         buttons[0].set_label(_('_License'))
示例#50
0
 def set_value(self, value):
     ls = self.get_model()
     for i, row in enumerate(ls):
         if row[0] == value:
             self.set_active(i)
             return
     ls.append((value, _('%s Years') % _(value)))
     self.set_active(len(ls) - 1)
示例#51
0
	def optionsWidgetCreate(self):
		from scal2.ui_gtk.mywidgets.multi_spin.integer import IntSpinButton
		from scal2.ui_gtk.pref_utils import CheckPrefItem, ColorPrefItem
		if self.optionsWidget:
			return
		self.optionsWidget = gtk.VBox()
		####
		hbox = gtk.HBox()
		spin = IntSpinButton(1, 9999)
		spin.set_value(ui.mcalHeight)
		spin.connect('changed', self.heightSpinChanged)
		pack(hbox, gtk.Label(_('Height')))
		pack(hbox, spin)
		pack(self.optionsWidget, hbox)
		####
		hbox = gtk.HBox(spacing=3)
		##
		pack(hbox, gtk.Label(_('Left Margin')))
		spin = IntSpinButton(0, 99)
		spin.set_value(ui.mcalLeftMargin)
		spin.connect('changed', self.leftMarginSpinChanged)
		pack(hbox, spin)
		##
		pack(hbox, gtk.Label(_('Top')))
		spin = IntSpinButton(0, 99)
		spin.set_value(ui.mcalTopMargin)
		spin.connect('changed', self.topMarginSpinChanged)
		pack(hbox, spin)
		##
		pack(hbox, gtk.Label(''), 1, 1)
		pack(self.optionsWidget, hbox)
		########
		hbox = gtk.HBox(spacing=3)
		####
		item = CheckPrefItem(ui, 'mcalGrid', _('Grid'))
		item.updateWidget()
		gridCheck = item._widget
		pack(hbox, gridCheck)
		gridCheck.item = item
		####
		colorItem = ColorPrefItem(ui, 'mcalGridColor', True)
		colorItem.updateWidget()
		pack(hbox, colorItem._widget)
		gridCheck.colorb = colorItem._widget
		gridCheck.connect('clicked', self.gridCheckClicked)
		colorItem._widget.item = colorItem
		colorItem._widget.connect('color-set', self.gridColorChanged)
		colorItem._widget.set_sensitive(ui.mcalGrid)
		####
		pack(self.optionsWidget, hbox)
		########
		frame = gtk.Frame(_('Calendars'))
		self.typeParamsVbox = gtk.VBox()
		frame.add(self.typeParamsVbox)
		frame.show_all()
		pack(self.optionsWidget, frame)
		self.optionsWidget.show_all()
		self.updateTypeParamsWidget()## FIXME
示例#52
0
 def __init__(self,
              event,
              typeChangable=True,
              title=None,
              isNew=False,
              parent=None,
              useSelectedDate=False):
     gtk.Dialog.__init__(self, parent=parent)
     #self.set_transient_for(None)
     #self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL)
     if title:
         self.set_title(title)
     self.isNew = isNew
     #self.connect('delete-event', lambda obj, e: self.destroy())
     #self.resize(800, 600)
     ###
     dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'),
                       gtk.RESPONSE_CANCEL)
     dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.RESPONSE_OK)
     ###
     self.connect('response', lambda w, e: self.hide())
     #######
     self.event = event
     self._group = event.parent
     self.activeWidget = None
     #######
     if isNew:
         event.timeZone = str(core.localTz)
     #######
     hbox = gtk.HBox()
     pack(hbox, gtk.Label(_('Event Type')))
     if typeChangable and len(self._group.acceptsEventTypes) > 1:  ## FIXME
         combo = gtk.combo_box_new_text()
         for eventType in self._group.acceptsEventTypes:
             combo.append_text(
                 event_lib.classes.event.byName[eventType].desc)
         pack(hbox, combo)
         ####
         combo.set_active(self._group.acceptsEventTypes.index(event.name))
         #self.activeWidget = makeWidget(event)
         combo.connect('changed', self.typeChanged)
         self.comboEventType = combo
     else:
         pack(hbox, gtk.Label(':  ' + event.desc))
     pack(hbox, gtk.Label(''), 1, 1)
     hbox.show_all()
     pack(self.vbox, hbox)
     #####
     if useSelectedDate:
         self.event.setJd(ui.cell.jd)
     self.activeWidget = makeWidget(event)
     if self.activeWidget:
         if self.isNew:
             self.activeWidget.focusSummary()
         pack(self.vbox, self.activeWidget, 1, 1)
     self.vbox.show()
示例#53
0
	def getDayTextData(self, i):
		n = len(self.wcal.status[i].eventsData)
		## item['show'][1] FIXME
		if n > 0:
			line = _('%s events')%_(n)
		else:
			line = ''
		return [
			(line, None),
		]
示例#54
0
	def updateMenu(self, start=None):
		self.createMenu()
		if start==None:
			start = self.active - self.height//2
		self.start = start
		for i in range(self.height):
			if start+i==self.active:
				self.menuLabels[i].set_label(self.getActiveStr(_(start+i)))
			else:
				self.menuLabels[i].set_label(_(start+i))
示例#55
0
    def authenticate(self):
        global auth_local_webserver
        import socket
        from oauth2client.file import Storage
        storage = Storage(self.authFile)
        credentials = storage.get()
        if credentials and not credentials.invalid:
            return credentials

        if auth_local_webserver:
            success = False
            port_number = 0
            for port in auth_host_port:
                port_number = port
                try:
                    httpd = ClientRedirectServer(
                        (auth_host_name, port),
                        ClientRedirectHandler,
                    )
                except socket.error as e:
                    pass
                else:
                    success = True
                    break
            auth_local_webserver = success

        if auth_local_webserver:
            oauth_callback = 'http://%s:%s/' % (auth_host_name, port_number)
        else:
            oauth_callback = 'oob'
        core.openUrl(self.flow.step1_get_authorize_url(oauth_callback))

        code = None
        if auth_local_webserver:
            httpd.handle_request()
            if 'error' in httpd.query_params:
                self.showError(_('Authentication request was rejected.'))
                return
            if 'code' in httpd.query_params:
                code = httpd.query_params['code']
            else:
                self.showError(
                    _('Failed to find "code" in the query parameters of the redirect.'
                      ))
                return
        else:
            code = self.askVerificationCode()
        try:
            credential = self.flow.step2_exchange(code)
        except Exception as e:
            self.showError(_('Authentication has failed') + ':\n%s' % e)
            return
        storage.put(credential)
        credential.set_store(storage)
        return credentials
示例#56
0
	def __init__(self):
		gtk.Dialog.__init__(self, title=_('Select Date...'))
		self.set_has_separator(False)
		#self.set_skip_taskbar_hint(True)
		self.connect('delete-event', self.hideMe)
		self.mode = calTypes.primary
		###### Reciving dropped day!
		self.drag_dest_set(gdk.MODIFIER_MASK,\
			(('a', 0, 0),), gdk.ACTION_COPY)
		self.drag_dest_add_text_targets()
		self.connect('drag-data-received', self.dragRec)
		######
		hb0 = gtk.HBox(spacing=4)
		pack(hb0, gtk.Label(_('Date Mode')))
		combo = CalTypeCombo()
		combo.set_active(self.mode)
		pack(hb0, combo)
		pack(self.vbox, hb0)
		#######################
		hbox = gtk.HBox(spacing=5)
		rb1 = gtk.RadioButton()
		rb1.num = 1
		pack(hbox, rb1)
		self.ymdBox = YearMonthDayBox()
		pack(hbox, self.ymdBox)
		pack(self.vbox, hbox)
		########
		hb2 = gtk.HBox(spacing=4)
		pack(hb2, gtk.Label('yyyy/mm/dd'))
		dateInput = DateButtonOption(hist_size=16)
		pack(hb2, dateInput)
		rb2 = gtk.RadioButton()
		rb2.num = 2
		rb2.set_group(rb1)
		hb2i = gtk.HBox(spacing=5)
		pack(hb2i, rb2)
		pack(hb2i, hb2)
		pack(self.vbox, hb2i)
		#######
		dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), 2, self.hideMe)
		dialog_add_button(self, gtk.STOCK_OK, _('_OK'), 1, self.ok)
		#######
		self.comboMode = combo
		self.dateInput = dateInput
		self.radio1 = rb1
		self.radio2 = rb2
		self.hbox2 = hb2
		#######
		combo.connect ('changed', self.comboModeChanged)
		rb1.connect_after('clicked', self.radioChanged)
		rb2.connect_after('clicked', self.radioChanged)
		dateInput.connect('activate', self.ok)
		self.radioChanged()
		#######
		self.vbox.show_all()
示例#57
0
	def updateWidget(self):
		self.activeTrees.clear()
		self.inactiveTrees.clear()
		##
		for mode in calTypes.active:
			module = calTypes[mode]
			self.activeTrees.append([module.name, _(module.desc)])
		##
		for mode in calTypes.inactive:
			module = calTypes[mode]
			self.inactiveTrees.append([module.name, _(module.desc)])
示例#58
0
		def __init__(self, win):
			gtk.VBox.__init__(self, spacing=20)
			self.win = win
			self.buttons = (
				(_('Back'), self.backClicked),
				(_('Close'), self.closeClicked),
			)
			####
			self.textview = gtk.TextView()
			pack(self, self.textview, 1, 1)
			####
			self.show_all()
示例#59
0
 def __init__(self, group):
     BaseWidgetClass.__init__(self, group)
     ####
     hbox = gtk.HBox()
     label = gtk.Label(_('Tag Description'))
     label.set_alignment(0, 0.5)
     self.sizeGroup.add_widget(label)
     pack(hbox, label)
     ##
     self.statCheck = gtk.CheckButton(_('Stat'))
     pack(hbox, self.statCheck)
     ##
     pack(self, hbox)
示例#60
0
文件: utils.py 项目: ilius/starcal2
def confirm(msg, parent=None):
    win = gtk.MessageDialog(
        parent=parent,
        flags=0,
        type=gtk.MESSAGE_INFO,
        buttons=gtk.BUTTONS_NONE,
        message_format=msg,
    )
    dialog_add_button(win, gtk.STOCK_CANCEL, _('_Cancel'), gtk.RESPONSE_CANCEL)
    dialog_add_button(win, gtk.STOCK_OK, _('_OK'), gtk.RESPONSE_OK)
    ok = win.run() == gtk.RESPONSE_OK
    win.destroy()
    return ok