def __closeResizeEvent__(self, w, res): """ @summary: Handle response of resize dialog. @param w: GtkDialog that raise the event. @param res: Response associated with the event. """ if (res == gtk.RESPONSE_OK): print "Response" width, height, unit = self.getData() if (width <= 0): sMessage = self.__trans__("Width must be getter than 0") __log__.info(sMessage) FactoryControls.getMessage( sMessage, title=self.__trans__("Wrong width"), type=gtk.MESSAGE_ERROR, parent=self) if (height <= 0): sMessage = self.__trans__("Height must be getter than 0") __log__.info(sMessage) FactoryControls.getMessage( sMessage, title=self.__trans__("Wrong height"), type=gtk.MESSAGE_ERROR, parent=self) if ((self.__callback__ != None) and (width > 0) and (height > 0)): self.__callback__(self, width, height, unit) w.hide()
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() != "SepiaToneAction"): __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: self.__doSepiaTone__() else: FactoryControls.getMessage(self.__trans__("Select one or more items"), title=self.__trans__("Sepia Toning"), parent=parentWindow) return
def __waitLogin__(self): """ @summary: Function that runs when facebook login is doing. """ FactoryControls.getMessage(self.__trans__("Close after sign up on facebook"), title=self.__trans__("Facebook Sign Up"), parent=self.__blockWindow__)
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() != "RotateAction") and (action.get_name() != "RotateLeftAction") and (action.get_name() != "RotateRightAction")): __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: if (action.get_name() == "RotateLeftAction"): self.__doRotate__(None, 90) elif(action.get_name() == "RotateRightAction"): self.__doRotate__(None, 270) elif(action.get_name() == "RotateAction"): rotateDialog = RotateDialog(callback=self.__doRotate__, parent=parentWindow) if (iNRows == 1): iter = model.get_iter(paths[0]) itemPath = model.get_value(iter, self.__currentTab__.COLUMN_SOURCE) item = self.__currentTab__.getCore().getItem(itemPath) rotateDialog.setData(item) __log__.debug("Rotate dialog created. %s" % rotateDialog) rotateDialog.run() pass else: FactoryControls.getMessage(self.__trans__("Select one or more items"), title=self.__trans__("Rotate"), parent=parentWindow) return
def __revokeEvent__(self, b): """ @summary: Process to revoke or remove previous login @param b: Action associated with event. """ if (FactoryControls.getConfirmMessage(self.__trans__("Do you like remove stored user of Google?"), title=self.__trans__("Google remove"), parent=self, gtkLock=False, returnBoolean=True)): self.__session__.remove() self.__initData__()
def __loginEvent__(self, b): """ @summary: Process login event. @param b: Action associated with event. """ doLogin = True if (self.__session__.isLogged()): doLogin = FactoryControls.getConfirmMessage(self.__trans__("You are signed up Google\nDo you like change current user of Google?"), title=self.__trans__("Google Sign In"), parent=self, gtkLock=False, returnBoolean=True) self.__session__.login(parent=self, forceLogin=doLogin)
def __loginEvent__(self, b): """ @summary: Process login event. @param b: Action associated with event. """ doLogin = True if (self.__fbsession__.isLogged()): doLogin = FactoryControls.getConfirmMessage(self.__trans__("You are signed up facebook\nDo you like sign up facebook?"), title=self.__trans__("Facebook Sign Up"), parent=self, gtkLock=False, returnBoolean=True) self.__fbsession__.login(self.__waitLogin__, forceLogin=doLogin)
def __loginEvent__(self, b): """ @summary: Process login event. @param b: Action associated with event. """ doLogin = True if (self.__gdata__.isLogged()): doLogin = FactoryControls.getConfirmMessage(self.__trans__("You are signed in picasa\nDo you like sign in with another user in picasa?"), title=self.__trans__("Picasa Sign In"), parent=self.__blockWindow__, gtkLock=False, returnBoolean=True) self.__gdata__.login(parent=self, forceLogin=doLogin, store=False)
def __closeEvent__(self, w, res): """ @summary: Handle response of rotate dialog. @param w: GtkDialog that raise event. @param res: Response associated with the event. """ if res == gtk.RESPONSE_OK: degrees = self.getData() if degrees == -1: FactoryControls.getMessage( self.__trans__("There is not valid degrees selected.\nPlease select correct degrees"), title=self.__trans__("Rotate"), type=gtk.MESSAGE_ERROR, parent=self, ) return gtk.FALSE if self.__callback__ != None: self.__callback__(self, degrees) w.hide()
def PreDoProject(self, core, blockWindow=None): """ @summary: Execute before items of project process. @param core: CamCore to execute. @param blockWindow: GtkWindow to block by any dialog. @return: True if all is right. """ self.__mainWindow__ = blockWindow if (self.__target__ == None): __log__.debug("Target folder is not defined, executing target callback.") self.setTargetFolder(doBlock=False) if (self.__target__ == None): __log__.debug("There is not target folder") FactoryControls.getMessage( self.__trans__("Target folder is not defined."), title=self.__trans__("Execute"), type=gtk.MESSAGE_ERROR, parent=self.__mainWindow__, gtkLock=False) __log__.debug("Target folder is not defined, exiting from execute dialog.") return False return True
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