From 1b9bb894c364dea30282ca8626baba927774e302 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Mon, 26 Nov 2007 21:53:58 +0000 Subject: [PATCH] 2007-11-26 Benny Malengier * src/plugins/NarrativeWeb.py: new select contact-header-footer-intro * src/GrampsWidgets.py: widget for new select svn: r9414 --- ChangeLog | 4 + src/GrampsWidgets.py | 1 + src/plugins/NarrativeWeb.py | 304 ++++++++++++++++++++---------------- 3 files changed, 172 insertions(+), 137 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4302a1a61..98c952f4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-11-26 Benny Malengier + * src/plugins/NarrativeWeb.py: new select contact-header-footer-intro + * src/GrampsWidgets.py: widget for new select + 2007-11-26 Jim Sack * src/plugins/ReadPkg.py : reverted previous change better to leave it broken than to risk worse diff --git a/src/GrampsWidgets.py b/src/GrampsWidgets.py index 5822f0667..d3db32cf9 100644 --- a/src/GrampsWidgets.py +++ b/src/GrampsWidgets.py @@ -867,6 +867,7 @@ class ObjEntry: if self.get_val(): self.set_val(None) self.label.set_text(self.EMPTY_TEXT) + self.label.set_use_markup(True) self.set_button(False) else: select = self.call_selector() diff --git a/src/plugins/NarrativeWeb.py b/src/plugins/NarrativeWeb.py index e8c9522d9..1efb5f1bd 100644 --- a/src/plugins/NarrativeWeb.py +++ b/src/plugins/NarrativeWeb.py @@ -167,8 +167,10 @@ class BasePage: self.showspouse = options.handler.options_dict['NWEBshowspouse'] self.showparents = options.handler.options_dict['NWEBshowparents'] self.showhalfsiblings = options.handler.options_dict['NWEBshowhalfsiblings'] - self.use_intro = options.handler.options_dict['NWEBintronote'] != u"" - self.use_contact = options.handler.options_dict['NWEBcontact'] != u"" + self.use_intro = options.handler.options_dict['NWEBintronote'] != u""\ + or options.handler.options_dict['NWEBintropic'] != u"" + self.use_contact = options.handler.options_dict['NWEBcontact'] != u""\ + or options.handler.options_dict['NWEBcontactpic'] != u"" self.use_gallery = options.handler.options_dict['NWEBgallery'] self.header = options.handler.options_dict['NWEBheader'] self.footer = options.handler.options_dict['NWEBfooter'] @@ -292,14 +294,10 @@ class BasePage: of.write('
\n') of.write('\n') if self.footer: - obj = db.get_object_from_handle(self.footer) - if obj: - notelist = obj.get_note_list() - if notelist: - note = db.get_note_from_handle(notelist[0]) - of.write('\n') + note = db.get_note_from_handle(self.footer) + of.write('\n') of.write('\n') of.write('\n') @@ -330,14 +328,10 @@ class BasePage: of.write('\n') of.write('\n') if self.header: - obj = db.get_object_from_handle(self.header) - if obj: - notelist = obj.get_note_list() - if notelist: - note = db.get_note_from_handle(notelist[0]) - of.write('
\n') - of.write(note.get(markup=True)) - of.write('
\n') + note = db.get_note_from_handle(self.header) + of.write('
\n') + of.write(note.get(markup=True)) + of.write('
\n') of.write('\n') of.write('
\n') - if obj: - nobj = obj.get_note_object() - if nobj: - format = nobj.get_format() - text = nobj.get(markup=True) - - if format: - text = u"
%s
" % text - else: - text = u"
".join(text.split("\n")) - of.write('

%s

\n' % text) + if note_id: + note_obj = db.get_note_from_handle(note_id) + text = note_obj.get(markup=True) + if note_obj.get_format(): + text = u"
%s
" % text + else: + text = u"
".join(text.split("\n")) + of.write('

%s

\n' % text) of.write('\n') @@ -2412,12 +2403,14 @@ class WebReport(Report): self.title = options.handler.options_dict['NWEBtitle'] self.sort = Sort.Sort(self.database) self.inc_gallery = options.handler.options_dict['NWEBgallery'] - self.inc_contact = options.handler.options_dict['NWEBcontact'] != u"" + self.inc_contact = options.handler.options_dict['NWEBcontact'] != u""\ + or options.handler.options_dict['NWEBcontactpic'] != u"" self.inc_download = options.handler.options_dict['NWEBdownload'] - self.user_header = options.handler.options_dict['NWEBheader'] - self.user_footer = options.handler.options_dict['NWEBfooter'] + #self.user_header = options.handler.options_dict['NWEBheader'] + #self.user_footer = options.handler.options_dict['NWEBfooter'] self.use_archive = options.handler.options_dict['NWEBarchive'] - self.use_intro = options.handler.options_dict['NWEBintronote'] != u"" + self.use_intro = options.handler.options_dict['NWEBintronote'] != u""\ + or options.handler.options_dict['NWEBintropic'] != u"" self.use_home = options.handler.options_dict['NWEBhomenote'] != u"" or\ options.handler.options_dict['NWEBhomepic'] != u"" @@ -2695,6 +2688,7 @@ class WebReportOptions(ReportOptions): 'NWEBshowparents' : 0, 'NWEBshowhalfsiblings' : 0, 'NWEBcontact' : '', + 'NWEBcontactpic' : '', 'NWEBgallery' : 1, 'NWEBheader' : '', 'NWEBfooter' : '', @@ -2705,8 +2699,9 @@ class WebReportOptions(ReportOptions): 'NWEBencoding' : 'utf-8', 'NWEBcss' : 'main0.css', 'NWEBintronote' : '', + 'NWEBintropic' : '', 'NWEBhomenote' : '', - 'NWEBhomepic' : '', + 'NWEBhomepic' : '', } self.options_help = { @@ -2718,7 +2713,8 @@ class WebReportOptions(ReportOptions): death_msg = _("Years from death to consider living") title_msg = _("Web site title") ext_msg = _("File extension") - contact_msg = _("Publisher contact/Note ID") + contact_msg = _("Publisher contact note") + contactpic_msg = _("Publisher contact image") gallery_msg = _("Include images and media objects") download_msg = _("Include download page") graph_msg = _("Include ancestor graph") @@ -2791,9 +2787,6 @@ class WebReportOptions(ReportOptions): # 1 -- no living images, but some images # 2 -- any images - self.intro_note = gtk.Entry() - self.intro_note.set_text(self.options_dict['NWEBintronote']) - self.title = gtk.Entry() self.title.set_text(self.options_dict['NWEBtitle']) @@ -2853,25 +2846,6 @@ class WebReportOptions(ReportOptions): title = _("Page Generation") - media_list = [['','']] - html_list = [['','']] - - #Page Generation tab - if self.db: - cursor = self.db.get_media_cursor() - data = cursor.first() - while data: - (handle, value) = data - if not value[3]: - #no mime type - html_list.append([value[4],handle]) - media_list.append([value[4],handle]) - - data = cursor.next() - cursor.close() - media_list.sort(lambda x, y: locale.strcoll(x[0], y[0])) - html_list.sort(lambda x, y: locale.strcoll(x[0], y[0])) - self.home_nt_box, self.home_nt_label, self.home_nt_share_btn \ = mk_object_entry() self.home_note = GrampsWidgets.NoteEntry(dialog.dbstate, @@ -2886,23 +2860,66 @@ class WebReportOptions(ReportOptions): self.home_pic_label, self.set_home_pic_val, self.get_home_pic_val, None, self.home_pic_share_btn) - self.intro_note = mk_combobox(media_list,self.options_dict['NWEBintronote']) - self.contact = mk_combobox(media_list,self.options_dict['NWEBcontact']) - self.header = mk_combobox(html_list,self.options_dict['NWEBheader']) - self.footer = mk_combobox(html_list,self.options_dict['NWEBfooter']) + self.intro_nt_box, self.intro_nt_label, self.intro_nt_share_btn \ + = mk_object_entry() + self.intro_note = GrampsWidgets.NoteEntry(dialog.dbstate, + dialog.uistate, dialog.track, + self.intro_nt_label, + self.set_intro_nt_val, self.get_intro_nt_val, + None, self.intro_nt_share_btn) + self.intro_pic_box, self.intro_pic_label, self.intro_pic_share_btn \ + = mk_object_entry() + self.intro_pic = GrampsWidgets.MediaEntry(dialog.dbstate, + dialog.uistate, dialog.track, + self.intro_pic_label, + self.set_intro_pic_val, self.get_intro_pic_val, + None, self.intro_pic_share_btn) + self.contact_nt_box, self.contact_nt_label, self.contact_nt_share_btn \ + = mk_object_entry() + self.contact = GrampsWidgets.NoteEntry(dialog.dbstate, + dialog.uistate, dialog.track, + self.contact_nt_label, + self.set_contact_nt_val, self.get_contact_nt_val, + None, self.contact_nt_share_btn) + self.contact_pic_box, self.contact_pic_label, \ + self.contact_pic_share_btn = mk_object_entry() + self.contact_pic = GrampsWidgets.MediaEntry(dialog.dbstate, + dialog.uistate, dialog.track, + self.contact_pic_label, + self.set_contact_pic_val, self.get_contact_pic_val, + None, self.contact_pic_share_btn) + self.header_nt_box, self.header_nt_label, self.header_nt_share_btn \ + = mk_object_entry() + self.header = GrampsWidgets.NoteEntry(dialog.dbstate, + dialog.uistate, dialog.track, + self.header_nt_label, + self.set_header_nt_val, self.get_header_nt_val, + None, self.header_nt_share_btn) + self.footer_nt_box, self.footer_nt_label, self.footer_nt_share_btn \ + = mk_object_entry() + self.footer = GrampsWidgets.NoteEntry(dialog.dbstate, + dialog.uistate, dialog.track, + self.footer_nt_label, + self.set_footer_nt_val, self.get_footer_nt_val, + None, self.footer_nt_share_btn) dialog.add_frame_option(title,_('Home Page note'), self.home_nt_box) dialog.add_frame_option(title,_('Home Page image'), self.home_pic_box) - dialog.add_frame_option(title,_('Introduction Media/Note ID'), - self.intro_note) - dialog.add_frame_option(title,contact_msg,self.contact) - dialog.add_frame_option(title,_('HTML user header'),self.header) - dialog.add_frame_option(title,_('HTML user footer'),self.footer) - dialog.add_frame_option(title,'',self.include_gallery) - dialog.add_frame_option(title,None,self.inc_download) - dialog.add_frame_option(title,None,self.noid) + dialog.add_frame_option(title,_('Introduction Note'), + self.intro_nt_box) + dialog.add_frame_option(title,_('Introduction image'), + self.intro_pic_box) + dialog.add_frame_option(title, contact_msg, self.contact_nt_box) + dialog.add_frame_option(title, contactpic_msg, self.contact_pic_box) + dialog.add_frame_option(title, _('HTML user header'), + self.header_nt_box) + dialog.add_frame_option(title, _('HTML user footer'), + self.footer_nt_box) + dialog.add_frame_option(title, '', self.include_gallery) + dialog.add_frame_option(title, None, self.inc_download) + dialog.add_frame_option(title, None, self.noid) title = _("Privacy") dialog.add_frame_option(title,None,self.no_private) @@ -2917,39 +2934,70 @@ class WebReportOptions(ReportOptions): dialog.add_frame_option(title,None,self.showparents) dialog.add_frame_option(title,None,self.showhalfsiblings) - def set_home_nt_val(self, val): + def set_nt_val(self, opt, val): ''' store the note handle in options ''' if val is None: - self.options_dict['NWEBhomenote'] = u'' + self.options_dict[opt] = u'' else: - self.options_dict['NWEBhomenote'] = unicode(val) + self.options_dict[opt] = unicode(val) + + def get_nt_val(self, opt): + ''' obtain note handle + ''' + val = self.options_dict[opt] + if val == "": + return None + else: + return val + + def set_home_nt_val(self, val): + self.set_nt_val('NWEBhomenote', val) def get_home_nt_val(self): - ''' obtain note handle - ''' - val = self.options_dict['NWEBhomenote'] - if val == "": - return None - else: - return val + return self.get_nt_val('NWEBhomenote') def set_home_pic_val(self, val): - ''' store the media handle in options - ''' - if val is None: - self.options_dict['NWEBhomepic'] = u'' - else: - self.options_dict['NWEBhomepic'] = unicode(val) + self.set_nt_val('NWEBhomepic', val) def get_home_pic_val(self): - ''' obtain note handle - ''' - val = self.options_dict['NWEBhomepic'] - if val == "": - return None - else: - return val + return self.get_nt_val('NWEBhomepic') + + def set_intro_nt_val(self, val): + self.set_nt_val('NWEBintronote', val) + + def get_intro_nt_val(self): + return self.get_nt_val('NWEBintronote') + + def set_intro_pic_val(self, val): + self.set_nt_val('NWEBintropic', val) + + def get_intro_pic_val(self): + return self.get_nt_val('NWEBintropic') + + def set_contact_nt_val(self, val): + self.set_nt_val('NWEBcontact', val) + + def get_contact_nt_val(self): + return self.get_nt_val('NWEBcontact') + + def set_contact_pic_val(self, val): + self.set_nt_val('NWEBcontactpic', val) + + def get_contact_pic_val(self): + return self.get_nt_val('NWEBcontactpic') + + def set_header_nt_val(self, val): + self.set_nt_val('NWEBheader', val) + + def get_header_nt_val(self): + return self.get_nt_val('NWEBheader') + + def set_footer_nt_val(self, val): + self.set_nt_val('NWEBfooter', val) + + def get_footer_nt_val(self): + return self.get_nt_val('NWEBfooter') def parse_user_options(self, dialog): """Parse the privacy options frame of the dialog. Save the @@ -2961,7 +3009,6 @@ class WebReportOptions(ReportOptions): int(self.restrict_years.get_text()) self.options_dict['NWEBincpriv'] = int(not self.no_private.get_active()) self.options_dict['NWEBnoid'] = int(self.noid.get_active()) - self.options_dict['NWEBcontact'] = unicode(self.contact.get_handle()) self.options_dict['NWEBlinkhome'] = int(self.linkhome.get_active()) self.options_dict['NWEBshowbirth'] = int(self.showbirth.get_active()) self.options_dict['NWEBshowdeath'] = int(self.showdeath.get_active()) @@ -2969,11 +3016,8 @@ class WebReportOptions(ReportOptions): self.options_dict['NWEBshowparents'] = int(self.showparents.get_active()) self.options_dict['NWEBshowhalfsiblings'] = int(self.showhalfsiblings.get_active()) self.options_dict['NWEBgallery'] = int(self.include_gallery.get_active()) - self.options_dict['NWEBheader'] = unicode(self.header.get_handle()) - self.options_dict['NWEBfooter'] = unicode(self.footer.get_handle()) self.options_dict['NWEBdownload'] = int(self.inc_download.get_active()) self.options_dict['NWEBtitle'] = unicode(self.title.get_text()) - self.options_dict['NWEBintronote'] = unicode(self.intro_note.get_handle()) self.options_dict['NWEBgraph'] = int(self.inc_graph.get_active()) index = self.graph_gens.get_active() @@ -3228,20 +3272,6 @@ class GrampsNoteComboBox(gtk.ComboBox): handle = self.local_store.get_value(active,1) return handle -def mk_combobox(media_list,select_value): - store = gtk.ListStore(str,str) - node = None - - for data in media_list: - if data[1] == select_value: - node = store.append(row=data) - else: - store.append(row=data) - widget = GrampsNoteComboBox(store,node) - if len(media_list) == 0: - widget.set_sensitive(False) - return widget - def mk_object_entry(): ''' return a vbox widget with fields for object selection '''