Simplified bookmarks and searching - glade no longer needed

svn: r828
This commit is contained in:
Don Allingham 2002-03-10 07:20:02 +00:00
parent 3d1ea45e78
commit 070f4c8d91
5 changed files with 97 additions and 511 deletions

View File

@ -26,7 +26,8 @@
#
#-------------------------------------------------------------------------
import gtk
import libglade
import GTK
from gnome.ui import *
#-------------------------------------------------------------------------
#
@ -35,6 +36,8 @@ import libglade
#-------------------------------------------------------------------------
import const
import Utils
from intl import gettext
_ = gettext
#-------------------------------------------------------------------------
#
@ -91,6 +94,38 @@ class Bookmarks :
item.connect("activate", self.callback, person)
item.show()
self.myMenu.append(item)
def draw_window(self):
title = "%s - GRAMPS" % _("Edit Bookmarks")
self.top = GnomeDialog(title,STOCK_BUTTON_OK,STOCK_BUTTON_CANCEL)
self.top.set_policy(0,1,0)
self.top.vbox.set_spacing(5)
self.top.vbox.pack_start(gtk.GtkLabel(_("Edit Bookmarks")),0,0,5)
self.top.vbox.pack_start(gtk.GtkHSeparator(),0,0,5)
box = gtk.GtkHBox()
self.top.vbox.pack_start(box,1,1,5)
self.namelist = gtk.GtkCList(1)
slist = gtk.GtkScrolledWindow()
slist.add_with_viewport(self.namelist)
slist.set_usize(250,150)
slist.set_policy(GTK.POLICY_AUTOMATIC, GTK.POLICY_AUTOMATIC)
box.pack_start(slist,1,1,5)
bbox = gtk.GtkVButtonBox()
bbox.set_layout_default(GTK.BUTTONBOX_START)
up = GnomePixmapButton(GnomeStock(STOCK_PIXMAP_UP),_("Up"))
down = GnomePixmapButton(GnomeStock(STOCK_PIXMAP_DOWN),_("Down"))
delete = gtk.GtkButton(_("Delete"))
up.connect('clicked', self.up_clicked)
down.connect('clicked',self.down_clicked)
delete.connect('clicked',self.delete_clicked)
self.top.button_connect(0,self.ok_clicked)
self.top.button_connect(1,self.cancel_clicked)
bbox.add(up)
bbox.add(down)
bbox.add(delete)
box.pack_start(bbox,0,0,5)
self.top.show_all()
def edit(self):
"""
@ -101,40 +136,30 @@ class Bookmarks :
selected row is attached to the name list. This is either 0 if the
list is not empty, or -1 if it is.
"""
top = libglade.GladeXML(const.bookFile,_TOPINST)
self.namelist = top.get_widget(_NAMEINST)
self.draw_window()
index = 0
for person in self.bookmarks:
self.namelist.append([person.getPrimaryName().getName()])
self.namelist.set_row_data(index,person)
index = index + 1
top.signal_autoconnect({
"on_ok_clicked" : self.ok_clicked,
"on_down_clicked" : self.down_clicked,
"on_up_clicked" : self.up_clicked,
"on_delete_clicked" : self.delete_clicked,
"on_cancel_clicked" : self.cancel_clicked
})
def delete_clicked(self,obj):
"""Removes the current selection from the list"""
if len(obj.selection) > 0:
obj.remove(obj.selection[0])
if len(self.namelist.selection) > 0:
self.namelist.remove(self.namelist.selection[0])
def up_clicked(self,obj):
"""Moves the current selection up one row"""
if len(obj.selection) > 0:
index = obj.selection[0]
obj.swap_rows(index-1,index)
if len(self.namelist.selection) > 0:
index = self.namelist.selection[0]
self.namelist.swap_rows(index-1,index)
def down_clicked(self,obj):
"""Moves the current selection down one row"""
if len(obj.selection) > 0:
index = obj.selection[0]
if index != obj.rows-1:
obj.swap_rows(index+1,index)
if len(self.namelist.selection) > 0:
index = self.namelist.selection[0]
if index != self.namelist.rows-1:
self.namelist.swap_rows(index+1,index)
def ok_clicked(self,obj):
"""Saves the current bookmarks from the list"""
@ -144,11 +169,11 @@ class Bookmarks :
if person:
self.bookmarks.append(person)
self.redraw()
obj.destroy()
self.top.destroy()
def cancel_clicked(self,obj):
"""Closes the current window"""
obj.destroy()
self.top.destroy()

View File

@ -23,13 +23,15 @@
__author__ = 'Don Allingham'
import libglade
import GrampsCfg
import const
import Utils
import string
import gtk
from gnome.ui import *
import AutoComp
from intl import gettext
_ = gettext
class Find:
"""Opens find person dialog for gramps"""
@ -43,16 +45,24 @@ class Find:
self.clist = clist
self.task = task
self.xml = libglade.GladeXML(const.findFile,"find")
self.xml.signal_autoconnect({
"destroy_passed_object" : Utils.destroy_passed_object,
"on_next_clicked" : self.on_next_clicked,
"on_prev_clicked" : self.on_prev_clicked,
})
self.top = self.xml.get_widget("find")
self.entry = self.xml.get_widget("entry")
title = "%s - GRAMPS" % _("Find Person")
self.top = GnomeDialog(title,STOCK_BUTTON_PREV,
STOCK_BUTTON_NEXT,STOCK_BUTTON_CLOSE)
self.top.set_policy(0,1,0)
self.top.vbox.set_spacing(5)
self.top.vbox.pack_start(gtk.GtkLabel(_("Find Person")),0,0,5)
self.top.vbox.pack_start(gtk.GtkHSeparator(),0,0,0)
self.entry = gtk.GtkEntry()
self.top.vbox.pack_start(self.entry,0,0,25)
self.top.button_connect(0,self.on_prev_clicked)
self.top.button_connect(1,self.on_next_clicked)
self.top.button_connect(2,self.on_close_clicked)
self.top.set_usize(350,175)
self.top.set_default(1)
self.top.show_all()
self.top.editable_enters(self.entry)
self.entry.grab_focus()
self.nlist = []
for n in plist:
self.nlist.append(n.getPrimaryName().getName())
@ -60,82 +70,53 @@ class Find:
if GrampsCfg.autocomp:
self.comp = AutoComp.AutoEntry(self.entry,self.nlist)
self.next = self.xml.get_widget("next")
self.top.editable_enters(self.entry)
def find_next(self):
"""Advances to the next person that matches the dialog text"""
text = self.entry.get_text()
def advance(self,func):
try:
row = self.clist.selection[0]
self.row = self.clist.selection[0]
except IndexError:
gtk.gdk_beep()
return
if row == None or text == "":
gtk.gdk_beep()
return
orow = row
row = row + 1
last = self.clist.rows
person = None
while row != orow:
person,alt = self.clist.get_row_data(row)
if alt == 0:
name = person.getPrimaryName().getName()
if string.find(string.upper(name),string.upper(text)) >= 0:
self.task(person)
return
row = row + 1
if row == last:
row = 0
gtk.gdk_beep()
def find_prev(self):
"""Advances to the previous person that matches the dialog text"""
text = self.entry.get_text()
try:
row = self.clist.selection[0]
except IndexError:
if self.row == None or text == "":
gtk.gdk_beep()
return
if row == None or text == "":
gtk.gdk_beep()
return
orow = row
row = row - 1
last = self.clist.rows
orow = self.row
func()
person = None
while row != orow:
value = self.clist.get_row_data(row)
while self.row != orow:
value = self.clist.get_row_data(self.row)
if value == None:
row = row - 1
func()
continue
person = value[0]
alt = value[1]
person,alt = value
if alt == 0:
name = person.getPrimaryName().getName()
if string.find(string.upper(name),string.upper(text)) >= 0:
self.task(person)
return
row = row - 1
if row < 0:
row = last
func()
gtk.gdk_beep()
def forward(self):
self.row = self.row + 1
if self.row == self.clist.rows:
self.row = 0
def backward(self):
self.row = self.row - 1
if self.row < 0:
self.row = self.clist.rows
def on_close_clicked(self,obj):
self.top.destroy()
def on_next_clicked(self,obj):
"""Callback for dialog box that causes the next person to be found"""
self.find_next()
"""Advances to the next person that matches the dialog text"""
self.advance(self.forward)
def on_prev_clicked(self,obj):
"""Callback for dialog box that causes the previous person to be found"""
self.find_prev()
"""Advances to the previous person that matches the dialog text"""
self.advance(self.backward)

View File

@ -1,246 +0,0 @@
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>bookmarks</name>
<program_name>bookmarks</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
</project>
<widget>
<class>GnomeDialog</class>
<name>top</name>
<title>Edit Bookmarks - GRAMPS</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>True</allow_shrink>
<allow_grow>True</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>dialog-vbox1</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>dialog-action_area1</name>
<layout_style>GTK_BUTTONBOX_END</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>ok</name>
<can_default>True</can_default>
<has_default>True</has_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_ok_clicked</handler>
<object>top</object>
<last_modification_time>Wed, 14 Feb 2001 20:10:00 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>cancel</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_cancel_clicked</handler>
<object>top</object>
<last_modification_time>Wed, 14 Feb 2001 20:10:25 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox1</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>bookmarksTitle</name>
<label>Edit Bookmarks</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>5</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkHSeparator</class>
<name>hseparator1</name>
<child>
<padding>10</padding>
<expand>False</expand>
<fill>True</fill>
</child>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox1</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkScrolledWindow</class>
<name>scrolledwindow1</name>
<hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy>
<vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkCList</class>
<name>namelist</name>
<width>250</width>
<height>150</height>
<can_focus>True</can_focus>
<signal>
<name>select_row</name>
<handler>on_namelist_select_row</handler>
<last_modification_time>Wed, 14 Feb 2001 20:08:50 GMT</last_modification_time>
</signal>
<columns>1</columns>
<column_widths>80</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<show_titles>False</show_titles>
<shadow_type>GTK_SHADOW_IN</shadow_type>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>label2</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
</widget>
<widget>
<class>GtkVButtonBox</class>
<name>vbuttonbox1</name>
<layout_style>GTK_BUTTONBOX_START</layout_style>
<spacing>10</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkButton</class>
<name>up</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_up_clicked</handler>
<object>namelist</object>
<last_modification_time>Wed, 14 Feb 2001 20:09:13 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_UP</stock_button>
<relief>GTK_RELIEF_NORMAL</relief>
</widget>
<widget>
<class>GtkButton</class>
<name>down</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_down_clicked</handler>
<object>namelist</object>
<last_modification_time>Wed, 14 Feb 2001 20:09:23 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_DOWN</stock_button>
<relief>GTK_RELIEF_NORMAL</relief>
</widget>
<widget>
<class>GtkButton</class>
<name>delete</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_delete_clicked</handler>
<object>namelist</object>
<last_modification_time>Wed, 14 Feb 2001 20:09:35 GMT</last_modification_time>
</signal>
<label>Delete</label>
<relief>GTK_RELIEF_NORMAL</relief>
</widget>
</widget>
</widget>
</widget>
</widget>
</widget>
</GTK-Interface>

View File

@ -1,174 +0,0 @@
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>Gramps</name>
<program_name>gramps</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory></pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
<output_translatable_strings>True</output_translatable_strings>
<translatable_strings_file>gramps.strings</translatable_strings_file>
</project>
<widget>
<class>GnomeDialog</class>
<name>find</name>
<title>Find Person - GRAMPS</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<default_width>375</default_width>
<default_height>175</default_height>
<allow_shrink>True</allow_shrink>
<allow_grow>True</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>dialog-vbox14</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>dialog-action_area14</name>
<layout_style>GTK_BUTTONBOX_SPREAD</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>prev</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_prev_clicked</handler>
<object>find</object>
<last_modification_time>Wed, 05 Sep 2001 02:55:37 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_PREV</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>next</name>
<can_default>True</can_default>
<has_default>True</has_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_next_clicked</handler>
<object>find</object>
<last_modification_time>Wed, 05 Sep 2001 02:55:23 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_NEXT</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button120</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>destroy_passed_object</handler>
<object>find</object>
<last_modification_time>Wed, 05 Sep 2001 02:55:07 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox41</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label238</name>
<label>Find Person</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>10</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkHSeparator</class>
<name>hseparator22</name>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox31</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>19</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkEntry</class>
<name>entry</name>
<can_focus>True</can_focus>
<has_focus>True</has_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>10</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
</widget>
</widget>
</widget>
</GTK-Interface>

View File

@ -1708,7 +1708,7 @@ class Gramps:
continue
for name in person.getAlternateNames():
pos = (person,0)
pos = (person,1)
new_alt2col[person].append(pos)
values = [gname(name,1), pid, gender, qbday, qdday,