Prompt for a comment on revision control save

svn: r445
This commit is contained in:
Don Allingham 2001-10-04 14:06:21 +00:00
parent 972689c30d
commit 0f3e1b5d7f
5 changed files with 419 additions and 124 deletions

View File

@ -93,6 +93,7 @@ prefsTop = None
autoload = 0
usetabs = 0
usevc = 0
vc_comment = 0
uncompress = 0
show_detail = 0
hide_altnames = 0
@ -152,6 +153,7 @@ def loadConfig(call):
global owner
global usetabs
global usevc
global vc_comment
global uncompress
global id_visible
global id_edit
@ -175,6 +177,7 @@ def loadConfig(call):
lastfile = gnome.config.get_string("/gramps/data/LastFile")
usetabs = gnome.config.get_bool("/gramps/config/UseTabs")
usevc = gnome.config.get_bool("/gramps/config/UseVersionControl")
vc_comment = gnome.config.get_bool("/gramps/config/UseComment")
uncompress = gnome.config.get_bool("/gramps/config/DontCompressXML")
id_visible = gnome.config.get_bool("/gramps/config/IdVisible")
id_edit = gnome.config.get_bool("/gramps/config/IdEdit")
@ -248,6 +251,8 @@ def loadConfig(call):
usetabs = 0
if usevc == None:
usevc = 0
if vc_comment == None:
vc_comment = 0
if uncompress == None:
uncompress = 0
if id_visible == None:
@ -354,6 +359,7 @@ def on_propertybox_apply(obj,page):
global owner
global usetabs
global usevc
global vc_comment
global uncompress
global id_visible
global id_edit
@ -377,6 +383,7 @@ def on_propertybox_apply(obj,page):
attr_name = string.strip(prefsTop.get_widget("attr_name").get_text())
usetabs = prefsTop.get_widget("usetabs").get_active()
usevc = prefsTop.get_widget("use_vc").get_active()
vc_comment = prefsTop.get_widget("vc_comment").get_active()
uncompress = prefsTop.get_widget("uncompress").get_active()
id_visible = prefsTop.get_widget("gid_visible").get_active()
id_edit = prefsTop.get_widget("gid_edit").get_active()
@ -408,6 +415,7 @@ def on_propertybox_apply(obj,page):
gnome.config.set_bool("/gramps/config/UseTabs",usetabs)
gnome.config.set_bool("/gramps/config/UseVersionControl",usevc)
gnome.config.set_bool("/gramps/config/UseComment",vc_comment)
gnome.config.set_bool("/gramps/config/DontCompressXML",uncompress)
gnome.config.set_bool("/gramps/config/IdVisible",id_visible)
gnome.config.set_bool("/gramps/config/IdEdit",id_edit)
@ -551,6 +559,7 @@ def display_preferences_box():
idedit = prefsTop.get_widget("gid_edit")
tabs = prefsTop.get_widget("usetabs")
vc = prefsTop.get_widget("use_vc")
vcom = prefsTop.get_widget("vc_comment")
compress = prefsTop.get_widget("uncompress")
detail = prefsTop.get_widget("showdetail")
display_attr_obj = prefsTop.get_widget("attr_display")
@ -559,6 +568,7 @@ def display_preferences_box():
detail.set_active(show_detail)
tabs.set_active(usetabs)
vc.set_active(usevc)
vcom.set_active(vc_comment)
compress.set_active(uncompress)
vis.set_active(id_visible)
idedit.set_active(id_edit)

122
src/ImageSelect.py Normal file
View File

@ -0,0 +1,122 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000 Donald N. Allingham
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# 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
#
#-------------------------------------------------------------------------
#
# Standard python modules
#
#-------------------------------------------------------------------------
import os
import string
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
from gtk import *
from gnome.ui import *
import libglade
import GdkImlib
#-------------------------------------------------------------------------
#
# gramps modules
#
#-------------------------------------------------------------------------
import intl
import const
import utils
import Config
from RelLib import *
import RelImage
import Sources
_ = intl.gettext
#-------------------------------------------------------------------------
#
# ImageSelect class
#
#-------------------------------------------------------------------------
class ImageSelect:
#---------------------------------------------------------------------
#
# __init__ - Creates an edit window. Associates a person with the
# window.
#
#---------------------------------------------------------------------
def __init__(self, path, prefix):
self.path = path;
self.prefix = prefix;
self.glade = libglade.GladeXML(const.imageselFile,"imageSelect")
self.window = self.glade.get_widget("imageSelect")
self.fname = self.glade.get_widget("fname")
self.image = self.glade.get_widget("image")
self.description = self.glade.get_widget("photoDescription")
self.external = self.glade.get_widget("private")
self.glade.signal_autoconnect({
"on_savephoto_clicked" : self.on_savephoto_clicked,
"on_name_changed" : self.on_name_changed,
"destroy_passed_object" : utils.destroy_passed_object
})
self.window.editable_enters(self.description)
self.window.show()
def on_name_changed(self, obj):
filename = self.fname.get_text()
if os.path.isfile(filename):
image = RelImage.scale_image(filename,const.thumbScale)
self.image.load_imlib(image)
def on_savephoto_clicked(self, obj):
filename = self.glade.get_widget("photosel").get_full_path(0)
description = self.glade.get_widget("photoDescription").get_text()
if os.path.exists(filename) == 0:
return
if self.external.get_active() == 1:
if os.path.isfile(filename):
name = filename
thumb = "%s%s.thumb%s%s" % (self.path,os.sep,os.sep,os.path.basename(filename))
RelImage.mk_thumb(filename,thumb,const.thumbScale)
else:
return
else:
name = RelImage.import_photo(filename,self.path,self.prefix)
if name == None:
return
photo = Photo()
photo.setPath(name)
photo.setDescription(description)
self.savephoto(photo)
utils.modified()
utils.destroy_passed_object(obj)
def savephoto(self, photo):
assert 0, "The savephoto function must be subclassed"

View File

@ -59,7 +59,7 @@
<widget>
<class>GtkTable</class>
<name>table13</name>
<rows>3</rows>
<rows>6</rows>
<columns>2</columns>
<homogeneous>False</homogeneous>
<row_spacing>0</row_spacing>
@ -125,20 +125,20 @@
<widget>
<class>GtkCheckButton</class>
<name>use_vc</name>
<name>usetabs</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Tue, 02 Oct 2001 14:14:35 GMT</last_modification_time>
<last_modification_time>Thu, 15 Feb 2001 21:32:23 GMT</last_modification_time>
</signal>
<label>Use Revision Control</label>
<label>Use tabbed pages</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<right_attach>2</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>5</xpad>
@ -153,20 +153,114 @@
</widget>
<widget>
<class>GtkOptionMenu</class>
<name>vc_menu</name>
<class>GtkEntry</class>
<name>attr_name</name>
<can_focus>True</can_focus>
<items>RCS
</items>
<initial_choice>0</initial_choice>
<signal>
<name>changed</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Thu, 24 May 2001 21:14:30 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<top_attach>5</top_attach>
<bottom_attach>6</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>gid_edit</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Thu, 12 Jul 2001 13:42:44 GMT</last_modification_time>
</signal>
<label>Allow internal GRAMPS ID numbers to be edited</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>2</right_attach>
<top_attach>4</top_attach>
<bottom_attach>5</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xexpand>True</xexpand>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>gid_visible</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Thu, 12 Jul 2001 13:42:44 GMT</last_modification_time>
</signal>
<label>Display gramps ID in lists</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>2</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>attr_display</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Thu, 24 May 2001 21:14:10 GMT</last_modification_time>
</signal>
<label>Display attribute on Edit Person form</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>5</top_attach>
<bottom_attach>6</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
@ -198,105 +292,17 @@
<row_spacing>0</row_spacing>
<column_spacing>0</column_spacing>
<widget>
<class>GtkEntry</class>
<name>attr_name</name>
<can_focus>True</can_focus>
<signal>
<name>changed</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Thu, 24 May 2001 21:14:30 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>attr_display</name>
<name>vc_comment</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Thu, 24 May 2001 21:14:10 GMT</last_modification_time>
<last_modification_time>Thu, 04 Oct 2001 13:26:10 GMT</last_modification_time>
</signal>
<label>Display attribute on Edit Person form</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>usetabs</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Thu, 15 Feb 2001 21:32:23 GMT</last_modification_time>
</signal>
<label>Use tabbed pages</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>2</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>gid_visible</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Thu, 12 Jul 2001 13:42:44 GMT</last_modification_time>
</signal>
<label>Display gramps ID in lists</label>
<label>Prompt for comment on save</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
@ -317,22 +323,45 @@
<widget>
<class>GtkCheckButton</class>
<name>gid_edit</name>
<name>use_vc</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Thu, 12 Jul 2001 13:42:44 GMT</last_modification_time>
<last_modification_time>Tue, 02 Oct 2001 14:14:35 GMT</last_modification_time>
</signal>
<label>Allow internal GRAMPS ID numbers to be edited</label>
<label>Use Revision Control</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkOptionMenu</class>
<name>vc_menu</name>
<can_focus>True</can_focus>
<items>RCS
</items>
<initial_choice>0</initial_choice>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xexpand>False</xexpand>
@ -349,7 +378,7 @@
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>label209</name>
<label>Display</label>
<label>Revision Control</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>

View File

@ -6463,4 +6463,118 @@ Unknown
</widget>
</widget>
<widget>
<class>GnomeDialog</class>
<name>revcom</name>
<title>Gramps - Revison Control Comment</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</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-vbox17</name>
<homogeneous>False</homogeneous>
<spacing>8</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_area17</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>button135</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_savecomment_clicked</handler>
<object>revcom</object>
<last_modification_time>Thu, 04 Oct 2001 13:42:23 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox46</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label252</name>
<label>Revision Control Comment</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>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkHSeparator</class>
<name>hseparator26</name>
<child>
<padding>10</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>text</name>
<width>350</width>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
</widget>
</GTK-Interface>

View File

@ -1231,14 +1231,17 @@ def on_ok_button2_clicked(obj):
filename = obj.get_filename()
if filename:
utils.destroy_passed_object(obj)
save_file(filename)
if Config.usevc and Config.vc_comment:
display_comment_box(filename)
else:
save_file(filename,_("No Comment Provided"))
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def save_file(filename):
def save_file(filename,comment):
import WriteXML
import VersionControl
@ -1280,7 +1283,7 @@ def save_file(filename):
if Config.usevc:
vc = VersionControl.RcsVersionControl(path)
vc.checkin(filename,"comments not supported yet",not Config.uncompress)
vc.checkin(filename,comment,not Config.uncompress)
statusbar.set_status("")
statusbar.set_progress(0)
@ -1983,35 +1986,52 @@ def on_save_as_activate(obj):
fileSelector = wFs.get_widget(FILESEL)
fileSelector.show()
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def on_save_activate(obj):
"""Saves the file, first prompting for a comment if revision control needs it"""
if not database.getSavePath():
on_save_as_activate(obj)
else:
save_file(database.getSavePath())
if Config.usevc and Config.vc_comment:
display_comment_box(database.getSavePath())
else:
save_file(database.getSavePath(),_("No Comment Provided"))
#-------------------------------------------------------------------------
#
# Switch notebook pages from menu
#
#-------------------------------------------------------------------------
def display_comment_box(filename):
"""Displays a dialog box, prompting for a revison control comment"""
top = libglade.GladeXML(const.gladeFile,"revcom")
rc = top.get_widget("revcom")
tbox = top.get_widget("text")
rc.editable_enters(tbox)
rc.set_data("f",filename)
rc.set_data("t",tbox)
top.signal_autoconnect({
"on_savecomment_clicked" : on_savecomment_clicked,
})
def on_savecomment_clicked(obj):
"""Saves the database, passing the revison control comment to the save routine"""
save_file(obj.get_data("f"),obj.get_data("t").get_text())
utils.destroy_passed_object(obj)
def on_person_list1_activate(obj):
"""Switches to the person list view"""
notebook.set_page(0)
def on_family1_activate(obj):
"""Switches to the family view"""
notebook.set_page(1)
def on_pedegree1_activate(obj):
"""Switches to the pedigree view"""
notebook.set_page(2)
def on_sources_activate(obj):
"""Switches to the sources view"""
notebook.set_page(3)
def on_places_activate(obj):
"""Switches to the places view"""
notebook.set_page(4)
#-------------------------------------------------------------------------