def __createUploderHBox(self, labelName, uploaders, fileType=None): """returns HBox with label with file type, and combobox with given uploaders. All given uploaders should be capable of handling given fileType""" if not fileType: fileType = labelName hbox = gtk.HBox(True, 0) label = gtk.Label(labelName) hbox.pack_start(label, False, True, 0) combobox = createCombobox(uploaders) hbox.pack_start(combobox, False, True, 0) self.__initUploaderComboboxSelectedValue(fileType, uploaders, combobox) combobox.connect("changed", self.__comboboxPrefferedUploader_changed, labelName, uploaders) return hbox
def __createCopyAllLinks(self): if self.__copyAllLinksCombobox: self.__copyAllLinksCombobox.destroy() else: label = gtk.Label(_("All files:")) self.vboxCopyAllLinks.pack_start(label, False, False, 0) label.show() comboBox = createCombobox(self.__commonLinkNames) comboBox.connect("changed", self.copyAllLinks) comboBox.connect("notify::popup-shown", self.__windowClicked) self.vboxCopyAllLinks.pack_start(comboBox, False, False, 0) comboBox.show() self.__copyAllLinksCombobox = comboBox self.vboxCopyAllLinks.show()
def __createCopyAllLinks(self): if self.__copyAllLinksCombobox: self.__copyAllLinksCombobox.destroy() #else: # label = gtk.Label(_("All files:")) # self.vboxCopyAllLinks.pack_start(label, False, False, 0) # label.show() copyAllButton = gtk.Button(label = "Copy All Links") copyAllButton.connect("clicked", self.copyAllLinks, 0) copyAllButton.show() self.vboxCopyAllLinks.pack_start(copyAllButton, False, False, 0) comboBox = createCombobox(self.__commonLinkNames) comboBox.connect("changed", self.copyAllLinks) comboBox.connect("notify::popup-shown", self.__windowClicked) #self.vboxCopyAllLinks.pack_start(comboBox, False, False, 0) #comboBox.show() self.__copyAllLinksCombobox = copyAllButton self.vboxCopyAllLinks.show()
def addFiles(self, urls, firstAdding=False): """adds progressbar, buttons, thumbnail and status menu entry for each file to GUI. calls set windows size if there is more than one file in the windows also shows copy all link combobox starts uploding given files""" files = self.urlsToPaths(urls) addedFiles = [] vbox = self.vboxFiles numberOfFilesAddedEarierl = len(self.__comboBoxes) totalNumberOfFiles = numberOfFilesAddedEarierl for file in files: hbox = gtk.HBox(False, 0) vbox.pack_start(hbox, False, False, 0) hbox.show() from stat import * st = os.stat(file) if (st[ST_SIZE] > 5000000): from subprocess import Popen proc=Popen("zenity --question --text='File may be to large to transfer. Continue?'", shell=True ) proc.communicate() if proc.returncode: break #thumbnail image = gtk.Image() image.set_from_pixbuf(createThumbnail(file)) hbox.pack_start(image, False, False, 8) image.show() vboxSmall = gtk.VBox(False, 5) hbox.pack_start(vboxSmall, False, False, 0) vboxSmall.show() #filename label = gtk.Label(file.split('/')[-1]) label.set_ellipsize(pango.ELLIPSIZE_MIDDLE) label.set_alignment(0, 0.5) vboxSmall.pack_start(label, False, False, 0) label.show() #progress bar pbar = gtk.ProgressBar() self.__pbars.append(pbar) vboxSmall.pack_start(pbar, False, False, 0) pbar.show() #comboBox = createCombobox(uploader.getReturnedLinkTypes()) comboBox = createCombobox() self.links.append([]) comboBox.connect("changed", self.copyLink, totalNumberOfFiles) comboBox.connect("notify::popup-shown", self.__windowClicked) #comboBox.show() # "show" comboboxes to make windows size calculation precise(comboboxes will be hidden again before window will be desplayed) self.__comboBoxes.append(comboBox) #Copy Link button - not displayed until upload finished copyButton = gtk.Button(label = "Copy Link") copyButton.connect("clicked", self.copyLink, totalNumberOfFiles, 0) self.__cplinkButton.append(copyButton) vboxSmall.pack_start(copyButton, False, False, 0) # Cancel upload button cancelButton = gtk.Button(label = "Cancel") cancelButton.connect("clicked", self.cancelUpload, totalNumberOfFiles) self.__cancelUploadButton.append(cancelButton) self.__cancelled.append(0) vboxSmall.pack_start(cancelButton, False, False, 0) cancelButton.show() #cancel label to appear after upload cancelled label = gtk.Label("Cancelled") label.set_size_request(150, 50) label.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white")) eb = gtk.EventBox() eb.add(label) eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("grey")) self.__cancelledLabel.append(eb) vboxSmall.pack_start(eb, False, False, 0) label.show() separator = gtk.HSeparator() vbox.pack_start(separator, False, False, 4) separator.show() uploader = getUploader(file) addedFiles.append(file) uploadFileWrapper(uploader,self.fileUploadFailed, file,self.fileUploaded,self.progress,totalNumberOfFiles, self.__semaphore) totalNumberOfFiles += 1 if firstAdding: self.__addFooter() self.__createStatusIconMenu(addedFiles) else: self.insertFilesToStatusIconMenu(addedFiles, numberOfFilesAddedEarierl) # if totalNumberOfFiles > 1: # self.__createCopyAllLinks() self.setWindowSize() while numberOfFilesAddedEarierl < totalNumberOfFiles: # hide comboboxes, they will be displayed when links are ready self.__comboBoxes[numberOfFilesAddedEarierl].hide() numberOfFilesAddedEarierl += 1 self.__statusIcon.set_blinking(False)
def addElement(self, data): """add element to history panel with thumb, links and information about image""" hbox = gtk.HBox(False, 0) self.panel.pack_start(hbox, False, False, 0) hbox.show() image = self.getImageThumb(data) image.set_padding(10,10) image.set_tooltip_text(data[6]) hbox.pack_start(image, False, False, 0) image.show() vboxSmall = gtk.VBox(True, 0) hbox.pack_start(vboxSmall, False, False, 0) vboxSmall.show() table = gtk.Table(4, 3, False) vboxSmall.pack_start(table, True, True, 0) table.set_size_request(400, -1) table.set_border_width(10) table.show() labelname = gtk.Label() labelname.set_markup("<b>"+_("Original filename:")+"</b>") labelname.set_alignment(xalign=0, yalign=0.5) labelname.show() table.attach(labelname, 0, 1, 0, 1) name=gtk.Label(data[6]) name.set_alignment(xalign=0, yalign=0.5) name.show() table.attach(name, 1, 2, 0, 1) labeldate = gtk.Label() labeldate.set_markup("<b>"+_("Upload date:")+"</b>") labeldate.set_alignment(xalign=0, yalign=0.5) labeldate.show() table.attach(labeldate, 0, 1, 1, 2) date=gtk.Label(convert_date(data[5])) date.set_alignment(xalign=0, yalign=0.5) date.show() table.attach(date, 1, 2, 1, 2) labelsize = gtk.Label() labelsize.set_markup("<b>"+_("Filesize:")+"</b>") labelsize.set_alignment(xalign=0, yalign=0.5) labelsize.show() table.attach(labelsize, 0, 1, 2, 3) size=gtk.Label(convert_bytes(data[7])) size.set_alignment(xalign=0, yalign=0.5) size.show() table.attach(size, 1, 2, 2, 3) labellink=gtk.Label() labellink.set_markup("<b>"+_("Links:")+"</b>") labellink.set_alignment(xalign=0, yalign=0.5) labellink.show() table.attach(labellink, 0, 1, 3, 4) if isImage(data[9]): links, typesOfLinks, basicLinks = createLinks(data[2], data[6], data[4], data[3]) else: links, typesOfLinks, basicLinks = createLinks(data[2], data[6], None, data[3]) self.links.append(links) comboBox = createCombobox(typesOfLinks) comboBox.connect("changed", self.copyLink, self.fileNumber) comboBox.show() self.fileNumber += 1 table.attach(comboBox, 1, 2, 3, 4) toolButton = gtk.ToolButton(gtk.STOCK_REMOVE) toolButton.set_tooltip_text(_("Remove")) toolButton.connect("clicked", self.removeElement, self.totalNumberOfElements, data[0]) table.attach(toolButton, 2,3, 0,3) separator = gtk.HSeparator() self.panel.pack_start(separator, False, False, 4) separator.show() self.elements[self.totalNumberOfElements] = hbox self.totalNumberOfElements += 1 self.elements[self.totalNumberOfElements] = separator self.totalNumberOfElements += 1
def addFiles(self, urls, firstAdding=False): """adds progressbar, buttons, thumbnail and status menu entry for each file to GUI. calls set windows size if there is more than one file in the windows also shows copy all link combobox starts uploding given files""" files = self.urlsToPaths(urls) addedFiles = [] vbox = self.vboxFiles numberOfFilesAddedEarierl = len(self.__comboBoxes) totalNumberOfFiles = numberOfFilesAddedEarierl for file in files: hbox = gtk.HBox(False, 0) vbox.pack_start(hbox, False, False, 0) hbox.show() vboxSmall = gtk.VBox(False, 0) hbox.pack_start(vboxSmall, False, False, 0) vboxSmall.show() label = gtk.Label(file.split('/')[-1]) vboxSmall.pack_start(label, False, False, 0) label.show() pbar = gtk.ProgressBar() self.__pbars.append(pbar) vboxSmall.pack_start(pbar, False, False, 0) pbar.show() #comboBox = createCombobox(uploader.getReturnedLinkTypes()) comboBox = createCombobox() self.links.append([]) comboBox.connect("changed", self.copyLink, totalNumberOfFiles) comboBox.connect("notify::popup-shown", self.__windowClicked) comboBox.show() # "show" comboboxes to make windows size calculation precise(comboboxes will be hidden again before window will be desplayed) self.__comboBoxes.append(comboBox) vboxSmall.pack_start(comboBox, False, False, 0) image = gtk.Image() image.set_from_pixbuf(createThumbnail(file)) hbox.pack_start(image, False, False, 8) image.show() separator = gtk.HSeparator() vbox.pack_start(separator, False, False, 4) separator.show() uploader = getUploader(file) addedFiles.append(file) uploadFileWrapper(uploader,self.fileUploadFailed, file,self.fileUploaded,self.progress,totalNumberOfFiles, self.__semaphore) totalNumberOfFiles += 1 if firstAdding: self.__addFooter() self.__createStatusIconMenu(addedFiles) else: self.insertFilesToStatusIconMenu(addedFiles, numberOfFilesAddedEarierl) # if totalNumberOfFiles > 1: # self.__createCopyAllLinks() self.setWindowSize() while numberOfFilesAddedEarierl < totalNumberOfFiles: # hide comboboxes, they will be displayed when links are ready self.__comboBoxes[numberOfFilesAddedEarierl].hide() numberOfFilesAddedEarierl += 1 self.__statusIcon.set_blinking(False)