Commit 9411db5a authored by Falk Alexander Seidl's avatar Falk Alexander Seidl

Add meson development configure option

* Enable debug mode
* Use development style class
* Flatpak manifest tags
parent 8622890a
Pipeline #33231 canceled with stage
......@@ -72,7 +72,7 @@
<description>Remember last used unlock method for future database unlocking.</description>
</key>
<key type="b" name="development-backup-mode">
<default>true</default>
<default>false</default>
<summary>Backup the database on unlock</summary>
<description>If an error occurs while saving the database, a backup can be found at ~/.cache/passwordsafe/backups</description>
</key>
......@@ -89,4 +89,3 @@
</schema>
</schemalist>
......@@ -31,11 +31,11 @@
color: alpha(currentColor,0.5);
}
.SeperatorLabel {
.SeperatorLabel {
color: alpha(currentColor,0.5);
}
.SeperatorLabelSelectedMode {
.SeperatorLabelSelectedMode {
color: alpha(white,0.8);
}
......@@ -211,3 +211,24 @@ levelbar block.secure {
border-radius: 3px;
background: @theme_base_color;
}
.DevHeaderBar headerbar {
background: transparent -gtk-icontheme("system-run-symbolic") 80% 0/128px 128px no-repeat,
linear-gradient(to left,
mix(@theme_fg_color, @theme_bg_color, 0.5) 0%,
@theme_bg_color 25%);
color: alpha(@theme_fg_color, 0.2);
}
.DevHeaderBar headerbar label {
color: @theme_fg_color;
}
.DevHeaderBar .SeperatorLabel {
color: alpha(@theme_fg_color, 0.5);
}
.DevHeaderBar .SeperatorLabelSelectedMode {
color: alpha(white,0.8);
}
......@@ -4,6 +4,12 @@
"runtime-version" : "master",
"branch" : "stable",
"sdk" : "org.gnome.Sdk",
"tags" : [
"devel",
"development",
"nightly"
],
"desktop-file-name-prefix": "(Development) ",
"command" : "gnome-passwordsafe",
"finish-args" : [
"--share=ipc",
......@@ -37,6 +43,9 @@
"name" : "passwordsafe",
"buildsystem" : "meson",
"builddir" : true,
"config-opts":[
"-Ddevelopment=true"
],
"sources" : [
{
"type" : "git",
......
project('passwordsafe', 'c',
version: '3.31.1',
meson_version: '>= 0.40.0',
default_options: ['development=false']
)
i18n = import('i18n')
python = import('python3')
......@@ -49,6 +50,7 @@ conf.set('PYTHON', python_bin.path())
conf.set('libexecdir', LIBEXEC_DIR)
conf.set('VERSION', meson.project_version())
conf.set('CONTRIBUTORS', contributors)
conf.set('DEVELOPMENT', get_option('development'))
subdir('data')
subdir('po')
......
option('development', type : 'boolean', value : false, description : 'Enable debug and backup mode')
......@@ -40,5 +40,7 @@ if __name__ == "__main__":
Gio.Resource._register(resource)
app = Application()
Application.development_mode = "@DEVELOPMENT@" == 'True'
exit_status = app.run(sys.argv)
sys.exit(exit_status)
......@@ -8,6 +8,7 @@ gi.require_version('Handy', '0.0')
from gi.repository import GObject, GLib, Gio, Gtk, Handy
from gi.repository import Notify
from gettext import gettext as _
from passwordsafe.logging_manager import LoggingManager
from passwordsafe.main_window import MainWindow
from passwordsafe.settings_dialog import SettingsDialog
......@@ -15,6 +16,7 @@ from passwordsafe.settings_dialog import SettingsDialog
class Application(Gtk.Application):
window = NotImplemented
file_list = []
development_mode = False
def __init__(self, *args, **kwargs):
super().__init__(
......@@ -49,6 +51,9 @@ class Application(Gtk.Application):
self.window.present()
def get_logger(self):
return LoggingManager(self.development_mode)
def assemble_application_menu(self):
settings_action = Gio.SimpleAction.new("settings", None)
settings_action.connect("activate", self.on_settings_menu_clicked)
......
......@@ -2,15 +2,21 @@ from gi.repository import Gtk
class ContainerPage(Gtk.Box):
development_mode = NotImplemented
headerbar = NotImplemented
def __init__(self, headerbar):
def __init__(self, headerbar, development_mode):
Gtk.Box.__init__(self, spacing=1)
self.show_all()
self.development_mode = development_mode
self.headerbar = headerbar
def set_headerbar(self, headerbar):
self.headerbar = headerbar
if self.development_mode is True:
context = self.headerbar.get_style_context()
context.add_class("DevHeaderBar")
def get_headerbar(self):
return self.headerbar
from pykeepass import PyKeePass
from passwordsafe.logging_manager import LoggingManager
import hashlib
class DatabaseManager:
logging_manager = LoggingManager(True)
logging_manager = NotImplemented
db = NotImplemented
database_path = ""
password_try = ""
......@@ -15,7 +14,8 @@ class DatabaseManager:
save_running = False
scheduled_saves = 0
def __init__(self, database_path, password=None, keyfile=None):
def __init__(self, database_path, password=None, keyfile=None, logging_manager=None):
self.logging_manager = logging_manager
self.db = PyKeePass(database_path, password, keyfile)
self.database_path = database_path
self.password = password
......
......@@ -3,7 +3,7 @@ import datetime
class LoggingManager:
debug = NotImplemented
development_mode = NotImplemented
timestamp = NotImplemented
date = NotImplemented
......@@ -11,8 +11,8 @@ class LoggingManager:
# Log Levels
#
def __init__(self, debug_mode):
self.debug = debug_mode
def __init__(self, development_mode):
self.development_mode = development_mode
self.timestamp = time.time()
self.date = datetime.datetime.fromtimestamp(self.timestamp).strftime(
'%Y-%m-%d %H:%M:%S')
......@@ -31,5 +31,5 @@ class LoggingManager:
print("( " + self.date + " ):" + "\033[92m INFO: \033[0m" + message)
def log_debug(self, message):
if(self.debug):
if(self.development_mode is True):
print("( " + self.date + " ):" + "\033[1m DEBUG: \033[0m" + message)
from gettext import gettext as _
from gi.repository import Gio, GLib, Gdk, Gtk, Handy
from gi.repository.GdkPixbuf import Pixbuf
from passwordsafe.logging_manager import LoggingManager
from passwordsafe.database_manager import DatabaseManager
from passwordsafe.create_database import CreateDatabase
from passwordsafe.container_page import ContainerPage
......@@ -15,6 +14,7 @@ import threading
class MainWindow(Gtk.ApplicationWindow):
application = NotImplemented
database_manager = NotImplemented
logging_manager = NotImplemented
container = NotImplemented
quit_dialog = NotImplemented
filechooser_creation_dialog = NotImplemented
......@@ -22,7 +22,6 @@ class MainWindow(Gtk.ApplicationWindow):
file_open_button = NotImplemented
file_new_button = NotImplemented
first_start_grid = NotImplemented
logging_manager = LoggingManager(True)
opened_databases = []
databases_to_save = []
spinner = NotImplemented
......@@ -31,9 +30,13 @@ class MainWindow(Gtk.ApplicationWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.logging_manager = kwargs['application'].get_logger()
self.assemble_window()
if self.logging_manager.development_mode is True:
passwordsafe.config_manager.set_development_backup_mode(True)
def assemble_window(self):
window_size = passwordsafe.config_manager.get_window_size()
self.set_default_size(window_size[0], window_size[1])
......@@ -67,6 +70,10 @@ class MainWindow(Gtk.ApplicationWindow):
self.set_titlebar(self.headerbar)
if self.logging_manager.development_mode is True:
context = self.get_style_context()
context.add_class("DevHeaderBar")
def set_headerbar(self):
self.set_headerbar_button_layout()
self.set_titlebar(self.headerbar)
......@@ -361,7 +368,7 @@ class MainWindow(Gtk.ApplicationWindow):
stock_database.copy(new_database, Gio.FileCopyFlags.OVERWRITE)
def create_new_database_instance(self, tab_title):
self.database_manager = DatabaseManager(self.filechooser_creation_dialog.get_filename(), "liufhre86ewoiwejmrcu8owe")
self.database_manager = DatabaseManager(self.filechooser_creation_dialog.get_filename(), "liufhre86ewoiwejmrcu8owe", logging_manager=self.logging_manager)
GLib.idle_add(self.start_database_creation_routine, tab_title)
def start_database_creation_routine(self, tab_title):
......@@ -384,7 +391,7 @@ class MainWindow(Gtk.ApplicationWindow):
if self.container == NotImplemented:
self.create_container()
page_instance = ContainerPage(headerbar)
page_instance = ContainerPage(headerbar, self.logging_manager.development_mode)
tab_hbox = Gtk.HBox.new(False, 0)
tab_label = Gtk.Label.new(title)
......
from gi.repository import Gtk
from passwordsafe.pathbar_button import PathbarButton
from passwordsafe.logging_manager import LoggingManager
class Pathbar(Gtk.HBox):
......@@ -13,7 +12,6 @@ class Pathbar(Gtk.HBox):
pathbar_box = NotImplemented
builder = NotImplemented
home_button = NotImplemented
logging_manager = LoggingManager(True)
def __init__(self, unlocked_database, dbm, path, headerbar):
Gtk.HBox.__init__(self)
......
......@@ -2,7 +2,6 @@ from gi.repository import Gio, Gtk, GLib, Handy, Pango
from passwordsafe.database_manager import DatabaseManager
from passwordsafe.unlocked_database import UnlockedDatabase
import passwordsafe.config_manager
from passwordsafe.logging_manager import LoggingManager
import ntpath
import os
import threading
......@@ -23,7 +22,6 @@ class UnlockDatabase:
unlock_database_stack_switcher = NotImplemented
keyfile_path = NotImplemented
composite_keyfile_path = NotImplemented
logging_manager = LoggingManager(True)
overlay = NotImplemented
timeout = NotImplemented
unlocked_database = NotImplemented
......@@ -241,7 +239,7 @@ class UnlockDatabase:
password_unlock_entry.grab_focus()
password_unlock_entry.get_style_context().add_class("error")
self.clear_input_fields()
self.logging_manager.log_debug("Could not open database, wrong password")
self.window.logging_manager.log_debug("Could not open database, wrong password")
else:
password_unlock_button = self.builder.get_object("password_unlock_button")
password_unlock_button_image = password_unlock_button.get_children()[0]
......@@ -263,7 +261,7 @@ class UnlockDatabase:
def password_unlock_process(self):
try:
self.database_manager = DatabaseManager(self.database_filepath, self.password_only)
self.database_manager = DatabaseManager(self.database_filepath, password=self.password_only, keyfile=None, logging_manager=self.window.logging_manager)
GLib.idle_add(self.password_unlock_success)
except(OSError, ValueError, AttributeError, core.ChecksumError):
GLib.idle_add(self.password_unlock_failure)
......@@ -275,7 +273,7 @@ class UnlockDatabase:
self.password_only = NotImplemented
self.set_last_used_unlock_method("password")
self.logging_manager.log_debug("Opening of database was successfull")
self.window.logging_manager.log_debug("Opening of database was successfull")
self.open_database_page()
def password_unlock_failure(self):
......@@ -292,7 +290,7 @@ class UnlockDatabase:
password_unlock_entry.grab_focus()
password_unlock_entry.get_style_context().add_class("error")
self.clear_input_fields()
self.logging_manager.log_debug("Could not open database, wrong password")
self.window.logging_manager.log_debug("Could not open database, wrong password")
# Keyfile Unlock
......@@ -310,7 +308,7 @@ class UnlockDatabase:
response = keyfile_chooser_dialog.run()
if response == Gtk.ResponseType.ACCEPT:
self.logging_manager.log_debug("File selected: " + keyfile_chooser_dialog.get_filename())
self.window.logging_manager.log_debug("File selected: " + keyfile_chooser_dialog.get_filename())
keyfile_unlock_select_button = self.builder.get_object("keyfile_unlock_select_button")
keyfile_unlock_select_button.get_style_context().remove_class(Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION)
......@@ -320,7 +318,7 @@ class UnlockDatabase:
self.keyfile_path = keyfile_chooser_dialog.get_filename()
elif response == Gtk.ResponseType.CANCEL:
self.logging_manager.log_debug("File selection canceled")
self.window.logging_manager.log_debug("File selection canceled")
def on_keyfile_unlock_button_clicked(self, widget):
keyfile_unlock_select_button = self.builder.get_object("keyfile_unlock_select_button")
......@@ -353,7 +351,7 @@ class UnlockDatabase:
keyfile_unlock_select_button.get_style_context().add_class(Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION)
keyfile_unlock_select_button.set_label(_("Try again"))
self.logging_manager.log_debug("Invalid keyfile chosen")
self.window.logging_manager.log_debug("Invalid keyfile chosen")
elif self.keyfile_path is not NotImplemented:
keyfile_unlock_select_button = self.builder.get_object("keyfile_unlock_select_button")
keyfile_unlock_button = self.builder.get_object("keyfile_unlock_button")
......@@ -375,7 +373,7 @@ class UnlockDatabase:
def keyfile_unlock_process(self):
try:
self.database_manager = DatabaseManager(self.database_filepath, password=None, keyfile=self.keyfile_path)
self.database_manager = DatabaseManager(self.database_filepath, password=None, keyfile=self.keyfile_path, logging_manager=self.window.logging_manager)
GLib.idle_add(self.keyfile_unlock_success)
except(OSError, IndexError, ValueError, AttributeError, core.ChecksumError):
GLib.idle_add(self.keyfile_unlock_failure)
......@@ -388,7 +386,7 @@ class UnlockDatabase:
return
self.set_last_used_unlock_method("keyfile")
self.logging_manager.log_debug("Database successfully opened with keyfile")
self.window.logging_manager.log_debug("Database successfully opened with keyfile")
self.keyfile_path = NotImplemented
self.open_database_page()
......@@ -410,7 +408,7 @@ class UnlockDatabase:
keyfile_unlock_select_button.get_style_context().add_class(Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION)
keyfile_unlock_select_button.set_label(_("Try again"))
self.logging_manager.log_debug("Invalid keyfile chosen")
self.window.logging_manager.log_debug("Invalid keyfile chosen")
# Composite Unlock
......@@ -432,7 +430,7 @@ class UnlockDatabase:
response = filechooser_opening_dialog.run()
if response == Gtk.ResponseType.ACCEPT:
self.logging_manager.log_debug("File selected: " + filechooser_opening_dialog.get_filename())
self.window.logging_manager.log_debug("File selected: " + filechooser_opening_dialog.get_filename())
file_path = filechooser_opening_dialog.get_filename()
label = Gtk.Label()
......@@ -444,7 +442,7 @@ class UnlockDatabase:
self.composite_keyfile_path = file_path
elif response == Gtk.ResponseType.CANCEL:
self.logging_manager.log_debug("File selection cancelled")
self.window.logging_manager.log_debug("File selection cancelled")
def on_composite_unlock_button_clicked(self, widget):
composite_unlock_entry = self.builder.get_object("composite_unlock_entry")
......@@ -480,7 +478,7 @@ class UnlockDatabase:
composite_unlock_select_button.get_style_context().add_class("destructive-action")
self.clear_input_fields()
self.logging_manager.log_debug("Could not open database, wrong password")
self.window.logging_manager.log_debug("Could not open database, wrong password")
else:
if composite_unlock_entry.get_text() is not "" and self.composite_keyfile_path is not NotImplemented:
composite_unlock_select_button = self.builder.get_object("composite_unlock_select_button")
......@@ -507,7 +505,7 @@ class UnlockDatabase:
def composite_unlock_process(self):
try:
self.database_manager = DatabaseManager(self.database_filepath, self.password_composite, self.composite_keyfile_path)
self.database_manager = DatabaseManager(self.database_filepath, password=self.password_composite, keyfile=self.composite_keyfile_path, logging_manager=self.window.logging_manager)
GLib.idle_add(self.composite_unlock_success)
except(OSError, IndexError, ValueError, AttributeError, core.ChecksumError):
GLib.idle_add(self.composite_unlock_failure)
......@@ -539,7 +537,7 @@ class UnlockDatabase:
passwordsafe.config_manager.set_last_used_composite_key(pair_array)
self.set_last_used_unlock_method("composite")
self.logging_manager.log_debug("Opening of database was successfull")
self.window.logging_manager.log_debug("Opening of database was successfull")
self.composite_keyfile_path = NotImplemented
self.open_database_page()
......@@ -565,7 +563,7 @@ class UnlockDatabase:
composite_unlock_select_button.get_style_context().add_class("destructive-action")
self.clear_input_fields()
self.logging_manager.log_debug("Could not open database, wrong password")
self.window.logging_manager.log_debug("Could not open database, wrong password")
#
# Open Database
......
from gettext import gettext as _
from gi.repository import Gio, Gdk, Gtk, GLib, Handy
from passwordsafe.database_settings_dialog import DatabaseSettingsDialog
from passwordsafe.logging_manager import LoggingManager
from passwordsafe.entry_page import EntryPage
from passwordsafe.entry_row import EntryRow
from passwordsafe.group_page import GroupPage
......@@ -24,7 +23,6 @@ class UnlockedDatabase:
# Instances
window = NotImplemented
database_manager = NotImplemented
logging_manager = LoggingManager(True)
unlock_database = NotImplemented
responsive_ui = NotImplemented
selection_ui = NotImplemented
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment