Project

General

Profile

« Previous | Next » 

Revision 64a1e5a9

Added by dsorber almost 9 years ago

Modified search so that the (first) matching term scrolls into view.

View differences:

software/pwmgr/pwmgr.py
SCRATCH_FILE_PATH = '/mnt/pw_ramdisk/chicken_soup.txt'
ENC_TMP_FILE_PATH = '/home/dsorber/Documents/chicken_soup.enc.tmp'
VERSION = '0.0.1'
VERSION = '0.0.2'
class SearchDialog(Gtk.Dialog):
......
self.show_all()
class WarningDialog(Gtk.Dialog):
def __init__(self, parent, title, message):
Gtk.MessageDialog.__init__(self, parent,
Gtk.DialogFlags.MODAL,
Gtk.MessageType.WARNING,
Gtk.ButtonsType.OK_CANCEL,
message)
self.set_title(title)
self.show_all()
def get_user_pw(parent, message, title=''):
"""
Returns user input as a string or None
......
https://stackoverflow.com/questions/13970445/python-gtk3-how-to-add-a-gtk-entry-to-a-gtk-messagedialog
"""
dialog = Gtk.MessageDialog(parent,
Gtk.DialogFlags.MODAL |
Gtk.DialogFlags.DESTROY_WITH_PARENT,
Gtk.MessageType.QUESTION,
Gtk.ButtonsType.OK_CANCEL,
message)
Gtk.DialogFlags.MODAL |
Gtk.DialogFlags.DESTROY_WITH_PARENT,
Gtk.MessageType.QUESTION,
Gtk.ButtonsType.OK_CANCEL,
message)
dialog.set_title(title)
......
self.tag_underline = self.textbuffer.create_tag("underline",
underline=Pango.Underline.SINGLE)
self.tag_found = self.textbuffer.create_tag('found',
background='orange')
background='orange',
weight=Pango.Weight.BOLD)
def create_bottom(self):
......
"""
Close handler
"""
#~ dialog = WarningDialog(self, 'Close?', 'Have you saved?')
#~ response = dialog.run()
#~ dialog.destroy()
rand_write_cmd = 'dd if=/dev/urandom of={:s} bs=16M count=1 status=none'
rand_write_cmd = rand_write_cmd.format(os.path.join(MOUNT_PATH, 'data'))
......
match = start.forward_search(text, 0, end)
if match != None:
match_start, match_end = match
match_start, match_end = match
self.textbuffer.apply_tag(self.tag_found, match_start, match_end)
self.search_and_mark(text, match_end)
# Scroll so the match appears in the middle of the screen
self.textview.scroll_to_iter(match_start, 0.1, True, 0.0, 0.5)
#~ self.search_and_mark(text, match_end)
def main():
"""

Also available in: Unified diff