* src/plugins/SimpleBookTitle.py: Add functionality to "From file".

* src/AddMedia.py: Make it a modal dialog.
* src/MediaView.py: Call AddMedia as modal dialog.
* src/imagesel.glade: Change responses for dialog buttons.


svn: r2112
This commit is contained in:
Alex Roitman 2003-09-10 13:38:02 +00:00
parent 791dc35a50
commit 9132d47c5c
5 changed files with 46 additions and 11 deletions

View File

@ -1,3 +1,9 @@
2003-09-10 Alex Roitman <shura@alex.neuro.umn.edu>
* src/plugins/SimpleBookTitle.py: Add functionality to "From file".
* src/AddMedia.py: Make it a modal dialog.
* src/MediaView.py: Call AddMedia as modal dialog.
* src/imagesel.glade: Change responses for dialog buttons.
2003-09-09 Alex Roitman <shura@alex.neuro.umn.edu>
* src/plugins/SimpleBookTitle.py
(SimpleBookTitleDialog.add_user_options): Add a tab for an image,

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000 Donald N. Allingham
# Copyright (C) 2000-2003 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
@ -66,7 +66,7 @@ class AddMediaObject:
a media object from the file system, while providing a description.
"""
def __init__(self,db,update):
def __init__(self,db,update=None):
"""
Creates and displays the dialog box
@ -81,19 +81,18 @@ class AddMediaObject:
self.file_text = self.glade.get_widget("fname")
self.update = update
self.temp_name = ""
self.object = None
Utils.set_titles(self.window,self.glade.get_widget('title'),
_('Select a media object'))
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.show()
def on_savephoto_clicked(self,obj):
def on_savephoto_clicked(self):
"""
Callback function called with the save button is pressed.
A new media object is created, and added to the database.
@ -126,8 +125,9 @@ class AddMediaObject:
mobj.setPath(name)
Utils.modified()
self.update()
Utils.destroy_passed_object(obj)
if self.update:
self.update()
self.object = mobj
def on_name_changed(self,obj):
"""
@ -152,3 +152,14 @@ class AddMediaObject:
else:
image = gtk.gdk.pixbuf_new_from_file(Utils.find_icon(type))
self.image.set_from_pixbuf(image)
def run(self):
val = self.window.run()
if val == gtk.RESPONSE_OK:
self.on_savephoto_clicked()
self.window.destroy()
return self.object
else:
self.window.destroy()
return None

View File

@ -233,7 +233,8 @@ class MediaView:
def on_add_clicked(self,obj):
"""Add a new media object to the media list"""
import AddMedia
AddMedia.AddMediaObject(self.db,self.load_media)
am = AddMedia.AddMediaObject(self.db,self.load_media)
am.run()
def on_edit_clicked(self,obj):
"""Edit the properties of an existing media object in the media list"""

View File

@ -35,7 +35,7 @@
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">0</property>
<property name="response_id">-6</property>
<signal name="clicked" handler="destroy_passed_object" object="imageSelect"/>
</widget>
</child>
@ -49,7 +49,7 @@
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">0</property>
<property name="response_id">-5</property>
<signal name="clicked" handler="on_savephoto_clicked" object="imageSelect"/>
</widget>
</child>

View File

@ -38,6 +38,7 @@ from QuestionDialog import ErrorDialog
from gettext import gettext as _
import SelectObject
import Utils
import AddMedia
import gtk
import gnome
@ -289,7 +290,23 @@ class SimpleBookTitleDialog(Report.BareReportDialog):
self.remove_obj_button.set_sensitive(gtk.TRUE)
def select_file(self, obj):
pass
a_o = AddMedia.AddMediaObject(self.db)
object = a_o.run()
if object:
self.object_id = object.getId()
else:
return
self.obj_title.set_text(object.getDescription())
the_type = Utils.get_mime_description(object.getMimeType())
path = object.getPath()
thumb_path = Utils.thumb_path(self.db.getSavePath(),object)
pexists = os.path.exists(path)
if pexists and os.path.exists(thumb_path):
self.preview.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(thumb_path))
else:
icon_image = gtk.gdk.pixbuf_new_from_file(Utils.find_icon(the_type))
self.preview.set_from_pixbuf(icon_image)
self.remove_obj_button.set_sensitive(gtk.TRUE)
def on_ok_clicked(self, obj):
"""The user is satisfied with the dialog choices. Parse all options