2005-12-30 01:22:12 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-01-10 22:39:40 +05:30
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
2005-12-30 01:22:12 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
2007-09-08 09:50:59 +05:30
|
|
|
# This program is distributed in the hope that it will be useful,
|
2005-12-30 01:22:12 +05:30
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
# $Id:Assistant.py 9912 2008-01-22 09:17:46Z acraphae $
|
2006-01-10 22:39:40 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2006-03-03 05:47:58 +05:30
|
|
|
import os
|
2005-12-30 01:22:12 +05:30
|
|
|
|
2006-01-10 22:39:40 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-12-30 01:22:12 +05:30
|
|
|
import gtk
|
2006-01-06 23:10:54 +05:30
|
|
|
import gobject
|
2005-12-30 01:22:12 +05:30
|
|
|
|
2006-01-10 22:39:40 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-12-30 01:22:12 +05:30
|
|
|
import const
|
2006-06-15 23:54:43 +05:30
|
|
|
import ManagedWindow
|
2005-12-30 01:22:12 +05:30
|
|
|
|
2006-01-10 22:39:40 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-09-08 11:24:02 +05:30
|
|
|
_gramps_png = os.path.join(const.IMAGE_DIR, "gramps.png")
|
|
|
|
_splash_jpg = os.path.join(const.IMAGE_DIR, "splash.jpg")
|
2005-12-30 01:22:12 +05:30
|
|
|
_format = '<span weight="bold" size="xx-large">%s</span>'
|
|
|
|
|
2006-01-10 22:39:40 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Assistant class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-09-08 09:50:59 +05:30
|
|
|
class Assistant(gtk.Object, ManagedWindow.ManagedWindow):
|
2007-08-23 17:28:36 +05:30
|
|
|
""" A tabbed dialog box used to implement Assistant interfaces.
|
|
|
|
Deprecated. Please use gtk.Assistant class from now on.
|
|
|
|
See eg. example use in ExportAssistant
|
|
|
|
"""
|
2006-01-06 23:10:54 +05:30
|
|
|
|
|
|
|
__gproperties__ = {}
|
|
|
|
|
2006-01-10 22:39:40 +05:30
|
|
|
__gsignals__ = {
|
2007-09-08 09:50:59 +05:30
|
|
|
'page-changed' : (gobject.SIGNAL_RUN_LAST,
|
|
|
|
gobject.TYPE_NONE,
|
|
|
|
(gobject.TYPE_INT, )),
|
|
|
|
'before-page-next' : (gobject.SIGNAL_RUN_LAST,
|
|
|
|
gobject.TYPE_NONE,
|
|
|
|
(gobject.TYPE_INT, )),
|
|
|
|
'after-page-next' : (gobject.SIGNAL_RUN_LAST,
|
|
|
|
gobject.TYPE_NONE,
|
|
|
|
(gobject.TYPE_INT, )),
|
|
|
|
'before-page-back' : (gobject.SIGNAL_RUN_LAST,
|
|
|
|
gobject.TYPE_NONE,
|
|
|
|
(gobject.TYPE_INT, )),
|
|
|
|
'after-page-back' : (gobject.SIGNAL_RUN_LAST,
|
|
|
|
gobject.TYPE_NONE,
|
|
|
|
(gobject.TYPE_INT, )),
|
|
|
|
'complete' : (gobject.SIGNAL_RUN_LAST,
|
|
|
|
gobject.TYPE_NONE,
|
2006-01-10 22:39:40 +05:30
|
|
|
())
|
|
|
|
}
|
2006-06-15 23:54:43 +05:30
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
def __init__(self, uistate, parent_class, complete, top_title=''):
|
2006-01-06 23:10:54 +05:30
|
|
|
gobject.GObject.__init__(self)
|
2006-06-15 23:54:43 +05:30
|
|
|
|
|
|
|
self.top_title = top_title
|
|
|
|
if uistate:
|
2007-09-08 09:50:59 +05:30
|
|
|
ManagedWindow.ManagedWindow.__init__(self, uistate, [],
|
2006-08-18 03:09:20 +05:30
|
|
|
parent_class)
|
2006-06-19 09:47:43 +05:30
|
|
|
else:
|
|
|
|
self.uistate = None
|
2006-06-15 23:54:43 +05:30
|
|
|
|
2005-12-30 01:22:12 +05:30
|
|
|
self.complete = complete
|
|
|
|
self.fg_color = gtk.gdk.color_parse('#7d684a')
|
|
|
|
self.bg_color = gtk.gdk.color_parse('#e1dbc5')
|
|
|
|
self.logo = gtk.gdk.pixbuf_new_from_file(_gramps_png)
|
|
|
|
self.splash = gtk.gdk.pixbuf_new_from_file(_splash_jpg)
|
|
|
|
|
2006-01-12 11:39:14 +05:30
|
|
|
self.current_page = -1
|
2005-12-30 01:22:12 +05:30
|
|
|
|
2006-06-15 23:54:43 +05:30
|
|
|
if uistate:
|
|
|
|
self.set_window(gtk.Window(), None, self.top_title)
|
|
|
|
else:
|
|
|
|
self.window = gtk.Window()
|
|
|
|
self.close = self.destroy
|
|
|
|
|
2005-12-30 01:22:12 +05:30
|
|
|
titlebox = gtk.HBox()
|
|
|
|
self.title_text = []
|
|
|
|
|
2006-01-12 11:39:14 +05:30
|
|
|
self.title = gtk.Label('')
|
2007-09-08 09:50:59 +05:30
|
|
|
self.title.set_alignment(0, 0.5)
|
2005-12-30 01:22:12 +05:30
|
|
|
self.title.set_use_markup(True)
|
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
titlebox.pack_start(self.title, True)
|
2005-12-30 01:22:12 +05:30
|
|
|
image = gtk.Image()
|
|
|
|
image.set_from_file(_gramps_png)
|
2007-09-08 09:50:59 +05:30
|
|
|
titlebox.pack_end(image, False)
|
2005-12-30 01:22:12 +05:30
|
|
|
|
|
|
|
self.notebook = gtk.Notebook()
|
|
|
|
self.notebook.set_show_border(False)
|
|
|
|
self.notebook.set_show_tabs(False)
|
|
|
|
|
|
|
|
vbox = gtk.VBox(spacing=6)
|
|
|
|
vbox.set_border_width(6)
|
|
|
|
hbox = gtk.HButtonBox()
|
|
|
|
hbox.set_spacing(6)
|
|
|
|
hbox.set_layout(gtk.BUTTONBOX_END)
|
|
|
|
|
|
|
|
self.cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
|
2007-09-08 09:50:59 +05:30
|
|
|
self.cancel.connect('clicked', self.close)
|
2005-12-30 01:22:12 +05:30
|
|
|
self.back = gtk.Button(stock=gtk.STOCK_GO_BACK)
|
|
|
|
self.back.set_sensitive(False)
|
2007-09-08 09:50:59 +05:30
|
|
|
self.back.connect('clicked', self.back_clicked)
|
2005-12-30 01:22:12 +05:30
|
|
|
self.next = gtk.Button(stock=gtk.STOCK_GO_FORWARD)
|
2007-09-08 09:50:59 +05:30
|
|
|
self.next.connect('clicked', self.next_clicked)
|
2006-01-08 20:49:46 +05:30
|
|
|
self.ok = gtk.Button(stock=gtk.STOCK_OK)
|
2007-09-08 09:50:59 +05:30
|
|
|
self.ok.connect('clicked', self.next_clicked)
|
|
|
|
self.ok.set_sensitive(False)
|
2005-12-30 01:22:12 +05:30
|
|
|
|
|
|
|
hbox.add(self.cancel)
|
|
|
|
hbox.add(self.back)
|
|
|
|
hbox.add(self.next)
|
2007-09-08 09:50:59 +05:30
|
|
|
hbox.add(self.ok)
|
2005-12-30 01:22:12 +05:30
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
vbox.pack_start(titlebox, False)
|
|
|
|
vbox.pack_start(self.notebook, True)
|
|
|
|
vbox.pack_start(hbox, False)
|
2005-12-30 01:22:12 +05:30
|
|
|
|
|
|
|
self.window.add(vbox)
|
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
def build_menu_names(self, obj):
|
|
|
|
return (self.top_title, None)
|
2006-06-15 23:54:43 +05:30
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
def set_busy_cursor(self, value):
|
2006-03-01 11:46:36 +05:30
|
|
|
if value:
|
|
|
|
self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
|
|
|
self.window.set_sensitive(0)
|
|
|
|
else:
|
|
|
|
self.window.window.set_cursor(None)
|
|
|
|
self.window.set_sensitive(1)
|
|
|
|
|
|
|
|
while gtk.events_pending():
|
|
|
|
gtk.main_iteration()
|
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
def destroy(self, *obj):
|
2009-06-19 03:26:37 +05:30
|
|
|
self.window.emit('delete-event', None)
|
2006-06-15 23:54:43 +05:30
|
|
|
self.window.destroy()
|
|
|
|
|
2006-01-06 23:10:54 +05:30
|
|
|
def do_get_property(self, prop):
|
2006-01-10 22:39:40 +05:30
|
|
|
"""Return the gproperty's value."""
|
2006-01-06 23:10:54 +05:30
|
|
|
raise AttributeError, 'unknown property %s' % prop.name
|
|
|
|
|
|
|
|
def do_set_property(self, prop, value):
|
2006-01-10 22:39:40 +05:30
|
|
|
"""Set the property of writable properties."""
|
2006-01-06 23:10:54 +05:30
|
|
|
raise AttributeError, 'unknown or read only property %s' % prop.name
|
|
|
|
|
2006-01-12 11:39:14 +05:30
|
|
|
def get_number_of_pages(self):
|
|
|
|
return self.notebook.get_n_pages()
|
|
|
|
|
2005-12-30 01:22:12 +05:30
|
|
|
def update_title(self):
|
2006-01-12 11:39:14 +05:30
|
|
|
self.title.set_label(self.title_text[self.current_page])
|
2005-12-30 01:22:12 +05:30
|
|
|
self.title.set_use_markup(True)
|
2006-01-08 20:49:46 +05:30
|
|
|
|
|
|
|
def set_buttons(self):
|
2006-01-12 11:39:14 +05:30
|
|
|
max_page = self.notebook.get_n_pages()
|
|
|
|
if self.current_page == max_page-2:
|
2007-09-08 09:50:59 +05:30
|
|
|
self.next.show()
|
|
|
|
self.back.show()
|
|
|
|
self.cancel.show()
|
|
|
|
self.ok.set_sensitive(True)
|
|
|
|
self.next.set_sensitive(False)
|
|
|
|
self.back.set_sensitive(True)
|
|
|
|
elif self.current_page == max_page-1:
|
|
|
|
self.next.hide()
|
|
|
|
self.back.hide()
|
|
|
|
self.cancel.hide()
|
|
|
|
elif self.current_page == 0:
|
|
|
|
self.next.show()
|
|
|
|
self.back.show()
|
|
|
|
self.cancel.show()
|
|
|
|
self.back.set_sensitive(False)
|
|
|
|
self.next.set_sensitive(True)
|
|
|
|
self.ok.set_sensitive(False)
|
|
|
|
else:
|
|
|
|
self.next.show()
|
|
|
|
self.back.show()
|
|
|
|
self.back.set_sensitive(True)
|
|
|
|
self.next.set_sensitive(True)
|
|
|
|
self.ok.set_sensitive(False)
|
|
|
|
self.cancel.show()
|
2005-12-30 01:22:12 +05:30
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
def back_clicked(self, obj):
|
|
|
|
self.emit('before-page-back', self.notebook.get_current_page())
|
2005-12-30 01:22:12 +05:30
|
|
|
self.current_page -= 1
|
|
|
|
self.notebook.set_current_page(self.current_page)
|
|
|
|
self.update_title()
|
2007-09-08 09:50:59 +05:30
|
|
|
self.set_buttons()
|
2006-01-06 23:10:54 +05:30
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
self.emit('after-page-back', self.notebook.get_current_page())
|
|
|
|
self.emit('page-changed', self.notebook.get_current_page())
|
2006-01-05 21:32:27 +05:30
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
def next_clicked(self, obj):
|
|
|
|
self.emit('before-page-next', self.notebook.get_current_page())
|
2006-01-12 11:39:14 +05:30
|
|
|
if self.current_page == self.notebook.get_n_pages()-1:
|
2006-01-06 23:10:54 +05:30
|
|
|
self.emit('complete')
|
2005-12-30 01:22:12 +05:30
|
|
|
self.complete()
|
2006-06-15 23:54:43 +05:30
|
|
|
self.close()
|
2005-12-30 01:22:12 +05:30
|
|
|
else:
|
|
|
|
self.current_page += 1
|
|
|
|
self.notebook.set_current_page(self.current_page)
|
|
|
|
self.update_title()
|
2006-01-11 06:56:17 +05:30
|
|
|
self.set_buttons()
|
2005-12-30 01:22:12 +05:30
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
self.emit('after-page-next', self.notebook.get_current_page())
|
|
|
|
self.emit('page-changed', self.notebook.get_current_page())
|
2006-01-05 21:32:27 +05:30
|
|
|
|
2006-01-12 11:39:14 +05:30
|
|
|
def add_text_page(self, title, text):
|
|
|
|
"""
|
|
|
|
Add page with Gramps logo and given text and title.
|
|
|
|
Usually, first page (introduction) and last page (conclusion)
|
|
|
|
use this method.
|
|
|
|
"""
|
|
|
|
hbox = self.prepare_text_page(text)
|
2007-09-08 09:50:59 +05:30
|
|
|
return self.add_page(title, hbox)
|
2006-01-12 11:39:14 +05:30
|
|
|
|
|
|
|
def insert_text_page(self, title, text, position):
|
|
|
|
"""
|
|
|
|
Add page with Gramps logo and given text and title.
|
|
|
|
Usually, first page (introduction) and last page (conclusion)
|
|
|
|
use this method.
|
|
|
|
"""
|
|
|
|
hbox = self.prepare_text_page(text)
|
2007-09-08 09:50:59 +05:30
|
|
|
return self.insert_page(title, hbox, position)
|
2006-01-12 11:39:14 +05:30
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
def prepare_text_page(self, text):
|
2005-12-30 01:22:12 +05:30
|
|
|
hbox = gtk.HBox(spacing=12)
|
|
|
|
image = gtk.Image()
|
|
|
|
image.set_from_file(_splash_jpg)
|
2007-09-08 09:50:59 +05:30
|
|
|
hbox.pack_start(image, False)
|
2006-01-11 06:56:17 +05:30
|
|
|
label = gtk.Label(text)
|
2005-12-30 01:22:12 +05:30
|
|
|
label.set_line_wrap(True)
|
2006-08-18 03:09:20 +05:30
|
|
|
label.set_use_markup(True)
|
2005-12-30 01:22:12 +05:30
|
|
|
hbox.add(label)
|
2006-01-11 06:56:17 +05:30
|
|
|
hbox.show_all()
|
2006-01-12 11:39:14 +05:30
|
|
|
return hbox
|
2006-01-11 06:56:17 +05:30
|
|
|
|
|
|
|
def add_page(self, title, child):
|
2006-01-12 11:39:14 +05:30
|
|
|
"""
|
|
|
|
Add page with the title and child widget.
|
2008-02-24 19:25:55 +05:30
|
|
|
Return index number of the new page.
|
2006-01-12 11:39:14 +05:30
|
|
|
"""
|
2006-01-11 06:56:17 +05:30
|
|
|
self.title_text.append(_format % title)
|
2006-01-12 11:39:14 +05:30
|
|
|
return self.notebook.append_page(child)
|
2006-01-11 06:56:17 +05:30
|
|
|
|
2006-01-12 11:39:14 +05:30
|
|
|
def insert_page(self, title, child, position):
|
|
|
|
"""
|
|
|
|
Insert page at a given position.
|
|
|
|
Returns index number of the new page.
|
|
|
|
"""
|
2007-09-08 09:50:59 +05:30
|
|
|
self.title_text.insert(position, _format % title)
|
|
|
|
return self.notebook.insert_page(child, None, position)
|
2006-01-11 06:56:17 +05:30
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
def remove_page(self, position):
|
2006-01-12 11:39:14 +05:30
|
|
|
"""
|
|
|
|
Remove page from a given position.
|
|
|
|
"""
|
2006-01-11 06:56:17 +05:30
|
|
|
self.title_text.pop(position)
|
|
|
|
self.notebook.remove_page(position)
|
|
|
|
|
|
|
|
def show(self):
|
2005-12-30 01:22:12 +05:30
|
|
|
self.window.show_all()
|
2006-01-12 11:39:14 +05:30
|
|
|
self.current_page = 0
|
|
|
|
self.notebook.set_current_page(self.current_page)
|
|
|
|
self.update_title()
|
|
|
|
self.set_buttons()
|
2007-09-08 09:50:59 +05:30
|
|
|
self.emit('page-changed', self.notebook.get_current_page())
|
2006-06-15 23:54:43 +05:30
|
|
|
if self.uistate:
|
|
|
|
ManagedWindow.ManagedWindow.show(self)
|
2006-01-06 23:10:54 +05:30
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
if gtk.pygtk_version < (2, 8, 0):
|
2006-01-06 23:10:54 +05:30
|
|
|
gobject.type_register(Assistant)
|
|
|
|
|
2005-12-30 01:22:12 +05:30
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
def complete():
|
|
|
|
gtk.main_quit()
|
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
def make_label(table, val, y, x1, x2, x3, x4):
|
2005-12-30 01:22:12 +05:30
|
|
|
label = gtk.Label(val)
|
2007-09-08 09:50:59 +05:30
|
|
|
label.set_alignment(0, 0.5)
|
2005-12-30 01:22:12 +05:30
|
|
|
text = gtk.Entry()
|
2007-09-08 09:50:59 +05:30
|
|
|
table.attach(label, x1, x2, y, y+1, gtk.SHRINK|gtk.FILL)
|
|
|
|
table.attach(text, x3, x4, y, y+1, gtk.EXPAND|gtk.FILL)
|
2005-12-30 01:22:12 +05:30
|
|
|
return text
|
|
|
|
|
2006-01-12 11:39:14 +05:30
|
|
|
a = Assistant(complete)
|
2007-09-08 09:50:59 +05:30
|
|
|
a.add_text_page('Getting started',
|
2009-11-19 23:02:11 +05:30
|
|
|
'Welcome to Gramps, the Genealogical Research '
|
2006-01-12 11:39:14 +05:30
|
|
|
'and Analysis Management Programming System.\n'
|
|
|
|
'Several options and information need to be gathered '
|
2009-11-19 23:02:11 +05:30
|
|
|
'before Gramps is ready to be used. Any of this '
|
2006-01-12 11:39:14 +05:30
|
|
|
'information can be changed in the future in the '
|
|
|
|
'Preferences dialog under the Settings menu.')
|
2005-12-30 01:22:12 +05:30
|
|
|
|
|
|
|
box = gtk.VBox()
|
|
|
|
box.set_spacing(12)
|
2007-09-08 09:50:59 +05:30
|
|
|
table = gtk.Table(8, 4)
|
2005-12-30 01:22:12 +05:30
|
|
|
table.set_row_spacings(6)
|
|
|
|
table.set_col_spacings(6)
|
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
make_label(table, _('Name:'), 0, 0, 1, 1, 4)
|
|
|
|
make_label(table, _('Address:'), 1, 0, 1, 1, 4)
|
|
|
|
make_label(table, _('City:'), 2, 0, 1, 1, 2)
|
|
|
|
make_label(table, _('State/Province:'), 2, 2, 3, 3, 4)
|
|
|
|
make_label(table, _('Country:'), 3, 0, 1, 1, 2)
|
|
|
|
make_label(table, _('ZIP/Postal code:'), 3, 2, 3, 3, 4)
|
|
|
|
make_label(table, _('Phone:'), 4, 0, 1, 1, 4)
|
|
|
|
make_label(table, _('Email:'), 5, 0, 1, 1, 4)
|
2005-12-30 01:22:12 +05:30
|
|
|
box.add(table)
|
2007-09-08 09:50:59 +05:30
|
|
|
a.add_page('Researcher information', box)
|
2006-01-11 06:56:17 +05:30
|
|
|
|
2007-09-08 09:50:59 +05:30
|
|
|
a.add_text_page('Conclusion title', 'Very long conclusion text here')
|
2005-12-30 01:22:12 +05:30
|
|
|
a.show()
|
2006-01-11 06:56:17 +05:30
|
|
|
|
2005-12-30 01:22:12 +05:30
|
|
|
gtk.main()
|