* src/DisplayTabs.py: Hook up editors

* src/EditFamily.py: Add _DND_TYPE
* src/UrlEdit.py: Add type selector
* src/Utils.py: add type/string maps for url types
* src/gramps.glade: add type selector comboboxentry
* src/ObjectSelector/_ObjectSelectorWindow.py: fix window management
so that the system is closed properly


svn: r5863
This commit is contained in:
Don Allingham 2006-02-01 21:57:11 +00:00
parent dbc0c52fc5
commit 15bc78db47
7 changed files with 213 additions and 31 deletions

View File

@ -1,3 +1,12 @@
2006-02-01 Don Allingham <don@gramps-project.org>
* src/DisplayTabs.py: Hook up editors
* src/EditFamily.py: Add _DND_TYPE
* src/UrlEdit.py: Add type selector
* src/Utils.py: add type/string maps for url types
* src/gramps.glade: add type selector comboboxentry
* src/ObjectSelector/_ObjectSelectorWindow.py: fix window management
so that the system is closed properly
2006-02-01 Alex Roitman <shura@gramps-project.org>
* src/GrampsDb/_GrampsBSDDB.py (_find_from_handle): Revert the
change, as it does not seem to bring any speedup.

View File

@ -37,6 +37,11 @@ from gtk.gdk import ACTION_COPY, BUTTON1_MASK
from gettext import gettext as _
import pickle
try:
set()
except:
from sets import Set as set
#-------------------------------------------------------------------------
#
# GRAMPS libraries
@ -390,6 +395,14 @@ class EmbeddedList(ButtonTab):
"""
return gtk.STOCK_JUSTIFY_FILL
def del_button_clicked(self,obj):
ref = self.get_selected()
if ref:
ref_list = self.get_data()
ref_list.remove(ref)
self.changed = True
self.rebuild()
def build_interface(self):
"""
Builds the interface, instantiating a gtk.TreeView in a
@ -549,14 +562,6 @@ class EventEmbedList(EmbeddedList):
EventEdit.EventRefEditor(self.dbstate,self.uistate,self.track,
None, ref, self.obj, self.event_added)
def del_button_clicked(self,obj):
ref = self.get_selected()
if ref:
ref_list = self.obj.get_event_ref_list()
ref_list.remove(ref)
self.changed = True
self.rebuild()
def edit_button_clicked(self,obj):
ref = self.get_selected()
if ref:
@ -720,6 +725,33 @@ class AttrEmbedList(EmbeddedList):
def column_order(self):
return ((1,0),(1,1))
def add_button_clicked(self,obj):
import AttrEdit
pname = ''
attr_list = []
AttrEdit.AttributeEditor(
self.dbstate, self.uistate, self.track, None,
pname, attr_list, self.add_callback)
def add_callback(self,name):
self.get_data().append(name)
self.changed = True
self.rebuild()
def edit_button_clicked(self,obj):
attr = self.get_selected()
if attr:
import AttrEdit
pname = ''
attr_list = []
AttrEdit.AttributeEditor(
self.dbstate, self.uistate, self.track, attr,
pname, attr_list, self.edit_callback)
def edit_callback(self,name):
self.changed = True
self.rebuild()
#-------------------------------------------------------------------------
#
#
@ -727,7 +759,7 @@ class AttrEmbedList(EmbeddedList):
#-------------------------------------------------------------------------
class WebEmbedList(EmbeddedList):
_HANDLE_COL = -1
_HANDLE_COL = 3
_DND_TYPE = DdTargets.URL
_column_names = [
@ -747,6 +779,26 @@ class WebEmbedList(EmbeddedList):
def column_order(self):
return ((1,0),(1,1),(1,2))
def add_button_clicked(self,obj):
import UrlEdit
url = RelLib.Url()
UrlEdit.UrlEditor(self.dbstate, self.uistate, self.track,
'', url, self.add_callback)
def add_callback(self,url):
self.get_data().append(url)
self.rebuild()
def edit_button_clicked(self,obj):
url = self.get_selected()
if url:
import UrlEdit
UrlEdit.UrlEditor(self.dbstate, self.uistate, self.track,
'', url, self.edit_callback)
def edit_callback(self,url):
self.rebuild()
#-------------------------------------------------------------------------
#
#
@ -754,7 +806,7 @@ class WebEmbedList(EmbeddedList):
#-------------------------------------------------------------------------
class NameEmbedList(EmbeddedList):
_HANDLE_COL = -1
_HANDLE_COL = 2
_DND_TYPE = DdTargets.NAME
_column_names = [
@ -773,6 +825,26 @@ class NameEmbedList(EmbeddedList):
def column_order(self):
return ((1,0),(1,1))
def add_button_clicked(self,obj):
import NameEdit
name = RelLib.Name()
NameEdit.NameEditor(self.dbstate, self.uistate, self.track,
name, self.add_callback)
def add_callback(self,name):
self.get_data().append(name)
self.rebuild()
def edit_button_clicked(self,obj):
name = self.get_selected()
if name:
import NameEdit
NameEdit.NameEditor(self.dbstate, self.uistate, self.track,
name, self.edit_callback)
def edit_callback(self,name):
self.rebuild()
#-------------------------------------------------------------------------
#
#
@ -780,7 +852,7 @@ class NameEmbedList(EmbeddedList):
#-------------------------------------------------------------------------
class AddrEmbedList(EmbeddedList):
_HANDLE_COL = -1
_HANDLE_COL = 5
_DND_TYPE = DdTargets.ADDRESS
_column_names = [
@ -802,6 +874,26 @@ class AddrEmbedList(EmbeddedList):
def column_order(self):
return ((1,0),(1,1),(1,2),(1,3),(1,4))
def add_button_clicked(self,obj):
import AddrEdit
addr = RelLib.Address()
AddrEdit.AddressEditor(self.dbstate, self.uistate, self.track,
addr, self.add_callback)
def add_callback(self,name):
self.get_data().append(name)
self.rebuild()
def edit_button_clicked(self,obj):
addr = self.get_selected()
if addr:
import AddrEdit
AddrEdit.AddressEditor(self.dbstate, self.uistate, self.track,
addr, self.edit_callback)
def edit_callback(self,name):
self.rebuild()
#-------------------------------------------------------------------------
#
# NoteTab
@ -992,7 +1084,6 @@ class SourceEmbedList(EmbeddedList):
class ChildModel(gtk.ListStore):
_HANDLE_COL = -8
_DND_TYPE = DdTargets.PERSON_LINK
def __init__(self, family, db):
self.family = family
@ -1234,7 +1325,16 @@ class WebModel(gtk.ListStore):
gtk.ListStore.__init__(self,str,str,str,object)
self.db = db
for obj in obj_list:
self.append(row=[obj.type, obj.path, obj.desc, obj])
self.append(row=[self.show_type(obj.type),
obj.path, obj.desc, obj])
def show_type(self,rtype):
rel = rtype[0]
val = rtype[1]
if rel == RelLib.Url.CUSTOM:
return val
else:
return Utils.web_types[rel]
#-------------------------------------------------------------------------
#

View File

@ -67,6 +67,7 @@ from ObjectSelector import PersonSelector,PersonFilterSpec
class ChildEmbedList(EmbeddedList):
_HANDLE_COL = 10
_DND_TYPE = DdTargets.PERSON_LINK
_column_names = [
(_('#'),0) ,

View File

@ -251,7 +251,7 @@ class ObjectSelectorWindow(gtk.Window,ManagedWindow):
cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL)
cancel_button.show()
cancel_button.connect_object("clicked", gtk.Widget.destroy, self)
cancel_button.connect_object("clicked", self._close_window, self)
bottom_button_bar = gtk.HButtonBox()
bottom_button_bar.set_layout(gtk.BUTTONBOX_SPREAD)
@ -284,6 +284,9 @@ class ObjectSelectorWindow(gtk.Window,ManagedWindow):
self.show()
def _close_window(self,obj):
self.close()
def _set_object_type(self,selected_object_type):
# enable selected object type
self._object_frames[selected_object_type].show()

View File

@ -46,6 +46,7 @@ import Utils
import RelLib
import GrampsDisplay
import DisplayState
import AutoComp
from WindowUtils import GladeIf
@ -74,11 +75,22 @@ class UrlEditor(DisplayState.ManagedWindow):
self.gladeif = GladeIf(self.top)
self.window = self.top.get_widget("url_edit")
self.wtype = self.top.get_widget("type")
self.des = self.top.get_widget("url_des")
self.addr = self.top.get_widget("url_addr")
self.priv = self.top.get_widget("priv")
title_label = self.top.get_widget("title")
mtype = self.url.get_type()
if mtype:
defval = mtype[0]
else:
defval = None
rel_types = dict(Utils.web_types)
self.type_sel = AutoComp.StandardCustomSelector(
rel_types, self.wtype, RelLib.Url.CUSTOM, defval)
if not name or name == ", ":
etitle =_('Internet Address Editor')
else:
@ -93,7 +105,7 @@ class UrlEditor(DisplayState.ManagedWindow):
self.priv.set_active(url.get_privacy())
self.gladeif.connect('url_edit','delete_event', self.on_delete_event)
self.gladeif.connect('button125','clicked', self.close)
self.gladeif.connect('button125','clicked', self.close_window)
self.gladeif.connect('button124','clicked', self.on_url_edit_ok_clicked)
self.gladeif.connect('button130','clicked', self.on_help_clicked)
@ -109,12 +121,11 @@ class UrlEditor(DisplayState.ManagedWindow):
def on_delete_event(self,*obj):
self.gladeif.close()
gc.collect()
self.close()
def close(self,*obj):
def close_window(self,*obj):
self.gladeif.close()
self.window.destroy()
gc.collect()
self.close()
def on_help_clicked(self,*obj):
"""Display the relevant portion of GRAMPS manual"""
@ -127,11 +138,15 @@ class UrlEditor(DisplayState.ManagedWindow):
self.update_url(des,addr,priv)
self.callback(self.url)
self.close(obj)
self.close_window(obj)
def update_url(self,des,addr,priv):
if self.url.get_path() != addr:
self.url.set_path(addr)
val = self.type_sel.get_values()
if self.url.get_type() != val:
self.url.set_type(val)
if self.url.get_description() != des:
self.url.set_description(des)

View File

@ -182,6 +182,15 @@ name_types = {
RelLib.Name.MARRIED : _("Married Name"),
}
web_types = {
RelLib.Url.UNKNOWN : _("Unknown"),
RelLib.Url.CUSTOM : _("Custom"),
RelLib.Url.EMAIL : _("E-mail"),
RelLib.Url.WEB_HOME : _("Web Home"),
RelLib.Url.WEB_SEARCH : _("Web Search"),
RelLib.Url.WEB_FTP : _("FTP"),
}
source_media_types = {
RelLib.RepoRef.UNKNOWN : _("Unknown"),
RelLib.RepoRef.CUSTOM : _("Custom"),

View File

@ -17629,7 +17629,7 @@ Very High</property>
<widget class="GtkTable" id="table27">
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
@ -17660,8 +17660,8 @@ Very High</property>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@ -17692,8 +17692,8 @@ Very High</property>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@ -17727,8 +17727,8 @@ Very High</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
@ -17750,8 +17750,8 @@ Very High</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_padding">3</property>
<property name="y_options"></property>
</packing>
@ -17772,11 +17772,56 @@ Very High</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label591">
<property name="visible">True</property>
<property name="label" translatable="yes">_Type:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBoxEntry" id="type">
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
<property name="has_frame">True</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>