def __init__(self): gtk.Dialog.__init__(self) self.set_title(_('Export')) self.vbox.set_spacing(10) #### 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() frame = gtk.Frame(_('Format')) radioBox = gtk.VBox() ## self.radioIcs = gtk.RadioButton(label='iCalendar') self.radioJsonCompact = gtk.RadioButton( label=_('Compact JSON (StarCalendar)'), group=self.radioIcs) self.radioJsonPretty = gtk.RadioButton( label=_('Pretty JSON (StarCalendar)'), group=self.radioIcs) ## pack(radioBox, self.radioJsonCompact) pack(radioBox, self.radioJsonPretty) pack(radioBox, self.radioIcs) ## self.radioJsonCompact.set_active(True) self.radioIcs.connect('clicked', self.formatRadioChanged) self.radioJsonCompact.connect('clicked', self.formatRadioChanged) self.radioJsonPretty.connect('clicked', self.formatRadioChanged) ## frame.add(radioBox) pack(hbox, frame) pack(hbox, gtk.Label(''), 1, 1) pack(self.vbox, hbox) ######## hbox = gtk.HBox(spacing=2) pack(hbox, gtk.Label(_('File') + ':')) self.fpathEntry = gtk.Entry() self.fpathEntry.set_text( join(deskDir, 'events-%.4d-%.2d-%.2d' % core.getSysDate(DATE_GREG))) pack(hbox, self.fpathEntry, 1, 1) pack(self.vbox, hbox) #### self.groupSelect = GroupsTreeCheckList() swin = gtk.ScrolledWindow() swin.add(self.groupSelect) swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) pack(self.vbox, swin, 1, 1) #### self.vbox.show_all() self.formatRadioChanged() self.resize(600, 600)
def __init__(self): gtk.Dialog.__init__(self) self.set_title(_('Export')) self.vbox.set_spacing(10) #### 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() frame = gtk.Frame(_('Format')) radioBox = gtk.VBox() ## self.radioIcs = gtk.RadioButton(label='iCalendar') self.radioJsonCompact = gtk.RadioButton(label=_('Compact JSON (StarCalendar)'), group=self.radioIcs) self.radioJsonPretty = gtk.RadioButton(label=_('Pretty JSON (StarCalendar)'), group=self.radioIcs) ## radioBox.pack_start(self.radioJsonCompact, 0, 0) radioBox.pack_start(self.radioJsonPretty, 0, 0) radioBox.pack_start(self.radioIcs, 0, 0) ## self.radioJsonCompact.set_active(True) self.radioIcs.connect('clicked', self.formatRadioChanged) self.radioJsonCompact.connect('clicked', self.formatRadioChanged) self.radioJsonPretty.connect('clicked', self.formatRadioChanged) ## frame.add(radioBox) hbox.pack_start(frame, 0, 0) hbox.pack_start(gtk.Label(''), 1, 1) self.vbox.pack_start(hbox, 0, 0) ######## hbox = gtk.HBox(spacing=2) hbox.pack_start(gtk.Label(_('File')+':'), 0, 0) self.fpathEntry = gtk.Entry() self.fpathEntry.set_text(join(deskDir, 'events-%.4d-%.2d-%.2d'%core.getSysDate())) hbox.pack_start(self.fpathEntry, 1, 1) self.vbox.pack_start(hbox, 0, 0) #### self.groupSelect = GroupsTreeCheckList() swin = gtk.ScrolledWindow() swin.add(self.groupSelect) swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.vbox.pack_start(swin, 1, 1) #### self.vbox.show_all() self.formatRadioChanged() self.resize(600, 600)
class MultiGroupExportDialog(gtk.Dialog): def __init__(self): gtk.Dialog.__init__(self) self.set_title(_('Export')) self.vbox.set_spacing(10) #### 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() frame = gtk.Frame(_('Format')) radioBox = gtk.VBox() ## self.radioIcs = gtk.RadioButton(label='iCalendar') self.radioJsonCompact = gtk.RadioButton(label=_('Compact JSON (StarCalendar)'), group=self.radioIcs) self.radioJsonPretty = gtk.RadioButton(label=_('Pretty JSON (StarCalendar)'), group=self.radioIcs) ## radioBox.pack_start(self.radioJsonCompact, 0, 0) radioBox.pack_start(self.radioJsonPretty, 0, 0) radioBox.pack_start(self.radioIcs, 0, 0) ## self.radioJsonCompact.set_active(True) self.radioIcs.connect('clicked', self.formatRadioChanged) self.radioJsonCompact.connect('clicked', self.formatRadioChanged) self.radioJsonPretty.connect('clicked', self.formatRadioChanged) ## frame.add(radioBox) hbox.pack_start(frame, 0, 0) hbox.pack_start(gtk.Label(''), 1, 1) self.vbox.pack_start(hbox, 0, 0) ######## hbox = gtk.HBox(spacing=2) hbox.pack_start(gtk.Label(_('File')+':'), 0, 0) self.fpathEntry = gtk.Entry() self.fpathEntry.set_text(join(deskDir, 'events-%.4d-%.2d-%.2d'%core.getSysDate())) hbox.pack_start(self.fpathEntry, 1, 1) self.vbox.pack_start(hbox, 0, 0) #### self.groupSelect = GroupsTreeCheckList() swin = gtk.ScrolledWindow() swin.add(self.groupSelect) swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.vbox.pack_start(swin, 1, 1) #### self.vbox.show_all() self.formatRadioChanged() self.resize(600, 600) def formatRadioChanged(self, widget=None): #self.dateRangeBox.set_visible(self.radioIcs.get_active()) ### fpath = self.fpathEntry.get_text() if fpath: fpath_nox, ext = splitext(fpath) if fpath_nox: if self.radioIcs.get_active(): if ext != '.ics': ext = '.ics' else: if ext != '.json': ext = '.json' self.fpathEntry.set_text(fpath_nox + ext) def save(self): fpath = self.fpathEntry.get_text() activeGroupIds = self.groupSelect.getValue() if self.radioIcs.get_active(): ui.eventGroups.exportToIcs(fpath, activeGroupIds) else: data = ui.eventGroups.exportData(activeGroupIds) ## what to do with all groupData['info'] s? FIXME if self.radioJsonCompact.get_active(): text = dataToCompactJson(data) elif self.radioJsonPretty.get_active(): text = dataToPrettyJson(data) else: raise RuntimeError open(fpath, 'w').write(text) def run(self): if gtk.Dialog.run(self)==gtk.RESPONSE_OK: self.save() self.destroy()
class MultiGroupExportDialog(gtk.Dialog): def __init__(self): gtk.Dialog.__init__(self) self.set_title(_('Export')) self.vbox.set_spacing(10) #### 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() frame = gtk.Frame(_('Format')) radioBox = gtk.VBox() ## self.radioIcs = gtk.RadioButton(label='iCalendar') self.radioJsonCompact = gtk.RadioButton( label=_('Compact JSON (StarCalendar)'), group=self.radioIcs) self.radioJsonPretty = gtk.RadioButton( label=_('Pretty JSON (StarCalendar)'), group=self.radioIcs) ## pack(radioBox, self.radioJsonCompact) pack(radioBox, self.radioJsonPretty) pack(radioBox, self.radioIcs) ## self.radioJsonCompact.set_active(True) self.radioIcs.connect('clicked', self.formatRadioChanged) self.radioJsonCompact.connect('clicked', self.formatRadioChanged) self.radioJsonPretty.connect('clicked', self.formatRadioChanged) ## frame.add(radioBox) pack(hbox, frame) pack(hbox, gtk.Label(''), 1, 1) pack(self.vbox, hbox) ######## hbox = gtk.HBox(spacing=2) pack(hbox, gtk.Label(_('File') + ':')) self.fpathEntry = gtk.Entry() self.fpathEntry.set_text( join(deskDir, 'events-%.4d-%.2d-%.2d' % core.getSysDate(DATE_GREG))) pack(hbox, self.fpathEntry, 1, 1) pack(self.vbox, hbox) #### self.groupSelect = GroupsTreeCheckList() swin = gtk.ScrolledWindow() swin.add(self.groupSelect) swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) pack(self.vbox, swin, 1, 1) #### self.vbox.show_all() self.formatRadioChanged() self.resize(600, 600) def formatRadioChanged(self, widget=None): #self.dateRangeBox.set_visible(self.radioIcs.get_active()) ### fpath = self.fpathEntry.get_text() if fpath: fpath_nox, ext = splitext(fpath) if fpath_nox: if self.radioIcs.get_active(): if ext != '.ics': ext = '.ics' else: if ext != '.json': ext = '.json' self.fpathEntry.set_text(fpath_nox + ext) def save(self): fpath = self.fpathEntry.get_text() activeGroupIds = self.groupSelect.getValue() if self.radioIcs.get_active(): ui.eventGroups.exportToIcs(fpath, activeGroupIds) else: data = ui.eventGroups.exportData(activeGroupIds) ## what to do with all groupData['info'] s? FIXME if self.radioJsonCompact.get_active(): text = dataToCompactJson(data) elif self.radioJsonPretty.get_active(): text = dataToPrettyJson(data) else: raise RuntimeError open(fpath, 'w').write(text) def run(self): if gtk.Dialog.run(self) == gtk.RESPONSE_OK: self.save() self.destroy()