def on_message_typed_in_clicked(self, widget): """When next button in "enter message" window gets clicked, this function checks if the amount of entered characters is not too many for the capacity of the chosen algorithm. If length is ok, it calls stegui_ctrl.embed to embed the message into the given file, writing it into the given output file. If not, it changes the windows info text to tell the user how too many characters he entered. """ msg_field = self.xml.get_widget('message_field') end = msg_field.get_buffer().get_end_iter() start = msg_field.get_buffer().get_start_iter() self.message = msg_field.get_buffer().get_text(start,end,True) if len(self.message) > self.cap: self.msg_in_label.set_text("Fehler! Sie haben "+str(len(self.message)-self.cap)+" Zeichen zu viel eingegeben!") else: if stegui_ctrl.embed_or_extract(self.algo, self.filename, self.destfile, self.message,self.para, True): self.window2.hide() self.window6 = self.xml.get_widget('window6') self.xml.get_widget('cover_img').set_from_file(self.filename) self.xml.get_widget('stego_img').set_from_file(self.destfile) self.window6.show() else: print "error embedding message."
def input_file_chosen_clicked(self, widget): """When next button in "choose input file" window gets clicked, this function uses stegui_ctrl.get_capacity to get the capacity and saves it in self.capacity. """ self.filename = self.xml.get_widget('choose_input_file').get_filename() if self.embed: #TODO: being a supported filetype is not enough! if self.filename[-3:] in stegui_ctrl.supported_filetypes: self.window1.hide() self.cap = stegui_ctrl.get_capacity(self.algo, self.filename, self.para) / 8 self.window5 = self.xml.get_widget('window5') self.window5.show() else: self.message = stegui_ctrl.embed_or_extract(self.algo, self.filename, None,None, self.para, False) self.msg_field = self.xml.get_widget('hidden_message') self.msg_field.get_buffer().set_text(self.message) self.window7 = self.xml.get_widget('window7') self.window1.hide() self.window7.show()