~tristan957/harvest-almanac

396c5ecb4201abdaf8c9969719517d15e30f4d27 — Tristan Partin 2 years ago
app: Created password schema
98 files changed, 9430 insertions(+), 0 deletions(-)

A .build.yml
A .clang-format
A .gitignore
A CONTRIBUTING.md
A LICENSE
A README.md
A data/hal-resources.gresource.xml
A data/io.partin.tristan.HarvestAlmanac.appdata.xml.in
A data/io.partin.tristan.HarvestAlmanac.desktop.in
A data/io.partin.tristan.HarvestAlmanac.gschema.xml
A data/meson.build
A data/ui/hal-preferences-window.ui
A data/ui/hal-profile.ui
A data/ui/hal-time-entry.ui
A data/ui/hal-time-tracker.ui
A data/ui/hal-window.ui
A dist/flatpak/io.partin.tristan.HarvestAlmanac.json
A dist/snap/snapcraft.yaml
A harvest-almanac/hal-application.c
A harvest-almanac/hal-application.h
A harvest-almanac/hal-preferences-window.c
A harvest-almanac/hal-preferences-window.h
A harvest-almanac/hal-profile.c
A harvest-almanac/hal-profile.h
A harvest-almanac/hal-time-entry.c
A harvest-almanac/hal-time-entry.h
A harvest-almanac/hal-time-tracker.c
A harvest-almanac/hal-time-tracker.h
A harvest-almanac/hal-window.c
A harvest-almanac/hal-window.h
A harvest-almanac/harvest-almanac.doap
A harvest-almanac/main.c
A harvest-almanac/meson.build
A harvest-glib/config.h
A harvest-glib/harvest-api-client.c
A harvest-glib/harvest-api-client.h
A harvest-glib/harvest-client.c
A harvest-glib/harvest-client.h
A harvest-glib/harvest-common.c
A harvest-glib/harvest-common.h
A harvest-glib/harvest-creator.c
A harvest-glib/harvest-creator.h
A harvest-glib/harvest-error.h
A harvest-glib/harvest-estimate-item-category.c
A harvest-glib/harvest-estimate-item-category.h
A harvest-glib/harvest-estimate-line-item.c
A harvest-glib/harvest-estimate-line-item.h
A harvest-glib/harvest-estimate.c
A harvest-glib/harvest-estimate.h
A harvest-glib/harvest-glib.doap
A harvest-glib/harvest-http.h
A harvest-glib/harvest-invoice-item-category.c
A harvest-glib/harvest-invoice-item-category.h
A harvest-glib/harvest-invoice-line-item.c
A harvest-glib/harvest-invoice-line-item.h
A harvest-glib/harvest-invoice.c
A harvest-glib/harvest-invoice.h
A harvest-glib/harvest-late-request.c
A harvest-glib/harvest-late-request.h
A harvest-glib/harvest-links.c
A harvest-glib/harvest-links.h
A harvest-glib/harvest-pageable.c
A harvest-glib/harvest-pageable.h
A harvest-glib/harvest-paged.c
A harvest-glib/harvest-paged.h
A harvest-glib/harvest-project.c
A harvest-glib/harvest-project.h
A harvest-glib/harvest-request.c
A harvest-glib/harvest-request.h
A harvest-glib/harvest-response-metadata.c
A harvest-glib/harvest-response-metadata.h
A harvest-glib/harvest-response.c
A harvest-glib/harvest-response.h
A harvest-glib/harvest-task-assignment.c
A harvest-glib/harvest-task-assignment.h
A harvest-glib/harvest-task.c
A harvest-glib/harvest-task.h
A harvest-glib/harvest-time-entry.c
A harvest-glib/harvest-time-entry.h
A harvest-glib/harvest-user-assignment.c
A harvest-glib/harvest-user-assignment.h
A harvest-glib/harvest-user.c
A harvest-glib/harvest-user.h
A harvest-glib/harvest.h
A harvest-glib/meson.build
A meson.build
A meson_options.txt
A meson_post_install.sh
A po/LINGUAS
A po/POTFILES
A po/meson.build
A scripts/run-glade-with-libhandy.sh
A subprojects/gio.wrap
A subprojects/gtk.wrap
A subprojects/json-glib.wrap
A subprojects/libhandy.wrap
A subprojects/libsecret.wrap
A subprojects/libsoup.wrap
A  => .build.yml +35 -0
@@ 1,35 @@
image: alpine/edge
packages:
  - gtk+3.0-dev
  - meson
  - json-glib-dev
  - libhandy-dev
  - libsoup-dev
  - libsecret-dev
  # annotatec deps
  - flex
  - bison
secrets:
  - 92357bf7-1b44-4630-999e-fca4a120c50b
sources:
  - https://git.sr.ht/~tristan957/harvest-almanac
  - https://git.sr.ht/~sircmpwn/annotatec
tasks:
  - setup: |
      cd harvest-almanac
      CC=gcc meson -Dwerror=true -Dbuildtype=release build
  - build: |
      cd harvest-almanac
      ninja -C build
  - annotatec: |
      cd annotatec
      make
      sudo make install PREFIX=/usr
  - annotate: |
      cd harvest-almanac
      find . -name "*.c" | xargs \
        annotatec -gC "cpp -std=gnu11 -U __GNUC__ -D__HARVEST_COMPILATION__ \
          -D HANDY_USE_UNSTABLE_API -Iharvest-glib -Iharvest-alamnac -Ibuild/data \
          $(pkg-config --cflags gio-2.0 json-glib-1.0 gtk+-3.0 \
          libhandy-0.0 libsoup-2.4 libsecret-1)" > annotations.json
      ~/upload-annotations annotations.json tristan957 harvest-almanac

A  => .clang-format +98 -0
@@ 1,98 @@
# The Return0Software C/C++ Coding Standard
#
# How to run executable: https://clang.llvm.org/docs/ClangFormat.html
# Style options: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
#
# Last Revision: 3/12/2018
---
AccessModifierOffset: 0
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
# AlignConsecutiveMacros: true
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
# AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: TopLevelDefinitions
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
  AfterClass: true
  AfterControlStatement: false
  AfterEnum: true
  AfterExternBlock: true
  AfterFunction: true
  AfterNamespace: true
  AfterStruct: true
  AfterUnion: true
  BeforeCatch: false
  BeforeElse: false
  IndentBraces: false
  SplitEmptyFunction: false
  SplitEmptyRecord: false
  SplitEmptyNamespace: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
BreakStringLiterals: true
ColumnLimit: 100
CommentPragmas:  '\*\<'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
IndentCaseLabels: false
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
Language: Cpp
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
# PenaltyBreakBeforeFirstCallParameter: 400
# PenaltyBreakComment: 0
# PenaltyBreakFirstLessLess: (not cpp)
# PenaltyBreakString: 500
# PenaltyExcessCharacter: 10000
# PenaltyReturnTypeOnItsOwnLine: 600
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
# Standard: Cpp11
TabWidth: 4
UseTab: Always
...

A  => .gitignore +12 -0
@@ 1,12 @@
*.ui#
*.ui~
.env
.flatpak*
.vscode/
build
*.http
.exrc

# Don't ignore wraps
subprojects/*
!subprojects/*.wrap

A  => CONTRIBUTING.md +73 -0
@@ 1,73 @@
# Contributing

Harvest Almanac is composed of two components:

* `libharvest-glib`
* `harvest-almanac`

## libharvest-glib

`libharvest-glib` is an API wrapper around the Harvest API V2. It makes use of
the GObject type system around its entities.

## harvest-almanac

`harvest-almanac` is the GUI application written in GTK to interact with
Harvest. It uses `libharvest-glib` to do this.

## Development

### Setup

This project has only been tested with `gcc`. The build system for the
project is Meson. Make sure that is installed on your system.

```text
CC=gcc meson build
```

### Dependencies

This project has been configured to use Meson's WrapDB if development libraries
are not found on the host system. If you want to use WrapDB-provided
dependencies, simply run the command

```text
meson configure -Dwrap_mode=forcefallback build
```

### Building

This project includes support for flatpak and snap in addition to a regular
application.

Unfortunately the version of GTK in the `core18` snap is incompatible with
`libhandy`. A workaround could be using the GTK wrap supplied in this repo. It
would take time to figure out if versions of packages in `core18` work with
GTK 3.24. This is doable if someone commits to it.

#### Host

```text
ninja -C build
```

#### flatpak

```text
flatpak-builder --verbose --sandbox --force-clean --repo=.flatpak-repo --ccache --user --install-deps-from=flathub --install .flatpak  dist/flatpak/io.partin.tristan.HarvestAlmanac.json
```

### Running

#### Host

```text
./build/src/harvest-almanac
```

#### flatpak

```text
flatpak run io.partin.tristan.HarvestAlmanac
```

A  => LICENSE +674 -0
@@ 1,674 @@
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    <program>  Copyright (C) <year>  <name of author>
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

A  => README.md +15 -0
@@ 1,15 @@
[![builds.sr.ht status](https://builds.sr.ht/~tristan957/harvest-almanac/.build.yml.svg)](https://builds.sr.ht/~tristan957/harvest-almanac/.build.yml?)

# Harvest Almanac

**Not endorsed by Harvest in any way shape or form**

If you have used Harvest in the past, you have probably used their Mobile, Mac,
and/or Windows clients. Unfortunately, Harvest does not provide a Linux client.

Harvest Almanac aims to be the client for Linux. It includes mobile support
for phones using [`libhandy`](https://source.puri.sm/Librem5/libhandy).

This product is still largely in development, and is unusable at the moment.
Contributors are welcome to participate, however. Please refer to the
`CONTRIBUTING.md` if you are interested.

A  => data/hal-resources.gresource.xml +10 -0
@@ 1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
	<gresource prefix="/io/partin/tristan/HarvestAlmanac">
		<file preprocess="xml-stripblanks">ui/hal-preferences-window.ui</file>
		<file preprocess="xml-stripblanks">ui/hal-profile.ui</file>
		<file preprocess="xml-stripblanks">ui/hal-time-entry.ui</file>
		<file preprocess="xml-stripblanks">ui/hal-time-tracker.ui</file>
		<file preprocess="xml-stripblanks">ui/hal-window.ui</file>
	</gresource>
</gresources>

A  => data/io.partin.tristan.HarvestAlmanac.appdata.xml.in +13 -0
@@ 1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
	<id>io.partin.tristan.HarvestAlmanac</id>
	<licence>GPL-3.0</licence>
	<description>
		<p>Harvest client for Linux</p>
	</description>
	<url type="homepage">https://git.sr.ht/~tristan957/harvest-almanac</url>
	<screenshots>
		<screenshot type="default">...</screenshot>
	</screenshots>
	<updatecontact>tristan_dot_partin_at_gmail.com</updatecontact>
</component>

A  => data/io.partin.tristan.HarvestAlmanac.desktop.in +11 -0
@@ 1,11 @@
[Desktop Entry]
Name=Harvest Almanac
Comment=Harvest for Linux
Keywords=harvest;time
Exec=harvest-almanac
Terminal=false
Type=Application
Categories=GTK
StartupNotify=true
X-GNOME-UsesNotifications=true


A  => data/io.partin.tristan.HarvestAlmanac.gschema.xml +30 -0
@@ 1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="harvest-almanac">
	<schema id="io.partin.tristan.HarvestAlmanac" path="/io/partin/tristan/HarvestAlmanac/">
		<key name="harvest-api-access-token" type="s">
			<default>""</default>
			<summary>Harvest API Access Token</summary>
			<description>Harvest API access token for issuing requests. Must be set.</description>
		</key>
		<key name="prefer-dark-theme" type="b">
			<default>true</default>
			<summary>Prefer a dark theme</summary>
			<description>When true, the application will request a dark theme.</description>
		</key>
		<key name="soup-logger-level" type="y">
			<default>0</default>
			<summary>Soup Logger level</summary>
			<description>Level at which to log HTTP activity within the application.</description>
		</key>
		<key name="soup-max-conns" type="u">
			<default>4</default>
			<summary>Soup Max Connections</summary>
			<description>Max number of connections to keep open in the HTTP client.</description>
		</key>
		<key name="harvest-api-contact-email" type="s">
			<default>""</default>
			<summary>Harvest API Contact Email</summary>
			<description>Harvest API will contact this email if the API is misused in anyway. Must be set.</description>
		</key>
	</schema>
</schemalist>

A  => data/meson.build +27 -0
@@ 1,27 @@
i18n.merge_file(
    input: 'io.partin.tristan.HarvestAlmanac.desktop.in',
    output: 'io.partin.tristan.HarvestAlmanac.desktop',
    type: 'desktop',
    po_dir: '../po',
    install: true,
    install_dir: join_paths(get_option('datadir'), 'applications'),
)

i18n.merge_file(
    input: 'io.partin.tristan.HarvestAlmanac.appdata.xml.in',
    output: 'io.partin.tristan.HarvestAlmanac.appdata.xml',
    po_dir: '../po',
    install: true,
    install_dir: join_paths(get_option('datadir'), 'appdata'),
)

harvest_almanac_resources = gnome.compile_resources(
    'hal-resources',
    'hal-resources.gresource.xml',
    source_dir: '../data',
    c_name: 'hal',
)

install_data('io.partin.tristan.HarvestAlmanac.gschema.xml',
    install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas')
)

A  => data/ui/hal-preferences-window.ui +129 -0
@@ 1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
  <requires lib="gtk+" version="3.20"/>
  <requires lib="libhandy" version="0.0"/>
  <template class="HalPreferencesWindow" parent="HdyPreferencesWindow">
    <property name="default_height">700</property>
    <property name="default_width">640</property>
    <property name="width_request">300</property>
    <child>
      <object class="HdyPreferencesPage">
        <property name="icon_name">preferences-system-symbolic</property>
        <property name="title">General</property>
        <property name="visible">True</property>
        <child>
          <object class="HdyPreferencesGroup">
            <property name="description" translatable="yes">Settings for changing the view.</property>
            <property name="title" translatable="yes">View</property>
            <property name="visible">True</property>
            <child>
              <object class="HdyActionRow">
                <property name="title" translatable="yes">Prefer Dark Theme</property>
                <property name="visible">True</property>
                <child type="action">
                  <object class="GtkSwitch" id="prefer_dark_theme_switch">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="valign">center</property>
                  </object>
                </child>
              </object>
            </child>
          </object>
        </child>
        <child>
          <object class="HdyPreferencesGroup">
            <property name="description" translatable="yes">Harvest Almanac requires that an access token and contact email be set in order to properly use the Harvest API on your behalf.</property>
            <property name="title" translatable="yes">Harvest API</property>
            <property name="visible">True</property>
            <child>
              <object class="HdyActionRow">
                <property name="title" translatable="yes">Access Token</property>
                <property name="visible">True</property>
                <child type="action">
                  <object class="GtkEntry" id="harvest_api_access_token_entry">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="valign">center</property>
                  </object>
                </child>
              </object>
            </child>
            <child>
              <object class="HdyActionRow">
                <property name="title" translatable="yes">Contact Email</property>
                <property name="visible">True</property>
                <child type="action">
                  <object class="GtkEntry" id="harvest_api_contact_email">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="valign">center</property>
                  </object>
                </child>
              </object>
            </child>
          </object>
        </child>
      </object>
    </child>
    <child>
      <object class="HdyPreferencesPage">
        <property name="icon_name">preferences-other-symbolic</property>
        <property name="title">Advanced</property>
        <property name="visible">True</property>
        <child>
          <object class="HdyPreferencesGroup">
            <property name="description" translatable="yes">Harvest Almanac uses libsoup to access the Harvest API. Below are some settings that you can adjust in order to adjust performance and more easily debug potential issues.</property>
            <property name="title" translatable="yes">Soup</property>
            <property name="visible">True</property>
            <child>
              <object class="HdyActionRow">
                <property name="title" translatable="yes">Max Connections</property>
                <property name="visible">True</property>
                <child type="action">
                  <object class="GtkSpinButton" id="soup_max_connections_spin">
                    <property name="adjustment">soup_max_connections_adjustment</property>
                    <property name="valign">center</property>
                    <property name="visible">True</property>
                  </object>
                </child>
              </object>
            </child>
            <child>
              <object class="HdyActionRow">
                <property name="title" translatable="yes">Logger Level</property>
                <property name="visible">True</property>
                <child type="action">
                  <object class="GtkComboBoxText" id="soup_logger_level_combo">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="valign">center</property>
                    <property name="active">0</property>
                    <items>
                      <item id="0" translatable="yes">None</item>
                      <item id="1" translatable="yes">Minimal</item>
                      <item id="2" translatable="yes">Headers</item>
                      <item id="3" translatable="yes">Body</item>
                    </items>
                  </object>
                  <packing>
                    <property name="left_attach">1</property>
                    <property name="top_attach">2</property>
                  </packing>
                </child>
              </object>
            </child>
          </object>
        </child>
      </object>
    </child>
  </template>
  <object class="GtkAdjustment" id="soup_max_connections_adjustment">
    <property name="lower">1</property>
    <property name="upper">10</property>
    <property name="value">4</property>
    <property name="step_increment">1</property>
    <property name="page_increment">2</property>
  </object>
</interface>

A  => data/ui/hal-profile.ui +216 -0
@@ 1,216 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
  <requires lib="gtk+" version="3.20"/>
  <template class="HalProfile" parent="GtkStack">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <child>
      <object class="GtkLabel">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="margin_top">10</property>
        <property name="margin_bottom">10</property>
        <property name="label" translatable="yes">Invalid Harvest access token or contact email detected. Go to the settings to set them.</property>
        <property name="justify">center</property>
        <property name="wrap">True</property>
      </object>
      <packing>
        <property name="name">harvest-api-access-token</property>
        <property name="title" translatable="yes">Harvest API Access Token</property>
      </packing>
    </child>
    <child>
      <object class="GtkLabel">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="margin_top">10</property>
        <property name="margin_bottom">10</property>
        <property name="label" translatable="yes">Unable to connect to Harvest.</property>
        <property name="justify">center</property>
        <property name="wrap">True</property>
      </object>
      <packing>
        <property name="name">no-connection</property>
        <property name="title" translatable="yes">No Connection</property>
        <property name="position">1</property>
      </packing>
    </child>
    <child>
      <object class="GtkGrid">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="margin_left">15</property>
        <property name="margin_right">15</property>
        <property name="margin_top">15</property>
        <property name="margin_bottom">15</property>
        <property name="row_spacing">20</property>
        <property name="column_spacing">50</property>
        <child>
          <object class="GtkImage">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="halign">end</property>
            <property name="valign">center</property>
            <property name="hexpand">True</property>
            <property name="vexpand">True</property>
            <property name="pixel_size">175</property>
            <property name="icon_name">user-info-symbolic</property>
            <property name="icon_size">6</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">0</property>
            <property name="height">2</property>
          </packing>
        </child>
        <child>
          <object class="GtkGrid">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="halign">start</property>
            <property name="valign">start</property>
            <property name="hexpand">True</property>
            <property name="column_spacing">5</property>
            <child>
              <object class="GtkLabel">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">Roles:</property>
                <property name="xalign">0</property>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkLabel" id="roles">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">Founder, CEO</property>
                <property name="xalign">0</property>
              </object>
              <packing>
                <property name="left_attach">1</property>
                <property name="top_attach">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkLabel">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">Timezone:</property>
                <property name="xalign">0</property>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkLabel" id="timezone">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">Central Standard Time</property>
                <property name="xalign">0</property>
              </object>
              <packing>
                <property name="left_attach">1</property>
                <property name="top_attach">1</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkGrid">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="halign">start</property>
            <property name="valign">end</property>
            <property name="hexpand">True</property>
            <property name="row_spacing">3</property>
            <property name="column_spacing">5</property>
            <child>
              <object class="GtkLabel" id="name">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">Tristan Partin</property>
                <property name="xalign">0</property>
                <attributes>
                  <attribute name="scale" value="1.5"/>
                </attributes>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">0</property>
                <property name="width">2</property>
              </packing>
            </child>
            <child>
              <object class="GtkImage">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="halign">start</property>
                <property name="icon_name">mail-unread-symbolic</property>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkImage">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="halign">start</property>
                <property name="icon_name">phone-symbolic</property>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">2</property>
              </packing>
            </child>
            <child>
              <object class="GtkLabel" id="email">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">tristan.partin@gmail.com</property>
                <property name="xalign">0</property>
              </object>
              <packing>
                <property name="left_attach">1</property>
                <property name="top_attach">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkLabel" id="phone">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">281-300-9395</property>
                <property name="xalign">0</property>
              </object>
              <packing>
                <property name="left_attach">1</property>
                <property name="top_attach">2</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">0</property>
          </packing>
        </child>
      </object>
      <packing>
        <property name="name">profile</property>
        <property name="title" translatable="yes">Profile</property>
        <property name="position">2</property>
      </packing>
    </child>
  </template>
</interface>

A  => data/ui/hal-time-entry.ui +153 -0
@@ 1,153 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
  <requires lib="gtk+" version="3.20"/>
  <template class="HalTimeEntry" parent="GtkGrid">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="halign">start</property>
    <property name="valign">center</property>
    <property name="margin_left">5</property>
    <property name="margin_right">5</property>
    <property name="margin_top">5</property>
    <property name="margin_bottom">5</property>
    <property name="row_spacing">3</property>
    <property name="column_spacing">10</property>
    <child>
      <object class="GtkLabel" id="description">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="label" translatable="yes">I did a lot of stuff for them. It was cool. Had a good time.</property>
        <property name="wrap">True</property>
        <property name="xalign">0</property>
      </object>
      <packing>
        <property name="left_attach">2</property>
        <property name="top_attach">2</property>
      </packing>
    </child>
    <child>
      <object class="GtkLabel" id="time">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="label" translatable="yes">0:00</property>
        <property name="width_chars">4</property>
        <attributes>
          <attribute name="scale" value="1.2"/>
        </attributes>
      </object>
      <packing>
        <property name="left_attach">1</property>
        <property name="top_attach">0</property>
        <property name="height">3</property>
      </packing>
    </child>
    <child>
      <object class="GtkRevealer" id="billable_revealer">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="transition_type">crossfade</property>
        <child>
          <object class="GtkImage">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="icon_name">starred-symbolic</property>
          </object>
        </child>
      </object>
      <packing>
        <property name="left_attach">0</property>
        <property name="top_attach">0</property>
        <property name="height">3</property>
      </packing>
    </child>
    <child>
      <object class="GtkLabel" id="project">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="label" translatable="yes">Graph Development</property>
        <property name="wrap">True</property>
        <property name="xalign">0</property>
        <attributes>
          <attribute name="weight" value="medium"/>
          <attribute name="scale" value="1.05"/>
        </attributes>
      </object>
      <packing>
        <property name="left_attach">2</property>
        <property name="top_attach">1</property>
      </packing>
    </child>
    <child>
      <object class="GtkLabel" id="client">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="halign">start</property>
        <property name="label" translatable="yes">Optum</property>
        <property name="wrap">True</property>
        <property name="xalign">0</property>
        <attributes>
          <attribute name="weight" value="bold"/>
          <attribute name="scale" value="1.2"/>
        </attributes>
      </object>
      <packing>
        <property name="left_attach">2</property>
        <property name="top_attach">0</property>
      </packing>
    </child>
    <child>
      <object class="GtkStack" id="status_stack">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <child>
          <object class="GtkButton" id="start_button">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="valign">center</property>
            <property name="action_name">app.time-entry-start</property>
            <signal name="clicked" handler="on_status_button_clicked" object="HalTimeEntry" swapped="no"/>
            <child>
              <object class="GtkImage">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="icon_name">media-playback-start-symbolic</property>
              </object>
            </child>
          </object>
          <packing>
            <property name="name">start</property>
            <property name="title" translatable="yes">Start</property>
          </packing>
        </child>
        <child>
          <object class="GtkButton" id="stop_button">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="valign">center</property>
            <property name="action_name">app.time-entry-stop</property>
            <child>
              <object class="GtkImage">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="icon_name">media-playback-stop-symbolic</property>
              </object>
            </child>
          </object>
          <packing>
            <property name="name">stop</property>
            <property name="title" translatable="yes">Stop</property>
            <property name="position">1</property>
          </packing>
        </child>
      </object>
      <packing>
        <property name="left_attach">3</property>
        <property name="top_attach">0</property>
        <property name="height">3</property>
      </packing>
    </child>
  </template>
</interface>

A  => data/ui/hal-time-tracker.ui +496 -0
@@ 1,496 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 

Copyright (C) 2019

This file is part of Harvest Almanac.

Harvest Almanac is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Harvest Almanac is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Harvest Almanac.  If not, see <http://www.gnu.org/licenses/>.

Author: Tristan Partin

-->
<interface domain="harvest-almanac">
  <requires lib="gtk+" version="3.20"/>
  <requires lib="libhandy" version="0.0"/>
  <!-- interface-license-type gplv3 -->
  <!-- interface-name Harvest Almanac -->
  <!-- interface-description Harvest client for Linux -->
  <!-- interface-copyright 2019 -->
  <!-- interface-authors Tristan Partin -->
  <template class="HalTimeTracker" parent="GtkBox">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="margin_left">10</property>
    <property name="margin_right">10</property>
    <property name="margin_top">10</property>
    <property name="margin_bottom">10</property>
    <property name="orientation">vertical</property>
    <child>
      <object class="GtkButtonBox">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="halign">center</property>
        <property name="layout_style">start</property>
        <child>
          <object class="GtkButton" id="monday_button">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <signal name="clicked" handler="on_monday_button_clicked" object="day_stack" swapped="no"/>
            <child>
              <object class="GtkBox">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="orientation">vertical</property>
                <child>
                  <object class="GtkLabel">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="label" translatable="yes">MON</property>
                    <attributes>
                      <attribute name="weight" value="semibold"/>
                    </attributes>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">True</property>
                    <property name="position">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkLabel" id="monday_time">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="label" translatable="yes">0.00</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">True</property>
                    <property name="position">1</property>
                  </packing>
                </child>
              </object>
            </child>
          </object>
          <packing>
            <property name="expand">True</property>
            <property name="fill">True</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkButton" id="tuesday_button">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <signal name="clicked" handler="on_tuesday_button_clicked" object="day_stack" swapped="no"/>
            <child>
              <object class="GtkBox">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="orientation">vertical</property>
                <child>
                  <object class="GtkLabel">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="label" translatable="yes">TUE</property>
                    <attributes>
                      <attribute name="weight" value="semibold"/>
                    </attributes>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">True</property>
                    <property name="position">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkLabel" id="tuesday_time">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="label" translatable="yes">0.00</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">True</property>
                    <property name="position">1</property>
                  </packing>
                </child>
              </object>
            </child>
          </object>
          <packing>
            <property name="expand">True</property>
            <property name="fill">True</property>
            <property name="position">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkButton" id="wednesday_button">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <signal name="clicked" handler="on_wednesday_button_clicked" object="day_stack" swapped="no"/>
            <child>
              <object class="GtkBox">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="orientation">vertical</property>
                <child>
                  <object class="GtkLabel">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="label" translatable="yes">WED</property>
                    <attributes>
                      <attribute name="weight" value="semibold"/>
                    </attributes>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">True</property>
                    <property name="position">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkLabel" id="wednesday_time">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="label" translatable="yes">0.00</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">True</property>
                    <property name="position">1</property>
                  </packing>
                </child>
              </object>
            </child>
          </object>
          <packing>
            <property name="expand">True</property>
            <property name="fill">True</property>
            <property name="position">2</property>
          </packing>
        </child>
        <child>
          <object class="GtkButton" id="thursday_button">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <signal name="clicked" handler="on_thursday_button_clicked" object="day_stack" swapped="no"/>
            <child>
              <object class="GtkBox">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="orientation">vertical</property>
                <child>
                  <object class="GtkLabel">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="label" translatable="yes">THU</property>
                    <attributes>
                      <attribute name="weight" value="semibold"/>
                    </attributes>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">True</property>
                    <property name="position">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkLabel" id="thursday_time">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="label" translatable="yes">0.00</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">True</property>
                    <property name="position">1</property>
                  </packing>
                </child>
              </object>
            </child>
          </object>
          <packing>
            <property name="expand">True</property>
            <property name="fill">True</property>
            <property name="position">3</property>
          </packing>
        </child>
        <child>
          <object class="GtkButton" id="friday_button">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <signal name="clicked" handler="on_friday_button_clicked" object="day_stack" swapped="no"/>
            <child>
              <object class="GtkBox">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="orientation">vertical</property>
                <child>
                  <object class="GtkLabel">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="label" translatable="yes">FRI</property>
                    <attributes>
                      <attribute name="weight" value="semibold"/>
                    </attributes>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">True</property>
                    <property name="position">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkLabel" id="friday_time">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="label" translatable="yes">0.00</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">True</property>
                    <property name="position">1</property>
                  </packing>
                </child>
              </object>
            </child>
          </object>
          <packing>
            <property name="expand">True</property>
            <property name="fill">True</property>
            <property name="position">4</property>
          </packing>
        </child>
        <child>
          <object class="GtkButton" id="saturday_button">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <signal name="clicked" handler="on_saturday_button_clicked" object="day_stack" swapped="no"/>
            <child>
              <object class="GtkBox">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="orientation">vertical</property>
                <child>
                  <object class="GtkLabel">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="label" translatable="yes">SAT</property>
                    <attributes>
                      <attribute name="weight" value="semibold"/>
                    </attributes>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">True</property>
                    <property name="position">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkLabel" id="saturday_time">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="label" translatable="yes">0.00</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">True</property>
                    <property name="position">1</property>
                  </packing>
                </child>
              </object>
            </child>
          </object>
          <packing>
            <property name="expand">True</property>
            <property name="fill">True</property>
            <property name="position">5</property>
          </packing>
        </child>
        <child>
          <object class="GtkButton" id="sunday_button">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <signal name="clicked" handler="on_sunday_button_clicked" object="day_stack" swapped="no"/>
            <child>
              <object class="GtkBox">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="orientation">vertical</property>
                <child>
                  <object class="GtkLabel">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="label" translatable="yes">SUN</property>
                    <attributes>
                      <attribute name="weight" value="semibold"/>
                    </attributes>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">True</property>
                    <property name="position">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkLabel" id="sunday_time">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="label" translatable="yes">0.00</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">True</property>
                    <property name="pack_type">end</property>
                    <property name="position">1</property>
                  </packing>
                </child>
              </object>
            </child>
          </object>
          <packing>
            <property name="expand">True</property>
            <property name="fill">True</property>
            <property name="position">6</property>
          </packing>
        </child>
        <style>
          <class name="linked"/>
        </style>
      </object>
      <packing>
        <property name="expand">False</property>
        <property name="fill">True</property>
        <property name="position">0</property>
      </packing>
    </child>
    <child>
      <object class="GtkScrolledWindow">
        <property name="visible">True</property>
        <property name="can_focus">True</property>
        <property name="margin_top">10</property>
        <child>
          <object class="GtkViewport">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <child>
              <object class="HdyColumn">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="maximum_width">500</property>
                <property name="linear_growth_width">500</property>
                <child>
                  <object class="GtkStack" id="day_stack">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="transition_type">slide-left-right</property>
                    <child>
                      <object class="GtkListBox" id="monday_time_entries">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                      </object>
                      <packing>
                        <property name="name">monday</property>
                        <property name="title" translatable="yes">Monday</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkListBox" id="tuesday_time_entries">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                      </object>
                      <packing>
                        <property name="name">tuesday</property>
                        <property name="title" translatable="yes">Tuesday</property>
                        <property name="position">1</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkListBox" id="wednesday_time_entries">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                      </object>
                      <packing>
                        <property name="name">wednesday</property>
                        <property name="title" translatable="yes">Wednesday</property>
                        <property name="position">2</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkListBox" id="thursday_time_entries">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                      </object>
                      <packing>
                        <property name="name">thursday</property>
                        <property name="title" translatable="yes">Thursday</property>
                        <property name="position">3</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkListBox" id="friday_time_entries">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                      </object>
                      <packing>
                        <property name="name">friday</property>
                        <property name="title" translatable="yes">Friday</property>
                        <property name="position">4</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkListBox" id="saturday_time_entries">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                      </object>
                      <packing>
                        <property name="name">saturday</property>
                        <property name="title" translatable="yes">Saturday</property>
                        <property name="position">5</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkListBox" id="sunday_time_entries">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                      </object>
                      <packing>
                        <property name="name">sunday</property>
                        <property name="title" translatable="yes">Sunday</property>
                        <property name="position">6</property>
                      </packing>
                    </child>
                  </object>
                </child>
              </object>
            </child>
          </object>
        </child>
      </object>
      <packing>
        <property name="expand">True</property>
        <property name="fill">True</property>
        <property name="position">1</property>
      </packing>
    </child>
  </template>
</interface>

A  => data/ui/hal-window.ui +154 -0
@@ 1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface>
  <requires lib="gtk+" version="3.20"/>
  <requires lib="libhandy" version="0.0"/>
  <object class="GtkPopoverMenu" id="actions_popover">
    <property name="can_focus">False</property>
    <child>
      <object class="GtkBox">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="margin_left">3</property>
        <property name="margin_right">3</property>
        <property name="margin_top">3</property>
        <property name="margin_bottom">3</property>
        <property name="orientation">vertical</property>
        <child>
          <object class="GtkModelButton">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="action_name">app.preferences</property>
            <property name="text" translatable="yes">Preferences</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkSeparator">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkModelButton">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="action_name">app.about</property>
            <property name="text" translatable="yes">About</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">2</property>
          </packing>
        </child>
      </object>
      <packing>
        <property name="submenu">main</property>
        <property name="position">1</property>
      </packing>
    </child>
  </object>
  <template class="HalWindow" parent="GtkApplicationWindow">
    <property name="can_focus">False</property>
    <child>
      <object class="GtkBox">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="orientation">vertical</property>
        <child>
          <object class="GtkStack" id="function_stack">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="transition_type">slide-left-right</property>
          </object>
          <packing>
            <property name="expand">True</property>
            <property name="fill">True</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="HdyViewSwitcherBar" id="function_switcher_bar">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="stack">function_stack</property>
            <property name="reveal">True</property>
          </object>
        </child>
      </object>
    </child>
    <child type="titlebar">
      <object class="HdyHeaderBar">
        <property name="visible">True</property>
        <property name="centering_policy">strict</property>
        <property name="can_focus">False</property>
        <property name="show_close_button">True</property>
        <property name="title">Harvest Almanac</property>
        <child type="title">
          <object class="HdySqueezer" id="function_squeezer">
            <property name="visible">True</property>
            <property name="transition-type">crossfade</property>
            <child>
              <object class="HdyViewSwitcher" id="function_wide_switcher">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="halign">center</property>
                <property name="policy">wide</property>
                <property name="stack">function_stack</property>
              </object>
            </child>
            <child>
              <object class="HdyViewSwitcher" id="function_narrow_switcher">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="halign">center</property>
                <property name="policy">narrow</property>
                <property name="stack">function_stack</property>
              </object>
            </child>
            <child>
              <object class="GtkLabel" id="title_label">
                <property name="visible">True</property>
                <property name="halign">center</property>
                <property name="label">Harvest Almanac</property>
                <style>
                  <class name="title"/>
                </style>
              </object>
            </child>
          </object>
        </child>
        <child>
          <object class="GtkMenuButton">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="popover">actions_popover</property>
            <child>
              <object class="GtkImage">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="icon_name">open-menu-symbolic</property>
              </object>
            </child>
          </object>
          <packing>
            <property name="pack_type">end</property>
          </packing>
        </child>
      </object>
    </child>
  </template>
</interface>

A  => dist/flatpak/io.partin.tristan.HarvestAlmanac.json +98 -0
@@ 1,98 @@
{
	"app-id": "io.partin.tristan.HarvestAlmanac",
	"runtime": "org.gnome.Platform",
	"runtime-version": "3.34",
	"sdk": "org.gnome.Sdk",
	"command": "harvest-almanac",
	"finish-args": [
		"--share=network",
		"--share=ipc",
		"--socket=x11",
		"--socket=wayland",
		"--filesystem=xdg-run/dconf",
		"--filesystem=~/.config/dconf:ro",
		"--talk-name=ca.desrt.dconf",
		"--env=DCONF_USER_CONFIG_DIR=.config/dconf"
	],
	"build-options": {
		"cflags": "-O3"
	},
	"cleanup": [
		"/include",
		"/lib/pkgconfig",
		"/man",
		"/share/doc",
		"/share/gtk-doc",
		"/share/man",
		"/share/pkgconfig",
		"*.la",
		"*.a"
	],
	"modules": [
		{
			"name": "libhandy",
			"builddir": true,
			"buildsystem": "meson",
			"config-opts": [
				"-Dtests=false",
				"-Dvapi=false",
				"-Dexamples=false"
			],
			"sources": [
				{
					"type": "archive",
					"url": "https://source.puri.sm/Librem5/libhandy/-/archive/v0.0.11/libhandy-v0.0.11.tar.gz",
					"sha256": "c7e7b51203d9221c50b1a38ba81e0aefb5ab906c55e85b6ca2d0501e907e077d"
				}
			]
		},
		{
			"name": "harvest-almanac",
			"builddir": true,
			"buildsystem": "meson",
			"config-opts": [
				"-Dbuildtype=release"
			],
			"sources": [
				{
					"type": "git",
					"url": "https://git.sr.ht/~tristan957/harvest-almanac"
				}
			]
		},
		{
			"name": "libsoup",
			"builddir": true,
			"buildsystem": "meson",
			"config-opts": [
				"-Dtests=false",
				"-Dvapi=false",
				"-Dintrospection=false"
			],
			"sources": [
				{
					"type": "archive",
					"url": "https://gitlab.gnome.org/GNOME/libsoup/-/archive/2.67.90/libsoup-2.67.90.tar.gz",
					"sha256": "6d27bf210a800d231cf91ceafb85f9d4ac7fa6bc0333434278a5a23f8cd0b230"
				}
			]
		},
		{
			"name": "libsecret",
			"builddir": true,
			"buildsystem": "meson",
			"config-opts": [
				"-Dgtk_doc=false",
				"-Dvapi=false",
				"-Dman=false"
			],
			"sources": [
				{
					"type": "archive",
					"url": "https://gitlab.gnome.org/GNOME/libsecret/-/archive/0.18.8/libsecret-0.18.8.tar.gz",
					"sha256": "33ee5dfd3556931b81d47111890c8b9c51093b4ced18e0e87f51c1769e24d43c"
				}
			]
		}
	]
}

A  => dist/snap/snapcraft.yaml +39 -0
@@ 1,39 @@
name: harvest-almanac
title: Harvest Almanac
version: "1.0.0"
summary: Harvest client for Linux
description: |
  Harvest client for Linux
license: GPL-3.0-only
confinement: devmode
grade: devel
base: core18

apps:
  harvest-almanac:
    command: harvest-almanac

parts:
  libhandy:
    plugin: meson
    meson-parameters:
      - -Dvapi=false
      - -Dtest=false
    source-type: git
    source: https://source.puri.sm/Librem5/libhandy
    build-packages:
      - gcc
      - libgtk-3-dev
  harvest-almanac:
    after: [libhandy]
    plugin: meson
    meson-parameters:
      - -Dbuildtype=release
      - -Dlibhandy:glade_catalog=disabled
    source-type: git
    source: https://git.sr.ht/~tristan957/harvest-almanac
    build-packages:
      - gcc
      - libjson-glib-dev
      - libcurl4-openssl-dev
      - libgtk-3-dev

A  => harvest-almanac/hal-application.c +177 -0
@@ 1,177 @@
#include "config.h"

#define G_LOG_DOMAIN "HalApplication"

#include <string.h>

#include <glib-object.h>
#include <gtk/gtk.h>
#include <harvest.h>
#include <libsoup/soup.h>

#include "hal-application.h"
#include "hal-preferences-window.h"
#include "hal-resources.h"
#include "hal-time-entry.h"
#include "hal-window.h"

#define HAL_MAX_CONNS_PER_HOST 4

struct _HalApplication
{
	GtkApplication parent_instance;

	GSettings *settings;
	HarvestApiClient *client;
};

typedef struct HalApplicationPrivate
{
	HalWindow *main_window;
} HalApplicationPrivate;

G_DEFINE_TYPE_WITH_PRIVATE(HalApplication, hal_application, GTK_TYPE_APPLICATION)

static void
hal_application_activate(GApplication *app)
{
	HalApplication *self		= HAL_APPLICATION(app);
	HalApplicationPrivate *priv = hal_application_get_instance_private(HAL_APPLICATION(self));

	if (priv->main_window == NULL) {
		priv->main_window = hal_window_new(app);
	}

	g_object_set(gtk_settings_get_default(), "gtk-application-prefer-dark-theme",
		g_settings_get_boolean(self->settings, "prefer-dark-theme"), NULL);

	gtk_window_present(GTK_WINDOW(priv->main_window));
}

static void
hal_application_about(
	G_GNUC_UNUSED GSimpleAction *action, G_GNUC_UNUSED GVariant *param, gpointer data)
{
	static const char *authors[] = {"Tristan Partin"};

	HalApplication *self		= HAL_APPLICATION(data);
	HalApplicationPrivate *priv = hal_application_get_instance_private(self);

	gtk_show_about_dialog(GTK_WINDOW(priv->main_window), "program-name", PACKAGE_NAME, "version",
		PACKAGE_VERSION, "license-type", PACKAGE_LICENSE, "website", PACKAGE_WEBSITE,
		"website-label", PACKAGE_WEBSITE_LABEL, "authors", authors, "logo-icon-name", "trophy-gold",
		NULL);
}

static void
hal_application_preferences(
	G_GNUC_UNUSED GSimpleAction *action, G_GNUC_UNUSED GVariant *param, gpointer data)
{
	HalApplication *self		= HAL_APPLICATION(data);
	HalApplicationPrivate *priv = hal_application_get_instance_private(self);

	HalPreferencesWindow *preferences_window
		= hal_preferences_window_new(GTK_WINDOW(priv->main_window), self->settings);
	gtk_window_present(GTK_WINDOW(preferences_window));
}

static void
hal_application_time_entry_start(
	G_GNUC_UNUSED GSimpleAction *action, GVariant *param, gpointer data)
{
	const guint64 address			  = g_variant_get_uint64(param);
	G_GNUC_UNUSED HalTimeEntry *entry = HAL_TIME_ENTRY((HalTimeEntry *) address);

	g_autoptr(GNotification) notification = g_notification_new("Harvest Almanac");
	g_notification_set_body(notification, "Client -- Project timer started");
	g_notification_add_button_with_target(
		notification, "Stop Timer", "app.time-entry-stop", "t", address, NULL);
	g_application_send_notification(G_APPLICATION(data), "time-entry", notification);
}

static void
hal_application_time_entry_stop(G_GNUC_UNUSED GSimpleAction *action, GVariant *param, gpointer data)
{
	const guint64 address = g_variant_get_uint64(param);
	HalTimeEntry *entry   = HAL_TIME_ENTRY((HalTimeEntry *) address);

	hal_time_entry_stop(entry);
	g_application_withdraw_notification(G_APPLICATION(data), "time-entry");
}

static void
hal_application_create_client(
	G_GNUC_UNUSED GSimpleAction *action, G_GNUC_UNUSED GVariant *param, gpointer data)
{
	HalApplication *self = HAL_APPLICATION(data);

	g_autofree const char *harvest_api_access_token
		= g_settings_get_string(self->settings, "harvest-api-access-token");
	g_autofree const char *harvest_api_contact_email
		= g_settings_get_string(self->settings, "harvest-api-contact-email");
	const unsigned int harvest_account_id
		= g_settings_get_uint(self->settings, "harvest-account-id");
	const unsigned int logger_level = g_settings_get_uint(self->settings, "soup-logger-level");

	SoupLogger *logger = soup_logger_new(logger_level, -1);

	SoupSession *session = soup_session_new_with_options(SOUP_SESSION_MAX_CONNS,
		g_settings_get_uint(self->settings, "soup-max-conns"), SOUP_SESSION_USER_AGENT,
		"Harvest Almanac (tristan dot partin at gmail dot com)", SOUP_SESSION_ADD_FEATURE_BY_TYPE,
		SOUP_TYPE_CONTENT_SNIFFER, SOUP_SESSION_ADD_FEATURE, SOUP_SESSION_FEATURE(logger), NULL);

	self->client = harvest_api_client_v2_new(session, harvest_api_access_token, harvest_account_id);
}

static void
hal_application_startup(GApplication *self)
{
	g_resources_register(hal_get_resource());
	g_application_set_resource_base_path(self, "/io/partin/tristan/HarvestAlmanac");

	G_APPLICATION_CLASS(hal_application_parent_class)->startup(self);
}

static void
hal_application_finalize(GObject *obj)
{
	HalApplication *self = HAL_APPLICATION(obj);

	g_clear_object(&self->settings);

	G_OBJECT_CLASS(hal_application_parent_class)->finalize(obj);
}

static void
hal_application_class_init(HalApplicationClass *klass)
{
	GObjectClass *obj_class		 = G_OBJECT_CLASS(klass);
	GApplicationClass *app_class = G_APPLICATION_CLASS(klass);

	obj_class->finalize = hal_application_finalize;
	app_class->activate = hal_application_activate;
	app_class->startup  = hal_application_startup;
}

static const GActionEntry app_entries[] = {{.name = "about", .activate = hal_application_about},
	{.name = "preferences", .activate = hal_application_preferences},
	{.name				= "time-entry-start",
		.activate		= hal_application_time_entry_start,
		.parameter_type = "t"},
	{.name = "time-entry-stop", .activate = hal_application_time_entry_stop, .parameter_type = "t"},
	{.name = "check-settings", .activate = hal_application_create_client}};

static void
hal_application_init(HalApplication *self)
{
	self->settings = g_settings_new("io.partin.tristan.HarvestAlmanac");

	g_action_map_add_action_entries(
		G_ACTION_MAP(self), app_entries, G_N_ELEMENTS(app_entries), self);
}

HalApplication *
hal_application_new(const char *id)
{
	return g_object_new(HAL_TYPE_APPLICATION, "application-id", id, NULL);
}

A  => harvest-almanac/hal-application.h +12 -0
@@ 1,12 @@
#pragma once

#include <gtk/gtk.h>

#define HAL_TYPE_APPLICATION (hal_application_get_type())
G_DECLARE_FINAL_TYPE(HalApplication, hal_application, HAL, APPLICATION, GtkApplication)

G_BEGIN_DECLS

HalApplication *hal_application_new(const char *id) G_GNUC_WARN_UNUSED_RESULT G_GNUC_CONST;

G_END_DECLS

A  => harvest-almanac/hal-preferences-window.c +142 -0
@@ 1,142 @@
#include "config.h"

#define G_LOG_DOMAIN "HalPreferencesWindow"

#include <glib-object.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <handy.h>
#include <libsecret/secret.h>

#include "hal-preferences-window.h"

struct _HalPreferencesWindow
{
	HdyPreferencesWindow parent_instance;

	GSettings *settings;
};

typedef struct HalPreferencesWindowPrivate
{
	GtkEntry *harvest_api_access_token_entry;
	GtkEntry *harvest_api_contact_email;
	GtkSwitch *prefer_dark_theme_switch;
	GtkSpinButton *soup_max_connections_spin;
	GtkComboBoxText *soup_logger_level_combo;
} HalPreferencesWindowPrivate;

G_DEFINE_TYPE_WITH_PRIVATE(
	HalPreferencesWindow, hal_preferences_window, HDY_TYPE_PREFERENCES_WINDOW)

enum HalPreferencesWindowProps
{
	PROP_0,
	PROP_SETTINGS,
	N_PROPS,
};

static GParamSpec *obj_properties[N_PROPS];

const SecretSchema *
hal_get_secret_schema(void)
{
	static const SecretSchema *hal_schema = {"io.partin.tristan.HarvestAlmanac", SECRET_SCHEMA_NONE,
		{{"email", SECRET_SCHEMA_ATTRIBUTE_STRING}}};

	return &hal_schema;
}

static void
on_prefer_dark_theme_switch_activate(
	GtkSwitch *widget, G_GNUC_UNUSED GParamSpec *pspec, gpointer user_data)
{
	HalPreferencesWindow *self = HAL_PREFERENCES_WINDOW(user_data);

	g_settings_set_boolean(self->settings, "prefer-dark-theme", gtk_switch_get_active(widget));
}

static void
hal_preferences_window_constructed(GObject *obj)
{
	HalPreferencesWindow *self		  = HAL_PREFERENCES_WINDOW(obj);
	HalPreferencesWindowPrivate *priv = hal_preferences_window_get_instance_private(self);

	g_autofree const char *key = g_settings_get_string(self->settings, "harvest-api-access-token");

	gtk_entry_set_text(priv->harvest_api_access_token_entry, key);
	gtk_switch_set_active(priv->prefer_dark_theme_switch,
		g_settings_get_boolean(self->settings, "prefer-dark-theme"));
}

static void
hal_preferences_window_finalize(GObject *obj)
{
	HalPreferencesWindow *self = HAL_PREFERENCES_WINDOW(obj);

	g_object_unref(self->settings);

	G_OBJECT_CLASS(hal_preferences_window_parent_class)->finalize(obj);
}

static void
hal_preferences_window_set_property(
	GObject *obj, guint prop_id, const GValue *val, GParamSpec *pspec)
{
	HalPreferencesWindow *self = HAL_PREFERENCES_WINDOW(obj);

	switch (prop_id) {
	case PROP_SETTINGS:
		if (self->settings != NULL) {
			g_object_unref(self->settings);
		}
		self->settings = g_value_dup_object(val);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
	}
}

static void
hal_preferences_window_class_init(HalPreferencesWindowClass *klass)
{
	GObjectClass *obj_class   = G_OBJECT_CLASS(klass);
	GtkWidgetClass *wid_class = GTK_WIDGET_CLASS(klass);

	obj_class->constructed  = hal_preferences_window_constructed;
	obj_class->finalize		= hal_preferences_window_finalize;
	obj_class->set_property = hal_preferences_window_set_property;

	obj_properties[PROP_SETTINGS]
		= g_param_spec_object("settings", _("Settings"), _("Application settings"), G_TYPE_SETTINGS,
			G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);

	g_object_class_install_properties(obj_class, N_PROPS, obj_properties);

	gtk_widget_class_set_template_from_resource(
		wid_class, "/io/partin/tristan/HarvestAlmanac/ui/hal-preferences-window.ui");
	gtk_widget_class_bind_template_child_private(
		wid_class, HalPreferencesWindow, harvest_api_access_token_entry);
	gtk_widget_class_bind_template_child_private(
		wid_class, HalPreferencesWindow, harvest_api_contact_email);
	gtk_widget_class_bind_template_child_private(
		wid_class, HalPreferencesWindow, prefer_dark_theme_switch);
	gtk_widget_class_bind_template_child_private(
		wid_class, HalPreferencesWindow, soup_max_connections_spin);
	gtk_widget_class_bind_template_child_private(
		wid_class, HalPreferencesWindow, soup_logger_level_combo);
	gtk_widget_class_bind_template_callback(wid_class, on_prefer_dark_theme_switch_activate);
}

static void
hal_preferences_window_init(HalPreferencesWindow *self)
{
	gtk_widget_init_template(GTK_WIDGET(self));
}

HalPreferencesWindow *
hal_preferences_window_new(GtkWindow *parent, GSettings *settings)
{
	return g_object_new(
		HAL_TYPE_PREFERENCES_WINDOW, "transient-for", parent, "settings", settings, NULL);
}

A  => harvest-almanac/hal-preferences-window.h +20 -0
@@ 1,20 @@
#pragma once

#include <glib-object.h>
#include <gtk/gtk.h>
#include <handy.h>
#include <libsecret/secret.h>

#define HAL_SECRET_SCHEMA (hal_get_secret_schema())
#define HAL_TYPE_PREFERENCES_WINDOW (hal_preferences_window_get_type())
G_DECLARE_FINAL_TYPE(
	HalPreferencesWindow, hal_preferences_window, HAL, PREFERENCES_WINDOW, HdyPreferencesWindow)

G_BEGIN_DECLS

const SecretSchema *hal_get_secret_schema(void) G_GNUC_CONST;

HalPreferencesWindow *hal_preferences_window_new(
	GtkWindow *parent, GSettings *settings) G_GNUC_WARN_UNUSED_RESULT;

G_END_DECLS

A  => harvest-almanac/hal-profile.c +95 -0
@@ 1,95 @@
#include "config.h"

#define G_LOG_DOMAIN "HalProfile"

#include <glib-object.h>
#include <gtk/gtk.h>

#include "hal-profile.h"

struct _HalProfile
{
	GtkStack parent_instance;
};

typedef struct HalProfilePrivate
{
	GtkLabel *name;
	GtkLabel *email;
	GtkLabel *phone;
	GtkLabel *roles;
	GtkLabel *timezone;
} HalProfilePrivate;

G_DEFINE_TYPE_WITH_PRIVATE(HalProfile, hal_profile, GTK_TYPE_STACK)

enum HalProfileProps
{
	PROP_0,
	PROP_USER,
	N_PROPS
};

G_GNUC_UNUSED static GParamSpec *obj_properties[N_PROPS];

static void
hal_profile_finalize(GObject *self)
{
	G_OBJECT_CLASS(hal_profile_parent_class)->finalize(self);
}

static void
hal_profile_get_property(GObject *obj, guint prop_id, G_GNUC_UNUSED GValue *val, GParamSpec *pspec)
{
	switch (prop_id) {
	case PROP_USER:
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
	}
}

static void
hal_profile_set_property(
	GObject *obj, guint prop_id, G_GNUC_UNUSED const GValue *val, GParamSpec *pspec)
{
	switch (prop_id) {
	case PROP_USER:
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
	}
}

static void
hal_profile_class_init(HalProfileClass *klass)
{
	GObjectClass *obj_class   = G_OBJECT_CLASS(klass);
	GtkWidgetClass *wid_class = GTK_WIDGET_CLASS(klass);

	obj_class->finalize		= hal_profile_finalize;
	obj_class->get_property = hal_profile_get_property;
	obj_class->set_property = hal_profile_set_property;

	// TODO: actually create GParamSpecs

	gtk_widget_class_set_template_from_resource(
		wid_class, "/io/partin/tristan/HarvestAlmanac/ui/hal-profile.ui");
	gtk_widget_class_bind_template_child_private(wid_class, HalProfile, name);
	gtk_widget_class_bind_template_child_private(wid_class, HalProfile, email);
	gtk_widget_class_bind_template_child_private(wid_class, HalProfile, phone);
	gtk_widget_class_bind_template_child_private(wid_class, HalProfile, roles);
	gtk_widget_class_bind_template_child_private(wid_class, HalProfile, timezone);
}

static void
hal_profile_init(HalProfile *self)
{
	gtk_widget_init_template(GTK_WIDGET(self));
}

HalProfile *
hal_profile_new()
{
	return g_object_new(HAL_TYPE_PROFILE, NULL);
}

A  => harvest-almanac/hal-profile.h +13 -0
@@ 1,13 @@
#pragma once

#include <glib-object.h>
#include <gtk/gtk.h>

#define HAL_TYPE_PROFILE (hal_profile_get_type())
G_DECLARE_FINAL_TYPE(HalProfile, hal_profile, HAL, PROFILE, GtkStack)

G_BEGIN_DECLS

HalProfile *hal_profile_new(void) G_GNUC_WARN_UNUSED_RESULT;

G_END_DECLS

A  => harvest-almanac/hal-time-entry.c +184 -0
@@ 1,184 @@
#include "config.h"

#define G_LOG_DOMAIN "HalTimeEntry"

#include <glib-object.h>
#include <gtk/gtk.h>

#include "hal-time-entry.h"

struct _HalTimeEntry
{
	GtkGrid parent_instance;

	gboolean running;
	GTimer *timer;
	GCancellable *cancellable;
};

typedef struct HalTimeEntryPrivate
{
	GtkRevealer *billable_revealer;
	GtkLabel *time;
	GtkLabel *client;
	GtkLabel *project;
	GtkLabel *thursday_time;
	GtkLabel *description;
	GtkStack *status_stack;
	GtkButton *start_button;
	GtkButton *stop_button;
} HalTimeEntryPrivate;

G_DEFINE_TYPE_WITH_PRIVATE(HalTimeEntry, hal_time_entry, GTK_TYPE_GRID)

enum HalTimeEntryProps
{
	PROP_0,
	PROP_ENTRY,
	N_PROPS
};

G_GNUC_UNUSED static GParamSpec *obj_properties[N_PROPS];

static gboolean
update_time_label(gpointer user_data)
{
	HalTimeEntry *self		  = HAL_TIME_ENTRY(user_data);
	HalTimeEntryPrivate *priv = hal_time_entry_get_instance_private(self);

	if (self->cancellable == NULL || g_cancellable_is_cancelled(self->cancellable)) {
		return G_SOURCE_REMOVE;
	}

	const gdouble elapsed	= g_timer_elapsed(self->timer, NULL);
	g_autoptr(GString) label = g_string_new(NULL);
	g_string_printf(label, "%d:%02d", (int) elapsed / 3600, ((int) elapsed % 3600) / 60);
	gtk_label_set_text(priv->time, label->str);

	return G_SOURCE_CONTINUE;
}

static void
on_status_button_clicked(G_GNUC_UNUSED GtkButton *widget, gpointer user_data)
{
	HalTimeEntry *self		  = HAL_TIME_ENTRY(user_data);
	HalTimeEntryPrivate *priv = hal_time_entry_get_instance_private(self);

	if (!self->running) {
		self->running = TRUE;
		g_timer_continue(self->timer);
		gtk_stack_set_visible_child_name(priv->status_stack, "stop");
		g_cancellable_reset(self->cancellable);
		g_timeout_add(500, update_time_label, self);
	} else {
		self->running = FALSE;
		g_timer_stop(self->timer);
		g_cancellable_cancel(self->cancellable);
		gtk_stack_set_visible_child_name(priv->status_stack, "start");
	}
}

static void
hal_time_entry_finalize(GObject *obj)
{
	HalTimeEntry *self = HAL_TIME_ENTRY(obj);

	if (!g_cancellable_is_cancelled(self->cancellable)) {
		g_cancellable_cancel(self->cancellable);
	}

	g_object_unref(self->cancellable);
	g_timer_destroy(self->timer);

	G_OBJECT_CLASS(hal_time_entry_parent_class)->finalize(obj);
}

static void
hal_time_entry_get_property(
	GObject *obj, guint prop_id, G_GNUC_UNUSED GValue *val, GParamSpec *pspec)
{
	switch (prop_id) {
	case PROP_ENTRY:
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
	}
}

static void
hal_time_entry_set_property(
	GObject *obj, guint prop_id, G_GNUC_UNUSED const GValue *val, GParamSpec *pspec)
{
	switch (prop_id) {
	case PROP_ENTRY:
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
	}
}

static void
hal_time_entry_class_init(HalTimeEntryClass *klass)
{
	GObjectClass *obj_class   = G_OBJECT_CLASS(klass);
	GtkWidgetClass *wid_class = GTK_WIDGET_CLASS(klass);

	obj_class->finalize		= hal_time_entry_finalize;
	obj_class->get_property = hal_time_entry_get_property;
	obj_class->set_property = hal_time_entry_set_property;

	// TODO: actually create GParamSpec

	gtk_widget_class_set_template_from_resource(
		wid_class, "/io/partin/tristan/HarvestAlmanac/ui/hal-time-entry.ui");
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeEntry, billable_revealer);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeEntry, time);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeEntry, client);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeEntry, project);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeEntry, description);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeEntry, status_stack);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeEntry, start_button);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeEntry, stop_button);
	gtk_widget_class_bind_template_callback(wid_class, on_status_button_clicked);
}

static void
hal_time_entry_init(HalTimeEntry *self)
{
	HalTimeEntryPrivate *priv = hal_time_entry_get_instance_private(self);

	gtk_widget_init_template(GTK_WIDGET(self));

	gtk_actionable_set_action_target(GTK_ACTIONABLE(priv->start_button), "t", (guint64) self);
	gtk_actionable_set_action_target(GTK_ACTIONABLE(priv->stop_button), "t", (guint64) self);

	self->running = FALSE;
	self->timer   = g_timer_new();
	g_timer_stop(self->timer);
	self->cancellable = g_cancellable_new();
}

HalTimeEntry *
hal_time_entry_new()
{
	return g_object_new(HAL_TYPE_TIME_ENTRY, NULL);
}

gboolean
hal_time_entry_is_running(HalTimeEntry *self)
{
	return self->running;
}

void
hal_time_entry_stop(HalTimeEntry *self)
{
	HalTimeEntryPrivate *priv = hal_time_entry_get_instance_private(self);

	if (self->running && !g_cancellable_is_cancelled(self->cancellable)) {
		self->running = FALSE;
		g_timer_stop(self->timer);
		g_cancellable_cancel(self->cancellable);
		gtk_stack_set_visible_child_name(priv->status_stack, "start");
	}
}

A  => harvest-almanac/hal-time-entry.h +15 -0
@@ 1,15 @@
#pragma once

#include <glib-object.h>
#include <gtk/gtk.h>

#define HAL_TYPE_TIME_ENTRY (hal_time_entry_get_type())
G_DECLARE_FINAL_TYPE(HalTimeEntry, hal_time_entry, HAL, TIME_ENTRY, GtkGrid)

G_BEGIN_DECLS

HalTimeEntry *hal_time_entry_new(void) G_GNUC_WARN_UNUSED_RESULT;
gboolean hal_time_entry_is_running(HalTimeEntry *self);
void hal_time_entry_stop(HalTimeEntry *self);

G_END_DECLS

A  => harvest-almanac/hal-time-tracker.c +199 -0
@@ 1,199 @@
#include "config.h"

#define G_LOG_DOMAIN "HalTimeTracker"

#include <glib-object.h>
#include <gtk/gtk.h>

#include "hal-time-entry.h"
#include "hal-time-tracker.h"

struct _HalTimeTracker
{
	GtkBox parent_instance;
};

typedef struct HalTimeTrackerPrivate
{
	GtkButton *monday_button;
	GtkButton *tuesday_button;
	GtkButton *wednesday_button;
	GtkButton *thursday_button;
	GtkButton *friday_button;
	GtkButton *saturday_button;
	GtkButton *sunday_button;
	GtkLabel *monday_time;
	GtkLabel *tuesday_time;
	GtkLabel *wednesday_time;
	GtkLabel *thursday_time;
	GtkLabel *friday_time;
	GtkLabel *saturday_time;
	GtkLabel *sunday_time;
	GtkListBox *monday_time_entries;
	GtkListBox *tuesday_time_entries;
	GtkListBox *wednesday_time_entries;
	GtkListBox *thursday_time_entries;
	GtkListBox *friday_time_entries;
	GtkListBox *saturday_time_entries;
	GtkListBox *sunday_time_entries;
} HalTimeTrackerPrivate;

G_DEFINE_TYPE_WITH_PRIVATE(HalTimeTracker, hal_time_tracker, GTK_TYPE_BOX)

enum HalTimeTrackerProps
{
	PROP_0,
	PROP_CLIENT,
	PROP_USER,
	N_PROPS
};

G_GNUC_UNUSED static GParamSpec *obj_properties[N_PROPS];

static void
hal_time_tracker_clear_entries(HalTimeTracker *self)
{
	G_GNUC_UNUSED HalTimeTrackerPrivate *priv = hal_time_tracker_get_instance_private(self);
}

static void
on_monday_button_clicked(G_GNUC_UNUSED GtkButton *widget, gpointer user_data)
{
	gtk_stack_set_visible_child_name(GTK_STACK(user_data), "monday");
}

static void
on_tuesday_button_clicked(G_GNUC_UNUSED GtkButton *widget, gpointer user_data)
{
	gtk_stack_set_visible_child_name(GTK_STACK(user_data), "tuesday");
}

static void
on_wednesday_button_clicked(G_GNUC_UNUSED GtkButton *widget, gpointer user_data)
{
	gtk_stack_set_visible_child_name(GTK_STACK(user_data), "wednesday");
}

static void
on_thursday_button_clicked(G_GNUC_UNUSED GtkButton *widget, gpointer user_data)
{
	gtk_stack_set_visible_child_name(GTK_STACK(user_data), "thursday");
}

static void
on_friday_button_clicked(G_GNUC_UNUSED GtkButton *widget, gpointer user_data)
{
	gtk_stack_set_visible_child_name(GTK_STACK(user_data), "friday");
}

static void
on_saturday_button_clicked(G_GNUC_UNUSED GtkButton *widget, gpointer user_data)
{
	gtk_stack_set_visible_child_name(GTK_STACK(user_data), "saturday");
}

static void
on_sunday_button_clicked(G_GNUC_UNUSED GtkButton *widget, gpointer user_data)
{
	gtk_stack_set_visible_child_name(GTK_STACK(user_data), "sunday");
}

static void
hal_time_tracker_finalize(GObject *self)
{
	hal_time_tracker_clear_entries(HAL_TIME_TRACKER(self));

	G_OBJECT_CLASS(hal_time_tracker_parent_class)->finalize(self);
}

static void
hal_time_tracker_get_property(
	GObject *obj, guint prop_id, G_GNUC_UNUSED GValue *val, GParamSpec *pspec)
{
	switch (prop_id) {
	case PROP_CLIENT:
		break;
	case PROP_USER:
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
	}
}

static void
hal_time_tracker_set_property(
	GObject *obj, guint prop_id, G_GNUC_UNUSED const GValue *val, GParamSpec *pspec)
{
	switch (prop_id) {
	case PROP_CLIENT:
		break;
	case PROP_USER:
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
	}
}

static void
hal_time_tracker_class_init(HalTimeTrackerClass *klass)
{
	GObjectClass *obj_class   = G_OBJECT_CLASS(klass);
	GtkWidgetClass *wid_class = GTK_WIDGET_CLASS(klass);

	obj_class->finalize		= hal_time_tracker_finalize;
	obj_class->get_property = hal_time_tracker_get_property;
	obj_class->set_property = hal_time_tracker_set_property;

	gtk_widget_class_set_template_from_resource(
		wid_class, "/io/partin/tristan/HarvestAlmanac/ui/hal-time-tracker.ui");
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, monday_button);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, tuesday_button);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, wednesday_button);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, thursday_button);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, friday_button);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, saturday_button);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, sunday_button);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, monday_time);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, tuesday_time);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, wednesday_time);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, thursday_time);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, friday_time);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, saturday_time);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, sunday_time);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, monday_time_entries);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, tuesday_time_entries);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, wednesday_time_entries);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, thursday_time_entries);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, friday_time_entries);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, saturday_time_entries);
	gtk_widget_class_bind_template_child_private(wid_class, HalTimeTracker, sunday_time_entries);
	gtk_widget_class_bind_template_callback(wid_class, on_monday_button_clicked);
	gtk_widget_class_bind_template_callback(wid_class, on_tuesday_button_clicked);
	gtk_widget_class_bind_template_callback(wid_class, on_wednesday_button_clicked);
	gtk_widget_class_bind_template_callback(wid_class, on_thursday_button_clicked);
	gtk_widget_class_bind_template_callback(wid_class, on_friday_button_clicked);
	gtk_widget_class_bind_template_callback(wid_class, on_saturday_button_clicked);
	gtk_widget_class_bind_template_callback(wid_class, on_sunday_button_clicked);
}

static void
hal_time_tracker_init(HalTimeTracker *self)
{
	HalTimeTrackerPrivate *priv = hal_time_tracker_get_instance_private(self);

	gtk_widget_init_template(GTK_WIDGET(self));

	gtk_list_box_insert(priv->monday_time_entries, GTK_WIDGET(hal_time_entry_new()), -1);
	gtk_list_box_insert(priv->tuesday_time_entries, GTK_WIDGET(hal_time_entry_new()), -1);
	gtk_list_box_insert(priv->wednesday_time_entries, GTK_WIDGET(hal_time_entry_new()), -1);
	gtk_list_box_insert(priv->thursday_time_entries, GTK_WIDGET(hal_time_entry_new()), -1);
	gtk_list_box_insert(priv->friday_time_entries, GTK_WIDGET(hal_time_entry_new()), -1);
	gtk_list_box_insert(priv->saturday_time_entries, GTK_WIDGET(hal_time_entry_new()), -1);
	gtk_list_box_insert(priv->sunday_time_entries, GTK_WIDGET(hal_time_entry_new()), -1);
}

HalTimeTracker *
hal_time_tracker_new()
{
	return g_object_new(HAL_TYPE_TIME_TRACKER, NULL);
}

A  => harvest-almanac/hal-time-tracker.h +13 -0
@@ 1,13 @@
#pragma once

#include <glib-object.h>
#include <gtk/gtk.h>

#define HAL_TYPE_TIME_TRACKER (hal_time_tracker_get_type())
G_DECLARE_FINAL_TYPE(HalTimeTracker, hal_time_tracker, HAL, TIME_TRACKER, GtkBox)

G_BEGIN_DECLS

HalTimeTracker *hal_time_tracker_new(void) G_GNUC_WARN_UNUSED_RESULT;

G_END_DECLS

A  => harvest-almanac/hal-window.c +167 -0
@@ 1,167 @@
#include "config.h"

#define G_LOG_DOMAIN "HalWindow"

#include <glib-object.h>
#include <gtk/gtk.h>
#include <handy.h>

#include "hal-profile.h"
#include "hal-time-tracker.h"
#include "hal-window.h"

struct _HalWindow
{
	GtkApplicationWindow parent_instance;
};

typedef struct HalWindowPrivate
{
	GtkStack *function_stack;
	HdySqueezer *function_squeezer;
	HdyViewSwitcherBar *function_switcher_bar;
	HdyViewSwitcher *function_wide_switcher;
	HdyViewSwitcher *function_narrow_switcher;
	GtkLabel *title_label;
	HalTimeTracker *time_tracker;
	HalProfile *profile;
} HalWindowPrivate;

G_DEFINE_TYPE_WITH_PRIVATE(HalWindow, hal_window, GTK_TYPE_APPLICATION_WINDOW)

static void
hal_window_show_content(
	G_GNUC_UNUSED GSimpleAction *action, G_GNUC_UNUSED GVariant *param, gpointer data)
{
	HalWindow *self		   = HAL_WINDOW(data);
	HalWindowPrivate *priv = hal_window_get_instance_private(self);

	/**
	 * There should probably be a check to make sure the access token is actually
	 * valid using the me endpoint.
	 */

	gtk_stack_set_visible_child_name(GTK_STACK(priv->profile), "profile");
	gtk_widget_set_sensitive(GTK_WIDGET(priv->function_wide_switcher), TRUE);
	gtk_widget_set_sensitive(GTK_WIDGET(priv->function_narrow_switcher), TRUE);
	gtk_widget_set_sensitive(GTK_WIDGET(priv->function_switcher_bar), TRUE);
}

static void
hal_window_hide_content(
	G_GNUC_UNUSED GSimpleAction *action, G_GNUC_UNUSED GVariant *param, gpointer data)
{
	HalWindow *self		   = HAL_WINDOW(data);
	HalWindowPrivate *priv = hal_window_get_instance_private(self);

	gtk_stack_set_visible_child_name(priv->function_stack, "profile");
	gtk_stack_set_visible_child_name(GTK_STACK(priv->profile), "harvest-api-access-token");
	gtk_widget_set_sensitive(GTK_WIDGET(priv->function_wide_switcher), FALSE);
	gtk_widget_set_sensitive(GTK_WIDGET(priv->function_narrow_switcher), FALSE);
	gtk_widget_set_sensitive(GTK_WIDGET(priv->function_switcher_bar), FALSE);
}

static void
hal_window_finalize(GObject *obj)
{
	G_OBJECT_CLASS(hal_window_parent_class)->finalize(obj);
}

static void
hal_window_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
	HalWindow *self		   = HAL_WINDOW(widget);
	HalWindowPrivate *priv = hal_window_get_instance_private(self);

	hdy_squeezer_set_child_enabled(
		priv->function_squeezer, GTK_WIDGET(priv->function_wide_switcher), allocation->width > 600);
	hdy_squeezer_set_child_enabled(priv->function_squeezer,
		GTK_WIDGET(priv->function_narrow_switcher), allocation->width > 400);

	GTK_WIDGET_CLASS(hal_window_parent_class)->size_allocate(widget, allocation);
}

static gboolean
hal_window_is_title_label_visible(
	G_GNUC_UNUSED GBinding *binding, const GValue *from_value, GValue *to_value, gpointer user_data)
{
	g_value_set_boolean(to_value, g_value_get_object(from_value) == user_data);

	return TRUE;
}

static void
hal_window_class_init(HalWindowClass *klass)
{
	GObjectClass *object_class = G_OBJECT_CLASS(klass);
	GtkWidgetClass *wid_class  = GTK_WIDGET_CLASS(klass);

	object_class->finalize = hal_window_finalize;

	wid_class->size_allocate = hal_window_size_allocate;

	gtk_widget_class_set_template_from_resource(
		wid_class, "/io/partin/tristan/HarvestAlmanac/ui/hal-window.ui");
	gtk_widget_class_bind_template_child_private(wid_class, HalWindow, function_stack);
	gtk_widget_class_bind_template_child_private(wid_class, HalWindow, function_squeezer);
	gtk_widget_class_bind_template_child_private(wid_class, HalWindow, function_switcher_bar);
	gtk_widget_class_bind_template_child_private(wid_class, HalWindow, function_wide_switcher);
	gtk_widget_class_bind_template_child_private(wid_class, HalWindow, function_narrow_switcher);
	gtk_widget_class_bind_template_child_private(wid_class, HalWindow, title_label);
}

static const GActionEntry win_entries[]
	= {{.name = "show-content", .activate = hal_window_show_content},
		{.name = "hide-content", .activate = hal_window_hide_content}};

static void
hal_window_init(HalWindow *self)
{
	HalWindowPrivate *priv = hal_window_get_instance_private(self);

	g_action_map_add_action_entries(
		G_ACTION_MAP(self), win_entries, G_N_ELEMENTS(win_entries), self);

	gtk_widget_init_template(GTK_WIDGET(self));

	priv->profile	  = hal_profile_new();
	priv->time_tracker = hal_time_tracker_new();

	gtk_stack_add_titled(priv->function_stack, GTK_WIDGET(priv->profile), "profile", "Profile");
	gtk_stack_add_titled(
		priv->function_stack, GTK_WIDGET(priv->time_tracker), "time-tracker", "Time");
	gtk_container_child_set(GTK_CONTAINER(priv->function_stack), GTK_WIDGET(priv->profile),
		"icon-name", "user-info-symbolic", NULL);
	gtk_container_child_set(GTK_CONTAINER(priv->function_stack), GTK_WIDGET(priv->time_tracker),
		"icon-name", "document-open-recent-symbolic", NULL);

	g_autoptr(GSettings) settings = g_settings_new("io.partin.tristan.HarvestAlmanac");
	const char *harvest_api_access_token
		= g_settings_get_string(settings, "harvest-api-access-token");
	const char *harvest_api_contact_email
		= g_settings_get_string(settings, "harvest-api-contact-email");

	GActionMap *map = G_ACTION_MAP(self);
	if ((harvest_api_access_token != NULL && strlen(harvest_api_access_token) != 0)
		&& (harvest_api_contact_email != NULL || strlen(harvest_api_contact_email) != 0)) {
		GAction *show_content = g_action_map_lookup_action(map, "show-content");
		g_action_activate(show_content, NULL);
	} else {
		GAction *show_content = g_action_map_lookup_action(map, "hide-content");
		g_action_activate(show_content, NULL);
	}

	gtk_widget_set_sensitive(GTK_WIDGET(priv->function_wide_switcher), FALSE);
	gtk_widget_set_sensitive(GTK_WIDGET(priv->function_narrow_switcher), FALSE);
	gtk_widget_set_sensitive(GTK_WIDGET(priv->function_switcher_bar), FALSE);

	g_object_bind_property_full(priv->function_squeezer, "visible-child",
		priv->function_switcher_bar, "reveal", G_BINDING_SYNC_CREATE,
		hal_window_is_title_label_visible, NULL, priv->title_label, NULL);
}

HalWindow *
hal_window_new(GApplication *app)
{
	return g_object_new(HAL_TYPE_WINDOW, "application", app, NULL);
}

A  => harvest-almanac/hal-window.h +13 -0
@@ 1,13 @@
#pragma once

#include <glib-object.h>
#include <gtk/gtk.h>

#define HAL_TYPE_WINDOW (hal_window_get_type())
G_DECLARE_FINAL_TYPE(HalWindow, hal_window, HAL, WINDOW, GtkApplicationWindow)

G_BEGIN_DECLS

HalWindow *hal_window_new(GApplication *app) G_GNUC_WARN_UNUSED_RESULT;

G_END_DECLS

A  => harvest-almanac/harvest-almanac.doap +26 -0
@@ 1,26 @@
<Project xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
         xmlns:foaf="http://xmlns.com/foaf/0.1/"
         xmlns:gnome="http://api.gnome.org/doap-extensions#"
         xmlns="http://usefulinc.com/ns/doap#">

  <name xml:lang="en">Harvest Almanac</name>
  <shortdesc xml:lang="en">A Harvest client for Linux</shortdesc>
  <description>If you have used Harvest in the past, you have probably used their
Mobile, Mac, and/or Windows clients. Unfortunately, Harvest does not provide
a Linux client. Harvest Almanac aims to be the client for Linux.
  </description>

  <homepage rdf:resource="https://git.sr.ht/~tristan957/harvest-almanac" />
  <download-page rdf:resource="https://git.sr.ht/~tristan957/harvest-almanac/refs" />
  <bug-database rdf:resource="https://todo.sr.ht/~tristan957/harvest-almanac" />

  <category rdf:resource="http://api.gnome.org/doap-extensions#core" />
  <programming-language>C</programming-language>

  <maintainer>
    <foaf:Person>
      <foaf:name>Tristan Partin</foaf:name>
    </foaf:Person>
  </maintainer>
</Project>

A  => harvest-almanac/main.c +35 -0
@@ 1,35 @@
#include "config.h"

#define G_LOG_DOMAIN "HarvestAlmanac"

#include <locale.h>

#include <glib-object.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <handy.h>

#include "hal-application.h"

int
main(int argc, char *argv[])
{
	setlocale(LC_ALL, "");
	bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
	textdomain(GETTEXT_PACKAGE);

	g_autoptr(HalApplication) app = hal_application_new("io.partin.tristan.HarvestAlmanac");

	g_set_application_name(_("Harvest Almanac"));

	const gboolean success = hdy_init(&argc, &argv);
	if (!success) {
		g_log(G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, "Unable to initialize libhandy");
		return 1;
	}

	const int status = g_application_run(G_APPLICATION(app), argc, argv);

	return status;
}

A  => harvest-almanac/meson.build +58 -0
@@ 1,58 @@
harvest_almanac_config_h = configuration_data({
    'PACKAGE_NAME': '"@0@"'.format('Harvest Almanac'),
    'PACKAGE_VERSION': '"@0@"'.format(meson.project_version()),
    'GETTEXT_PACKAGE': '"@0@"'.format(meson.project_name()),
    'LOCALEDIR': '"@0@"'.format(join_paths(get_option('prefix'), get_option('localedir'))),
    'LIBDIR': '"@0@"'.format(join_paths(get_option('prefix'), get_option('libdir'))),
    'PACKAGE_LICENSE': 'GTK_LICENSE_GPL_3_0_ONLY',
    'PACKAGE_WEBSITE': '"@0@"'.format('https://git.sr.ht/~tristan957/harvest-almanac'),
    'PACKAGE_WEBSITE_LABEL': '"@0@"'.format('Repository'),
})

configure_file(
    output: 'config.h',
    configuration: harvest_almanac_config_h,
)

harvest_almanac_sources = [
    'main.c',
    'hal-application.c',
    'hal-preferences-window.c',
    'hal-profile.c',
    'hal-time-entry.c',
    'hal-time-tracker.c',
    'hal-window.c',
]

harvest_almanac_c_args = [
    '-DHANDY_USE_UNSTABLE_API',
]

if get_option('buildtype') == 'release'
    harvest_almanac_c_args += [
        '-DG_DISABLE_ASSERT',
        '-DG_DISABLE_CHECKS',
        '-DG_DISABLE_CAST_CHECKS',
    ]
elif get_option('buildtype').startswith('debug')
    harvest_almanac_c_args += [
        '-DG_ENABLE_DEBUG',
    ]
endif

harvest_almanac_dependencies = [
    libgtk_dep,
    libhandy_dep,
    libsecret_dep,
    libsoup_dep,
    harvest_glib_dep,
]

executable(
    'harvest-almanac',
    harvest_almanac_sources + harvest_almanac_resources,
    c_args: harvest_almanac_c_args,
    dependencies: harvest_almanac_dependencies,
    gui_app: true,
    install: true,
)

A  => harvest-glib/config.h +3 -0
@@ 1,3 @@
#pragma once

#define GETTEXT_PACKAGE "harvest-glib"

A  => harvest-glib/harvest-api-client.c +233 -0
@@ 1,233 @@
#include "config.h"
#define G_LOG_DOMAIN "HarvestApiClient"

#include <limits.h>

#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <json-glib/json-glib.h>
#include <libsoup/soup.h>

#include "harvest-api-client.h"
#include "harvest-common.h"
#include "harvest-error.h"
#include "harvest-http.h"
#include "harvest-request.h"
#include "harvest-response-metadata.h"
#include "harvest-response.h"

#define HARVEST_API_URL_V2 "https://api.harvestapp.com/v2"

static HarvestApiClient *v2_instance;

typedef struct HarvestAsyncCallbackData
{
	GType body_type;
	HttpStatusCode expected_status;
	HarvestAsyncCallback callback;
	gpointer user_data;
} HarvestAsyncCallbackData;

struct _HarvestApiClient
{
	GObject parent_instance;

	SoupSession *session;
	const char *server;
	char *access_token;
	char *account_id;
	char *application_name;
	char *contact_info;
};

G_DEFINE_TYPE(HarvestApiClient, harvest_api_client, G_TYPE_OBJECT)

enum HarvestApiClientProps
{
	PROP_0,
	PROP_SESSION,
	PROP_SERVER,
	PROP_ACCESS_TOKEN,
	PROP_ACCOUNT_ID,
	N_PROPS,
};

static GParamSpec *obj_properties[N_PROPS];

static void
harvest_api_client_get_property(GObject *obj, guint prop_id, GValue *val, GParamSpec *pspec)
{
	HarvestApiClient *self = HARVEST_API_CLIENT(obj);

	switch (prop_id) {
	case PROP_SESSION:
		g_value_set_object(val, self->session);
		break;
	case PROP_SERVER:
		g_value_set_string(val, self->server);
		break;
	case PROP_ACCESS_TOKEN:
		g_value_set_string(val, self->access_token);
		break;
	case PROP_ACCOUNT_ID:
		g_value_set_string(val, self->account_id);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
		break;
	}
}

static void
harvest_api_client_set_property(GObject *obj, guint prop_id, const GValue *val, GParamSpec *pspec)
{
	HarvestApiClient *self = HARVEST_API_CLIENT(obj);

	switch (prop_id) {
	case PROP_SESSION:
		if (self->session != NULL)
			g_object_unref(self->session);
		self->session = g_value_dup_object(val);
		break;
	case PROP_SERVER:
		self->server = g_value_get_string(val);
		break;
	case PROP_ACCESS_TOKEN:
		g_free(self->access_token);
		self->access_token = g_strdup_printf("Bearer %s", g_value_get_string(val));
		break;
	case PROP_ACCOUNT_ID:
		g_free(self->account_id);
		self->account_id = g_strdup_printf("%u", g_value_get_uint(val));
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
		break;
	}
}

static void
harvest_api_client_finalize(GObject *obj)
{
	HarvestApiClient *self = HARVEST_API_CLIENT(obj);

	g_free(self->access_token);
	g_free(self->account_id);
	g_free(self->application_name);
	g_free(self->contact_info);

	G_OBJECT_CLASS(harvest_api_client_parent_class)->finalize(obj);
}

static void
harvest_api_client_class_init(HarvestApiClientClass *klass)
{
	GObjectClass *obj_class = G_OBJECT_CLASS(klass);

	obj_class->finalize		= harvest_api_client_finalize;
	obj_class->get_property = harvest_api_client_get_property;
	obj_class->set_property = harvest_api_client_set_property;

	obj_properties[PROP_SESSION] = g_param_spec_object("session", _("Session"),
		_("SoupSession object to use to make requests."), SOUP_TYPE_SESSION,
		G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_SERVER]
		= g_param_spec_string("server", _("Server"), _("Location of the server"), NULL,
			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_ACCESS_TOKEN] = g_param_spec_string("access-token", _("Access Token"),
		_("Developer access token for the Harvest API."), NULL,
		G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_ACCOUNT_ID]
		= g_param_spec_uint("account-id", _("Account ID"), _("Harvest account ID to use."), 1,
			UINT_MAX, 1, G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);

	g_object_class_install_properties(obj_class, N_PROPS, obj_properties);
}

static void
harvest_api_client_init(G_GNUC_UNUSED HarvestApiClient *self)
{}

HarvestApiClient *
harvest_api_client_v2_new(SoupSession *session, const char *access_token, unsigned int account_id)
{
	g_return_val_if_fail(
		!SOUP_IS_SESSION(session) || access_token == NULL || account_id == 0, NULL);

	if (v2_instance != NULL) {
		v2_instance = g_object_new(HARVEST_TYPE_API_CLIENT, "session", session, "server",
			HARVEST_API_URL_V2, "access-token", access_token, "account-id", account_id, NULL);
	}

	return v2_instance;
}

static void
harvest_api_client_async_callback(
	G_GNUC_UNUSED SoupSession *Session, SoupMessage *msg, gpointer user_data)
{
	GObject *body				   = NULL;
	GError *err					   = NULL;
	HarvestAsyncCallbackData *data = user_data;

	if (data->body_type != G_TYPE_NONE) {
		g_autoptr(SoupBuffer) buf = soup_message_body_flatten(msg->response_body);
		g_autoptr(GBytes) bytes   = soup_buffer_get_as_bytes(buf);

		gsize size				= 0;
		gconstpointer body_data = g_bytes_get_data(bytes, &size);
		body					= json_gobject_from_data(data->body_type, body_data, size, &err);
	}

	HarvestResponse *response = harvest_response_new(body, msg->status_code, err);

	data->callback(response);
}

void
harvest_api_client_execute_request_async(
	HarvestApiClient *self, HarvestRequest *req, HarvestAsyncCallback callback, gpointer user_data)
{
	g_return_if_fail(HARVEST_IS_API_CLIENT(self) && HARVEST_IS_REQUEST(req));

	g_autoptr(SoupMessage) msg = NULL;
	g_autoptr(GString) uri	 = g_string_new(NULL);
	g_string_append_printf(uri, "%s%s", self->server, harvest_request_get_endpoint(req));
	gboolean response_has_body = harvest_request_get_data(req) != NULL;
	char *body				   = NULL;
	gsize len				   = 0;
	if (response_has_body) {
		body = json_gobject_to_data(harvest_request_get_data(req), &len);
		len  = strlen(body);
	}

	switch (harvest_request_get_http_method(req)) {
	case HTTP_METHOD_GET:
		msg = soup_message_new("GET", uri->str);
		soup_message_set_request(
			msg, response_has_body ? "application/json" : NULL, SOUP_MEMORY_TAKE, body, len);
		break;
	case HTTP_METHOD_POST:
		break;
	case HTTP_METHOD_PATCH:
		break;
	case HTTP_METHOD_PUT:
		break;
	case HTTP_METHOD_DELETE:
		break;
	default:
		g_return_if_reached();
	}

	soup_message_headers_append(msg->request_headers, "Authorization", self->access_token);
	soup_message_headers_append(msg->request_headers, "Harvest-Account-Id", self->account_id);

	HarvestResponseMetadata *meta  = harvest_request_get_response_metadata(req);
	HarvestAsyncCallbackData *data = g_malloc(sizeof(HarvestAsyncCallbackData));
	data->body_type				   = harvest_response_metadata_get_body_type(meta);
	data->expected_status		   = harvest_response_metadata_get_expected_status(meta);
	data->callback				   = callback;
	data->user_data				   = user_data;

	soup_session_queue_message(self->session, msg, harvest_api_client_async_callback, data);
}

A  => harvest-glib/harvest-api-client.h +31 -0
@@ 1,31 @@
#pragma once

#if !defined(__HARVEST_HEADER_INTERNAL__) && !defined(__HARVEST_COMPILATION__)
#	error "Only <harvest-glib/harvest.h> can be included directly."
#endif

#include <glib-object.h>
#include <libsoup/soup.h>

#include "harvest-request.h"
#include "harvest-response.h"

G_BEGIN_DECLS

#define HARVEST_TYPE_API_CLIENT (harvest_api_client_get_type())
G_DECLARE_FINAL_TYPE(HarvestApiClient, harvest_api_client, HARVEST, API_CLIENT, GObject)

typedef gboolean (*HarvestAsyncCallback)(HarvestResponse *response);

typedef enum HarvestApiVersion
{
	HARVEST_API_V2 = 2,
} HarvestApiVersion;

HarvestApiClient *harvest_api_client_v2_new(SoupSession *session, const char *access_token,
	unsigned int account_id) G_GNUC_WARN_UNUSED_RESULT;
HarvestApiClient *harvest_api_client_get_instance(const HarvestApiVersion version) G_GNUC_CONST;
void harvest_api_client_execute_request_async(
	HarvestApiClient *self, HarvestRequest *req, HarvestAsyncCallback callback, gpointer user_data);

G_END_DECLS

A  => harvest-glib/harvest-client.c +198 -0
@@ 1,198 @@
#include "config.h"
#define G_LOG_DOMAIN "HarvestClient"

#include <limits.h>

#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <json-glib/json-glib.h>

#include "harvest-client.h"

struct _HarvestClient
{
	GObject parent_instance;

	int id;
	char *name;
	gboolean is_active : 1;
	char *address;
	char *currency;
	GDateTime *created_at;
	GDateTime *updated_at;
};

static void harvest_client_json_serializable_init(JsonSerializableIface *iface);

G_DEFINE_TYPE_WITH_CODE(HarvestClient, harvest_client, G_TYPE_OBJECT,
	G_IMPLEMENT_INTERFACE(JSON_TYPE_SERIALIZABLE, harvest_client_json_serializable_init))

enum HarvestClientProps
{
	PROP_0,
	PROP_ID,
	PROP_NAME,
	PROP_IS_ACTIVE,
	PROP_ADDRESS,
	PROP_CURRENCY,
	PROP_CREATED_AT,
	PROP_UPDATED_AT,
	N_PROPS,
};

static GParamSpec *obj_properties[N_PROPS];

static gboolean
harvest_client_json_deserialize_property(JsonSerializable *serializable, const gchar *prop_name,
	GValue *val, GParamSpec *pspec, JsonNode *prop_node)
{
	if (g_strcmp0(prop_name, "created_at") == 0 || g_strcmp0(prop_name, "updated_at") == 0) {
		const gchar *ds = json_node_get_string(prop_node);
		if (ds == NULL) {
			g_value_set_boxed(val, NULL);

			return TRUE;
		}

		const GDateTime *dt = g_date_time_new_from_iso8601(ds, NULL);
		g_value_set_boxed(val, dt);

		return TRUE;
	}

	return json_serializable_default_deserialize_property(
		serializable, prop_name, val, pspec, prop_node);
}

static void
harvest_client_json_serializable_init(JsonSerializableIface *iface)
{
	iface->deserialize_property = harvest_client_json_deserialize_property;
}

static void
harvest_client_finalize(GObject *obj)
{
	HarvestClient *self = HARVEST_CLIENT(obj);

	g_free(self->name);
	g_free(self->address);
	g_free(self->currency);
	if (self->created_at != NULL)
		g_date_time_unref(self->created_at);
	if (self->updated_at != NULL)
		g_date_time_unref(self->updated_at);

	G_OBJECT_CLASS(harvest_client_parent_class)->finalize(obj);
}

static void
harvest_client_get_property(GObject *obj, guint prop_id, GValue *val, GParamSpec *pspec)
{
	HarvestClient *self = HARVEST_CLIENT(obj);

	switch (prop_id) {
	case PROP_ID:
		g_value_set_int(val, self->id);
		break;
	case PROP_NAME:
		g_value_set_string(val, self->name);
		break;
	case PROP_IS_ACTIVE:
		g_value_set_boolean(val, self->is_active);
		break;
	case PROP_ADDRESS:
		g_value_set_string(val, self->address);
		break;
	case PROP_CURRENCY:
		g_value_set_string(val, self->currency);
		break;
	case PROP_CREATED_AT:
		g_value_set_boxed(val, self->created_at);
		break;
	case PROP_UPDATED_AT:
		g_value_set_boxed(val, self->updated_at);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
		break;
	}
}

static void
harvest_client_set_property(GObject *obj, guint prop_id, const GValue *val, GParamSpec *pspec)
{
	HarvestClient *self = HARVEST_CLIENT(obj);

	switch (prop_id) {
	case PROP_ID:
		self->id = g_value_get_int(val);
		break;
	case PROP_NAME:
		g_free(self->name);
		self->name = g_value_dup_string(val);
		break;
	case PROP_IS_ACTIVE:
		self->is_active = g_value_get_boolean(val);
		break;
	case PROP_ADDRESS:
		g_free(self->address);
		self->address = g_value_dup_string(val);
		break;
	case PROP_CURRENCY:
		g_free(self->currency);
		self->currency = g_value_dup_string(val);
		break;
	case PROP_CREATED_AT:
		if (self->created_at != NULL)
			g_date_time_unref(self->created_at);
		self->created_at = g_value_dup_boxed(val);
		break;
	case PROP_UPDATED_AT:

		if (self->updated_at != NULL)
			g_date_time_unref(self->updated_at);
		self->updated_at = g_value_dup_boxed(val);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
		break;
	}
}

static void
harvest_client_class_init(HarvestClientClass *klass)
{
	GObjectClass *obj_class = G_OBJECT_CLASS(klass);

	obj_class->finalize		= harvest_client_finalize;
	obj_class->get_property = harvest_client_get_property;
	obj_class->set_property = harvest_client_set_property;

	obj_properties[PROP_ID] = g_param_spec_int("id", _("ID"), _("Unique ID for the client."), 0,
		INT_MAX, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
	obj_properties[PROP_NAME]
		= g_param_spec_string("name", _("Name"), _("A textual description of the client."), NULL,
			G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_IS_ACTIVE] = g_param_spec_boolean("is_active", _("Is Active"),
		_("Whether the client is active or archived."), TRUE,
		G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
	obj_properties[PROP_ADDRESS]
		= g_param_spec_string("address", _("Address"), _("The physical address for the client."),
			NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_CURRENCY]   = g_param_spec_string("currency", _("Currency"),
		  _("The currency code associated with this client."), NULL,
		  G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_CREATED_AT] = g_param_spec_boxed("created_at", _("Created At"),
		_("Date and time the client was created."), G_TYPE_DATE_TIME,
		G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_UPDATED_AT] = g_param_spec_boxed("updated_at", _("Updated At"),
		_("Date and time the client was last updated."), G_TYPE_DATE_TIME,
		G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);

	g_object_class_install_properties(obj_class, N_PROPS, obj_properties);
}

static void
harvest_client_init(G_GNUC_UNUSED HarvestClient *self)
{}

A  => harvest-glib/harvest-client.h +10 -0
@@ 1,10 @@
#pragma once

#if !defined(__HARVEST_HEADER_INTERNAL__) && !defined(__HARVEST_COMPILATION__)
#	error "Only <harvest-glib/harvest.h> can be included directly."
#endif

#include <glib-object.h>

#define HARVEST_TYPE_CLIENT (harvest_client_get_type())
G_DECLARE_FINAL_TYPE(HarvestClient, harvest_client, HARVEST, CLIENT, GObject)

A  => harvest-glib/harvest-common.c +39 -0
@@ 1,39 @@
#include "config.h"

#define G_LOG_DOMAIN "HarvestCommon"

#include <glib-object.h>

#include "harvest-common.h"

// Never gets unrefed
static const GRegex *regex;
static const unsigned int HARVEST_DATE_EXPECTED_MATCHES = 4;

GDateTime *
g_date_time_new_from_abbreviated_date(const char *date)
{
	g_return_val_if_fail(date != NULL, NULL);

	// Compile once to save time
	if (regex == NULL)
		regex = g_regex_new("(\\d+)-(\\d){1,2}-(\\d){1,2}", 0, 0, NULL);

	GMatchInfo *match_info;
	const gboolean found = g_regex_match(regex, date, 0, &match_info);
	if (!found || match_info == NULL)
		return NULL;

	gchar **matches = g_match_info_fetch_all(match_info);
	if (matches == NULL || g_match_info_get_match_count(match_info) != HARVEST_DATE_EXPECTED_MATCHES
		|| matches[1] == NULL || matches[2] == NULL || matches[3] == NULL)
		return NULL;

	GDateTime *dt
		= g_date_time_new(NULL, atoi(matches[1]), atoi(matches[2]), atoi(matches[3]), 0, 0, 0);

	g_strfreev(matches);
	g_match_info_unref(match_info);

	return dt;
}

A  => harvest-glib/harvest-common.h +13 -0
@@ 1,13 @@
#pragma once

#if !defined(__HARVEST_HEADER_INTERNAL__) && !defined(__HARVEST_COMPILATION__)
#	error "Only <harvest-glib/harvest.h> can be included directly."
#endif

#include <glib-object.h>

G_BEGIN_DECLS

GDateTime *g_date_time_new_from_abbreviated_date(const char *date);

G_END_DECLS

A  => harvest-glib/harvest-creator.c +97 -0
@@ 1,97 @@
#include "config.h"
#define G_LOG_DOMAIN "HarvestCreator"

#include <limits.h>

#include <glib-object.h>
#include <glib/gi18n-lib.h>

#include "harvest-creator.h"

struct _HarvestCreator
{
	GObject parent_instance;

	int id;
	char *name;
};

G_DEFINE_TYPE(HarvestCreator, harvest_creator, G_TYPE_OBJECT);

enum HarvestCreatorProps
{
	PROP_0,
	PROP_ID,
	PROP_NAME,
	N_PROPS,
};

static GParamSpec *obj_properties[N_PROPS];

static void
harvest_creator_finalize(GObject *obj)
{
	HarvestCreator *self = HARVEST_CREATOR(obj);

	g_free(self->name);

	G_OBJECT_CLASS(harvest_creator_parent_class)->finalize(obj);
}

static void
harvest_creator_get_property(GObject *obj, guint prop_id, GValue *val, GParamSpec *pspec)
{
	HarvestCreator *self = HARVEST_CREATOR(obj);

	switch (prop_id) {
	case PROP_ID:
		g_value_set_int(val, self->id);
		break;
	case PROP_NAME:
		g_value_set_string(val, self->name);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
		break;
	}
}

static void
harvest_creator_set_property(GObject *obj, guint prop_id, const GValue *val, GParamSpec *pspec)
{
	HarvestCreator *self = HARVEST_CREATOR(obj);

	switch (prop_id) {
	case PROP_ID:
		self->id = g_value_get_int(val);
		break;
	case PROP_NAME:
		g_free(self->name);
		self->name = g_value_dup_string(val);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
		break;
	}
}

static void
harvest_creator_class_init(HarvestCreatorClass *klass)
{
	GObjectClass *obj_class = G_OBJECT_CLASS(klass);

	obj_class->finalize		= harvest_creator_finalize;
	obj_class->get_property = harvest_creator_get_property;
	obj_class->set_property = harvest_creator_set_property;

	obj_properties[PROP_ID]   = g_param_spec_int("id", _("ID"), _("Unique ID for the creator."), 0,
		  INT_MAX, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_NAME] = g_param_spec_string("name", _("Name"), _("Name of the creator."),
		NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);

	g_object_class_install_properties(obj_class, N_PROPS, obj_properties);
}

static void
harvest_creator_init(G_GNUC_UNUSED HarvestCreator *self)
{}

A  => harvest-glib/harvest-creator.h +14 -0
@@ 1,14 @@
#pragma once

#if !defined(__HARVEST_HEADER_INTERNAL__) && !defined(__HARVEST_COMPILATION__)
#	error "Only <harvest-glib/harvest.h> can be included directly."
#endif

#include <glib-object.h>

G_BEGIN_DECLS

#define HARVEST_TYPE_CREATOR (harvest_creator_get_type())
G_DECLARE_FINAL_TYPE(HarvestCreator, harvest_creator, HARVEST, CREATOR, GObject);

G_END_DECLS

A  => harvest-glib/harvest-error.h +19 -0
@@ 1,19 @@
#pragma once

#if !defined(__HARVEST_HEADER_INTERNAL__) && !defined(__HARVEST_COMPILATION__)
#	error "Only <harvest-glib/harvest.h> can be included directly."
#endif

#include <glib-object.h>

G_BEGIN_DECLS

typedef enum HarvestErrorCode
{
	ERROR_MEM,
	ERROR_JSON,
} HarvestCpErrorCode;

G_DEFINE_QUARK("libharvest-glib", harvest_error)

G_END_DECLS

A  => harvest-glib/harvest-estimate-item-category.c +158 -0
@@ 1,158 @@
#include "config.h"
#define G_LOG_DOMAIN "HarvestEstimateItemCategory"

#include <limits.h>

#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <json-glib/json-glib.h>

#include "harvest-estimate-item-category.h"

struct _HarvestEstimateItemCategory
{
	GObject parent_instance;

	int id;
	char *name;
	GDateTime *created_at;
	GDateTime *updated_at;
};

static void harvest_estimate_item_category_json_serializable_init(JsonSerializableIface *iface);

G_DEFINE_TYPE_WITH_CODE(HarvestEstimateItemCategory, harvest_estimate_item_category, G_TYPE_OBJECT,
	G_IMPLEMENT_INTERFACE(
		JSON_TYPE_SERIALIZABLE, harvest_estimate_item_category_json_serializable_init))

enum HarvestEstimateItemCategoryProps
{
	PROP_0,
	PROP_ID,
	PROP_NAME,
	PROP_CREATED_AT,
	PROP_UPDATED_AT,
	N_PROPS,
};

static GParamSpec *obj_properties[N_PROPS];

static gboolean
harvest_estimate_item_category_deserialize_property(JsonSerializable *serializable,
	const gchar *prop_name, GValue *val, GParamSpec *pspec, JsonNode *prop_node)
{
	if (g_strcmp0(prop_name, "created_at") == 0 || g_strcmp0(prop_name, "updated_at") == 0) {
		const GDateTime *dt = g_date_time_new_from_iso8601(json_node_get_string(prop_node), NULL);
		g_value_set_boxed(val, dt);

		return TRUE;
	}

	return json_serializable_default_deserialize_property(
		serializable, prop_name, val, pspec, prop_node);
}

static void
harvest_estimate_item_category_json_serializable_init(JsonSerializableIface *iface)
{
	iface->deserialize_property = harvest_estimate_item_category_deserialize_property;
}

static void
harvest_estimate_item_category_finalize(GObject *obj)
{
	HarvestEstimateItemCategory *self = HARVEST_ESTIMATE_ITEM_CATEGORY(obj);

	g_free(self->name);
	if (self->created_at != NULL)
		g_date_time_unref(self->created_at);
	if (self->updated_at != NULL)
		g_date_time_unref(self->updated_at);

	G_OBJECT_CLASS(harvest_estimate_item_category_parent_class)->finalize(obj);
}

static void
harvest_estimate_item_category_get_property(
	GObject *obj, guint prop_id, GValue *val, GParamSpec *pspec)
{
	HarvestEstimateItemCategory *self = HARVEST_ESTIMATE_ITEM_CATEGORY(obj);

	switch (prop_id) {
	case PROP_ID:
		g_value_set_int(val, self->id);
		break;
	case PROP_NAME:
		g_value_set_string(val, self->name);
		break;
	case PROP_CREATED_AT:
		g_value_set_boxed(val, self->created_at);
		break;
	case PROP_UPDATED_AT:
		g_value_set_boxed(val, self->updated_at);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
		break;
	}
}

static void
harvest_estimate_item_category_set_property(
	GObject *obj, guint prop_id, const GValue *val, GParamSpec *pspec)
{
	HarvestEstimateItemCategory *self = HARVEST_ESTIMATE_ITEM_CATEGORY(obj);

	switch (prop_id) {
	case PROP_ID:
		self->id = g_value_get_int(val);
		break;
	case PROP_NAME:
		g_free(self->name);
		self->name = g_value_dup_string(val);
		break;
	case PROP_CREATED_AT:
		if (self->created_at != NULL)
			g_date_time_unref(self->created_at);
		self->created_at = g_value_dup_boxed(val);
		break;
	case PROP_UPDATED_AT:

		if (self->updated_at != NULL)
			g_date_time_unref(self->updated_at);
		self->updated_at = g_value_dup_boxed(val);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
		break;
	}
}

static void
harvest_estimate_item_category_class_init(HarvestEstimateItemCategoryClass *klass)
{
	GObjectClass *obj_class = G_OBJECT_CLASS(klass);

	obj_class->finalize		= harvest_estimate_item_category_finalize;
	obj_class->get_property = harvest_estimate_item_category_get_property;
	obj_class->set_property = harvest_estimate_item_category_set_property;

	obj_properties[PROP_ID]
		= g_param_spec_int("id", _("ID"), _("Unique ID for the estimate item category."), 0,
			INT_MAX, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_NAME]
		= g_param_spec_string("name", _("Name"), _("The name of the estimate item category."), NULL,
			G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_CREATED_AT] = g_param_spec_boxed("created_at", _("Created At"),
		_("Date and time the estimate item category was created."), G_TYPE_DATE_TIME,
		G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_UPDATED_AT] = g_param_spec_boxed("updated_at", _("Updated At"),
		_("Date and time the estimate item category was last updated."), G_TYPE_DATE_TIME,
		G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);

	g_object_class_install_properties(obj_class, N_PROPS, obj_properties);
}

static void
harvest_estimate_item_category_init(G_GNUC_UNUSED HarvestEstimateItemCategory *self)
{}

A  => harvest-glib/harvest-estimate-item-category.h +15 -0
@@ 1,15 @@
#pragma once

#if !defined(__HARVEST_HEADER_INTERNAL__) && !defined(__HARVEST_COMPILATION__)
#	error "Only <harvest-glib/harvest.h> can be included directly."
#endif

#include <glib-object.h>

G_BEGIN_DECLS

#define HARVEST_TYPE_ESTIMATE_ITEM_CATEGORY (harvest_estimate_item_category_get_type())
G_DECLARE_FINAL_TYPE(HarvestEstimateItemCategory, harvest_estimate_item_category, HARVEST,
	ESTIMATE_ITEM_CATEGORY, GObject)

G_END_DECLS

A  => harvest-glib/harvest-estimate-line-item.c +166 -0
@@ 1,166 @@
#include "config.h"
#define G_LOG_DOMAIN "HarvestEstimateLineItem"

#include <float.h>
#include <limits.h>

#include <glib-object.h>
#include <glib/gi18n-lib.h>

#include "harvest-estimate-line-item.h"

struct _HarvestEstimateLineItem
{
	GObject parent_instance;

	int id;
	char *kind;
	char *description;
	int quantity;
	double unit_price;
	double amount;
	gboolean taxed : 1;
	gboolean taxed2 : 1;
};

G_DEFINE_TYPE(HarvestEstimateLineItem, harvest_estimate_line_item, G_TYPE_OBJECT)

enum HarvestEstimateLineItemProps
{
	PROP_0,
	PROP_ID,
	PROP_KIND,
	PROP_DESCRIPTION,
	PROP_QUANTITY,
	PROP_UNIT_PRICE,
	PROP_AMOUNT,
	PROP_TAXED,
	PROP_TAXED2,
	N_PROPS,
};

static GParamSpec *obj_properties[N_PROPS];

static void
harvest_estimate_line_item_finalize(GObject *obj)
{
	HarvestEstimateLineItem *self = HARVEST_ESTIMATE_LINE_ITEM(obj);

	g_free(self->kind);
	g_free(self->description);

	G_OBJECT_CLASS(harvest_estimate_line_item_parent_class)->finalize(obj);
}

static void
harvest_estimate_line_item_get_property(GObject *obj, guint prop_id, GValue *val, GParamSpec *pspec)
{
	HarvestEstimateLineItem *self = HARVEST_ESTIMATE_LINE_ITEM(obj);

	switch (prop_id) {
	case PROP_ID:
		g_value_set_int(val, self->id);
		break;
	case PROP_KIND:
		g_value_set_string(val, self->kind);
		break;
	case PROP_DESCRIPTION:
		g_value_set_string(val, self->description);
		break;
	case PROP_QUANTITY:
		g_value_set_int(val, self->quantity);
		break;
	case PROP_UNIT_PRICE:
		g_value_set_double(val, self->unit_price);
		break;
	case PROP_AMOUNT:
		g_value_set_double(val, self->amount);
		break;
	case PROP_TAXED:
		g_value_set_boolean(val, self->taxed);
		break;
	case PROP_TAXED2:
		g_value_set_boolean(val, self->taxed2);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
	}
}

static void
harvest_estimate_line_item_set_property(
	GObject *obj, guint prop_id, const GValue *val, GParamSpec *pspec)
{
	HarvestEstimateLineItem *self = HARVEST_ESTIMATE_LINE_ITEM(obj);

	switch (prop_id) {
	case PROP_ID:
		self->id = g_value_get_int(val);
		break;
	case PROP_KIND:
		g_free(self->kind);
		self->kind = g_value_dup_string(val);
		break;
	case PROP_DESCRIPTION:
		g_free(self->description);
		self->description = g_value_dup_string(val);
		break;
	case PROP_QUANTITY:
		self->quantity = g_value_get_int(val);
		break;
	case PROP_UNIT_PRICE:
		self->unit_price = g_value_get_double(val);
		break;
	case PROP_AMOUNT:
		self->amount = g_value_get_double(val);
		break;
	case PROP_TAXED:
		self->taxed = g_value_get_boolean(val);
		break;
	case PROP_TAXED2:
		self->taxed2 = g_value_get_boolean(val);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
	}
}

static void
harvest_estimate_line_item_class_init(HarvestEstimateLineItemClass *klass)
{
	GObjectClass *obj_class = G_OBJECT_CLASS(klass);

	obj_class->finalize		= harvest_estimate_line_item_finalize;
	obj_class->get_property = harvest_estimate_line_item_get_property;
	obj_class->set_property = harvest_estimate_line_item_set_property;

	obj_properties[PROP_ID] = g_param_spec_int("id", _("ID"), _("Unique ID for the line item."), 0,
		INT_MAX, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_KIND]
		= g_param_spec_string("kind", _("Kind"), _("The name of an estimate item category."), NULL,
			G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_DESCRIPTION] = g_param_spec_string("description", _("Description"),
		_("Text description of the line item."), NULL,
		G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_QUANTITY]
		= g_param_spec_int("quantity", _("Quantity"), _("The unit quantity of the item."), 0,
			INT_MAX, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_UNIT_PRICE]
		= g_param_spec_double("unit_price", _("Unit Price"), _("The individual price per unit."), 0,
			DBL_MAX, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_AMOUNT] = g_param_spec_double("amount", _("Amount"),
		_("The line item subtotal (quantity * unit_price)."), 0, DBL_MAX, 0,
		G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_TAXED]  = g_param_spec_boolean("taxed", _("Taxed"),
		 _("Whether the estimate’s tax percentage applies to this line item."), FALSE,
		 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
	obj_properties[PROP_TAXED2] = g_param_spec_boolean("taxed2", _("Taxed2"),
		_("Whether the estimate’s tax2 percentage applies to this line item."), FALSE,
		G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);

	g_object_class_install_properties(obj_class, N_PROPS, obj_properties);
}

static void
harvest_estimate_line_item_init(G_GNUC_UNUSED HarvestEstimateLineItem *self)
{}

A  => harvest-glib/harvest-estimate-line-item.h +15 -0
@@ 1,15 @@
#pragma once

#if !defined(__HARVEST_HEADER_INTERNAL__) && !defined(__HARVEST_COMPILATION__)
#	error "Only <harvest-glib/harvest.h> can be included directly."
#endif

#include <glib-object.h>

G_BEGIN_DECLS

#define HARVEST_TYPE_ESTIMATE_LINE_ITEM (harvest_estimate_line_item_get_type())
G_DECLARE_FINAL_TYPE(
	HarvestEstimateLineItem, harvest_estimate_line_item, HARVEST, ESTIMATE_LINE_ITEM, GObject)

G_END_DECLS

A  => harvest-glib/harvest-estimate.c +493 -0
@@ 1,493 @@
#include "config.h"
#define G_LOG_DOMAIN "HarvestEstimate"

#include <float.h>
#include <limits.h>

#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <json-glib/json-glib.h>

#include "harvest-client.h"
#include "harvest-common.h"
#include "harvest-creator.h"
#include "harvest-estimate-line-item.h"
#include "harvest-estimate.h"

struct _HarvestEstimate
{
	GObject parent_instance;

	int id;
	HarvestClient *client;
	GPtrArray *line_items; // HarvestEstimateLineItem
	HarvestCreator *creator;
	char *client_key;
	char *number;
	char *purchase_order;
	double amount;
	double tax;
	double tax_amount;
	double tax2;
	double tax2_amount;
	double discount;
	double discount_amount;
	char *subject;
	char *notes;
	char *currency;
	HarvestEstimateState state;
	GDateTime *issue_date;
	GDateTime *sent_at;
	GDateTime *accepted_at;
	GDateTime *declined_at;
	GDateTime *created_at;
	GDateTime *updated_at;
};

static void harvest_estimate_json_serializable_init(JsonSerializableIface *iface);

G_DEFINE_TYPE_WITH_CODE(HarvestEstimate, harvest_estimate, G_TYPE_OBJECT,
	G_IMPLEMENT_INTERFACE(JSON_TYPE_SERIALIZABLE, harvest_estimate_json_serializable_init))

enum HarvestEstimateProps
{
	PROP_0,
	PROP_ID,
	PROP_CLIENT,
	PROP_LINE_ITEMS,
	PROP_CREATOR,
	PROP_CLIENT_KEY,
	PROP_NUMBER,
	PROP_PURCHASE_ORDER,
	PROP_AMOUNT,
	PROP_TAX,
	PROP_TAX_AMOUNT,
	PROP_TAX2,
	PROP_TAX2_AMOUNT,
	PROP_DISCOUNT,
	PROP_DISCOUNT_AMOUNT,
	PROP_SUBJECT,
	PROP_NOTES,
	PROP_CURRENCY,
	PROP_STATE,
	PROP_ISSUE_DATE,
	PROP_SENT_AT,
	PROP_ACCEPTED_AT,
	PROP_DECLINED_AT,
	PROP_CREATED_AT,
	PROP_UPDATED_AT,
	N_PROPS,
};

static GParamSpec *obj_properties[N_PROPS];

static void
line_items_for_each(
	G_GNUC_UNUSED JsonArray *array, G_GNUC_UNUSED guint index, JsonNode *node, gpointer user_data)
{
	g_ptr_array_add(user_data, json_gobject_deserialize(HARVEST_TYPE_ESTIMATE_LINE_ITEM, node));
}

static gboolean
harvest_estimate_deserialize_property(JsonSerializable *serializable, const gchar *prop_name,
	GValue *val, GParamSpec *pspec, JsonNode *prop_node)
{
	if (g_strcmp0(prop_name, "client") == 0) {
		GObject *obj = json_gobject_deserialize(HARVEST_TYPE_CLIENT, prop_node);
		g_value_set_object(val, obj);

		return TRUE;
	} else if (g_strcmp0(prop_name, "line_items") == 0) {
		JsonArray *arr	 = json_node_get_array(prop_node);
		const guint length = json_array_get_length(arr);
		GPtrArray *roles   = g_ptr_array_sized_new(length);
		json_array_foreach_element(arr, line_items_for_each, roles);
		g_value_set_boxed(val, roles);

		return TRUE;
	} else if (g_strcmp0(prop_name, "creator") == 0) {
		GObject *obj = json_gobject_deserialize(HARVEST_TYPE_CREATOR, prop_node);
		g_value_set_object(val, obj);

		return TRUE;
	} else if (g_strcmp0(prop_name, "state") == 0) {
		const char *state = json_node_get_string(prop_node);

		if (g_strcmp0(state, "accepted") == 0) {
			g_value_set_int(val, HARVEST_ESTIMATE_STATE_ACCEPTED);
		} else if (g_strcmp0(state, "declined") == 0) {
			g_value_set_int(val, HARVEST_ESTIMATE_STATE_DECLINED);
		} else if (g_strcmp0(state, "draft") == 0) {
			g_value_set_int(val, HARVEST_ESTIMATE_STATE_DRAFT);
		} else if (g_strcmp0(state, "sent")) {
			g_value_set_int(val, HARVEST_ESTIMATE_STATE_SENT);
		} else {
			g_warn_if_reached();
		}

		return TRUE;
	} else if (g_strcmp0(prop_name, "issue_date") == 0) {
		const GDateTime *dt
			= g_date_time_new_from_abbreviated_date(json_node_get_string(prop_node));
		g_value_set_boxed(val, dt);

		return TRUE;
	} else if (g_strcmp0(prop_name, "sent_at") == 0 || g_strcmp0(prop_name, "accepted_at") == 0
			   || g_strcmp0(prop_name, "declined_at") == 0
			   || g_strcmp0(prop_name, "created_at") == 0
			   || g_strcmp0(prop_name, "updated_at") == 0) {
		const GDateTime *dt = g_date_time_new_from_iso8601(json_node_get_string(prop_node), NULL);
		g_value_set_boxed(val, dt);

		return TRUE;
	}

	return json_serializable_default_deserialize_property(
		serializable, prop_name, val, pspec, prop_node);
}

static void
harvest_estimate_json_serializable_init(JsonSerializableIface *iface)
{
	iface->deserialize_property = harvest_estimate_deserialize_property;
}

static void
harvest_estimate_finalize(GObject *obj)
{
	HarvestEstimate *self = HARVEST_ESTIMATE(obj);

	if (self->client != NULL)