def __refreshImage__(self, img): """ @summary: Refresh image on ImageArea. """ if (img != None) and (self.__item__ != None): meta = ImgMeta(self.__item__.getPath(), image=img) im = self.__iPreview__.getImageControl() if meta != None: pb = meta.getIcon(rescale=100.0, maxHeight=im.getMaxSize()[1]) im.set_from_pixbuf(pb) else: __log__.warning("It could not retrieve metadata from item. %s" % self.__item__.getPath()) else: __log__.debug("Img or Item is None. It can not refresh image.")
def __updateImageTarget__(self, iter, item, delMetadata=False): """ @summary: Updates image of target file. @param iter: Iter of listview that matches with target file. @param item: CamItem to update. @param delMetadata: True to delete metadata at the end of function """ little = None big = None item.waitLoadThumbnail() imgPil = item.doPreview() if (imgPil != None): metaData = ImgMeta(item.getPath(), image=imgPil) else: metaData = item.getMetadata() UIUtils.setIterData(self.getModel(), iter, self.COLUMN_LOADING, True) if (self.__doPreviewList__): if (not self.__model__.get_value(iter, self.COLUMN_DO_IMG)): __log__.debug("Get thumbnail from %s" % file) little = metaData.getIcon(maxHeight=self.__maxHeight__, rescale=self.__rescalePercent__) if (little): UIUtils.setIterData(self.__model__, iter, self.COLUMN_IMAGE, little) UIUtils.setIterData(self.__model__, iter, self.COLUMN_DO_IMG, True) __log__.debug("Doing preview image of %s" % self.__model__.get_value(iter, self.COLUMN_SOURCE)) if (metaData != None): big = metaData.getIcon(rescale=100, maxHeight=self.__maxHeightImageIconView__) if (big): __log__.debug("Updating data on model for %s." % self.__model__.get_value(iter, self.COLUMN_SOURCE)) UIUtils.setIterData(self.__model__, iter, self.COLUMN_PREVIEW, big) if (delMetadata and (metaData != None)): del metaData UIUtils.setIterData(self.getModel(), iter, self.COLUMN_LOADING, False)
def openPreview (self, b): """ @summary: Open image. @param b: Button that threw event. """ if (self.__currentTab__ == None): __log__.debug("There is not current project") return paths = self.__currentTab__.getSelection() model = self.__currentTab__.getModel() if ((paths == None) or (model == None)): __log__.error("It can not recover tree selection. Set selection at 0.") iNRows = 0 else: iNRows = len(paths) if iNRows > 0: path = paths[0] iter = model.get_iter(path) if (iter != None): file = model.get_value(iter, 1) meta = ImgMeta(file) meta.show() else: __log__.error("It can not recover iter from path %s. Abort preview" % path) FactoryControls.getMessage(_("It can not show image"), title=_("Preview"), type=gtk.MESSAGE_ERROR, parent=self.__mainWindow__) else: FactoryControls.getMessage(_("Select one item"), title=_("Preview"), parent=self.__mainWindow__)
def callbackAction(self, action, currentTab, userData=None): """ @summary: Callback that will be thrown when any action is actived. @param action: gtk.Action activated. @param currentTab: Current Tab. pycamimg.ui.TabProject.TabProject @param userData: User data """ if (action.get_name() != "ResizeAction"): __log__.warning("It is not a valid action. %s" % action.get_name()) return if (currentTab == None): __log__.warning("There is not current project") return self.__currentTab__ = currentTab parentWindow = userData paths = currentTab.getSelection() model = currentTab.getModel() if ((paths == None) or (model == None)): __log__.error("It can not recover tree selection. Set selection at 0.") iNRows = 0 else: iNRows = len(paths) if iNRows > 0: resizeDialog = ResizeDialog(callback=self.__doResize__, parent=parentWindow) __log__.debug("Resize dialog created. %s" % resizeDialog) if (iNRows > 1): resizeDialog.setData(100.0, 100.0, ImageUtils.PERCENT) else: path = paths[0] iter = model.get_iter(path) file = model.get_value(iter, 1) size = (100.0, 100.0) scale = ImageUtils.PERCENT resizeNew = True item = currentTab.getCore().getItem(file) if (item != None): op = item.getOperation(Operation.OPERATION) if (op != None): size = (op.getParameter("width"), op.getParameter("height")) scale = op.getParameter("scale") if (scale == ImageUtils.PERCENT): meta = ImgMeta(file) srcSize = meta.getSize() size = ( srcSize[0] * (size[0] / float(100)), srcSize[1] * (size[1] / float(100))) scale = ImageUtils.PIXEL resizeDialog.setData(size[0], size[1], scale, srcSize) resizeNew = False if (resizeNew): meta = ImgMeta(file) size = meta.getSize() scale = ImageUtils.PIXEL resizeDialog.setData(size[0], size[1], scale) resizeDialog.run() else: FactoryControls.getMessage(self.__trans__("Select one or more items"), title=self.__trans__("Resize"), parent=parentWindow) return