adding/testing some initial views/architecture

main
Steve Ayerhart 2022-01-04 15:24:11 -05:00
parent dc32e06925
commit a858c27e23
No known key found for this signature in database
GPG Key ID: 5C815FDF3A00B8BA
27 changed files with 657 additions and 104 deletions

View File

@ -1,3 +1,7 @@
install_data(
meson.project_name() + '.gschema.xml'
meson.project_name() + '.gschema.xml',
install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas')
)
subdir('ui')

View File

@ -1,6 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/bonerbonerboner/reclaim/">
<gresource prefix="/reclaim">
<file alias="application.css" compressed="true">application.css</file>
<file compressed="true" preprocess="xml-stripblanks" alias="MainWindow.ui">ui/MainWindow.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="MainAccountListView.ui">ui/MainAccountListView.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="MainAccountListRow.ui">ui/MainAccountListRow.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="ContentView.ui">ui/ContentView.ui</file>
</gresource>
</gresources>

64
data/ui/#Reclaim.ui# Normal file
View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkApplicationWindow" id="ReclaimWindow">
<property name="can-focus">False</property>
<child>
<object class="GtkPaned">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="wide-handle">True</property>
<child>
<object class="GtkListBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">label</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="resize">False</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<object class="GtkStack">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="transition-type">crossfade</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<requires lib="libhandy" version="0.0"/>
<object class="HdyApplicationWindow">
<property name="can-focus">False</property>
<child>
<placeholder/>
</child>
</object>
</interface>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="AccountTransactions" parent="GtkBox">
<child>
<object class="GtkTreeView" id="tree_view">
<child>
<object class="GtkTreeViewColumn" id="datetime_column">
<property name="title" translatable="yes">_Date</property>
<child>
<object class="GtkCellRendererText" id="date-renderer">
<attributes>
<attribute name="text">1</attribute>
</attributes>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>

25
data/ui/ContentView.ui Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ReclaimContentView" parent="ReclaimView">
<property name="vexpand">1</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="AdwHeaderBar" id="titlebar">
<property name="hexpand">1</property>
<property name="show-start-title-buttons">0</property>
<child type="title">
<object class="GtkBox">
</object>
</child>
<style>
<class name="reclaim-titlebar"/>
</style>
</object>
</child>
<!--stack?-->
</object>
</child>
</template>
</interface>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkBox">
<property name="spacing">12</property>
<child>
<object class="GtkImage" id="account_badge">
<property name="valign">center</property>
<property name="icon-name">account-symbolic</property>
</object>
</child>
<child>
<object class="GtkLabel" id="account_label">
<property name="valign">center</property>
<binding name="label">
<lookup name="title" type="ReclaimAccount">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</child>
</object>
</property>
</template>
</interface>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ReclaimAccountListView" parent="ReclaimView">
<child>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
<property name="width-request">250</property>
<property name="vexpand">1</property>
<child>
<object class="GtkListView" id="lv">
<style>
<class name="boxed-list"/>
<class name="content-sidebar-main"/>
</style>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="resource">/reclaim/MainAccountListRow.ui</property>
</object>
</property>
<property name="model">
<object class="GtkNoSelection" id="selection_model">
<binding name="model">
<lookup name="accounts">ReclaimMainAcountListView</lookup>
</binding>
</object>
</property>
</object>
</child>
</object>
</child>
</template>
</interface>

174
data/ui/MainWindow.ui Normal file
View File

@ -0,0 +1,174 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.0"/>
<template class="ReclaimMainWindow" parent="AdwApplicationWindow">
<property name="visible">1</property>
<property name="default-width">830</property>
<property name="default-height">700</property>
<child>
<object class="GtkBox" id="main_box">
<property name="orientation">vertical</property>
<property name="homogeneous">1</property>
<child>
<object class="AdwLeaflet" id="leaf">
<property name="can-navigate-back">1</property>
<property name="can-navigate-forward">1</property>
<child>
<object class="AdwLeafletPage">
<property name="child">
<object class="GtkWindowHandle" id="nbgrid">
<property name="hexpand">0</property>
<property name="vexpand">1</property>
<child>
<object class="GtkBox">
<property name="hexpand">0</property>
<property name="orientation">vertical</property>
<child>
<object class="AdwHeaderBar" id="nbtitlebar">
<property name="show-end-title-buttons" bind-source="leaf" bind-property="folded" bind-flags="sync-create"/>
<property name="valign">center</property>
<property name="hexpand">0</property>
<property name="width-request">220</property>
<property name="margin-bottom">6</property>
<style>
<class name="reclaim-stitle"/>
</style>
<child type="title">
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label">Reclaim</property>
<style>
<class name="title"/>
</style>
</object>
</child>
</object>
</child>
<child type="end">
<object class="GtkMenuButton" id="menu_button">
<property name="icon-name">open-menu-symbolic</property>
</object>
</child>
<child>
<object class="GtkButton" id="en_button">
<property name="icon-name">x-office-spreadsheet-symbolic</property>
<property name="tooltip-text" translatable="yes">Manage Accounts…</property>
</object>
</child>
</object>
</child>
<child>
</child>
<child>
<object class="GtkToggleButton" id="an_button">
<!--<signal name="toggled" handler="on_action_all_accounts" />-->
<property name="margin-bottom">6</property>
<property name="margin-start">6</property>
<property name="margin-end">6</property>
<child>
<object class="AdwButtonContent">
<property name="halign">start</property>
<property name="label" translatable="yes">All Accounts</property>
<property name="icon-name">view-list-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLabel" id="account_label">
<property name="label" translatable="yes">Accounts</property>
<property name="halign">start</property>
<property name="margin-start">12</property>
<style>
<class name="heading"/>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="margin-bottom">6</property>
<property name="vexpand">1</property>
<child>
</child>
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</child>
<child>
<object class="AdwLeafletPage">
<property name="child">
<object class="GtkStack" id="sgrid">
<property name="vexpand">1</property>
<property name="hexpand">0</property>
<property name="transition-type">crossfade</property>
<child>
<object class="GtkStackPage">
<property name="name">accounts</property>
<property name="child">
<object class="GtkOverlay" id="list_scroller">
<child>
<object class="GtkBox">
<property name="vexpand">1</property>
<property name="hexpand">0</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="bscroller">
<property name="hscrollbar-policy">never</property>
<property name="vexpand">1</property>
<child>
</child>
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</child>
</object>
</property>
</object>
</child>
<child>
<object class="AdwLeafletPage">
<property name="navigatable">0</property>
<property name="child">
<object class="GtkSeparator">
<style>
<class name="no-sep"/>
</style>
</object>
</property>
</object>
</child>
<child>
<object class="AdwLeafletPage">
<property name="child">
<object class="GtkStack" id="grid">
<child>
<object class="GtkStackPage">
<property name="name">content</property>
<property name="child">
<object class="ReclaimContentView">
<property name="hexpand">yes</property>
</object>
</property>
</object>
</child>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>

5
data/ui/MainWindow.ui~ Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
</interface>

57
data/ui/Reclaim.ui~ Normal file
View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<requires lib="libhandy" version="0.0"/>
<object class="HdyApplicationWindow" id="ReclaimWindow">
<property name="can-focus">False</property>
<property name="title" translatable="yes">Reclaim</property>
<child>
<object class="GtkPaned">
<property name="width-request">50</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="hexpand">False</property>
<property name="position-set">True</property>
<property name="wide-handle">True</property>
<child>
<object class="GtkListBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">start</property>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">label</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="resize">False</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="stock">gtk-about</property>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<template class="ReclaimTransactionsView" parent="GtkTreeView">
<child>
<property name="visible">True</property>
<property name="can-focus">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="DateTimeColumn">
<property name="title" translatable="yes">Date</property>
<property name="clickable">True</property>
<property name="sort-indicator">True</property>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="PayeeColumn">
<property name="title" translatable="yes">Payee</property>
</object>
</child>
</child>
</template>
</interface>

7
data/ui/meson.build Normal file
View File

@ -0,0 +1,7 @@
gnome = import ('gnome')
reclaim_resources = gnome.compile_resources(
'reclaim-resources',
'reclaim.gresource.xml',
c_name: 'reclaim'
)

View File

@ -24,24 +24,12 @@ asresources = gnome.compile_resources(
c_name: 'as'
)
conf_data = configuration_data()
conf_data.set_quoted('PROJECT_NAME', meson.project_name())
conf_data.set_quoted('VERSION', meson.project_version())
conf_data.set_quoted('GETTEXT_PACKAGE', meson.project_name())
conf_data.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
config_header = configure_file(
input : 'config.vala.in',
output : 'config.vala',
configuration : conf_data
)
dependencies = [
dependency('gee-0.8'),
dependency('glib-2.0'),
dependency('gobject-2.0'),
dependency('gtk+-3.0'),
dependency('granite', version: '>=6.1.0'),
dependency('libhandy-1', version: '>=1.4.0'),
dependency('gtk4', version: '>=4.4.1'),
dependency('libadwaita-1', version: '>=1.0.1'),
dependency('sqlite3'),
meson.get_compiler('vala').find_library('posix'),
@ -49,4 +37,5 @@ dependencies = [
]
subdir('src')
subdir('data')
subdir('po')

View File

@ -1,11 +1,16 @@
public class Reclaim.Application : Gtk.Application {
public static GLib.Settings settings;
public class Reclaim.Application : Adw.Application {
public static int main (string[] args) {
var app = new Reclaim.Application ();
private MainWindow? main_window = null;
return app.run (args);
}
public Application () {
Object (
application_id: Config.APP_ID,
flags: ApplicationFlags.HANDLES_COMMAND_LINE
);
construct {
flags |= ApplicationFlags.HANDLES_COMMAND_LINE;
application_id = "org.bonerbonerboner.reclaim";
Intl.setlocale (LocaleCategory.ALL, "");
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
@ -13,18 +18,28 @@ public class Reclaim.Application : Gtk.Application {
Intl.textdomain (Config.GETTEXT_PACKAGE);
}
static construct {
// settings = new GLib.Settings ("org.bonerbonerboner.reclaim");
protected override void activate () {
active_window?.present ();
}
public override void activate () {
if (main_window == null) {
main_window = new MainWindow (this);
protected override void startup () {
resource_base_path = "/boneboneboner/reclaim";
main_window.show_all ();
}
base.startup ();
// typeof (AccountListView).ensure ();
// var account_repository = new AccountRespository ();
// var account_view_model = new AccountViewModel (account_repository);
//
typeof (ContentView).ensure ();
new MainWindow (this);
}
protected override void shutdown () {
base.shutdown ();
main_window.present ();
}
public override int command_line (ApplicationCommandLine command_line) {
@ -32,10 +47,4 @@ public class Reclaim.Application : Gtk.Application {
return 0;
}
public static int main (string[] args) {
var app = new Reclaim.Application ();
return app.run (args);
}
}

View File

@ -1,6 +1,9 @@
[CCode (cprefix="", lower_case_cprefix = "", cheader_filename = "config.h")]
namespace Config {
public const string APP_ID = @APP_ID@;
public const string PROJECT_NAME = @PROJECT_NAME@;
public const string VERSION = @VERSION@;
public const string GETTEXT_PACKAGE = @GETTEXT_PACKAGE@;
public const string LOCALEDIR = @LOCALEDIR@;
public const string DATADIR = @DATADIR@;
}

6
src/core/Account.vala Normal file
View File

@ -0,0 +1,6 @@
namespace Reclaim {
public class Account : Object {
public int id { get; set; }
public string name { get; set; }
}
}

View File

@ -1,9 +1,37 @@
source_files = files(
'Application.vala',
'ui/TransactionsView.vala',
'utils/ObservableList.vala',
'repositories/AccountRepository.vala',
'core/Account.vala',
'repositories/AccountRepository.vala',
'ui/View.vala',
'ui/ContentView.vala',
'ui/AccountViewModel.vala',
'ui/MainAccountListView.vala',
'ui/MainWindow.vala'
)
conf_data = configuration_data()
conf_data.set_quoted('G_LOG_DOMAIN', 'Reclaim')
conf_data.set_quoted('APP_ID', 'com.bonerbonerboner.Reclaim')
conf_data.set_quoted('PROJECT_NAME', meson.project_name())
conf_data.set_quoted('VERSION', meson.project_version())
conf_data.set_quoted('GETTEXT_PACKAGE', meson.project_name())
conf_data.set_quoted('DATADIR', join_paths(get_option('prefix'), get_option('datadir')))
conf_data.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
config_header = configure_file(
input : 'Config.vala.in',
output : 'Config.vala',
configuration : conf_data
)
executable(
meson.project_name(),
source_files,

View File

@ -0,0 +1,4 @@
namespace Reclaim {
public class AccountRepository : Object {
}
}

View File

@ -0,0 +1,5 @@
namespace Reclaim {
[GtkTempalte (ui = "/reclaim/AccountTransactions.ui")]
public class AccountTransactions : GtkBox {
}
}

View File

@ -0,0 +1,10 @@
namespace Reclaim {
public class AccountViewModel : Object {
public ObservableList<Account> accounts { get; default = new ObservableList<Account> (); }
public AccountRepository? repository { get; construct; }
public AccountViewModel (AccountRepository repository) {
Object(repository: repository);
}
}
}

5
src/ui/ContentView.vala Normal file
View File

@ -0,0 +1,5 @@
namespace Reclaim {
[GtkTemplate (ui = "/reclaim/ContentView.ui")]
public class ContentView : View {
}
}

View File

@ -0,0 +1,5 @@
namespace Reclaim {
[GtkTemplate (ui = "/reclaim/MainAccountListView.ui")]
public class MainAccountListView : View {
}
}

View File

@ -1,41 +1,14 @@
namespace Reclaim {
public class MainWindow : Hdy.ApplicationWindow {
[GtkTemplate (ui = "/reclaim/MainWindow.ui")]
public class MainWindow : Adw.ApplicationWindow {
public Reclaim.Application app { get; construct; }
public Reclaim.TransactionView transaction_view { get; construct; }
public MainWindow? main_window { get; set; }
public Adw.Leaflet? leaflet { get; set; }
public MainWindow (Reclaim.Application app) {
Object (
app: app
);
}
static construct {
Hdy.init ();
}
construct {
set_application (app);
// temp code for now
var store = new Gtk.TreeStore (2, typeof(string), typeof(string));
var transaction_view = new Reclaim.TransactionView();
transaction_view.set_model(store);
add(transaction_view);
set_visual (Gdk.Screen.get_default ().get_rgba_visual ());
setup_ui ();
show_all ();
}
private void setup_ui () {
var provider = new Gtk.CssProvider ();
Gtk.StyleContext.add_provider_for_screen (
Gdk.Screen.get_default (),
provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + 1
GLib.Object (
application: app,
title: "Reclaim"
);
}
}

View File

@ -1,33 +0,0 @@
using Gtk;
namespace Reclaim {
public class TransactionView : TreeView {
public TreeViewColumn date_column { get; construct; }
public TreeViewColumn payee_column { get; construct; }
construct {
date_column = new TreeViewColumn ();
payee_column = new TreeViewColumn ();
setup_ui ();
}
private void setup_ui () {
date_column.title = _("Date");
var date_cell = new CellRendererText ();
date_column.add_attribute (date_cell, "text", 0);
date_column.set_resizable (true);
date_column.pack_start (date_cell, true);
payee_column.title = _("Payee");
payee_column.set_resizable (true);
var payee_cell = new CellRendererText ();
payee_column.add_attribute (payee_cell, "text", 1);
payee_column.pack_start (payee_cell, true);
append_column (date_column);
append_column (payee_column);
}
}
}

35
src/ui/View.vala Normal file
View File

@ -0,0 +1,35 @@
using Gtk;
using Adw;
namespace Reclaim {
public abstract class View : Widget, Buildable {
Bin? child_bin = new Bin () { vexpand = true };
public Widget? child {
get { return child_bin.child; }
set { child_bin.child = value; }
}
construct {
layout_manager = new BoxLayout (VERTICAL);
child_bin?.set_parent (this);
}
protected override void dispose () {
child_bin?.unparent ();
child_bin = null;
base.dispose ();
}
void add_child (Builder builder, Object child, string? type) {
if (child is Widget) {
this.child = (Widget) child;
return;
}
base.add_child (builder, child, type);
}
}
}

View File

@ -0,0 +1,56 @@
namespace Reclaim {
public class ObservableList<T> : Object, ListModel {
List<T> data = new List<T> ();
public void add (T item) {
var position = data.length ();
data.append (item);
items_changed (position, 0, 1);
}
public void add_all (List<T> items) {
var position = data.length ();
foreach (var item in items)
data.append (item);
items_changed (position, 0, items.length ());
}
public void remove_all () {
var current_size = data.length ();
data = new List<T> ();
items_changed (0, current_size, 0);
}
public new T @get (uint index) {
return data.nth_data (index);
}
public bool remove (T item) {
var position = data.index (item);
if (position == -1)
return false;
data.remove (item);
items_changed (position, 1, 0);
return true;
}
Object? get_item (uint position) {
return this[position] as Object;
}
Type get_item_type () {
return typeof (T);
}
uint get_n_items () {
return data.length ();
}
}
}