Revision f1c0c262
Added by David Sorber over 7 years ago
| software/pwmgr/pwmgr.py | ||
|---|---|---|
|
ENC_TMP_FILE_PATH = '/home/dsorber/Documents/chicken_soup.enc.tmp'
|
||
|
KEY_FILE_PATH = '/mnt/pw_ramdisk/.f05d11ef-000c-45c2-ae14-56b56c23e1c5'
|
||
|
|
||
|
VERSION = '0.0.8'
|
||
|
VERSION = '0.0.9-alpha'
|
||
|
|
||
|
class BetterSearchWindow(Gtk.Window):
|
||
|
|
||
|
def __init__(self, parent):
|
||
|
self.parent = parent
|
||
|
Gtk.Window.__init__(self, title='Search')
|
||
|
self.set_default_size(400, 140)
|
||
|
self.set_border_width(10)
|
||
|
|
||
|
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3)
|
||
|
self.add(vbox)
|
||
|
|
||
|
# ~ search_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=1)
|
||
|
search_grid = Gtk.Grid()
|
||
|
search_grid.set_column_spacing(10)
|
||
|
search_label = Gtk.Label('Search for:')
|
||
|
search_grid.attach(search_label, 0, 0, 1, 1)
|
||
|
|
||
|
self.search_entry = Gtk.Entry()
|
||
|
self.search_entry.set_hexpand(True)
|
||
|
search_grid.attach(self.search_entry, 1, 0, 1, 1)
|
||
|
|
||
|
vbox.pack_start(search_grid, True, True, 4)
|
||
|
|
||
|
# Stats display
|
||
|
self.stats_label = Gtk.Label('Matches found: ')
|
||
|
vbox.pack_start(self.stats_label, True, True, 0)
|
||
|
|
||
|
# Buttons
|
||
|
button_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
|
||
|
|
||
|
self.close_button = Gtk.Button.new_with_label('Close')
|
||
|
button_box.pack_start(self.close_button, True, True, 0)
|
||
|
self.close_button.connect('clicked', self.on_close_clicked)
|
||
|
|
||
|
self.next_button = Gtk.Button.new_with_label('Next')
|
||
|
button_box.pack_start(self.next_button, True, True, 0)
|
||
|
self.next_button.connect('clicked', self.on_next_clicked)
|
||
|
|
||
|
vbox.pack_start(button_box, False, True, 0)
|
||
|
|
||
|
def on_close_clicked(self, widget):
|
||
|
self.destroy()
|
||
|
|
||
|
def on_next_clicked(self, widget):
|
||
|
search_term = self.search_entry.get_text().strip()
|
||
|
print('Search for: '.format(search_term))
|
||
|
|
||
|
# Get start iterator
|
||
|
cursor_mark = self.parent.textbuffer.get_insert()
|
||
|
start = self.parent.textbuffer.get_iter_at_mark(cursor_mark)
|
||
|
if start.get_offset() == self.parent.textbuffer.get_char_count():
|
||
|
start = self.parent.textbuffer.get_start_iter()
|
||
|
|
||
|
# ~ self.search_and_mark(dialog.entry.get_text(), start)
|
||
|
|
||
|
|
||
|
class SearchDialog(Gtk.Dialog):
|
||
|
|
||
| ... | ... | |
|
self.progressbar.set_show_text(True)
|
||
|
|
||
|
self.set_modal(True)
|
||
|
#~ self.set_decorated(False)
|
||
|
self.set_decorated(False)
|
||
|
self.set_deletable(False)
|
||
|
self.set_transient_for(parent)
|
||
|
|
||
| ... | ... | |
|
button_search.set_icon_name('system-search-symbolic')
|
||
|
button_search.connect('clicked', self.on_search_clicked)
|
||
|
toolbar.insert(button_search, 6)
|
||
|
|
||
|
button_new_search = Gtk.ToolButton()
|
||
|
button_new_search.set_icon_name('system-search-symbolic')
|
||
|
button_new_search.connect('clicked', self.on_new_search_clicked)
|
||
|
toolbar.insert(button_new_search, 7)
|
||
|
|
||
|
def create_textview(self):
|
||
|
scrolledwindow = Gtk.ScrolledWindow()
|
||
| ... | ... | |
|
self.pass_data_loaded = False
|
||
|
|
||
|
def _remove_mount_files(self):
|
||
|
# Remove files in the mount path
|
||
|
""" Helper function to remove files in the mount path
|
||
|
"""
|
||
|
for file_object in os.listdir(MOUNT_PATH):
|
||
|
file_object_path = os.path.join(MOUNT_PATH, file_object)
|
||
|
if os.path.isfile(file_object_path):
|
||
| ... | ... | |
|
shutil.rmtree(file_object_path)
|
||
|
|
||
|
def _hash_textview(self):
|
||
|
""" Helper function to hash the contents of the textview
|
||
|
"""
|
||
|
passwd_text = self.textbuffer.get_text(self.textbuffer.get_start_iter(),
|
||
|
self.textbuffer.get_end_iter(),
|
||
|
True)
|
||
| ... | ... | |
|
# 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 on_new_search_clicked(self, widget):
|
||
|
print('New search!')
|
||
|
search_win = BetterSearchWindow(self)
|
||
|
search_win.show_all()
|
||
|
|
||
|
def main():
|
||
|
"""
|
||
Started working on a custom search dialog. The old one is still in place
until I finish working on the new one.