def __insert_text_cb(self, buf, unused_location, text, unused_len): command = self.get_command_line() if text == "\t" and command.strip() != "": # If input text is '\t' and command doesn't start with spaces or tab # prevent GtkTextView to insert the text "\t" for autocompletion. GObject.signal_stop_emission_by_name(buf, "insert-text") self.show_autocompletion(command)
def signal_sftp_start(self, _): GObject.signal_stop_emission_by_name(self.application, 'sftp-client-start') if self.sftp_window is None: connection = self.application._ssh_forwarder if connection is None: message = 'The King Phisher client does not have an active SSH connection\n' message += 'to the server. The SFTP client plugin can not be used.' gui_utilities.show_dialog_error( 'No SSH Connection', self.application.get_active_window(), message ) return ssh = connection.client self.logger.debug('loading gtk builder file from: ' + sftp_utilities.gtk_builder_file) try: manager = client.FileManager(self.application, ssh, self.config) except paramiko.ssh_exception.ChannelException as error: self.logger.error('an ssh channel exception was raised while initializing', exc_info=True) if len(error.args) == 2: details = "SSH Channel Exception #{0} ({1})".format(*error.args) else: details = 'An unknown SSH Channel Exception occurred.' gui_utilities.show_dialog_error('SSH Channel Exception', self.application.get_active_window(), details) return except paramiko.ssh_exception.SSHException: self.logger.error('an ssh exception was raised while initializing', exc_info=True) gui_utilities.show_dialog_error('SSH Exception', self.application.get_active_window(), 'An error occurred in the SSH transport.') return self.sftp_window = manager.window self.sftp_window.connect('destroy', self.signal_window_destroy) self.sftp_window.show() self.sftp_window.present()
def on_num_entry_insert( self, editable: Gtk.Editable, new_text: str, new_text_length: int, position: int, digits: int = 0, ): """React to insertion into a Gtk.Editable and only allow numbers. Args: editable (Gtk.Editable): The Gtk.Editable that received the signal new_text (str): The new text to insert new_text_length (int): The length of the new text, in bytes, or -1 if new_text is nul-terminated position (int): The position, in characters, at which to insert the new text. digits (int, optional): How many digits to allow after a decimal point (comma). 0 to disallow decimal points. Defaults to 0 """ old_text: str = editable.get_text() cursor_pos: int = editable.get_position() if self.editable: if digits > 0: if cursor_pos > 0: new_text = new_text.replace(",", "") else: new_text = new_text[0] + new_text[1:].replace(",", "") if new_text != "" and not str.isnumeric(new_text): GObject.signal_stop_emission_by_name(editable, "insert-text") elif "," in old_text and cursor_pos - old_text.index(",") > digits: GObject.signal_stop_emission_by_name(editable, "insert-text")
def dummy_scroll_handler(widget, _): """scroll-event handler that just disables the default handler. Tag field widgets should use this to prevent the user from accidentally modifying tags by scrolling. """ GObject.signal_stop_emission_by_name(widget, 'scroll-event') return False
def child3_key_pressed_handler(widget, key_code): if key_code == curses.KEY_LEFT: stack.set_active_child(child2_box) elif key_code == curses.KEY_RIGHT: stack.set_active_child(child1_box) else: return False stack.focus_first() GObject.signal_stop_emission_by_name(child3_box, "key-pressed") return True
def onResponse(self,widget,id): if id == Gtk.ResponseType.CLOSE or \ id == Gtk.ResponseType.NONE or \ id == Gtk.ResponseType.DELETE_EVENT: self.hide() elif id == DirectorDialog.RESPONSE_RENDER: self.animation.set_avi_file(self.txt_temp_avi.get_text()) try: self.generate(self.converterpath is not None) except (SanityCheckError, UserCancelledError): # prevent dialog closing if being run GObject.signal_stop_emission_by_name(self, "response") else: self.hide()
def onResponse(self, widget, id): if id == Gtk.ResponseType.CLOSE or \ id == Gtk.ResponseType.NONE or \ id == Gtk.ResponseType.DELETE_EVENT: self.hide() elif id == DirectorDialog.RESPONSE_RENDER: self.animation.set_avi_file(self.txt_temp_avi.get_text()) try: self.generate(self.converterpath is not None) except (SanityCheckError, UserCancelledError): # prevent dialog closing if being run GObject.signal_stop_emission_by_name(self, "response") else: self.hide()
def onResponse(self,widget,id): if id == Gtk.ResponseType.CLOSE or \ id == Gtk.ResponseType.NONE or \ id == Gtk.ResponseType.DELETE_EVENT: self.hide() elif id == Gtk.ResponseType.APPLY: self.onApply() # prevent dialog closing if being run GObject.signal_stop_emission_by_name(self, "response") elif id == Gtk.ResponseType.OK: self.onApply() self.hide() elif id == BrowserDialog.RESPONSE_REFRESH: self.onRefresh() else: print("unexpected response %d" % id)
def onResponse(self, widget, id): if id == Gtk.ResponseType.CLOSE or \ id == Gtk.ResponseType.NONE or \ id == Gtk.ResponseType.DELETE_EVENT: self.hide() elif id == Gtk.ResponseType.APPLY: self.onApply() # prevent dialog closing if being run GObject.signal_stop_emission_by_name(self, "response") elif id == Gtk.ResponseType.OK: self.onApply() self.hide() elif id == BrowserDialog.RESPONSE_REFRESH: self.onRefresh() else: print("unexpected response %d" % id)
def scroll_event_cb(widget, unused_event): GObject.signal_stop_emission_by_name(widget, "scroll-event") return False
def on_response(self, widget, response): if response < 0: GObject.signal_stop_emission_by_name(widget, 'response') return True
def child_added_cb(clip, elem): if elem not in children: clip.remove(elem) GObject.signal_stop_emission_by_name(clip, "child-added")
def _on_scroll_event(self, widget, event): # Prevent a scroll in the list to get caught by the scale GObject.signal_stop_emission_by_name(widget, "scroll-event") return False
def do_key_pressed(self, window, key_code): # ignore the backspace key press if key_code == curses.KEY_BACKSPACE: GObject.signal_stop_emission_by_name(self, 'key-pressed') return True return False
def validate_insert(self, obj, text, text_length, position): if re.match('[^\d\.\*\/\-\+]', text): GObject.signal_stop_emission_by_name(obj, 'insert-text')
def drop_scroll_event(widget: Gtk.Widget, event): GObject.signal_stop_emission_by_name(widget, 'scroll-event')
def onResponse(self, widget, id): if id == Gtk.ResponseType.OK and not self.check_fields(): GObject.signal_stop_emission_by_name(self.dialog, "response")
def line_entry_insert_text(entry, new_text, length, position): if not new_text.isdigit(): GObject.signal_stop_emission_by_name(entry, 'insert-text') return
def on_html_text_view_copy_clipboard(self, unused_data): clipboard = self.get_clipboard(Gdk.SELECTION_CLIPBOARD) selected = self.get_selected_text() clipboard.set_text(selected, -1) GObject.signal_stop_emission_by_name(self, 'copy-clipboard')
def _on_copy_clipboard(textview): clipboard = textview.get_clipboard(Gdk.SELECTION_CLIPBOARD) selected = textview.get_selected_text() clipboard.set_text(selected, -1) GObject.signal_stop_emission_by_name(textview, 'copy-clipboard')
def on_dialog_close(self, dialog): # Instead of closing a dialog box, just hide it. GObject.signal_stop_emission_by_name(dialog, "close") dialog.hide()