From 070f4c8d919a732e38345de15c854c5399990b7e Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 10 Mar 2002 07:20:02 +0000 Subject: [PATCH] Simplified bookmarks and searching - glade no longer needed svn: r828 --- gramps/src/Bookmarks.py | 71 +++++++---- gramps/src/Find.py | 115 ++++++++--------- gramps/src/bookmarks.glade | 246 ------------------------------------- gramps/src/find.glade | 174 -------------------------- gramps/src/gramps_main.py | 2 +- 5 files changed, 97 insertions(+), 511 deletions(-) delete mode 100644 gramps/src/bookmarks.glade delete mode 100644 gramps/src/find.glade diff --git a/gramps/src/Bookmarks.py b/gramps/src/Bookmarks.py index 1f10159c0..9580aab5a 100644 --- a/gramps/src/Bookmarks.py +++ b/gramps/src/Bookmarks.py @@ -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() diff --git a/gramps/src/Find.py b/gramps/src/Find.py index 75c8b7a82..3d4cde3eb 100644 --- a/gramps/src/Find.py +++ b/gramps/src/Find.py @@ -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) + diff --git a/gramps/src/bookmarks.glade b/gramps/src/bookmarks.glade deleted file mode 100644 index caadc3832..000000000 --- a/gramps/src/bookmarks.glade +++ /dev/null @@ -1,246 +0,0 @@ - - - - - bookmarks - bookmarks - - src - pixmaps - C - True - True - - - - GnomeDialog - top - Edit Bookmarks - GRAMPS - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - True - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox1 - False - 0 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area1 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - ok - True - True - True - - clicked - on_ok_clicked - top - Wed, 14 Feb 2001 20:10:00 GMT - - GNOME_STOCK_BUTTON_OK - - - - GtkButton - cancel - True - True - - clicked - on_cancel_clicked - top - Wed, 14 Feb 2001 20:10:25 GMT - - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkVBox - vbox1 - False - 0 - - 0 - True - True - - - - GtkLabel - bookmarksTitle - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 5 - False - False - - - - - GtkHSeparator - hseparator1 - - 10 - False - True - - - - - GtkHBox - hbox1 - False - 0 - - 0 - True - True - - - - GtkScrolledWindow - scrolledwindow1 - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkCList - namelist - 250 - 150 - True - - select_row - on_namelist_select_row - Wed, 14 Feb 2001 20:08:50 GMT - - 1 - 80 - GTK_SELECTION_SINGLE - False - GTK_SHADOW_IN - - - GtkLabel - CList:title - label2 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - GtkVButtonBox - vbuttonbox1 - GTK_BUTTONBOX_START - 10 - 85 - 27 - 7 - 0 - - 0 - False - False - - - - GtkButton - up - True - True - - clicked - on_up_clicked - namelist - Wed, 14 Feb 2001 20:09:13 GMT - - GNOME_STOCK_BUTTON_UP - GTK_RELIEF_NORMAL - - - - GtkButton - down - True - True - - clicked - on_down_clicked - namelist - Wed, 14 Feb 2001 20:09:23 GMT - - GNOME_STOCK_BUTTON_DOWN - GTK_RELIEF_NORMAL - - - - GtkButton - delete - True - True - - clicked - on_delete_clicked - namelist - Wed, 14 Feb 2001 20:09:35 GMT - - - GTK_RELIEF_NORMAL - - - - - - - - diff --git a/gramps/src/find.glade b/gramps/src/find.glade deleted file mode 100644 index 33add76da..000000000 --- a/gramps/src/find.glade +++ /dev/null @@ -1,174 +0,0 @@ - - - - - Gramps - gramps - - src - - C - True - True - True - gramps.strings - - - - GnomeDialog - find - Find Person - GRAMPS - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - 375 - 175 - True - True - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox14 - False - 0 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area14 - GTK_BUTTONBOX_SPREAD - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - prev - True - True - - clicked - on_prev_clicked - find - Wed, 05 Sep 2001 02:55:37 GMT - - GNOME_STOCK_BUTTON_PREV - - - - GtkButton - next - True - True - True - - clicked - on_next_clicked - find - Wed, 05 Sep 2001 02:55:23 GMT - - GNOME_STOCK_BUTTON_NEXT - - - - GtkButton - button120 - True - True - - clicked - destroy_passed_object - find - Wed, 05 Sep 2001 02:55:07 GMT - - GNOME_STOCK_BUTTON_CLOSE - - - - - GtkVBox - vbox41 - False - 0 - - 0 - True - True - - - - GtkLabel - label238 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 10 - False - False - - - - - GtkHSeparator - hseparator22 - - 0 - False - False - - - - - GtkHBox - hbox31 - False - 0 - - 19 - True - True - - - - GtkEntry - entry - True - True - True - True - 0 - - - 10 - True - True - - - - - - - - diff --git a/gramps/src/gramps_main.py b/gramps/src/gramps_main.py index 99fb2f112..0818d339d 100755 --- a/gramps/src/gramps_main.py +++ b/gramps/src/gramps_main.py @@ -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,