Пример #1
0
 def load_images(self, obj):
     """
     Load the primary image into the main form if it exists.
     """
     media_list = obj.get_media_list()
     count = 0
     for media_ref in media_list:
         media_handle = media_ref.get_reference_handle()
         media = self.dbstate.db.get_media_from_handle(media_handle)
         full_path = media_path_full(self.dbstate.db, media.get_path())
         mime_type = media.get_mime_type()
         if mime_type and mime_type.startswith("image"):
             photo = Photo(self.uistate.screen_height() < 1000)
             photo.set_image(full_path, mime_type,
                             media_ref.get_rectangle())
             photo.set_uistate(self.uistate, media_handle)
         else:
             photo = Photo(self.uistate.screen_height() < 1000)
             photo.set_pixbuf(
                 full_path,
                 get_thumbnail_image(full_path, mime_type,
                                     media_ref.get_rectangle()))
         self.image_list.append(photo)
         self.top.pack_start(photo, False, False, 0)
         count += 1
     self.top.show_all()
     self.set_has_data(count > 0)
Пример #2
0
 def load_images(self, obj):
     """
     Load the primary image into the main form if it exists.
     """
     media_list = obj.get_media_list()
     count = 0
     for media_ref in media_list:
         media_handle = media_ref.get_reference_handle()
         media = self.dbstate.db.get_media_from_handle(media_handle)
         full_path = media_path_full(self.dbstate.db, media.get_path())
         mime_type = media.get_mime_type()
         if mime_type and mime_type.startswith("image"):
             photo = Photo(self.uistate.screen_height() < 1000)
             photo.set_image(full_path, mime_type, media_ref.get_rectangle())
             photo.set_uistate(self.uistate, media_handle)
         else:
             photo = Photo(self.uistate.screen_height() < 1000)
             photo.set_pixbuf(full_path,
                             get_thumbnail_image(full_path,
                                 mime_type,
                                 media_ref.get_rectangle()))
         self.image_list.append(photo)
         self.top.pack_start(photo, False, False, 0)
         count += 1
     self.top.show_all()
     self.set_has_data(count > 0)
Пример #3
0
 def draw_preview(self):
     mtype = self.obj.get_mime_type()
     if mtype:
         pb = get_thumbnail_image(media_path_full(self.db, self.obj.get_path()), mtype)
         self.pixmap.set_from_pixbuf(pb)
     else:
         pb = find_mime_type_pixbuf("text/plain")
         self.pixmap.set_from_pixbuf(pb)
Пример #4
0
 def _row_change(self, obj):
     id_list = self.get_selected_ids()
     if not (id_list and id_list[0]):
         return
     handle = id_list[0]
     obj = self.get_from_handle_func()(handle)
     pix = get_thumbnail_image(media_path_full(self.db, obj.get_path()))
     self.preview.set_from_pixbuf(pix)
     gc.collect()
Пример #5
0
 def _row_change(self, obj):
     id_list = self.get_selected_ids()
     if not (id_list and id_list[0]):
         return
     handle = id_list[0]
     obj = self.get_from_handle_func()(handle)
     pix = get_thumbnail_image(media_path_full(self.db, obj.get_path()))
     self.preview.set_from_pixbuf(pix)
     gc.collect()
Пример #6
0
 def draw_preview(self):
     mtype = self.obj.get_mime_type()
     if mtype:
         pb = get_thumbnail_image(
             media_path_full(self.db, self.obj.get_path()), mtype)
         self.pixmap.set_from_pixbuf(pb)
     else:
         pb = find_mime_type_pixbuf('text/plain')
         self.pixmap.set_from_pixbuf(pb)
Пример #7
0
    def load_photo(self, ref, obj):
        """
        Load the person's main photo using the Thumbnailer.
        """
        pixbuf = get_thumbnail_image(
            media_path_full(self.dbstate.db, obj.get_path()), obj.get_mime_type(), ref.get_rectangle()
        )

        self.obj_photo.set_from_pixbuf(pixbuf)
        self.obj_photo.show()
        self.frame_photo.show_all()
Пример #8
0
    def load_photo(self, ref, obj):
        """
        Load the person's main photo using the Thumbnailer.
        """
        pixbuf = get_thumbnail_image(
            media_path_full(self.dbstate.db, obj.get_path()),
            obj.get_mime_type(), ref.get_rectangle())

        self.obj_photo.set_from_pixbuf(pixbuf)
        self.obj_photo.show()
        self.frame_photo.show_all()
Пример #9
0
 def set_image(self, full_path, mime_type=None, rectangle=None):
     """
     Set the image to be displayed.
     """
     self.full_path = full_path
     if full_path:
         pixbuf = get_thumbnail_image(full_path, mime_type, rectangle,
                                      self.__size)
         self.photo.set_from_pixbuf(pixbuf)
         self.photo.show()
     else:
         self.photo.hide()
Пример #10
0
 def set_image(self, full_path, mime_type=None, rectangle=None):
     """
     Set the image to be displayed.
     """
     self.full_path = full_path
     if full_path:
         pixbuf = get_thumbnail_image(full_path, mime_type, rectangle,
                                      self.__size)
         self.photo.set_from_pixbuf(pixbuf)
         self.photo.show()
     else:
         self.photo.hide()
Пример #11
0
 def draw_preview(self):
     """
     Draw the two preview images. This method can be called on eg change of
     the path.
     """
     mtype = self.source.get_mime_type()
     if mtype:
         fullpath = media_path_full(self.db, self.source.get_path())
         pb = get_thumbnail_image(fullpath, mtype)
         self.pixmap.set_from_pixbuf(pb)
         self.selection.load_image(fullpath)
     else:
         pb = find_mime_type_pixbuf('text/plain')
         self.pixmap.set_from_pixbuf(pb)
         self.selection.load_image('')
Пример #12
0
 def draw_preview(self):
     """
     Draw the two preview images. This method can be called on eg change of
     the path.
     """
     mtype = self.source.get_mime_type()
     if mtype:
         fullpath = media_path_full(self.db, self.source.get_path())
         pb = get_thumbnail_image(fullpath, mtype)
         self.pixmap.set_from_pixbuf(pb)
         self.selection.load_image(fullpath)
     else:
         pb = find_mime_type_pixbuf("text/plain")
         self.pixmap.set_from_pixbuf(pb)
         self.selection.load_image("")
Пример #13
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))
         button.show_all()
         return button
     return None
Пример #14
0
 def rebuild(self):
     self._build_icon_model()
     for ref in self.media_list:
         handle = ref.get_reference_handle()
         obj = self.dbstate.db.get_object_from_handle(handle)
         if obj is None:
             #notify user of error
             from ...dialog import RunDatabaseRepair
             RunDatabaseRepair(_('Non existing media found in the Gallery'))
         else:
             pixbuf = get_thumbnail_image(
                 media_path_full(self.dbstate.db, obj.get_path()),
                 obj.get_mime_type(), ref.get_rectangle())
             self.iconmodel.append(row=[pixbuf, obj.get_description(), ref])
     self._connect_icon_model()
     self._set_label()
     self._selection_changed()
     if self.update:
         self.update()
Пример #15
0
 def rebuild(self):
     self._build_icon_model()
     for ref in self.media_list:
         handle = ref.get_reference_handle()
         obj = self.dbstate.db.get_media_from_handle(handle)
         if obj is None :
             #notify user of error
             from ...dialog import RunDatabaseRepair
             RunDatabaseRepair(
                         _('Non existing media found in the Gallery'))
         else :
             pixbuf = get_thumbnail_image(
                             media_path_full(self.dbstate.db,
                                                   obj.get_path()),
                             obj.get_mime_type(),
                             ref.get_rectangle())
             self.iconmodel.append(row=[pixbuf, obj.get_description(), ref])
     self._connect_icon_model()
     self._set_label()
     self._selection_changed()
     if self.update:
         self.update()
Пример #16
0
    def on_name_changed(self, *obj):
        """
        Called anytime the filename text window changes. Checks to
        see if the file exists. If it does, the image is loaded into
        the preview window.
        """
        fname = self.file_text.get_filename()
        if not fname:
            return
        filename = fname
        basename = os.path.basename(filename)
        (root, ext) = os.path.splitext(basename)
        old_title = self.description.get_text()

        if old_title == '' or old_title == self.temp_name:
            self.description.set_text(root)
        self.temp_name = root

        filename = find_file(filename)
        if filename:
            mtype = get_type(filename)
            image = get_thumbnail_image(filename, mtype)
            self.image.set_from_pixbuf(image)
Пример #17
0
def generate_thumbnail(full_path, mime_type, rectangle=None):
    """
    Generate thumbnails for an image rectangle.
    """
    get_thumbnail_image(full_path, mime_type, rectangle, SIZE_NORMAL)
    get_thumbnail_image(full_path, mime_type, rectangle, SIZE_LARGE)