2007-02-25 Don Allingham <don@gramps-project.org>

* src/DataViews/__init__.py: Add NoteView
	* src/DataViews/_NoteView.py: Added
	* src/Config/_GrampsConfigKeys.py: Added new keys to handle note dialog 
	width
	* src/Editors/__init__.py: Add _EditNote.py
	* src/Editors/_EditNote.py: Added
	* src/DisplayTabs/_NoteTab.py: Updated to the new list format
	* src/GrampsWidgets.py: Add checkbox support
	* src/glade/gramps.glade: Added edit_note
	* data/gramps.schemas.in: new keys



svn: r8240
This commit is contained in:
Don Allingham 2007-02-26 01:39:16 +00:00
parent 7ee2ff3f5c
commit 18984b840e
11 changed files with 485 additions and 15 deletions

View File

@ -1,3 +1,15 @@
2007-02-25 Don Allingham <don@gramps-project.org>
* src/DataViews/__init__.py: Add NoteView
* src/DataViews/_NoteView.py: Added
* src/Config/_GrampsConfigKeys.py: Added new keys to handle note dialog
width
* src/Editors/__init__.py: Add _EditNote.py
* src/Editors/_EditNote.py: Added
* src/DisplayTabs/_NoteTab.py: Updated to the new list format
* src/GrampsWidgets.py: Add checkbox support
* src/glade/gramps.glade: Added edit_note
* data/gramps.schemas.in: new keys
2007-02-25 Brian Matherly <brian@gramps-project.org>
* src/plugins/AncestorChart2.py: Fix index error

View File

@ -297,6 +297,30 @@
</locale>
</schema>
<schema>
<key>/schemas/apps/gramps/interface/note-height</key>
<applyto>/apps/gramps/interface/note-height</applyto>
<owner>gramps</owner>
<type>int</type>
<default>500</default>
<locale name="C">
<short>Height of the note editor interface.</short>
<long>Specifies the height of the note editor interface.</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gramps/interface/note-width</key>
<applyto>/apps/gramps/interface/note-width</applyto>
<owner>gramps</owner>
<type>int</type>
<default>700</default>
<locale name="C">
<short>Width of the note editor interface.</short>
<long>Specifies the width of the note editor interface.</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gramps/interface/person-height</key>
<applyto>/apps/gramps/interface/person-height</applyto>

View File

@ -49,6 +49,8 @@ HEIGHT = ('interface','height', 1)
WIDTH = ('interface','width', 1)
FAMILY_HEIGHT = ('interface','family-height', 1)
FAMILY_WIDTH = ('interface','family-width', 1)
NOTE_HEIGHT = ('interface','note-height', 1)
NOTE_WIDTH = ('interface','note-width', 1)
PERSON_HEIGHT = ('interface','person-height', 1)
PERSON_WIDTH = ('interface','person-width', 1)
EVENT_HEIGHT = ('interface','event-height', 1)
@ -148,6 +150,8 @@ default_value = {
WIDTH : 775,
FAMILY_HEIGHT : 500,
FAMILY_WIDTH : 700,
NOTE_HEIGHT : 500,
NOTE_WIDTH : 700,
PERSON_HEIGHT : 550,
PERSON_WIDTH : 750,
EVENT_HEIGHT : 450,

View File

@ -48,6 +48,7 @@ import Config
from DdTargets import DdTargets
from QuestionDialog import QuestionDialog, ErrorDialog
from Filters.SideBar import NoteSidebarFilter
from Editors import EditNote
#-------------------------------------------------------------------------
#
@ -109,9 +110,6 @@ class NoteView(PageView.ListView):
self.add_action('FilterEdit', None, _('Note Filter Editor'),
callback=self.filter_editor,)
# def drag_info(self):
# return DdTargets.PLACE_LINK
def column_editor(self, obj):
pass
# import ColumnOrder
@ -168,16 +166,14 @@ class NoteView(PageView.ListView):
def on_double_click(self, obj, event):
handle = self.first_selected()
note = self.dbstate.db.get_note_from_handle(handle)
note = RelLib.Note()
try:
#EditPlace(self.dbstate, self.uistate, [], place)
print handle
EditNote(self.dbstate, self.uistate, [], note)
except Errors.WindowActiveError:
pass
def add(self, obj):
try:
#EditPlace(self.dbstate, self.uistate, [], RelLib.Place())
pass
except Errors.WindowActiveError:
pass
@ -226,8 +222,7 @@ class NoteView(PageView.ListView):
for handle in mlist:
note = self.dbstate.db.get_note_from_handle(handle)
try:
#EditPlace(self.dbstate, self.uistate, [], place)
print handle
EditNote(self.dbstate, self.uistate, [], note)
except Errors.WindowActiveError:
pass

View File

@ -34,7 +34,6 @@ from _EventView import EventView
from _SourceView import SourceView
from _PlaceView import PlaceView
from _MediaView import MediaView
#from _MapView import MapView
from _RepositoryView import RepositoryView
from _NoteView import NoteView

View File

@ -33,9 +33,12 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
import Spell
import Errors
from DisplayTabs import log
from _NoteModel import NoteModel
from _EmbeddedList import EmbeddedList
from Editors import EditNote
#-------------------------------------------------------------------------
#
@ -69,7 +72,11 @@ class NoteTab(EmbeddedList):
return ((1, 0), (1, 1))
def add_button_clicked(self, obj):
pass
note = RelLib.Note()
try:
EditNote(self.dbstate, self.uistate, [], note)
except Errors.WindowActiveError:
pass
def add_callback(self, name):
self.get_data().append(name)
@ -77,9 +84,13 @@ class NoteTab(EmbeddedList):
self.rebuild()
def edit_button_clicked(self, obj):
note = self.get_selected()
if note:
print note
handle = self.get_selected()
if handle:
note = self.dbstate.db.get_note_from_handle(handle)
try:
EditNote(self.dbstate, self.uistate, [], note)
except Errors.WindowActiveError:
pass
def edit_callback(self, name):
self.changed = True

View File

@ -28,6 +28,7 @@ pkgdata_PYTHON = \
_EditSecondary.py \
_EditSource.py \
_EditSourceRef.py \
_EditNote.py \
_EditUrl.py
pkgpyexecdir = @pkgpyexecdir@/Editors

243
src/Editors/_EditNote.py Normal file
View File

@ -0,0 +1,243 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2006 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
#
# $Id$
#-------------------------------------------------------------------------
#
# Python classes
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
import pango
#-------------------------------------------------------------------------
#
# GRAMPS classes
#
#-------------------------------------------------------------------------
import const
import Spell
import Config
from _EditPrimary import EditPrimary
from MarkupText import EditorBuffer
from GrampsWidgets import *
#-------------------------------------------------------------------------
#
# NoteTab
#
#-------------------------------------------------------------------------
class EditNote(EditPrimary):
def __init__(self, state, uistate, track, note, callback=None):
"""
Creates an EditPerson window. Associates a person with the window.
"""
EditPrimary.__init__(self, state, uistate, track, note,
state.db.get_note_from_handle, callback)
def empty_object(self):
"""
Returns an empty Person object for comparison for changes. This
is used by the base class (EditPrimary)
"""
return RelLib.Note()
def get_menu_title(self):
if self.obj.get_handle():
title = _('Note') + ': %s' % self.obj.get_gramps_id()
else:
title = _('New Note')
return title
def _local_init(self):
"""
Local initialization function. Performs basic initialization,
including setting up widgets and the glade interface. This is called
by the base class of EditPrimary, and overridden here.
"""
self.top = gtk.glade.XML(const.gladeFile, "edit_note", "gramps")
win = self.top.get_widget("edit_note")
self.set_window(win, None, self.get_menu_title())
width = Config.get(Config.NOTE_WIDTH)
height = Config.get(Config.NOTE_HEIGHT)
self.window.set_default_size(width, height)
self.type = self.top.get_widget('type')
self.format = self.top.get_widget('format')
container = self.top.get_widget('container')
container.pack_start(self.build_interface())
container.show_all()
def _setup_fields(self):
self.type_selector = MonitoredDataType(
self.top.get_widget("type"),
self.obj.set_type,
self.obj.get_type,
self.db.readonly,
)
self.check = MonitoredCheckbox(
self.obj,
self.format,
self.obj.set_format,
self.obj.get_format,
)
def _connect_signals(self):
"""
Connects any signals that need to be connected. Called by the
init routine of the base class (_EditPrimary).
"""
self.define_ok_button(self.top.get_widget('ok'),self.save)
self.define_cancel_button(self.top.get_widget('cancel'))
def build_interface(self):
BUTTON = [(_('Italic'),gtk.STOCK_ITALIC,'<i>i</i>','<Control>I'),
(_('Bold'),gtk.STOCK_BOLD,'<b>b</b>','<Control>B'),
(_('Underline'),gtk.STOCK_UNDERLINE,'<u>u</u>','<Control>U'),
#('Separator', None, None, None),
]
vbox = gtk.VBox()
self.text = gtk.TextView()
self.text.set_accepts_tab(True)
# Accelerator dictionary used for formatting shortcuts
# key: tuple(key, modifier)
# value: widget, to emit 'activate' signal on
self.accelerator = {}
self.text.connect('key-press-event', self._on_key_press_event)
if self.obj and self.obj.get_format():
self.format.set_active(True)
self.text.set_wrap_mode(gtk.WRAP_NONE)
else:
self.format.set_active(False)
self.text.set_wrap_mode(gtk.WRAP_WORD)
self.spellcheck = Spell.Spell(self.text)
self.format.connect('toggled', self.flow_changed)
scroll = gtk.ScrolledWindow()
scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
scroll.set_shadow_type(gtk.SHADOW_IN)
scroll.add(self.text)
# FIXME: is this signal called at all
scroll.connect('focus-out-event', self.update)
hbox = gtk.HBox()
hbox.set_spacing(0)
hbox.set_border_width(0)
vbox.pack_start(hbox, False)
vbox.pack_start(scroll, True)
vbox.set_spacing(6)
vbox.set_border_width(6)
self.buf = EditorBuffer()
self.text.set_buffer(self.buf)
tooltips = gtk.Tooltips()
for tip, stock, markup, accel in BUTTON:
if markup:
button = gtk.ToggleButton()
image = gtk.Image()
image.set_from_stock(stock, gtk.ICON_SIZE_MENU)
button.set_image(image)
button.set_relief(gtk.RELIEF_NONE)
tooltips.set_tip(button, tip)
self.buf.setup_widget_from_xml(button, markup)
key, mod = gtk.accelerator_parse(accel)
self.accelerator[(key, mod)] = button
hbox.pack_start(button, False)
else:
hbox.pack_start(gtk.VSeparator(), False)
if self.obj:
self.empty = False
self.buf.set_text(self.obj.get(markup=True))
#log.debug("Text: %s" % self.buf.get_text())
else:
self.empty = True
self.buf.connect('changed', self.update)
self.buf.connect_after('apply-tag', self.update)
self.buf.connect_after('remove-tag', self.update)
#self.rebuild()
return vbox
def _on_key_press_event(self, widget, event):
#log.debug("Key %s (%d) was pressed on %s" %
#(gtk.gdk.keyval_name(event.keyval), event.keyval, widget))
key = event.keyval
mod = event.state
if self.accelerator.has_key((key, mod)):
self.accelerator[(key, mod)].emit('activate')
return True
def update(self, obj, *args):
if self.obj:
start = self.buf.get_start_iter()
stop = self.buf.get_end_iter()
text = self.buf.get_text(start, stop)
self.obj.set(text)
else:
print "NOTE OBJ DOES NOT EXIST"
return False
def flow_changed(self, obj):
if obj.get_active():
self.text.set_wrap_mode(gtk.WRAP_NONE)
self.obj.set_format(True)
else:
self.text.set_wrap_mode(gtk.WRAP_WORD)
self.obj.set_format(False)
def save(self, *obj):
"""
Save the data.
"""
trans = self.db.transaction_begin()
if self.obj.get_handle():
self.db.commit_note(self.obj,trans)
else:
self.db.add_note(self.obj,trans)
self.db.transaction_commit(trans, _("Edit Note"))
if self.callback:
self.callback(self.obj)
self.close()
def _cleanup_on_exit(self):
(width, height) = self.window.get_size()
Config.set(Config.NOTE_WIDTH, width)
Config.set(Config.NOTE_HEIGHT, height)
Config.sync()

View File

@ -18,6 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
from _EditNote import *
from _EditAddress import *
from _EditAttribute import *
from _EditEvent import *

View File

@ -316,7 +316,7 @@ class MonitoredCheckbox:
self.obj = obj
self.set_val = set_val
self.get_val = get_val
self.obj.set_active(get_val())
self.button.set_active(get_val())
def _on_toggle(self, obj):
self.set_val(obj.get_active())

View File

@ -14982,4 +14982,184 @@ Very High</property>
</child>
</widget>
<widget class="GtkDialog" id="edit_note">
<property name="visible">True</property>
<property name="title" translatable="yes"></property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">500</property>
<property name="default_height">400</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox25">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area25">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancel">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="ok">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-5</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox131">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkVBox" id="container">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="table79">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="n_rows">1</property>
<property name="n_columns">3</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<widget class="GtkLabel" id="label707">
<property name="visible">True</property>
<property name="label" translatable="yes">Type</property>
<property name="use_underline">False</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="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="format">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Preformatted</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</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>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>