2007-07-18 Don Allingham <don@gramps-project.org>
* src/ReportBase/_StyleEditor.py: get rid of Utils.destroy_passed_object * src/Utils.py: Remove unused functions * src/ScratchPad.py: get_note removal svn: r8741
This commit is contained in:
parent
7ce0cc4eef
commit
f3d39e5f33
@ -1,3 +1,8 @@
|
|||||||
|
2007-07-18 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/ReportBase/_StyleEditor.py: get rid of Utils.destroy_passed_object
|
||||||
|
* src/Utils.py: Remove unused functions
|
||||||
|
* src/ScratchPad.py: get_note removal
|
||||||
|
|
||||||
2007-07-18 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
|
2007-07-18 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
|
||||||
* src/MarkupText.py: improved xml generator
|
* src/MarkupText.py: improved xml generator
|
||||||
* src/docgen/GtkPrint.py: fix svn proplist
|
* src/docgen/GtkPrint.py: fix svn proplist
|
||||||
|
@ -67,7 +67,7 @@ class StyleListDisplay:
|
|||||||
add, edit, and delete styles from a StyleSheet.
|
add, edit, and delete styles from a StyleSheet.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,stylesheetlist,callback,parent_window):
|
def __init__(self, stylesheetlist, callback, parent_window):
|
||||||
"""
|
"""
|
||||||
Creates a StyleListDisplay object that displays the styles in the
|
Creates a StyleListDisplay object that displays the styles in the
|
||||||
StyleSheet.
|
StyleSheet.
|
||||||
@ -78,7 +78,7 @@ class StyleListDisplay:
|
|||||||
self.callback = callback
|
self.callback = callback
|
||||||
|
|
||||||
self.sheetlist = stylesheetlist
|
self.sheetlist = stylesheetlist
|
||||||
self.top = gtk.glade.XML(const.gladeFile,"styles","gramps")
|
self.top = gtk.glade.XML(const.gladeFile, "styles", "gramps")
|
||||||
self.window = self.top.get_widget('styles')
|
self.window = self.top.get_widget('styles')
|
||||||
|
|
||||||
ManagedWindow.set_titles( self.window,
|
ManagedWindow.set_titles( self.window,
|
||||||
@ -86,7 +86,7 @@ class StyleListDisplay:
|
|||||||
_('Document Styles') )
|
_('Document Styles') )
|
||||||
|
|
||||||
self.top.signal_autoconnect({
|
self.top.signal_autoconnect({
|
||||||
"destroy_passed_object" : Utils.destroy_passed_object,
|
"destroy_passed_object" : self.__close,
|
||||||
"on_ok_clicked" : self.on_ok_clicked,
|
"on_ok_clicked" : self.on_ok_clicked,
|
||||||
"on_add_clicked" : self.on_add_clicked,
|
"on_add_clicked" : self.on_add_clicked,
|
||||||
"on_delete_clicked" : self.on_delete_clicked,
|
"on_delete_clicked" : self.on_delete_clicked,
|
||||||
@ -99,13 +99,16 @@ class StyleListDisplay:
|
|||||||
title_label.set_use_markup(True)
|
title_label.set_use_markup(True)
|
||||||
|
|
||||||
self.list = ListModel.ListModel(self.top.get_widget("list"),
|
self.list = ListModel.ListModel(self.top.get_widget("list"),
|
||||||
[(_('Style'),-1,10)],)
|
[(_('Style'), -1, 10)], )
|
||||||
self.redraw()
|
self.redraw()
|
||||||
if parent_window:
|
if parent_window:
|
||||||
self.window.set_transient_for(parent_window)
|
self.window.set_transient_for(parent_window)
|
||||||
self.window.run()
|
self.window.run()
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
|
||||||
|
def __close(self, obj):
|
||||||
|
self.top.destroy()
|
||||||
|
|
||||||
def redraw(self):
|
def redraw(self):
|
||||||
"""Redraws the list of styles that are current available"""
|
"""Redraws the list of styles that are current available"""
|
||||||
|
|
||||||
@ -119,47 +122,47 @@ class StyleListDisplay:
|
|||||||
self.list.add([style])
|
self.list.add([style])
|
||||||
index = index + 1
|
index = index + 1
|
||||||
|
|
||||||
def on_add_clicked(self,obj):
|
def on_add_clicked(self, obj):
|
||||||
"""Called with the ADD button is clicked. Invokes the StyleEditor to
|
"""Called with the ADD button is clicked. Invokes the StyleEditor to
|
||||||
create a new style"""
|
create a new style"""
|
||||||
style = self.sheetlist.get_style_sheet("default")
|
style = self.sheetlist.get_style_sheet("default")
|
||||||
StyleEditor("New Style",style,self)
|
StyleEditor("New Style", style, self)
|
||||||
|
|
||||||
def on_ok_clicked(self,obj):
|
def on_ok_clicked(self, obj):
|
||||||
"""Called with the OK button is clicked; Calls the callback task,
|
"""Called with the OK button is clicked; Calls the callback task,
|
||||||
then saves the stylesheet."""
|
then saves the stylesheet."""
|
||||||
self.callback()
|
self.callback()
|
||||||
try:
|
try:
|
||||||
self.sheetlist.save()
|
self.sheetlist.save()
|
||||||
except IOError,msg:
|
except IOError, msg:
|
||||||
from QuestionDialog import ErrorDialog
|
from QuestionDialog import ErrorDialog
|
||||||
ErrorDialog(_("Error saving stylesheet"),str(msg))
|
ErrorDialog(_("Error saving stylesheet"), str(msg))
|
||||||
except:
|
except:
|
||||||
log.error("Failed to save stylesheet",exc_info=True)
|
log.error("Failed to save stylesheet", exc_info=True)
|
||||||
|
|
||||||
def on_button_press(self,obj,event):
|
def on_button_press(self, obj, event):
|
||||||
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
||||||
self.on_edit_clicked(obj)
|
self.on_edit_clicked(obj)
|
||||||
|
|
||||||
def on_edit_clicked(self,obj):
|
def on_edit_clicked(self, obj):
|
||||||
"""
|
"""
|
||||||
Called with the EDIT button is clicked.
|
Called with the EDIT button is clicked.
|
||||||
Calls the StyleEditor to edit the selected style.
|
Calls the StyleEditor to edit the selected style.
|
||||||
"""
|
"""
|
||||||
store,node = self.list.selection.get_selected()
|
store, node = self.list.selection.get_selected()
|
||||||
if not node:
|
if not node:
|
||||||
return
|
return
|
||||||
|
|
||||||
name = self.list.model.get_value(node,0)
|
name = self.list.model.get_value(node, 0)
|
||||||
style = self.sheetlist.get_style_sheet(name)
|
style = self.sheetlist.get_style_sheet(name)
|
||||||
StyleEditor(name,style,self)
|
StyleEditor(name, style, self)
|
||||||
|
|
||||||
def on_delete_clicked(self,obj):
|
def on_delete_clicked(self, obj):
|
||||||
"""Deletes the selected style."""
|
"""Deletes the selected style."""
|
||||||
store,node = self.list.selection.get_selected()
|
store, node = self.list.selection.get_selected()
|
||||||
if not node:
|
if not node:
|
||||||
return
|
return
|
||||||
name = self.list.model.get_value(node,0)
|
name = self.list.model.get_value(node, 0)
|
||||||
self.sheetlist.delete_style_sheet(name)
|
self.sheetlist.delete_style_sheet(name)
|
||||||
self.redraw()
|
self.redraw()
|
||||||
|
|
||||||
@ -174,7 +177,7 @@ class StyleEditor:
|
|||||||
of the paragraphs in the style to be altered.
|
of the paragraphs in the style to be altered.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,name,style,parent):
|
def __init__(self, name, style, parent):
|
||||||
"""
|
"""
|
||||||
Creates the StyleEditor.
|
Creates the StyleEditor.
|
||||||
|
|
||||||
@ -187,11 +190,11 @@ class StyleEditor:
|
|||||||
|
|
||||||
self.style = BaseDoc.StyleSheet(style)
|
self.style = BaseDoc.StyleSheet(style)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.top = gtk.glade.XML(const.gladeFile,"editor","gramps")
|
self.top = gtk.glade.XML(const.gladeFile, "editor", "gramps")
|
||||||
|
|
||||||
self.top.signal_autoconnect({
|
self.top.signal_autoconnect({
|
||||||
"on_save_style_clicked" : self.on_save_style_clicked,
|
"on_save_style_clicked" : self.on_save_style_clicked,
|
||||||
"destroy_passed_object" : Utils.destroy_passed_object
|
"destroy_passed_object" : self.__close,
|
||||||
})
|
})
|
||||||
|
|
||||||
self.window = self.top.get_widget("editor")
|
self.window = self.top.get_widget("editor")
|
||||||
@ -204,18 +207,18 @@ class StyleEditor:
|
|||||||
|
|
||||||
self.first = 1
|
self.first = 1
|
||||||
|
|
||||||
titles = [(_('Paragraph'),0,130)]
|
titles = [(_('Paragraph'), 0, 130)]
|
||||||
self.plist = ListModel.ListModel(self.top.get_widget("ptree"),titles,
|
self.plist = ListModel.ListModel(self.top.get_widget("ptree"), titles,
|
||||||
self.change_display)
|
self.change_display)
|
||||||
|
|
||||||
self.top.get_widget('color').connect('color-set',self.fg_color_set)
|
self.top.get_widget('color').connect('color-set', self.fg_color_set)
|
||||||
self.top.get_widget('bgcolor').connect('color-set',self.bg_color_set)
|
self.top.get_widget('bgcolor').connect('color-set', self.bg_color_set)
|
||||||
self.top.get_widget("style_name").set_text(name)
|
self.top.get_widget("style_name").set_text(name)
|
||||||
|
|
||||||
names = self.style.get_paragraph_style_names()
|
names = self.style.get_paragraph_style_names()
|
||||||
names.reverse()
|
names.reverse()
|
||||||
for p_name in names:
|
for p_name in names:
|
||||||
self.plist.add([p_name],self.style.get_paragraph_style(p_name))
|
self.plist.add([p_name], self.style.get_paragraph_style(p_name))
|
||||||
self.plist.select_row(0)
|
self.plist.select_row(0)
|
||||||
|
|
||||||
if self.parent:
|
if self.parent:
|
||||||
@ -223,6 +226,9 @@ class StyleEditor:
|
|||||||
self.window.run()
|
self.window.run()
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
|
||||||
|
def __close(self, obj):
|
||||||
|
self.window.destroy()
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
"""Updates the display with the selected paragraph."""
|
"""Updates the display with the selected paragraph."""
|
||||||
|
|
||||||
@ -266,21 +272,21 @@ class StyleEditor:
|
|||||||
self.top.get_widget("bborder").set_active(p.get_bottom_border())
|
self.top.get_widget("bborder").set_active(p.get_bottom_border())
|
||||||
|
|
||||||
self.fg_color = font.get_color()
|
self.fg_color = font.get_color()
|
||||||
c = Color(self.fg_color[0],self.fg_color[1],self.fg_color[2])
|
c = Color(self.fg_color[0], self.fg_color[1], self.fg_color[2])
|
||||||
self.top.get_widget("color").set_color(c)
|
self.top.get_widget("color").set_color(c)
|
||||||
self.top.get_widget('color_code').set_text("#%02X%02X%02X" % self.fg_color)
|
self.top.get_widget('color_code').set_text("#%02X%02X%02X" % self.fg_color)
|
||||||
|
|
||||||
self.bg_color = p.get_background_color()
|
self.bg_color = p.get_background_color()
|
||||||
c = Color(self.bg_color[0],self.bg_color[1],self.bg_color[2])
|
c = Color(self.bg_color[0], self.bg_color[1], self.bg_color[2])
|
||||||
self.top.get_widget("bgcolor").set_color(c)
|
self.top.get_widget("bgcolor").set_color(c)
|
||||||
self.top.get_widget('bgcolor_code').set_text("#%02X%02X%02X" % self.bg_color)
|
self.top.get_widget('bgcolor_code').set_text("#%02X%02X%02X" % self.bg_color)
|
||||||
|
|
||||||
def bg_color_set(self,x):
|
def bg_color_set(self, x):
|
||||||
c = x.get_color()
|
c = x.get_color()
|
||||||
self.bg_color = (c.red >> 8, c.green >> 8, c.blue >> 8)
|
self.bg_color = (c.red >> 8, c.green >> 8, c.blue >> 8)
|
||||||
self.top.get_widget('bgcolor_code').set_text("#%02X%02X%02X" % self.bg_color)
|
self.top.get_widget('bgcolor_code').set_text("#%02X%02X%02X" % self.bg_color)
|
||||||
|
|
||||||
def fg_color_set(self,x):
|
def fg_color_set(self, x):
|
||||||
c = x.get_color()
|
c = x.get_color()
|
||||||
self.fg_color = (c.red >> 8, c.green >> 8, c.blue >> 8)
|
self.fg_color = (c.red >> 8, c.green >> 8, c.blue >> 8)
|
||||||
self.top.get_widget('color_code').set_text("#%02X%02X%02X" % self.fg_color)
|
self.top.get_widget('color_code').set_text("#%02X%02X%02X" % self.fg_color)
|
||||||
@ -322,9 +328,9 @@ class StyleEditor:
|
|||||||
font.set_color(self.fg_color)
|
font.set_color(self.fg_color)
|
||||||
p.set_background_color(self.bg_color)
|
p.set_background_color(self.bg_color)
|
||||||
|
|
||||||
self.style.add_paragraph_style(self.current_name,self.current_p)
|
self.style.add_paragraph_style(self.current_name, self.current_p)
|
||||||
|
|
||||||
def on_save_style_clicked(self,obj):
|
def on_save_style_clicked(self, obj):
|
||||||
"""
|
"""
|
||||||
Saves the current style sheet and causes the parent to be updated with
|
Saves the current style sheet and causes the parent to be updated with
|
||||||
the changes.
|
the changes.
|
||||||
@ -333,17 +339,17 @@ class StyleEditor:
|
|||||||
|
|
||||||
self.save_paragraph()
|
self.save_paragraph()
|
||||||
self.style.set_name(name)
|
self.style.set_name(name)
|
||||||
self.parent.sheetlist.set_style_sheet(name,self.style)
|
self.parent.sheetlist.set_style_sheet(name, self.style)
|
||||||
self.parent.redraw()
|
self.parent.redraw()
|
||||||
Utils.destroy_passed_object(obj)
|
self.window.destroy()
|
||||||
|
|
||||||
def change_display(self,obj):
|
def change_display(self, obj):
|
||||||
"""Called when the paragraph selection has been changed. Saves the
|
"""Called when the paragraph selection has been changed. Saves the
|
||||||
old paragraph, then draws the newly selected paragraph"""
|
old paragraph, then draws the newly selected paragraph"""
|
||||||
|
|
||||||
objs = self.plist.get_selected_objects()
|
objs = self.plist.get_selected_objects()
|
||||||
store,node = self.plist.get_selected()
|
store, node = self.plist.get_selected()
|
||||||
self.current_name = store.get_value(node,0)
|
self.current_name = store.get_value(node, 0)
|
||||||
if self.first == 0:
|
if self.first == 0:
|
||||||
self.save_paragraph()
|
self.save_paragraph()
|
||||||
else:
|
else:
|
||||||
|
@ -462,14 +462,10 @@ class ScratchPadSourceRef(ScratchPadGrampsTypeWrapper):
|
|||||||
base = self._db.get_source_from_handle(self._obj.get_reference_handle())
|
base = self._db.get_source_from_handle(self._obj.get_reference_handle())
|
||||||
s = "<big><b>%s</b></big>\n\n"\
|
s = "<big><b>%s</b></big>\n\n"\
|
||||||
"\t<b>%s:</b>\t%s\n"\
|
"\t<b>%s:</b>\t%s\n"\
|
||||||
"\t<b>%s:</b>\t%s\n"\
|
"\t<b>%s:</b>\t%s" % \
|
||||||
"\t<b>%s:</b>\t%s\n"\
|
(_("Source Reference"),
|
||||||
"\t<b>%s:</b>\t%s" % (
|
|
||||||
_("Source Reference"),
|
|
||||||
_("Title"),escape(base.get_title()),
|
_("Title"),escape(base.get_title()),
|
||||||
_("Page"), escape(self._obj.get_page()),
|
_("Page"), escape(self._obj.get_page()))
|
||||||
_("Text"), escape(self._obj.get_text()),
|
|
||||||
_("Comment"), escape(self._obj.get_note()))
|
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
@ -491,15 +487,13 @@ class ScratchPadRepoRef(ScratchPadGrampsTypeWrapper):
|
|||||||
global escape
|
global escape
|
||||||
base = self._db.get_repository_from_handle(self._obj.get_reference_handle())
|
base = self._db.get_repository_from_handle(self._obj.get_reference_handle())
|
||||||
s = "<big><b>%s</b></big>\n\n"\
|
s = "<big><b>%s</b></big>\n\n"\
|
||||||
"\t<b>%s:</b>\t%s\n"\
|
|
||||||
"\t<b>%s:</b>\t%s\n"\
|
"\t<b>%s:</b>\t%s\n"\
|
||||||
"\t<b>%s:</b>\t%s\n"\
|
"\t<b>%s:</b>\t%s\n"\
|
||||||
"\t<b>%s:</b>\t%s" % (
|
"\t<b>%s:</b>\t%s" % (
|
||||||
_("Repository Reference"),
|
_("Repository Reference"),
|
||||||
_("Name"),escape(base.get_name()),
|
_("Name"),escape(base.get_name()),
|
||||||
_("Call Number"), escape(self._obj.get_call_number()),
|
_("Call Number"), escape(self._obj.get_call_number()),
|
||||||
_("Media Type"), escape(self._obj.get_media_type().__str__()),
|
_("Media Type"), escape(self._obj.get_media_type().__str__()))
|
||||||
_("Comment"), escape(self._obj.get_note()))
|
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
@ -749,7 +743,6 @@ class ScratchSourceLink(ScratchPadWrapper):
|
|||||||
(drag_type, idval, handle, val) = pickle.loads(self._obj)
|
(drag_type, idval, handle, val) = pickle.loads(self._obj)
|
||||||
base = self._db.get_source_from_handle(handle)
|
base = self._db.get_source_from_handle(handle)
|
||||||
s = "<big><b>%s</b></big>\n\n"\
|
s = "<big><b>%s</b></big>\n\n"\
|
||||||
"\t<b>%s:</b>\t%s\n"\
|
|
||||||
"\t<b>%s:</b>\t%s\n"\
|
"\t<b>%s:</b>\t%s\n"\
|
||||||
"\t<b>%s:</b>\t%s\n"\
|
"\t<b>%s:</b>\t%s\n"\
|
||||||
"\t<b>%s:</b>\t%s" % (
|
"\t<b>%s:</b>\t%s" % (
|
||||||
@ -757,8 +750,7 @@ class ScratchSourceLink(ScratchPadWrapper):
|
|||||||
_("Title"),escape(base.get_title()),
|
_("Title"),escape(base.get_title()),
|
||||||
_("Abbreviation"), escape(base.get_abbreviation()),
|
_("Abbreviation"), escape(base.get_abbreviation()),
|
||||||
_("Author"), escape(base.get_author()),
|
_("Author"), escape(base.get_author()),
|
||||||
_("Publication Information"), escape(base.get_publication_info()),
|
_("Publication Information"), escape(base.get_publication_info()))
|
||||||
_("Comment"), escape(base.get_note()))
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
|
32
src/Utils.py
32
src/Utils.py
@ -191,38 +191,6 @@ def family_upper_name(family, db):
|
|||||||
name = mother.get_primary_name().get_upper_name()
|
name = mother.get_primary_name().get_upper_name()
|
||||||
return name
|
return name
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def destroy_passed_object(obj):
|
|
||||||
obj.destroy()
|
|
||||||
while gtk.events_pending():
|
|
||||||
gtk.main_iteration()
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def get_detail_text(obj,priv=1):
|
|
||||||
if obj.get_note() != "":
|
|
||||||
details = "%s" % _("Note")
|
|
||||||
else:
|
|
||||||
details = ""
|
|
||||||
if len(obj.get_source_references()) > 0:
|
|
||||||
if details == "":
|
|
||||||
details = _("Source")
|
|
||||||
else:
|
|
||||||
details = "%s, %s" % (details,_("Source"))
|
|
||||||
if priv and obj.get_privacy() == 1:
|
|
||||||
if details == "":
|
|
||||||
details = _("Private")
|
|
||||||
else:
|
|
||||||
details = "%s, %s" % (details,_("Private"))
|
|
||||||
return details
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user