From 9132d47c5c913d2b5a58bd3ce2af87f6c5d46834 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Wed, 10 Sep 2003 13:38:02 +0000 Subject: [PATCH] * 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 --- ChangeLog | 6 ++++++ src/AddMedia.py | 25 ++++++++++++++++++------- src/MediaView.py | 3 ++- src/imagesel.glade | 4 ++-- src/plugins/SimpleBookTitle.py | 19 ++++++++++++++++++- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d8f17e16..c42a3ccb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-09-10 Alex Roitman + * 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 * src/plugins/SimpleBookTitle.py (SimpleBookTitleDialog.add_user_options): Add a tab for an image, diff --git a/src/AddMedia.py b/src/AddMedia.py index 144a04b25..89e9075c2 100644 --- a/src/AddMedia.py +++ b/src/AddMedia.py @@ -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 diff --git a/src/MediaView.py b/src/MediaView.py index 848964468..5346da52c 100644 --- a/src/MediaView.py +++ b/src/MediaView.py @@ -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""" diff --git a/src/imagesel.glade b/src/imagesel.glade index 288c8ed51..29a2ec566 100644 --- a/src/imagesel.glade +++ b/src/imagesel.glade @@ -35,7 +35,7 @@ gtk-cancel True GTK_RELIEF_NORMAL - 0 + -6 @@ -49,7 +49,7 @@ gtk-ok True GTK_RELIEF_NORMAL - 0 + -5 diff --git a/src/plugins/SimpleBookTitle.py b/src/plugins/SimpleBookTitle.py index d36429c0a..52ada989e 100644 --- a/src/plugins/SimpleBookTitle.py +++ b/src/plugins/SimpleBookTitle.py @@ -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