"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/lib/ui.py" between
revelation-0.5.3.tar.xz and revelation-0.5.4.tar.xz

About: Revelation is a password manager for the GNOME 3 desktop.

ui.py  (revelation-0.5.3.tar.xz):ui.py  (revelation-0.5.4.tar.xz)
skipping to change at line 31 skipping to change at line 31
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
from . import config, data, dialog, entry, io, util from . import config, data, dialog, entry, io, util
import gi import gi
gi.require_version('Gtk', '3.0') gi.require_version('Gtk', '3.0')
from gi.repository import GObject, Gtk, Gdk, Gio, Pango from gi.repository import GObject, Gtk, Gdk, Gio, Pango
import gettext, os, pwd, time import gettext, time
_ = gettext.gettext _ = gettext.gettext
STOCK_CONTINUE = _("_Continue") # "revelation-continue" STOCK_CONTINUE = _("_Continue") # "revelation-continue"
STOCK_DISCARD = "revelation-discard" STOCK_DISCARD = "revelation-discard"
STOCK_EDIT = "revelation-edit" STOCK_EDIT = "revelation-edit"
STOCK_EXPORT = _("_Export") # "revelation-export" STOCK_EXPORT = _("_Export") # "revelation-export"
STOCK_FOLDER = "revelation-folder" STOCK_FOLDER = "revelation-folder"
STOCK_GENERATE = _("_Generate") # "revelation-generate" STOCK_GENERATE = _("_Generate") # "revelation-generate"
STOCK_IMPORT = _("_Import") # "revelation-import" STOCK_IMPORT = _("_Import") # "revelation-import"
skipping to change at line 242 skipping to change at line 242
def __init__(self, *args): def __init__(self, *args):
Gtk.VBox.__init__(self) Gtk.VBox.__init__(self)
self.set_spacing(6) self.set_spacing(6)
self.set_border_width(0) self.set_border_width(0)
for widget in args: for widget in args:
self.pack_start(widget, True, True, 0) self.pack_start(widget, True, True, 0)
class HPaned(Gtk.HPaned):
"A horizontal pane"
def __init__(self, left = None, right = None):
Gtk.HPaned.__init__(self)
self.set_border_width(6)
if left is not None:
self.pack1(left, True, True)
if right is not None:
self.pack2(right, True, True)
class Notebook(Gtk.Notebook): class Notebook(Gtk.Notebook):
"A notebook (tabbed view)" "A notebook (tabbed view)"
def __init__(self): def __init__(self):
Gtk.Notebook.__init__(self) Gtk.Notebook.__init__(self)
def create_page(self, title): def create_page(self, title):
"Creates a notebook page" "Creates a notebook page"
page = NotebookPage() page = NotebookPage()
self.append_page(page, Label(title)) self.append_page(page, Label(title))
return page return page
class NotebookPage(VBox): class NotebookPage(VBox):
"A notebook page" "A notebook page"
def __init__(self): def __init__(self):
VBox.__init__(self) VBox.__init__(self)
self.sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) self.sizegroup = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL)
self.set_border_width(12) self.set_border_width(12)
self.set_spacing(18) self.set_spacing(18)
def add_section(self, title, description = None): def add_section(self, title, description = None):
"Adds an input section to the notebook" "Adds an input section to the notebook"
section = InputSection(title, description, self.sizegroup) section = InputSection(title, description, self.sizegroup)
self.pack_start(section, False, False, 0) self.pack_start(section, False, False, 0)
return section return section
skipping to change at line 339 skipping to change at line 326
if title is not None: if title is not None:
self.title = Label("<span weight=\"bold\">%s</span>" % util.escape_m arkup(title)) self.title = Label("<span weight=\"bold\">%s</span>" % util.escape_m arkup(title))
self.pack_start(self.title, False, True, 0) self.pack_start(self.title, False, True, 0)
if description is not None: if description is not None:
self.desc = Label(util.escape_markup(description)) self.desc = Label(util.escape_markup(description))
self.pack_start(self.desc, False, True, 0) self.pack_start(self.desc, False, True, 0)
if sizegroup is None: if sizegroup is None:
self.sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) self.sizegroup = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL)
def append_widget(self, title, widget, indent = True): def append_widget(self, title, widget, indent = True):
"Adds a widget to the section" "Adds a widget to the section"
row = HBox() row = HBox()
row.set_spacing(12) row.set_spacing(12)
self.pack_start(row, False, False, 0) self.pack_start(row, False, False, 0)
if self.title is not None and indent == True: if self.title is not None and indent == True:
row.pack_start(Label(""), False, False, 0) row.pack_start(Label(""), False, False, 0)
skipping to change at line 638 skipping to change at line 625
self.entry.set_text(io.file_normpath(filename)) self.entry.set_text(io.file_normpath(filename))
self.entry.set_position(-1) self.entry.set_position(-1)
def set_text(self, text): def set_text(self, text):
"Wrapper to emulate Entry" "Wrapper to emulate Entry"
self.entry.set_text(text) self.entry.set_text(text)
GObject.type_register(FileEntry) GObject.type_register(FileEntry)
GObject.signal_new("changed", FileEntry, GObject.SIGNAL_ACTION, GObject.TYPE_BOO GObject.signal_new("changed", FileEntry, GObject.SignalFlags.ACTION,
LEAN, ()) GObject.TYPE_BOOLEAN, ())
class PasswordEntry(Gtk.Entry): class PasswordEntry(Gtk.Entry):
"An entry for editing a password (follows the 'show passwords' preference)" "An entry for editing a password (follows the 'show passwords' preference)"
def __init__(self, password = None, cfg = None, clipboard = None): def __init__(self, password = None, cfg = None, clipboard = None):
Gtk.Entry.__init__(self) Gtk.Entry.__init__(self)
self.set_visibility(False) self.set_visibility(False)
if password: if password:
self.set_text(password) self.set_text(password)
skipping to change at line 934 skipping to change at line 922
def __init__(self): def __init__(self):
Gtk.Menu.__init__(self) Gtk.Menu.__init__(self)
##### MISCELLANEOUS WIDGETS ##### ##### MISCELLANEOUS WIDGETS #####
class TreeView(Gtk.TreeView): class TreeView(Gtk.TreeView):
"A tree display" "A tree display"
def __init__(self, model): def __init__(self, model):
Gtk.TreeView.__init__(self, model) Gtk.TreeView.__init__(self, model=model)
self.set_headers_visible(False) self.set_headers_visible(False)
self.model = model self.model = model
self.__cbid_drag_motion = None self.__cbid_drag_motion = None
self.__cbid_drag_end = None self.__cbid_drag_end = None
self.selection = self.get_selection() self.selection = self.get_selection()
self.selection.set_mode(Gtk.SelectionMode.MULTIPLE) self.selection.set_mode(Gtk.SelectionMode.MULTIPLE)
self.connect("button-press-event", self.__cb_buttonpress) self.connect("button-press-event", self.__cb_buttonpress)
skipping to change at line 974 skipping to change at line 962
# display popup on right-click # display popup on right-click
elif data.button == 3: elif data.button == 3:
if path != None and self.selection.iter_is_selected(self.model.get_i ter(path[0])) == False: if path != None and self.selection.iter_is_selected(self.model.get_i ter(path[0])) == False:
self.set_cursor(path[0], path[1], False) self.set_cursor(path[0], path[1], False)
self.emit("popup", data) self.emit("popup", data)
return True return True
# handle drag-and-drop of multiple rows # handle drag-and-drop of multiple rows
elif self.__cbid_drag_motion == None and data.button in ( 1, 2 ) and dat a.type == Gdk.EventType.BUTTON_PRESS and path != None and self.selection.iter_is _selected(self.model.get_iter(path[0])) == True and len(self.get_selected()) > 1 : elif self.__cbid_drag_motion is None and data.button in ( 1, 2 ) and dat a.type == Gdk.EventType.BUTTON_PRESS and path != None and self.selection.iter_is _selected(self.model.get_iter(path[0])) == True and len(self.get_selected()) > 1 :
self.__cbid_drag_motion = self.connect("motion-notify-event", self._ _cb_drag_motion, data.copy() ) self.__cbid_drag_motion = self.connect("motion-notify-event", self._ _cb_drag_motion, data.copy() )
self.__cbid_drag_end = self.connect("button-release-event", self.__c b_button_release, data.copy() ) self.__cbid_drag_end = self.connect("button-release-event", self.__c b_button_release, data.copy() )
return True return True
def __cb_button_release(self, widget, data, userdata = None): def __cb_button_release(self, widget, data, userdata = None):
"Ends a drag" "Ends a drag"
self.emit("button-press-event", userdata) self.emit("button-press-event", userdata)
self.__drag_check_end() self.__drag_check_end()
skipping to change at line 1033 skipping to change at line 1021
path = self.model.get_path(iter) path = self.model.get_path(iter)
for i in range(len(path)): for i in range(len(path)):
iter = self.model.get_iter(path[0:i]) iter = self.model.get_iter(path[0:i])
self.expand_row(iter) self.expand_row(iter)
def get_active(self): def get_active(self):
"Get the currently active row" "Get the currently active row"
if self.model == None: if self.model is None:
return None return None
iter = self.model.get_iter(self.get_cursor()[0]) iter = self.model.get_iter(self.get_cursor()[0])
if iter is None or self.selection.iter_is_selected(iter) == False: if iter is None or self.selection.iter_is_selected(iter) == False:
return None return None
return iter return iter
def get_selected(self): def get_selected(self):
"Get a list of currently selected rows" "Get a list of currently selected rows"
list = [] list = []
self.selection.selected_foreach(lambda model, path, iter: list.append(it er)) self.selection.selected_foreach(lambda model, path, iter: list.append(it er))
return list return list
def select(self, iter): def select(self, iter):
"Select a particular row" "Select a particular row"
if iter == None: if iter is None:
self.unselect_all() self.unselect_all()
else: else:
self.expand_to_iter(iter) self.expand_to_iter(iter)
self.set_cursor(self.model.get_path(iter)) self.set_cursor(self.model.get_path(iter))
def select_all(self): def select_all(self):
"Select all rows in the tree" "Select all rows in the tree"
self.selection.select_all() self.selection.select_all()
skipping to change at line 1094 skipping to change at line 1082
self.expand_row(iter) self.expand_row(iter)
def unselect_all(self): def unselect_all(self):
"Unselect all rows in the tree" "Unselect all rows in the tree"
self.selection.unselect_all() self.selection.unselect_all()
self.selection.emit("changed") self.selection.emit("changed")
self.emit("cursor_changed") self.emit("cursor_changed")
self.emit("unselect_all") self.emit("unselect_all")
GObject.signal_new("doubleclick", TreeView, GObject.SIGNAL_ACTION, GObject.TYPE_ GObject.signal_new("doubleclick", TreeView, GObject.SignalFlags.ACTION,
BOOLEAN, (GObject.TYPE_PYOBJECT, )) GObject.TYPE_BOOLEAN, (GObject.TYPE_PYOBJECT, ))
GObject.signal_new("popup", TreeView, GObject.SIGNAL_ACTION, GObject.TYPE_BOOLEA GObject.signal_new("popup", TreeView, GObject.SignalFlags.ACTION,
N, (GObject.TYPE_PYOBJECT, )) GObject.TYPE_BOOLEAN, (GObject.TYPE_PYOBJECT, ))
class EntryTree(TreeView): class EntryTree(TreeView):
"An entry tree" "An entry tree"
def __init__(self, entrystore): def __init__(self, entrystore):
TreeView.__init__(self, entrystore) TreeView.__init__(self, entrystore)
column = Gtk.TreeViewColumn() column = Gtk.TreeViewColumn()
self.append_column(column) self.append_column(column)
skipping to change at line 1188 skipping to change at line 1178
if important == True: if important == True:
self.set_property("is-important", True) self.set_property("is-important", True)
class ActionGroup(Gtk.ActionGroup): class ActionGroup(Gtk.ActionGroup):
"UI Manager Actiongroup" "UI Manager Actiongroup"
def add_action(self, action, accel = None): def add_action(self, action, accel = None):
"Adds an action to the actiongroup" "Adds an action to the actiongroup"
if accel == None: if accel is None:
Gtk.ActionGroup.add_action(self, action) Gtk.ActionGroup.add_action(self, action)
else: else:
self.add_action_with_accel(action, accel) self.add_action_with_accel(action, accel)
class ToggleAction(Gtk.ToggleAction): class ToggleAction(Gtk.ToggleAction):
"A toggle action item" "A toggle action item"
def __init__(self, name, label, tooltip = None, stock = None): def __init__(self, name, label, tooltip = None, stock = None):
Gtk.ToggleAction.__init__(self, name, label, tooltip, stock) Gtk.ToggleAction.__init__(self, name, label, tooltip, stock)
skipping to change at line 1293 skipping to change at line 1283
if name in self.toolbars: if name in self.toolbars:
self.toolbars[name].hide() self.toolbars[name].hide()
def __cb_toolbar_show(self, widget, name): def __cb_toolbar_show(self, widget, name):
"Shows the toolbar dock when the toolbar is shown" "Shows the toolbar dock when the toolbar is shown"
if name in self.toolbars: if name in self.toolbars:
self.toolbars[name].show() self.toolbars[name].show()
def add_toolbar(self, toolbar, name, band, detachable): def add_toolbar(self, toolbar, name, band):
"Adds a toolbar" "Adds a toolbar"
# TODO: This is not working correctly yet.
if detachable:
handlebox = Gtk.HandleBox()
handlebox.add(toolbar)
toolbar = handlebox
self.toolbars[name] = toolbar self.toolbars[name] = toolbar
self.main_vbox.pack_start(toolbar, False, True, 0) self.main_vbox.pack_start(toolbar, False, True, 0)
toolbar.connect("show", self.__cb_toolbar_show, name) toolbar.connect("show", self.__cb_toolbar_show, name)
toolbar.connect("hide", self.__cb_toolbar_hide, name) toolbar.connect("hide", self.__cb_toolbar_hide, name)
toolbar.show_all() toolbar.show_all()
def get_title(self): def get_title(self):
"Returns the app title" "Returns the app title"
skipping to change at line 1389 skipping to change at line 1373
for child in self.get_children(): for child in self.get_children():
child.destroy() child.destroy()
def display_entry(self, e): def display_entry(self, e):
"Displays info about an entry" "Displays info about an entry"
self.clear() self.clear()
self.entry = e self.entry = e
if self.entry == None: if self.entry is None:
return return
# set up metadata display # set up metadata display
metabox = VBox() metabox = VBox()
self.pack_start(metabox) self.pack_start(metabox)
label = ImageLabel( label = ImageLabel(
"<span size=\"large\" weight=\"bold\">%s</span>" % util.escape_marku p(e.name), "<span size=\"large\" weight=\"bold\">%s</span>" % util.escape_marku p(e.name),
e.icon, ICON_SIZE_DATAVIEW e.icon, ICON_SIZE_DATAVIEW
) )
skipping to change at line 1450 skipping to change at line 1434
widget.set_halign(Gtk.Align.CENTER) widget.set_halign(Gtk.Align.CENTER)
widget.set_valign(Gtk.Align.CENTER) widget.set_valign(Gtk.Align.CENTER)
VBox.pack_start(self, widget, False, False, 0) VBox.pack_start(self, widget, False, False, 0)
class Searchbar(Toolbar): class Searchbar(Toolbar):
"A toolbar for easy searching" "A toolbar for easy searching"
def __init__(self): def __init__(self):
Toolbar.__init__(self) Toolbar.__init__(self)
self.label = Label(" " + _(' Find:') + " ") self.entry = Gtk.SearchEntry()
self.entry = Entry() self.entry.set_tooltip_text(_('Text to search for'))
self.dropdown = EntryDropDown() self.dropdown = EntryDropDown()
self.dropdown.insert_item(0, _('Any type'), "help-about") self.dropdown.insert_item(0, _('Any type'), "help-about")
self.button_next = Gtk.Button.new_from_icon_name(STOCK_NEXT, Gtk.Icon
Size.LARGE_TOOLBAR)
self.button_prev = Gtk.Button.new_from_icon_name(STOCK_PREVIOUS, Gtk.
IconSize.LARGE_TOOLBAR)
self.append_widget(self.label) box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
self.append_widget(self.entry, _('Text to search for')) Gtk.StyleContext.add_class(box.get_style_context(), "linked")
self.append_widget(EventBox(self.dropdown), _('The type of account to se self.button_prev = Gtk.Button.new_from_icon_name(STOCK_PREVIOUS,
arch for')) Gtk.IconSize.BUTTON)
self.append_space() self.button_prev.set_tooltip_text(_('Find the previous match'))
self.append_widget(self.button_next, _('Find the next match')) self.button_next = Gtk.Button.new_from_icon_name(STOCK_NEXT,
self.append_widget(self.button_prev, _('Find the previous match')) Gtk.IconSize.BUTTON)
self.button_next.set_tooltip_text(_('Find the next match'))
box.add(self.entry)
box.add(self.button_prev)
box.add(self.button_next)
box.add(self.dropdown)
self.append_widget(box)
self.connect("show", self.__cb_show) self.connect("show", self.__cb_show)
self.entry.connect("changed", self.__cb_entry_changed) self.entry.connect("changed", self.__cb_entry_changed)
self.entry.connect("key-press-event", self.__cb_key_press) self.entry.connect("key-press-event", self.__cb_key_press)
self.button_next.set_sensitive(False) self.button_next.set_sensitive(False)
self.button_prev.set_sensitive(False) self.button_prev.set_sensitive(False)
def __cb_entry_changed(self, widget, data = None): def __cb_entry_changed(self, widget, data = None):
 End of changes. 17 change blocks. 
48 lines changed or deleted 33 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)