Skip to content

Commit

Permalink
Use large thumbnails in album
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-Hall committed May 17, 2020
1 parent 381b1ce commit 5370a42
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CombinedView/combinedview.gpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
id = 'combinedview',
name = _("Combined"),
description = _("A view showing relationships and events for a person"),
version = '1.0.18',
version = '1.0.19',
gramps_target_version = '5.1',
status = STABLE,
fname = 'combinedview.py',
Expand Down
51 changes: 25 additions & 26 deletions CombinedView/combinedview.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
from gramps.gen.utils.db import get_participant_from_event
from gramps.gui.utils import open_file_with_default_application
from gramps.gen.datehandler import displayer, get_date
from gramps.gen.utils.thumbnails import get_thumbnail_image
from gramps.gen.utils.thumbnails import (get_thumbnail_image, SIZE_NORMAL,
SIZE_LARGE)
from gramps.gen.config import config
from gramps.gen.relationship import get_relationship_calculator
from gramps.gui import widgets
Expand Down Expand Up @@ -762,22 +763,28 @@ def write_person_title(self, person):
# image
image_list = person.get_media_list()
if image_list:
mobj = self.dbstate.db.get_media_from_handle(image_list[0].ref)
if mobj and mobj.get_mime_type()[0:5] == "image":
pixbuf = get_thumbnail_image(
media_path_full(self.dbstate.db,
mobj.get_path()),
rectangle=image_list[0].get_rectangle())
image = Gtk.Image()
image.set_from_pixbuf(pixbuf)
button = Gtk.Button()
button.add(image)
button.connect("clicked", lambda obj: self.view_photo(mobj))
button = self.get_thumbnail(image_list[0], size=SIZE_NORMAL)
if button:
mbox.pack_end(button, False, True, 0)

mbox.show_all()
self.header.pack_start(mbox, False, True, 0)

def get_thumbnail(self, media_ref, size):
mobj = self.dbstate.db.get_media_from_handle(media_ref.ref)
if mobj and mobj.get_mime_type()[0:5] == "image":
pixbuf = get_thumbnail_image(
media_path_full(self.dbstate.db,
mobj.get_path()),
rectangle=media_ref.get_rectangle(),
size=size)
image = Gtk.Image()
image.set_from_pixbuf(pixbuf)
button = Gtk.Button()
button.add(image)
button.connect("clicked", lambda obj: self.view_photo(mobj))
return button
return None

def view_photo(self, photo):
"""
Open this picture in the default picture viewer.
Expand Down Expand Up @@ -1376,19 +1383,11 @@ def write_media(self, media_list, event):
for media_ref in media_list:

mobj = self.dbstate.db.get_media_from_handle(media_ref.ref)
if mobj and mobj.get_mime_type()[0:5] == "image":
src_file = media_path_full(self.dbstate.db, mobj.get_path())
try:
pixbuf = GdkPixbuf.Pixbuf.new_from_file(src_file)
except:
default = os.path.join(IMAGE_DIR, "image-missing.png")
pixbuf = GdkPixbuf.Pixbuf.new_from_file(default)

image = Gtk.Image()
image.set_from_pixbuf(pixbuf)
image.show()
button = self.get_thumbnail(media_ref, size=SIZE_LARGE)
button.show_all()
if button:

self.vbox2.add(image)
self.vbox2.add(button)

vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

Expand Down Expand Up @@ -1416,7 +1415,7 @@ def write_media(self, media_list, event):
vbox.show_all()


self.vbox2.attach_next_to(vbox, image,
self.vbox2.attach_next_to(vbox, button,
Gtk.PositionType.RIGHT, 1, 1)

##############################################################################
Expand Down

0 comments on commit 5370a42

Please sign in to comment.