Ejemplo n.º 1
0
	def makeRuleHbox(self, rule):
		hbox = gtk.HBox(spacing=5)
		lab = gtk.Label(rule.desc)
		lab.set_alignment(0, 0.5)
		pack(hbox, lab)
		self.groups[rule.sgroup].add_widget(lab)
		#pack(hbox, gtk.Label(''), 1, 1)
		inputWidget = makeWidget(rule)
		if not inputWidget:
			print('failed to create inpout widget for rule %s'%rule.name)
			return
		if rule.expand:
			pack(hbox, inputWidget, 1, 1)
		else:
			pack(hbox, inputWidget)
			pack(hbox, gtk.Label(''), 1, 1)
		####
		removeButton = gtk.Button(stock=gtk.STOCK_REMOVE)
		if ui.autoLocale:
			removeButton.set_label(_('_Remove'))
			removeButton.set_image(gtk.Image.new_from_stock(gtk.STOCK_REMOVE, gtk.IconSize.BUTTON))
		removeButton.connect('clicked', self.removeButtonClicked, hbox)## FIXME
		pack(hbox, removeButton)
		####
		hbox.inputWidget = inputWidget
		hbox.removeButton = removeButton
		return hbox
Ejemplo n.º 2
0
 def __init__(self, event):
     gtk.Expander.__init__(self)
     self.set_label(_('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)
Ejemplo n.º 3
0
 def __init__(self, event, typeChangable=True, isNew=False, useSelectedDate=False, **kwargs):
     checkEventsReadOnly()
     gtk.Dialog.__init__(self, **kwargs)
     #self.set_transient_for(None)
     #self.set_type_hint(gdk.WindowTypeHint.NORMAL)
     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.ResponseType.CANCEL)
     dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.ResponseType.OK)
     ###
     self.connect('response', lambda w, e: self.hide())
     ###
     self.activeWidget = None
     self._group = event.parent
     self.eventTypeOptions = list(self._group.acceptsEventTypes)
     ####
     if not event.name in self.eventTypeOptions:
         self.eventTypeOptions.append(event.name)
     eventTypeIndex = self.eventTypeOptions.index(event.name)
     ####
     self.event = event
     #######
     if isNew and not event.timeZone:
         event.timeZone = str(core.localTz)## why? FIXME
     #######
     hbox = gtk.HBox()
     pack(hbox, gtk.Label(
         _('Group') + ': ' + self._group.title
     ))
     hbox.show_all()
     pack(self.vbox, hbox)
     #######
     hbox = gtk.HBox()
     pack(hbox, gtk.Label(_('Event Type')))
     if typeChangable:
         combo = gtk.ComboBoxText()
         for tmpEventType in self.eventTypeOptions:
             combo.append_text(event_lib.classes.event.byName[tmpEventType].desc)
         pack(hbox, combo)
         ####
         combo.set_active(eventTypeIndex)
         ####
         #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.isNew:
         self.activeWidget.focusSummary()
     pack(self.vbox, self.activeWidget, 1, 1)
     self.vbox.show()
Ejemplo n.º 4
0
 def __init__(self, event):
     gtk.Expander.__init__(self)
     self.set_label(_('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)
Ejemplo n.º 5
0
 def typeChanged(self, combo):
     if self.activeWidget:
         self.activeWidget.updateVars()
         self.activeWidget.destroy()
     eventType = self.eventTypeOptions[combo.get_active()]
     if self.isNew:
         self.event = self._group.createEvent(eventType)
     else:
         self.event = self._group.copyEventWithType(self.event, eventType)
     self._group.updateCache(self.event)  ## needed? FIXME
     self.activeWidget = makeWidget(self.event)
     if self.isNew:
         self.activeWidget.focusSummary()
     pack(self.vbox, self.activeWidget, 1, 1)
Ejemplo n.º 6
0
 def typeChanged(self, combo):
     if self.activeWidget:
         self.activeWidget.updateVars()
         self.activeWidget.destroy()
     eventType = self.eventTypeOptions[combo.get_active()]
     if self.isNew:
         self.event = self._group.createEvent(eventType)
     else:
         self.event = self._group.copyEventWithType(self.event, eventType)
     self._group.updateCache(self.event)## needed? FIXME
     self.activeWidget = makeWidget(self.event)
     if self.isNew:
         self.activeWidget.focusSummary()
     pack(self.vbox, self.activeWidget)
Ejemplo n.º 7
0
	def typeChanged(self, combo=None):
		if self.activeWidget:
			self.activeWidget.updateVars()
			self.activeWidget.destroy()
		cls = event_lib.classes.account[self.comboType.get_active()]
		account = cls()
		if self.account:
			account.copyFrom(self.account)
			account.setId(self.account.id)
			del self.account
		if self.isNew:
			account.title = cls.desc ## FIXME
		self.account = account
		self.activeWidget = makeWidget(account)
		pack(self.vbox, self.activeWidget)
Ejemplo n.º 8
0
 def typeChanged(self, combo=None):
     if self.activeWidget:
         self.activeWidget.updateVars()
         self.activeWidget.destroy()
     cls = event_lib.classes.account[self.comboType.get_active()]
     account = cls()
     if self.account:
         account.copyFrom(self.account)
         account.setId(self.account.id)
         del self.account
     if self.isNew:
         account.title = cls.desc  ## FIXME
     self.account = account
     self.activeWidget = makeWidget(account)
     pack(self.vbox, self.activeWidget)
Ejemplo n.º 9
0
	def typeChanged(self, combo=None):
		if self.activeWidget:
			self.activeWidget.updateVars()
			self.activeWidget.destroy()
		cls = event_lib.classes.group[self.comboType.get_active()]
		group = cls()
		if self.isNew:
			group.setRandomColor()
			if group.icon:
				self._group.icon = group.icon
		if not self.isNew:
			group.copyFrom(self._group)
		group.setId(self._group.id)
		if self.isNew:
			group.title = self.getNewGroupTitle(cls.desc)
		self._group = group
		self.activeWidget = makeWidget(group)
		pack(self.vbox, self.activeWidget)
Ejemplo n.º 10
0
	def typeChanged(self, combo=None):
		if self.activeWidget:
			self.activeWidget.updateVars()
			self.activeWidget.destroy()
		cls = event_lib.classes.group[self.comboType.get_active()]
		group = cls()
		if self.isNew:
			group.setRandomColor()
			if group.icon:
				self._group.icon = group.icon
		if not self.isNew:
			group.copyFrom(self._group)
		group.setId(self._group.id)
		if self.isNew:
			group.title = self.getNewGroupTitle(cls.desc)
		self._group = group
		self.activeWidget = makeWidget(group)
		pack(self.vbox, self.activeWidget)