Commit 1274dd54 authored by Falk Alexander Seidl's avatar Falk Alexander Seidl

Add meson build manifest

Restructured the source files in order to support compiling KeepassGtk via Meson. Additionally there is now a binary file, desktop application starting file and ui files are now loaded as resources.
parent d6b318b8
src/__pycache__
ui/create_database.ui~
ui/create_database_success.ui~
ui/entries_listbox.ui~
ui/main_headerbar.ui~
ui/override_dialog.ui~
ui/unlock_database.ui~
ui/#unlock_database.ui#
ui/#entries_listbox.ui#
ui/about_dialog.ui~
ui/#about_dialog.ui#
ui/settings_dialog.ui~
ui/#settings_dialog.ui#
keepassgtk/__pycache__
data/create_database.ui~
data/create_database_success.ui~
data/entries_listbox.ui~
data/main_headerbar.ui~
data/override_dialog.ui~
data/unlock_database.ui~
data/#unlock_database.ui#
data/#entries_listbox.ui#
data/about_dialog.ui~
data/#about_dialog.ui#
data/settings_dialog.ui~
data/#settings_dialog.ui#
_build
.buildconfig
.vscode
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/run/terminal/KeepassGtk">
<file compressed="true">database.kdbx</file>
<file compressed="true">keepassgtk.css</file>
<file compressed="true" preprocess="xml-stripblanks">about_dialog.ui</file>
<file compressed="true" preprocess="xml-stripblanks">create_database.ui</file>
<file compressed="true" preprocess="xml-stripblanks">create_database_success.ui</file>
<file compressed="true" preprocess="xml-stripblanks">entries_listbox.ui</file>
<file compressed="true" preprocess="xml-stripblanks">main_headerbar.ui</file>
<file compressed="true" preprocess="xml-stripblanks">override_dialog.ui</file>
<file compressed="true" preprocess="xml-stripblanks">settings_dialog.ui</file>
<file compressed="true" preprocess="xml-stripblanks">unlock_database.ui</file>
</gresource>
</gresources>
gnome = import('gnome')
message('Compiling resources')
gnome.compile_resources(
meson.project_name(),
meson.project_name() + '.gresource.xml',
gresource_bundle: true,
source_dir: '.',
install_dir: DATA_DIR,
install: true
)
# Merging the translations with the desktop file
i18n.merge_file(
output: project_id + '.desktop',
input: project_id + '.desktop.in',
po_dir: join_paths(meson.source_root(), 'po'),
type: 'desktop',
install: true,
install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'applications')
)
# Validating the desktop file
desktop_file_validate = find_program('desktop-file-validate', required:false)
if desktop_file_validate.found()
test (
'Validate desktop file',
desktop_file_validate,
args: join_paths(meson.current_build_dir (), project_id + '.desktop')
)
endif
# Validating the appdata file
appstreamcli = find_program('appstream-util', required: false)
if appstreamcli.found()
test (
'Validate appdata file',
appstreamcli,
args: ['validate-relax', join_paths(meson.current_build_dir (), project_id + '.appdata.xml')]
)
endif
# Validating schemas
compile_schemas = find_program('glib-compile-schemas', required: false)
if compile_schemas.found()
test('Validate schema file', compile_schemas,
args: ['--strict', '--dry-run', meson.current_source_dir()]
)
endif
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>run.terminal.KeepassGtk</id>
<launchable type="desktop-id">run.terminal.KeepassGtk.desktop</launchable>
<licence>GPL3</licence>
<name>KeepassGtk</name>
<summary>Keepass Client</summary>
<description>
<p>An eye candy password manager for Linux (Keepass v.4)</p>
</description>
<releases>
<release version="0.0.1" date="2018-05-27">
<description>
<ul>
<li>First public test release</li>
</ul>
</description>
</release>
</releases>
<categories>
<category>Utility</category>
</categories>
<screenshots>
<screenshot type="default"></screenshot>
</screenshots>
<url type="homepage">https://github.com/TerminalDotRun/KeepassGtk</url>
<updatecontact>fa@terminal.run</updatecontact>
<updatecontact>uta@terminal.run</updatecontact>
</component>
[Desktop Entry]
Name=KeepassGtk
Comment=An eye candy password manager for Linux
Icon=dialog-password
Exec=keepassgtk %U
Terminal=false
Type=Application
Categories=Utility;GTK;GNOME;
MimeType=application/x-keepass2;
Name[de_DE]=KeepassGtk
#!@PYTHON@
import sys
import os
import locale
sys.path.insert(1, '@PYTHON_EXEC_DIR@')
sys.path.insert(1, '@PYTHON_DIR@')
from gi.repository import Gio
localedir = '@LOCALE_DIR@'
pkgdatadir = '@DATA_DIR@'
extensiondir = '@EXTENSION_DIR@'
from keepassgtk.application import Application
def install_excepthook():
""" Make sure we exit when an unhandled exception occurs. """
from gi.repository import Gtk
old_hook = sys.excepthook
def new_hook(etype, evalue, etb):
old_hook(etype, evalue, etb)
while Gtk.main_level():
Gtk.main_quit()
sys.exit()
sys.excepthook = new_hook
if __name__ == "__main__":
install_excepthook()
resource = Gio.resource_load(os.path.join(pkgdatadir, 'keepassgtk.gresource'))
Gio.Resource._register(resource)
app = Application()
exit_status = app.run(sys.argv)
sys.exit(exit_status)
import gi
import sys
import main_window
gi.require_version('Gtk', '3.0')
from gi.repository import GLib, Gio, Gtk
from main_window import MainWindow
from keepassgtk.main_window import MainWindow
class Application(Gtk.Application):
def __init__(self, *args, **kwargs):
......@@ -48,7 +47,7 @@ class Application(Gtk.Application):
def on_settings_menu_clicked(self, action, param):
builder = Gtk.Builder()
builder.add_from_file("ui/settings_dialog.ui")
builder.add_from_resource("/run/terminal/KeepassGtk/settings_dialog.ui")
settings_dialog = builder.get_object("settings_dialog")
settings_dialog.set_modal(True)
settings_dialog.set_transient_for(self.window)
......@@ -56,7 +55,7 @@ class Application(Gtk.Application):
def on_about_menu_clicked(self, action, param):
builder = Gtk.Builder()
builder.add_from_file("ui/about_dialog.ui")
builder.add_from_resource("/run/terminal/KeepassGtk/about_dialog.ui")
about_dialog = builder.get_object("about_dialog")
about_dialog.set_modal(True)
about_dialog.set_transient_for(self.window)
......@@ -68,4 +67,4 @@ class Application(Gtk.Application):
if __name__ == "__main__":
app = Application()
app.run(sys.argv)
\ No newline at end of file
app.run(sys.argv)
import pykeepass
from pykeepass import PyKeePass
import logging_manager
from logging_manager import LoggingManager
from keepassgtk.logging_manager import LoggingManager
class KeepassLoader:
......
......@@ -2,10 +2,8 @@ import gi
import pykeepass
gi.require_version('Gtk', '3.0')
from gi.repository import GLib, Gtk
import database
from database import KeepassLoader
import database_creation_success_gui
from database_creation_success_gui import DatabaseCreationSuccessGui
from keepassgtk.database import KeepassLoader
from keepassgtk.database_creation_success_gui import DatabaseCreationSuccessGui
class DatabaseCreationGui:
builder = NotImplemented
......@@ -26,7 +24,7 @@ class DatabaseCreationGui:
def password_creation(self):
self.builder = Gtk.Builder()
self.builder.add_from_file("ui/create_database.ui")
self.builder.add_from_resource("/run/terminal/KeepassGtk/create_database.ui")
self.set_headerbar()
......
......@@ -2,8 +2,7 @@ import gi
import pykeepass
gi.require_version('Gtk', '3.0')
from gi.repository import GLib, Gtk
import database_opening_gui
from database_opening_gui import DatabaseOpeningGui
from keepassgtk.database_opening_gui import DatabaseOpeningGui
class DatabaseCreationSuccessGui:
......@@ -25,7 +24,7 @@ class DatabaseCreationSuccessGui:
def success_page(self):
self.builder = Gtk.Builder()
self.builder.add_from_file("ui/create_database_success.ui")
self.builder.add_from_resource("/run/terminal/KeepassGtk/create_database_success.ui")
self.stack = self.builder.get_object("database_creation_success_stack")
self.stack.set_visible_child(self.stack.get_child_by_name("page0"))
......
......@@ -2,16 +2,11 @@ import gi
import pykeepass
gi.require_version('Gtk', '3.0')
from gi.repository import GLib, Gio, Gtk
import database
from database import KeepassLoader
import logging_manager
from logging_manager import LoggingManager
import pathbar
from pathbar import Pathbar
import entry_row
from entry_row import EntryRow
import group_row
from group_row import GroupRow
from keepassgtk.database import KeepassLoader
from keepassgtk.logging_manager import LoggingManager
from keepassgtk.pathbar import Pathbar
from keepassgtk.entry_row import EntryRow
from keepassgtk.group_row import GroupRow
class DatabaseOpenGui:
......@@ -40,7 +35,7 @@ class DatabaseOpenGui:
self.current_group = self.keepass_loader.get_root_group()
self.builder = Gtk.Builder()
self.builder.add_from_file("ui/entries_listbox.ui")
self.builder.add_from_resource("/run/terminal/KeepassGtk/entries_listbox.ui")
scrolled_window = self.builder.get_object("scrolled_window")
self.parent_widget.add(scrolled_window)
......@@ -85,7 +80,7 @@ class DatabaseOpenGui:
def show_page_of_new_directory(self):
if self.stack.get_child_by_name(self.keepass_loader.get_group_uuid_from_group_object(self.current_group)) is None:
builder = Gtk.Builder()
builder.add_from_file("ui/entries_listbox.ui")
builder.add_from_resource("/run/terminal/KeepassGtk/entries_listbox.ui")
list_box = builder.get_object("list_box")
list_box.connect("row-activated", self.on_list_box_row_activated)
list_box.connect("row-selected", self.on_list_box_row_selected)
......
......@@ -3,13 +3,10 @@ import ntpath
import pykeepass
gi.require_version('Gtk', '3.0')
from gi.repository import GLib, Gtk
import database
from database import KeepassLoader
import database_open_gui
from database_open_gui import DatabaseOpenGui
import config_manager
import logging_manager
from logging_manager import LoggingManager
from keepassgtk.database import KeepassLoader
from keepassgtk.database_open_gui import DatabaseOpenGui
import keepassgtk.config_manager
from keepassgtk.logging_manager import LoggingManager
class DatabaseOpeningGui:
builder = NotImplemented
......@@ -35,7 +32,7 @@ class DatabaseOpeningGui:
def unlock_database(self):
self.builder = Gtk.Builder()
self.builder.add_from_file("ui/unlock_database.ui")
self.builder.add_from_resource("/run/terminal/KeepassGtk/unlock_database.ui")
self.set_headerbar()
......@@ -249,8 +246,8 @@ class DatabaseOpeningGui:
self.clear_input_fields()
self.parent_widget.remove(self.stack)
config_manager.create_config_entry_string("history", "last-opened-db", str(self.database_filepath))
config_manager.save_config()
keepassgtk.config_manager.create_config_entry_string("history", "last-opened-db", str(self.database_filepath))
keepassgtk.config_manager.save_config()
DatabaseOpenGui(self.window, self.parent_widget, self.keepass_loader)
......
import database
from database import KeepassLoader
from keepassgtk.database import KeepassLoader
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
......@@ -27,7 +26,7 @@ class EntryRow(Gtk.ListBoxRow):
def assemble_entry_row(self):
builder = Gtk.Builder()
builder.add_from_file("ui/entries_listbox.ui")
builder.add_from_resource("/run/terminal/KeepassGtk/entries_listbox.ui")
entry_box = builder.get_object("entry_box")
entry_name_label = builder.get_object("entry_name_label")
......@@ -55,4 +54,4 @@ class EntryRow(Gtk.ListBoxRow):
self.password = self.keepass_loader.get_entry_password(self.entry_uuid)
def get_type(self):
return self.type
\ No newline at end of file
return self.type
import database
from database import KeepassLoader
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from keepassgtk.database import KeepassLoader
class GroupRow(Gtk.ListBoxRow):
keepass_loader = NotImplemented
......@@ -25,7 +23,7 @@ class GroupRow(Gtk.ListBoxRow):
def assemble_group_row(self):
builder = Gtk.Builder()
builder.add_from_file("ui/entries_listbox.ui")
builder.add_from_resource("/run/terminal/KeepassGtk/entries_listbox.ui")
group_box = builder.get_object("group_box")
group_name_label = builder.get_object("group_name_label")
......
......@@ -8,17 +8,12 @@ gi.require_version('Gdk', '3.0')
from gi.repository import GLib, Gio, Gdk, Gtk
import pykeepass
from pykeepass import PyKeePass
import config_manager
import logging_manager
from logging_manager import LoggingManager
import database
from database import KeepassLoader
import database_creation_gui
from database_creation_gui import DatabaseCreationGui
import container_page
from container_page import ContainerPage
import database_opening_gui
from database_opening_gui import DatabaseOpeningGui
import keepassgtk.config_manager
from keepassgtk.logging_manager import LoggingManager
from keepassgtk.database import KeepassLoader
from keepassgtk.database_creation_gui import DatabaseCreationGui
from keepassgtk.container_page import ContainerPage
from keepassgtk.database_opening_gui import DatabaseOpeningGui
class MainWindow(Gtk.ApplicationWindow):
......@@ -29,13 +24,13 @@ class MainWindow(Gtk.ApplicationWindow):
filechooser_creation_dialog = NotImplemented
headerbar = NotImplemented
first_start_grid = NotImplemented
logging_manager
logging_manager = NotImplemented
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
config_manager.configure()
keepassgtk.config_manager.configure()
self.assemble_window()
......@@ -60,7 +55,7 @@ class MainWindow(Gtk.ApplicationWindow):
def create_headerbar(self):
builder = Gtk.Builder()
builder.add_from_file("ui/main_headerbar.ui")
builder.add_from_resource("/run/terminal/KeepassGtk/main_headerbar.ui")
self.headerbar = builder.get_object("headerbar")
......@@ -88,7 +83,8 @@ class MainWindow(Gtk.ApplicationWindow):
screen = Gdk.Screen.get_default()
css_provider = Gtk.CssProvider()
css_provider.load_from_path('data/custom.css')
css_provider_resource = Gio.File.new_for_uri('resource:///run/terminal/KeepassGtk/keepassgtk.css')
css_provider.load_from_file(css_provider_resource)
context = Gtk.StyleContext()
context.add_provider_for_screen(screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
......@@ -98,16 +94,16 @@ class MainWindow(Gtk.ApplicationWindow):
#
def first_start_screen(self):
if config_manager.has_group("history") and config_manager.get_string("history", "last-opened-db") != "" and exists(config_manager.get_string("history", "last-opened-db")):
self.logging_manager.log_debug("Found last opened database entry (" + config_manager.get_string("history", "last-opened-db") + ")")
if keepassgtk.config_manager.has_group("history") and keepassgtk.config_manager.get_string("history", "last-opened-db") != "" and exists(keepassgtk.config_manager.get_string("history", "last-opened-db")):
self.logging_manager.log_debug("Found last opened database entry (" + keepassgtk.config_manager.get_string("history", "last-opened-db") + ")")
regex = re.search("^(([A-Z]:)?[\.]?[\\{1,2}/]?.*[\\{1,2}/])*(.+)\.(.+)", config_manager.get_string("history", "last-opened-db"))
regex = re.search("^(([A-Z]:)?[\.]?[\\{1,2}/]?.*[\\{1,2}/])*(.+)\.(.+)", keepassgtk.config_manager.get_string("history", "last-opened-db"))
tab_title = regex[0]
self.start_database_opening_routine(tab_title, config_manager.get_string("history", "last-opened-db"))
self.start_database_opening_routine(tab_title, keepassgtk.config_manager.get_string("history", "last-opened-db"))
else:
self.logging_manager.log_debug("No / Not valid last opened database entry found.")
builder = Gtk.Builder()
builder.add_from_file("ui/main_headerbar.ui")
builder.add_from_resource("/run/terminal/KeepassGtk/main_headerbar.ui")
self.first_start_grid = builder.get_object("first_start_grid")
self.add(self.first_start_grid)
......@@ -162,7 +158,7 @@ class MainWindow(Gtk.ApplicationWindow):
def start_database_opening_routine(self, tab_title, filepath):
builder = Gtk.Builder()
builder.add_from_file("ui/create_database.ui")
builder.add_from_resource("/run/terminal/KeepassGtk/create_database.ui")
headerbar = builder.get_object("headerbar")
DatabaseOpeningGui(self, self.create_tab(tab_title, headerbar), filepath)
......@@ -192,7 +188,7 @@ class MainWindow(Gtk.ApplicationWindow):
def does_file_exist(self):
if os.path.exists(self.filechooser_creation_dialog.get_filename()):
builder = Gtk.Builder()
builder.add_from_file("ui/override_dialog.ui")
builder.add_from_resource("/run/terminal/KeepassGtk/override_dialog.ui")
self.override_dialog = builder.get_object("override_dialog")
self.override_dialog.set_parent(self.filechooser_creation_dialog)
......@@ -221,7 +217,7 @@ class MainWindow(Gtk.ApplicationWindow):
def start_database_creation_routine(self, tab_title):
self.keepass_loader = KeepassLoader(self.filechooser_creation_dialog.get_filename(), "liufhre86ewoiwejmrcu8owe")
builder = Gtk.Builder()
builder.add_from_file("ui/create_database.ui")
builder.add_from_resource("/run/terminal/KeepassGtk/create_database.ui")
headerbar = builder.get_object("headerbar")
DatabaseCreationGui(self, self.create_tab(tab_title, headerbar), self.keepass_loader)
......
import pathbar_button
from pathbar_button import PathbarButton
from keepassgtk.pathbar_button import PathbarButton
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
......@@ -23,7 +22,7 @@ class Pathbar(Gtk.HBox):
self.headerbar = headerbar
self.builder = Gtk.Builder()
self.builder.add_from_file("ui/entries_listbox.ui")
self.builder.add_from_resource("/run/terminal/KeepassGtk/entries_listbox.ui")
self.assemble_pathbar()
......
project('keepassgtk', 'c',
version: '0.0.1',
meson_version: '>= 0.40.0',
)
i18n = import('i18n')
python = import('python3')
project_id = 'run.terminal.KeepassGtk'
message('Looking for dependencies')
python_bin = python.find_python()
if not python_bin.found()
error('No valid python3 binary found')
else
message('Found python3 binary')
endif
dependency('glib-2.0')
dependency('gobject-introspection-1.0', version: '>=1.35.9')
dependency('gtk+-3.0', version :'>=3.20')
env = environment()
python_dir = join_paths(get_option('prefix'), python.sysconfig_path('purelib'))
LIBEXEC_DIR = join_paths(get_option('prefix'), get_option('libexecdir'))
EXTENSION_DIR = join_paths(get_option('prefix'), get_option('libdir'), meson.project_name())
DATA_DIR = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
bindir = join_paths(get_option('prefix'), get_option('bindir'))
conf = configuration_data()
conf.set('PACKAGE_URL', 'https://github.com/TerminalDotRun/KeepassGtk')
conf.set('DATA_DIR', DATA_DIR)
conf.set('EXTENSION_DIR', EXTENSION_DIR)
conf.set('LOCALE_DIR', join_paths(get_option('prefix'), get_option('datadir'), 'locale'))
conf.set('PYTHON_DIR', python_dir)
conf.set('PYTHON_EXEC_DIR', join_paths(get_option('prefix'), python.sysconfig_path('stdlib')))
conf.set('PYTHON', python_bin.path())
conf.set('libexecdir', LIBEXEC_DIR)
conf.set('VERSION', meson.project_version())
subdir('data')
install_subdir(
'keepassgtk',
install_dir: python_dir
)
message('Preparing init file')
configure_file(
input: 'keepassgtk.in',
output: 'keepassgtk',
configuration: conf,
install_dir: bindir
)
meson.add_install_script('meson_post_install.py')
#!/usr/bin/env python3
from os import environ, path
from subprocess import call
prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
datadir = path.join(prefix, 'share')
destdir = environ.get('DESTDIR', '')
if not destdir:
print('Updating icon cache...')
call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')])
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