Improved reporting for traceback dialog, attempts to determine the distribution

svn: r1220
This commit is contained in:
Don Allingham 2002-12-11 05:18:47 +00:00
parent a1edffc260
commit 509800a470
9 changed files with 80 additions and 44 deletions

Binary file not shown.

View File

@ -88,7 +88,6 @@ class AddMediaObject:
"destroy_passed_object" : Utils.destroy_passed_object
})
self.window.editable_enters(self.description)
self.window.show()
def on_savephoto_clicked(self,obj):
@ -143,8 +142,10 @@ class AddMediaObject:
if os.path.isfile(filename):
type = Utils.get_mime_type(filename)
if type[0:5] == 'image':
if type[0:5] == "image":
image = RelImage.scale_image(filename,const.thumbScale)
self.image.load_imlib(image)
self.image.set_from_pixbuf(image)
else:
self.image.load_file(Utils.find_icon(type))
i = gtk.gdk.pixbuf_new_from_file(Utils.find_icon(type))
self.image.set_from_pixbuf(i)

View File

@ -26,12 +26,14 @@
import cStringIO
import traceback
import sys
import os
#-------------------------------------------------------------------------
#
# GTK/GNOME modules
#
#-------------------------------------------------------------------------
import gtk
import gtk.glade
#-------------------------------------------------------------------------
@ -42,6 +44,14 @@ import gtk.glade
import const
from intl import gettext as _
_release_files = [
"/etc/redhat-release",
"/etc/mandrake-release",
"/etc/debian-release",
"/etc/SuSE-release",
"/etc/gentoo-release",
]
#-------------------------------------------------------------------------
#
# DisplayTrace
@ -51,12 +61,27 @@ class DisplayTrace:
def __init__(self):
data = sys.exc_info()
ver = sys.version_info
msg = cStringIO.StringIO()
msg.write(_('GRAMPS %s has encountered an internal error.\n'
'Please copy the message below and post a bug report '
'at http://sourceforge.net/projects/gramps or send an '
'email message to gramps-users@lists.sourceforge.net\n\n')
% const.version)
msg.write(_('GRAMPS has encountered an internal error.\n'
'Please copy the message below and post a bug report\n'
'at http://sourceforge.net/projects/gramps or send an\n'
'email message to gramps-bugs@lists.sourceforge.net\n\n'))
msg.write("GRAMPS : %s\n" % const.version)
msg.write("Python : %s.%s.%s %s\n" % (ver[0],ver[1],ver[2],ver[3]))
msg.write("GTK : %s.%s.%s\n" % gtk.gtk_version)
for n in _release_files:
if os.path.isfile(n):
try:
f = open(n)
text = f.readline()
msg.write("OS : %s\n" % text)
f.close()
break
except:
pass
traceback.print_exception(data[0],data[1],data[2],None,msg)

View File

@ -234,14 +234,11 @@ class Gallery(ImageSelect):
self.photo = None
def close(self):
pass
# self.iconlist.hide()
# print self.canvas_list
# print self.p_map
# self.canvas_list = None
# self.p_map = None
self.iconlist.hide()
self.canvas_list = None
self.p_map = None
# gc.collect()
# self.iconlist.destroy()
self.iconlist.destroy()
def on_canvas1_event(self,obj,event):
"""Handle resize events over the canvas, redrawing if the size changes"""
@ -267,11 +264,11 @@ class Gallery(ImageSelect):
item = widget.get_item_at(event.x,event.y)
if item:
(i,t,b,self.photo) = self.p_map[item]
(i,t,b,self.photo,oid) = self.p_map[item]
t.set(fill_color_gdk=style.fg[gtk.STATE_SELECTED])
b.set(fill_color_gdk=style.bg[gtk.STATE_SELECTED])
if self.sel:
(i,t,b,photo) = self.p_map[self.sel]
(i,t,b,photo,oid) = self.p_map[self.sel]
t.set(fill_color_gdk=style.fg[gtk.STATE_NORMAL])
b.set(fill_color_gdk=style.bg[gtk.STATE_NORMAL])
@ -285,7 +282,7 @@ class Gallery(ImageSelect):
elif event.button == 3:
item = widget.get_item_at(event.x,event.y)
if item:
(i,t,b,self.photo) = self.p_map[item]
(i,t,b,self.photo,oid) = self.p_map[item]
self.show_popup(self.photo)
return gtk.TRUE
elif event.type == gtk.gdk.BUTTON_RELEASE:
@ -293,7 +290,7 @@ class Gallery(ImageSelect):
elif event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
item = widget.get_item_at(event.x,event.y)
if item:
(i,t,b,self.photo) = self.p_map[item]
(i,t,b,self.photo,oid) = self.p_map[item]
LocalMediaProperties(self.photo,self.path,self)
return gtk.TRUE
elif event.type == gtk.gdk.MOTION_NOTIFY:
@ -365,7 +362,7 @@ class Gallery(ImageSelect):
self.cx = _PAD
self.cy = self.cy + _PAD + _IMAGEY
else:
self.cx = _PAD + self.cx + _IMAGEX
self.cx = self.cx + _PAD + _IMAGEX
def load_images(self):
"""clears the currentImages list to free up any cached
@ -502,7 +499,7 @@ class Gallery(ImageSelect):
thumbnails, and remove it from the dataobj photo list."""
if self.sel:
(i,t,b,photo) = self.p_map[self.sel]
(i,t,b,photo,oid) = self.p_map[self.sel]
val = self.canvas_list[photo.getReference().getId()]
val[0].hide()
val[1].hide()
@ -591,7 +588,7 @@ class LocalMediaProperties:
self.attr_details = self.change_dialog.get_widget("attr_details")
self.attr_list = self.change_dialog.get_widget("attr_list")
titles = [(_('Attribute'),-1,150),(_('Value'),-1,100)]
titles = [(_('Attribute'),0,150),(_('Value'),0,100)]
self.atree = ListModel.ListModel(self.attr_list,titles,
self.on_attr_list_select_row,
@ -723,7 +720,7 @@ class GlobalMediaProperties:
self.attr_list = self.change_dialog.get_widget("attr_list")
titles = [(_('Attribute'),-1,150),(_('Value'),-1,100)]
titles = [(_('Attribute'),0,150),(_('Value'),1,100)]
self.atree = ListModel.ListModel(self.attr_list,titles,
self.on_attr_list_select_row,

View File

@ -55,7 +55,8 @@ class ListModel:
if name[1] != -1:
self.tree.append_column(column)
self.model.set_sort_column_id(self.cids[0],gtk.SORT_ASCENDING)
if self.cids[0] > 0:
self.model.set_sort_column_id(self.cids[0],gtk.SORT_ASCENDING)
self.connect_model()
if select_func:

View File

@ -233,24 +233,27 @@ class MediaView:
# self.list.moveto(0)
# self.list.thaw()
def create_add_dialog(self,obj):
def on_add_clicked(self,obj):
"""Add a new media object to the media list"""
import AddMedia
AddMedia.AddMediaObject(self.db,self.load_media)
def on_edit_media_clicked(self,obj):
def on_edit_clicked(self,obj):
"""Edit the properties of an existing media object in the media list"""
if len(self.list.selection) <= 0:
return
object = self.list.get_row_data(self.list.selection[0])
ImageSelect.GlobalMediaProperties(self.db,object,self.load_media)
list_store, iter = self.selection.get_selected()
if iter:
id = list_store.get_value(iter,1)
object = self.db.getObject(id)
ImageSelect.GlobalMediaProperties(self.db,object,self.load_media)
def on_delete_clicked(self,obj):
if len(self.list.selection) <= 0:
store,iter = self.selection.get_selected()
if not iter:
return
else:
index = self.list.selection[0]
mobj = self.list.get_row_data(index)
id = store.get_value(iter,1)
mobj = self.db.getObject(id)
if self.is_object_used(mobj):
ans = ImageSelect.DeleteMediaQuery(mobj,self.db,self.update)
QuestionDialog(_('Delete Object'),
@ -258,12 +261,11 @@ class MediaView:
"Delete anyway?"),
ans.query_response)
else:
map = self.db.getObjectMap()
del map[mobj.getId()]
self.db.removeObject(mobj.getId())
Utils.modified()
self.update(0)
def is_media_object_used(self,mobj):
def is_object_used(self,mobj):
for p in self.db.getFamilyMap().values():
for o in p.getPhotoList():
if o.getReference() == mobj:

View File

@ -2252,6 +2252,9 @@ class GrampsDB(Persistent):
self.omapIndex = self.omapIndex + 1
return index
def getObject(self,id):
return self.objectMap[id]
def findObject(self,idVal,map):
"""finds an Object in the database using the idVal and map
variables to translate between the external ID and gramps'
@ -2303,6 +2306,9 @@ class GrampsDB(Persistent):
self.placeTable[index] = place.getDisplayInfo()
return index
def removeObject(self,id):
del self.placeMap[id]
def removePlace(self,id):
del self.placeMap[id]
del self.placeTable[id]

View File

@ -311,9 +311,6 @@ class Gramps:
"on_edit_active_person" : self.load_active_person,
"on_edit_selected_people" : self.load_selected_people,
"on_edit_bookmarks_activate" : self.on_edit_bookmarks_activate,
"on_edit_media_clicked" : self.media_view.on_edit_media_clicked,
"on_edit_place_clicked" : self.place_view.on_edit_clicked,
"on_edit_source_clicked" : self.source_view.on_edit_clicked,
"on_exit_activate" : self.on_exit_activate,
"on_family1_activate" : self.on_family1_activate,
"on_find_activate" : self.on_find_activate,
@ -326,7 +323,6 @@ class Gramps:
"on_pedigree1_activate" : self.on_pedigree1_activate,
"on_person_list1_activate" : self.on_person_list1_activate,
"on_main_key_release_event" : self.on_main_key_release_event,
"on_add_media_clicked" : self.media_view.create_add_dialog,
"on_media_activate" : self.on_media_activate,
"on_media_list_select_row" : self.media_view.on_select_row,
"on_media_list_drag_data_get" : self.media_view.on_drag_data_get,
@ -371,6 +367,8 @@ class Gramps:
self.source_view.on_edit_clicked(obj)
elif cpage == 4:
self.place_view.on_edit_clicked(obj)
elif cpage == 5:
self.media_view.on_edit_clicked(obj)
def add_button_clicked(self,obj):
cpage = self.notebook.get_current_page()
@ -380,6 +378,8 @@ class Gramps:
self.source_view.on_add_clicked(obj)
elif cpage == 4:
self.place_view.on_add_place_clicked(obj)
elif cpage == 5:
self.media_view.on_add_clicked(obj)
def remove_button_clicked(self,obj):
cpage = self.notebook.get_current_page()
@ -389,6 +389,8 @@ class Gramps:
self.source_view.on_delete_clicked(obj)
elif cpage == 4:
self.place_view.on_delete_clicked(obj)
elif cpage == 5:
self.media_view.on_delete_clicked(obj)
def enable_buttons(self,val):
self.addbtn.set_sensitive(val)

View File

@ -135,6 +135,8 @@
<child>
<widget class="GtkImage" id="image">
<property name="width_request">100</property>
<property name="height_request">100</property>
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>